-
Notifications
You must be signed in to change notification settings - Fork 16
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
displaying more then 5 characters #4
Comments
The print method is asynchronous (as mentioned in the documentation :)) so it may return before it has printed everything. In the case of lcd.print("111112222233333444445") is does return before everything is printed. After everything has been printed a 'printed' event is emitted. The reasoning behind this is that it takes about 10 milliseconds to fill a 20x4 display with 80 characters on the BeagleBone Black (~20 milliseconds on the Pi.) Printing the 80 characters synchronously would prevent the event loop from doing anything else for 10 or 20 milliseconds which is quite a long time. print therefore prints 5 characters, allows the event loop to do other work, if required, and then prints the next 5 characters. So, because print is asynchronous, the output from the calls to print in the above code will be interlaced and things probably look very messed up. Handling the 'printed' event isn't the easiest either. Perhaps the print method should return a promise which would make things easier to handle. Alternatively, a printSync method could be added for people who don't mind the event loop being blocked for 10 or 20 milliseconds. Add the following to your example code from above and call printSync instead of print to see if it works. Lcd.prototype.printSync = function(val) {
var i;
val += '';
this.rs.writeSync(1);
for (i = 0; i != val.length; ++i) {
this.write(val.charCodeAt(i));
}
}; |
This works as well good for me. I guess I have a few difficulties to use the printed-event. Thanks |
Great, thanks for the feedback. I'll add printSync to lcd in the not too distant future and reopen this issue as a reminder. |
I decided not to add printSync to lcd as it's synchronous and can take too long to execute (approx. 10 or 20 milliseconds to print 80 characters on the BeagleBone or Pi respectively). The example print-twice-20x4.js shows how to handle the 'printed' event. It's not as difficult as claimed in the post above :) |
I have a display that has 20 columns and 2 rows.
If I run the following script it turns out that the first row is divided after the 5th character.
what I found out, that the lcd.js is in line 83 limited to 5 characters.
if I change this to
it lets me use all 20 characters on the lcd. If i would like to print 21, it puts the 21st somewhere in the 2 row. Haven't looked for a fix yet.
The text was updated successfully, but these errors were encountered: