updated protoview

This commit is contained in:
jbohack
2023-01-23 14:21:10 -05:00
parent 35fe007814
commit 5c4f4cfbd2
26 changed files with 2224 additions and 274 deletions

View File

@@ -13,6 +13,7 @@ static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoView
if (off == BITMAP_SEEK_NOT_FOUND) return false;
FURI_LOG_E(TAG, "Oregon2 preamble+sync found");
info->start_off = off;
off += 32; /* Skip preamble. */
uint8_t buffer[8], raw[8] = {0};
@@ -21,8 +22,10 @@ static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoView
FURI_LOG_E(TAG, "Oregon2 decoded bits: %lu", decoded);
if (decoded < 11*4) return false; /* Minimum len to extract some data. */
info->pulses_count = (off+11*4*4) - info->start_off;
char temp[3] = {0}, deviceid[2] = {0}, hum[2] = {0};
char temp[3] = {0}, hum[2] = {0};
uint8_t deviceid[2];
for (int j = 0; j < 64; j += 4) {
uint8_t nib[1];
nib[0] = (bitmap_get(buffer,8,j+0) |
@@ -45,21 +48,20 @@ static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoView
}
}
snprintf(info->name,sizeof(info->name),"%s","Oregon v2.1");
/* The following line crashes the Flipper because of broken
* snprintf() implementation. */
snprintf(info->raw,sizeof(info->raw),"%02X%02X%02X%02X%02X%02X%02X%02X",
raw[0],raw[1],raw[2],raw[3],raw[4],raw[5],
raw[6],raw[7]);
snprintf(info->info1,sizeof(info->info1),"Sensor ID %02X%02X",
deviceid[0], deviceid[1]);
snprintf(info->info2,sizeof(info->info2),"Temperature %d%d.%d",
temp[0],temp[1],temp[2]);
snprintf(info->info3,sizeof(info->info3),"Humidity %d%d",
hum[0],hum[1]);
float tempval = ((temp[0]-'0')*10) +
(temp[1]-'0') +
((float)(temp[2]-'0')*0.1);
int humval = (hum[0]-'0')*10 + (hum[1]-'0');
fieldset_add_bytes(info->fieldset,"Sensor ID",deviceid,4);
fieldset_add_float(info->fieldset,"Temperature",tempval,1);
fieldset_add_uint(info->fieldset,"Humidity",humval,7);
return true;
}
ProtoViewDecoder Oregon2Decoder = {
"Oregon2", decode
.name = "Oregon2",
.decode = decode,
.get_fields = NULL,
.build_message = NULL
};