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); 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); 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 #endif
@ -1986,7 +1987,7 @@ void STS_FHMOS_sensor_upload_map(uint8_t map_index)
{ {
#if 1 #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); 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) // - 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} // The function must return an object, e.g. {"temperature": 22.5}
// //
// Yunhorn SmarToilets Sensor R20250521R02 // Yunhorn SmarToilets Sensor R20250522R01
// //
function Decode(fPort, data, variables) { function Decode(fPort, data, variables) {
@ -283,6 +283,16 @@ function Decode(fPort, data, variables) {
data.fhmos_gesture_map7 = bytes2matrix(13, bytes); data.fhmos_gesture_map7 = bytes2matrix(13, bytes);
data.fhmos_gesture_map8 = bytes2matrix(14, bytes); data.fhmos_gesture_map8 = bytes2matrix(14, bytes);
break; 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 }; return { "Yunhorn_SmarToilets_data": data };
@ -966,8 +976,7 @@ function Decode(fPort, data, variables) {
break; break;
case 8: 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]]; data.L8_CMD = l8code2cmd[bytes[3]];
if ((bytes[3] == '9')) { if ((bytes[3] == '9')) {
if (bytes[7] == 2) { if (bytes[7] == 2) {
@ -992,7 +1001,7 @@ function Decode(fPort, data, variables) {
if ((bytes[0] == 0x59) && (bytes[9] == 0x38)) { if ((bytes[0] == 0x59) && (bytes[9] == 0x38)) {
data.Yunhorn_PRD = "True"; data.Yunhorn_PRD = "True";
data.PRD_String = String.fromCharCode(bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6]); data.PRD_String = String.fromCharCode(bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6]);
} }
break; break;
// YUNHORN NVM CONFIG LENGTH // YUNHORN NVM CONFIG LENGTH
@ -1070,6 +1079,16 @@ function bytes2matrix(i, bytes) {
return matrix0; 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 // Yunhorn SmarToilets Sensor Decoder