Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5

"Palmy Weather" Goes live with WeatherDuino Pro2
#25

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.
Reply


Messages In This Thread
"Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 02-12-2015, 08:18
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by uncle_bob - 02-12-2015, 22:39
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by werk_ag - 03-12-2015, 04:39
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by GreggWardNZ - 08-12-2015, 19:51
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 09-12-2015, 08:51
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Barrow4491 - 18-09-2016, 07:41
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by werk_ag - 10-12-2015, 00:38
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 27-12-2015, 07:51
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by werk_ag - 27-12-2015, 08:06
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by hornychz - 30-12-2015, 22:54
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by dalehardy - 01-01-2016, 04:52
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 26-03-2016, 08:38
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by werk_ag - 24-04-2016, 08:18
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 16-07-2016, 09:24
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by zitoune - 18-08-2016, 10:12
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by AllanG - 16-07-2016, 10:45
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by johnmw1 - 18-07-2016, 16:41
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 19-07-2016, 08:47
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by johnmw1 - 20-07-2016, 08:06
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by uncle_bob - 20-07-2016, 10:58
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by johnmw1 - 20-07-2016, 12:47
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 11-09-2016, 09:22
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by zitoune - 11-09-2016, 14:26
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 11-09-2016, 20:45
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 18-09-2016, 09:16
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Barrow4491 - 19-09-2016, 01:18
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Barrow4491 - 11-10-2016, 09:30
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by zitoune - 18-09-2016, 12:35
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by zitoune - 21-09-2016, 16:09
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 12-10-2016, 07:21
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Barrow4491 - 12-10-2016, 09:20
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 12-10-2016, 10:10
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 16-10-2016, 08:29
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Barrow4491 - 16-10-2016, 11:49
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Barrow4491 - 01-12-2016, 13:17
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 29-05-2017, 09:50
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by werk_ag - 02-06-2017, 04:43
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 02-06-2017, 07:36
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by zitoune - 29-05-2017, 13:23
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by hornychz - 29-05-2017, 14:30
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by danner - 29-05-2017, 23:51
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by Palmyweather - 30-05-2017, 20:46
RE: "Palmy Weather" Goes live with WeatherDuino Pro2 - by danner - 30-05-2017, 22:26



Users browsing this thread: 1 Guest(s)