b e e p
This commit is contained in:
parent
bb17abaa90
commit
8b302d2ae6
20
main.c
20
main.c
|
@ -13,6 +13,7 @@
|
|||
int timer_start = 0xffff - (F_CPU / 1024 / 1000);
|
||||
volatile uint32_t ticks = 0;
|
||||
volatile bool counting = false;
|
||||
volatile bool beeping = false;
|
||||
|
||||
void start_timer() {
|
||||
// Sets the Clock Select. See table on page 157 the Atmel datasheet.
|
||||
|
@ -39,6 +40,12 @@ void main() {
|
|||
ISR(TIMER1_OVF_vect) {
|
||||
TCNT1 = timer_start; // TODO figure out how to get the correct number
|
||||
if (counting) ticks += 1;
|
||||
|
||||
if (bit_is_set(PIND, PIND0)) {
|
||||
PORTD &= 0b11111110;
|
||||
} else if (beeping) {
|
||||
PORTD |= 0b00000001;
|
||||
}
|
||||
}
|
||||
|
||||
void prog_7segment() {
|
||||
|
@ -67,19 +74,28 @@ void prog_7segment() {
|
|||
}
|
||||
}
|
||||
|
||||
void beep() {
|
||||
beeping = true;
|
||||
_delay_ms(50);
|
||||
beeping = false;
|
||||
}
|
||||
|
||||
void prog_7segment_4digit() {
|
||||
DDRF = 0b11111111;
|
||||
DDRK = 0b00001111;
|
||||
DDRD = 0b00000001;
|
||||
PORTK = 0b11000000; // set pull-up
|
||||
|
||||
float num = 0.0f;
|
||||
bool pressed_pause = false;
|
||||
bool pressed_clear = false;
|
||||
|
||||
while(1) {
|
||||
show_float(ticks / 1000.0f);
|
||||
float sleep_time = update_display();
|
||||
|
||||
if (!pressed_pause && bit_is_clear(PINK, PINK7)) {
|
||||
beep();
|
||||
counting = !counting;
|
||||
pressed_pause = true;
|
||||
} else if (pressed_pause && bit_is_set(PINK, PINK7)) {
|
||||
|
@ -87,8 +103,10 @@ void prog_7segment_4digit() {
|
|||
}
|
||||
|
||||
if (bit_is_clear(PINK, PINK6)) {
|
||||
if (!pressed_clear) beep(50);
|
||||
ticks = 0;
|
||||
counting = false;
|
||||
}
|
||||
pressed_clear = true;
|
||||
} else pressed_clear = false;
|
||||
}
|
||||
}
|
||||
|
|
BIN
pinout.png
Normal file
BIN
pinout.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 414 KiB |
Loading…
Reference in a new issue