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

LCDController.cpp

Committer:
joran
Date:
2016-06-15
Revision:
44:7c932cc5991b
Parent:
41:dce2c29f49cd
Child:
57:8dc3192ff150

File content as of revision 44:7c932cc5991b:

#include "LCDController.h"

TextLCD lcd(p5, p6, p7, p8, p9, p10, TextLCD::LCD16x2);



LCDController::LCDController()
{
    printf("Initiate LCD Controller\n\r");
    lcd.cls();
}
    

void LCDController::splash()
{
    lcd.cls();
    lcd.printf("Welcome to\nSaltware");
    wait(0.5);   
}    

void LCDController::updateScreen(float displaytemp, float saltvolt, PIDController *pidc)
{
     lcd.cls();
     
     char tempbuffer[16];
     char saltbuffer[16];
     
     if (displaytemp > 100)
     {
         sprintf(tempbuffer, "Temp: NC");
     } else {
         sprintf(tempbuffer,"Temp: %.1fC",displaytemp);
     }
     
     if (pidc->is_heating())
     {
          sprintf(tempbuffer,"%s *",tempbuffer);   
     }   
     
     sprintf(saltbuffer,"Salt: %.3fPPT",saltvolt);
     
     if (pidc->is_pumping())
     {
         sprintf(saltbuffer,"%s *",saltbuffer);
     }   

     lcd.printf("%s\n%s",tempbuffer,saltbuffer);   
}

void LCDController::showPumping() {
    lcd.cls();
    lcd.printf("Now pumping...");
}

void LCDController::updateScreen(float distance) {
    lcd.cls();
    lcd.printf("Volume:\n%.0fml", distance);    
}

void LCDController::error(const char *msg) {
    lcd.cls();
    lcd.printf("ERROR:\n%s", msg);    
}