Class for Model 2.
More...
#include <TM1638plus_Model2.h>
|
| TM1638plus_Model2 (uint8_t strobe, uint8_t clock, uint8_t data, bool swap_nibbles=false, bool high_freq=false) |
| Constructor for class TM1638plus_Model2. More...
|
|
uint8_t | ReadKey16 (void) |
| Read push buttons method ( one of two methods available) More...
|
|
uint16_t | ReadKey16Two (void) |
| Read push buttons method ( one of two methods available) More...
|
|
void | DisplaySegments (uint8_t segment, uint8_t segmentValue) |
| Send seven segment value to display. More...
|
|
void | DisplayHexNum (uint16_t numberUpper, uint16_t numberLower, uint8_t dots, boolean leadingZeros=true, AlignTextType_e=TMAlignTextLeft) |
| Display an Hexadecimal number in each nibble (4 digits on display) More...
|
|
void | DisplayDecNum (unsigned long number, uint8_t dots, boolean leadingZeros=true, AlignTextType_e=TMAlignTextLeft) |
| Display an decimal number. More...
|
|
void | DisplayStr (const char *string, const uint16_t dots=0) |
| Display a string, with decimal point display. More...
|
|
void | ASCIItoSegment (const uint8_t values[]) |
| Takes in Array of 8 ASCII bytes , Called from DisplayStr . Scans each ASCII byte converts to array of 8 segment bytes where each byte represents a segment. Then calls DisplaySegments() method to display segments on display. More...
|
|
void | DisplayDecNumNibble (uint16_t numberUpper, uint16_t numberLower, uint8_t dots, boolean leadingZeros=true, AlignTextType_e=TMAlignTextLeft) |
| Display an integer in each nibble (4 digits on display) More...
|
|
| TM1638plus_common () |
| Constructor for class TM1638plus_common.
|
|
void | displayBegin () |
| Begin method , sets pin modes and activate display. More...
|
|
void | reset (void) |
| Reset / clear the display. More...
|
|
void | brightness (uint8_t brightness) |
| Sets the brightness level of segments in display on a scale of brightness. More...
|
|
◆ TM1638plus_Model2()
TM1638plus_Model2::TM1638plus_Model2 |
( |
uint8_t |
strobe, |
|
|
uint8_t |
clock, |
|
|
uint8_t |
data, |
|
|
bool |
swap_nibbles = false , |
|
|
bool |
high_freq = false |
|
) |
| |
Constructor for class TM1638plus_Model2.
- Parameters
-
strobe | GPIO STB pin |
clock | GPIO CLK pin |
data | GPIO DIO pin |
swap_nibbles | default false, if true, swaps nibbles on display byte. |
high_freq | Changes the value of parameter _HIGH_FREQ which is default false. |
- Note
- _HIGH_FREQ is used when running high freq MCU CPU (~>100Mhz) because of issues with button function. Pass true to turn on.
◆ ASCIItoSegment()
void TM1638plus_Model2::ASCIItoSegment |
( |
const uint8_t |
values[] | ) |
|
Takes in Array of 8 ASCII bytes , Called from DisplayStr . Scans each ASCII byte converts to array of 8 segment bytes where each byte represents a segment. Then calls DisplaySegments() method to display segments on display.
- Parameters
-
values | An array of 8 ASCII bytes |
- Note
- byte 0 represents a in segment and then each bit represents the a segment in each digit. So for "00000005" is converted by DisplayStr to ASCII hex"3F 3F 3F 3F 3F 3F 3F 6D" where left is first digit. this is converted to hex "FF FE FF FF FE FF 01 00" by ASCIItoSegment, Where left is first segment. So "a" segment is turned on for all digits and "b" is on for all except last digit. The bits are mapping below abcdefg(dp) = 01234567 ! . See for mapping of seven segment to digit https://en.wikipedia.org/wiki/Seven-segment_display We have to do this as TM1638 model 2 is addressed by segment not digit unlike Model 1&3
◆ DisplayDecNum()
void TM1638plus_Model2::DisplayDecNum |
( |
unsigned long |
number, |
|
|
uint8_t |
dots, |
|
|
boolean |
leadingZeros = true , |
|
|
AlignTextType_e |
TextAlignment = TMAlignTextLeft |
|
) |
| |
Display an decimal number.
- Parameters
-
number | integer to display 2^32. |
dots | Decimal point display, switch's on decimal point for those positions. |
leadingZeros | leading zeros set, true on , false off. |
TextAlignment | left or right text alignment on display. |
- Note
- Converts to string internally
◆ DisplayDecNumNibble()
void TM1638plus_Model2::DisplayDecNumNibble |
( |
uint16_t |
numberUpper, |
|
|
uint16_t |
numberLower, |
|
|
uint8_t |
dots, |
|
|
boolean |
leadingZeros = true , |
|
|
AlignTextType_e |
TextAlignment = TMAlignTextLeft |
|
) |
| |
Display an integer in each nibble (4 digits on display)
- Parameters
-
numberUpper | upper nibble integer 2^16 |
numberLower | lower nibble integer 2^16 |
dots | Turn on or off decimal points to 0xFF d7d6d5d4d3d2d1d0 |
leadingZeros | leading zeros set, true on , false off |
TextAlignment | left or right text alignment on display |
- Note
- Divides the display into two nibbles and displays a Decimal number in each. takes in two numbers 0-9999 for each nibble.
◆ DisplayHexNum()
void TM1638plus_Model2::DisplayHexNum |
( |
uint16_t |
numberUpper, |
|
|
uint16_t |
numberLower, |
|
|
uint8_t |
dots, |
|
|
boolean |
leadingZeros = true , |
|
|
AlignTextType_e |
TextAlignment = TMAlignTextLeft |
|
) |
| |
Display an Hexadecimal number in each nibble (4 digits on display)
- Parameters
-
numberUpper | upper nibble integer 2^16 |
numberLower | lower nibble integer 2^16 |
dots | Decimal point display, switch's on decimal point for those positions. 0 to 0xFF |
leadingZeros | leading zeros set, true on , false off |
TextAlignment | left or right text alignment on display |
- Note
- Divides the display into two nibbles and displays a Decimal number in each. takes in two numbers 0-9999 for each nibble. Converts to string internally.
◆ DisplaySegments()
void TM1638plus_Model2::DisplaySegments |
( |
uint8_t |
segment, |
|
|
uint8_t |
digit |
|
) |
| |
Send seven segment value to display.
- Parameters
-
segment | 0-7 byte of data corresponding to segments abcdefg(dp) 01234567. |
digit | display digit position, 0x00 to 0xFF d8d7d6d5d54d3d2d1. |
- Note
for segment parameter a is 0 , dp is 7 , segment Value is which segments are off or on for each digit. To to set all "a" on send (0x00,0xFF). To set all segment "g" off (0x06,0X00)
◆ DisplayStr()
void TM1638plus_Model2::DisplayStr |
( |
const char * |
string, |
|
|
const uint16_t |
dots = 0 |
|
) |
| |
Display a string, with decimal point display.
- Parameters
-
string | pointer to char array |
dots | Turn on or off decimal points 0 to 0xFF d7d6d5d4d3d2d1d0 |
- Note
- Takes in string , converts it to ASCII using the font and masks for the decimal point. Then passes array of eight ASCII bytes to DisplayValues function
◆ ReadKey16()
unsigned char TM1638plus_Model2::ReadKey16 |
( |
void |
| ) |
|
Read push buttons method ( one of two methods available)
- Returns
- 0 if no button pressed or a decimal value of buttons 1-16 (1 for S1 ... 16 for S16 ).
- Note
- User may have to debounce buttons depending on application.. model 2 example here in ADC file TM1638plus_ADC_TEST_Model2.ino
◆ ReadKey16Two()
uint16_t TM1638plus_Model2::ReadKey16Two |
( |
void |
| ) |
|
Read push buttons method ( one of two methods available)
- Returns
- A 16 bit integer where each bit correspond to a switch.
- S1 = 0x0001
- S16 = 0x8000
- S1 + S16 together = 0x8001
- Note
- Can detect multiple key presses. However, See notes section in readme regarding, problems with seven segment display when pressing certain keys in combination.
The documentation for this class was generated from the following files: