Send counter output to LCD
gregfox
Posts: 68
in Propeller 1
Hello, I have the following code, I didn’t include the forward declarations, or the functions as they are not in question. I’m trying to send a counter (every 1 sec) to a LCD.
The code I wrote will send “this is line 2” to the LCD. I can’t think up a way to send the counter to the LCD. I’m working in C code. Any thoughts?
The code I wrote will send “this is line 2” to the LCD. I can’t think up a way to send the counter to the LCD. I’m working in C code. Any thoughts?
for(int c = 0; c <=10000; c++); //This is any counter { Pause(1); } //end counter /* I want to send the output of the counter (or any A/D output) to the LCD*/ line2(); //Sends to LCD line 2 char a[25] = " this is line 2 "; // Initialize the array for(int i = 0; i < 20; i++) // Count i from 0 to 20 { pause(2); //wait 2mS data(); //tell LCD data follows set_outputs (0,7, (a[i])); //Send (output) LINE 2 to data bus pins 0-7 (8bit) pause(TW); //wait about 1 mS strobe(); //latch data }
Comments
as
Also, this looks suspiciously similar to the HD44780 protocol. Have you seen PropWare's HD44780 class?
If you have enough code space, you can even use printf with that object:
I was aware of the compiler working dynamically but I put in [25] for testing and should not included it in this example.
So... what does PropWare::HD44780 lcd; do? I'm not acquainted with ' :: '
If I down load HD44780.h should I not #include "HD44780.h " in the program?
If I do would the statements you supplied above work to send dynamic data (like from a A/D) to the LCD?
Thank you.
The "::" is used to separate a "namespace" from a class within that namespace. A "namespace" can simply be thought of as a group of objects. For instance, I wrote a group of objects called PropWare. SRLM wrote a group of objects called libpropeller. Because we both wrote objects for the exact same microcontroller, there is a very high probability that we wrote objects with exactly the same name (for instance, we both have "I2C" objects. A namespace allows you to uniquely identify both versions of the object - PropWare::I2C and libpropeller::I2C.
If you know you're only using PropWare, and not libpropeller, then you can save yourself some typing by adding an extra line at the top of your file to say "just assume that I want PropWare objects"
Notice the "using namespace PropWare;" at the top. That means you no longer have to type "PropWare::" in front of PropWare objects.
In previous posts here on the forums, I might have recommended downloading specific files from PropWare's GitHub page and then copying them into your project. As of last night, there is now an easier way to use PropWare in SimpleIDE. Check out the first section of the download page: http://david.zemon.name/PropWare/Download.xhtml