revised decoder with 3D map

This commit is contained in:
Yunhorn 2025-05-22 19:23:51 +08:00
parent 9d35bc4e42
commit ac9d8680bd
4 changed files with 26 additions and 6 deletions

View File

@ -564,7 +564,8 @@ void STS_YunhornSTSEventP5_Process(void)
{
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Upload Fall Gesture Type 2 , status=%d \r\n", sts_fhmos_bitmap_pending);
STS_FHMOS_sensor_upload_map(0x02);
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Upload Fall Gesture Type 4 , status=%d \r\n", sts_fhmos_bitmap_pending);
STS_FHMOS_sensor_upload_map(0x04);
}
#endif
@ -1986,7 +1987,7 @@ void STS_FHMOS_sensor_upload_map(uint8_t map_index)
{
#if 1
//if (sts_fhmos_bitmap_pending == 0x01)
//if (sts_fhmos_bitmap_pending != FHMOS_BITMAP_BLANK)
{
APP_LOG(TS_OFF, VLEVEL_M, "\r\n +++++++++++++++++++++++ \r\nBitmap Pending to upload flag=%02x index=%d \r\n", sts_fhmos_bitmap_pending, map_index);

View File

@ -4,7 +4,7 @@
// - variables contains the device variables e.g. {"calibration": "3.5"} (both the key / value are of type string)
// The function must return an object, e.g. {"temperature": 22.5}
//
// Yunhorn SmarToilets Sensor R20250521R02
// Yunhorn SmarToilets Sensor R20250522R01
//
function Decode(fPort, data, variables) {
@ -283,6 +283,16 @@ function Decode(fPort, data, variables) {
data.fhmos_gesture_map7 = bytes2matrix(13, bytes);
data.fhmos_gesture_map8 = bytes2matrix(14, bytes);
break;
case 0x04: // Gesture 3D map
data.fhmos_gesture_3Dmap1 = bytes2matrix3d(7, bytes);
data.fhmos_gesture_3Dmap2 = bytes2matrix3d(11, bytes);
data.fhmos_gesture_3Dmap3 = bytes2matrix3d(15, bytes);
data.fhmos_gesture_3Dmap4 = bytes2matrix3d(19, bytes);
data.fhmos_gesture_3Dmap5 = bytes2matrix3d(23, bytes);
data.fhmos_gesture_3Dmap6 = bytes2matrix3d(27, bytes);
data.fhmos_gesture_3Dmap7 = bytes2matrix3d(31, bytes);
data.fhmos_gesture_3Dmap8 = bytes2matrix3d(35, bytes);
break;
}
return { "Yunhorn_SmarToilets_data": data };
@ -966,8 +976,7 @@ function Decode(fPort, data, variables) {
break;
case 8:
if ((bytes[0] == 'P') && (bytes[1] == '1') && (bytes[2] == '1'))
{
if ((bytes[0] == 'P') && (bytes[1] == '1') && (bytes[2] == '1')) {
data.L8_CMD = l8code2cmd[bytes[3]];
if ((bytes[3] == '9')) {
if (bytes[7] == 2) {
@ -1070,6 +1079,16 @@ function bytes2matrix(i, bytes) {
return matrix0;
}
function bytes2matrix3d(i, bytes) {
var mm1 = bytes[i];
var mm2 = bytes[i + 1];
var mm3 = bytes[i + 2];
var mm4 = bytes[i + 3];
var con = 0x30;
var matrix0 = " [ ";
matrix0 += (mm1 >> 4) + " " + (mm1 & 0x0f) + " " + (mm2 >> 4) + " " + (mm2 & 0x0f) + " " + (mm3 >> 4) + " " + (mm3 & 0x0f) + " " + (mm4 >> 4) + " " + (mm4 & 0x0f) + " ]";
return matrix0;
}
//
// Yunhorn SmarToilets Sensor Decoder