Skip to content

Commit bbd40fb

Browse files
authored
fix #21 displayExtraLeds() (#22)
* fix #21 displayExtraLeds()
1 parent c4fc4ba commit bbd40fb

File tree

8 files changed

+339
-7
lines changed

8 files changed

+339
-7
lines changed

HT16K33.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: HT16K33.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.3.4
4+
// VERSION: 0.3.5
55
// DATE: 2019-02-07
66
// PURPOSE: Arduino Library for HT16K33 4x7segment display
77
// URL: https://github.com/RobTillaart/HT16K33
@@ -13,11 +13,13 @@
1313
// 0.1.3 2019-10-07 fixed clear, added suppressLeadingZeroPlaces();
1414
// 0.1.4 2019-11-28 added displayRaw(), displayVULeft(), displayVURight()
1515
// 0.1.5 2019-11-30 refactor,
16+
//
1617
// 0.2.0 2020-06-13 ESP32 support; fix brightness bug;
1718
// 0.2.1 2020-07-15 fix #160 - decimal point
1819
// 0.2.2 2020-10-04 added displayDate() thanks to bepitama
1920
// 0.2.3 2020-10-09 issue #4 add negative values for displayInt()
2021
// 0.2.4 2020-10-10 refactor #5 setDigits() iso suppressLeadingZeroPlaces()
22+
//
2123
// 0.3.0 2020-10-12 negative float, cache control, extend displayRaw()
2224
// 0.3.1 2020-12-28 Arduino-CI, unit test (framework only),
2325
// 0.3.2 2021-01-14 add WireN support,
@@ -26,6 +28,8 @@
2628
// add displayFloat(f, decimals); // experimental
2729
// 0.3.3 2021-05-26 fix #17 add leadingZero flag in displayTIme() [Kudos to OwenDuffy]
2830
// 0.3.4 2021-12-19 update library.json, license, minor edits
31+
// 0.3.5 2022-09-23 fix #21 additional LEDs on the display
32+
// used in a special layout :88:8'8
2933

3034

3135
#include "HT16K33.h"
@@ -498,6 +502,16 @@ void HT16K33::displayColon(uint8_t on)
498502
}
499503

500504

505+
void HT16K33::displayExtraLeds(uint8_t value)
506+
{
507+
if (value > 30)
508+
{
509+
return; // no leds.
510+
}
511+
writePos(2, value);
512+
}
513+
514+
501515
void HT16K33::dumpSerial(uint8_t *array, uint8_t point)
502516
{
503517
// to debug without display

HT16K33.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: HT16K33.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.3.4
5+
// VERSION: 0.3.5
66
// DATE: 2019-02-07
77
// PURPOSE: Arduino Library for HT16K33 4x7segment display
88
// http://www.adafruit.com/products/1002
@@ -14,7 +14,7 @@
1414
#include "Wire.h"
1515

1616

17-
#define HT16K33_LIB_VERSION (F("0.3.4"))
17+
#define HT16K33_LIB_VERSION (F("0.3.5"))
1818

1919

2020
// Characters
@@ -90,6 +90,14 @@ class HT16K33
9090
void displayColon(uint8_t on); // 0 = off
9191
void displayRaw(uint8_t *array, bool colon = false); // max control
9292

93+
// from issue #21 - used in special layout :88:8'8 normal = 88:88 or 8.8.8.8
94+
// value = 0 ==> all off.
95+
// 2 = colon
96+
// 4 = upper left point, left of the 1st digit
97+
// 8 = lower left point, left of the 1st digit
98+
// 16 = upper point between 3rd and 4th digit
99+
void displayExtraLeds(uint8_t value);
100+
93101
bool displayVULeft(uint8_t value); // 0..8
94102
bool displayVURight(uint8_t value); // 0..8
95103

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ These functions are new and still under investigation.
119119
- **void display(uint8_t \* array, uint8_t point)** idem + point = position of the digit with point (0..3).
120120
- **void displayColon(uint8_t on)** 0 = off, all values other are on.
121121
- **void displayRaw(uint8_t \* array, bool colon)** array of 4 bytes to control one 7seg display + colon flag.
122+
- **void displayExtraLeds(uint8_t value)** switch on extra leds.
123+
value is in fact a bit mask see table below. 0 = all off.
124+
125+
#### Extra Leds table
126+
127+
| mask | description |
128+
|:------:|:--------------|
129+
| 0x00 | all off
130+
| 0x02 | colon.
131+
| 0x04 | upper left point, left of the 1st digit.
132+
| 0x08 | lower left point, left of the 1st digit.
133+
| 0x10 | upper point between 3rd and 4th digit.
134+
135+
( based upon issue #21 )
122136

123137

124138
### Debugging
@@ -139,16 +153,19 @@ See examples
139153

140154
## Future
141155

142-
**0.4.0**
156+
#### 0.4.0
157+
143158
- **bool isDisplayOn()** and similar state functions
144159
- configuration byte: 4 bits brightness, 1 bit on off flag, 1 bit cache flag, 2 blink rate
145160
- **void setBrightness()** and **uint8_t getBrightness()**
146161
- **void setBlink()** and **uint8_t getBlink()**
147162
- **void getDigits()**
148163
- **FixedPoint()** regular (experimental in 0.3.2)
149164
- overflow flag ? or not decision
165+
- move all code to .cpp file
166+
- even the small functions.
150167

151-
**unknown**
168+
#### unknown
152169
- VU metering using halve bars allows two VU from 0..8 **new**
153170
- VU metering using halve bars allows one VU from 0..17. extension of current VUleft/right
154171
- optimize the math if possible - performance and footprint. +float + int division

examples/demo2/demo2.ino

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
//
2+
// FILE: 4x7segmentI2C.ino
3+
// AUTHOR: Rob Tillaart
4+
// PURPOSE: demo 2
5+
// URL: http://www.adafruit.com/products/1002
6+
// URL: https://github.com/RobTillaart/HT16K33
7+
8+
#include "HT16K33.h"
9+
10+
HT16K33 seg(0x70);
11+
12+
uint32_t start;
13+
uint32_t stop;
14+
15+
void setup()
16+
{
17+
Serial.begin(115200);
18+
Serial.println(__FILE__);
19+
20+
seg.begin();
21+
Wire.setClock(100000);
22+
23+
seg.displayOn();
24+
seg.suppressLeadingZeroPlaces(0);
25+
26+
Serial.println("displayTest()");
27+
seg.displayTest(100);
28+
seg.displayOff();
29+
delay(1000);
30+
seg.displayOn();
31+
}
32+
33+
void loop()
34+
{
35+
Serial.println("Int");
36+
seg.displayInt(9999);
37+
delay(1000);
38+
39+
Serial.println("Hex");
40+
seg.displayHex(0xABCF);
41+
delay(1000);
42+
43+
Serial.println("dim()");
44+
for (int i = 0; i < 16; i++)
45+
{
46+
seg.brightness(i);
47+
delay(500);
48+
}
49+
for (int i = 15; i > 0; i--)
50+
{
51+
seg.brightness(i);
52+
delay(500);
53+
}
54+
seg.brightness(2);
55+
56+
Serial.println("displayClear()");
57+
seg.displayClear();
58+
delay(1000);
59+
60+
Serial.println("displayTime()");
61+
seg.displayTime(13, 25);
62+
for (int i = 50; i < 60; i++)
63+
{
64+
seg.displayTime(13, i);
65+
delay(500);
66+
seg.displayColon(true);
67+
delay(500);
68+
}
69+
70+
Serial.println("float");
71+
seg.displayClear();
72+
delay(500);
73+
seg.displayFloat(3.14159265);
74+
delay(500);
75+
seg.displayFloat(99999);
76+
delay(500);
77+
seg.displayFloat(9999);
78+
delay(500);
79+
seg.displayFloat(31.4159265);
80+
delay(500);
81+
seg.displayFloat(314.159265);
82+
delay(500);
83+
seg.displayFloat(3141.59265);
84+
delay(500);
85+
seg.displayFloat(0.314159265);
86+
delay(500);
87+
seg.displayFloat(0.0314159265);
88+
delay(500);
89+
seg.displayFloat(0.00314159265);
90+
delay(500);
91+
seg.displayFloat(0.000314159265);
92+
delay(500);
93+
94+
95+
Serial.println("Voltmeter");
96+
for (int i = 0; i < 100; i++)
97+
{
98+
float voltage = analogRead(A0) * 5.0 / 1023;
99+
seg.displayFloat(voltage);
100+
delay(100);
101+
}
102+
103+
Serial.println("blink()");
104+
for (uint8_t i = 0; i < 3; i++)
105+
{
106+
seg.blink(i);
107+
delay(4000);
108+
}
109+
seg.blink(0);
110+
111+
Serial.print("INT TEST:\t");
112+
start = millis();
113+
for (uint16_t counter = 0; counter < 9999; counter++)
114+
{
115+
seg.displayInt(counter);
116+
}
117+
stop = millis();
118+
Serial.println(stop - start);
119+
120+
121+
Serial.print("HEX TEST:\t");
122+
start = millis();
123+
for (uint16_t counter = 0; counter < 0xFFFF; counter++)
124+
{
125+
seg.displayHex(counter);
126+
}
127+
stop = millis();
128+
Serial.println(stop - start);
129+
130+
Serial.print("SUPRESS ZERO TEST:\t");
131+
for (uint8_t nlz = 0; nlz < 5; nlz++)
132+
{
133+
Serial.print(nlz);
134+
seg.suppressLeadingZeroPlaces(nlz);
135+
seg.displayInt(0);
136+
delay(1000);
137+
}
138+
seg.suppressLeadingZeroPlaces(0);
139+
Serial.println("\n -- DONE -- \n");
140+
}
141+
142+
143+
// -- END OF FILE --

0 commit comments

Comments
 (0)