sensor_gm1351: fix digit 0 decoding

This commit is contained in:
King Kévin 2020-02-23 14:19:52 +01:00
parent 3779e848db
commit df14317924
1 changed files with 6 additions and 8 deletions

View File

@ -135,13 +135,13 @@ static volatile uint8_t frame_i = 0;
*/
static const uint32_t digit_segments[4][8] = {
{ // digit 1
0x00000000, // a
0x00000001, // a (segment does not exist, use fake bit to avoid false positive)
0x00000040, // b
0x00000040, // c
0x00000000, // d
0x00000000, // e
0x00000000, // f
0x00000000, // g
0x00000001, // d (segment does not exist, use fake bit to avoid false positive)
0x00000001, // e (segment does not exist, use fake bit to avoid false positive)
0x00000001, // f (segment does not exist, use fake bit to avoid false positive)
0x00000001, // g (segment does not exist, use fake bit to avoid false positive)
0x00000400, // dp
},
{ // digit 2
@ -197,7 +197,6 @@ static const uint8_t number_segments[10] = {
*/
static uint32_t digit_number[4][10];
void sensor_gm1351_setup(void)
{
sensor_gm1351_frame_i = 0; // reset frame index
@ -300,7 +299,7 @@ static bool sensor_gm1351_decode(void)
}
}
if (number >= LENGTH(digit_number[digit])) {
if (digit == 0) {
if (0 == digit) {
number = 0;
} else {
return false;
@ -309,7 +308,6 @@ static bool sensor_gm1351_decode(void)
decoded *= 10;
decoded += number;
}
sensor_gm1351_decidba = decoded; // save decoded pattern
return true;
}