Hi, I have a working library for HT1621.
Here is the code that is counting correctly and efficiently some numbers.
This is actually one of the example codes that comes with this library.
/*
This program is made to drive a HT1621B LCD Driver IC
HT1621B only multiplexed LCD Driver 1/2 or 1/3 bias, and 1/2 or 1/3 or 1/4 duty SSOP48 [smd]
*/
#include <HT1621.h> // include our library
HT1621 lcd; // create an "lcd" object
void setup()
{
Serial.begin(9600);
// cs to pin 5
// wr to pin 3
// Data to pin 2
lcd.begin(5, 3, 2); // (cs, wr, Data)
lcd.clear(); // clear the screen
}
void loop()
{
lcd.print(millis()/100000.0); // print the floating point seconds value with 3 decimal digits precision
delay(1); // wait 1 millisecond
}
All I want is to be able to drive individual digits AND individual segments.
Is it possible with this library? Or do you recommend another library than this?
Here is all this class/header internal functions:
class HT1621
{
public:
HT1621();
void begin(int cs_p, int wr_p, int data_p, int backlight_p);
void begin(int cs_p, int wr_p, int data_p);
void clear();
void backlight();
void noBacklight();
void setBatteryLevel(int level);
void print(long num, const char* flags="%6li", int precision = 0);
void print(double num, int precision = 3);
void printCelsius(double num); // precision is always 1
void print(const char* str, bool leftPadded = false);
void display();
void noDisplay();
Here are the 2 main files of this HT1621 driver: HT1621.cpp (10.0 KB) HT1621.h (3.6 KB)
I created a new function in the header
and its reference function in the cpp file
is an empty function and I only tested if is giving any errors in the main arduino program. And so far so good, no errors. Next, is to actually add some code in it.
...
I find this char HT1621::charToSegBits(char character) function inside cpp file and I made it public (it was private) and I can access it from my main code.
-But, Im getting some errors if Im using it like this: charToSegBits('|'); LCDA2:20:3: error: 'charToSegBits' was not declared in this scope
-Then I look more closely how is used in the cpp file and is always used like this: _buffer[i] |= charToSegBits(character); in only 2 print() functions. This means... it is OR-ed and compared to an array? I don't understand it.
I discovered this function void HT1621::print(const char* str, bool leftPadded)
And, I figure out how to write to it!
you write like this: lcd.print('-',false);
but is one problem... it is converting into ASCII Decimal
for ex:
if Im writing lcd.print('-',false); I get 45 displayed on my LCD
if Im writing lcd.print('a',false); I get 97 displayed on my LCD
if Im writing lcd.print('|',false); I get 124 displayed on my LCD
So, I quickly looked into an ASCII table and it is exactly this conversion.
Hmmm...
The IDEAL next step is to --somehow-- send this kind of line: // address segment lcd.print(0b0000,0b0001); to get [a] segment lit up at addres0
I downloaded your library and insert it into C:\Users\XXX\Documents\Arduino\libraries\HT1621Formenti
where I made a new HT1621Formenti folder and dump your 3 files inside it.
From Arduino IDE I go to Sketch-Include Library - and I could find it there, and loaded it as: #include <HT1621.h> exactly as the other one I had before. A bit confusing now, having 2 libraries with the exact names but totally different content in them. Im making use of comments to distinguish this is a new one.
-I really need a program example !
So far, I look inside it, and from what I can tell, it is doing it from the address and segment level. I hope.
-Please help me with an example for this new class.
This is very close to what I need, if indeed I can command specific address and segments !!!
Thank you !
I have no idea how to initialize and run the functions from your library !
Also Arduino IDE recognized 2 HT1621.h in its installation folder so I had to modify this last class name.
No. The function you discovered is expecting a 'C-string' which is a null-terminated array of char. You gave it a single char.
So the function you discovered will not be used. Instead, the other function you used before is being used again:
The single char you gave as the parameter is getting converted to its ASCII code and that code is getting printed.
Try this:
lcd.print("-",false);
Using the double-quote symbol instead of the single-quote symbol makes it a C-string instead of a single character. Now, the function you discovered will be used.
I try it and nothing appears on the LCD.
At least with my approach it is showing something.
Or, this is a very special or dedicated function for a very special LCD that I dont have.
this is a subject related to "string manipulation" which is one of the basics of C languages, and which I am very good at in C# at least - not so much here in C++ arduino because it involves (probably) pointers and more low level than c#. I do know about these differences, but here in this case, I didn't perfectly understood what that function really do inside it. So I play with it until I got a result. Thanks for your input.