Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect voltage readout against modification from ISR #92

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions fsm/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,16 +427,18 @@ PROGMEM const uint8_t voltage_blinks[] = {
};
#endif
void battcheck() {
// protect against modification from ISR and also reduce code size
const uint8_t volt = voltage;
#ifdef BATTCHECK_VpT
blink_num(voltage / dV);
blink_num(volt / dV);
#ifdef USE_EXTRA_BATTCHECK_DIGIT
// 0.02V precision, 0 1 2 3 4 remainder -> .00 .02 .04 .06 .08V
blink_num((voltage % dV) * (10/dV));
blink_num((volt % dV) * (10/dV));
#endif
#else
uint8_t i;
for(i=0;
voltage >= pgm_read_byte(voltage_blinks + i);
volt >= pgm_read_byte(voltage_blinks + i);
i++) {}
#ifdef DONT_DELAY_AFTER_BATTCHECK
blink_digit(i);
Expand Down
Loading