use 'd' as hotkey, and indicate active bootloader by fading instead of running
lights
This commit is contained in:
parent
45e6c7f2c2
commit
62a9a954c4
@ -124,8 +124,9 @@
|
||||
# define SRSTROBEOFF PORTC &= ~(1 << PC7)
|
||||
# define KEYROW 16
|
||||
#endif
|
||||
uint8_t ledcounter = 0; ///< counter used to set the speed of the running light
|
||||
uint8_t ledstate = 0; ///< state of the running light
|
||||
uint8_t ledbrightness = 0; ///< brightness level of the leds, between 0 and 127
|
||||
uint8_t ledcounter = 0; ///< needed for PWM operation
|
||||
int8_t leddirection = 1; ///< indicates if leds fade higher or lower
|
||||
|
||||
/**
|
||||
* Prepare IO-ports for detection of bootloader-condition, which happens in
|
||||
@ -136,14 +137,14 @@ static inline void bootLoaderInit(void) {
|
||||
// switch on leds
|
||||
DDRD |= (1 << PIND4) | (1 << PIND5) | (1 << PIND6);
|
||||
PORTD &= ~((1 << PIND4) | (1 << PIND5) | (1 << PIND6));
|
||||
// choose matrix position for hotkey. we use KEY_KPminus, so we set row 13
|
||||
// and later look for column 7
|
||||
DDRA = 0x00;
|
||||
PORTA = 0xff;
|
||||
DDRB &= ~(1 << PB7);
|
||||
PORTB |= (1 << PB7);
|
||||
DDRC = (1 << DDC2);
|
||||
PORTC = ~(1 << PINC2);
|
||||
// choose matrix position for hotkey. we use KEY_D, so we set row 4
|
||||
// and later look for column 5
|
||||
DDRA = (1 << DDA4);
|
||||
PORTA = ~(1 << PINA4);
|
||||
DDRB &= ~(1 << PB5);
|
||||
PORTB |= (1 << PB5);
|
||||
DDRC = 0x00;
|
||||
PORTC = 0xff;
|
||||
}
|
||||
#endif
|
||||
#ifdef MODELSUNTYPE5
|
||||
@ -161,8 +162,8 @@ static inline void bootLoaderInit(void) {
|
||||
// switch on leds
|
||||
PORTB &= ~((1 << PB4) | (1 << PB5) | (1 << PB6) | (1 << PB7));
|
||||
|
||||
// choose matrix position for hotkey. we use KEY_KPminus, so we set all
|
||||
// rows to 1 except for row 6 (KEYROW) and later look for column 6
|
||||
// choose matrix position for hotkey. we use KEY_D, so we set all
|
||||
// rows to 1 except for row 16 (KEYROW) and later look for column 12
|
||||
SRDATAON;
|
||||
SRSTROBEOFF;
|
||||
uint8_t i = 0;
|
||||
@ -203,32 +204,24 @@ static inline void bootLoaderExit(void) {
|
||||
*/
|
||||
#ifdef MODELIBMMODELM
|
||||
static inline uint8_t bootLoaderCondition() {
|
||||
// look for pin 7
|
||||
if (!(PINB & (1 << PINB7))) {
|
||||
// boot loader active, blink leds
|
||||
_delay_ms(1);
|
||||
// look for pin 5
|
||||
if (!(PINB & (1 << PINB5))) {
|
||||
// boot loader active, fade leds
|
||||
ledcounter++;
|
||||
if (ledcounter == 127) {
|
||||
switch (ledstate) {
|
||||
case 0:
|
||||
PORTD &= ~(1 << PIND6);
|
||||
PORTD |= (1 << PIND4) | (1 << PIND5);
|
||||
ledstate = 1;
|
||||
break;
|
||||
case 1:
|
||||
PORTD &= ~(1 << PIND5);
|
||||
PORTD |= (1 << PIND4) | (1 << PIND6);
|
||||
ledstate = 2;
|
||||
break;
|
||||
case 2:
|
||||
PORTD &= ~(1 << PIND4);
|
||||
PORTD |= (1 << PIND5) | (1 << PIND6);
|
||||
ledstate = 0;
|
||||
break;
|
||||
default:
|
||||
ledstate = 0;
|
||||
if (ledcounter < ledbrightness) {
|
||||
// switch on leds
|
||||
PORTD &= ~((1 << PIND4) | (1 << PIND5) | (1 << PIND6));
|
||||
} else {
|
||||
// switch off leds
|
||||
PORTD |= (1 << PIND4) | (1 << PIND5) | (1 << PIND6);
|
||||
}
|
||||
if (ledcounter == 255) {
|
||||
ledcounter = 0;
|
||||
ledbrightness += leddirection;
|
||||
if (ledbrightness == 255) {
|
||||
leddirection = -leddirection;
|
||||
ledbrightness += leddirection;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
@ -239,37 +232,24 @@ static inline uint8_t bootLoaderCondition() {
|
||||
#endif
|
||||
#ifdef MODELSUNTYPE5
|
||||
static inline uint8_t bootLoaderCondition() {
|
||||
// look for pin 12, key: d
|
||||
// look for pin 12, KEY_D
|
||||
if (!(PINC & (1 << PINC4))) {
|
||||
// boot loader active, blink leds
|
||||
_delay_ms(1);
|
||||
// boot loader active, fade leds
|
||||
ledcounter++;
|
||||
if (ledcounter == 127) {
|
||||
switch (ledstate) {
|
||||
case 0:
|
||||
PORTB &= ~(1 << PINB7);
|
||||
PORTB |= (1 << PINB4) | (1 << PINB5) | (1 << PINB6);
|
||||
ledstate = 1;
|
||||
break;
|
||||
case 1:
|
||||
PORTB &= ~(1 << PINB6);
|
||||
PORTB |= (1 << PINB4) | (1 << PINB5) | (1 << PINB7);
|
||||
ledstate = 2;
|
||||
break;
|
||||
case 2:
|
||||
PORTB &= ~(1 << PINB5);
|
||||
PORTB |= (1 << PINB4) | (1 << PINB6) | (1 << PINB7);
|
||||
ledstate = 3;
|
||||
break;
|
||||
case 3:
|
||||
PORTB &= ~(1 << PINB4);
|
||||
PORTB |= (1 << PINB5) | (1 << PINB6) | (1 << PINB7);
|
||||
ledstate = 0;
|
||||
break;
|
||||
default:
|
||||
ledstate = 0;
|
||||
if (ledcounter < ledbrightness) {
|
||||
// switch on leds
|
||||
PORTB &= ~((1 << PINB4) | (1 << PINB5) | (1 << PINB6) | (1 << PINB7));
|
||||
} else {
|
||||
// switch off leds
|
||||
PORTB |= (1 << PINB4) | (1 << PINB5) | (1 << PINB6) | (1 << PINB7);
|
||||
}
|
||||
if (ledcounter == 255) {
|
||||
ledcounter = 0;
|
||||
ledbrightness += leddirection;
|
||||
if (ledbrightness == 255) {
|
||||
leddirection = -leddirection;
|
||||
ledbrightness += leddirection;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user