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:
Wed Jun 22 13:17:05 2016 +0000
Revision:
78:a44ad011dd41
Parent:
72:f8c4f731f0fe
turn off heater after halting the system

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 }
sbouber1 65:b277b4067d4a 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 78:a44ad011dd41 27 sprintf(temp_buffer, "T: NC");
sbouber1 64:735009c4c8aa 28 SensorAlarmController::buzzOnce();
6366295 18:da84737ee427 29 } else {
sbouber1 78:a44ad011dd41 30 sprintf(temp_buffer, "T: %.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 65:b277b4067d4a 38 if(salt_value < MIN_VALID_SALINITY) {
sbouber1 65:b277b4067d4a 39 // Show not connected
sbouber1 78:a44ad011dd41 40 sprintf(salt_buffer, "S: NC");
sbouber1 65:b277b4067d4a 41 SensorAlarmController::buzzOnce();
sbouber1 65:b277b4067d4a 42 } else {
sbouber1 78:a44ad011dd41 43 sprintf(salt_buffer, "S: %.3fPPT", salt_value);
sbouber1 65:b277b4067d4a 44 }
joran 41:dce2c29f49cd 45
sbouber1 57:8dc3192ff150 46 // Indicate pumping with an "*" near the salinity
sbouber1 57:8dc3192ff150 47 if (pidc->isPumping()) {
sbouber1 58:b5f0c0f305ff 48 sprintf(salt_buffer, "%s *", salt_buffer);
joran 41:dce2c29f49cd 49 }
joran 41:dce2c29f49cd 50
sbouber1 65:b277b4067d4a 51 lcd.printf("%s\n%s", temp_buffer, salt_buffer);
joran 6:067e999b9c6e 52 }
sbouber1 10:fd4670ec0806 53
joran 44:7c932cc5991b 54 void LCDController::showPumping() {
joran 44:7c932cc5991b 55 lcd.cls();
joran 44:7c932cc5991b 56 lcd.printf("Now pumping...");
joran 44:7c932cc5991b 57 }
joran 44:7c932cc5991b 58
sbouber1 68:b769c0f23406 59 void LCDController::updateScreen(float volume) {
sbouber1 10:fd4670ec0806 60 lcd.cls();
sbouber1 68:b769c0f23406 61
sbouber1 69:6138d4e0410e 62 if(-1.0f == volume)
sbouber1 68:b769c0f23406 63 lcd.printf("Volume:\nNC");
sbouber1 72:f8c4f731f0fe 64 else if(volume > VOLUME_MAX_CRIT)
sbouber1 72:f8c4f731f0fe 65 lcd.printf("Volume:\nOverflow");
sbouber1 72:f8c4f731f0fe 66 else if(volume < VOLUME_MIN_CRIT)
sbouber1 72:f8c4f731f0fe 67 lcd.printf("Volume:\nUnderflow");
sbouber1 68:b769c0f23406 68 else
sbouber1 72:f8c4f731f0fe 69 lcd.printf("Volume:\nOK");
sbouber1 10:fd4670ec0806 70 }
sbouber1 10:fd4670ec0806 71
sbouber1 57:8dc3192ff150 72 void LCDController::showError(const char *msg) {
sbouber1 10:fd4670ec0806 73 lcd.cls();
sbouber1 10:fd4670ec0806 74 lcd.printf("ERROR:\n%s", msg);
sbouber1 10:fd4670ec0806 75 }