lcd.cursor and lcd.noCursor won't work for what I want to use it for since it seemed to be "global" sort of speak and follow lcd.setCursor which I don't want it to but it is otherwise exactly what I want to be done; just to put a line at the very bottom and also remove the line whenever I want to but without removing the entire char above.
Just like lcd.cursor do but as said it won't work in the code since the line has to reside where it is even if lcd.setCursor is used elsewhere but then the cursor line follow to that other point which I don't want and such a controllable cursor that sits at the place even if lcd.setCursor is used elsewhere. But the char there first and then the line of vice versa doesn't matter just as long as there it a line. And I cant create custom chars with a line under them since its numbers from 0 - 9 and so many custom chars can't be made.
It's fully possible to write to the bottom row though and I thought it would be possible to do something with lcd.createChar by not no write anything at all at the bytes rows but the lowest one, but that surprisingly failed. This is what I tested:
byte line[8] = {
B,
B,
B,
B,
B,
B,
B,
B11111,
};
And that writes on the lowest row as expected, but strangely enough STILL deletes any char that is written above even if nothing should have been written there as I see it.
The test here put out pretty much garbage and pretty much delete the char written but something still remain but the line is written at top instead of bottom and I guess it all goes out of the normal bounds in the registry or something:
#include <LiquidCrystal.h>
LiquidCrystal lcd(40, 42, 28, 26, 24, 22);
byte line[1] = {
B00000,
};
byte noline[1] = {
B11111,
};
byte sure[8] = { //It didn't like to use "square" as name by whatever the reason
B00000,
B00000,
B01110,
B01110,
B01110,
B01110,
B00000,
B00000,
};
void setup() {
lcd.createChar(0, line);
lcd.createChar(1, noline);
lcd.createChar(2, sure);
lcd.begin(20, 4);
lcd:clear:
}
void loop() {
delay(500);
lcd.setCursor(0, 0);
lcd.write(byte(2));
delay(500);
lcd.setCursor(0, 0);
lcd.write(byte(1));
delay(500);
lcd.setCursor(0, 0);
lcd.write(byte(0));
}
Any tips on how to do the same with create.Char or any other simple way? I mean the lcd.cursor and lcd.noCursor can do it, how do that do it then? It's an ordinary 20X4 LCD if that would matter.
-
1Often instead of using a cursor you would just blink the character that is currently the "selected" one.Majenko– Majenko2020年03月22日 10:41:53 +00:00Commented Mar 22, 2020 at 10:41
1 Answer 1
I do not really understand what you mean by your first sentence. Did you succeed in getting a "hardware" cursor to display together with a character or not? And if you do, why doesn't this fulfill your requirements?
You have to realize that your LCD cannot display partial characters, like a line at the bottom, leaving the rest of the character that was already there intact. An exception is a hardware generated cursor.
You also have to realize that createChar always expects a full character with 8 rows.
Your code examples
In your first example, starting with byte line[8] = {
, the first 7 "empty" B,
lines actually produce a value of (binary) zero. So here you create an empty character with a line at the bottom, exactly like you said you see on the display.
In your second piece of code, you define characters byte line[1] =
and byte noline[1] =
consisting of just 1 byte. createChar expects 8 bytes. createChar will fill the characters with the single byte defined in your character definition, plus whatever it finds in the 7 memory locations following your actual definition (which will probably contain some random data). This explains the "garbage" you see on the screen.
Possible solution
One solution would be to re-create each character you want your cursor to display under, on the fly. I.e. if you want your cursor to be displayed under the letter "A", you create a complete custom character which contains "A", plus a cursor underneath and you display it in place of the real "A" at this location. When you move the cursor, you replace the "custom" A with the real "A" again.
This will be cumbersome in code complexity as well as code size (you'd have to create a complete character map for every character you wish to display), but should be a feasible solution.