|
53 | 53 | #define OPCODE_BAFANG_DISPLAY_READ_SPEED 0x20 |
54 | 54 | #define OPCODE_BAFANG_DISPLAY_READ_UNKNOWN1 0x21 |
55 | 55 | #define OPCODE_BAFANG_DISPLAY_READ_RANGE 0x22 |
56 | | -#define OPCODE_BAFANG_DISPLAY_READ_UNKNOWN2 0x24 |
| 56 | +#define OPCODE_BAFANG_DISPLAY_READ_CALORIES 0x24 |
57 | 57 | #define OPCODE_BAFANG_DISPLAY_READ_UNKNOWN3 0x25 |
58 | 58 | #define OPCODE_BAFANG_DISPLAY_READ_MOVING 0x31 |
59 | 59 |
|
@@ -104,7 +104,7 @@ static int16_t process_bafang_display_read_battery(); |
104 | 104 | static int16_t process_bafang_display_read_speed(); |
105 | 105 | static int16_t process_bafang_display_read_unknown1(); |
106 | 106 | static int16_t process_bafang_display_read_range(); |
107 | | -static int16_t process_bafang_display_read_unknown2(); |
| 107 | +static int16_t process_bafang_display_read_calories(); |
108 | 108 | static int16_t process_bafang_display_read_unknown3(); |
109 | 109 | static int16_t process_bafang_display_read_moving(); |
110 | 110 |
|
@@ -282,8 +282,8 @@ static int16_t try_process_bafang_read_request() |
282 | 282 | return process_bafang_display_read_unknown1(); |
283 | 283 | case OPCODE_BAFANG_DISPLAY_READ_RANGE: |
284 | 284 | return process_bafang_display_read_range(); |
285 | | - case OPCODE_BAFANG_DISPLAY_READ_UNKNOWN2: |
286 | | - return process_bafang_display_read_unknown2(); |
| 285 | + case OPCODE_BAFANG_DISPLAY_READ_CALORIES: |
| 286 | + return process_bafang_display_read_calories(); |
287 | 287 | case OPCODE_BAFANG_DISPLAY_READ_UNKNOWN3: |
288 | 288 | return process_bafang_display_read_unknown3(); |
289 | 289 | case OPCODE_BAFANG_DISPLAY_READ_MOVING: |
@@ -582,16 +582,21 @@ static int16_t process_bafang_display_read_range() |
582 | 582 | return 3; |
583 | 583 | } |
584 | 584 |
|
585 | | -static int16_t process_bafang_display_read_unknown2() |
| 585 | +static int16_t process_bafang_display_read_calories() |
586 | 586 | { |
587 | 587 | if (msg_len < 3) |
588 | 588 | { |
589 | 589 | return KEEP; |
590 | 590 | } |
591 | 591 |
|
592 | | - uart1_write(0x00); |
593 | | - uart1_write(0x00); |
594 | | - uart1_write(0x00); // checksum |
| 592 | + uint8_t checksum = 0; |
| 593 | + |
| 594 | + // send battery voltage x10 to show in calories field |
| 595 | + uint16_t volt = motor_get_battery_voltage_x10(); |
| 596 | + |
| 597 | + write_uart1_and_increment_checksum(volt >> 8, & checksum); |
| 598 | + write_uart1_and_increment_checksum(volt & 0xff, & checksum); |
| 599 | + uart1_write(checksum); // checksum |
595 | 600 |
|
596 | 601 | return 3; |
597 | 602 | } |
|
0 commit comments