Upload
dangcong
View
229
Download
0
Embed Size (px)
Citation preview
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 1
ET-DSP I2C 7SEG BASE
ET-DSP I2C 7SEG BASE is a Control-Panel of 7-SEGMENT Display that supports the
simultaneous connections with 4 sets of 3-DIGIT or 4-DIGIT Display. It can be connected to
control 4 of External Display Boards “ET-DSP 7SEG 3DG” or “ET-DSP 7SEG 4DG”
simultaneously via 14PIN PAIR Cable. The connection type of board is commanded via I2C Bus
Port by using CHIP IC No.HT16K33 to control the display.
An example shows the connection between Board ET-DSP I2C 7SEG BASE and DISPLAY
“ET-DSP 7SEG 3DG/4DG”.
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 2
SPECIFICATIONS OF ET-DSP I2C 7SEG BASE
Use CHIP HT16K33 from HOLTEK to control the display internal board
Use CONNECTOR WAFER 4 PIN 2.54mm to connect with I2C Bus
Support both 3.3V and 5V
Can setup 8 different Address Positions for HT16K33; so it can connect a maximum of 8
boards together internal Bus of the same I2C Bus.
Have 4 of Connector 14 PIN IDC to connect to 3-DIGIT or 4-DIGIT Display “ET-DSP
7SEG 3DG” or “ET-DSP 7SEG 4DG”; it can connect a maximum of 4 panels at the same
time
Board Size: 40.5mm. X 63.5mm. (1.5inchs X 2.5inchs)
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 3
HOW TO SETUP I2C SLAVE ADDRESS POSITIONS OF BOARD ET-DSP I2C
7SEG BASE
Normally, it can setup 8 of I2C Slave Address Position for CHIP HT16K33; it uses Pin A0,
A1 and A2 to be logical condition for setting position of A2, A1 and A0 for I2C Slave Address
Position. Board ET-DSP I2C 7SEG BASE uses PAD Jumper to setup logical condition of A2, A1
and A0 for I2C Slave Address Position. If PAD Jumper of any signal is opened (OPEN), the
Logic of the Signal Pin is “0”; or, if PAD Jumper of any signal is closed (CLOSE), the Logic of the
Signal Pin becomes “1” instantly. Normally, PAD Jumper is set as OPEN; so, Logic of A2, A1
and A0 always is “0”. Code Structure of Slave Address Position of HT16K33 is shown below;
It shows PAD Jumper’s position for setting Address of Board ET-DSP I2C 7SEG BASE.
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 4
It shows feature of Board ET-DSP 7SEG 3DG for connecting together with ET-DSP I2C 7SEG
BASE.
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 5
It shows feature of Board ET-DSP 7SEG 4DG for connecting together with ET-DSP I2C 7SEG
BASE.
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 6
When using this Board ET-DSP I2C 7SEG BASE, it has to connect together with External
Display Board. There are 2 alternatives as followed;
Board ET-DSP 7SEG 3DG: It is a 0.56 inch wide Display with 3-DIGIT.
Board ET-DSP 7SEG 4DG: It is a 0.36 inch wide Display with 4-DIGIT.
It can connect a maximum of 4 External Display Boards together with 1 Board ET-DSP
I2C 7SEG BASE via 14PIN PAIR CABLE; in this case, it is free to use the same or mixed
models of Display Board on one panel.
It shows the connection between Board ET-DSP 7SEG 3DG/4DG and ET-DSP I2C 7SEG
BASE.
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 7
ET-DSP I2C 7SEG PANEL3
ET-DSP I2C 7SEG PANEL3 is a 7-SEGMENT DISPLAY with 3-DIGIT, it is provided with
frame to cover the circuit and hold panels. Board is commanded via I2C Bus Port by using CHIP
IC No.HT16K33 to control the display.
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 8
SPECIFICATIONS OF ET-DSP I2C 7SEG PANEL3
Use CHIP HT16K33 from HOLTEK to control the display internal board
Use CONNECTOR WAFER 4PIN 2.54mm to connect to I2C Bus
Can setup 8 Address Positions for HT16K33; so it can connect a maximum of 8 Display
Board “ET-DSP I2C 7SEG PANEL3” together in the same I2C Bus.
Support both 3.3V and 5V
Use a 0.56 inch wide red 7-SEGMENT Display with 3-DIGIT
Size of frame of Display
o Width of Panel: 48mm X 29mm
o Hole size to hold frame of Display: 45mm X 26mm
o Height: 22mm.
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 9
It shows feature of Board ET-DSP I2C 7SEG PANEL3.
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 10
HOW TO SETUP I2C SLAVE ADDRESS POSITIONS OF BOARD ET-DSP I2C
7SEG PANEL3
Normally, it can setup 8 of I2C Slave Address Position for CHIP HT16K33; it uses Pin A0,
A1 and A2 to be logical condition for setting position of A2, A1 and A0 for I2C Slave Address
Position. Board ET-DSP I2C 7SEG PANEL3 uses PAD Jumper to setup logical condition of A2,
A1 and A0 for I2C Slave Address Position. If PAD Jumper of any signal is opened (OPEN), the
Logic of the Signal Pin is “0”; or, if PAD Jumper of any signal is closed (CLOSE), the Logic of the
Signal Pin becomes “1” instantly. Normally, PAD Jumper is set as OPEN; so, Logic of A2, A1
and A0 always is “0”. Code Structure of Slave Address Position of HT16K33 is shown below;
It shows PAD Jumper’s positions to setup Address of Board ET-DSP I2C 7SEG PANEL3.
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 11
ET-DSP I2C 7SEG PANEL4
ET-DSP I2C 7SEG PANEL4 is a 7-SEGMENT DISPLAY with 4-DIGIT, it is provided with
frame to cover the circuit and hold panels. Board is commanded via I2C Bus Port by using CHIP
IC No.HT16K33 to control the display.
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 12
SPECIFICATIONS OF ET-DSP I2C 7SEG PANEL4
Use CHIP HT16K33 from HOLTEK to control the display internal board
Use CONNECTOR WAFER 4PIN 2.54mm to connect to I2C Bus
Can setup 8 Address Positions for HT16K33; so it can connect a maximum of 8 Display
Board “ET-DSP I2C 7SEG PANEL4” together in the same I2C Bus.
Support both 3.3V and 5V
Use a 0.36 inch wide red 7-SEGMENT Display with 4-DIGIT
Size of frame of Display
o Width of Panel: 48mm X 29mm
o Hole size to hold frame of Display: 45mm X 26mm
o Height: 22mm.
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 13
It shows feature of Board ET-DSP I2C 7SEG PANEL4.
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 14
HOW TO SETUP I2C SLAVE ADDRESS POSITONS OF BOARD ET-DSP I2C
7SEG PANEL4
Normally, it can setup 8 of I2C Slave Address Position for CHIP HT16K33; it uses Pin A0,
A1 and A2 to be logical condition for setting position of A2, A1 and A0 for I2C Slave Address
Position. Board ET-DSP I2C 7SEG PANEL4 uses PAD Jumper to setup logical condition of A2,
A1 and A0 for I2C Slave Address Position. If PAD Jumper of any signal is opened (OPEN), the
Logic of the Signal Pin is “0”; or, if PAD Jumper of any signal is closed (CLOSE), the Logic of the
Signal Pin becomes “1” instantly. Normally, PAD Jumper is set as OPEN; so, Logic of A2, A1
and A0 always is “0”. Code Structure of Slave Address Position of HT16K33 is shown below;
It shows PAD Jumper’s positions to setup ADDRESS of Board ET-DSP I2C 7SEG PANEL4.
#include <Wire.h>
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 15
/*
* ET-ESP8266-RS485 Hardware Board
* Demo : Test HT16K33 Control 7 Segment Display
*/
#include "ET_HT16K33_7SEGMENT.h"
#define I2C_SCL1_PIN D1 #define I2C_SDA1_PIN D2
ET_HT16K33_7SEGMENT display = ET_HT16K33_7SEGMENT();
void setup()
{
Wire.begin(I2C_SDA1_PIN,I2C_SCL1_PIN);
display.begin(0x70);
}
void loop()
{
//=======================================================================================
// Test Display Segment : A..G,Dp
//=======================================================================================
for(uint8_t seg=0; seg<8; seg++) // Seg-A,Seg-B,Seg-C,...,Seg-G,Seg-Dp
{
display.writeDigitSegment(0,(1<<(seg))); // Write Buffer Digit[0] : [x][?][?][?]
display.writeDigitSegment(1,(1<<(seg))); // Write Buffer Digit[1] : [?][x][?][?]
display.writeDigitSegment(2,(1<<(seg))); // Write Buffer Digit[2] : [?][?][x][?]
display.writeDigitSegment(3,(1<<(seg))); // Write Buffer Digit[3] : [?][?][?][x]
//=====================================================================================
display.writeDisplayPanel0(); // Transfer Buffer to Display Panel[0]
display.writeDisplayPanel1(); // Transfer Buffer to Display Panel[1]
display.writeDisplayPanel2(); // Transfer Buffer to Display Panel[2]
display.writeDisplayPanel3(); // Transfer Buffer to Display Panel[3]
//=====================================================================================
delay(1000);
//=====================================================================================
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 16
//=======================================================================================
// Test Display Number : 0..9,A..F
//=======================================================================================
for(uint16_t bcd=0; bcd<16; bcd++) // 0..9,A..F
{
display.writeDigitBCD(0,bcd); // Write Buffer Digit[0] : [0][?][?][?]
display.writeDigitBCD(1,bcd); // Write Buffer Digit[1] : [?][1][?][?]
display.writeDigitBCD(2,bcd); // Write Buffer Digit[2] : [?][?][2][?]
display.writeDigitBCD(3,bcd); // Write Buffer Digit[3] : [?][?][?][3]
//=====================================================================================
display.writeDisplayPanel0(); // Transfer Buffer to Display Panel[0]
display.writeDisplayPanel1(); // Transfer Buffer to Display Panel[1]
display.writeDisplayPanel2(); // Transfer Buffer to Display Panel[2]
display.writeDisplayPanel3(); // Transfer Buffer to Display Panel[3]
//=====================================================================================
delay(1000);
//=====================================================================================
}
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 17
/*
* ET-MEGA32U4-RS485 Hardware Board
* Demo : Test HT16K33 Control 7 Segment Display
*/
#include <Wire.h>
#include "ET_HT16K33_7SEGMENT.h"
ET_HT16K33_7SEGMENT display = ET_HT16K33_7SEGMENT();
void setup()
{
display.begin(0x70);
}
void loop()
{
//=======================================================================================
// Test Display Segment : A..G,Dp
//=======================================================================================
for(uint8_t seg=0; seg<8; seg++) // Seg-A,Seg-B,Seg-C,...,Seg-G,Seg-Dp
{
display.writeDigitSegment(0,(1<<(seg))); // Write Buffer Digit[0] : [x][?][?][?]
display.writeDigitSegment(1,(1<<(seg))); // Write Buffer Digit[1] : [?][x][?][?]
display.writeDigitSegment(2,(1<<(seg))); // Write Buffer Digit[2] : [?][?][x][?]
display.writeDigitSegment(3,(1<<(seg))); // Write Buffer Digit[3] : [?][?][?][x]
//=====================================================================================
display.writeDisplayPanel0(); // Transfer Buffer to Display Panel[0]
display.writeDisplayPanel1(); // Transfer Buffer to Display Panel[1]
display.writeDisplayPanel2(); // Transfer Buffer to Display Panel[2]
display.writeDisplayPanel3(); // Transfer Buffer to Display Panel[3]
//=====================================================================================
delay(1000);
//=====================================================================================
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 18
//=======================================================================================
// Test Display Number : 0..9,A..F
//=======================================================================================
for(uint16_t bcd=0; bcd<16; bcd++) // 0..9,A..F
{
display.writeDigitBCD(0,bcd); // Write Buffer Digit[0] : [0][?][?][?]
display.writeDigitBCD(1,bcd); // Write Buffer Digit[1] : [?][1][?][?]
display.writeDigitBCD(2,bcd); // Write Buffer Digit[2] : [?][?][2][?]
display.writeDigitBCD(3,bcd); // Write Buffer Digit[3] : [?][?][?][3]
//=====================================================================================
display.writeDisplayPanel0(); // Transfer Buffer to Display Panel[0]
display.writeDisplayPanel1(); // Transfer Buffer to Display Panel[1]
display.writeDisplayPanel2(); // Transfer Buffer to Display Panel[2]
display.writeDisplayPanel3(); // Transfer Buffer to Display Panel[3]
//=====================================================================================
delay(1000);
//=====================================================================================
}
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 19
/***********************************************
File : ET_HT16K33_7SEGMENT.H
Library For HT16K33 Control 7 Segment Display
write by...ETT CO.,LTD.
***********************************************/
#ifndef ET_HT16K33_7SEGMENT_h
#define ET_HT16K33_7SEGMENT_h
#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <Wire.h>
#define HT16K33_BLINK_CMD 0x80
#define HT16K33_BLINK_DISPLAYON 0x01
#define HT16K33_BLINK_OFF 0
#define HT16K33_BLINK_2HZ 1
#define HT16K33_BLINK_1HZ 2
#define HT16K33_BLINK_HALFHZ 3
#define HT16K33_CMD_BRIGHTNESS 0xE0
#define MAX_7SEGMENT_DIGIT 4
#define HEX 16
#define DEC 10
#define OCT 8
#define BIN 2
#define BYTE 0
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 20
class ET_HT16K33_7SEGMENT
{
public:
ET_HT16K33_7SEGMENT(void);
void begin(uint8_t _addr); // I2C Address
void setBrightness(uint8_t brightness); // Setup Brightness
void blinkRate(uint8_t blinkrate); // Setup Blink Rate
void writeUpdateDisplay(void); // Update Display Panel[1..4]
void writeDisplayPanel0(void); // Update Display Panel[1]
void writeDisplayPanel1(void); // Update Display Panel[2]
void writeDisplayPanel2(void); // Update Display Panel[3]
void writeDisplayPanel3(void); // Update Display Panel[4]
void clear(void); // Clear All Display
void clear(uint8_t panel); // Clear Panel[n] Display
//
size_t write(uint8_t c);
void print(char val, // Value
int base = BYTE); // Value Type
void print(unsigned char, // Value
int base = BYTE); // Value Type
void print(int val, // Value
int base = DEC); // Value Type
void print(unsigned int val, // Value
int base = DEC); // Value Type
void print(long val, // Value
int base = DEC); // Value Type
void print(unsigned long val, // Value
int base = DEC); // Value Type
void print(double val, // Value
int base = BIN); // Value Type(2)
void println(void);
void println(char val, // Value
int base = BYTE); // Value Type
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 21
void println(unsigned char val, // Value
int base = BYTE); // Value Type
void println(int val, // Value
int base = DEC); // Value Type
void println(unsigned int val, // Value
int base = DEC); // Value Type
void println(long val, // Value
int base = DEC); // Value Type
void println(unsigned long val, // Value
int base = DEC); // Value Type
void println(double val, // Value
int base = BIN); // Value Type(2)
void printNumber(long val, // Value
uint8_t = BIN); // Value Type(2)
void printFloat(double val, // Value
uint8_t fracDigits = 2, // frac. Digits(x.yy)
uint8_t base = DEC); // Value Type
void printError(void);
void writeDigitSegment(uint8_t dig_pos, // Digit Position For Display
uint8_t seg_val); // 7-Segment Value
void writeDigitBCD(uint8_t dig_pos, // Digit Position For Display
uint8_t bcd_val, // BCD[0..F] For Display
boolean dot = false); // Dot 7-Segment ON/OFF Display
private:
uint8_t position; // Dislay Digit Position
uint8_t displaybuffer[4]; // Dummy Display Buffer
uint8_t panel0buffer[4]; // Panel[0] Display Buffer(Lower LSB)
uint8_t panel1buffer[4]; // Panel[1] Display Buffer(Lower MSB)
uint8_t panel2buffer[4]; // Panel[2] Display Buffer(Upper LSB)
uint8_t panel3buffer[4]; // Panel[3] Display Buffer(Upper MSB)
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 22
protected:
uint8_t i2c_addr; // HT16K33 I2C Address
uint8_t panel0_dg; // Panel[0] Digit Display
uint8_t panel1_dg; // Panel[1] Digit Display
uint8_t panel2_dg; // Panel[2] Digit Display
uint8_t panel3_dg; // Panel[3] Digit Display
};
#endif
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 23
/***********************************************
File : ET_HT16K33_7SEGMENT.CPP
Library For HT16K33 Control 7 Segment Display
write by...ETT CO.,LTD.
***********************************************/
#include <Wire.h>
#include "ET_HT16K33_7SEGMENT.h"
#ifndef _swap_int16_t
#define _swap_int16_t(a, b) { int16_t t = a; a = b; b = t; }
#endif
static const uint8_t numbertable[] =
{
0x3F, /* 0 */
0x06, /* 1 */
0x5B, /* 2 */
0x4F, /* 3 */
0x66, /* 4 */
0x6D, /* 5 */
0x7D, /* 6 */
0x07, /* 7 */
0x7F, /* 8 */
0x6F, /* 9 */
0x77, /* a */
0x7C, /* b */
0x39, /* C */
0x5E, /* d */
0x79, /* E */
0x71, /* F */
};
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 24
ET_HT16K33_7SEGMENT::ET_HT16K33_7SEGMENT(void)
{
position = 0;
panel0_dg = 4;
panel1_dg = 4;
panel2_dg = 4;
panel3_dg = 4;
}
void ET_HT16K33_7SEGMENT::setBrightness(uint8_t brightness)
{
if(brightness > 15)
{
brightness = 15; // Maximum Brightness Adjust
}
Wire.beginTransmission(i2c_addr);
Wire.write(HT16K33_CMD_BRIGHTNESS | brightness);
Wire.endTransmission();
}
void ET_HT16K33_7SEGMENT::blinkRate(uint8_t blinkrate)
{
if(blinkrate > 3)
{
blinkrate = 0; // Disable Blink Adjust
}
Wire.beginTransmission(i2c_addr);
Wire.write(HT16K33_BLINK_CMD | HT16K33_BLINK_DISPLAYON | (blinkrate << 1));
Wire.endTransmission();
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 25
void ET_HT16K33_7SEGMENT::begin(uint8_t _addr = 0x70)
{
i2c_addr = _addr; // HT16K33 I2C Device Address
Wire.begin();
Wire.beginTransmission(i2c_addr);
Wire.write(0x21); // turn on oscillator
Wire.endTransmission();
blinkRate(HT16K33_BLINK_OFF);
setBrightness(15); // max brightness
}
void ET_HT16K33_7SEGMENT::writeUpdateDisplay(void)
{
Wire.beginTransmission(i2c_addr);
Wire.write((uint8_t)0x00); // start at address $00
// Send LSB Data Display to HT16K33
for (uint8_t i=0; i<4; i++)
{
Wire.write(panel0buffer[i]); // Lower-LSB
Wire.write(panel2buffer[i]); // Upper-LSB
}
// Send MSB Data Display to HT16K33
for (uint8_t i=0; i<4; i++)
{
Wire.write(panel1buffer[i]); // Lower-MSB
Wire.write(panel3buffer[i]); // Upper-MSB
}
Wire.endTransmission();
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 26
void ET_HT16K33_7SEGMENT::writeDisplayPanel0(void)
{
for(uint8_t i=0; i<4; i++)
{
panel0buffer[i] = displaybuffer[i]; // Update Display Buffer to Panel[1] Display
}
writeUpdateDisplay(); // Show Display
}
void ET_HT16K33_7SEGMENT::writeDisplayPanel1(void)
{
for(uint8_t i=0; i<4; i++)
{
panel1buffer[i] = displaybuffer[i]; // Update Display Buffer to Panel[2] Display
}
writeUpdateDisplay(); // Show Display
}
void ET_HT16K33_7SEGMENT::writeDisplayPanel2(void)
{
for(uint8_t i=0; i<4; i++)
{
panel2buffer[i] = displaybuffer[i]; // Update Display Buffer to Panel[3] Display
}
writeUpdateDisplay(); // Show Display
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 27
void ET_HT16K33_7SEGMENT::writeDisplayPanel3(void)
{
for(uint8_t i=0; i<4; i++)
{
panel3buffer[i] = displaybuffer[i]; // Update Display Buffer to Panel[4] Display
}
writeUpdateDisplay(); // Show Display
}
void ET_HT16K33_7SEGMENT::clear(void)
{
for (uint8_t i=0; i<4; i++)
{
panel0buffer[i] = 0; // Lower-LSB
panel1buffer[i] = 0; // Lower-MSB
panel2buffer[i] = 0; // Upper-LSB
panel3buffer[i] = 0; // Upper-MSB
}
position = 0;
}
void ET_HT16K33_7SEGMENT::clear(uint8_t panel)
{
for (uint8_t i=0; i<4; i++)
{
switch(panel)
{
case 1:
panel0buffer[i] = 0; // Lower-LSB
break;
case 2:
panel1buffer[i] = 0; // Lower-MSB
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 28
break;
case 3:
panel2buffer[i] = 0; // Upper-LSB
break;
case 4:
panel3buffer[i] = 0; // Upper-MSB
break;
}
}
position = 0;
}
void ET_HT16K33_7SEGMENT::print(char val, // Value
int base) // Value Type
{
print((long) val, base);
}
void ET_HT16K33_7SEGMENT::print(unsigned char val, // Value
int base) // Value Type
{
print((unsigned long) val, base);
}
void ET_HT16K33_7SEGMENT::print(int val, // Value
int base) // Value Type
{
print((long) val, base);
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 29
void ET_HT16K33_7SEGMENT::print(unsigned int val, // Value
int base) // Value Type
{
print((unsigned long) val, base);
}
void ET_HT16K33_7SEGMENT::print(long val, // Value
int base) // Value Type
{
printNumber(val, base);
}
void ET_HT16K33_7SEGMENT::print(unsigned long val, // Value
int base) // Value Type
{
if(base == BYTE)
{
write(val);
}
else
{
printNumber(val, base);
}
}
void ET_HT16K33_7SEGMENT::print(double val, // Value
int base) // Value Type(2:BIN)
{
printFloat(val, base); // x.yy(DEC)
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 30
void ET_HT16K33_7SEGMENT::println(void)
{
position = 0;
}
void ET_HT16K33_7SEGMENT::println(char val, // Value
int base) // Value Type
{
print(val, base);
println();
}
void ET_HT16K33_7SEGMENT::println(unsigned char val, // Value
int base) // Value Type
{
print(val, base);
println();
}
void ET_HT16K33_7SEGMENT::println(int val, // Value
int base) // Value Type
{
print(val, base);
println();
}
void ET_HT16K33_7SEGMENT::println(unsigned int val, // Value
int base) // Value Type
{
print(val, base);
println();
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 31
void ET_HT16K33_7SEGMENT::println(long val, // Value
int base) // Value Type
{
print(val, base);
println();
}
void ET_HT16K33_7SEGMENT::println(unsigned long val, // Value
int base) // Value Type
{
print(val, base);
println();
}
void ET_HT16K33_7SEGMENT::println(double val, // Value
int base) // Value Type(2:BIN)
{
print(val, base);
println();
}
void ET_HT16K33_7SEGMENT::printNumber(long val, // Value
uint8_t base) // Value Type
{
printFloat(val, 0, base); // 0 fracDigits Display
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 32
//==========================================================================================
// print Float value to 7-Segment Display
// val : Value of float
// fracDigits : number of digit frac. Display(Default : 2) : x.yy
// base : Type of Value(Default : DEC)
//==========================================================================================
void ET_HT16K33_7SEGMENT::printFloat(double val, // Value
uint8_t fracDigits, // frac. Digits(x.yy)
uint8_t base) // Value Type(DEC)
{
uint8_t numericDigits = 4; // available digits on display
boolean isNegative = false; // true if the number is negative
// is the number negative?
if(val < 0)
{
isNegative = true; // Enable Display Negative Sign[-]
--numericDigits; // Reserve 1 Digit For Display Sign[-]
val *= -1; // Convert Negative Value to Postive Value
}
// calculate the factor required to shift all fractional digits
// into the integer part of the number
double toIntFactor = 1.0;
for(int i = 0; i < fracDigits; ++i)
{
toIntFactor *= base;
}
// create integer containing digits to display by applying
// shifting factor and rounding adjustment
uint32_t displayNumber = val * toIntFactor + 0.5;
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 33
// calculate upper bound on displayNumber given
// available digits on display
uint32_t tooBig = 1;
for(int i = 0; i < numericDigits; ++i)
{
tooBig *= base;
}
// if displayNumber is too large, try fewer fractional digits
while(displayNumber >= tooBig)
{
--fracDigits;
toIntFactor /= base;
displayNumber = val * toIntFactor + 0.5;
}
// did toIntFactor shift the decimal off the display?
if (toIntFactor < 1)
{
printError();
}
else
{
// otherwise, display the number
//int8_t displayPos = 4;
int8_t displayPos = 3;
if (displayNumber) //if displayNumber is not 0
{
for(uint8_t i = 0; displayNumber || i <= fracDigits; ++i)
{
boolean displayDecimal = (fracDigits != 0 && i == fracDigits);
writeDigitBCD(displayPos--, displayNumber % base, displayDecimal); // Display Value
displayNumber /= base;
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 34
}
}
else
{
writeDigitBCD(displayPos--, 0, false); // Display : [0]
}
// display negative sign if negative
if(isNegative) writeDigitSegment(displayPos--, 0x40); // Display Negative Sign : [-]
// clear remaining display positions
while(displayPos >= 0) writeDigitSegment(displayPos--, 0x00); // Display Space : [ ]
}
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 35
//==========================================================================================
// Display [-][-][-][-]
//==========================================================================================
void ET_HT16K33_7SEGMENT::printError(void)
{
for(uint8_t i = 0; i < MAX_7SEGMENT_DIGIT; ++i)
{
writeDigitSegment(i, 0x40); // [-]:(0100 0000)
}
}
//==========================================================================================
//==========================================================================================
// Write Digit 7-Segment(Direct) to Segment Display
// dig_pos : Digit Position[0..3]
// bcd_seg : 7-Segment Direct[0x00..0xFF] Code For Display
// : Data[7..0] : Dp-G-F-E-D-C-B-A
// dot : Dot ON/OFF(true = ON, false = OFF)
//==========================================================================================
void ET_HT16K33_7SEGMENT::writeDigitSegment(uint8_t dig_pos, // Digit Position Display
uint8_t seg_val) // Display Value
{
if(dig_pos > MAX_7SEGMENT_DIGIT) return; // Over Digit Display
displaybuffer[dig_pos] = seg_val; // Update Display Buffer
}
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 36
//==========================================================================================
// Write Digit BCD[0..F] to Segment Display
// dig_pos : Digit Position[0..3]
// bcd_seg : 7-Segment BCD[0..F] Code For Display
// dot : Dot ON/OFF(true = ON, false = OFF)
//==========================================================================================
void ET_HT16K33_7SEGMENT::writeDigitBCD(uint8_t dig_pos, // Digit For Display
uint8_t bcd_val, // Number For Display
boolean dot) // Dot 7-Segment ON/OFF
{
if(dig_pos > MAX_7SEGMENT_DIGIT) return; // Over Digit Display
writeDigitSegment(dig_pos, numbertable[bcd_val] | (dot << 7)); // Dot = D7
}
//==========================================================================================
ET-DSP IŚC şSEG PANEL DISPLAY SET
ET-DSP I2C 7SEG PANEL DISPLAY SET 37
//==========================================================================================
// Write Display Value
//==========================================================================================
size_t ET_HT16K33_7SEGMENT::write(uint8_t c)
{
uint8_t r = 0;
if(c == '\n') position = 0;
if(c == '\r') position = 0;
if((c >= '0') && (c <= '9'))
{
writeDigitBCD(position, c-'0');
r = 1; // 1-Byte
}
position++;
return r;
}
//==========================================================================================