Monitor motorhome leisure battery and provide simple control of habitation

Dependencies:   net lpc1768 crypto clock web fram log

Revision:
9:d957af50fdc2
Parent:
0:b843d647695c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web-this/battery/web-battery-ajax.c	Mon Jun 06 11:08:53 2022 +0000
@@ -0,0 +1,53 @@
+#include  <stdint.h>
+#include   <stdio.h>
+
+#include "http.h"
+#include "comms.h"
+
+void WebBatteryAjax()
+{
+    HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL);
+    
+    HttpAddInt32AsHex(BatteryGetCountedCapacity());
+    HttpAddChar('\n');
+    
+    HttpAddByteAsHex(BatteryGetCountedError());
+    HttpAddChar('\n');
+    
+    HttpAddInt32AsHex(BatteryGetCurrentMa());
+    HttpAddChar('\n');
+    
+    HttpAddByteAsHex(BatteryGetCapacitySetPointPercent());
+    HttpAddChar('\n');
+    
+    HttpAddChar(BatteryGetOutputState());
+    HttpAddChar('\n');
+    
+    int nibble = 0;
+    if (BatteryGetChargeEnabled()   ) nibble |= 1;
+    if (BatteryGetDischargeEnabled()) nibble |= 2;
+    HttpAddNibbleAsHex (nibble);
+    HttpAddChar('\n');
+    
+    HttpAddInt16AsHex(BatteryGetTemperatureTenths());
+    HttpAddChar('\n');
+    
+    HttpAddInt16AsHex(BatteryGetTemperatureSetPoint());
+    HttpAddChar('\n');
+    
+    HttpAddByteAsHex(BatteryGetHeaterOutputPercent());
+    HttpAddChar('\n');
+    
+    HttpAddInt16AsHex(BatteryGetVoltageMv());
+    HttpAddChar('\n');
+    
+    HttpAddByteAsHex(BatteryGetMeasuredPercent());
+    HttpAddChar('\n');
+    
+    HttpAddByteAsHex(BatteryGetMeasuredError());
+    HttpAddChar('\n');
+    
+    HttpAddByteAsHex(BatteryGetCapacityAutoUpdate());
+    HttpAddChar('\n');
+}
+