mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-29 04:09:58 -07:00
updated protoview
This commit is contained in:
@@ -16,7 +16,7 @@ static const char *test_vector = "0000001111010101010110100101100101101010010101
|
||||
static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoViewMsgInfo *info) {
|
||||
|
||||
if (USE_TEST_VECTOR) { /* Test vector to check that decoding works. */
|
||||
bitmap_set_pattern(bits,numbytes,test_vector);
|
||||
bitmap_set_pattern(bits,numbytes,0,test_vector);
|
||||
numbits = strlen(test_vector);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,13 @@ 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, "Schrader TPMS gap+preamble found");
|
||||
|
||||
info->start_off = off;
|
||||
off += 10; /* Skip just the long pulse and the first 3 bits of sync, so
|
||||
that we have the first byte of data with the sync nibble
|
||||
0011 = 0x3. */
|
||||
|
||||
uint8_t raw[8];
|
||||
uint8_t id[4];
|
||||
uint32_t decoded =
|
||||
convert_from_line_code(raw,sizeof(raw),bits,numbytes,off,
|
||||
"01","10"); /* Manchester code. */
|
||||
@@ -46,20 +48,24 @@ static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoView
|
||||
return false;
|
||||
}
|
||||
|
||||
info->pulses_count = (off+8*8*2) - info->start_off;
|
||||
|
||||
float kpa = (float)raw[5]*2.5;
|
||||
int temp = raw[6]-50;
|
||||
id[0] = raw[1]&7;
|
||||
id[1] = raw[2];
|
||||
id[2] = raw[3];
|
||||
id[3] = raw[4];
|
||||
|
||||
snprintf(info->name,sizeof(info->name),"%s","Schrader TPMS");
|
||||
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),"Tire ID %01X%02X%02X%02X",
|
||||
raw[1]&7,raw[2],raw[3],raw[4]); /* Only 28 bits of ID, not 32. */
|
||||
snprintf(info->info2,sizeof(info->info2),"Pressure %.2f kpa", (double)kpa);
|
||||
snprintf(info->info3,sizeof(info->info3),"Temperature %d C", temp);
|
||||
fieldset_add_bytes(info->fieldset,"Tire ID",id,4*2);
|
||||
fieldset_add_float(info->fieldset,"Pressure kpa",kpa,2);
|
||||
fieldset_add_int(info->fieldset,"Temperature C",temp,8);
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtoViewDecoder SchraderTPMSDecoder = {
|
||||
"Schrader TPMS", decode
|
||||
.name = "Schrader TPMS",
|
||||
.decode = decode,
|
||||
.get_fields = NULL,
|
||||
.build_message = NULL
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user