Program for the water play project for the course Software Testing Practical 2016 given at the VU University

Dependencies:   mbed DRV88255 TextLCD Ping mbed-rtos

Committer:
sbouber1
Date:
Mon Jun 20 10:22:10 2016 +0000
Revision:
64:735009c4c8aa
Parent:
58:b5f0c0f305ff
Child:
65:b277b4067d4a
fixed alarm error msgs

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joran 6:067e999b9c6e 1 #include "LCDController.h"
sbouber1 64:735009c4c8aa 2 #include "SensorAlarmController.h"
joran 6:067e999b9c6e 3
sbouber1 57:8dc3192ff150 4 static TextLCD lcd(p5, p6, p7, p8, p9, p10, TextLCD::LCD16x2);
joran 6:067e999b9c6e 5
joran 6:067e999b9c6e 6
sbouber1 57:8dc3192ff150 7 LCDController::LCDController() {
joran 6:067e999b9c6e 8 printf("Initiate LCD Controller\n\r");
joran 6:067e999b9c6e 9 lcd.cls();
joran 41:dce2c29f49cd 10 }
joran 6:067e999b9c6e 11
joran 6:067e999b9c6e 12
sbouber1 57:8dc3192ff150 13 void LCDController::splash() {
joran 6:067e999b9c6e 14 lcd.cls();
joran 6:067e999b9c6e 15 lcd.printf("Welcome to\nSaltware");
joran 44:7c932cc5991b 16 wait(0.5);
joran 6:067e999b9c6e 17 }
joran 6:067e999b9c6e 18
sbouber1 57:8dc3192ff150 19 void LCDController::updateScreen(float temp_value, float salt_value, PIDController *pidc) {
joran 6:067e999b9c6e 20 lcd.cls();
joran 17:17ea1372f64a 21
sbouber1 57:8dc3192ff150 22 char temp_buffer[16];
sbouber1 57:8dc3192ff150 23 char salt_buffer[16];
joran 17:17ea1372f64a 24
sbouber1 57:8dc3192ff150 25 if (temp_value > 100) {
sbouber1 57:8dc3192ff150 26 // Show Not Connected
sbouber1 57:8dc3192ff150 27 sprintf(temp_buffer, "Temp: NC");
sbouber1 64:735009c4c8aa 28 SensorAlarmController::buzzOnce();
6366295 18:da84737ee427 29 } else {
sbouber1 57:8dc3192ff150 30 sprintf(temp_buffer, "Temp: %.1fC", temp_value);
6366295 18:da84737ee427 31 }
joran 17:17ea1372f64a 32
sbouber1 57:8dc3192ff150 33 if (pidc->isHeating()) {
sbouber1 57:8dc3192ff150 34 // Indicate heating with an "*" near the temperature
sbouber1 57:8dc3192ff150 35 sprintf(temp_buffer, "%s *", temp_buffer);
sbouber1 57:8dc3192ff150 36 }
joran 41:dce2c29f49cd 37
sbouber1 57:8dc3192ff150 38 sprintf(salt_buffer, "Salt: %.3fPPT", salt_value);
joran 41:dce2c29f49cd 39
sbouber1 57:8dc3192ff150 40 // Indicate pumping with an "*" near the salinity
sbouber1 57:8dc3192ff150 41 if (pidc->isPumping()) {
sbouber1 58:b5f0c0f305ff 42 sprintf(salt_buffer, "%s *", salt_buffer);
joran 41:dce2c29f49cd 43 }
joran 41:dce2c29f49cd 44
sbouber1 58:b5f0c0f305ff 45 lcd.printf("%s\n%s", temp_buffer, salt_buffer);
joran 6:067e999b9c6e 46 }
sbouber1 10:fd4670ec0806 47
joran 44:7c932cc5991b 48 void LCDController::showPumping() {
joran 44:7c932cc5991b 49 lcd.cls();
joran 44:7c932cc5991b 50 lcd.printf("Now pumping...");
joran 44:7c932cc5991b 51 }
joran 44:7c932cc5991b 52
sbouber1 10:fd4670ec0806 53 void LCDController::updateScreen(float distance) {
sbouber1 10:fd4670ec0806 54 lcd.cls();
joran 44:7c932cc5991b 55 lcd.printf("Volume:\n%.0fml", distance);
sbouber1 10:fd4670ec0806 56 }
sbouber1 10:fd4670ec0806 57
sbouber1 57:8dc3192ff150 58 void LCDController::showError(const char *msg) {
sbouber1 10:fd4670ec0806 59 lcd.cls();
sbouber1 10:fd4670ec0806 60 lcd.printf("ERROR:\n%s", msg);
sbouber1 10:fd4670ec0806 61 }