reform

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

commit 547f559b492e5c9abce30181f4c369e1eb893276
parent ec419e617c3db2188b737ebbc7d0e1f3f878a123
Author: mntmn <lukas@mntmn.com>
Date:   Wed, 24 Jun 2020 20:40:08 +0200

remote: add battery gauge read

Diffstat:
Mreform2-keyboard-fw/Keyboard.c | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/reform2-keyboard-fw/Keyboard.c b/reform2-keyboard-fw/Keyboard.c @@ -218,6 +218,7 @@ void remote_get_voltages(void) { float bat_volts = 0; float bat_amps = 0; + char bat_gauge[5] = {0,0,0,0,0}; Serial_SendByte('V'); Serial_SendByte('\r'); @@ -230,6 +231,12 @@ void remote_get_voltages(void) { Delay_MS(1); remote_receive_string(0); bat_amps = ((float)atoi(response))/1000.0; + + Serial_SendByte('g'); + Serial_SendByte('\r'); + Delay_MS(1); + remote_receive_string(0); + strncpy(bat_gauge, response, 4); float sum_volts = 0; @@ -252,11 +259,9 @@ void remote_get_voltages(void) { //plot voltages gfx_clear(); - float percentage = ((sum_volts-23.0)/5.0)*100.0; - if (percentage<0) percentage = 0; char str[32]; - sprintf(str,"[] %.1f [] %.1f %d%%",voltages[0],voltages[4],(int)percentage); + sprintf(str,"[] %.1f [] %.1f %s",voltages[0],voltages[4],bat_gauge); insert_bat_icon(str,0,voltages[0]); insert_bat_icon(str,8,voltages[4]); gfx_poke_str(0,0,str);