Skip to content

Commit

Permalink
Merge pull request #13 from valerionew/character-display
Browse files Browse the repository at this point in the history
Character display
  • Loading branch information
valerionew authored Nov 9, 2021
2 parents 2a14d8a + c54bf34 commit 8922dc3
Show file tree
Hide file tree
Showing 7 changed files with 351 additions and 104 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ Accepts values from 0 to 3. Smaller values will be treated like 0, bigger values
* `void print(long num)`
Prints a signed integer between -99999 and 999999. Larger and smaller values will be displayed as -99999 and 999999

* `void printCelsius(float num)`
Prints a signed temperature between -999 and 9999 and appends the degree symbol. Larger and smaller values will be displayed as -999 and 9999. The precision is limited to 1 digit due to the fact that there is no dot on the left part of the display (it's used for the battery).

* `void print(float num)`
Prints a float with 3 decimals.

* `void print(float num, int precision)`
Prints a float with 0 to 3 decimals, based on the `precision` parameter.

* `void print(char* str, bool leftPadded = false)`
Prints a string. If `leftPadded` is true, the string will be left padded with spaces to fit the display. Not all characters are supported, only the ones that can be displayed on the display. Higher and lower case characters are ignored and the one that is the most clear between the two is used. Currenly not supporting: 'k' (unprintable???), 'v', 'w'. 'm' is printed in a funny way but looks like it's common notation. Symbols available: '°' (must use '*' but prints °), '|', '-', '_'.

* `void noDisplay()`
Turns off the display (doesn't turn off the backlight)

Expand All @@ -45,13 +51,13 @@ Turns the display back on after it has been disabled by `noDisplay()`
C -> 0x1D = 10 + 01 + 04 + 08

```
___10___
| |
01 20
|___02___|
| |
04 40
|___08___|
_0b1 0000_
| |
0b1 0b10 0000
|___0b10___|
| |
0b0100 0b0100 0000
|__00b1000_|
```

79 changes: 79 additions & 0 deletions examples/KitchenSink/KitchenSink.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include <HT1621.h>
#define LCD_CS_PIN 6
#define LCD_WR_PIN 7
#define LCD_DATA_PIN 8
#define DELAY_SINK 1000

HT1621 lcd;
void setup() {
lcd.begin(LCD_CS_PIN, LCD_WR_PIN, LCD_DATA_PIN);
lcd.backlight();
lcd.clear();
lcd.setBatteryLevel(3);
}

void loop(){
lcd.clear();
lcd.print("AaBbCc");
delay(DELAY_SINK);
lcd.clear();
lcd.print("DdEeFf");
delay(DELAY_SINK);
lcd.clear();
lcd.print("GgHhIi");
delay(DELAY_SINK);
lcd.clear();
lcd.print("JjKkLl");
delay(DELAY_SINK);
lcd.clear();
lcd.print("MmNnOo");
delay(DELAY_SINK);
lcd.clear();
lcd.print("PpQqRr");
delay(DELAY_SINK);
lcd.clear();
lcd.print("SsTtUu");
delay(DELAY_SINK);
lcd.clear();
lcd.print("VvWwXx");
delay(DELAY_SINK);
lcd.clear();
lcd.print("YyZz ");
delay(DELAY_SINK);
lcd.clear();
lcd.print("123456");
delay(DELAY_SINK);
lcd.clear();
lcd.print("7890", true); // left padded
delay(DELAY_SINK);
lcd.clear();
lcd.print(" _-|*"); // Spaces
delay(DELAY_SINK);
lcd.clear();
lcd.print("HELLO");
delay(DELAY_SINK);
lcd.clear();
lcd.print("HT1621");
delay(DELAY_SINK);
lcd.clear();
lcd.print("bye");
delay(DELAY_SINK);
lcd.clear();
lcd.print("123*", true); // Degrees
delay(DELAY_SINK);
lcd.clear();
lcd.print((long)123456);
delay(DELAY_SINK);
lcd.clear();
lcd.print(1234.10, 2);
delay(DELAY_SINK);
lcd.clear();
lcd.print(999.123234);
delay(DELAY_SINK);
lcd.clear();
lcd.print(1250.0, 3);
delay(DELAY_SINK);
lcd.clear();
lcd.print(111.1111, 3);
delay(DELAY_SINK);
}
35 changes: 35 additions & 0 deletions examples/PrintCelsius/PrintCelsius.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <HT1621.h>
#define LCD_CS_PIN 6
#define LCD_WR_PIN 7
#define LCD_DATA_PIN 8
#define DELAY_SINK 6000

// #define HT1621_DEBUG

HT1621 lcd;
void setup() {
lcd.begin(LCD_CS_PIN, LCD_WR_PIN, LCD_DATA_PIN);
lcd.backlight();
lcd.clear();
}

void loop(){
lcd.clear();
lcd.printCelsius(0.1);
delay(DELAY_SINK);
lcd.clear();
lcd.printCelsius(10);
delay(DELAY_SINK);
lcd.clear();
lcd.printCelsius(11111.1); // saturates at 9999
delay(DELAY_SINK);
lcd.clear();
lcd.printCelsius(-1111.1); // saturates at -999
delay(DELAY_SINK);
lcd.clear();
lcd.printCelsius(-0.1);
delay(DELAY_SINK);
lcd.clear();
lcd.printCelsius(-12.57);
delay(DELAY_SINK);
}
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ backlight KEYWORD2
noBacklight KEYWORD2
setBatteryLevel KEYWORD2
print KEYWORD2
printCelsius KEYWORD2
display KEYWORD2
noDisplay KEYWORD2

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=HT1621
version=2.0.3
version=2.1.0
author=valerio\new (5N44P), anxzhu
maintainer=valerio\new (5N44P)
sentence=A library for HT1621 based 7-seg LCDs.
Expand Down
Loading

0 comments on commit 8922dc3

Please sign in to comment.