move stuff around
This commit is contained in:
parent
86f1744f25
commit
69cf1dc936
Before Width: | Height: | Size: 414 KiB After Width: | Height: | Size: 414 KiB |
35
main.c
35
main.c
|
@ -32,11 +32,6 @@ void start_timer() {
|
|||
sei();
|
||||
}
|
||||
|
||||
void main() {
|
||||
start_timer();
|
||||
prog_7segment_4digit();
|
||||
}
|
||||
|
||||
// ISR is used to handle interrupts. TIMER1_OVF_vect
|
||||
// is triggered whenever timer 1 (16 bit) overflows.
|
||||
ISR(TIMER1_OVF_vect) {
|
||||
|
@ -54,44 +49,20 @@ ISR(TIMER2_OVF_vect) {
|
|||
update_next_digit();
|
||||
}
|
||||
|
||||
void prog_7segment() {
|
||||
DDRF = 0b11111111;
|
||||
DDRK = 0b00000000;
|
||||
PORTK = 0b00000001; // enable pull-up resistor
|
||||
|
||||
uint8_t val = 0;
|
||||
|
||||
set_display(&PORTF, val, false);
|
||||
|
||||
while(1) {
|
||||
loop_until_bit_is_clear(PINK, PINK0);
|
||||
|
||||
if (val >= 9) {
|
||||
val = 0xff; // will overflow to 0 when incremented
|
||||
}
|
||||
|
||||
set_display(&PORTF, ++val, true);
|
||||
|
||||
// debounce
|
||||
_delay_ms(200);
|
||||
|
||||
loop_until_bit_is_set(PINK, PINK0);
|
||||
set_display(&PORTF, val, false);
|
||||
}
|
||||
}
|
||||
|
||||
void beep() {
|
||||
beeping = true;
|
||||
_delay_ms(50);
|
||||
beeping = false;
|
||||
}
|
||||
|
||||
void prog_7segment_4digit() {
|
||||
void main() {
|
||||
DDRF = 0b11111111;
|
||||
DDRK = 0b00001111;
|
||||
DDRD = 0b00000001;
|
||||
PORTK = 0b11000000; // set pull-up
|
||||
|
||||
start_timer();
|
||||
|
||||
float num = 0.0f;
|
||||
bool pressed_pause = false;
|
||||
bool pressed_clear = false;
|
||||
|
|
Loading…
Reference in a new issue