123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- #ifndef __TM1637DISPLAY__
- #define __TM1637DISPLAY__
- #include <inttypes.h>
- #define SEG_A 0b00000001
- #define SEG_B 0b00000010
- #define SEG_C 0b00000100
- #define SEG_D 0b00001000
- #define SEG_E 0b00010000
- #define SEG_F 0b00100000
- #define SEG_G 0b01000000
- #define COLON_POSITION 1
- class TM1637Display {
- public:
-
-
-
-
-
- TM1637Display(uint8_t pinClk, uint8_t pinDIO);
-
-
-
-
-
-
-
- void setBrightness(uint8_t brightness);
-
-
-
- void setColon(const bool colon);
-
-
-
-
-
-
-
-
-
-
-
-
-
- void setSegments(const uint8_t segments[], uint8_t length = 4, uint8_t pos = 0);
-
-
-
-
-
-
-
-
-
-
-
-
- void showNumberDec(int num, bool leading_zero = false, uint8_t length = 4, uint8_t pos = 0);
-
-
-
-
-
-
-
-
-
-
- uint8_t encodeDigit(uint8_t digit);
- protected:
- void bitDelay();
-
- void start();
-
- void stop();
-
- bool writeByte(uint8_t b);
-
- private:
- uint8_t m_pinClk;
- uint8_t m_pinDIO;
- uint8_t m_brightness;
- bool m_colon;
- };
- #endif
|