diff --git a/TM1637Display.cpp b/TM1637Display.cpp index 3deb1a5..2f45f19 100644 --- a/TM1637Display.cpp +++ b/TM1637Display.cpp @@ -58,11 +58,12 @@ const uint8_t digitToSegment[] = { static const uint8_t minusSegments = 0b01000000; -TM1637Display::TM1637Display(uint8_t pinClk, uint8_t pinDIO) +TM1637Display::TM1637Display(uint8_t pinClk, uint8_t pinDIO, unsigned int bitDelay) { // Copy the pin numbers m_pinClk = pinClk; m_pinDIO = pinDIO; + m_bitDelay = bitDelay; // Set the pin direction and default value. // Both pins are set as inputs, allowing the pull-up resistors to pull them up @@ -177,7 +178,7 @@ void TM1637Display::showNumberBaseEx(int8_t base, uint16_t num, uint8_t dots, bo void TM1637Display::bitDelay() { - delayMicroseconds(100); + delayMicroseconds(m_bitDelay); } void TM1637Display::start() diff --git a/TM1637Display.h b/TM1637Display.h index df8b0db..84d327c 100644 --- a/TM1637Display.h +++ b/TM1637Display.h @@ -27,6 +27,8 @@ #define SEG_F 0b00100000 #define SEG_G 0b01000000 +#define DEFAULT_BIT_DELAY 100 + class TM1637Display { public: @@ -35,7 +37,9 @@ class TM1637Display { //! //! @param pinClk - The number of the digital pin connected to the clock pin of the module //! @param pinDIO - The number of the digital pin connected to the DIO pin of the module - TM1637Display(uint8_t pinClk, uint8_t pinDIO); + //! @param bitDelay - The delay, in microseconds, between bit transition on the serial + //! bus connected to the display + TM1637Display(uint8_t pinClk, uint8_t pinDIO, unsigned int bitDelay = DEFAULT_BIT_DELAY); //! Sets the brightness of the display. //! @@ -155,6 +159,7 @@ class TM1637Display { uint8_t m_pinClk; uint8_t m_pinDIO; uint8_t m_brightness; + unsigned int m_bitDelay; }; #endif // __TM1637DISPLAY__