79 #ifndef ERRIEZ_TM1637_H_ 80 #define ERRIEZ_TM1637_H_ 85 #define TM1637_CMD_DATA 0x40 86 #define TM1637_CMD_CTRL 0x80 87 #define TM1637_CMD_ADDR 0xc0 90 #define TM1637_DATA_WRITE 0x00 91 #define TM1637_DATA_READ_KEYS 0x02 92 #define TM1637_DATA_AUTO_INC_ADDR 0x00 93 #define TM1637_DATA_FIXED_ADDR 0x04 96 #define TM1637_CTRL_PULSE_1_16 0x00 97 #define TM1637_CTRL_PULSE_2_16 0x01 98 #define TM1637_CTRL_PULSE_4_16 0x02 99 #define TM1637_CTRL_PULSE_10_16 0x03 100 #define TM1637_CTRL_PULSE_11_16 0x04 101 #define TM1637_CTRL_PULSE_12_16 0x05 102 #define TM1637_CTRL_PULSE_13_16 0x06 103 #define TM1637_CTRL_PULSE_14_16 0x07 104 #define TM1637_CTRL_DISPLAY_OFF 0x00 105 #define TM1637_CTRL_DISPLAY_ON 0x08 107 #define TM1637_NUM_GRIDS 6 110 #define TM1637_CLK_LOW() { *portOutputRegister(_clkPort) &= ~_clkBit; } 111 #define TM1637_CLK_HIGH() { *portOutputRegister(_clkPort) |= _clkBit; } 112 #define TM1637_CLK_INPUT() { *portModeRegister(_clkPort) &= ~_clkBit; } 113 #define TM1637_CLK_OUTPUT() { *portModeRegister(_clkPort) |= _clkBit; } 114 #define TM1637_DIO_LOW() { *portOutputRegister(_dioPort) &= ~_dioBit; } 115 #define TM1637_DIO_HIGH() { *portOutputRegister(_dioPort) |= _dioBit; } 116 #define TM1637_DIO_INPUT() { *portModeRegister(_dioPort) &= ~_dioBit; } 117 #define TM1637_DIO_OUTPUT() { *portModeRegister(_dioPort) |= _dioBit; } 118 #define TM1637_DIO_READ() ( *portInputRegister(_dioPort) & _dioBit ) 120 #define TM1637_CLK_LOW() { digitalWrite(_clkPin, LOW); } 121 #define TM1637_CLK_HIGH() { digitalWrite(_clkPin, HIGH); } 122 #define TM1637_CLK_INPUT() { pinMode(_clkPin, INPUT); } 123 #define TM1637_CLK_OUTPUT() { pinMode(_clkPin, OUTPUT); } 124 #define TM1637_DIO_LOW() { digitalWrite(_dioPin, LOW); } 125 #define TM1637_DIO_HIGH() { digitalWrite(_dioPin, HIGH); } 126 #define TM1637_DIO_INPUT() { pinMode(_dioPin, INPUT); } 127 #define TM1637_DIO_OUTPUT() { pinMode(_dioPin, OUTPUT); } 128 #define TM1637_DIO_READ() ( digitalRead(_dioPin) ) 131 #if F_CPU >= 20000000UL 132 #define TM1637_PIN_DELAY() { delayMicroseconds(1); } 134 #define TM1637_PIN_DELAY() 144 TM1637(uint8_t clkPin, uint8_t dioPin,
bool displayOn=
true, uint8_t brightness=5);
146 virtual void begin();
151 virtual void clear();
152 virtual void writeData(uint8_t address, uint8_t data);
153 virtual void writeData(uint8_t address,
const uint8_t *buf, uint8_t len);
174 virtual void start();
180 #endif // ERRIEZ_TM1637_H_
virtual void writeByte(uint8_t data)
Write byte to TM1637.
virtual void writeData(uint8_t address, uint8_t data)
Write display register.
virtual void start()
Generate start condition.
virtual uint8_t getKeys()
Get key states.
virtual uint8_t readByte()
Read byte from TM1637.
virtual void end()
Release TM1637 pins.
uint8_t _brightness
Display brightness for display control register.
uint8_t _clkPin
Clock pin.
virtual void writeDisplayControl()
Write display control register.
virtual void writeCommand(uint8_t cmd)
Write command to TM1637.
virtual void displayOff()
Turn display off.
virtual void clear()
Turn all LED's off.
virtual void stop()
Generate stop condition.
bool _displayOn
Display on and off status for display control register.
TM1637(uint8_t clkPin, uint8_t dioPin, bool displayOn=true, uint8_t brightness=5)
TM1637 constructor.
virtual void setBrightness(uint8_t brightness)
Set brightness LED's.
virtual void displayOn()
Turn Display on.
virtual void begin()
Initialize TM1637 controller.