Skip to content

Commit d3840ef

Browse files
authored
Add files via upload
1 parent acd27b3 commit d3840ef

13 files changed

+863
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# BC759x 7seg LED Display Library For Arduino
2+
3+
## Overview
4+
5+
BC759x series 7-segment LED display driver + keyboard interface chip provides a unified UART single-line LED display interface, this driver library can be applied to the following chips:
6+
7+
- BC7595 -- 48 segments (six 7-segment numeric displays with decimal points) + 48-key keyboard matrix chip, datasheets: (English , [简体中文](./extras/docs/bc7595.pdf))
8+
9+
- BC7591 -- 256 segments (32 7-segment numeric displays with decimal points) + 96-key keyboard matrix chip, datasheets: ([English](./extras/docs/bc7591_en.pdf_) , [简体中文](./extras/docs/bc7591.pdf))
10+
11+
This driver library is compatible with all Arduino devices, and can be used with both hardware serial ports and software serial ports.
12+
Each instruction of the BC759x consists of 2 bytes, the first byte is the instruction and the second byte is the data. The driver library provides a basic function, sendCmd(), which can be used to send arbitrary instructions to the BC759x. At the same time, the driver library provides several upper-layer functions that wrap several of the most commonly used functions in use. The upper-layer functions are as follows.
13+
14+
- clear() - Clear display content and blink status
15+
16+
- displayDec() - Display values in decimal
17+
18+
- displayHex() - Display values in hexadecimal
19+
20+
- displayFloat() - Display float point values
21+
22+
- digitBlink() - Digitwise blink control
23+
24+
For those functions that can be done with a single BC759x instruction, although they are frequently used - such as individual LED on/off control - are not implemented as upper-level functions, as this does not simplify their use for the user.
25+
For detailed information about the instructions of the BC759x chip, please refer to the datasheets of the corresponding chip.
26+
27+
## Library Installation
28+
29+
The driver library is very easy to install, just search the name of the library or the chip number in the Arduino Library Manager.
30+
Or if you prefer to download the zip file and start from there: In the Arduino IDE menu, select "Sketch --> Include Library --> Add .ZIP Library..."
31+
Select "uart_7seg_display.zip", then it's done.
32+
After installation, you will see the UART_7Seg_Display library in the "Skech --> Include Library" menu, which means it is ready to use.
33+
34+
## Hardware Connection
35+
36+
The BC759x chip uses serial communication, and the communication uses 2 pins TX and RX, where TX on chip is the output of the keyboard interface of the BC759x, and the display driver actually uses the on chip RX pin only. If you use the display function of the BC759x only(without using its keyboard interface), the only pin you need to connect is the RX plus the power supply. As the display and keyboard are usually used together in most cases, both RX and TX will be connected. To connect, the TX/RX pins on the chip are cross-linked to the RX/TX pins of the Arduino's serial port.
37+
38+
![](./extras/img/serial_port_connection.png)
39+
40+
For more detailed information about this library please see : [usage](./extras/docs/usage.md)
41+
42+
Or for the PDF version of the complete user manual in [简体中文](./extras/docs/BC759x_7seg_LED_Display_Library_Arduino_cn.pdf) or [English](./extras/docs/BC759x_7seg_LED_Display_Library_Arduino.pdf)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/******************************************************************************
2+
* led_disp_example.ino
3+
* BC759x 7-segment LED Display Library Example Code
4+
*
5+
* This code uses Serial1 to drive a BC7595 or BC7591 to display a 3
6+
* digits counter on DIG0-2 which will increase at an interval of 10ms.
7+
* The SoftwareSerial uses digital I/O pin 2 as Rx and pin 3 as Tx.
8+
* The SoftwareSerial can be replaced by hardware serial such as Serial,
9+
* Serial1, or Serial2.
10+
* This code runs on any Arduino compatible boards.
11+
*
12+
* Dependencies:
13+
* This code depends on the following libraries:
14+
* Arduino Software Serial Library
15+
* UART_7seg_Display Library
16+
*
17+
* Author:
18+
* This software is written by BitCode. https://bitcode.com.cn
19+
*
20+
* Version:
21+
* V1.0 March 2021
22+
*
23+
* License:
24+
* MIT license. It can be used for both open source and commercial projects.
25+
******************************************************************************/
26+
#include <UART_7Seg_Display.h>
27+
28+
#define LED_SERIAL Serial1 // By default this code uses Serial1 as LED display port
29+
// If you are using Arduino with only 1 Serial (such as UNO), you may want to disable
30+
// the above line and use the following setting:
31+
// #include <SoftwareSerial.h>
32+
// #define LED_SERIAL swSerial
33+
// SoftwareSerial swSerial(11, 12); // creating SoftwareSerial instance, using pin 11 as Rx, 12 as Tx (Rx not used in this example)
34+
35+
UART_7Seg_Display Disp(LED_SERIAL); // creating display driver instance
36+
37+
38+
uint16_t cnt=0;
39+
float x=1.23;
40+
41+
void setup()
42+
{
43+
Serial.begin(115200); // Initializing printing serial port
44+
LED_SERIAL.begin(9600); // Initializing LED display serial port
45+
Disp.clear(); // Clear any display contents
46+
}
47+
48+
void loop()
49+
{
50+
Serial.print("Disaplying in decimal : ");
51+
Serial.println(cnt, DEC);
52+
Disp.displayDec(cnt, 0, 3); // Display cnt as decimal number on DIG0-DIG2 (3 digits wide)
53+
delay(1000);
54+
Serial.print("Disaplying in hexdecimal : ");
55+
Serial.println(cnt, HEX);
56+
Disp.displayHex(cnt, 0, 4); // Display cnt as hexdecimal on DIG0-DIG3 (4 digits wide)
57+
delay(1000);
58+
Serial.print("Disaplying in float : ");
59+
Serial.println(x,2);
60+
Disp.displayFloat(x, 0, 3, 2); // Display x as float number on DIG0-DIG2, 2 digits after decimal point
61+
Disp.sendCmd(SEG_ON, 0x17); // Turn on the decimal point on DIG2 (segment address 0x17, see datasheets)
62+
delay(1000);
63+
Disp.sendCmd(SEG_OFF, 0x17); // Turn off the decimal point on DIG2
64+
cnt = cnt + 1;
65+
if (cnt == 1000)
66+
{
67+
cnt = 0;
68+
}
69+
x = x+0.01;
70+
}
Binary file not shown.
Binary file not shown.

extras/docs/Usage.md

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
## Use Of The Library
2+
3+
### Create Instance
4+
5+
The interface of the BC759x chip is a serial port, so the use of this driver library must also rely on the Arduino's serial port. The serial port can be either Arduino's hardware serial port (e.g. Serial, Serial1, Serial2, etc.) or software serial port (Software Serial).
6+
For models like the Arduino UNO, there is only one hardware serial port, and that serial port is already used for communication with the computer, so it is appropriate to use the software serial port, otherwise there will be conflicts with the IDE (unless the program is downloaded to the hardware using an external programmer that does not occupy the Arduino's serial port).
7+
Before use, the first step should be to include the library. After loading, the following statement appears in the Sketch editing window.
8+
9+
```c
10+
#include <UART_7Seg_Display.h>
11+
```
12+
13+
then, for easy understanding and using, define an instant named LED_SERIAL:
14+
15+
```c
16+
#define LED_SERIAL Serial1
17+
```
18+
19+
Below the statements above, and before setup(), create the instance of the UART_7Seg_Display library, e.g.
20+
21+
```c
22+
UART_7Seg_Display Disp(LED_SERIAL);
23+
```
24+
25+
Where UART_7Seg_Display is the name of this driver class, Disp is the name given to the instance by the user, it can be anything, as long as it conforms to the Arduino variable naming rules.
26+
If you are using SoftwareSerial, you'll need 2 extra steps. The first step is to include the SoftwareSerial library, which is one of the standard libraries for Arduino.
27+
28+
```c
29+
#include <SoftwareSerial.h>
30+
```
31+
32+
The second step requires the creation of an instance of the software serial prior to the creation of an instance of UART_7Seg_Display.
33+
34+
```c
35+
SoftwareSerial swSerial(11, 12);
36+
```
37+
38+
Where swSerial is the name given to the instance by the user, which can be anything that matches the Arduino variable naming rules. In parentheses the 11, 12 are the RX and TX pins used by the software serial port. See the Arduino software serial port library for more information.
39+
The definition of the LED_SERIAL should also be changed to:
40+
41+
```c
42+
#define LED_SERIAL swSerial
43+
```
44+
45+
### setup()
46+
47+
This library itself does not require any initialization to be used, but the serial port must be properly initialized to connect to the BC759x chip. The serial port must be initialized to baud rate 9600.
48+
49+
```c
50+
LED_SERIAL.begin(9600);
51+
```
52+
53+
Although it can be used without initialization, because different PCB hardware designs may have different PCB layouts, it may be necessary to set the direction of the display in the initialization. If the library is set to display the opposite direction of the actual board, when the value is displayed, the position of the high and low digits will be reversed, for example, when displaying decimal numbers, the ones may be displayed on the leftmost side.
54+
The library has two functions to set the display direction, which are
55+
setDispLowDigOnLeft() and setDispLowDigOnRight() , respectively, represent the smaller digit number on the board is the 7-segment on the left side or right side. Users can call the corresponding function according to the design of the PCB, for example.
56+
57+
```c
58+
Disp.setDispLowDigOnLeft(); // Notify the library of the smaller digit number is on the left
59+
```
60+
61+
If not set, the default setting is smaller digit number on the right.
62+
In addition, the clear function clear() is often used in the initialization section to clear all display content and blink attributes after a reset.
63+
64+
```c
65+
Disp.clear();
66+
```
67+
68+
### Display Content
69+
70+
The BC759x chip has internal registers where the display content is written and will remain displayed until it is replaced by new content. Therefore the program only needs to call the library when the display content is to be updated.
71+
The library provides 3 functions related to display.
72+
73+
- Display in decimal -- displayDec()
74+
75+
- Display in hexadecimal -- displayHex()
76+
77+
- Display float point value -- displayFloat()
78+
79+
- Blink by digit -- digitBlink()
80+
81+
For more information on the use of these three functions, see the function references section later.
82+
Only the three display-related functions above are provided, as other common operations can generally be completed by a BC727x instructions, encapsulated into a function does not simplify the user program. The following are some common scenarios:
83+
84+
#### Display Special Characters
85+
86+
Some special characters, such as "L", "H", "P", "-", etc., can be implemented by writing directly to the display register, using the BC759x direct register write instruction DIRECT_WT. For example, to display "L":
87+
sendCmd(DIRECT_WT|Pos, 0x38); // Where Pos is the display position and 0x38 is the character map of "L". For detailed instructions of BC759x, you can refer to the datasheet of BC759x.
88+
89+
#### Display A Decimal Point
90+
91+
The numeric display function, whether it is a decimal display or a hexadecimal display, will not affect the status of the decimal point. To control the status of the decimal point, you can use the segment addressing instruction SEG_OFF/SEG_ON of the BC759x. For example, to light up the decimal point in the 3rd position:
92+
93+
```c
94+
sendCmd(SEG_ON, 0x1f); // Where 0x1f is the segment address of the decimal point of the 3rd digit.
95+
```
96+
97+
#### Other Special Controls
98+
99+
Any control of the BC759x chip can be done by using the sendCmd() function, such as controlling the blinking speed, adjusting the display brightness, etc. For more information about the commands of the BC759x chip, please refer to the datasheet of the BC759x.
100+
101+
### Function Reference
102+
103+
#### sendCmd() : Send Command
104+
105+
Format:
106+
107+
```c
108+
sendCmd(Cmd, Data);
109+
```
110+
111+
This function can be used to send any command to the BC759x. The library only provides a few upper-level common display functions. If the user needs to have full control of the BC759x, this function needs to be called. There are two parameters, Cmd is the command to be sent and Data is the data to be sent. In "bc_led_disp.h" header file all the commands for the BC759x are listed. For detailed descriptions of the instructions for specific BC759x chips, please refer to the datasheets of the selected BC759x chip. All other functions provided by the library are implemented by calling this function.
112+
113+
##### Predefined Commands:
114+
115+
The following commands have already been defined in library and are ready to be used:
116+
117+
- DIRECT_WT Direct write to display register
118+
119+
- COL_WRITE Column write (BC7591 only)
120+
121+
- BLINK_WT_CLR Segment blink clear
122+
123+
- BLINK_WT_SET Segment blink set
124+
125+
- SHIFT_H_WT Column insert and shift high(right) (BC7591 only)
126+
127+
- ROTATE_R Rotate right(high) (BC7591 only)
128+
129+
- ROTATE_L Rotate left(low) (BC7591 only)
130+
131+
- SHIFT_L_WT Column insert and shift low(left) (BC7591 only)
132+
133+
- DECODE_WT Decoded write
134+
135+
- QTR_WT_BOT Quarter line write at bottom (BC7591 only)
136+
137+
- QTR_INS_BOT Quarter line insert at bottom (BC7591 only)
138+
139+
- QTR_WT_TOP Quarter line write at top (BC7591 only)
140+
141+
- WRITE_EXT Direct write at extended position
142+
143+
- QTR_INS_TOP Quarter line insert at top (BC7591 only)
144+
145+
- DECODE_EXT Decoded write at extended position
146+
147+
- SEG_OFF Segment OFF
148+
149+
- COORD_OFF Coordinate OFF (BC7591 only)
150+
151+
- SEG_ON Segment ON
152+
153+
- COORD_ON Coordinate ON (BC7591 only)
154+
155+
- BLINK_DIG_CTL Digit blink control
156+
157+
- GLOBAL_CTL Global control
158+
159+
- WRITE_ALL Write to all
160+
161+
- BLINK_SPEED Blink speed
162+
163+
- DIM_CTL Dim control
164+
165+
- RESET_H Reset (as Cmd)
166+
167+
- RESET_L Reset (as Data)
168+
169+
- UART_SEND_0_H UART send 0 (as Cmd)
170+
171+
- UART_SEND_0_L UART send 0 (as Data)
172+
173+
#### clear() : Clear display and blink status
174+
175+
Format:
176+
177+
```c
178+
clear();
179+
```
180+
181+
This function is used to clear all display and blink properties.
182+
183+
#### displayDec() : Display Values In Decimal
184+
185+
Format:
186+
187+
```c
188+
displayDec(Val, Pos, Width);
189+
```
190+
191+
This function displays the input value in decimal. Only unsigned values are accepted, and the display of negative values requires the user to write the '-' sign manually. If the higher significant digits are out of the display range of the chip, the excess will not be displayed and no error message will be given.
192+
Val is the value to be displayed, and the range is 0 to 4,294,967,295.
193+
Pos is the position of the display. The display position is based on the lowest digit, Pos value is the DIG number of the character where the lowest significant digit is located, the value range is 0-31.
194+
Width is the display width, the valid value range is 0-255. In the binary representation, the lower 7 bits are the display width value, and the 7th bit is the control bit of whether to display leading '0's or not. For example, if the Width is set to 5 and the Val value to be displayed is 132, the display result will be "␣␣132" (␣ stands for blank), if the Width value is 133 (5| 0x80, the highest bit in the binary representation of 5 set to '1'), then the result will be "00132". The valid range of the display width is 1-32. When the display width is set smaller than the width of the actual value, the exceeding part will not be displayed, and when the display width Width is larger than the width of the actual value, the exceeding part will be displayed blank or '0' according to the bit7 of Width. If the display position of the digit is beyond the display range of the actual chip, the excess part will be ignored.
195+
setDispLowDigOnLeft() and setDispLowDigOnRight() will affect the direction of the digit display. When setDispLowDigOnRight() is called, the lowest digit is displayed at the Pos position, and the higher digits of the displayed value will be displayed at the higher DIG position in order. And when using setDispLowDigOnLeft(), the lowest digit will be displayed at Pos position, and the more significant digits will be displayed at positions smaller than Pos in order. The library defaults to the state of setDispLowDigOnRight().
196+
197+
#### displayHex() : Display Values In Hexadecimal
198+
199+
Format:
200+
201+
```c
202+
displayHex(Val, Pos, Width);
203+
```
204+
205+
This function displays the input value in hexadecimal. Pos and Width have the same meaning as in displayDec() above, but the difference is that for hexadecimal display, when Width is set to exceed the width of the actual value, the excess part will be displayed as 0, instead of the blank in decimal display. For example, if you input 0xA5, set Width to 5, then the result will be 000A5
206+
207+
#### displayFloat() : Display Float Point Values
208+
209+
Format:
210+
211+
```c
212+
displayFloat(Val, Pos, Width, Frac);
213+
```
214+
215+
This function displays a float point value. Pos and Width have the same meaning as in displayDec() above, Frac is the width of the fraction part. Width is the whole display width. The function doesn't deal with the decimal point and negative sign, user must use proper command to turn on/off decimal point and negative sign.
216+
217+
#### digitBlink() : Digit Blink Control
218+
219+
Format:
220+
221+
```c
222+
digitBlink(Digit, OnOff);
223+
```
224+
225+
Control blinking by digit. This function controls the blinking property of one display digit at a time. The blinking property of the 16th - 31st digit, if it's set directly by the user through the sendCmd() function, may be lost if then changed by using this function. The Digit value range is 0-31; OnOff is the set state, 1=blinking, 0=no blinking.
226+
227+
### Examples
228+
229+
The following Sketch uses Serial1 as display port, displays counts from 0-999 in both decimal and hexdecimal format and a float point number starting form 1.23 increased by 0.01 each step. The display changed every second.
230+
231+
```c
232+
233+
```

extras/docs/bc7591.pdf

1.43 MB
Binary file not shown.

extras/docs/bc7591_en.pdf

1.26 MB
Binary file not shown.

extras/docs/bc7595.pdf

740 KB
Binary file not shown.

extras/img/serial_port_connection.png

36.9 KB
Loading

keywords.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#####################
2+
# Class Names
3+
#####################
4+
UART_7Seg_Display KEYWORD1
5+
6+
#####################
7+
# Functions
8+
#####################
9+
sendCmd KEYWORD2
10+
clear KEYWORD2
11+
displayDec KEYWORD2
12+
displayHex KEYWORD2
13+
digitBlink KEYWORD2
14+
setDispLowDigOnRight KEYWORD2
15+
setDispLowDigOnLeft KEYWORD2
16+
17+
####################
18+
# Constants
19+
####################
20+
DIRECT_WT LITERAL1
21+
COL_WRITE LITERAL1
22+
BLINK_WT_CLR LITERAL1
23+
BLINK_WT_SET LITERAL1
24+
SHIFT_H_WT LITERAL1
25+
ROTATE_R LITERAL1
26+
ROTATE_L LITERAL1
27+
SHIFT_l_WT LITERAL1
28+
DECODE_WT LITERAL1
29+
QTR_WT_BOT LITERAL1
30+
QTR_INS_BOT LITERAL1
31+
QTR_WT_TOP LITERAL1
32+
WRITE_EXT LITERAL1
33+
QTR_INS_TOP LITERAL1
34+
DECODE_EXT LITERAL1
35+
SEG_OFF LITERAL1
36+
COORD_OFF LITERAL1
37+
SEG_ON LITERAL1
38+
COORD_ON LITERAL1
39+
BLINK_DIG_CTL LITERAL1
40+
GLOBAL_CTL LITERAL1
41+
WRITE_ALL LITERAL1
42+
BLINK_SPEED LITERAL1
43+
DIM_CTL LITERAL1
44+
RESET_H LITERAL1
45+
RESET_L LITERAL1
46+
UART_SEND_0_H LITERAL1
47+
UART_SEND_0_L LITERAL1
48+

0 commit comments

Comments
 (0)