aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorSelene ToyKeeper2024-03-29 08:21:24 -0600
committerSelene ToyKeeper2024-03-29 08:21:24 -0600
commit849bc5951b27f3f6296d28e8f62f2077e811e2ad (patch)
tree96939f9b03267c410bb211427f5ca346dc75df04 /arch
parentd3aa weak battery test: blink 3x instead of 2x, and omit number readout (diff)
parentuse smooth steps in lockout mode, if enabled (diff)
downloadanduril-849bc5951b27f3f6296d28e8f62f2077e811e2ad.tar.gz
anduril-849bc5951b27f3f6296d28e8f62f2077e811e2ad.tar.bz2
anduril-849bc5951b27f3f6296d28e8f62f2077e811e2ad.zip
Merge branch 'trunk' into emisar-d3aa
FIXME: The d3aa's voltage calculator needs to be fixed after this merge. * trunk: use smooth steps in lockout mode, if enabled fixed Tactical Mode's strobes when Momentary Mode not enabled increased voltage precision from 0.025V to 0.02V (so 0 to 255 now goes from 0.00V to 5.10V) fixed inaccurate comment (thanks to xikteny for spotting it) Allow manually running GitHub actions workflows Bugfix: Prevent switching channel modes when in tactical mode Bugfix: Tactical mode has a dependency on momentary mode
Diffstat (limited to '')
-rw-r--r--arch/attiny1616.c12
-rw-r--r--arch/attiny1616.h2
-rw-r--r--arch/attiny1634.c12
-rw-r--r--arch/attiny1634.h2
-rw-r--r--arch/attiny85.c10
-rw-r--r--arch/attiny85.h2
-rw-r--r--arch/avr32dd20.c6
-rw-r--r--arch/avr32dd20.h2
8 files changed, 24 insertions, 24 deletions
diff --git a/arch/attiny1616.c b/arch/attiny1616.c
index c5499dd..02e64b1 100644
--- a/arch/attiny1616.c
+++ b/arch/attiny1616.c
@@ -104,18 +104,18 @@ inline uint16_t mcu_adc_result_volts() {
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement) {
// In : 65535 * 1.5 / Vbat
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// 1.5 = ADC Vref
#if 0
// 1024 = how much ADC resolution we're using (10 bits)
// (12 bits available, but it costs an extra 84 bytes of ROM to calculate)
- uint8_t vbat40 = (uint16_t)(40 * 1.5 * 1024) / (measurement >> 6);
+ uint8_t vbat = (uint16_t)(10 * dV * 1.5 * 1024) / (measurement >> 6);
#else
// ... spend the extra 84 bytes of ROM for better precision
// 4096 = how much ADC resolution we're using (12 bits)
- uint8_t vbat40 = (uint32_t)(40 * 1.5 * 4096) / (measurement >> 4);
+ uint8_t vbat = (uint32_t)(10 * dV * 1.5 * 4096) / (measurement >> 4);
#endif
- return vbat40;
+ return vbat;
}
#if 0 // fine voltage, 0 to 10.24V in 1/6400th V steps
@@ -130,12 +130,12 @@ inline uint16_t mcu_vdd_raw2fine(uint16_t measurement) {
#ifdef USE_VOLTAGE_DIVIDER
inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement) {
// In : 4095 * Vdiv / 1.1V
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// Vdiv = Vbat / 4.3 (typically)
// 1.1 = ADC Vref
const uint16_t adc_per_volt =
(((uint16_t)ADC_44 << 4) - ((uint16_t)ADC_22 << 4))
- / (4 * (44-22));
+ / (dV * (44-22));
uint8_t result = measurement / adc_per_volt;
return result;
}
diff --git a/arch/attiny1616.h b/arch/attiny1616.h
index 940973e..711452d 100644
--- a/arch/attiny1616.h
+++ b/arch/attiny1616.h
@@ -85,7 +85,7 @@ inline void mcu_adc_vect_clear();
inline uint16_t mcu_adc_result_temp();
inline uint16_t mcu_adc_result_volts();
-// return Volts * 40, range 0 to 6.375V
+// return Volts * 50, range 0 to 5.10V
#define voltage_raw2cooked mcu_vdd_raw2cooked
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement);
inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement);
diff --git a/arch/attiny1634.c b/arch/attiny1634.c
index e29d1c3..314ca52 100644
--- a/arch/attiny1634.c
+++ b/arch/attiny1634.c
@@ -97,30 +97,30 @@ inline uint16_t mcu_adc_result() {
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement) {
// In : 65535 * 1.1 / Vbat
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// 1.1 = ADC Vref
#if 0
// 1024 = how much ADC resolution we're using (10 bits)
// (12 bits available, but it costs an extra 84 bytes of ROM to calculate)
- uint8_t vbat40 = (uint16_t)(40 * 1.1 * 1024) / (measurement >> 6);
+ uint8_t vbat = (uint16_t)(10 * dV * 1.1 * 1024) / (measurement >> 6);
#else
// ... spend the extra 84 bytes of ROM for better precision
// 4096 = how much ADC resolution we're using (12 bits)
- uint8_t vbat40 = (uint32_t)(40 * 1.1 * 4096) / (measurement >> 4);
+ uint8_t vbat = (uint32_t)(10 * dV * 1.1 * 4096) / (measurement >> 4);
#endif
- return vbat40;
+ return vbat;
}
#ifdef USE_VOLTAGE_DIVIDER
inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement) {
// In : 4095 * Vdiv / 1.1V
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// Vdiv = Vbat / 4.3 (typically)
// 1.1 = ADC Vref
const uint16_t adc_per_volt =
(((uint16_t)ADC_44 << 4) - ((uint16_t)ADC_22 << 4))
- / (4 * (44-22));
+ / (dV * (44-22));
uint8_t result = measurement / adc_per_volt;
return result;
}
diff --git a/arch/attiny1634.h b/arch/attiny1634.h
index 559d04e..19920fe 100644
--- a/arch/attiny1634.h
+++ b/arch/attiny1634.h
@@ -66,7 +66,7 @@ inline void mcu_adc_off();
inline uint16_t mcu_adc_result();
-// return Volts * 40, range 0 to 6.375V
+// return Volts * 50, range 0 to 5.10V
#define voltage_raw2cooked mcu_vdd_raw2cooked
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement);
inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement);
diff --git a/arch/attiny85.c b/arch/attiny85.c
index 9e298cc..4ca4b87 100644
--- a/arch/attiny85.c
+++ b/arch/attiny85.c
@@ -103,24 +103,24 @@ inline uint16_t mcu_adc_result() { return ADC; }
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement) {
// In : 65535 * 1.1 / Vbat
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// 1.1 = ADC Vref
// 1024 = how much ADC resolution we're using (10 bits)
// (12 bits available, but it costs an extra 84 bytes of ROM to calculate)
- uint8_t vbat40 = (uint16_t)(40 * 1.1 * 1024) / (measurement >> 6);
- return vbat40;
+ uint8_t vbat = (uint16_t)(10 * dV * 1.1 * 1024) / (measurement >> 6);
+ return vbat;
}
#ifdef USE_VOLTAGE_DIVIDER
inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement) {
// In : 4095 * Vdiv / 1.1V
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// Vdiv = Vbat / 4.3 (typically)
// 1.1 = ADC Vref
const uint16_t adc_per_volt =
(((uint16_t)ADC_44 << 4) - ((uint16_t)ADC_22 << 4))
- / (4 * (44-22));
+ / (dV * (44-22));
uint8_t result = measurement / adc_per_volt;
return result;
}
diff --git a/arch/attiny85.h b/arch/attiny85.h
index 3f6ffcb..06a1061 100644
--- a/arch/attiny85.h
+++ b/arch/attiny85.h
@@ -53,7 +53,7 @@ inline void mcu_adc_off();
inline uint16_t mcu_adc_result();
-// return Volts * 40, range 0 to 6.375V
+// return Volts * 50, range 0 to 5.10V
#define voltage_raw2cooked mcu_vdd_raw2cooked
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement);
inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement);
diff --git a/arch/avr32dd20.c b/arch/avr32dd20.c
index 2ac3526..3ada2ee 100644
--- a/arch/avr32dd20.c
+++ b/arch/avr32dd20.c
@@ -141,10 +141,10 @@ inline uint16_t mcu_adc_result() {
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement) {
// In : 65535 * (Vbat / 10) / 1.024V
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// (add 80 to round up near a boundary)
- uint8_t vbat40 = (uint16_t)(measurement + 80) / 160;
- return vbat40;
+ uint8_t vbat50 = (uint16_t)(measurement + 64) / 128;
+ return vbat50;
}
#if 0
diff --git a/arch/avr32dd20.h b/arch/avr32dd20.h
index 09b4096..7d06863 100644
--- a/arch/avr32dd20.h
+++ b/arch/avr32dd20.h
@@ -71,7 +71,7 @@ inline uint16_t mcu_adc_result();
//inline uint16_t mcu_adc_result_temp();
//inline uint16_t mcu_adc_result_volts();
-// return Volts * 40, range 0 to 6.375V
+// return Volts * 50, range 0 to 5.10V
#define voltage_raw2cooked mcu_vdd_raw2cooked
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement);
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.