Saltware / Mbed 2 deprecated Water Play

Dependencies:   mbed DRV88255 TextLCD Ping mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LCDController.cpp Source File

LCDController.cpp

00001 #include "LCDController.h"
00002 #include "SensorAlarmController.h"
00003 
00004 static TextLCD lcd(p5, p6, p7, p8, p9, p10, TextLCD::LCD16x2);
00005 
00006 
00007 LCDController::LCDController() {
00008     printf("Initiate LCD Controller\n\r");
00009     lcd.cls();
00010 }
00011 
00012 
00013 void LCDController::splash() {
00014     lcd.cls();
00015     lcd.printf("Welcome to\nSaltware");
00016     wait(0.5);   
00017 }    
00018 
00019 void LCDController::updateScreen(float temp_value, float salt_value, PIDController *pidc) {
00020      lcd.cls();
00021      
00022      char temp_buffer[16];
00023      char salt_buffer[16];
00024      
00025      if (temp_value > 100) {
00026          // Show Not Connected
00027          sprintf(temp_buffer, "T: NC");
00028          SensorAlarmController::buzzOnce();
00029      } else {
00030          sprintf(temp_buffer, "T: %.1fC", temp_value);
00031      }
00032      
00033      if (pidc->isHeating()) {
00034           // Indicate heating with an "*" near the temperature
00035           sprintf(temp_buffer, "%s *", temp_buffer);   
00036      }
00037      
00038      if(salt_value < MIN_VALID_SALINITY) {
00039         // Show not connected
00040         sprintf(salt_buffer, "S: NC");
00041         SensorAlarmController::buzzOnce();
00042      } else {
00043         sprintf(salt_buffer, "S: %.3fPPT", salt_value);
00044      }
00045      
00046      // Indicate pumping with an "*" near the salinity
00047      if (pidc->isPumping()) {
00048          sprintf(salt_buffer, "%s *", salt_buffer);
00049      }   
00050 
00051      lcd.printf("%s\n%s", temp_buffer, salt_buffer);  
00052 }
00053 
00054 void LCDController::showPumping() {
00055     lcd.cls();
00056     lcd.printf("Now pumping...");
00057 }
00058 
00059 void LCDController::updateScreen(float volume) {
00060     lcd.cls();
00061     
00062     if(-1.0f == volume)
00063         lcd.printf("Volume:\nNC");
00064     else if(volume > VOLUME_MAX_CRIT)
00065         lcd.printf("Volume:\nOverflow");
00066     else if(volume < VOLUME_MIN_CRIT)
00067         lcd.printf("Volume:\nUnderflow");
00068     else
00069         lcd.printf("Volume:\nOK");
00070 }
00071 
00072 void LCDController::showError(const char *msg) {
00073     lcd.cls();
00074     lcd.printf("ERROR:\n%s", msg);    
00075 }