Coder Social home page Coder Social logo

ch455-arduino's Introduction

ch455 Arduino Library

This is a comprehensive Arduino library for interfacing with the CH455 7-segment LED display driver IC. It provides an easy-to-use interface for controlling the displays and reading key presses.

Features

Simple interface to set up and control CH455 based displays.
Support for changing LED brightness.
Capabilities to read key presses from a keypad connected to CH455.
Functions to operate in either 7-segment or 8-segment mode.
Power management through sleep mode functionality.

Getting Started

Installation

Download or clone this repository to your local machine.
Unzip and rename the folder to CH455 (if necessary).
Move the CH455 folder into your Arduino libraries directory.
Restart your Arduino IDE.
Include the library with #include <ch455.h> in your sketch.

Initialization

Create a CH455 object and begin communication by specifying SDA and SCL pins along with the desired brightness level:

CH455 display;

void setup() {
display.begin(uint8_t sda, uint8_t scl, uint8_t brightness); // Standard initialization with custom SDA/SCL
// or
display.begin(uint8_t brightness); // ATTiny or default SDA/SCL pins
}

Brightness ranges from 1 (minimum) to 8 (maximum), with a default of 8 if unspecified.

Advanced Configuration

To initialize the display with additional parameters:

void setup() {
display.begin(uint8_t sda, uint8_t scl, uint8_t brightness, bool enabled, bool sleep, bool sevenSegment);
// or
display.begin(uint8_t brightness, bool enabled, bool sleep, bool sevenSegment);
}

Displaying Numbers

Send digits to the display, optionally with decimal points:

void loop() {
display.digit(uint8_t digit, uint8_t number, bool dot); // With decimal point
// or
display.digit(uint8_t digit, uint8_t number); // Without decimal point
}

Configuration

Adjust the display configuration at any time:

display.configure(uint8_t brightness, bool enabled, bool sleep, bool sevenSegment);

Full Display Control

Control all digits and their respective decimal points:

display.showWithDots(uint8_t digit0, bool dot0, uint8_t digit1, bool dot1, uint8_t digit2, bool dot2, uint8_t digit3, bool dot3);
display.dotPosition(bool dot0, bool dot1, bool dot2, bool dot3);
display.show(uint8_t digit0, uint8_t digit1, uint8_t digit2, uint8_t digit3);

Custom Characters

Create and display custom characters on the LED segments:

display.customDigit(uint8_t digit, bool a, bool b, bool c, bool d, bool e, bool f, bool g, bool dot);
display.customDigit(uint8_t digit, uint8_t digitData);

Keypad Interaction

Read key presses when using CH455 with a keypad:

uint8_t keyboardData = display.readKeyboard();

Note: The library is designed to handle numeric displays and does not support alphabetic characters or other symbols.

Contribute

Your contributions are welcome. Please feel free to submit pull requests or open issues to enhance the functionality of this library.

Enjoy building your projects with the CH455 Arduino Library!

ch455-arduino's People

Contributors

shiroichiheisen avatar

Stargazers

Damian Vila avatar Hannes Campidell avatar Crazy avatar

Watchers

 avatar

ch455-arduino's Issues

Problem About the Parameters of display.begin()

Hello, shiroichiheisen ! I appreciate you making the Arduino library for the ch455. But I encountered some problems during use.

When I call display.begin to initialize CH455, the IDE reports an error:

Code:

#include <ch455.h>

uint8_t sdaPin = 27;
uint8_t sclPin = 28;
uint8_t bright = 1;

ch455 display;

void setup() {
  display.begin(sdaPin, sclPin, bright);
}

void loop() {
}

OutPut:
/home/xinglin/Arduino/libraries/ch455/ch455.cpp: In member function 'void ch455::begin(uint8_t, uint8_t, uint8_t, bool, bool, bool)':
/home/xinglin/Arduino/libraries/ch455/ch455.cpp:38:24: error: no matching function for call to 'TwoWire::begin(uint8_t&, uint8_t&)'
     Wire.begin(sda, scl);
                        ^
In file included from /home/xinglin/Arduino/libraries/ch455/ch455.h:5:0,
                 from /home/xinglin/Arduino/libraries/ch455/ch455.cpp:1:
/home/xinglin/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire/src/Wire.h:53:10: note: candidate: void TwoWire::begin()
     void begin();
          ^~~~~
/home/xinglin/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire/src/Wire.h:53:10: note:   candidate expects 0 arguments, 2 provided
/home/xinglin/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire/src/Wire.h:54:10: note: candidate: void TwoWire::begin(uint8_t)
     void begin(uint8_t);
          ^~~~~
/home/xinglin/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire/src/Wire.h:54:10: note:   candidate expects 1 argument, 2 provided
/home/xinglin/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire/src/Wire.h:55:10: note: candidate: void TwoWire::begin(int)
     void begin(int);
          ^~~~~
/home/xinglin/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire/src/Wire.h:55:10: note:   candidate expects 1 argument, 2 provided

exit status 1

Compilation error: exit status 1

According to the information I found in the Arduino official reference,Wire.begin() seems like it shouldn't specify the SCL and SDA pins manually. When I pass the SDA and SCL parameters to display.begin, these two parameters will continue to be passed to Wire.begin(). That's the problem.(By the way, the Wire library seems to automatically recognize the Arduino model to determine which pins to use. When there are multiple I2C buses available on an Arduino, Wire0 and Wire1 should be used to distinguish them.)

Moreover, it seems that regardless of whether the above two parameters are passed to display.begin(), the following code is ultimately called:

void ch455::begin(uint8_t sda, uint8_t scl, uint8_t brightness, bool enabled, bool sleep, bool sevenSegment)
{
    Wire.begin(sda, scl);
    ch455::configure(brightness);
}

This will cause the program to not run properly regardless of the method used in the example.

Based on the above information I think this library needs further modifications, but I appreciate all your efforts.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.