@@ -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 |
@@ -3,7 +3,7 @@ | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
#include <Code.h> | |||
#include <LED.h> | |||
#include <LEDInterface.h> | |||
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(); | |||
}; |
@@ -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++) | |||
{ |
@@ -1,13 +1,13 @@ | |||
#ifndef DEBUG_H | |||
#define DEBUG_H | |||
#include <Arduino.h> | |||
#include <LED.h> | |||
#include <LEDInterface.h> | |||
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 |
@@ -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 |
@@ -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 |
@@ -3,13 +3,13 @@ | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
#include <Wire.h> | |||
#include <LED.h> | |||
#include <LEDInterface.h> | |||
#include <PortInterface.h> | |||
/* 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; |
@@ -2,11 +2,11 @@ | |||
#define LED_UC_H | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
#include <LED.h> | |||
#include <LEDInterface.h> | |||
/* 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 |
@@ -4,7 +4,7 @@ | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
#include <LayerState.h> | |||
#include <LED.h> | |||
#include <LEDInterface.h> | |||
/* 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 |
@@ -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); |
@@ -28,7 +28,7 @@ This layout table shows left and right matrices: | |||
#include <LED_uC.h> | |||
//right matrix | |||
#include <PortMCP23S17.h> | |||
#include <Port_MCP23S17.h> | |||
#include <Scanner_IOE.h> | |||
#include <LED_IOE.h> | |||
@@ -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); |