mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.3.8 HT16K33
This commit is contained in:
parent
d118589587
commit
eb4e8c64cd
@ -6,7 +6,7 @@ jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: arduino/arduino-lint-action@v1
|
||||
with:
|
||||
library-manager: update
|
||||
|
@ -8,7 +8,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
|
@ -10,7 +10,7 @@ jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
|
@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [0.3.8] - 2023-02-26
|
||||
- add **getBrightness()**
|
||||
- moved code to .cpp file (prep 0.4.0)
|
||||
- update readme.md
|
||||
- added OBSOLETE section (prep 0.4.0)
|
||||
- update GitHub actions
|
||||
- update license 2023
|
||||
- minor edits
|
||||
|
||||
|
||||
## [0.3.7] - 2022-11-19
|
||||
- add displayUnit(float, char);
|
||||
@ -12,13 +21,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- add degree symbol
|
||||
- moved code to .cpp file (prep 0.4.0)
|
||||
|
||||
|
||||
## [0.3.6] - 2022-11-09
|
||||
- add changelog.md
|
||||
- add rp2040 to build-CI
|
||||
- update readme.md
|
||||
|
||||
|
||||
## [0.3.5] - 2022-09-23
|
||||
- fix #21 additional LEDs on the display
|
||||
used in a special layout :88:8'8
|
||||
|
@ -1,25 +1,23 @@
|
||||
//
|
||||
// FILE: HT16K33.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.7
|
||||
// VERSION: 0.3.8
|
||||
// DATE: 2019-02-07
|
||||
// PURPOSE: Arduino Library for HT16K33 4x7segment display
|
||||
// URL: https://github.com/RobTillaart/HT16K33
|
||||
//
|
||||
// HISTORY: see changelog.md
|
||||
|
||||
|
||||
#include "HT16K33.h"
|
||||
|
||||
|
||||
// Commands
|
||||
#define HT16K33_ON 0x21 // 0=off 1=on
|
||||
#define HT16K33_ON 0x21 // 0 = off 1 = on
|
||||
#define HT16K33_STANDBY 0x20 // bit xxxxxxx0
|
||||
|
||||
|
||||
// bit pattern 1000 0xxy
|
||||
// y = display on / off
|
||||
// xx = 00=off 01=2Hz 10=1Hz 11=0.5Hz
|
||||
// xx = 00=off 01=2Hz 10 = 1Hz 11 = 0.5Hz
|
||||
#define HT16K33_DISPLAYON 0x81
|
||||
#define HT16K33_DISPLAYOFF 0x80
|
||||
#define HT16K33_BLINKON0_5HZ 0x87
|
||||
@ -42,7 +40,7 @@
|
||||
// 10 04
|
||||
// 08
|
||||
//
|
||||
static const uint8_t charmap[] = { // TODO PROGMEM ?
|
||||
static const uint8_t charmap[] = { // TODO PROGMEM = slower?
|
||||
|
||||
0x3F, // 0
|
||||
0x06, // 1
|
||||
@ -187,6 +185,12 @@ void HT16K33::brightness(uint8_t value)
|
||||
}
|
||||
|
||||
|
||||
uint8_t HT16K33::getBrightness()
|
||||
{
|
||||
return _bright;
|
||||
}
|
||||
|
||||
|
||||
void HT16K33::setDigits(uint8_t value)
|
||||
{
|
||||
_digits = value > 4 ? 4 : value;
|
||||
@ -598,6 +602,18 @@ void HT16K33::dumpSerial()
|
||||
}
|
||||
|
||||
|
||||
uint8_t HT16K33::getAddress()
|
||||
{
|
||||
return _address;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// PRIVATE
|
||||
@ -635,11 +651,10 @@ void HT16K33::writePos(uint8_t pos, uint8_t mask)
|
||||
void HT16K33::writePos(uint8_t pos, uint8_t mask, bool point)
|
||||
{
|
||||
if (point) mask |= 0x80;
|
||||
// if (_overflow) mask |= 0x80;
|
||||
else mask &= 0x7F;
|
||||
writePos(pos, mask);
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: HT16K33.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.7
|
||||
// VERSION: 0.3.8
|
||||
// DATE: 2019-02-07
|
||||
// PURPOSE: Arduino Library for HT16K33 4x7segment display
|
||||
// http://www.adafruit.com/products/1002
|
||||
@ -13,7 +13,7 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define HT16K33_LIB_VERSION (F("0.3.7"))
|
||||
#define HT16K33_LIB_VERSION (F("0.3.8"))
|
||||
|
||||
|
||||
// Characters
|
||||
@ -39,64 +39,61 @@
|
||||
#define HT16K33_DEGREE 19 // °
|
||||
#define HT16K33_NONE 99
|
||||
|
||||
// P for Pascal / Pressure ?
|
||||
// J for joule?
|
||||
|
||||
class HT16K33
|
||||
{
|
||||
public:
|
||||
HT16K33(const uint8_t address, TwoWire *wire = &Wire); // 0x70 .. 0x77
|
||||
HT16K33(const uint8_t address, TwoWire *wire = &Wire); // 0x70 .. 0x77
|
||||
|
||||
#if defined (ESP8266) || defined(ESP32)
|
||||
bool begin(uint8_t sda, uint8_t scl);
|
||||
bool begin(uint8_t sda, uint8_t scl);
|
||||
#endif
|
||||
bool begin();
|
||||
void reset();
|
||||
bool begin();
|
||||
void reset();
|
||||
|
||||
bool isConnected();
|
||||
bool isConnected();
|
||||
|
||||
// default _cache is true as it is ~3x faster but if one has noise
|
||||
// on the I2C and wants to force refresh one can disable caching
|
||||
// for one or more calls.
|
||||
void clearCache();
|
||||
void cacheOn();
|
||||
void cacheOff();
|
||||
void refresh(); // force writing of cache to display
|
||||
void clearCache();
|
||||
void cacheOn();
|
||||
void cacheOff();
|
||||
void refresh(); // force writing of cache to display
|
||||
|
||||
void displayOn();
|
||||
void displayOff();
|
||||
void displayOn();
|
||||
void displayOff();
|
||||
|
||||
void brightness(uint8_t value); // 0 .. 15
|
||||
void blink(uint8_t value); // 0 .. 3 0 = off
|
||||
void brightness(uint8_t value); // 0 .. 15
|
||||
uint8_t getBrightness();
|
||||
void blink(uint8_t value); // 0 .. 3 0 = off
|
||||
|
||||
|
||||
// 0,1,2,3,4 digits - will replace suppressLeadingZeroPlaces
|
||||
void setDigits(uint8_t value);
|
||||
// 0 = off, 1,2,3,4 digits space instead of 0
|
||||
void suppressLeadingZeroPlaces(uint8_t value); // will be obsolete
|
||||
void setDigits(uint8_t value);
|
||||
|
||||
void displayClear();
|
||||
bool displayInt(int n); // -999 .. 9999
|
||||
bool displayHex(uint16_t n); // 0000 .. FFFF
|
||||
void displayClear();
|
||||
bool displayInt(int n); // -999 .. 9999
|
||||
bool displayHex(uint16_t n); // 0000 .. FFFF
|
||||
|
||||
// Date could be {month.day} or {day.hour} . as separator
|
||||
// Time could be hh:mm or mm:ss or ss:uu (hundreds : as separator
|
||||
// colon displays : lz = Leading Zero or space
|
||||
bool displayDate(uint8_t left, uint8_t right, bool lz = true); // 00.00 .. 99.99
|
||||
bool displayTime(uint8_t left, uint8_t right, bool colon = true, bool lz = true); // 00:00 .. 99:99
|
||||
bool displaySeconds(uint16_t seconds, bool colon = true, bool lz = true); // 00:00 .. 99:99
|
||||
bool displayDate(uint8_t left, uint8_t right, bool lz = true); // 00.00 .. 99.99
|
||||
bool displayTime(uint8_t left, uint8_t right, bool colon = true, bool lz = true); // 00:00 .. 99:99
|
||||
bool displaySeconds(uint16_t seconds, bool colon = true, bool lz = true); // 00:00 .. 99:99
|
||||
|
||||
// -999 .. 0.000 .. 9999
|
||||
bool displayFloat(float f, uint8_t decimals = 3);
|
||||
bool displayFloat(float f, uint8_t decimals = 3);
|
||||
|
||||
// -99 .. 0.00 .. 999
|
||||
bool displayUnit(float f, uint8_t decimals = 2, uint8_t unitChar = HT16K33_SPACE);
|
||||
bool displayUnit(float f, uint8_t decimals = 2, uint8_t unitChar = HT16K33_SPACE);
|
||||
|
||||
|
||||
void display(uint8_t *array); // array with 4 elements
|
||||
void display(uint8_t *array, uint8_t point); // point = digit with . (0..3)
|
||||
void displayColon(uint8_t on); // 0 = off
|
||||
void displayRaw(uint8_t *array, bool colon = false); // max control
|
||||
void display(uint8_t *array); // array with 4 elements
|
||||
void display(uint8_t *array, uint8_t point); // point = digit with . (0..3)
|
||||
void displayColon(uint8_t on); // 0 = off
|
||||
void displayRaw(uint8_t *array, bool colon = false); // max control
|
||||
|
||||
// from issue #21 - used in special layout :88:8'8 normal = 88:88 or 8.8.8.8
|
||||
// value = 0 ==> all off.
|
||||
@ -104,10 +101,10 @@ public:
|
||||
// 4 = upper left point, left of the 1st digit
|
||||
// 8 = lower left point, left of the 1st digit
|
||||
// 16 = upper point between 3rd and 4th digit
|
||||
void displayExtraLeds(uint8_t value);
|
||||
void displayExtraLeds(uint8_t value);
|
||||
|
||||
bool displayVULeft(uint8_t value); // 0..8
|
||||
bool displayVURight(uint8_t value); // 0..8
|
||||
bool displayVULeft(uint8_t value); // 0..8
|
||||
bool displayVURight(uint8_t value); // 0..8
|
||||
|
||||
|
||||
// DEBUG
|
||||
@ -116,20 +113,25 @@ public:
|
||||
void dumpSerial(uint8_t *array, uint8_t point);
|
||||
// display cache in HEX format
|
||||
void dumpSerial();
|
||||
uint8_t getAddress() { return _address; };
|
||||
uint8_t getAddr() { return getAddress(); }; // TODO obsolete in future
|
||||
uint8_t getAddress();
|
||||
|
||||
|
||||
// EXPERIMENTAL
|
||||
bool getOverflow() { return _overflow; };
|
||||
void clrOverflow() { _overflow = false; };
|
||||
|
||||
bool displayFixedPoint0(float f);
|
||||
bool displayFixedPoint1(float f);
|
||||
bool displayFixedPoint2(float f);
|
||||
bool displayFixedPoint3(float f);
|
||||
|
||||
|
||||
// OBSOLETE SOON
|
||||
// use getAddress(); instead.
|
||||
uint8_t getAddr() { return getAddress(); };
|
||||
|
||||
// use setDigits(); instead.
|
||||
// 0 = off, 1,2,3,4 digits space instead of 0
|
||||
void suppressLeadingZeroPlaces(uint8_t value);
|
||||
|
||||
|
||||
private:
|
||||
void _refresh();
|
||||
void writeCmd(uint8_t cmd);
|
||||
@ -143,11 +145,8 @@ private:
|
||||
uint8_t _bright;
|
||||
|
||||
TwoWire* _wire;
|
||||
|
||||
// EXPERIMENTAL
|
||||
bool _overflow = false;
|
||||
};
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-2022 Rob Tillaart
|
||||
Copyright (c) 2019-2023 Rob Tillaart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -55,8 +55,12 @@ get leading/trailing zero's correctly.
|
||||
|
||||
## Interface
|
||||
|
||||
```CPP
|
||||
#include "HT16K33.h"
|
||||
```
|
||||
|
||||
### Setup behaviour
|
||||
|
||||
#### Setup behaviour
|
||||
|
||||
- **HT16K33(const uint8_t address)** address is 0x70..0x77 depending on the jumpers A0..A2. **0x70** is default.
|
||||
- **bool begin(uint8_t sda, uint8_t scl)** for ESP32, select I2C pins, initialize I2C and calls **reset()**.
|
||||
@ -65,9 +69,15 @@ Returns false if device not seen on I2C bus.
|
||||
Returns false if device not seen on I2C bus.
|
||||
- **bool isConnected()** Returns false if device not seen on I2C bus.
|
||||
- **void reset()** resets display.
|
||||
|
||||
#### Cache
|
||||
|
||||
- **void clearCache()** forced clearing of the cache, to be used to switch the cache off just for one write.
|
||||
- **void cacheOn()** enable caching, this is default behaviour.
|
||||
- **void cacheOff()** disable caching, will force writing to every position.
|
||||
|
||||
#### Display
|
||||
|
||||
- **void displayOn()** enable display.
|
||||
- **void displayOff()** disable display, fast way to darken display e.g. for energy consumption.
|
||||
- **void brightness(uint8_t value)** values (dim) 0..15 (bright).
|
||||
@ -76,7 +86,7 @@ Returns false if device not seen on I2C bus.
|
||||
- **uint8_t getAddress()** idem.
|
||||
|
||||
|
||||
### Data types
|
||||
#### Data types
|
||||
|
||||
The bool return value indicates that the value displayed is in range.
|
||||
|
||||
@ -102,7 +112,7 @@ The unitChar must be one of the chars supported like HT16K33_C, HT16K33_TOP_C or
|
||||
So **displayUnit(25.6, 1, HT16K33_DEGREE)** will display **23.5°**.
|
||||
|
||||
|
||||
### Experimental fixed point
|
||||
#### Experimental fixed point
|
||||
|
||||
These functions are new and still under investigation.
|
||||
|
||||
@ -112,13 +122,13 @@ These functions are new and still under investigation.
|
||||
- **bool displayFixedPoint3(float f)** displays values 0.000 .. 9.999 with 3 decimals.
|
||||
|
||||
|
||||
### Special VU meters
|
||||
#### Special VU meters
|
||||
|
||||
- **bool displayVULeft(uint8_t value)** display used as sort VU meter, values 0..8 Vales > 8 are treated as 8 (but return false).
|
||||
- **bool displayVURight(uint8_t value)** display used as sort VU meter, values 0..8 Vales > 8 are treated as 8 (but return false).
|
||||
|
||||
|
||||
### Lower level workers
|
||||
#### Lower level workers
|
||||
|
||||
- **void display(uint8_t \* array)** array of 4 bytes to control one 7seg display.
|
||||
- **void display(uint8_t \* array, uint8_t point)** idem + point = position of the digit with point (0..3).
|
||||
@ -127,6 +137,7 @@ These functions are new and still under investigation.
|
||||
- **void displayExtraLeds(uint8_t value)** switch on extra leds.
|
||||
value is in fact a bit mask see table below. 0 = all off.
|
||||
|
||||
|
||||
#### Extra LEDs table
|
||||
|
||||
| mask | description |
|
||||
@ -140,7 +151,7 @@ value is in fact a bit mask see table below. 0 = all off.
|
||||
( based upon issue #21 )
|
||||
|
||||
|
||||
### Debugging
|
||||
#### Debugging
|
||||
|
||||
- **void displayTest(uint8_t del)** debugging / test function.
|
||||
- **void dumpSerial(uint8_t \* array, uint8_t point)** debugging equivalent of the display.
|
||||
@ -148,9 +159,11 @@ Prints to Serial.
|
||||
- **void dumpSerial()** print HEX codes equivalent of the display to Serial.
|
||||
|
||||
|
||||
### Obsolete
|
||||
#### Obsolete
|
||||
|
||||
- suppressLeadingZeroPlaces(uint8_t value) use **setDigits()**
|
||||
- getAddr() use **getAddress()**
|
||||
|
||||
- **void suppressLeadingZeroPlaces(uint8_t value)** obsolete, replaced by setDigits
|
||||
|
||||
## Characters supported
|
||||
|
||||
@ -190,21 +203,41 @@ See examples
|
||||
|
||||
## Future
|
||||
|
||||
#### 0.4.0
|
||||
|
||||
#### Must
|
||||
|
||||
Mainly for a 0.4.0
|
||||
|
||||
- **bool isDisplayOn()** and similar state functions
|
||||
- configuration byte: 4 bits brightness, 1 bit on off flag, 1 bit cache flag, 2 blink rate
|
||||
- **void setBrightness()** and **uint8_t getBrightness()**
|
||||
|
||||
|
||||
#### Should
|
||||
|
||||
- **void setBrightness()**
|
||||
- **void setBlink()** and **uint8_t getBlink()**
|
||||
- **void getDigits()**
|
||||
- **FixedPoint()** regular (experimental in 0.3.2)
|
||||
- overflow flag ? or not decision
|
||||
- move all code to .cpp file
|
||||
- even the small functions.
|
||||
|
||||
#### unknown
|
||||
|
||||
#### Could
|
||||
|
||||
- VU metering using halve bars allows two VU from 0..8 **new**
|
||||
- VU metering using halve bars allows one VU from 0..17. extension of current VUleft/right
|
||||
- optimize the math if possible - performance and footprint. +float + int division
|
||||
- optimize math if possible - performance and footprint. + float + int division
|
||||
- low level I2C error detection
|
||||
- write single position - **writePos(uint8_t pos, uint8_t mask)**
|
||||
- [status] dd.d
|
||||
- add examples
|
||||
- car battery monitor (voltage divider & analogRead)
|
||||
|
||||
|
||||
#### Wont (unless sponsored)
|
||||
|
||||
- **rotate(bool rot = false)**
|
||||
- 180 degree rotation of all digits for mounting
|
||||
- reverse digit order
|
||||
- flip every digit (function to overwrite the char array)
|
||||
- **HUD(bool hud = false)** = Heads Up Display
|
||||
- flip every digit
|
||||
|
||||
|
@ -9,6 +9,7 @@ HT16K33 KEYWORD1
|
||||
|
||||
HT16K33 KEYWORD2
|
||||
begin KEYWORD2
|
||||
|
||||
reset KEYWORD2
|
||||
clearCache KEYWORD2
|
||||
cacheOn KEYWORD2
|
||||
@ -46,6 +47,8 @@ displayVURight KEYWORD2
|
||||
|
||||
|
||||
# Experimental
|
||||
getOverflow KEYWORD2
|
||||
clrOverflow KEYWORD2
|
||||
displayFixedPoint0 KEYWORD2
|
||||
displayFixedPoint1 KEYWORD2
|
||||
displayFixedPoint2 KEYWORD2
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/HT16K33.git"
|
||||
},
|
||||
"version": "0.3.7",
|
||||
"version": "0.3.8",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=HT16K33
|
||||
version=0.3.7
|
||||
version=0.3.8
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino Library for HT16K33 I2C 4x7segment display
|
||||
|
@ -33,22 +33,11 @@ unittest_setup()
|
||||
fprintf(stderr, "HT16K33_LIB_VERSION: %s\n", (char *) HT16K33_LIB_VERSION);
|
||||
}
|
||||
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
unittest(test_new_operator)
|
||||
{
|
||||
assertEqualINF(exp(800));
|
||||
assertEqualINF(0.0/0.0);
|
||||
assertEqualINF(42);
|
||||
|
||||
assertEqualNAN(INFINITY - INFINITY);
|
||||
assertEqualNAN(0.0/0.0);
|
||||
assertEqualNAN(42);
|
||||
}
|
||||
*/
|
||||
|
||||
unittest(test_constructor)
|
||||
{
|
||||
@ -86,6 +75,9 @@ unittest(test_constants)
|
||||
assertEqual(HT16K33_NONE , 99);
|
||||
}
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
||||
|
||||
// --END OF FILE --
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user