updated to use 66 ticks or counter overflows at 4.8Mhz; at 6.8ms per overflow so aproximatly 450ms long press time.
This commit is contained in:
parent
2d85b5138c
commit
0c2fbb1d19
11
main.c
11
main.c
|
@ -75,7 +75,8 @@
|
||||||
*
|
*
|
||||||
* Ticks are used as our way of keep track of long button presses.
|
* Ticks are used as our way of keep track of long button presses.
|
||||||
* */
|
* */
|
||||||
#define LONG_PRESS_TICKS 60
|
//original sent had 60
|
||||||
|
#define LONG_PRESS_TICKS 66
|
||||||
|
|
||||||
|
|
||||||
/*A structure to hold the button info*/
|
/*A structure to hold the button info*/
|
||||||
|
@ -381,9 +382,8 @@ static inline void init_timer0() {
|
||||||
TCCR0B = 0x00; //zero timer
|
TCCR0B = 0x00; //zero timer
|
||||||
|
|
||||||
/*set prescaler*/
|
/*set prescaler*/
|
||||||
//TCCR0B |= (1<<CS00)|(1<<CS02);
|
//Set to div64
|
||||||
TCCR0B |= (1<<CS01)|(1<<CS00);
|
TCCR0B |= (1<<CS01)|(1<<CS00);
|
||||||
//TCCR0B |= (1<<CS01);
|
|
||||||
|
|
||||||
|
|
||||||
/*Enable global interrupts*/
|
/*Enable global interrupts*/
|
||||||
|
@ -403,6 +403,9 @@ ISR(TIM0_OVF_vect)
|
||||||
/*Disable global interrupts*/
|
/*Disable global interrupts*/
|
||||||
cli();
|
cli();
|
||||||
|
|
||||||
|
/*Check the state of the switches*/
|
||||||
|
debounce_switch();
|
||||||
|
|
||||||
/*Update the tick_count*/
|
/*Update the tick_count*/
|
||||||
if(btn1.timer_enabled && btn1.pressed_ticks <= UINT8_MAX){
|
if(btn1.timer_enabled && btn1.pressed_ticks <= UINT8_MAX){
|
||||||
btn1.pressed_ticks += 1;
|
btn1.pressed_ticks += 1;
|
||||||
|
@ -412,8 +415,6 @@ ISR(TIM0_OVF_vect)
|
||||||
btn2.pressed_ticks += 1;
|
btn2.pressed_ticks += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Check the state of the switches*/
|
|
||||||
debounce_switch();
|
|
||||||
|
|
||||||
/*Re-Enable global interrupts*/
|
/*Re-Enable global interrupts*/
|
||||||
sei();
|
sei();
|
||||||
|
|
Loading…
Reference in New Issue