Skip to content

Commit

Permalink
Merge pull request #29 from mgesteiro/constructor_update
Browse files Browse the repository at this point in the history
Updated library operation with new begin() method
  • Loading branch information
jasonacox authored Feb 20, 2023
2 parents ba0f0c8 + 1c9e674 commit 7052651
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 11 deletions.
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for TM1637TinyDisplay

## v1.8.0 - Updated library operation with new begin() method

* Updated library operation to include an initializing method `begin()` to move outside the constructor hardware related calls, as reported in https://github.com/jasonacox/TM1637TinyDisplay/issues/28

## v1.7.1 - Fix Compile Errors for ESP8266

* Fix compile errors and warnings on ESP8266 cores (type casts and erroneous defaults in functions) as reported in https://github.com/jasonacox/TM1637TinyDisplay/issues/26
Expand Down
5 changes: 4 additions & 1 deletion TM1637TinyDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ TM1637TinyDisplay::TM1637TinyDisplay(uint8_t pinClk, uint8_t pinDIO, unsigned in
m_scrollDelay = scrollDelay;
// Flip
m_flipDisplay = flip;

}

void TM1637TinyDisplay::begin()
{
// Set the pin direction and default value.
// Both pins are set as inputs, allowing the pull-up resistors to pull them up
pinMode(m_pinClk, INPUT);
Expand Down
9 changes: 7 additions & 2 deletions TM1637TinyDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@
class TM1637TinyDisplay {

public:
//! Initialize a TM1637TinyDisplay object, setting the clock and
//! data pins.
//! Initialize a TM1637TinyDisplay object.
//!
//! @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
Expand All @@ -128,6 +127,12 @@ class TM1637TinyDisplay {
TM1637TinyDisplay(uint8_t pinClk, uint8_t pinDIO, unsigned int bitDelay = DEFAULT_BIT_DELAY,
unsigned int scrollDelay = DEFAULT_SCROLL_DELAY, bool flip=DEFAULT_FLIP);

//! Initialize the display, setting the clock and data pins.
//!
//! This method should be called once (typically in setup()) before calling any other.
//! @note It may be unnecessary depending on your hardware configuration.
void begin();

//! Sets the orientation of the display.
//!
//! Setting this parameter to true will cause the rendering on digits to be displayed
Expand Down
5 changes: 4 additions & 1 deletion TM1637TinyDisplay6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ TM1637TinyDisplay6::TM1637TinyDisplay6(uint8_t pinClk, uint8_t pinDIO,
m_scrollDelay = scrollDelay;
// Flip
m_flipDisplay = flip;

}

void TM1637TinyDisplay6::begin()
{
// Set the pin direction and default value.
// Both pins are set as inputs, allowing the pull-up resistors to pull them up
pinMode(m_pinClk, INPUT);
Expand Down
9 changes: 7 additions & 2 deletions TM1637TinyDisplay6.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@
class TM1637TinyDisplay6 {

public:
//! Initialize a TM1637TinyDisplay object, setting the clock and
//! data pins.
//! Initialize a TM1637TinyDisplay object.
//!
//! @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
Expand All @@ -128,6 +127,12 @@ class TM1637TinyDisplay6 {
TM1637TinyDisplay6(uint8_t pinClk, uint8_t pinDIO, unsigned int bitDelay = DEFAULT_BIT_DELAY,
unsigned int scrollDelay = DEFAULT_SCROLL_DELAY, bool flip=DEFAULT_FLIP);

//! Initialize the display, setting the clock and data pins.
//!
//! This method should be called once (typically in setup()) before calling any other.
//! @note It may be unnecessary depending on your hardware configuration.
void begin();

//! Sets the orientation of the display.
//!
//! Setting this parameter to true will cause the rendering on digits to be displayed
Expand Down
2 changes: 2 additions & 0 deletions examples/ATtiny85/ATtiny85.ino
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ const PROGMEM char FlashString[] = "Flash Test - 1234567890"; // Must be globall
const PROGMEM char FlashString2[] = "good";

void setup() {
display.begin();
display.clear();
display.setBrightness(BRIGHT_7);
}

Expand Down
3 changes: 2 additions & 1 deletion examples/TM1637-6Digit-Test/TM1637-6Digit-Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ TM1637TinyDisplay6 display(CLK, DIO);

void setup()
{
display.setBrightness(BRIGHT_HIGH);
display.begin();
display.clear();
display.setBrightness(BRIGHT_HIGH);
}

void loop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ int Sec = 0;

void setup()
{
display.setBrightness(BRIGHT_HIGH);
display.begin();
display.clear();
display.setBrightness(BRIGHT_HIGH);

pinMode(BUTTON_UP, INPUT_PULLUP);
pinMode(BUTTON_DOWN, INPUT_PULLUP);
Expand Down
3 changes: 2 additions & 1 deletion examples/TM1637-Countdown/TM1637-Countdown.ino
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ unsigned long countDown;

void setup()
{
display.setBrightness(BRIGHT_HIGH);
display.begin();
display.clear();
display.setBrightness(BRIGHT_HIGH);

// Record Epoch - Same as Timer Reset
startTime = millis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ TM1637TinyDisplay display(CLK, DIO);
void setup()
{
Serial.begin(9600);
display.begin();
display.clear();
display.setBrightness(BRIGHT_HIGH);
AnimationNum = 0;
}
Expand Down
2 changes: 2 additions & 0 deletions examples/TM1637Demo/TM1637Demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ const uint8_t ANIMATION3[218][4] PROGMEM = {
};

void setup() {
display.begin();
display.clear();
display.setBrightness(BRIGHT_7);
display.showNumber(1234);
delay(1000);
Expand Down
2 changes: 2 additions & 0 deletions examples/TM1637Test/TM1637Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ TM1637TinyDisplay display(CLK, DIO);

void setup()
{
display.begin();
display.clear();
}

void loop()
Expand Down
2 changes: 1 addition & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ TM1637TinyDisplay6 KEYWORD1
# Methods and Functions (KEYWORD2)
#######################################

begin KEYWORD2
setBrightness KEYWORD2
setSegments KEYWORD2
setScrolldelay KEYWORD2
Expand Down Expand Up @@ -60,7 +61,6 @@ BRIGHT_4 LITERAL1
BRIGHT_5 LITERAL1
BRIGHT_6 LITERAL1
BRIGHT_7 LITERAL1
BRIGHT_8 LITERAL1
BRIGHT_HIGH LITERAL1

ON LITERAL1
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TM1637TinyDisplay
version=1.7.1
version=1.8.0
author=Jason Cox <[email protected]>
maintainer=Jason Cox <[email protected]>
sentence=A simple library to display numbers, text and animation on 4 and 6 digit 7-segment TM1637 based display modules. Offers non-blocking animations and scrolling!
Expand Down

0 comments on commit 7052651

Please sign in to comment.