43 TM1638::TM1638(uint8_t clkPin, uint8_t dioPin, uint8_t stbPin,
bool displayOn, uint8_t brightness) :
44 _displayOn(displayOn), _brightness(brightness & 0x07)
48 _clkPort = digitalPinToPort(clkPin);
49 _dioPort = digitalPinToPort(dioPin);
50 _stbPort = digitalPinToPort(stbPin);
52 _clkBit = digitalPinToBitMask(clkPin);
53 _dioBit = digitalPinToBitMask(dioPin);
54 _stbBit = digitalPinToBitMask(stbPin);
126 if (brightness <= 7) {
179 for (uint8_t i = 0; i < len; i++) {
197 for (uint8_t i = 0; i < 4; i++) {
198 keys |= ((uint32_t)
readByte() << (i * 8));
234 for (uint8_t i = 0; i < 8; i++) {
237 if (data & (1 << i)) {
256 for (uint8_t i = 0; i < 8; i++) {
uint8_t _brightness
Display brightness for display control register.
#define TM1638_DIO_HIGH()
DIO pin high.
virtual void writeByte(uint8_t data)
Write byte to TM1638.
#define TM1638_CMD_DATA
Display data command.
TM1638(uint8_t clkPin, uint8_t dioPin, uint8_t stbPin, bool displayOn=true, uint8_t brightness=5)
TM1638 constructor.
#define TM1638_CTRL_DISPLAY_ON
Display on.
#define TM1638_DATA_AUTO_INC_ADDR
Auto increment address.
#define TM1638_STB_OUTPUT()
STB pin output.
#define TM1638_PIN_DELAY()
Delay between pin changes.
#define TM1638_DIO_READ()
DIO pin read.
virtual void writeDisplayControl()
Write display control register.
virtual void setBrightness(uint8_t brightness)
Set brightness LED's.
#define TM1638_CLK_INPUT()
CLK pin input.
#define TM1638_NUM_GRIDS
Number of grid registers.
#define TM1638_DIO_INPUT()
DIO pin input.
#define TM1638_STB_INPUT()
STB pin input.
virtual void clear()
Turn all LED's off.
#define TM1638_CMD_CTRL
Display control command.
uint8_t _clkPin
Clock pin.
virtual void begin()
Initialize TM1638 controller.
#define TM1638_CLK_LOW()
CLK pin low.
virtual void writeData(uint8_t address, uint8_t data)
Write display register.
#define TM1638_STB_LOW()
STB pin low.
#define TM1638_DATA_READ_KEYS
Read keys.
virtual uint32_t getKeys()
Get key states.
#define TM1638_CMD_ADDR
Display address command.
virtual void writeCommand(uint8_t cmd)
Write command to TM1638.
#define TM1638_CTRL_DISPLAY_OFF
Display off.
#define TM1638_STB_HIGH()
STB pin high.
#define TM1638_CLK_HIGH()
CLK pin high.
virtual void displayOff()
Turn display off.
virtual void end()
Disable pins.
#define TM1638_DATA_WRITE
Write data.
#define TM1638_DIO_LOW()
DIO pin low.
uint8_t _stbPin
Enable pin.
#define TM1638_CLK_OUTPUT()
CLK pin output.
virtual void displayOn()
Turn Display on.
#define TM1638_DIO_OUTPUT()
DIO pin output.
bool _displayOn
Display on and off status for display control register.
virtual uint8_t readByte()
Read byte from TM1638.
TM1638 library for Arduino.