Add support for the status LEDs

Fixes #2.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/427/head^2
Gergely Nagy 7 years ago
parent afa32312e0
commit bd913cde2b

@ -47,6 +47,10 @@ void ErgoDox::setup(void) {
PORTE |= (1 << 6); PORTE |= (1 << 6);
scanner_.begin(); scanner_.begin();
setStatusLEDBrightness(1, 15);
setStatusLEDBrightness(2, 15);
setStatusLEDBrightness(3, 15);
} }
void ErgoDox::readMatrix() { void ErgoDox::readMatrix() {
@ -104,6 +108,23 @@ bool ErgoDox::isKeyMasked(byte row, byte col) {
return bitRead(masks_[row], col); return bitRead(masks_[row], col);
} }
// ErgoDox-specific stuff
void ErgoDox::setStatusLED(uint8_t led, bool state) {
if (state) {
DDRB |= (1 << (led + 4));
PORTB |= (1 << (led + 4));
} else {
DDRB &= ~(1 << (led + 4));
PORTB &= ~(1 << (led + 4));
}
}
void ErgoDox::setStatusLEDBrightness(uint8_t led, uint8_t brightness) {
(led == 1) ? (OCR1A = brightness) :
(led == 2) ? (OCR1B = brightness) :
(OCR1C = brightness);
}
} }
} }

@ -69,6 +69,10 @@ class ErgoDox {
void unMaskKey(byte row, byte col); void unMaskKey(byte row, byte col);
bool isKeyMasked(byte row, byte col); bool isKeyMasked(byte row, byte col);
// ErgoDox-specific stuff
void setStatusLED(uint8_t led, bool state = true);
void setStatusLEDBrightness(uint8_t led, uint8_t brightness);
private: private:
static ErgoDoxScanner scanner_; static ErgoDoxScanner scanner_;
static uint8_t previousKeyState_[ROWS]; static uint8_t previousKeyState_[ROWS];

Loading…
Cancel
Save