Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed DRV88255 TextLCD Ping mbed-rtos
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 }
Generated on Tue Jul 12 2022 18:59:29 by
1.7.2