From af575aa91759fe297a8f8b078403149bf12cbc1b Mon Sep 17 00:00:00 2001 From: Avishay Orpaz Date: Wed, 16 Nov 2016 23:59:21 +0200 Subject: [PATCH 1/5] Fix dot testing --- examples/TM1637Test/TM1637Test.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/TM1637Test/TM1637Test.ino b/examples/TM1637Test/TM1637Test.ino index 5106a5a..a6ff49a 100644 --- a/examples/TM1637Test/TM1637Test.ino +++ b/examples/TM1637Test/TM1637Test.ino @@ -69,7 +69,7 @@ void loop() // Run through all the dots for(k=0; k <= 4; k++) { - display.showNumberDecEx(0, (1 << k), true); + display.showNumberDecEx(0, (0x80 >> k), true); delay(TEST_DELAY); } From adaaf49963e8bf2a890d7cb3fef33a189e30e9a2 Mon Sep 17 00:00:00 2001 From: Avishay Orpaz Date: Sat, 19 Nov 2016 14:37:01 +0200 Subject: [PATCH 2/5] Fix dscription of the showNumberDec function https://github.com/avishorp/TM1637/issues/14 --- TM1637Display.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TM1637Display.h b/TM1637Display.h index 2b8c842..fd96730 100644 --- a/TM1637Display.h +++ b/TM1637Display.h @@ -69,7 +69,7 @@ public: //! @param length The number of digits to set. The user must ensure that the number to be shown //! fits to the number of digits requested (for example, if two digits are to be displayed, //! the number must be between 0 to 99) - //! @param pos The position least significant digit (0 - leftmost, 3 - rightmost) + //! @param pos The position most significant digit (0 - leftmost, 3 - rightmost) void showNumberDec(int num, bool leading_zero = false, uint8_t length = 4, uint8_t pos = 0); //! Displayes a decimal number, with dot control From 196c9c0dd3151efdee7a2e12cb6ea4b7e6235356 Mon Sep 17 00:00:00 2001 From: Avishay Orpaz Date: Sat, 19 Nov 2016 14:51:41 +0200 Subject: [PATCH 3/5] Refactor the brightness parameter in setBrightness to value + enable --- TM1637Display.cpp | 4 ++-- TM1637Display.h | 3 ++- examples/TM1637Test/TM1637Test.ino | 12 +++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/TM1637Display.cpp b/TM1637Display.cpp index 307c8dc..c2912a5 100644 --- a/TM1637Display.cpp +++ b/TM1637Display.cpp @@ -71,9 +71,9 @@ TM1637Display::TM1637Display(uint8_t pinClk, uint8_t pinDIO) digitalWrite(m_pinDIO, LOW); } -void TM1637Display::setBrightness(uint8_t brightness) +void TM1637Display::setBrightness(uint8_t brightness, bool on) { - m_brightness = brightness; + m_brightness = (brightness & 0x7) | (on? 0x08 : 0x00); } void TM1637Display::setSegments(const uint8_t segments[], uint8_t length, uint8_t pos) diff --git a/TM1637Display.h b/TM1637Display.h index fd96730..f8b12b9 100644 --- a/TM1637Display.h +++ b/TM1637Display.h @@ -43,7 +43,8 @@ public: //! displayed. //! //! @param brightness A number from 0 (lowes brightness) to 7 (highest brightness) - void setBrightness(uint8_t brightness); + //! @param on Turn display on or off + void setBrightness(uint8_t brightness, bool on = true); //! Display arbitrary data on the module //! diff --git a/examples/TM1637Test/TM1637Test.ino b/examples/TM1637Test/TM1637Test.ino index a6ff49a..115bcb7 100644 --- a/examples/TM1637Test/TM1637Test.ino +++ b/examples/TM1637Test/TM1637Test.ino @@ -89,11 +89,21 @@ void loop() // Brightness Test for(k = 0; k < 4; k++) data[k] = 0xff; - for(k = 0; k < 16; k++) { + for(k = 0; k < 7; k++) { display.setBrightness(k); display.setSegments(data); delay(TEST_DELAY); } + + // On/Off test + for(k = 0; k < 4; k++) { + display.setBrightness(k, false); // Turn off + display.setSegments(data); + delay(TEST_DELAY); + display.setBrightness(k, true); // Turn on + display.setSegments(data); + delay(TEST_DELAY); + } // Done! display.setSegments(SEG_DONE); From d308c624f8368967696cf49ccd668d77bf1dd00b Mon Sep 17 00:00:00 2001 From: Avishay Orpaz Date: Mon, 21 Nov 2016 23:44:27 +0200 Subject: [PATCH 4/5] Spelling corrections in README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ec54d98..e1c7b46 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ An Arduino library for 7-segment display modules based on the TM1637 chip, such Hardware Connection ------------------- -The display modules has two signal connection (and two power connections) which are CLK and DIO. These pins can be connected to any pair of digital pins on the Arduino. When an object is created, the pins should be configured. There is no limitaion on the number of instances used concurrently (as long as each instance has a pin pair of its own) +The display modules has two signal connection (and two power connections) which are CLK and DIO. These pins can be connected to any pair of digital pins on the Arduino. When an object is created, the pins should be configured. There is no limitation on the number of instances used concurrently (as long as each instance has a pin pair of its own) Installation ------------ @@ -21,8 +21,8 @@ The library provides a single class named TM1637Display. An instance of this cla * `setSegments` - Set the raw value of the segments of each digit * `showNumberDec` - Display a decimal number -* `showNumberDexEx` - Display a decimal number with decimal points or colon +* `showNumberDecEx` - Display a decimal number with decimal points or colon * `setBrightness` - Sets the brightness of the display -The information given above is only a summary. Please refer to TM1637Display.h for more information. An example is included, demonstarting the operation of most of the functions. +The information given above is only a summary. Please refer to TM1637Display.h for more information. An example is included, demonstrating the operation of most of the functions. From c0642d5427b2b95e787cbccc5700a68b6d4c0d2c Mon Sep 17 00:00:00 2001 From: Avishay Orpaz Date: Mon, 21 Nov 2016 23:47:54 +0200 Subject: [PATCH 5/5] Fix brightness setting in On/Off test --- examples/TM1637Test/TM1637Test.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/TM1637Test/TM1637Test.ino b/examples/TM1637Test/TM1637Test.ino index 115bcb7..6a8ddc6 100644 --- a/examples/TM1637Test/TM1637Test.ino +++ b/examples/TM1637Test/TM1637Test.ino @@ -97,10 +97,10 @@ void loop() // On/Off test for(k = 0; k < 4; k++) { - display.setBrightness(k, false); // Turn off + display.setBrightness(7, false); // Turn off display.setSegments(data); delay(TEST_DELAY); - display.setBrightness(k, true); // Turn on + display.setBrightness(7, true); // Turn on display.setSegments(data); delay(TEST_DELAY); }