Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
|
Public Member Functions | |
TM1637Display (uint8_t pinClk, uint8_t pinDIO) | |
void | setBrightness (uint8_t brightness, bool on=true) |
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) |
void | showNumberDecEx (int num, uint8_t dots=0, bool leading_zero=false, uint8_t length=4, uint8_t pos=0) |
uint8_t | encodeDigit (uint8_t digit) |
Protected Member Functions | |
void | bitDelay () |
void | start () |
void | stop () |
bool | writeByte (uint8_t b) |
TM1637Display::TM1637Display | ( | uint8_t | pinClk, |
uint8_t | pinDIO | ||
) |
Initialize a TM1637Display object, setting the clock and data pins.
pinClk | - The number of the digital pin connected to the clock pin of the module |
pinDIO | - The number of the digital pin connected to the DIO pin of the module |
uint8_t TM1637Display::encodeDigit | ( | uint8_t | digit | ) |
Translate a single digit into 7 segment code
The method accepts a number between 0 - 15 and converts it to the code required to display the number on a 7 segment display. Numbers between 10-15 are converted to hexadecimal digits (A-F)
digit | A number between 0 to 15 |
void TM1637Display::setBrightness | ( | uint8_t | brightness, |
bool | on = true |
||
) |
Sets the brightness of the display.
The setting takes effect when a command is given to change the data being displayed.
brightness | A number from 0 (lowes brightness) to 7 (highest brightness) |
on | Turn display on or off |
void TM1637Display::setSegments | ( | const uint8_t | segments[], |
uint8_t | length = 4 , |
||
uint8_t | pos = 0 |
||
) |
Display arbitrary data on the module
This function receives raw segment values as input and displays them. The segment data is given as a byte array, each byte corresponding to a single digit. Within each byte, bit 0 is segment A, bit 1 is segment B etc. The function may either set the entire display or any desirable part on its own. The first digit is given by the pos argument with 0 being the leftmost digit. The length argument is the number of digits to be set. Other digits are not affected.
segments | An array of size length containing the raw segment values |
length | The number of digits to be modified |
pos | The position from which to start the modification (0 - leftmost, 3 - rightmost) |
void TM1637Display::showNumberDec | ( | int | num, |
bool | leading_zero = false , |
||
uint8_t | length = 4 , |
||
uint8_t | pos = 0 |
||
) |
Displayes a decimal number
Dispalyes the given argument as a decimal number
num | The number to be shown |
leading_zero | When true, leading zeros are displayed. Otherwise unnecessary digits are blank |
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) |
pos | The position most significant digit (0 - leftmost, 3 - rightmost) |
void TM1637Display::showNumberDecEx | ( | int | num, |
uint8_t | dots = 0 , |
||
bool | leading_zero = false , |
||
uint8_t | length = 4 , |
||
uint8_t | pos = 0 |
||
) |
Displayes a decimal number, with dot control
Dispalyes the given argument as a decimal number. The dots between the digits (or colon) can be individually controlled
num | The number to be shown |
dots | Dot/Colon enable. The argument is a bitmask, with each bit corresponding to a dot between the digits (or colon mark, as implemented by each module). i.e. For displays with dots between each digit:
|
leading_zero | When true, leading zeros are displayed. Otherwise unnecessary digits are blank |
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) |
pos | The position least significant digit (0 - leftmost, 3 - rightmost) |