- Notifications
You must be signed in to change notification settings - Fork3
A library for the SH5461AS 4 Digit Segment Display
License
UniQHW/SH5461AS
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Just another library to communicate with the SHA5461AS 4 Digit Segment Display.
This library has been written in order to help a pupil of mine with his Arduino project.
- Installation
- Importing/Including
- Example
- Flags
- Library Overview
- License
Download the repository as a zip
After obtaining a local copy, import the library in theArduino IDE:
Add the following to the top of your source file in order to include this library:
#include"Segment.h"#include"Digit.h"#include"Display.h"
The following example prints1.234 to the display
#include<Arduino.h>/* Include this library*/#include"Segment.h"#include"Digit.h"#include"Display.h"const byte digit_pins[4] {6,9,10,12};// From com1 - com4const byte segment_pins[7] {7,11,2,4,5,8,13};// From a - g (abc...g)const byte dp_pin =3;Displayd(digit_pins, segment_pins, dp_pin);voidsetup() {for (int i =0; i <= A5; i++) {pinMode(i, OUTPUT); }}voidloop() { d.print("1.234");// Must be looped!}
Result:
The following preprocessor directives may be used to optimize the library:
| Preprocessor | Description |
|---|---|
| #DISABLE_DP | Disables support for decimal points, minimally increasing the frame rate |
Preprocessors must be setBEFORE the library is included:
#defineDISABLE_DP#include"Segment.h"#include"Digit.h"#include"Display.h"
The library provides a total of three classes:
| Class | Defined In | Description |
|---|---|---|
| Display | Display.h | Display controller class |
| Digit | Digit.h | Hardware abstraction for COM pins |
| Segment | Segment.h | Hardware abstraction for segments |
The Display class acts as a display controller and should be sufficient for most applications. It provides aprint function that displays the provided number on the display. Seeclass Display for more.
A display controller class
The constructor is provided with the necessary pin information in order to successfully communicate with the display.
#ifdef DISABLE_DPDisplay(byte digit_pins[4], byte segment_pins[7])#elseDisplay(byte digit_pins[4], byte segment_pins[7], byte dp_pin)#endif
| Parameter | Description | Example |
|---|---|---|
| byte digit_pins[4] | Array of digit pinsCOM1 - COM4 | byte digit_pins[4] {6, 9, 10, 12}; |
| byte segment_pins[7] | Array of segment pinsa - g (abc..g) | byte segment_pins[7] {7, 11, 2, 4, 5, 8, 13}; |
| byte dp_pin | Pin to control Decimal Point. Leave out if#DISABLE_DP has been defined | 13 |
| Member | Access | Description |
|---|---|---|
| bool state | Private | A private flag fortoggle() |
| Digit *digits[4] | Public | Storesdigit objects to activate/disable COMs |
| Segment *segments[7] | Public | Storessegment objects froma - g (abc...g) to activate and disable segments |
| DecimalPoint *d | Public | Stores dp object (alias tosegment objects) to activate/disable dp |
Access: Public
Prints a string of numbers onto the display. The string may only include characters\0,0-9 and. (unless#DISABLE_DP has been defined).The print function requires to be constantly refreshed!
If\0 has been provided, no number is displayed (Ex:print("1\0\01") will display 1 on the first and last digit only).
Because speed is crucial, this function provides no error-checking. As a result, if too many, or invalid characters have been specified, the display will return unpredictable/wrong results.
Access: Public
Togglesall digits on or off, depending on it's previous state.
| Display prior toggle | Display after toggle |
|---|---|
| OFF | ON |
| ON | OFF |
Access: Public
Setsall digits to the provided state.
| State | Display after toggle |
|---|---|
| true | ON |
| false | OFF |
Access: Public
Turns all segments and decimal points (unless#DISABLE_DP has been defined) to 'ON'. Ifbool all has been set tofalse, only digits that are 'ON' will be filled.
Access: Public
Turns all segments and decimal points (unless#DISABLE_DP has been defined) to 'OFF'.
A hardware abstraction for COM pins
The constructor is provided with the necessary pin information in order to successfully communicate with the display.
Digit(byte pin);| Parameter | Description | Example |
|---|---|---|
| byte pin | COM pin | A1 |
| Member | Access | Description |
|---|---|---|
| byte pin | Private | COM pin |
| bool state | Private | A private flag fortoggle() |
Access: Public
Toggles digit on or off, depending on it's previous state.
| Digit prior toggle | Digit after toggle |
|---|---|
| OFF | ON |
| ON | OFF |
Access: Public
Sets digit to the provided state.
| State | Digit after toggle |
|---|---|
| true | ON |
| false | OFF |
A hardware abstraction for segments
The constructor is provided with the necessary pin information in order to successfully communicate with the display.
Segment(byte pin);| Parameter | Description | Example |
|---|---|---|
| byte pin | Segment pin | A0 |
| Member | Access | Description |
|---|---|---|
| byte pin | Private | Segment pin |
| bool state | Private | A private flag fortoggle() |
Access: Public
Toggles segment on or off, depending on it's previous state.
| Segment prior toggle | Segment after toggle |
|---|---|
| OFF | ON |
| ON | OFF |
Access: Public
Sets segment to the provided state.
| State | Segment after toggle |
|---|---|
| true | ON |
| false | OFF |
The MIT License (MIT)Copyright (c) 2018 Patrick PedersenPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.About
A library for the SH5461AS 4 Digit Segment Display
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Contributors2
Uh oh!
There was an error while loading.Please reload this page.




