2nd line of LCD flashing
Dave A
Posts: 31
in Propeller 1
I am having a problem with the 2nd line of info on my LCD display. It flashes, is there a way to correct this.
Anyone's help will be appreciated. See attached code
Dave
Code starts here.
const int ON = 254;
const int CLR = 1;
const int L2 = 192;
#include "simpletools.h"
#include <propeller.h>
#include "dht22.h"
int main()
{
while(1) // Loop repeats indefinitely
{
int to, ho, co;
co = dht22_read(2);
to = dht22_getTemp(FAHRENHEIT);
int ti, hi, ci;
ci = dht22_read(3);
ti = dht22_getTemp(FAHRENHEIT);
serial *lcd = serial_open(12, 12, 0, 9600); //Pin12 out,pin12 in,data bits 0,baud rate 9600
writeChar(lcd, ON);
writeChar(lcd, CLR);
dprint(lcd, "Out %.1f",to / 10.0); //Outside temp must have %d to display value
dprint(lcd, " In %.1f",ti / 10.0); //Inside temp must have %d to display value
int cycles = count(16,1000); // Wind speed Count for 1 second Pin16
dprint(lcd,"Speed %d", cycles); //display wind speed
dprint(lcd," Dir");
pause(250);
}
}
Anyone's help will be appreciated. See attached code
Dave
Code starts here.
const int ON = 254;
const int CLR = 1;
const int L2 = 192;
#include "simpletools.h"
#include <propeller.h>
#include "dht22.h"
int main()
{
while(1) // Loop repeats indefinitely
{
int to, ho, co;
co = dht22_read(2);
to = dht22_getTemp(FAHRENHEIT);
int ti, hi, ci;
ci = dht22_read(3);
ti = dht22_getTemp(FAHRENHEIT);
serial *lcd = serial_open(12, 12, 0, 9600); //Pin12 out,pin12 in,data bits 0,baud rate 9600
writeChar(lcd, ON);
writeChar(lcd, CLR);
dprint(lcd, "Out %.1f",to / 10.0); //Outside temp must have %d to display value
dprint(lcd, " In %.1f",ti / 10.0); //Inside temp must have %d to display value
int cycles = count(16,1000); // Wind speed Count for 1 second Pin16
dprint(lcd,"Speed %d", cycles); //display wind speed
dprint(lcd," Dir");
pause(250);
}
}
Comments
Your code should look more like this:
You don't want to be opening a serial connection each time through the loop. This can cause memory leaks and since the connection is open you don't need to open it again.
Define your variables outside the while loop so that the program doesn't have to recreate them each time through the loop. This causes thrashing. Define the storage and then use them.
Mike
To do wind speed I setup a counter in another cog and then use a timer to read the count every minute. When it reads the count it also zeros it so that it starts over. I then track 60 events to get one hour and then average those values to get the average wind speed for past hour.
You could also look at each minute value and determine the high value and that would be the gust value.
Mike