mirror of
https://github.com/avishorp/TM1637.git
synced 2026-07-27 19:56:13 +00:00
Allow users to set the bit delay via constructor
This commit is contained in:
+3
-2
@@ -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()
|
||||
|
||||
+6
-1
@@ -27,6 +27,8 @@
|
||||
#define SEG_F 0b00100000
|
||||
#define SEG_G 0b01000000
|
||||
|
||||
#define DEFAULT_BIT_DELAY 100
|
||||
|
||||
class TM1637Display {
|
||||
|
||||
public:
|
||||
@@ -35,7 +37,9 @@ public:
|
||||
//!
|
||||
//! @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 @@ private:
|
||||
uint8_t m_pinClk;
|
||||
uint8_t m_pinDIO;
|
||||
uint8_t m_brightness;
|
||||
unsigned int m_bitDelay;
|
||||
};
|
||||
|
||||
#endif // __TM1637DISPLAY__
|
||||
|
||||
Reference in New Issue
Block a user