Skip to content

Commit

Permalink
Merge pull request #49 from Gloveland/interpretations
Browse files Browse the repository at this point in the history
Interpretations
  • Loading branch information
jazminsofiaf authored Nov 9, 2021
2 parents 94b7a77 + f3a59b8 commit 029f96c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/datacollection/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class SensorMeasurements {
'device_name': deviceName,
'device_id': deviceId,
'word': word,
'measurements_amount': values.length,
'values': values,
'timestamps': timestamps
};
Expand Down
2 changes: 1 addition & 1 deletion lib/edgeimpulse/api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class EdgeImpulseApiClient {
deviceType: "ESP32",
// exact model of the device
//the frequency of the data in this file (in milliseconds). E.g. for 100Hz fill in 10 (new data every 10 ms.)
intervalMs: averageIntervalInMilliseconds.toInt(),
intervalMs: 16,
//mpu6050 Default Internal 8MHz oscillator (register 0x6B = 0) equals to 1.25 milliseconds
sensors: EdgeImpulseApiClient.sensorMeasurementNames,
values: sensorMeasurements.values);
Expand Down
6 changes: 4 additions & 2 deletions lib/pages/ble_data_collection_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ class _BleDataCollectionState extends State<BleDataCollectionPage>
void _stopRecording(BluetoothBackend bluetoothBackend) async {
developer.log('stopRecording');
bluetoothBackend.sendStopCommand();

_isRecording = false;
showDialog(
context: context,
Expand Down Expand Up @@ -198,10 +197,13 @@ class _BleDataCollectionState extends State<BleDataCollectionPage>
}

static List<String> getCategoryList() {
return <String>["Números", "Letras", "Saludo"];
return <String>["Test", "Números", "Letras", "Saludo"];
}

static List<String> getGestureList(String category) {
if (category == "Test") {
return <String>["pointing-up", "pointing-front", "pointing-down", "up-down", "right-left", "idle"];
}
if (category == "Números") {
return <String>["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
}
Expand Down
31 changes: 26 additions & 5 deletions lib/pages/interpretation_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class _InterpretationsPanelState extends State<InterpretationsPanel> {
key: Key(entry.key.id.id),
device: entry.key,
interpretationCharacteristic: entry.value,
measurementsCharacteristic:
backend.dataCollectionCharacteristics[entry.key]!,
));
}
return Column(
Expand All @@ -87,24 +89,28 @@ class _InterpretationsPanelState extends State<InterpretationsPanel> {
class InterpretationWidget extends StatefulWidget {
final BluetoothDevice device;
final BluetoothCharacteristic interpretationCharacteristic;
final BluetoothCharacteristic measurementsCharacteristic;

const InterpretationWidget(
{Key? key,
required this.device,
required this.interpretationCharacteristic})
required this.interpretationCharacteristic,
required this.measurementsCharacteristic})
: super(key: key);

@override
_InterpretationWidgetState createState() =>
_InterpretationWidgetState(device, interpretationCharacteristic);
_InterpretationWidgetState createState() => _InterpretationWidgetState(
device, interpretationCharacteristic, measurementsCharacteristic);
}

class _InterpretationWidgetState extends State<InterpretationWidget> {
static final String TAG = "InterpretationWidget";
final BluetoothDevice device;
final BluetoothCharacteristic interpretationCharacteristic;
final BluetoothCharacteristic dcCharacteristic;

_InterpretationWidgetState(this.device, this.interpretationCharacteristic);
_InterpretationWidgetState(
this.device, this.interpretationCharacteristic, this.dcCharacteristic);

@override
void dispose() {
Expand All @@ -130,7 +136,22 @@ class _InterpretationWidgetState extends State<InterpretationWidget> {
alignment: Alignment.topCenter,
color: Theme.of(context).backgroundColor,
child: Text("Mac addr: ${device.id.id}")),
displayStats()
displayStats(),
StreamBuilder<List<int>>(
stream: dcCharacteristic.value,
initialData: [],
builder: (c, measurements) {
String msg = "";
if (measurements.hasData) {
msg = new String.fromCharCodes(measurements.data!);
}
return Container(
width: double.infinity,
height: 80,
alignment: Alignment.center,
color: Theme.of(c).backgroundColor,
child: Text(msg));
})
],
));
}
Expand Down

0 comments on commit 029f96c

Please sign in to comment.