Skip to content

Commit 3ddd302

Browse files
committed
Added packet type 2 for Healthypi
1 parent bca8fe0 commit 3ddd302

4 files changed

Lines changed: 54 additions & 53 deletions

File tree

.idea/libraries/Flutter_Plugins.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/boards/decoders/healthypi_decoders.dart

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,52 @@ import 'dart:typed_data';
66
import '../../protocol/decoded_packet.dart';
77
import 'shared_codecs.dart';
88

9+
/// HealthyPi 5 (USB) — pktType 2 — Combined ECG, BioZ & PPG single-sample packet.
10+
///
11+
/// Payload layout (22 bytes):
12+
/// [0-3] ecg_sample int32 LE — sign-extended 24-bit ADC value
13+
/// [4-7] bioz_sample int32 LE — bio-impedance / respiration waveform
14+
/// [8] bioZSkipSample uint8 — 0 = valid BioZ; 1 = skip (do not plot/process)
15+
/// [9-12] raw_red int32 LE — PPG red-channel raw photodiode counts
16+
/// [13-16] raw_ir int32 LE — PPG IR-channel raw photodiode counts
17+
/// [17-18] temp int16 LE — °C × 100 (only low 16 bits of int32 used;
18+
/// e.g. 3650 → 36.50 °C)
19+
/// [19] spo2 uint8 — SpO₂ in %
20+
/// [20] hr uint8 — heart rate in bpm
21+
/// [21] rr uint8 — respiration rate in breaths/min
22+
///
23+
/// Note: bioz_sample is always emitted in channelSamples. Consumers must check
24+
/// the 'bioZSkip' event flag (1 = invalid) before plotting or processing the
25+
/// 'bioz' channel for this sample.
26+
DecodedPacket decodeHealthypiPkt2(Uint8List p) {
27+
final ecgSample = Codec.readInt32LE(p, 0).toDouble();
28+
final biozSample = Codec.readInt32LE(p, 4).toDouble();
29+
final bioZSkip = p[8] != 0; // true → firmware says skip this BioZ sample
30+
final rawRed = Codec.readInt32LE(p, 9).toDouble();
31+
final rawIr = Codec.readInt32LE(p, 13).toDouble();
32+
final temp = Codec.readInt16LE(p, 17).toDouble() / 100.0;
33+
final spo2 = p[19];
34+
final hr = p[20];
35+
final rr = p[21];
36+
37+
return DecodedPacket(
38+
pktType: 2,
39+
channelSamples: {
40+
'ecg': [ecgSample],
41+
'bioz': [biozSample], // check events['bioZSkip'] before using
42+
'ppgRed': [rawRed],
43+
'ppgIr': [rawIr],
44+
},
45+
events: {
46+
'heartRate': hr,
47+
'respRate': rr,
48+
'spo2': spo2,
49+
'temperature': temp,
50+
'bioZSkip': bioZSkip ? 1 : 0,
51+
},
52+
);
53+
}
54+
955
// ── HealthyPi 5 firmware v1.0.0+ (USB) — separate ECG/BioZ and PPG packets ──
1056
//
1157
// HealthyPi 5's USB stream batches samples into two framed packet types (see

lib/boards/descriptors/healthypi.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ final BoardDescriptor healthypiDescriptor = BoardDescriptor(
121121
_ppgRedChannel,
122122
],
123123
packets: [
124+
PacketSpec(
125+
pktType: 2,
126+
label: 'ECG/BioZ/PPG-Red/PPG-IR/Temp/SpO2/HR/RR',
127+
expectedPayloadLength: 22,
128+
decode: decodeHealthypiPkt2,
129+
),
124130
// Firmware v1.0.0+ USB batch packets.
125131
PacketSpec(
126132
pktType: 3,

macos/Podfile.lock

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,34 @@
11
PODS:
2-
- desktop_window (0.4.3):
3-
- FlutterMacOS
4-
- file_selector_macos (0.0.1):
5-
- FlutterMacOS
62
- flutter_libserialport (0.0.1):
73
- FlutterMacOS
84
- libserialport
95
- FlutterMacOS (1.0.0)
10-
- geolocator_apple (1.2.0):
11-
- Flutter
12-
- FlutterMacOS
136
- libserialport (0.1.1)
14-
- package_info_plus (0.0.1):
15-
- FlutterMacOS
16-
- screen_retriever_macos (0.0.1):
17-
- FlutterMacOS
18-
- universal_ble (0.0.1):
19-
- Flutter
20-
- FlutterMacOS
21-
- url_launcher_macos (0.0.1):
22-
- FlutterMacOS
237
- window_manager (0.2.0):
248
- FlutterMacOS
259

2610
DEPENDENCIES:
27-
- desktop_window (from `Flutter/ephemeral/.symlinks/plugins/desktop_window/macos`)
28-
- file_selector_macos (from `Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos`)
2911
- flutter_libserialport (from `Flutter/ephemeral/.symlinks/plugins/flutter_libserialport/macos`)
3012
- FlutterMacOS (from `Flutter/ephemeral`)
31-
- geolocator_apple (from `Flutter/ephemeral/.symlinks/plugins/geolocator_apple/darwin`)
32-
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
33-
- screen_retriever_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever_macos/macos`)
34-
- universal_ble (from `Flutter/ephemeral/.symlinks/plugins/universal_ble/darwin`)
35-
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
3613
- window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`)
3714

3815
SPEC REPOS:
3916
trunk:
4017
- libserialport
4118

4219
EXTERNAL SOURCES:
43-
desktop_window:
44-
:path: Flutter/ephemeral/.symlinks/plugins/desktop_window/macos
45-
file_selector_macos:
46-
:path: Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos
4720
flutter_libserialport:
4821
:path: Flutter/ephemeral/.symlinks/plugins/flutter_libserialport/macos
4922
FlutterMacOS:
5023
:path: Flutter/ephemeral
51-
geolocator_apple:
52-
:path: Flutter/ephemeral/.symlinks/plugins/geolocator_apple/darwin
53-
package_info_plus:
54-
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
55-
screen_retriever_macos:
56-
:path: Flutter/ephemeral/.symlinks/plugins/screen_retriever_macos/macos
57-
universal_ble:
58-
:path: Flutter/ephemeral/.symlinks/plugins/universal_ble/darwin
59-
url_launcher_macos:
60-
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
6124
window_manager:
6225
:path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos
6326

6427
SPEC CHECKSUMS:
65-
desktop_window: aef15b80e828d9e6e683646bbcdf0a244ac89527
66-
file_selector_macos: 9e9e068e90ebee155097d00e89ae91edb2374db7
67-
flutter_libserialport: 2c523cb8d8203fc6d1b0da88190da31ac970eb93
28+
flutter_libserialport: d1a505fd4b05785f7b50cc7c93b361937ea1c5bd
6829
FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
69-
geolocator_apple: ab36aa0e8b7d7a2d7639b3b4e48308394e8cef5e
7030
libserialport: 1cb25e66ef3c92a8e59c2ea3820302c3fa2268cd
71-
package_info_plus: f0052d280d17aa382b932f399edf32507174e870
72-
screen_retriever_macos: c5508cc3c66ff0d4db650480cf0ab691e220d933
73-
universal_ble: a322ebabee64f0ec27a313e89a5dd6967f37a60f
74-
url_launcher_macos: f87a979182d112f911de6820aefddaf56ee9fbfd
75-
window_manager: 1d01fa7ac65a6e6f83b965471b1a7fdd3f06166c
31+
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
7632

7733
PODFILE CHECKSUM: 0d3963a09fc94f580682bd88480486da345dc3f0
7834

0 commit comments

Comments
 (0)