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:
Sun Jun 19 22:39:16 2016 +0000
Revision:
58:b5f0c0f305ff
Parent:
57:8dc3192ff150
Child:
64:735009c4c8aa
update

Who changed what in which revision?

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