Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
/SH5461ASPublic archive

A library for the SH5461AS 4 Digit Segment Display

License

NotificationsYou must be signed in to change notification settings

UniQHW/SH5461AS

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.

gif

Contents

Installation

Download the repository as a zip

Downloading the repo

After obtaining a local copy, import the library in theArduino IDE:

Importing the library

Importing/Including

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"

Example

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:

result

Flags

The following preprocessor directives may be used to optimize the library:

PreprocessorDescription
#DISABLE_DPDisables 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"

Library Overview

The library provides a total of three classes:

ClassDefined InDescription
DisplayDisplay.hDisplay controller class
DigitDigit.hHardware abstraction for COM pins
SegmentSegment.hHardware 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.

class Display

A display controller class

Constructor

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
ParameterDescriptionExample
byte digit_pins[4]Array of digit pinsCOM1 - COM4byte 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_pinPin to control Decimal Point. Leave out if#DISABLE_DP has been defined13

datasheet

Members

MemberAccessDescription
bool statePrivateA private flag fortoggle()
Digit *digits[4]PublicStoresdigit objects to activate/disable COMs
Segment *segments[7]PublicStoressegment objects froma - g (abc...g) to activate and disable segments
DecimalPoint *dPublicStores dp object (alias tosegment objects) to activate/disable dp

Member Functions

void print(const char[])

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.

void toggle()

Access: Public

Togglesall digits on or off, depending on it's previous state.

Display prior toggleDisplay after toggle
OFFON
ONOFF
void toggle(bool arg_state)

Access: Public

Setsall digits to the provided state.

StateDisplay after toggle
trueON
falseOFF
void fill(bool all = true)

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.

void empty()

Access: Public

Turns all segments and decimal points (unless#DISABLE_DP has been defined) to 'OFF'.

class Digit

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);
ParameterDescriptionExample
byte pinCOM pinA1

Members

MemberAccessDescription
byte pinPrivateCOM pin
bool statePrivateA private flag fortoggle()

Member Functions

void toggle()

Access: Public

Toggles digit on or off, depending on it's previous state.

Digit prior toggleDigit after toggle
OFFON
ONOFF
void toggle(bool arg_state)

Access: Public

Sets digit to the provided state.

StateDigit after toggle
trueON
falseOFF

class Segment

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);
ParameterDescriptionExample
byte pinSegment pinA0

Members

MemberAccessDescription
byte pinPrivateSegment pin
bool statePrivateA private flag fortoggle()

Member Functions

void toggle()

Access: Public

Toggles segment on or off, depending on it's previous state.

Segment prior toggleSegment after toggle
OFFON
ONOFF
void toggle(bool arg_state)

Access: Public

Sets segment to the provided state.

StateSegment after toggle
trueON
falseOFF

License

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp