Skip to content

Commit

Permalink
Fixes #18
Browse files Browse the repository at this point in the history
  • Loading branch information
valerionew authored Aug 22, 2022
1 parent 1268f0b commit 0dd6f00
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 2 additions & 0 deletions examples/KitchenSink/KitchenSink.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#define LCD_DATA_PIN 8
#define DELAY_SINK 1000

// #define _HTDEBUG

HT1621 lcd;
void setup() {
lcd.begin(LCD_CS_PIN, LCD_WR_PIN, LCD_DATA_PIN);
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.1.1
version=2.1.2
author=valerio\new (5N44P), anxzhu
maintainer=valerio\new (5N44P)
sentence=A library for HT1621 based 7-seg LCDs.
Expand Down
18 changes: 12 additions & 6 deletions src/HT1621.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,28 @@ void HT1621::print(long num, const char* flags, int precision){

char localbuffer[7]; //buffer to work within the function
snprintf(localbuffer, 7, flags, num); // convert the decimal into string
Serial.begin(9600);
Serial.print(localbuffer);
Serial.print("\t");
#ifdef _HTDEBUG
Serial.begin(9600);
Serial.print(localbuffer);
Serial.print("\t");
#endif

// horrible handling but should get us working. needs refactor in next major
if (precision > 0 && (num) < pow(10, precision)) {
// we remove extra leading zeros
for (int i = 0; i < (5 - precision); i++) {
Serial.print(localbuffer[1]);
#ifdef _HTDEBUG
Serial.print(localbuffer[1]);
#endif // _HTDEBUG
if(localbuffer[i+1] == '0' && localbuffer[i] != '-'){ // we remove only if there is another zero ahead AND if it's not a minus sign
localbuffer[i] = ' ';
}
else{
break;
}
Serial.println();
}
#ifdef _HTDEBUG
Serial.println();buffer[1]);
#endif // _HTDEBUG
}
}

Expand Down

0 comments on commit 0dd6f00

Please sign in to comment.