Hi Jim
This is the code I am currently using to display the information on my LCD. Basically there is a loop running in the background to update the display. Each time the loop runs, the first thing it does is update the wind speed. Next there are four switch cases; these are case statements which run when called and the easiest way of doing this is to work with numbers as we can increment the numbers after each run.
Within each case statement, it will print the temperature and other weather veritable. I have four case statements: One for pressure, second for rain, third for Solar Radiation and fourth is the UV index. within each of these cases I will add a temperature/humidity reading. For the even numbers I display the inside temperature/humidity and for the odd numbers I display the outside information.
This is an example of a case statement:
Code:
case 1:
{
lcd.setCursor(0,3); //Set text to line 3 and display pressure information
lcd.print(F("Press:"));
lcd.print(SeaLevel_ATM, 2);
lcd.print(F(" mB"));
lcd.setCursor(0,1); // set text to line 1 and display temperature information
lcd.print(F("T"));
lcd.write(B11011111); // Degree Symbol
lcd.print(F("IN : "));
if (Output_T_Int >= 100) lcd.setCursor(6,1);
else if (Output_T_Int < 0) lcd.setCursor(6,1);
else lcd.setCursor(7,1);
lcd.print(Output_T_Int / 10.0, 1);
lcd.write(B11011111); // Degree Symbol
lcd.print(F("C"));
lcd.setCursor(14,1);
lcd.print(Output_H_Int / 10.0, 1);
lcd.print(F("%H"));
L_info = 2; // Change case number from 1, to 2 so that the next case will run
break; // Get out of this case and carry on with the routine
}
Writing and re-writing information to the LCD screen and processing all that extra information is SLOW and I do not necessarily recommend it because this is a modification not proved to be stable for any system.
There are probably a number of other ways this could be better executed, but it is what has worked for me. I know
Werk_AG and others probably won't approve of making the LCD code so heavy.
You will notice in my full code that there is also a check to see if it is night or day based upon the solar radiation readings. This will turn off/not display the solar and UV information during the night, instead looping between pressure and rain only. This is a feature of the original code and is very useful.
This is the code I am currently running:
Code:
#if DisplayType == 0
void write_LCD()
{
if (FirstRunInit != 0xAC)
{
lcd.setCursor(4, 2);
lcd.print(F("Initializing"));
lcd.setCursor(2, 3);
lcd.print(F("Auto-Reboot soon!"));
lcd.setCursor(17, 1);
lcd.print (bitRead(MainSensorsRX, 0));
lcd.print (bitRead(MainSensorsRX, 1));
lcd.print (bitRead(MainSensorsRX, 2));
return;
}
else if (StartUp == true)
{
lcd.setCursor(7, 1);
lcd.print(F("Wait!"));
lcd.setCursor(0, 2);
lcd.print(F("Don't start weather"));
lcd.setCursor(3, 3);
lcd.print(F("software yet! "));
lcd.print (bitRead(MainSensorsRX, 0));
lcd.print (bitRead(MainSensorsRX, 1));
lcd.print (bitRead(MainSensorsRX, 2));
return;
}
lcd.setCursor(0,3);
lcd.print(F(" "));
lcd.setCursor(0,2);
lcd.print(F(" "));
lcd.setCursor(0,2);
lcd.print(F("Wind :"));
if (Output_WGust >0.72 )
{
if (Output_WGust <= 9.99){lcd.print(Output_WGust, 2); }
else{lcd.print(Output_WGust, 1);}
#if Wind_Display_Unit == 0
lcd.print(F(" km/h "));
#endif
#if Wind_Display_Unit == 2
lcd.print(F(" m/s "));
#endif
#if Wind_Display_Unit == 3
lcd.print(F(" Kts "));
#endif
lcd.print(vaneDirectionsText[(Unit[WIND_OutUnit].Wind_dir % 3600) / 225]);
}
else {lcd.print(F("Calm "));
lcd.print(vaneDirectionsText[(Unit[WIND_OutUnit].Wind_dir % 3600) / 225]);}
switch (L_info)
{
case 1:
{
lcd.setCursor(0,3);
lcd.print(F("Press:"));
lcd.print(SeaLevel_ATM, 2);
lcd.print(F(" mB"));
lcd.setCursor(0,1);
lcd.print(F("T"));
lcd.write(B11011111); // Degree Symbol
lcd.print(F("IN : "));
if (Output_T_Int >= 100) lcd.setCursor(6,1);
else if (Output_T_Int < 0) lcd.setCursor(6,1);
else lcd.setCursor(7,1);
lcd.print(Output_T_Int / 10.0, 1);
lcd.write(B11011111); // Degree Symbol
lcd.print(F("C"));
lcd.setCursor(14,1);
lcd.print(Output_H_Int / 10.0, 1);
lcd.print(F("%H"));
L_info = 2;
break;
}
case 2:
{
lcd.setCursor(0,3);
if (Output_RToday != 0 )
{
lcd.print(F("Rain :"));
lcd.print(Output_RToday, 2);
lcd.print(F(" mm"));
}
else
{
lcd.print(F("Rain :"));
lcd.print(DaysWithoutRain);
lcd.print(F(" Dry Day(s)"));
}
lcd.setCursor(0,1);
lcd.print(F("T"));
lcd.write(B11011111); // Degree Symbol
lcd.print(F("OUT: "));
if (Output_T_Out >= 100) lcd.setCursor(6,1);
else if (Output_T_Out < 0) lcd.setCursor(6,1);
else lcd.setCursor(7,1);
lcd.print(Output_T_Out / 10.0, 1);
lcd.write(B11011111); // Degree Symbol
lcd.print(F("C"));
lcd.setCursor(14,1);
lcd.print(Output_H_Out / 10.0, 1);
lcd.print(F("%H"));
if (SRUV_OutUnit != 9 && Solar_Sensor == 1 && Output_SRad != 0) L_info = 3;
else L_info = 1;
break;
}
#if SRUV_OutUnit != 9
case 3:
{
lcd.setCursor(0,3);
lcd.print(F("Solar:"));
lcd.print(Output_SRad);
lcd.print(F(" W/m^2"));
lcd.setCursor(0,1);
lcd.print(F("T"));
lcd.write(B11011111); // Degree Symbol
lcd.print(F("IN : "));
if (Output_T_Int >= 100) lcd.setCursor(6,1);
else if (Output_T_Int < 0) lcd.setCursor(6,1);
else lcd.setCursor(7,1);
lcd.print(Output_T_Int / 10.0, 1);
lcd.write(B11011111); // Degree Symbol
lcd.print(F("C"));
lcd.setCursor(14,1);
lcd.print(Output_H_Int / 10.0, 1);
lcd.print(F("%H"));
L_info = 4;
break;
}
case 4:
{
lcd.setCursor(0,3);
lcd.print(F("UVI :"));
lcd.print(Output_UV / 1000.0, 1);
lcd.print(F(" UVI"));
lcd.setCursor(0,1);
lcd.print(F("T"));
lcd.write(B11011111); // Degree Symbol
lcd.print(F("OUT: "));
if (Output_T_Out >= 100) lcd.setCursor(6,1);
else if (Output_T_Out < 0) lcd.setCursor(6,1);
else lcd.setCursor(7,1);
lcd.print(Output_T_Out / 10.0, 1);
lcd.write(B11011111); // Degree Symbol
lcd.print(F("C"));
lcd.setCursor(14,1);
lcd.print(Output_H_Out / 10.0, 1);
lcd.print(F("%H"));
L_info = 1;
break;
}
#endif
}
}
This is just an example of what can be done with a little bit of code tinkering to the original project which is why the WeatherDuino Pro2 system is fantastic; customise it to what you want.