Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createChar does not work after calling setCursor #6

Open
agdl opened this issue Jun 30, 2016 · 10 comments · May be fixed by #32
Open

createChar does not work after calling setCursor #6

agdl opened this issue Jun 30, 2016 · 10 comments · May be fixed by #32
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@agdl
Copy link
Member

agdl commented Jun 30, 2016

Moved from arduino/Arduino#4809 by @tablatronix

createChar does not work after calling setCursor

at least for me, was driving me nuts until I made sure to always do it before moving the cursor.

  // would not print my character
  lcd.setCursor(numCols-1, 0);
  lcd.createChar(1,custombyte);
  lcd.write((char)1);
@TacoOblivion
Copy link

I just spent 4+ hours pulling my hair out only to find out that it's most definitely a library issue. Doesn't look like the library is maintained anymore either. I would try Cosa: https://github.com/mikaelpatel/Cosa/tree/master/libraries/HD44780 but I'm already too deep into this project to bother switching out the library right now.

Reading the datasheets for the HD44780, I noticed what appeared to be improper implementation of what the datasheets said, inside this library. That's the only warning I'll give anyone using this.

@PaulStoffregen
Copy link

what appeared to be improper implementation of what the datasheets said, inside this library.

Not even a hint of what you believe is incorrect or where (like line numbers) within the library?

@TacoOblivion
Copy link

I'm not an electronics engineer so I'm not sure if I was reading the datasheets correctly, but for instance the datasheets would say to read off if the screen was in a busy state before certain operations, and no such check was done from the looks of it. In the case of this, CGRAM and DDRAM share certain state functionality and because of that, doing setCursor() first followed by createChar() fails because the busy state was most likely on. Once again, not sure. You can take a read through the datasheets yourself to verify whether or not I was correct or wrong.

@PaulStoffregen
Copy link

PaulStoffregen commented Jan 15, 2018

You can take a read through the datasheets yourself

Are you aware many slightly different datasheets exist for these displays and their controller chips? Without a link to the specific one you're reading, I can't actually read through it myself. (are you seeing a pattern here... the need for details in your messages?)

But I can tell you the datasheets I've seen allow for busy polling or simply a wait time. I and others have made variants of this library which do the busy polling, which does allow for faster updates with some displays. However, simply waiting the maximum busy time is an acceptable approach.

@TacoOblivion
Copy link

TacoOblivion commented Jan 15, 2018

I was not aware. I was reading the one from SparkFun: https://www.sparkfun.com/datasheets/LCD/HD44780.pdf

Also, I attempted delays between operations and that didn't seem to help.

Also this is what would happen...

setCursor(0, 1);
createChar(0, blah); // might load character (who knows)
write(0); // never writes
print("Anything"); // never writes

I also had this happen...

print("Anything");
createChar(0, blah1);
createChar(1, blah2);
write(0); // renders blah1
write(1); // doesn't render blah2

If the order of commands fired off to the screen gives any hints, that's the best I can give. Frankly I got it to work by reordering and so I'm sticking to that instead of screwing around trying to understand the HD44780 in depth.

@PaulStoffregen
Copy link

PaulStoffregen commented Jan 15, 2018

Would you like me (or perhaps anyone else) to try to reproduce this problem?

Imagine if you were reading these messages and you wanted to find and fix the problem. First, you'd have to turn these code fragments into a complete program. Then you'd need to choose a board. This library offers 4 different constructors, so you'd need to guess which of those were used, or perhaps try them all. You'd also need to guess which specific LCD you're using, or maybe buy a collection of them from many vendors and how to get the same or similar enough model.

I'm glad you got things to work for your project. But if you're going to report the problem here, please try to be specific. Details matter. If someone is going to try to investigate and fix a problem, they need all the details of exactly how to recreate the problem.

@TacoOblivion
Copy link

If you'd like to attempt to reproduce, go ahead. My posting has a direct relationship to this project: https://github.com/Goodlookinguy/FishLight2

The constructor(rs, enable, d0, d1, d2, d3) was used as per the information I was given by my friend who designed what I'm working on.

@PaulStoffregen
Copy link

No, this just isn't reasonable. I'm not going to spend the time to pull out just the LCD code from your project, only to try reproducing a problem which may or may not actually be an issue within this library, not to mention doing actual testing without knowing exactly which display you used. Realistically, I do not imagine anyone will spend the time to do this.

Maybe these messages can make you feel better, perhaps relieve some of the frustration you suffered trying to get your specific display to work, but they're not at all constructive for reporting an issue with this library.

@TacoOblivion
Copy link

TacoOblivion commented Jan 15, 2018

I actually left my message here to suggest trying a different library first if you have problems with this one early on. Cosa seems maintained and this one doesn't. That's what my original message's goal was as well as to illuminate possible issues this library has.

Here's a simplified test I just tried that fails. 👍

#include "LiquidCrystal.h"

// control panel
#define PIN_CP_RS A0
#define PIN_CP_ENABLE A1
#define PIN_CP_D0 A2
#define PIN_CP_D1 A3
#define PIN_CP_D2 A4
#define PIN_CP_D3 A5

uint8_t clock[] =
{
  0b00000,
  0b01110,
  0b10101,
  0b10101,
  0b11001,
  0b01110,
  0b00000,
  0b00000
};

uint8_t screen[] =
{
  0b00000,
  0b00000,
  0b11111,
  0b10001,
  0b10011,
  0b11111,
  0b00000,
  0b00000
};

LiquidCrystal* lcd;

void setup()
{
  lcd= new LiquidCrystal(
    PIN_CP_RS, PIN_CP_ENABLE,
    PIN_CP_D0, PIN_CP_D1, PIN_CP_D2, PIN_CP_D3);
  lcd->begin(16, 2);
  delay(1000);

  lcd->print("Hello World");
  lcd->setCursor(0, 1);
  lcd->createChar(0, clock);
  lcd->createChar(1, screen);
  lcd->write((uint8_t)0);
  lcd->print(" ");
  lcd->write((uint8_t)1);
  lcd->print(" Testing...");
}

void loop() {}

@bgxlin
Copy link

bgxlin commented Aug 4, 2019

If GoodLookingGuy insert lcd->clear() after lcd->createChar(1, screen) it will run successfully. clear() sets LCD IC to use DDRAM, while createChar() leaves LCD IC in CGRAM mode.

@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Aug 4, 2019
@zaidMughal zaidMughal linked a pull request Mar 20, 2020 that will close this issue
@per1234 per1234 changed the title create char after setCursor createChar does not work after calling setCursor Apr 18, 2022
@per1234 per1234 added the topic: code Related to content of the project itself label Apr 18, 2022
@per1234 per1234 linked a pull request Apr 18, 2022 that will close this issue
jaltekruse added a commit to jaltekruse/electronics_projects that referenced this issue May 8, 2023
- I had tried plugging into an alternative power source
  to make the LCD refresh faster, someone was talking about
  having less than the ideal voltage would slow it down
- that didn't fix the problem, but it apparently also broke
  driving the screen to some degree, moving the 5V and GCD
  back the the main driver board this code is working fine
  as well as the last commit

- don't need these links anymore, but the first one has a
  little pixel doodle thing to design chars

- some links from trying to work it out
- https://maxpromer.github.io/LCD-Character-Creator/
- https://forum.arduino.cc/t/solved-custom-chars-not-being-printed-on-lcd/413082/9
- https://forums.adafruit.com/viewtopic.php?f=31&t=25972
- arduino-libraries/LiquidCrystal#6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants