Go Down

Topic: liquid crystal library is rubbish (Read 916 times) previous topic - next topic

SparkyLabs

I am becoming very disappointed with Arduino as of late. I'm not an idiot, I code C on AVR. I use Arduino for quick and dirty jobs hat will never have more than one made of them. The whole point of using Arduino was the good documentation making it easy to hack something together without writing my own libraries because it's pointless trying to reverse engineer anyone elses undocumented library...

So the liquid crystal library. Firstly I see no clear distinction between write and print but never mind.

https://www.arduino.cc/en/Reference/LiquidCrystalPrint

States: data: the data to print (char, byte, int, long, or string)

Yet so far no variable type works producing a compile error. I take it that the only acceptable variable type is char and that my int number needs manually breaking down.....

J-M-L

#1
Nov 24, 2018, 07:54 pm Last Edit: Nov 24, 2018, 08:00 pm by J-M-L
write will send straight the byte value. Print will transform your argument in ASCII

so lcd.write('C'); is indeed the same as lcd.print('C'); or as lcd.print("C"); but lcd.write(67) and lcd.print(67); are very different. The write will output a 'C' because 67 is the ASCII code for 'C' (the associated char) whereas the print will output "67" on the screen, the ASCII representation of the number (the associated text)

That's what the doc states (if you read carefully and go check also what print and write in Stream do a put some good will into it :)) )

print()
Description --> Prints text to the LCD.

write()
Description --> Write a character to the LCD.


Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

DKWatson

It's difficult I know. I detest most (all?) of these third-party libraries as well. Still, without seeing any code and/or error message, then it's just a rant. I happen to use the LiquidCrystal library (one of very few) quite a bit and without any problems, compile or otherwise.
Live as if you were to die tomorrow. Learn as if you were to live forever. - Mahatma Gandhi

blh64

I am becoming very disappointed with Arduino as of late. I'm not an idiot, I code C on AVR. I use Arduino for quick and dirty jobs hat will never have more than one made of them. The whole point of using Arduino was the good documentation making it easy to hack something together without writing my own libraries because it's pointless trying to reverse engineer anyone elses undocumented library...

So the liquid crystal library. Firstly I see no clear distinction between write and print but never mind.
print formats a number intro a string so lcd.print(45) will produce "45"
write simply sends the data so lcd.print(45) will produce the ascii(45) which is '-'

Quote
https://www.arduino.cc/en/Reference/LiquidCrystalPrint

States: data: the data to print (char, byte, int, long, or string)

Yet so far no variable type works producing a compile error. I take it that the only acceptable variable type is char and that my int number needs manually breaking down.....
Nope, they all work just fine.  Why don't you post your code and people will be able to help you?

UKHeliBob

Quote
Yet so far no variable type works producing a compile error.
Post some examples and the associated error messages
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

SparkyLabs

lcd.write( lane1_time100, DEC );

race_end:34:35: error: no matching function for call to 'write(char&, int)'

Yep I got print and write mixed up seems to be working now but I stand by what I said the documentation is poor. Considering this is for kids and artists all i can say is good luck

DKWatson

Most of it's volunteer work. You could make it much better.
Live as if you were to die tomorrow. Learn as if you were to live forever. - Mahatma Gandhi

J-M-L

lcd.write( lane1_time100, DEC );

race_end:34:35: error: no matching function for call to 'write(char&, int)'

Yep I got print and write mixed up seems to be working now but I stand by what I said the documentation is poor. Considering this is for kids and artists all i can say is good luck
indeed you were calling an investing write() function (this prototype does not exist);

Kids and artist should stick with print :)
Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

SparkyLabs

I'd have to reverse engineer it to understand it remember. Only those that wrote it know how it works. Seem's everyone else know's how it works so why are the examples and explanations not more extensive?

I don't know who writes the instructions but they do make and sell the boards that i buy so it's not like it is free. i paid £35 for a PCB that is massed produced.

J-M-L

#9
Nov 24, 2018, 08:21 pm Last Edit: Nov 24, 2018, 08:22 pm by J-M-L
I'd have to reverse engineer it to understand it remember. Only those that wrote it know how it works. Seem's everyone else know's how it works so why are the examples and explanations not more extensive?
usually one comes to print and write form the Serial class, so the context is already understood. Again if you don't need to mess around with sending bytes value, stick to print and life will be glorious and beautiful.

(agree that if you read the doc it's not great)
Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

gfvalvo

I'd have to reverse engineer it to understand it remember.
Well, it wouldn't require THAT much reverse engineering. If you'd bother to spend two minutes looking at the library's source code, you'd see that the LiquidCrystal class inherits from the Print class -- as does HardwareSerial, SoftwareSerial, etc. So the basic interface should already be familiar to you.

The source code is always the definitive documentation.

spycatcher2k

Quote
Considering this is for kids and artists all i can say is good luck
Where did you get this crap from? I'm neither a Kid, nor an artist! I'm a systems solution engineer, designing both hardware and software for some rather large companies, and often include hardware developed & prototyped on the Arduino platform. While the reference material may be lacking a little in places, GOOGLE is a great resource for any developer, asking here for help is also a great resource!

Like all pursuits, experience is the best teacher, make mistakes, find the fix, don't make the same mistake again.
Mrs Drew
-=-
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.

SparkyLabs

I never called you a kid or artist. I was referring to the official blurbs.

I really don't get the "google it".  It's a poor excuse for poor documentation.

Whandall

I think the Print interface is document quite well, even the source code is included.
Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)

SparkyLabs

So the hypothetical child or artist needs to be fluent in "C"? OK fair enough.

Go Up