GY-63_MS5611/libraries/HT16K33/README.md

157 lines
6.6 KiB
Markdown
Raw Normal View History

2021-01-29 06:31:58 -05:00
[![Arduino CI](https://github.com/RobTillaart/HT16K33/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
2021-12-19 09:24:23 -05:00
[![Arduino-lint](https://github.com/RobTillaart/HT16K33/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/HT16K33/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/HT16K33/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/HT16K33/actions/workflows/jsoncheck.yml)
2021-01-29 06:31:58 -05:00
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/HT16K33/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/HT16K33.svg?maxAge=3600)](https://github.com/RobTillaart/HT16K33/releases)
2020-07-17 06:34:54 -04:00
# HT16K33
2021-12-19 09:24:23 -05:00
Arduino Library for HT16K33 I2C 4x7segment display.
2020-07-17 06:34:54 -04:00
2021-01-29 06:31:58 -05:00
2020-07-17 06:34:54 -04:00
## Description
This library is for the Adafruit 4x7segment display with HT16K33 driver,
http://www.adafruit.com/products/1002
2020-11-27 05:16:22 -05:00
This library is functionally less capable than Adafruits.
However as it caches the values written to the display per position
it is faster for writing on average. The actual gain depends on the
application and of course the values.
2020-07-17 06:34:54 -04:00
2020-11-27 05:16:22 -05:00
## Perfomance
Version 0.3.0 allows one to switch the caching on/off to enforce
writing all positions e.g. in case of noisy I2C bus.
The example **demo_cache.ino** measures the performance gain of caching
for different I2C bus speeds.
```
2020-07-17 06:34:54 -04:00
Test on UNO, I2C.setClock(100000); // version 0.1.2
0-9999 integers 3.960 sec
0-65535 hexadecimal 23.685 sec
Test on UNO, I2C.setClock(800000); // version 0.1.2
0-9999 integers 1.223 sec
0-65535 hexadecimal 6.350 sec
2020-11-27 05:16:22 -05:00
Test on UNO, I2C.setClock(100000); // version 0.3.0
0-9999 integers 4.092 sec // ~3% slower due to robustness & cache control
0-65535 hexadecimal 24.336 sec
```
2021-01-29 06:31:58 -05:00
2020-11-27 05:16:22 -05:00
## Multiple display
The library supports only one display. Using multiple displays (cascading) e.g. to
display more than 4 digits must done by the user - see **demo_dual1.ino**.
With dual display it is important to **setDigits()** for the displays correctly to
2021-01-29 06:31:58 -05:00
get leading/trailing zero's correctly.
2020-11-27 05:16:22 -05:00
## Interface
2021-01-29 06:31:58 -05:00
### Setup behaviour
2021-12-19 09:24:23 -05:00
- **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()**.
2021-01-29 06:31:58 -05:00
Returns false if device not seen on I2C bus.
- **bool begin()** initialize I2C and calls **reset()**.
Returns false if device not seen on I2C bus.
- **bool isConnected()** Returns false if device not seen on I2C bus.
2021-12-19 09:24:23 -05:00
- **void reset()** resets display.
2020-11-27 05:16:22 -05:00
- **void clearCache()** forced clearing of the cache, to be used to switch the cache off just for one write.
2021-12-19 09:24:23 -05:00
- **void cacheOn()** enable caching, this is default behaviour.
- **void cacheOff()** disable caching, will force writing to every position.
- **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).
- **void blink(uint8_t value)** values 0..3 0 = off.
- **void setDigits(uint8_t value)** values 0..4, minimal number of digits shown, mandatory for large numbers on dual display.
- **uint8_t getAddress()** idem.
2020-11-27 05:16:22 -05:00
2021-01-29 06:31:58 -05:00
2021-12-19 09:24:23 -05:00
### Data types
2021-01-29 06:31:58 -05:00
The bool return value indicates that the value displayed is in range.
2021-05-26 09:01:19 -04:00
- **void displayClear()** fill display with spaces => results in an empty display.
2021-12-19 09:24:23 -05:00
- **bool displayInt(int n)** values -999 .. 9999
- **bool displayHex(uint16_t n)** values 0000 .. FFFF
- **bool displayDate(uint8_t left, uint8_t right, bool lz = true)** values 00.00..99.99 Date could be {month.day} or {day.hour}
2021-05-26 09:01:19 -04:00
It uses **.** as separator. Optional the leading zero (lz)
2021-12-19 09:24:23 -05:00
can be replaced by a space to look more natural e.g 1:54 instead of 01:54
- **bool displayTime(uint8_t left, uint8_t right, bool colon = true, bool lz = true)** values 00:00..99:99
2021-05-26 09:01:19 -04:00
Time could be hh:mm or mm:ss or ss:uu (hundreds), it uses **:** as separator.
Optional the colon is set to false (e.g. to simulate blink) and optional the leading zero (lz)
2021-12-19 09:24:23 -05:00
can be replaced by a space to look more natural e.g 1:54 instead of 01:54
- **void displaySeconds(uint16_t seconds, bool colon, bool lz = true)** displays 00:00..99:99 units in seconds (or minutes) - splits % 60 : as separator
2021-05-26 09:01:19 -04:00
Optional the colon is set to false (to simulate blink).
2021-12-19 09:24:23 -05:00
Optional the leading zero (lz) can be replaced by a space to look more natural e.g 1:54 instead of 01:54
- **bool displayFloat(float f, uint8_t decimals = 3)** values -999..0.000..9999
2021-01-29 06:31:58 -05:00
The number of decimals = 0,1,2,3 = default. When less decimals are displayed, the number will be right aligned.
2020-11-27 05:16:22 -05:00
2021-01-29 06:31:58 -05:00
### Experimental
These functions are new and still under investigation.
- **bool displayFixedPoint0(float f)** displays values -999 .. 9999 without decimals.
- **bool displayFixedPoint1(float f)** displays values -99.9 .. 999.9 with 1 decimals.
- **bool displayFixedPoint2(float f)** displays values -9.99 .. 99.99 with 2 decimals.
- **bool displayFixedPoint3(float f)** displays values 0.000 .. 9.999 with 3 decimals.
### Special
2021-12-19 09:24:23 -05:00
- **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).
2021-01-29 06:31:58 -05:00
### Lower level workers
2020-11-27 05:16:22 -05:00
2021-12-19 09:24:23 -05:00
- **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).
- **void displayColon(uint8_t on)** 0 = off, all values other are on.
- **void displayRaw(uint8_t \* array, bool colon)** array of 4 bytes to control one 7seg display + colon flag.
2020-11-27 05:16:22 -05:00
2021-01-29 06:31:58 -05:00
### Debugging
2021-12-19 09:24:23 -05:00
- **void displayTest(uint8_t del)** debugging / test function.
- **void dumpSerial(uint8_t \* array, uint8_t point)** debugging equivalent of display.
2020-07-17 06:34:54 -04:00
2021-01-29 06:31:58 -05:00
2021-12-19 09:24:23 -05:00
### Obsolete
- **void suppressLeadingZeroPlaces(uint8_t value)** obsolete, replaced by setDigits
## Operation
See examples
## Future
2021-01-29 06:31:58 -05:00
**0.4.0**
- **bool isDisplayOn()** and similar state functions
2021-12-19 09:24:23 -05:00
- configuration byte: 4 bits brightness, 1 bit on off flag, 1 bit cache flag, 2 blink rate
2021-01-29 06:31:58 -05:00
- **void setBrightness()** and **uint8_t getBrightness()**
- **void setBlink()** and **uint8_t getBlink()**
- **void getDigits()**
- **FixedPoint()** regular (experimental in 0.3.2)
2021-12-19 09:24:23 -05:00
- overflow flag ? or not decision
2021-01-29 06:31:58 -05:00
**unknown**
- 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
- low level I2C error detection