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

Custom Characters (useChar) not working #1478

Closed
camer0 opened this issue Jun 17, 2018 · 5 comments
Closed

Custom Characters (useChar) not working #1478

camer0 opened this issue Jun 17, 2018 · 5 comments

Comments

@camer0
Copy link

camer0 commented Jun 17, 2018

I am running practically the example code:

var five = require("johnny-five");
var board = new five.Board();
board.on("ready", function() {
    let lcd = new five.LCD({ pins: [2, 3, 4, 5, 6, 7]});
    lcd.useChar("heart")
    lcd.print("test :heart: test");
})

And nothing is printed to the screen. I have tried reinstalling johnny-five, but this does not fix the issue. Regular characters print just fine to the LCD, it is only custom ones that fail. I tested my LCD out in the Arduino IDE with a custom character and it drew it just fine, but for some reason no character will work in johnny-five. Is this a known issue or have I completely done something wrong?

Edit: Actually, if I use useChar, it will not print ANYTHING to the LCD afterwards.

@camer0
Copy link
Author

camer0 commented Jun 17, 2018

I've narrowed it down to the createChar function, specifically the

this.command(this.REGISTER.SETCGRAMADDR | (address << 3));

line in the lcd.js file.

If I remove this line, it doesn't print the character, but I can write other characters to the screen, whereas with that line I cannot write anything to the screen until I reset and remove the useChar() function.

Again, custom characters works fine for me in the regular arduino IDE, but something goes amiss for me in johnny-five. Does anyone have any idea as to why this might be happening? Any help is appreciated!

@rwaldron
Copy link
Owner

Sorry for the delay in responding here. I'm not sure why this would stop working—no code has changed in LCD.

@fivdi is something of an expert with LCD, perhaps he can help us figure this out.

@fivdi
Copy link
Contributor

fivdi commented Jul 13, 2018

After invoking useChar the cursor needs to be positioned by invoking cursor. The following should work:

var five = require("johnny-five");
var board = new five.Board();
board.on("ready", function() {
    let lcd = new five.LCD({ pins: [2, 3, 4, 5, 6, 7]});
    lcd.useChar("heart")
    lcd.cursor(0, 0); // <=== Add this to get it to work
    lcd.print("test :heart: test");
})

Further details: Invoking useChar sets the address counter on the LCD to the CGRAM address. From this point onwards all data writes are to CGRAM. Invoking cursor sets the address counter on the LCD to the DDRAM address. From this point onwards all data write are to DDRAM.

To display characters on the LCD the characters need to be written to the DDRAM.

@camer0
Copy link
Author

camer0 commented Jul 14, 2018

I cannot believe the problem was that simple. Thank you so much, this seems to work!

@dtex
Copy link
Collaborator

dtex commented Jul 15, 2018

Thanks @fivdi !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants