aboutsummaryrefslogtreecommitdiff
path: root/hw/hank
diff options
context:
space:
mode:
authorSelene ToyKeeper2024-03-29 08:24:32 -0600
committerSelene ToyKeeper2024-03-29 08:34:29 -0600
commitda5278d03f67c868bdc5388832c175a9199554f9 (patch)
tree8d5c06f7b910f8cc7daf936d903090abe445add1 /hw/hank
parentMerge branch 'trunk' into emisar-d3aa (diff)
downloadanduril-da5278d03f67c868bdc5388832c175a9199554f9.tar.gz
anduril-da5278d03f67c868bdc5388832c175a9199554f9.tar.bz2
anduril-da5278d03f67c868bdc5388832c175a9199554f9.zip
d3aa: fixed voltage calculation to use 0.02V units instead of 0.025V
Diffstat (limited to '')
-rw-r--r--hw/hank/emisar-d3aa/hwdef.c8
-rw-r--r--hw/hank/emisar-d3aa/hwdef.h4
2 files changed, 5 insertions, 7 deletions
diff --git a/hw/hank/emisar-d3aa/hwdef.c b/hw/hank/emisar-d3aa/hwdef.c
index 36c6fed..be673e1 100644
--- a/hw/hank/emisar-d3aa/hwdef.c
+++ b/hw/hank/emisar-d3aa/hwdef.c
@@ -101,13 +101,11 @@ bool gradual_tick_main(uint8_t gt) {
#ifdef USE_VOLTAGE_DIVIDER
uint8_t voltage_raw2cooked(uint16_t measurement) {
// In : 65535 * BATTLVL / 1.024V
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// BATTLVL = Vbat * (100.0/(330+100)) = Vbat / 4.3
- // So, Out = In * 4.3 / 1600
- // (plus a bit of fudging to fix the slope and offset,
- // based on measuring actual hardware)
+ // So, Out = In * 4.3 / 1280
uint8_t result = (uint32_t)(measurement + (65535 * 4 / 1024))
- * 43 / 16000;
+ * 43 / 12800;
return result;
}
#endif
diff --git a/hw/hank/emisar-d3aa/hwdef.h b/hw/hank/emisar-d3aa/hwdef.h
index c675208..87740ba 100644
--- a/hw/hank/emisar-d3aa/hwdef.h
+++ b/hw/hank/emisar-d3aa/hwdef.h
@@ -98,8 +98,8 @@ enum CHANNEL_MODES {
#define SWITCH_INTFLG VPORTA.INTFLAGS
#endif
-#define DUAL_VOLTAGE_FLOOR (4*21) // for AA/14500 boost drivers, don't indicate low voltage if below this level
-#define DUAL_VOLTAGE_LOW_LOW (4*7) // the lower voltage range's danger zone 0.7 volts (NiMH)
+#define DUAL_VOLTAGE_FLOOR (21*dV) // for AA/14500 boost drivers, don't indicate low voltage if below this level
+#define DUAL_VOLTAGE_LOW_LOW ( 7*dV) // the lower voltage range's danger zone 0.7 volts (NiMH)
// comment out to use VDDIO2 instead of external voltage divider
#define USE_VOLTAGE_DIVIDER
#ifdef USE_VOLTAGE_DIVIDER
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.