diff --git a/src/Code_LEDLock.cpp b/src/Code_LEDLock.cpp index f4d38b4..8d76187 100644 --- a/src/Code_LEDLock.cpp +++ b/src/Code_LEDLock.cpp @@ -2,7 +2,7 @@ /* USB_LED_bit are codes from http://www.usb.org/developers/hidpage/HID1_11.pdf keyboard output report */ -Code_LEDLock::Code_LEDLock(const uint16_t scancode, LED& refLED) +Code_LEDLock::Code_LEDLock(const uint16_t scancode, LEDInterface& refLED) : scancode(scancode), refLED(refLED) { switch (scancode) //initilize USB_LED_bit for given scancode diff --git a/src/Code_LEDLock.h b/src/Code_LEDLock.h index 1f25606..d1462b5 100644 --- a/src/Code_LEDLock.h +++ b/src/Code_LEDLock.h @@ -3,7 +3,7 @@ #include #include #include -#include +#include extern volatile uint8_t keyboard_leds; @@ -21,11 +21,11 @@ class Code_LEDLock : public Code private: const uint16_t scancode; uint8_t USB_LED_bit; //codes used by keyboard output report - LED& refLED; //indicator on keyboard + LEDInterface& refLED; //indicator on keyboard void updateLED() const; public: - Code_LEDLock(const uint16_t scancode, LED& refLED); + Code_LEDLock(const uint16_t scancode, LEDInterface& refLED); virtual void press(); virtual void release(); }; diff --git a/src/Debug.cpp b/src/Debug.cpp index 85ffd68..7db0ccb 100644 --- a/src/Debug.cpp +++ b/src/Debug.cpp @@ -31,7 +31,7 @@ void Debug::printScansPerSecond() //Sometimes OS takes 6 seconds to recongnize keyboard. //wait_for_OS() will blink LED and count up once per second for specified number of seconds. -void Debug::wait_for_OS(LED& led, const uint8_t seconds) +void Debug::wait_for_OS(LEDInterface& led, const uint8_t seconds) { for (uint8_t elapsed = 0; elapsed < seconds; elapsed++) { diff --git a/src/Debug.h b/src/Debug.h index 75e5a11..07dcf2b 100644 --- a/src/Debug.h +++ b/src/Debug.h @@ -1,13 +1,13 @@ #ifndef DEBUG_H #define DEBUG_H #include -#include +#include class Debug { public: void printMicrosecondsPerScan(); //print microseconds per scan every second void printScansPerSecond(); //print scans per second every second - void wait_for_OS(LED& led, uint8_t seconds); //wait for OS to recongnize keyboard + void wait_for_OS(LEDInterface& led, uint8_t seconds); //wait for OS to recongnize keyboard }; #endif diff --git a/src/LED.h b/src/LED.h deleted file mode 100644 index 1816aed..0000000 --- a/src/LED.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef LED_H -#define LED_H - -/* LED is an interface class -Each LED object is an IC pin that is used to power an LED on and off. -*/ -class LED -{ - public: - virtual void on()=0; - virtual void off()=0; -}; -#endif diff --git a/src/LEDInterface.h b/src/LEDInterface.h new file mode 100644 index 0000000..9ff46c7 --- /dev/null +++ b/src/LEDInterface.h @@ -0,0 +1,12 @@ +#ifndef LEDINTERFACE_H +#define LEDINTERFACE_H + +/* Each LED object is an IC pin that is used to power an LED on and off. +*/ +class LEDInterface +{ + public: + virtual void on()=0; + virtual void off()=0; +}; +#endif diff --git a/src/LED_IOE.h b/src/LED_IOE.h index ac125a4..53b619f 100644 --- a/src/LED_IOE.h +++ b/src/LED_IOE.h @@ -3,13 +3,13 @@ #include #include #include -#include +#include #include /* A LED_IOE object is an I/O expander pin that is connected to an LED indicator light. Input/Ouput Direction configuration are set to ouput in PortWrite_*.begin() and PortRead_*.begin(). todo PortRead_*?? */ -class LED_IOE : public LED +class LED_IOE : public LEDInterface { private: PortInterface& refPort; diff --git a/src/LED_uC.h b/src/LED_uC.h index 79863cd..3b89ae4 100644 --- a/src/LED_uC.h +++ b/src/LED_uC.h @@ -2,11 +2,11 @@ #define LED_UC_H #include #include -#include +#include /* A LED_uC turns LED on and off. */ -class LED_uC: public LED +class LED_uC: public LEDInterface { private: const uint8_t pin; //Aduino pin that is connected to an LED diff --git a/src/LayerState_LED.h b/src/LayerState_LED.h index 2a61236..d9ba0be 100644 --- a/src/LayerState_LED.h +++ b/src/LayerState_LED.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include /* Basic LayerState with layer LED indictor lights. begin() should be called once to turn on LED for initial active layer. @@ -12,10 +12,10 @@ begin() should be called once to turn on LED for initial active layer. class LayerState_LED : public LayerState { private: - LED*const *const ptrsLEDs; //array of LEDs, where layerId is array index + LEDInterface*const *const ptrsLEDs; //array of LEDs, where layerId is array index virtual void setActiveLayer(const uint8_t layerId);//set active layerId and turn on it's LED public: - LayerState_LED(LED*const ptrsLEDs[]): ptrsLEDs(ptrsLEDs) {} + LayerState_LED(LEDInterface*const ptrsLEDs[]): ptrsLEDs(ptrsLEDs) {} void begin(); }; #endif diff --git a/tutorials/keybrd_5a_LED_on_uC/keybrd_5a_LED_on_uC.ino b/tutorials/keybrd_5a_LED_on_uC/keybrd_5a_LED_on_uC.ino index 4f4c3f7..7c3ab41 100644 --- a/tutorials/keybrd_5a_LED_on_uC/keybrd_5a_LED_on_uC.ino +++ b/tutorials/keybrd_5a_LED_on_uC/keybrd_5a_LED_on_uC.ino @@ -50,7 +50,7 @@ The active layerId is used as an index to dereference the prtsLayerLEDs[] array. */ enum layers { NORMAL, FN }; -LED* prtsLayerLEDs[] = { &LED_normal, &LED_fn }; //array index matches enum layerIds +LEDInterface* prtsLayerLEDs[] = { &LED_normal, &LED_fn }; //array index matches enum layerIds LayerState_LED layerState(prtsLayerLEDs); Code_LayerHold l_fn(FN, layerState); diff --git a/tutorials/keybrd_5b_LED_on_IOE/keybrd_5b_LED_on_IOE.ino b/tutorials/keybrd_5b_LED_on_IOE/keybrd_5b_LED_on_IOE.ino index 210657e..f10fb76 100644 --- a/tutorials/keybrd_5b_LED_on_IOE/keybrd_5b_LED_on_IOE.ino +++ b/tutorials/keybrd_5b_LED_on_IOE/keybrd_5b_LED_on_IOE.ino @@ -28,7 +28,7 @@ This layout table shows left and right matrices: #include //right matrix -#include +#include #include #include @@ -47,8 +47,8 @@ LED_uC LED_CapsLck(21); // --------------- RIGHT SCANNER --------------- const uint8_t IOE_ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins are grounded -PortMCP23S17 portA(IOE_ADDR, 0, 1<<0 | 1<<1 ); //for read and LED -PortMCP23S17 portB(IOE_ADDR, 1, 0); //for strobe and LED +Port_MCP23S17 portA(IOE_ADDR, 0, 1<<0 | 1<<1 ); //for read and LED +Port_MCP23S17 portB(IOE_ADDR, 1, 0); //for strobe and LED Scanner_IOE scanner_R(LOW, portB, portA); @@ -60,7 +60,7 @@ LED_IOE LED_fn(portB, 1<<4); // ---------------- LAYER CODE ----------------- enum layers { NORMAL, FN }; -LED* prtsLayerLEDs[] = { &LED_normal, &LED_fn }; //array index matches enum layerIds +LEDInterface* prtsLayerLEDs[] = { &LED_normal, &LED_fn }; //array index matches enum layerIds LayerState_LED layerState(prtsLayerLEDs); Code_LayerHold l_fn(FN, layerState);