Giter Site home page Giter Site logo

ht16k33's Introduction

ht16k33

This library is used to allow an arduino like platform talk to the holtek ht16k33 chip to do things like turn on/off LEDs or scan keys

You set/clear whatever LEDs you want, then you call sendLed() to update the display with the new values.

simple code sample

/****************************************************************
* Simple test of ht16k33 library turning on and off LEDs
*/

#include "ht16k33.h"

// Define the class
HT16K33 HT;

/****************************************************************/
void setup() {
    Serial.begin(115200);
    Serial.println(F("ht16k33 light test v0.01"));
    Serial.println();
    // initialize everything, 0x00 is the i2c address for the first one (0x70 is added in the class).
    HT.begin(0x00);
}

/****************************************************************/
void loop() {
    uint8_t led;

    Serial.println(F("Turn on all LEDs"));
    // first light up all LEDs
    for (led=0; led<128; led++) {
        HT.setLedNow(led);
        delay(10);
    } // for led

    Serial.println(F("Clear all LEDs"));
    //Next clear them
    for (led=0; led<128; led++) {
        HT.clearLedNow(led);
        delay(10);
    } // for led

    //Now do one by one, slowly, and print out which one
    for (led=0; led<128; led++) {
        HT.setLedNow(led);
        Serial.print(F("Led no "));
        Serial.print(led,DEC);
        Serial.print(F(": On"));
        delay(1000);
        HT.clearLedNow(led);
        Serial.println(F(" Off"));
    } // for led
} // loop

Sample to Read keyboard and seg16 is in example directory.

Methods

void      clearAll();               // clear all LEDs
uint8_t   sleep();                  // stop oscillator to put the chip to sleep
uint8_t   normal();                 // wake up chip and start ocillator
uint8_t   clearLed(uint8_t ledno);  // 16x8 = 128 LEDs to turn off, 0-127
uint8_t   setLed(uint8_t ledno);    // 16x8 = 128 LEDs to turn on, 0-127
void      define7segFont(uint8_t *ptr);                     // Pass a pointer to a font table for 7seg
void      define16segFont(uint16_t *ptr);                   // Pass a pointer to a font table for 16seg see example/seg16/asciifont-pinout11.h & asciifont-pinout12.h
uint8_t   set7Seg(uint8_t dig, uint8_t cha, boolean dp);    // position 0-15, 0-15 (0-F Hexadecimal), decimal point
uint8_t   set16Seg(uint8_t dig, uint8_t cha);               // position 0-7, see asciifont.h
boolean   getLed(uint8_t ledno,boolean Fresh=false);        // check if a specific led is on(true) or off(false)
uint8_t   setDisplayRaw(uint8_t pos, uint8_t val);          // load byte "pos" with value "val"
uint8_t   sendLed();                                        // send whatever led patter you set
uint8_t   set7SegNow(uint8_t dig, uint8_t cha, boolean dp); // position 0-15, 0-15 (0-F Hexadecimal), decimal point and send led in one function
uint8_t   set7SegRaw(uint8_t dig, uint8_t val);             // load byte "pos" with value "val"
uint8_t   set16SegNow(uint8_t dig, uint8_t cha);            // position 0-17, see asciifont.h and send led in one function
uint8_t   setLedNow(uint8_t ledno);                         // Set a single led and send led in one function
uint8_t   clearLedNow(uint8_t ledno);                       // Clear a single led and send led in one function
uint8_t   setBrightness(uint8_t level);                     // level 0-16, 0 means display off
uint8_t   keyINTflag();                                     // INTerrupt flag value, set when a key is pressed
uint8_t   keysPressed();                                    // report how many keys that are pressed, clear means report as if new
int8_t    readKey(boolean clear=false);                     // read what key was pressed, Fresh=false to go from cache
void      readKeyRaw(KEYDATA keydata,boolean Fresh=true);   // read the raw key info, bitmapped info of all key(s) pressed
uint8_t   setBlinkRate(uint8_t rate);                       // HT16K33_DSP_{NOBLINK,BLINK2HZ,BLINK1HZ,BLINK05HZ}
void      displayOn();
void      displayOff();

ht16k33's People

Contributors

lpaseen avatar nomakewan avatar

Stargazers

Jose Vega avatar  avatar  avatar Ben Stern avatar TK avatar  avatar  avatar  avatar  avatar  avatar underwood avatar Robert Klajko avatar  avatar  avatar Owen Clarke avatar  avatar  avatar Phenates  avatar  avatar  avatar Peter Jakab avatar  avatar squad31 avatar Michael Furtak avatar xinlnix avatar Eric Hiller avatar  avatar lisper avatar

Watchers

James Cloos avatar  avatar  avatar Scotty Franzyshen avatar RickyS avatar  avatar Rafał Rogowski avatar

ht16k33's Issues

Compile warnings

When I use this library, I get the following compilation warnings:

.pio/libdeps/serial/ht16k33/src/ht16k33.cpp: In member function 'void HT16K33::begin(uint8_t)':
.pio/libdeps/serial/ht16k33/src/ht16k33.cpp:84:11: warning: unused variable 'i' [-Wunused-variable]
uint8_t i;
^
.pio/libdeps/serial/ht16k33/src/ht16k33.cpp: In member function 'uint8_t HT16K33::i2c_read(uint8_t, uint8_t*, uint8_t)':
.pio/libdeps/serial/ht16k33/src/ht16k33.cpp:143:20: warning: unused variable 'val' [-Wunused-variable]
uint8_t i,retcnt,val;
^
.pio/libdeps/serial/ht16k33/src/ht16k33.cpp: In member function 'boolean HT16K33::getLed(uint8_t, boolean)':
.pio/libdeps/serial/ht16k33/src/ht16k33.cpp:244:1: warning: control reaches end of non-void function [-Wreturn-type]
} // getLed

I'm compiling this for an ESP8266.

The warnings about unused variables is mostly harmless and can probably simply be fixed by simply removing the unused variables.
The warning about "control reaches end of non-void function" looks a bit more serious.
How I would fix it:

  • do the range check first, before doing any other stuff
  • if the range check fails, return false
  • the check itself verifies that an uint8_t is >= 0, this is a silly check since the data type is already unsigned

readKey doesn't work properly

the readKey function suppose to return key that was (de)pressed but it doesn't always do that, seems to return random numbers now and then.

ESP8266-01 compatibility

For the library to work correctly on ESP8266-01 it should be in the file ht16k33.cpp
line
Wire.begin();
and change to
Wire.begin(0,2);

Regards

Wrong Test in "setBrightness"

The setBrightness function (line 345 in the file ht16k33.cpp) contains the following test:

if (HT16K33_DIM_1>=0 && level <HT16K33_DIM_16){

Should it be correct as follows?

if (level >= HT16K33_DIM_1 && level <HT16K33_DIM_16){

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.