reform

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

commit 52ad0cd20ce2ee21c31b1cb890dc7415c6fb5a1f
parent 221c1ba5e52af659235f8acb30dcb0ed470e1ac8
Author: Lukas F. Hartmann <lukas@mntre.com>
Date:   Wed, 13 Jan 2021 21:10:46 +0100

WIP extract new cell info format from LPC

Diffstat:
Mreform2-keyboard-fw/Keyboard.c | 48+++++++++++++++++++++++++++---------------------
1 file changed, 27 insertions(+), 21 deletions(-)

diff --git a/reform2-keyboard-fw/Keyboard.c b/reform2-keyboard-fw/Keyboard.c @@ -222,43 +222,49 @@ void remote_get_voltages(void) { float bat_amps = 0; char bat_gauge[5] = {0,0,0,0,0}; - Serial_SendByte('V'); + Serial_SendByte('g'); Serial_SendByte('\r'); Delay_MS(1); remote_receive_string(0); - bat_volts = ((float)atoi(response))/1000.0; + strncpy(bat_gauge, response, 4); - Serial_SendByte('a'); + Serial_SendByte('0'); + Serial_SendByte('c'); Serial_SendByte('\r'); Delay_MS(1); remote_receive_string(0); - bat_amps = ((float)atoi(response))/1000.0; + bat_volts = ((float)atoi(response))/1000.0; - Serial_SendByte('g'); - Serial_SendByte('\r'); - Delay_MS(1); - remote_receive_string(0); - strncpy(bat_gauge, response, 4); + //Serial_SendByte('a'); + //Serial_SendByte('\r'); + //Delay_MS(1); + //remote_receive_string(0); + //bat_amps = ((float)atoi(response))/1000.0; float sum_volts = 0; for (int i=0; i<8; i++) { // progress anim - gfx_poke(0,0,32*4+((2*i)%10)); - gfx_poke(1,0,32*4+1+((2*i)%10)); - iota_gfx_flush(); - - Serial_SendByte('0'+i); - Serial_SendByte('v'); - Serial_SendByte('\r'); - Delay_MS(1); - remote_receive_string(0); - - voltages[i] = ((float)atoi(response))/1000.0; - if (voltages[i]<0 || voltages[i]>=5) voltages[i]=0; + //gfx_poke(0,0,32*4+((2*i)%10)); + //gfx_poke(1,0,32*4+1+((2*i)%10)); + //iota_gfx_flush(); + + //Serial_SendByte('0'+i); + //Serial_SendByte('v'); + //Serial_SendByte('\r'); + //Delay_MS(1); + //remote_receive_string(0); + + voltages[i] = ((float)((response[i*3]-'0')*10 + (response[i*3+1]-'0')))/10.0; + //if (voltages[i]<0 || voltages[i]>=5) voltages[i]=0; sum_volts += voltages[i]; } + int amps_offset = 3*8+2; + // cut off string + response[amps_offset+4]=0; + bat_amps = ((float)atoi(&response[amps_offset]))/1000.0; + //plot voltages gfx_clear(); char str[32];