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