Display_Lib_RPI 2.3.0
A C++ Library to connect electronic displays to Linux single board computers.
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
TM1638plus_Model2 Class Reference

Class for Model 2. More...

#include <TM1638plus_Model2_RDL.hpp>

Inheritance diagram for TM1638plus_Model2:
Inheritance graph
[legend]

Public Member Functions

 TM1638plus_Model2 (uint8_t strobe, uint8_t clock, uint8_t data, int gpioDev, bool swap_nibbles=false)
 Constructor for class TM1638plus_Model2.
 
uint8_t ReadKey16 (void)
 Read push buttons method ( one of two methods available)
 
uint16_t ReadKey16Two (void)
 Read push buttons method ( one of two methods available)
 
void DisplaySegments (uint8_t segment, uint8_t segmentValue)
 Send seven segment value to display.
 
void DisplayHexNum (uint16_t numberUpper, uint16_t numberLower, uint8_t dots, AlignTextType_e=TMAlignTextLeft)
 Display an Hexadecimal number in each nibble (4 digits on display)
 
void DisplayDecNum (unsigned long number, uint8_t dots, AlignTextType_e=TMAlignTextLeft)
 Display an decimal number.
 
rdlib::Return_Codes_e DisplayStr (const char *string, uint16_t dots=0)
 Display a string, with decimal point display.
 
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.
 
void DisplayDecNumNibble (uint16_t numberUpper, uint16_t numberLower, uint8_t dots, AlignTextType_e=TMAlignTextLeft)
 Display an integer in each nibble (4 digits on display)
 
- Public Member Functions inherited from TM1638plus_common
 TM1638plus_common (uint8_t strobe, uint8_t clock, uint8_t data, int gpioDev)
 Constructor for class TM1638plus_common.
 
void reset (void)
 Reset / clear the display.
 
rdlib::Return_Codes_e displayBegin (void)
 Begin method , sets pin modes and activate display.
 
void brightness (uint8_t brightness)
 Sets the brightness level of segments in display on a scale of brightness.
 
uint16_t TMCommDelayGet (void)
 get the TM comm delay.
 
void TMCommDelayset (uint16_t)
 set the TM comm delay.
 
rdlib::Return_Codes_e displayClose (void)
 Close method , frees GPIO and deactivate display.
 

Private Attributes

bool _SWAP_NIBBLES = false
 

Additional Inherited Members

- Public Types inherited from TM1638plus_common
enum  AlignTextType_e : uint8_t { TMAlignTextRight = 1 , TMAlignTextLeft = 2 , TMAlignTextZeros = 3 }
 
enum  TMOffsetsMasks : uint8_t { TM_ASCII_OFFSET = 0x20 , TM_HEX_OFFSET = 0x10 , TM_DOT_MASK_DEC = 0x80 , TM_BRIGHT_MASK = 0x07 }
 
- Protected Types inherited from TM1638plus_common
enum  TMCommands : uint8_t {
  TM_ACTIVATE = 0x8F , TM_BUTTONS_MODE = 0x42 , TM_WRITE_LOC = 0x44 , TM_WRITE_INC = 0x40 ,
  TM_SEG_ADR = 0xC0 , TM_LEDS_ADR = 0xC1 , TM_BRIGHT_ADR = 0x88
}
 
- Protected Member Functions inherited from TM1638plus_common
void sendCommand (uint8_t value)
 Send command to display.
 
void sendData (uint8_t data)
 Send Data to display.
 
uint8_t HighFreqshiftin (void)
 Shifts in a byte of data from the Tm1638 SPI-like bus.
 
void HighFreqshiftOut (uint8_t val)
 Shifts out a byte of data on to the Tm1638 SPI-like bus.
 
- Protected Attributes inherited from TM1638plus_common
uint8_t _Display_CS
 
uint8_t _Display_SDATA
 
uint8_t _Display_SCLK
 
const uint8_t _TMDisplaySize = 8
 
int _DeviceNumGpioChip = 0
 
int _GpioHandle = 0
 

Detailed Description

Class for Model 2.

Constructor & Destructor Documentation

◆ TM1638plus_Model2()

TM1638plus_Model2::TM1638plus_Model2 ( uint8_t  strobe,
uint8_t  clock,
uint8_t  data,
int  gpioDev,
bool  swap_nibbles = false 
)

Constructor for class TM1638plus_Model2.

Parameters
strobeGPIO STB pin
clockGPIO CLK pin
dataGPIO DIO pin
gpioDevThe device number of a gpiochip.
swap_nibblesdefault false, if true, swaps nibbles on display byte.

Member Function Documentation

◆ 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
valuesAn 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,
AlignTextType_e  TextAlignment = TMAlignTextLeft 
)

Display an decimal number.

Parameters
numberinteger to display 2^32.
dotsDecimal point display, switch's on decimal point for those positions.
TextAlignmentleading zeros 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,
AlignTextType_e  TextAlignment = TMAlignTextLeft 
)

Display an integer in each nibble (4 digits on display)

Parameters
numberUpperupper nibble integer 2^16
numberLowerlower nibble integer 2^16
dotsTurn on or off decimal points to 0xFF d7d6d5d4d3d2d1d0
TextAlignmentleading zeros, 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,
AlignTextType_e  TextAlignment = TMAlignTextLeft 
)

Display an Hexadecimal number in each nibble (4 digits on display)

Parameters
numberUpperupper nibble integer 2^16
numberLowerlower nibble integer 2^16
dotsDecimal point display, switch's on decimal point for those positions. 0 to 0xFF
TextAlignmentleading zeros, 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
segment0-7 byte of data corresponding to segments abcdefg(dp) 01234567.
digitdisplay 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()

rdlib::Return_Codes_e TM1638plus_Model2::DisplayStr ( const char *  string,
uint16_t  dots = 0 
)

Display a string, with decimal point display.

Parameters
stringpointer to char array
dotsTurn on or off decimal points 0 to 0xFF d7d6d5d4d3d2d1d0
Returns
error code if string is nullptr
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..

◆ 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.
  1. S1 = 0x0001
  2. S16 = 0x8000
  3. S1 + S16 together = 0x8001

Data matrix for read key_value. c = datain c3 0110 0110 c2 0110 0110 c1 0110 0110 c0 0110 0110 :uint8_ts read 8,16 7,15 6,14 5,13 4,12 3,11 2,10 1,9 :button value

Note
Can detect multiple key presses. However, See notes section in readme regarding, problems with seven segment display when pressing certain keys in combination.

Member Data Documentation

◆ _SWAP_NIBBLES

bool TM1638plus_Model2::_SWAP_NIBBLES = false
private

Swap the nibbles on display byte


The documentation for this class was generated from the following files: