Commit 8addcc45 authored by Sven Greiner's avatar Sven Greiner
Browse files

More optimizations

- Use dedicated delay_s() function
- Move ticks into register
parent c1808b20
......@@ -94,8 +94,7 @@ register Options options asm("r7");
register uint8_t output_eeprom asm("r6");
register uint8_t output_eeprom_pos asm("r5");
register uint8_t microticks asm("r4");
volatile uint8_t ticks = 0;
register uint8_t ticks asm("r3");
/**
* Busy wait delay with ms resolution. This function allows to choose the
......@@ -109,6 +108,14 @@ void delay_ms(uint16_t duration) {
}
}
/**
* Busy wait one second. Saves some space because call does not require setup
* of arguments.
*/
void delay_s(void) {
delay_ms(1000);
}
/**
* Set output, i.e. compare register.
*
......@@ -261,7 +268,7 @@ void toggle_option(uint8_t new_opts, uint8_t flashes) {
blink(24, FLICKER_TIME);
options.raw = old_options;
save_options();
delay_ms(1000);
delay_s();
}
#if defined(LOW_VOLTAGE_PROTECTION) || defined(BATTCHECK)
......@@ -299,6 +306,7 @@ ISR(TIM0_OVF_vect) {
*/
int main(void) {
microticks = 0;
ticks = 0;
// Fast PWM, system clock with /8 prescaler
// Frequency will be F_CPU/(8*256) = 2343.75 Hz
......@@ -441,7 +449,7 @@ int main(void) {
}
if (output == RAMP_SIZE) {
delay_ms(1000);
delay_s();
} else {
delay_ms(RAMP_TIME*1000/RAMP_SIZE);
}
......@@ -470,13 +478,13 @@ int main(void) {
}
blink(i+1, FLASH_TIME);
delay_ms(1000);
delay_s();
break;
#endif // ifdef BATTCHECK
case kConfig:
set_level(0);
delay_ms(1000);
delay_s();
state = kDefault;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment