reform

MNT Reform: Open Source Portable Computer
Log (Feed) | Files | Refs (Tags) | README

commit d7ebe47e08dff89abad2536a8d81a9654cfdd48f
parent cf882c35a03addc457cfafbf016afb34abafef4c
Author: Lukas F. Hartmann <lukas@mntre.com>
Date:   Tue,  9 Mar 2021 14:54:20 +0100

kbd/lpc: fix alignment of amps/battery gauge

Diffstat:
Mreform2-keyboard-fw/Keyboard.c | 6+++---
Mreform2-lpc-fw/src/boards/reform2/board_reform2.c | 17+++++++++++++----
2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/reform2-keyboard-fw/Keyboard.c b/reform2-keyboard-fw/Keyboard.c @@ -40,7 +40,7 @@ #include "scancodes.h" #include <stdlib.h> -#define KBD_FW_REV "R1 20210218" +#define KBD_FW_REV "R1 20210309" #define KBD_VARIANT_STANDALONE 0 /** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */ @@ -243,9 +243,9 @@ void remote_get_voltages(void) { int amps_offset = 3*8+3; // cut off string - response[amps_offset+4]=0; + response[amps_offset+5]=0; bat_amps = ((float)atoi(&response[amps_offset]))/1000.0; - int volts_offset = amps_offset+4+1; + int volts_offset = amps_offset+6+1; response[volts_offset+5]=0; bat_volts = ((float)atoi(&response[volts_offset]))/1000.0; int gauge_offset = volts_offset+5+1; diff --git a/reform2-lpc-fw/src/boards/reform2/board_reform2.c b/reform2-lpc-fw/src/boards/reform2/board_reform2.c @@ -38,7 +38,7 @@ // don't forget to set this! #define REFORM_MOTHERBOARD_REV REFORM_MBREV_R2 //#define REF2_DEBUG 1 -#define FW_REV "MNT Reform LPC R-2 20210218" +#define FW_REV "MNT Reform LPC R-2 20210309" #define INA260_ADDRESS 0x4e #define LTC4162F_ADDRESS 0x68 @@ -696,7 +696,15 @@ void handle_commands() { sprintf(gauge,"???%%"); } - sprintf(uartBuffer,"%02d%c%02d%c%02d%c%02d%c%02d%c%02d%c%02d%c%02d%cmA%04dmV%05d %s\r\n", + int mA = (int)(current*1000.0); + char mA_sign = " "; + if (mA<0) { + mA = -mA; + mA_sign = "-"; + } + int mV = (int)(volts*1000.0); + + sprintf(uartBuffer,"%02d%c%02d%c%02d%c%02d%c%02d%c%02d%c%02d%c%02d%cmA%c%04dmV%05d %s\r\n", (int)(cells_v[0]*10), (discharge_bits &(1<<0))?'!':' ', (int)(cells_v[1]*10), @@ -713,8 +721,9 @@ void handle_commands() { (discharge_bits &(1<<6))?'!':' ', (int)(cells_v[7]*10), (discharge_bits &(1<<7))?'!':' ', - (int)(current*1000.0), - (int)(volts*1000.0), + mA_sign, + mA, + mV, gauge); uartSend((uint8_t*)uartBuffer, strlen(uartBuffer)); }