Merge branch 'dots'

This commit is contained in:
Avishay Orpaz
2016-11-21 23:55:37 +02:00
4 changed files with 20 additions and 9 deletions
+3 -3
View File
@@ -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,7 +21,7 @@ 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.
+2 -2
View File
@@ -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)
+3 -2
View File
@@ -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
//!
@@ -69,7 +70,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
+12 -2
View File
@@ -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);
}
@@ -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(7, false); // Turn off
display.setSegments(data);
delay(TEST_DELAY);
display.setBrightness(7, true); // Turn on
display.setSegments(data);
delay(TEST_DELAY);
}
// Done!
display.setSegments(SEG_DONE);