1
0

Add backlight level support for gh60 revB

This commit is contained in:
Kai Ryu 2014-04-08 18:02:20 +09:00
parent 8b75dd43ba
commit d004baf727

View File

@ -72,14 +72,39 @@ void backlight_set(uint8_t level)
} }
} }
#else #else
static const uint8_t backlight_table[] PROGMEM = {
0, 16, 128, 255
};
void backlight_set(uint8_t level) void backlight_set(uint8_t level)
{ {
if (level > 0) { if (level > 0) {
DDRF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4); DDRF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
PORTF &= ~(1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4); PORTF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
cli();
TIMSK1 |= ((1<<OCIE1A) | (1<<TOIE1));
TIFR1 |= (1<<TOV1);
sei();
OCR1A = pgm_read_byte(&backlight_table[level]);
} }
else { else {
DDRF &= ~(1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4); DDRF &= ~(1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
cli();
TIMSK1 |= ((1<<OCIE1A) | (1<<TOIE1));
TIFR1 |= (1<<TOV1);
sei();
OCR1A = 0;
} }
} }
ISR(TIMER1_COMPA_vect)
{
// LED off
PORTF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
}
ISR(TIMER1_OVF_vect)
{
// LED on
PORTF &= ~(1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
}
#endif #endif