summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-03-06 21:55:30 +0100
committerDaniel Friesel <derf@finalrewind.org>2020-03-06 21:55:30 +0100
commitf6e7d4fd15bc1adb538d4b4f053a7ac43f8bb2fe (patch)
tree75df2123fd8b53c5a8cee742ec0bec3cfb681dd3 /src
parentab8595e04c7009ee7fbe33f005fda678baad8ebd (diff)
ws2812b_uart: monitor VCC
Diffstat (limited to 'src')
-rw-r--r--src/app/ws2812b_uart/main.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/app/ws2812b_uart/main.cc b/src/app/ws2812b_uart/main.cc
index b35800a..791e67a 100644
--- a/src/app/ws2812b_uart/main.cc
+++ b/src/app/ws2812b_uart/main.cc
@@ -226,6 +226,17 @@ int main(void)
target_mode = blinkencat.COLOR_RGB;
}
}
+ if (ADCSRA & _BV(ADIF)) {
+ uint8_t adcr_l = ADCL;
+ uint8_t adcr_h = ADCH;
+ uint16_t adcr = adcr_l + (adcr_h << 8);
+ uint16_t vcc = 1100L * 1023 / adcr;
+
+ TIFR1 |= _BV(TOV1);
+ ADCSRA |= _BV(ADIF);
+
+ kout << "VCC = " << vcc << endl;
+ }
}
return 0;