Rev 1.6 - Sample Period Work in progress

Dependencies:   mbed Bitmap N5110 TMP102 Joystick

Committer:
louismarr
Date:
Fri Jan 28 13:55:38 2022 +0000
Revision:
23:655780ba2686
Parent:
22:ef63c41689c2
Parent:
15:73383333229d
Child:
24:0ae7d800d17d
Version 1.0 Final

Who changed what in which revision?

UserRevisionLine numberNew contents of line
louismarr 5:138a91e25e1c 1 /*
louismarr 5:138a91e25e1c 2
louismarr 7:ef1dab708752 3 Acknowledgements to (c) Craig A. Evans, University of Leeds, Feb 2016 for Temp Library
louismarr 7:ef1dab708752 4 Acknowledgements to (c) Dr. Edmond Nurellari, University of Lincoln, Dec 2021 for Classes used
louismarr 5:138a91e25e1c 5
louismarr 7:ef1dab708752 6 Using Various Libraries & Functions in order to create a
louismarr 7:ef1dab708752 7 Temperature Based Health Assistive Smart Device
louismarr 0:f8a8c6a8a5c3 8 */
louismarr 0:f8a8c6a8a5c3 9
louismarr 7:ef1dab708752 10 /*
louismarr 7:ef1dab708752 11 ======================== Library Imports =======================================
louismarr 7:ef1dab708752 12 Importing the Header Files from the Class Libraries into the main.cpp
louismarr 7:ef1dab708752 13 */
louismarr 20:3bc5958190cd 14 #include "mbed.h" // Mbed OS Library
louismarr 20:3bc5958190cd 15 #include "TMP102.h" // TMP102 Header File
louismarr 20:3bc5958190cd 16 #include "N5110.h" // N5110 Header File
louismarr 20:3bc5958190cd 17 #include "Bitmap.h" // Bitmap Header File
louismarr 20:3bc5958190cd 18 #include "Joystick.h" // Joystick Header File
louismarr 0:f8a8c6a8a5c3 19
louismarr 7:ef1dab708752 20 /*
louismarr 7:ef1dab708752 21 ========================== Vairable Setup ======================================
louismarr 7:ef1dab708752 22 Pre-Determining the various Variable names to hardware pins on the K64F Board
louismarr 7:ef1dab708752 23 */
louismarr 0:f8a8c6a8a5c3 24
louismarr 22:ef63c41689c2 25 TMP102 Tmp(I2C_SDA,I2C_SCL); // Create TMP102 object
louismarr 7:ef1dab708752 26 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); // Create lcd objec
louismarr 7:ef1dab708752 27 Serial serial(USBTX,USBRX); // CoolTerm TX, RX Comms Setup for Debug
louismarr 22:ef63c41689c2 28 AnalogIn SetP(PTB2); // Potentiometer for Setpoint
louismarr 12:1c821d6d50f9 29 Joystick Joystick(PTB10,PTB11,PTC16); // Create Joystick (PTB10 = Up/Down) (PTB11 = L/R) (PTB16 = Button)
louismarr 12:1c821d6d50f9 30
louismarr 7:ef1dab708752 31 DigitalOut RED_led(LED_RED); // On-board K64F LED'S
louismarr 7:ef1dab708752 32 DigitalOut GRN_led(LED_GREEN);
louismarr 7:ef1dab708752 33 DigitalOut BLU_led(LED_BLUE);
louismarr 7:ef1dab708752 34
louismarr 23:655780ba2686 35 <<<<<<< working copy
louismarr 20:3bc5958190cd 36 DigitalOut Clg_LED(PTA2); // Green LED on PCB for Cooling
louismarr 20:3bc5958190cd 37 DigitalOut Ready_LED(PTA1); // Green LED on PCB for when water is ready
louismarr 20:3bc5958190cd 38 DigitalOut Htg_LED(PTC3); // Red LED on PCB for Cooling
louismarr 21:bf02fb9876b3 39 DigitalOut Boil_LED(PTD3);
louismarr 23:655780ba2686 40 =======
louismarr 15:73383333229d 41 //DigitalOut Grn1(PTA1);
louismarr 15:73383333229d 42 //DigitalOut Grn2(PTA2);
louismarr 15:73383333229d 43 //DigitalOut Grn3(PTC2);
louismarr 15:73383333229d 44
louismarr 15:73383333229d 45 //DigitalOut Red1(PTD3);
louismarr 15:73383333229d 46 //DigitalOut Red2(PTC4);
louismarr 15:73383333229d 47 //DigitalOut Red3(PTC3);
louismarr 23:655780ba2686 48 >>>>>>> merge rev
louismarr 15:73383333229d 49
louismarr 7:ef1dab708752 50 InterruptIn sw2(SW2); // On-board K64F Switches
louismarr 5:138a91e25e1c 51 InterruptIn sw3(SW3);
louismarr 20:3bc5958190cd 52 InterruptIn R(PTB3); // Right Bumper Button
louismarr 20:3bc5958190cd 53 InterruptIn L(PTB18); // Left Bumper Button
louismarr 20:3bc5958190cd 54 InterruptIn A(PTB9); // A button Button
louismarr 20:3bc5958190cd 55 InterruptIn Y(PTC12); // Y Button Button
louismarr 0:f8a8c6a8a5c3 56
louismarr 20:3bc5958190cd 57 // Interrupt Services volatile flag which will change within the isr
louismarr 20:3bc5958190cd 58 volatile int g_R_flag = 0; // g_ in order to show it is a global variable.
louismarr 20:3bc5958190cd 59 volatile int g_L_flag = 0;
louismarr 20:3bc5958190cd 60 volatile int g_A_flag = 0;
louismarr 20:3bc5958190cd 61 volatile int g_Y_flag = 0;
louismarr 18:8e025b809dfb 62
louismarr 20:3bc5958190cd 63 /*
louismarr 20:3bc5958190cd 64 ========================= Void Declaration =====================================
louismarr 20:3bc5958190cd 65 Functions to be called throughout code in order to improve readability
louismarr 20:3bc5958190cd 66 */
louismarr 7:ef1dab708752 67 void error(); // Error Hang Code Function
louismarr 7:ef1dab708752 68 void init_serial(); // Setup serial port Function
louismarr 7:ef1dab708752 69 void init_K64F(); // K64F Disabling Onboard Components Function
louismarr 20:3bc5958190cd 70
louismarr 22:ef63c41689c2 71
louismarr 20:3bc5958190cd 72 void R_isr(); // Interrupt Voids
louismarr 9:77a6ea988e01 73 void L_isr();
louismarr 13:70f02d5e56f5 74 void A_isr();
louismarr 13:70f02d5e56f5 75 void Y_isr();
louismarr 20:3bc5958190cd 76
louismarr 20:3bc5958190cd 77 // Display Screen Voids used in the Menu
louismarr 20:3bc5958190cd 78 void info();
louismarr 22:ef63c41689c2 79 void Page0();
louismarr 13:70f02d5e56f5 80 void Page1();
louismarr 13:70f02d5e56f5 81 void Page2();
louismarr 20:3bc5958190cd 82 void Home();
louismarr 20:3bc5958190cd 83
louismarr 20:3bc5958190cd 84 void MenuNav(); // Menu Navigation using the Joystick to move Left & Right
louismarr 20:3bc5958190cd 85
louismarr 22:ef63c41689c2 86 void Custom(); // Custom Setpoint - Mode Function
louismarr 22:ef63c41689c2 87 void T_SP_Pg0();
louismarr 22:ef63c41689c2 88 void HtgClg_Pg0();
louismarr 22:ef63c41689c2 89
louismarr 20:3bc5958190cd 90 void WWtr(); // Page 1 - Mode Functions
louismarr 20:3bc5958190cd 91 void T_SP_Pg1();
louismarr 20:3bc5958190cd 92 void HtgClg_Pg1();
louismarr 20:3bc5958190cd 93
louismarr 20:3bc5958190cd 94 void CWtr(); // Page 2 - Mode Functions
louismarr 20:3bc5958190cd 95 void T_SP_Pg2();
louismarr 18:8e025b809dfb 96 void HtgClg_Pg2();
louismarr 18:8e025b809dfb 97
louismarr 21:bf02fb9876b3 98 void BWtr(); // Page 2 - Mode Functions
louismarr 21:bf02fb9876b3 99 void T_SP_Pg3();
louismarr 21:bf02fb9876b3 100 void HtgClg_Pg3();
louismarr 1:5cdfc8d78097 101
louismarr 7:ef1dab708752 102 /*======================== Main Function =====================================*/
louismarr 20:3bc5958190cd 103
louismarr 22:ef63c41689c2 104 int Setpoint[4] = {8,37,80,24}; // Setpoint Array to be used dependant on Mode Selected
louismarr 17:be8dd797e60b 105
louismarr 0:f8a8c6a8a5c3 106 int main()
louismarr 0:f8a8c6a8a5c3 107 {
louismarr 6:117edd5dc0a0 108
louismarr 7:ef1dab708752 109 init_K64F(); // Initialise K64F Board
louismarr 7:ef1dab708752 110 init_serial(); // Initialise Serial Port
louismarr 22:ef63c41689c2 111 Tmp.init(); // Initialise Temp Sensor Libraries
louismarr 7:ef1dab708752 112 lcd.init(); // Initialise LCD
louismarr 23:655780ba2686 113 <<<<<<< working copy
louismarr 22:ef63c41689c2 114 Joystick.init(); // Initialise Joystick
louismarr 16:648f9012c47a 115
louismarr 9:77a6ea988e01 116 lcd.setContrast(0.4); // Setup the contrast for the LCD Screen
louismarr 22:ef63c41689c2 117
louismarr 22:ef63c41689c2 118 R.fall(&R_isr); // Flipping the Interrupt Function
louismarr 22:ef63c41689c2 119 R.mode(PullDown); // When the PCB Button is Pulled Down
louismarr 23:655780ba2686 120 =======
louismarr 12:1c821d6d50f9 121 Joystick.init();
louismarr 15:73383333229d 122
louismarr 9:77a6ea988e01 123 lcd.setContrast(0.4); // Setup the contrast for the LCD Screen
louismarr 9:77a6ea988e01 124 R.fall(&R_isr);
louismarr 9:77a6ea988e01 125 R.mode(PullDown);
louismarr 23:655780ba2686 126 >>>>>>> merge rev
louismarr 9:77a6ea988e01 127
louismarr 9:77a6ea988e01 128 L.fall(&L_isr);
louismarr 9:77a6ea988e01 129 L.mode(PullDown);
louismarr 0:f8a8c6a8a5c3 130
louismarr 13:70f02d5e56f5 131 A.fall(&A_isr);
louismarr 13:70f02d5e56f5 132 A.mode(PullDown);
louismarr 13:70f02d5e56f5 133
louismarr 13:70f02d5e56f5 134 Y.fall(&Y_isr);
louismarr 13:70f02d5e56f5 135 Y.mode(PullDown);
louismarr 23:655780ba2686 136 <<<<<<< working copy
louismarr 22:ef63c41689c2 137
louismarr 20:3bc5958190cd 138 Clg_LED = 1; // Disabling the LED's
louismarr 18:8e025b809dfb 139 Ready_LED = 1;
louismarr 18:8e025b809dfb 140 Htg_LED = 1;
louismarr 21:bf02fb9876b3 141 Boil_LED = 1;
louismarr 18:8e025b809dfb 142
louismarr 22:ef63c41689c2 143 while (1) {
louismarr 20:3bc5958190cd 144 MenuNav();
louismarr 23:655780ba2686 145 =======
louismarr 13:70f02d5e56f5 146
louismarr 12:1c821d6d50f9 147 while (1) {
louismarr 13:70f02d5e56f5 148
louismarr 14:fa5f83f26ed7 149 MenuNav(); // Call the info function
louismarr 13:70f02d5e56f5 150 Page1();
louismarr 13:70f02d5e56f5 151 Page2();
louismarr 13:70f02d5e56f5 152 temp_SP();
louismarr 13:70f02d5e56f5 153
louismarr 12:1c821d6d50f9 154
louismarr 23:655780ba2686 155 >>>>>>> merge rev
louismarr 0:f8a8c6a8a5c3 156 }
louismarr 13:70f02d5e56f5 157
louismarr 9:77a6ea988e01 158 }
louismarr 13:70f02d5e56f5 159
louismarr 5:138a91e25e1c 160
louismarr 7:ef1dab708752 161 /*
louismarr 7:ef1dab708752 162 =========================== Void Setup =========================================
louismarr 7:ef1dab708752 163 Custom Function's are called Void's, which are called upon inside the of the
louismarr 7:ef1dab708752 164 Main Function Code
louismarr 7:ef1dab708752 165 */
louismarr 0:f8a8c6a8a5c3 166
louismarr 22:ef63c41689c2 167 void init_serial()
louismarr 22:ef63c41689c2 168 {
louismarr 22:ef63c41689c2 169 /** Serial Port Communications
louismarr 22:ef63c41689c2 170 * Initialise the serial communication port for communication
louismarr 22:ef63c41689c2 171 * to CoolTerm in order to Debug the code through various parts
louismarr 22:ef63c41689c2 172 */
louismarr 22:ef63c41689c2 173 serial.baud(9600); // Baud Rate Communication for CoolTerm Debugging
louismarr 0:f8a8c6a8a5c3 174 }
louismarr 0:f8a8c6a8a5c3 175
louismarr 5:138a91e25e1c 176 void init_K64F()
louismarr 0:f8a8c6a8a5c3 177 {
louismarr 22:ef63c41689c2 178 /* K64F Board Set up
louismarr 22:ef63c41689c2 179 * since the on-board switches have external pull-ups, disable the
louismarr 22:ef63c41689c2 180 * internal pull-down resistors that are enabled by default using
louismarr 22:ef63c41689c2 181 * the InterruptIn Command */
louismarr 22:ef63c41689c2 182
louismarr 22:ef63c41689c2 183 RED_led = 1; // on-board LEDs are active when 0, so setting the pin to 1 turns them off
louismarr 7:ef1dab708752 184 GRN_led = 1;
louismarr 9:77a6ea988e01 185 BLU_led = 1;
louismarr 22:ef63c41689c2 186
louismarr 5:138a91e25e1c 187 sw2.mode(PullNone);
louismarr 5:138a91e25e1c 188 sw3.mode(PullNone);
louismarr 9:77a6ea988e01 189 }
louismarr 0:f8a8c6a8a5c3 190
louismarr 9:77a6ea988e01 191 void R_isr() // Right Bumper Interrupt Service
louismarr 9:77a6ea988e01 192 {
louismarr 9:77a6ea988e01 193 g_R_flag = 1; // set flag in ISR
louismarr 0:f8a8c6a8a5c3 194 }
louismarr 9:77a6ea988e01 195
louismarr 9:77a6ea988e01 196 void L_isr() // Left Bumper Interrupt Service
louismarr 9:77a6ea988e01 197 {
louismarr 9:77a6ea988e01 198 g_L_flag = 1; // set flag in ISR
louismarr 9:77a6ea988e01 199 }
louismarr 20:3bc5958190cd 200 void A_isr() // A Button Interrupt Service
louismarr 13:70f02d5e56f5 201 {
louismarr 13:70f02d5e56f5 202 g_A_flag = 1; // set flag in ISR
louismarr 13:70f02d5e56f5 203 }
louismarr 20:3bc5958190cd 204 void Y_isr() // Y Button Interrupt Service
louismarr 13:70f02d5e56f5 205 {
louismarr 13:70f02d5e56f5 206 g_Y_flag = 1; // set flag in ISR
louismarr 13:70f02d5e56f5 207 }
louismarr 10:d98b2dd7ba09 208 void info()
louismarr 10:d98b2dd7ba09 209 {
louismarr 22:ef63c41689c2 210 /** Printing Information Page
louismarr 22:ef63c41689c2 211 * Pre-defined software information page to be printed when called upon
louismarr 22:ef63c41689c2 212 */
louismarr 22:ef63c41689c2 213
louismarr 22:ef63c41689c2 214 //serial.printf(" Information Page Selected "); // Debugging Print
louismarr 22:ef63c41689c2 215 lcd.clear(); // Clear Screen
louismarr 22:ef63c41689c2 216 lcd.printString(" Info Page ",0,0); // Print Information Screen
louismarr 22:ef63c41689c2 217 lcd.printString(" Author: LM ",0,1);
louismarr 22:ef63c41689c2 218 lcd.printString(" 18689006 ",0,2);
louismarr 22:ef63c41689c2 219 lcd.printString(" Version 1 ",0,3);
louismarr 22:ef63c41689c2 220 lcd.printString(" R = Home ",0,4);
louismarr 22:ef63c41689c2 221 lcd.printString(" A = Select ",0,5);
louismarr 22:ef63c41689c2 222
louismarr 22:ef63c41689c2 223 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 22:ef63c41689c2 224 wait(1);
louismarr 14:fa5f83f26ed7 225
louismarr 12:1c821d6d50f9 226 }
louismarr 18:8e025b809dfb 227 void Home()
louismarr 18:8e025b809dfb 228 {
louismarr 22:ef63c41689c2 229 /** Printing Home Page
louismarr 22:ef63c41689c2 230 * Pre-defined Home page to be printed when called upon
louismarr 22:ef63c41689c2 231 */
louismarr 22:ef63c41689c2 232
louismarr 22:ef63c41689c2 233 //serial.printf("Home Menu"); // Debugging Print
louismarr 22:ef63c41689c2 234 lcd.clear(); // Clear Screen
louismarr 22:ef63c41689c2 235 lcd.printString(" Navigate >",0,0); // Print Home Screen
louismarr 22:ef63c41689c2 236 lcd.printString(" Use Joystick ",0,1);
louismarr 22:ef63c41689c2 237 lcd.printString(" Welcome ",0,3);
louismarr 22:ef63c41689c2 238 lcd.printString(" Main Menu: ",0,4);
louismarr 22:ef63c41689c2 239 lcd.printString(" Y for Info ",0,5);
louismarr 22:ef63c41689c2 240
louismarr 22:ef63c41689c2 241 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 22:ef63c41689c2 242 wait(1);
louismarr 18:8e025b809dfb 243
louismarr 22:ef63c41689c2 244 if (g_Y_flag){ // Condition to change over into new loop
louismarr 22:ef63c41689c2 245 g_Y_flag = 0; // When the Button has been pressed
louismarr 22:ef63c41689c2 246 Y.rise(&Y_isr);
louismarr 22:ef63c41689c2 247 //serial.printf("Y Pressed"); // Debugging Print
louismarr 22:ef63c41689c2 248 info(); // Display Information Screen
louismarr 22:ef63c41689c2 249 }
louismarr 22:ef63c41689c2 250 }
louismarr 22:ef63c41689c2 251 void Page0()
louismarr 22:ef63c41689c2 252 {
louismarr 22:ef63c41689c2 253 /** Printing Page 0
louismarr 22:ef63c41689c2 254 * Pre-defined PCustom Page to be printed when called upon
louismarr 22:ef63c41689c2 255 */
louismarr 22:ef63c41689c2 256
louismarr 22:ef63c41689c2 257 //serial.printf(" Custom Page "); // Debugging Print
louismarr 22:ef63c41689c2 258 lcd.clear(); // Clear Screen
louismarr 22:ef63c41689c2 259 lcd.printString("< Custom >",0,0); // Print Page 1 Screen
louismarr 22:ef63c41689c2 260 lcd.printString(" MODE: ",0,1);
louismarr 22:ef63c41689c2 261 lcd.printString(" Custom ",0,2);
louismarr 22:ef63c41689c2 262 lcd.printString(" Setpoint ",0,3);
louismarr 22:ef63c41689c2 263 lcd.printString(" Press A ",0,4);
louismarr 22:ef63c41689c2 264
louismarr 22:ef63c41689c2 265 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 22:ef63c41689c2 266 wait(1);
louismarr 22:ef63c41689c2 267
louismarr 22:ef63c41689c2 268 if (g_A_flag){ // Condition to change over into new loop
louismarr 22:ef63c41689c2 269 g_A_flag = 0; // When the A Flag has been pressed
louismarr 22:ef63c41689c2 270 A.rise(&A_isr);
louismarr 22:ef63c41689c2 271 //serial.printf("A Pressed"); // Debugging Print
louismarr 22:ef63c41689c2 272 Custom(); // Select Custom Mode
louismarr 18:8e025b809dfb 273 wait(1);
louismarr 20:3bc5958190cd 274 }
louismarr 18:8e025b809dfb 275 }
louismarr 12:1c821d6d50f9 276 void Page1()
louismarr 20:3bc5958190cd 277 {
louismarr 22:ef63c41689c2 278 /** Printing Page 1
louismarr 22:ef63c41689c2 279 * Pre-defined Page 1 to be printed when called upon
louismarr 22:ef63c41689c2 280 */
louismarr 22:ef63c41689c2 281
louismarr 22:ef63c41689c2 282 //serial.printf(" Page 1 "); // Debugging Print
louismarr 22:ef63c41689c2 283 lcd.clear(); // Clear Screen
louismarr 22:ef63c41689c2 284 lcd.printString("< Page 1 >",0,0); // Print Page 1 Screen
louismarr 22:ef63c41689c2 285 lcd.printString(" MODE: ",0,1);
louismarr 20:3bc5958190cd 286 lcd.printString("Washing Water",0,2);
louismarr 20:3bc5958190cd 287 lcd.printString(" Press A ",0,3);
louismarr 14:fa5f83f26ed7 288
louismarr 22:ef63c41689c2 289 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 14:fa5f83f26ed7 290 wait(1);
louismarr 21:bf02fb9876b3 291
louismarr 22:ef63c41689c2 292 if (g_A_flag){ // Condition to change over into new loop
louismarr 22:ef63c41689c2 293 g_A_flag = 0; // When the A Flag has been pressed
louismarr 16:648f9012c47a 294 A.rise(&A_isr);
louismarr 22:ef63c41689c2 295 //serial.printf("A Pressed"); // Debugging Print
louismarr 22:ef63c41689c2 296 WWtr(); // Select Mode 2
louismarr 17:be8dd797e60b 297 wait(1);
louismarr 20:3bc5958190cd 298 }
louismarr 9:77a6ea988e01 299 }
louismarr 12:1c821d6d50f9 300 void Page2()
louismarr 23:655780ba2686 301 <<<<<<< working copy
louismarr 22:ef63c41689c2 302 {
louismarr 22:ef63c41689c2 303 /** Printing Page 2
louismarr 22:ef63c41689c2 304 * Pre-defined Page 2 to be printed when called upon
louismarr 22:ef63c41689c2 305 */
louismarr 23:655780ba2686 306 =======
louismarr 14:fa5f83f26ed7 307 {
louismarr 12:1c821d6d50f9 308 serial.printf(" Page 2 "); // Debugging Print
louismarr 12:1c821d6d50f9 309 lcd.clear(); // Clear Screen
louismarr 14:fa5f83f26ed7 310 lcd.printString("< Page 2 ",0,0); // Print Information Screen
louismarr 15:73383333229d 311 lcd.printString("Outside Air Mode",0,1);
louismarr 15:73383333229d 312 lcd.printString("=",0,2);
louismarr 14:fa5f83f26ed7 313 lcd.printString("Press A",0,3);
louismarr 14:fa5f83f26ed7 314
louismarr 13:70f02d5e56f5 315 lcd.refresh();
louismarr 14:fa5f83f26ed7 316 wait(1);
louismarr 14:fa5f83f26ed7 317 }
louismarr 12:1c821d6d50f9 318 void temp_SP()
louismarr 12:1c821d6d50f9 319 {
louismarr 13:70f02d5e56f5 320
louismarr 12:1c821d6d50f9 321 float T = tmp102.get_temperature(); // Reading Temperature as a floating variable
louismarr 12:1c821d6d50f9 322 float Set = SP * 100; // Reading Potentiometer as a floating variable. Multiplied by 100 to give larger range
louismarr 23:655780ba2686 323 >>>>>>> merge rev
louismarr 12:1c821d6d50f9 324
louismarr 23:655780ba2686 325 <<<<<<< working copy
louismarr 22:ef63c41689c2 326 //serial.printf(" Page 2 "); // Debugging Print
louismarr 22:ef63c41689c2 327 lcd.clear(); // Clear Screen
louismarr 21:bf02fb9876b3 328 lcd.printString("< Page 2 >",0,0); // Print Information Screen
louismarr 22:ef63c41689c2 329 lcd.printString(" MODE: ",0,1);
louismarr 17:be8dd797e60b 330 lcd.printString("Drinking Water",0,2);
louismarr 20:3bc5958190cd 331 lcd.printString(" Press A ",0,3);
louismarr 14:fa5f83f26ed7 332
louismarr 22:ef63c41689c2 333 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 14:fa5f83f26ed7 334 wait(1);
louismarr 21:bf02fb9876b3 335
louismarr 22:ef63c41689c2 336 if (g_A_flag){ // Condition to change over into new loop
louismarr 22:ef63c41689c2 337 g_A_flag = 0; // When the R Flag has been pressed
louismarr 22:ef63c41689c2 338 A.rise(&A_isr);
louismarr 22:ef63c41689c2 339 serial.printf("A Pressed"); // Debugging Print
louismarr 22:ef63c41689c2 340 CWtr(); // Select Mode 3
louismarr 22:ef63c41689c2 341 wait(1);
louismarr 20:3bc5958190cd 342 }
louismarr 14:fa5f83f26ed7 343 }
louismarr 21:bf02fb9876b3 344 void Page3()
louismarr 21:bf02fb9876b3 345 {
louismarr 22:ef63c41689c2 346 /** Printing Page 3
louismarr 22:ef63c41689c2 347 * Pre-defined Page 3 to be printed when called upon
louismarr 22:ef63c41689c2 348 */
louismarr 23:655780ba2686 349 =======
louismarr 12:1c821d6d50f9 350 lcd.clear(); // clearing the LCD buffer at the begining of the loop
louismarr 12:1c821d6d50f9 351 lcd.printString("Temperature",0,0); // Can also pre-determine the co-ordinates of the ',0,0' (must be less than 84 pixels to fit on display)
louismarr 12:1c821d6d50f9 352 char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14 Max amound of Characters)
louismarr 13:70f02d5e56f5 353 Direction d = Joystick.get_direction();
louismarr 12:1c821d6d50f9 354
louismarr 12:1c821d6d50f9 355 int length = sprintf(buffer,"T=%.2F 'C",T); // print the temperature from the float variable T
louismarr 12:1c821d6d50f9 356 if (length <= 14) // Ensuring string will fit on the screen (Printing at x=0)
louismarr 12:1c821d6d50f9 357 lcd.printString(buffer,0,1); // display on screen
louismarr 12:1c821d6d50f9 358 serial.printf("T = %f C\n",T); // Printing the Temperature over Serial Port
louismarr 23:655780ba2686 359 >>>>>>> merge rev
louismarr 12:1c821d6d50f9 360
louismarr 23:655780ba2686 361 <<<<<<< working copy
louismarr 22:ef63c41689c2 362 //serial.printf(" Page 3 "); // Debugging Print
louismarr 21:bf02fb9876b3 363 lcd.clear(); // Clear Screen
louismarr 22:ef63c41689c2 364 lcd.printString("< Page 3",0,0); // Print Information Screen
louismarr 22:ef63c41689c2 365 lcd.printString(" MODE: ",0,1);
louismarr 22:ef63c41689c2 366 lcd.printString("Boiling Water",4,2);
louismarr 21:bf02fb9876b3 367 lcd.printString(" Press A ",0,3);
louismarr 21:bf02fb9876b3 368
louismarr 22:ef63c41689c2 369 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 21:bf02fb9876b3 370 wait(1);
louismarr 21:bf02fb9876b3 371
louismarr 22:ef63c41689c2 372 if (g_A_flag){ // Condition to change over into new loop
louismarr 22:ef63c41689c2 373 g_A_flag = 0; // When the A Flag has been pressed
louismarr 21:bf02fb9876b3 374 A.rise(&A_isr);
louismarr 22:ef63c41689c2 375 //serial.printf("A Pressed"); // Debugging Print
louismarr 22:ef63c41689c2 376 BWtr(); // Select Mode 3
louismarr 21:bf02fb9876b3 377 wait(1);
louismarr 21:bf02fb9876b3 378 }
louismarr 21:bf02fb9876b3 379 }
louismarr 23:655780ba2686 380 =======
louismarr 12:1c821d6d50f9 381 length = sprintf(buffer,"SP=%.2F 'C",Set); // Print the Setpoint from the Float Variable Set
louismarr 12:1c821d6d50f9 382 if (length <= 14) // Ensuring string will fit on the screen (Printing at x=0)
louismarr 12:1c821d6d50f9 383 lcd.printString(buffer,0,2); // display on screen
louismarr 12:1c821d6d50f9 384 serial.printf(" SP = %f", Set); //
louismarr 13:70f02d5e56f5 385 lcd.refresh();
louismarr 15:73383333229d 386 wait(10);
louismarr 12:1c821d6d50f9 387 if (Set < T){ // Condition to change over into new loop
louismarr 12:1c821d6d50f9 388 lcd.clear(); // clearing the LCD buffer at the begining of the loop
louismarr 12:1c821d6d50f9 389 lcd.printString("Over Heating",3,2); // Print New Message
louismarr 12:1c821d6d50f9 390 serial.printf("OverTemp"); // Debugging Print
louismarr 13:70f02d5e56f5 391 lcd.refresh();
louismarr 15:73383333229d 392 if (g_Y_flag){ // Condition to change over into new loop
louismarr 15:73383333229d 393 g_Y_flag = 0; // When the R Flag has been pressed
louismarr 15:73383333229d 394 Y.rise(&Y_isr);
louismarr 15:73383333229d 395 serial.printf("Y Pressed");
louismarr 15:73383333229d 396 //Page1();
louismarr 15:73383333229d 397 wait(3);
louismarr 13:70f02d5e56f5 398 }
louismarr 14:fa5f83f26ed7 399
louismarr 15:73383333229d 400 }
louismarr 15:73383333229d 401 }
louismarr 23:655780ba2686 402 >>>>>>> merge rev
louismarr 14:fa5f83f26ed7 403 void MenuNav()
louismarr 14:fa5f83f26ed7 404 {
louismarr 23:655780ba2686 405 <<<<<<< working copy
louismarr 22:ef63c41689c2 406 /** Menu Navigation Function
louismarr 22:ef63c41689c2 407 * Using the Joystick and a Switch-Case Function Operation
louismarr 22:ef63c41689c2 408 * in order to build the menu system that will be printing
louismarr 22:ef63c41689c2 409 * onto the LCD N5110 Screen by calling upon funcitons
louismarr 22:ef63c41689c2 410 */
louismarr 18:8e025b809dfb 411
louismarr 22:ef63c41689c2 412 lcd.clear(); // Clear LCD Screen
louismarr 22:ef63c41689c2 413 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 22:ef63c41689c2 414
louismarr 22:ef63c41689c2 415 int Mode = 0; // Initialise Mode to 0
louismarr 23:655780ba2686 416 =======
louismarr 15:73383333229d 417 lcd.clear();
louismarr 14:fa5f83f26ed7 418 lcd.refresh();
louismarr 14:fa5f83f26ed7 419
louismarr 14:fa5f83f26ed7 420 int select = 0;
louismarr 23:655780ba2686 421 >>>>>>> merge rev
louismarr 13:70f02d5e56f5 422 while (1){
louismarr 14:fa5f83f26ed7 423
louismarr 22:ef63c41689c2 424 //serial.printf("Direction = %i ",d); // Debugging Print
louismarr 20:3bc5958190cd 425 Direction d = Joystick.get_direction(); // Joystick Direction used in order to switch between modes
louismarr 17:be8dd797e60b 426
louismarr 20:3bc5958190cd 427 switch(Mode) { // Main External Switch to detetermine Mode
louismarr 20:3bc5958190cd 428 case 0: // Main Initial Case instance
louismarr 20:3bc5958190cd 429 switch(d) { // Looking at the Joystick Direction for internal switch
louismarr 20:3bc5958190cd 430 case W: // If the direction is W (Left) carry out Case W
louismarr 20:3bc5958190cd 431 wait(0.5); // Delay added to allow for joystick movement
louismarr 20:3bc5958190cd 432 Mode = 0; // Remain in Mode 0 - Prevents idol cycling through the switch
louismarr 20:3bc5958190cd 433 //serial.printf("LEFT.0"); // Debugging Print to see which state the Main switch is at via Direction
louismarr 20:3bc5958190cd 434 break; // Break out from Loop
louismarr 20:3bc5958190cd 435 case E: // If the direction is E (Right) carry out Case E
louismarr 20:3bc5958190cd 436 wait(0.5); // Delay added to allow for joystick movement
louismarr 20:3bc5958190cd 437 Mode = 1; // Switch to Mode 1
louismarr 20:3bc5958190cd 438 //serial.printf("RIGHT.0"); // Debugging Print
louismarr 20:3bc5958190cd 439 break; // Break out from Loop
louismarr 19:00cdcf5a5b7a 440 }
louismarr 20:3bc5958190cd 441 break; // Break out from Loop into Main Switch
louismarr 19:00cdcf5a5b7a 442
louismarr 23:655780ba2686 443 <<<<<<< working copy
louismarr 20:3bc5958190cd 444 case 1: // Main Initial Case instance - When at Page 1
louismarr 20:3bc5958190cd 445 switch(d) { // Looking at the Joystick Direction for internal switch
louismarr 20:3bc5958190cd 446 case W: // If the direction is W (Left) carry out Case W
louismarr 20:3bc5958190cd 447 wait(0.5); // Delay added to allow for joystick movement
louismarr 20:3bc5958190cd 448 Mode = 0; // Return to Mode 0
louismarr 20:3bc5958190cd 449 //serial.printf("LEFT.1"); // Debugging Print
louismarr 20:3bc5958190cd 450 break; // Break out from Loop
louismarr 20:3bc5958190cd 451 case E: // If the direction is E (Right) carry out Case E
louismarr 20:3bc5958190cd 452 wait(0.5); // Delay added to allow for joystick movement
louismarr 20:3bc5958190cd 453 Mode = 2; // Switch to Mode 0
louismarr 20:3bc5958190cd 454 //serial.printf("RIGHT.1"); // Debugging Print
louismarr 20:3bc5958190cd 455 break; // Break out from Loop
louismarr 19:00cdcf5a5b7a 456 }
louismarr 20:3bc5958190cd 457 break; // Break out from Loop into Main Switch
louismarr 20:3bc5958190cd 458
louismarr 22:ef63c41689c2 459 case 2: // Main Initial Case instance - When at Page 2
louismarr 20:3bc5958190cd 460 switch(d) { // Looking at the Joystick Direction for internal switch
louismarr 20:3bc5958190cd 461 case W: // If the direction is W (Left) carry out Case W
louismarr 20:3bc5958190cd 462 wait(0.5); // Delay added to allow for joystick movement
louismarr 20:3bc5958190cd 463 Mode = 1; // Return to Mode 1
louismarr 20:3bc5958190cd 464 //serial.printf("LEFT.2"); // Debugging Print
louismarr 20:3bc5958190cd 465 break; // Break out from Loop
louismarr 20:3bc5958190cd 466 case E: // If the direction is E (Right) carry out Case E
louismarr 20:3bc5958190cd 467 wait(0.5); // Delay added to allow for joystick movement
louismarr 21:bf02fb9876b3 468 Mode = 3; // Remain in Mode 2 - Prevents idol cycling through the switch
louismarr 21:bf02fb9876b3 469 //serial.printf("RIGHT.2"); // Debugging Print
louismarr 21:bf02fb9876b3 470 break; // Break out from Loop
louismarr 21:bf02fb9876b3 471 }
louismarr 22:ef63c41689c2 472 break; // Break out from Loop into Main Switch
louismarr 22:ef63c41689c2 473
louismarr 22:ef63c41689c2 474 case 3: // Main Initial Case instance - When at Page 3
louismarr 21:bf02fb9876b3 475 switch(d) { // Looking at the Joystick Direction for internal switch
louismarr 21:bf02fb9876b3 476 case W: // If the direction is W (Left) carry out Case W
louismarr 21:bf02fb9876b3 477 wait(0.5); // Delay added to allow for joystick movement
louismarr 21:bf02fb9876b3 478 Mode = 2; // Return to Mode 1
louismarr 22:ef63c41689c2 479 //serial.printf("LEFT.3"); // Debugging Print
louismarr 21:bf02fb9876b3 480 break; // Break out from Loop
louismarr 21:bf02fb9876b3 481 case E: // If the direction is E (Right) carry out Case E
louismarr 21:bf02fb9876b3 482 wait(0.5); // Delay added to allow for joystick movement
louismarr 22:ef63c41689c2 483 Mode = 4; // Remain in Mode 2 - Prevents idol cycling through the switch
louismarr 22:ef63c41689c2 484 //serial.printf("RIGHT.3"); // Debugging Print
louismarr 22:ef63c41689c2 485 break; // Break out from Loop
louismarr 22:ef63c41689c2 486 }
louismarr 22:ef63c41689c2 487 break; // Break out from Loop into Main Switch
louismarr 22:ef63c41689c2 488
louismarr 22:ef63c41689c2 489 case 4: // Main Initial Case instance - When at Page 2
louismarr 22:ef63c41689c2 490 switch(d) { // Looking at the Joystick Direction for internal switch
louismarr 22:ef63c41689c2 491 case W: // If the direction is W (Left) carry out Case W
louismarr 22:ef63c41689c2 492 wait(0.5); // Delay added to allow for joystick movement
louismarr 22:ef63c41689c2 493 Mode = 3; // Return to Mode 1
louismarr 22:ef63c41689c2 494 //serial.printf("LEFT.4"); // Debugging Print
louismarr 22:ef63c41689c2 495 break; // Break out from Loop
louismarr 22:ef63c41689c2 496 case E: // If the direction is E (Right) carry out Case E
louismarr 22:ef63c41689c2 497 wait(0.5); // Delay added to allow for joystick movement
louismarr 22:ef63c41689c2 498 Mode = 4; // Remain in Mode 2 - Prevents idol cycling through the switch
louismarr 22:ef63c41689c2 499 //serial.printf("RIGHT.4"); // Debugging Print
louismarr 20:3bc5958190cd 500 break; // Break out from Loop
louismarr 20:3bc5958190cd 501 }
louismarr 20:3bc5958190cd 502 break; // Break out from Loop into Main Switch
louismarr 22:ef63c41689c2 503 default:
louismarr 22:ef63c41689c2 504 Mode = 0;
louismarr 22:ef63c41689c2 505
louismarr 14:fa5f83f26ed7 506 break;
louismarr 19:00cdcf5a5b7a 507 }
louismarr 20:3bc5958190cd 508 wait(0.5);
louismarr 22:ef63c41689c2 509 // Mode Actions
louismarr 22:ef63c41689c2 510 if (Mode == 0){ // When the Mode is 0
louismarr 22:ef63c41689c2 511 Home(); // Go to Home Page Function
louismarr 22:ef63c41689c2 512 }
louismarr 22:ef63c41689c2 513 else if (Mode == 1){ // When the Mode is 1
louismarr 22:ef63c41689c2 514 Page0(); // Go to Page 0 Function
louismarr 19:00cdcf5a5b7a 515 }
louismarr 22:ef63c41689c2 516 else if (Mode == 2){ // When the Mode is 2
louismarr 22:ef63c41689c2 517 Page1(); // Go to Page 1 Function
louismarr 20:3bc5958190cd 518 }
louismarr 22:ef63c41689c2 519 else if (Mode == 3){ // When the Mode is 3
louismarr 22:ef63c41689c2 520 Page2(); // Go to Page 2 Function
louismarr 22:ef63c41689c2 521 }
louismarr 22:ef63c41689c2 522 else if (Mode == 4){ // When the Mode is 4
louismarr 22:ef63c41689c2 523 Page3(); // Go to Page 3 Function
louismarr 21:bf02fb9876b3 524 }
louismarr 12:1c821d6d50f9 525 }
louismarr 19:00cdcf5a5b7a 526 }
louismarr 22:ef63c41689c2 527 void Custom()
louismarr 22:ef63c41689c2 528 {
louismarr 22:ef63c41689c2 529 /** Custom Monitoring Mode
louismarr 22:ef63c41689c2 530 * Using Parameters for Temperature with a custom setpoint
louismarr 22:ef63c41689c2 531 */
louismarr 22:ef63c41689c2 532 while(1){
louismarr 22:ef63c41689c2 533
louismarr 22:ef63c41689c2 534 Setpoint[3] = SetP * 100;
louismarr 22:ef63c41689c2 535 float T = Tmp.get_temperature(); // Reading Temperature as a floating variable
louismarr 22:ef63c41689c2 536 float SP = Setpoint[3]; // Reading the Setpoint from the Array
louismarr 22:ef63c41689c2 537 //serial.printf("SP = %.2f \n",CWtr_SP); // Debugging Print
louismarr 22:ef63c41689c2 538 //serial.printf("SETPOINT = ",CWtr_SP); // Debugging Print
louismarr 22:ef63c41689c2 539 if (SP-1 > T || T > SP+1){ // If the Temperature is not within the Tolerance
louismarr 22:ef63c41689c2 540
louismarr 22:ef63c41689c2 541 HtgClg_Pg0(); // Heating Cooling Control Function
louismarr 22:ef63c41689c2 542 lcd.clear(); // Clear LCD Screen
louismarr 22:ef63c41689c2 543 T_SP_Pg0(); // Print Modes Temperature & Setpoint info
louismarr 22:ef63c41689c2 544 lcd.printString(" Adjusting ",0,2); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 22:ef63c41689c2 545 lcd.printString(" Water Temp ",0,3);
louismarr 22:ef63c41689c2 546 lcd.printString(" Please Wait! ",4,4);
louismarr 23:655780ba2686 547 =======
louismarr 14:fa5f83f26ed7 548 if (select == 2){
louismarr 12:1c821d6d50f9 549 Page2();
louismarr 14:fa5f83f26ed7 550 if (g_A_flag){ // Condition to change over into new loop
louismarr 13:70f02d5e56f5 551 g_A_flag = 0; // When the R Flag has been pressed
louismarr 13:70f02d5e56f5 552 A.rise(&A_isr);
louismarr 14:fa5f83f26ed7 553 serial.printf("Y Pressed");
louismarr 14:fa5f83f26ed7 554 info();
louismarr 14:fa5f83f26ed7 555 }
louismarr 12:1c821d6d50f9 556 }
louismarr 12:1c821d6d50f9 557 }
louismarr 14:fa5f83f26ed7 558 }
louismarr 15:73383333229d 559 //}
louismarr 13:70f02d5e56f5 560 void Menu()
louismarr 13:70f02d5e56f5 561 {
louismarr 13:70f02d5e56f5 562 if (g_R_flag){ // Condition to change over into new loop
louismarr 13:70f02d5e56f5 563 g_R_flag = 0; // When the R Flag has been pressed
louismarr 13:70f02d5e56f5 564 R.rise(&R_isr);
louismarr 23:655780ba2686 565 >>>>>>> merge rev
louismarr 13:70f02d5e56f5 566
louismarr 22:ef63c41689c2 567 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 22:ef63c41689c2 568 wait(1);
louismarr 22:ef63c41689c2 569 }
louismarr 22:ef63c41689c2 570
louismarr 22:ef63c41689c2 571 else if (SP-1 <= T <= SP+1){ // If the Temperature is within the Tolerance
louismarr 22:ef63c41689c2 572
louismarr 22:ef63c41689c2 573 HtgClg_Pg0(); // Heating Cooling Control Function
louismarr 22:ef63c41689c2 574 lcd.clear(); // Clear LCD Screen
louismarr 22:ef63c41689c2 575 T_SP_Pg0(); // Print Modes Temperature & Setpoint info
louismarr 22:ef63c41689c2 576 lcd.printString(" Temperature ",0,2); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 22:ef63c41689c2 577 lcd.printString(" Satisfied ",0,3);
louismarr 22:ef63c41689c2 578 lcd.printString(" Ready! ",4,4);
louismarr 22:ef63c41689c2 579
louismarr 22:ef63c41689c2 580 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 22:ef63c41689c2 581 Ready_LED = 0; // Enable the Ready LED
louismarr 22:ef63c41689c2 582 wait(1);
louismarr 22:ef63c41689c2 583 }
louismarr 22:ef63c41689c2 584
louismarr 22:ef63c41689c2 585 if (g_R_flag){ // Condition to change over into new loop
louismarr 22:ef63c41689c2 586 g_R_flag = 0; // When the Button has been pressed
louismarr 22:ef63c41689c2 587 R.rise(&R_isr); // Button Rising edge
louismarr 22:ef63c41689c2 588 //serial.printf("Home Pressed"); // Debugging Print
louismarr 22:ef63c41689c2 589
louismarr 22:ef63c41689c2 590 Clg_LED = 1; // Disable the LED's for next Mode
louismarr 22:ef63c41689c2 591 Htg_LED = 1;
louismarr 22:ef63c41689c2 592 Ready_LED = 1;
louismarr 22:ef63c41689c2 593
louismarr 22:ef63c41689c2 594 MenuNav(); // Return to Navigation Menu
louismarr 22:ef63c41689c2 595 wait(1);
louismarr 22:ef63c41689c2 596 }
louismarr 22:ef63c41689c2 597 }
louismarr 22:ef63c41689c2 598 }
louismarr 23:655780ba2686 599 <<<<<<< working copy
louismarr 20:3bc5958190cd 600 void WWtr()
louismarr 13:70f02d5e56f5 601 {
louismarr 22:ef63c41689c2 602 /** Warm Washing Water Mode
louismarr 20:3bc5958190cd 603 * Using Parameters for Safe Washing Water Temperature
louismarr 20:3bc5958190cd 604 */
louismarr 17:be8dd797e60b 605 while(1){
louismarr 19:00cdcf5a5b7a 606
louismarr 22:ef63c41689c2 607 float T = Tmp.get_temperature(); // Reading Temperature as a floating variable
louismarr 20:3bc5958190cd 608 float SP = Setpoint[1]; // Reading the Setpoint from the Array
louismarr 20:3bc5958190cd 609 //serial.printf("SP = %.2f \n",CWtr_SP); // Debugging Print
louismarr 20:3bc5958190cd 610 //serial.printf("SETPOINT = ",CWtr_SP); // Debugging Print
louismarr 20:3bc5958190cd 611 if (SP-1 > T || T > SP+1){ // If the Temperature is not within the Tolerance
louismarr 20:3bc5958190cd 612
louismarr 20:3bc5958190cd 613 HtgClg_Pg1(); // Heating Cooling Control Function
louismarr 20:3bc5958190cd 614 lcd.clear(); // Clear LCD Screen
louismarr 20:3bc5958190cd 615 T_SP_Pg1(); // Print Modes Temperature & Setpoint info
louismarr 20:3bc5958190cd 616 lcd.printString(" Adjusting ",0,2); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 20:3bc5958190cd 617 lcd.printString(" Water Temp ",0,3);
louismarr 20:3bc5958190cd 618 lcd.printString(" Please Wait! ",4,4);
louismarr 20:3bc5958190cd 619
louismarr 20:3bc5958190cd 620 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 20:3bc5958190cd 621 wait(1);
louismarr 20:3bc5958190cd 622 }
louismarr 20:3bc5958190cd 623
louismarr 20:3bc5958190cd 624 else if (SP-1 <= T <= SP+1){ // If the Temperature is within the Tolerance
louismarr 20:3bc5958190cd 625
louismarr 20:3bc5958190cd 626 HtgClg_Pg1(); // Heating Cooling Control Function
louismarr 20:3bc5958190cd 627 lcd.clear(); // Clear LCD Screen
louismarr 20:3bc5958190cd 628 T_SP_Pg1(); // Print Modes Temperature & Setpoint info
louismarr 20:3bc5958190cd 629 lcd.printString(" Warm ",0,2); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 20:3bc5958190cd 630 lcd.printString("Washing Water",0,3);
louismarr 20:3bc5958190cd 631 lcd.printString(" Ready! ",4,4);
louismarr 20:3bc5958190cd 632
louismarr 20:3bc5958190cd 633 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 20:3bc5958190cd 634 Ready_LED = 0; // Enable the Ready LED
louismarr 20:3bc5958190cd 635 wait(1);
louismarr 20:3bc5958190cd 636 }
louismarr 20:3bc5958190cd 637
louismarr 20:3bc5958190cd 638 if (g_R_flag){ // Condition to change over into new loop
louismarr 20:3bc5958190cd 639 g_R_flag = 0; // When the Button has been pressed
louismarr 20:3bc5958190cd 640 R.rise(&R_isr); // Button Rising edge
louismarr 20:3bc5958190cd 641 //serial.printf("Home Pressed"); // Debugging Print
louismarr 20:3bc5958190cd 642
louismarr 20:3bc5958190cd 643 Clg_LED = 1; // Disable the LED's for next Mode
louismarr 20:3bc5958190cd 644 Htg_LED = 1;
louismarr 20:3bc5958190cd 645 Ready_LED = 1;
louismarr 20:3bc5958190cd 646
louismarr 20:3bc5958190cd 647 MenuNav(); // Return to Navigation Menu
louismarr 20:3bc5958190cd 648 wait(1);
louismarr 20:3bc5958190cd 649 }
louismarr 20:3bc5958190cd 650 }
louismarr 20:3bc5958190cd 651 }
louismarr 20:3bc5958190cd 652 void CWtr()
louismarr 20:3bc5958190cd 653 {
louismarr 22:ef63c41689c2 654 /** Cold Drinking Water Mode
louismarr 20:3bc5958190cd 655 * Using Parameters for Safe Drinking Water Temperature
louismarr 20:3bc5958190cd 656 */
louismarr 20:3bc5958190cd 657 while(1){
louismarr 20:3bc5958190cd 658
louismarr 22:ef63c41689c2 659 float T = Tmp.get_temperature(); // Reading Temperature as a floating variable
louismarr 22:ef63c41689c2 660 float SP = Setpoint[0]; // Reading the Setpoint from the Array
louismarr 20:3bc5958190cd 661 //serial.printf("SP = %.2f \n",CWtr_SP); // Debugging Print
louismarr 20:3bc5958190cd 662 //serial.printf("SETPOINT = ",CWtr_SP); // Debugging Print
louismarr 22:ef63c41689c2 663 if (SP-1 > T || T > SP+1){ // If the Temperature is not within the Tolerance
louismarr 18:8e025b809dfb 664
louismarr 19:00cdcf5a5b7a 665 HtgClg_Pg2(); // Heating Cooling Control Function
louismarr 19:00cdcf5a5b7a 666 lcd.clear(); // Clear LCD Screen
louismarr 19:00cdcf5a5b7a 667 T_SP_Pg2(); // Print Modes Temperature & Setpoint info
louismarr 20:3bc5958190cd 668 lcd.printString(" Adjusting ",0,2); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 18:8e025b809dfb 669 lcd.printString(" Water Temp ",0,3);
louismarr 18:8e025b809dfb 670 lcd.printString(" Please Wait! ",4,4);
louismarr 18:8e025b809dfb 671
louismarr 20:3bc5958190cd 672 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 18:8e025b809dfb 673 wait(1);
louismarr 19:00cdcf5a5b7a 674 }
louismarr 17:be8dd797e60b 675
louismarr 22:ef63c41689c2 676 else if (SP-1 <= T <= SP+1){ // If the Temperature is within the Tolerance
louismarr 20:3bc5958190cd 677
louismarr 20:3bc5958190cd 678 HtgClg_Pg2(); // Heating Cooling Control Function
louismarr 20:3bc5958190cd 679 lcd.clear(); // Clear LCD Screen
louismarr 20:3bc5958190cd 680 T_SP_Pg2(); // Print Modes Temperature & Setpoint info
louismarr 20:3bc5958190cd 681 lcd.printString(" COLD ",0,2); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 17:be8dd797e60b 682 lcd.printString("Drinking Water",0,3);
louismarr 17:be8dd797e60b 683 lcd.printString(" Ready! ",4,4);
louismarr 18:8e025b809dfb 684
louismarr 20:3bc5958190cd 685 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 20:3bc5958190cd 686 Ready_LED = 0; // Enable the Ready LED
louismarr 16:648f9012c47a 687 wait(1);
louismarr 19:00cdcf5a5b7a 688 }
louismarr 18:8e025b809dfb 689
louismarr 20:3bc5958190cd 690 if (g_R_flag){ // Condition to change over into new loop
louismarr 20:3bc5958190cd 691 g_R_flag = 0; // When the Button has been pressed
louismarr 20:3bc5958190cd 692 R.rise(&R_isr); // Button Rising edge
louismarr 20:3bc5958190cd 693 //serial.printf("Home Pressed"); // Debugging Print
louismarr 18:8e025b809dfb 694
louismarr 20:3bc5958190cd 695 Clg_LED = 1; // Disable the LED's for next Mode
louismarr 19:00cdcf5a5b7a 696 Htg_LED = 1;
louismarr 19:00cdcf5a5b7a 697 Ready_LED = 1;
louismarr 18:8e025b809dfb 698
louismarr 20:3bc5958190cd 699 MenuNav(); // Return to Navigation Menu
louismarr 17:be8dd797e60b 700 wait(1);
louismarr 16:648f9012c47a 701 }
louismarr 19:00cdcf5a5b7a 702 }
louismarr 17:be8dd797e60b 703 }
louismarr 21:bf02fb9876b3 704 void BWtr()
louismarr 21:bf02fb9876b3 705 {
louismarr 22:ef63c41689c2 706 /** Warm Washing Water Mode
louismarr 21:bf02fb9876b3 707 * Using Parameters for Safe Washing Water Temperature
louismarr 21:bf02fb9876b3 708 */
louismarr 21:bf02fb9876b3 709 while(1){
louismarr 21:bf02fb9876b3 710
louismarr 22:ef63c41689c2 711 float T = Tmp.get_temperature(); // Reading Temperature as a floating variable
louismarr 22:ef63c41689c2 712 float SP = Setpoint[3]; // Reading the Setpoint from the Array
louismarr 21:bf02fb9876b3 713 //serial.printf("SP = %.2f \n",CWtr_SP); // Debugging Print
louismarr 21:bf02fb9876b3 714 //serial.printf("SETPOINT = ",CWtr_SP); // Debugging Print
louismarr 21:bf02fb9876b3 715 if (SP-1 > T || T > SP+1){ // If the Temperature is not within the Tolerance
louismarr 21:bf02fb9876b3 716
louismarr 21:bf02fb9876b3 717 HtgClg_Pg3(); // Heating Cooling Control Function
louismarr 21:bf02fb9876b3 718 lcd.clear(); // Clear LCD Screen
louismarr 21:bf02fb9876b3 719 T_SP_Pg3(); // Print Modes Temperature & Setpoint info
louismarr 21:bf02fb9876b3 720 lcd.printString(" Adjusting ",0,2); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 21:bf02fb9876b3 721 lcd.printString(" Water Temp ",0,3);
louismarr 21:bf02fb9876b3 722 lcd.printString(" Please Wait! ",4,4);
louismarr 21:bf02fb9876b3 723
louismarr 21:bf02fb9876b3 724 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 21:bf02fb9876b3 725 wait(1);
louismarr 21:bf02fb9876b3 726 }
louismarr 21:bf02fb9876b3 727
louismarr 21:bf02fb9876b3 728 else if (SP-1 <= T <= SP+1){ // If the Temperature is within the Tolerance
louismarr 21:bf02fb9876b3 729
louismarr 21:bf02fb9876b3 730 HtgClg_Pg3(); // Heating Cooling Control Function
louismarr 21:bf02fb9876b3 731 lcd.clear(); // Clear LCD Screen
louismarr 21:bf02fb9876b3 732 T_SP_Pg3(); // Print Modes Temperature & Setpoint info
louismarr 22:ef63c41689c2 733 lcd.printString(" Boiling ",0,2); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 21:bf02fb9876b3 734 lcd.printString("Boiling Water",0,3);
louismarr 21:bf02fb9876b3 735 lcd.printString(" Ready! ",4,4);
louismarr 21:bf02fb9876b3 736 lcd.printString(" WARNING HOT! ",0,5);
louismarr 21:bf02fb9876b3 737 lcd.refresh(); // Refresh & Display printed strings to LCD
louismarr 22:ef63c41689c2 738 Ready_LED = 0; // Enable the Ready LED
louismarr 22:ef63c41689c2 739 Boil_LED = 0; // Enable the Boiling LED
louismarr 21:bf02fb9876b3 740 wait(1);
louismarr 21:bf02fb9876b3 741 }
louismarr 21:bf02fb9876b3 742
louismarr 21:bf02fb9876b3 743 if (g_R_flag){ // Condition to change over into new loop
louismarr 21:bf02fb9876b3 744 g_R_flag = 0; // When the Button has been pressed
louismarr 21:bf02fb9876b3 745 R.rise(&R_isr); // Button Rising edge
louismarr 21:bf02fb9876b3 746 //serial.printf("Home Pressed"); // Debugging Print
louismarr 21:bf02fb9876b3 747
louismarr 21:bf02fb9876b3 748 Clg_LED = 1; // Disable the LED's for next Mode
louismarr 21:bf02fb9876b3 749 Htg_LED = 1;
louismarr 21:bf02fb9876b3 750 Ready_LED = 1;
louismarr 21:bf02fb9876b3 751
louismarr 21:bf02fb9876b3 752 MenuNav(); // Return to Navigation Menu
louismarr 13:70f02d5e56f5 753 wait(1);
louismarr 21:bf02fb9876b3 754 }
louismarr 21:bf02fb9876b3 755 }
louismarr 13:70f02d5e56f5 756 }
louismarr 22:ef63c41689c2 757 void T_SP_Pg0()
louismarr 20:3bc5958190cd 758 {
louismarr 22:ef63c41689c2 759 /** Mode Select = Cutsom
louismarr 20:3bc5958190cd 760 * When a new mode is selected the LCD screen will update in order
louismarr 20:3bc5958190cd 761 * to assist the user with the water temperature in order to provide
louismarr 20:3bc5958190cd 762 * Assistance, Safety and Comfort
louismarr 20:3bc5958190cd 763 */
louismarr 22:ef63c41689c2 764
louismarr 22:ef63c41689c2 765 Setpoint[3] = SetP * 100; // Use Potentiometer for custom setpoint and assign value into the array
louismarr 22:ef63c41689c2 766
louismarr 22:ef63c41689c2 767 float T = Tmp.get_temperature(); // Reading Temperature as a floating variable
louismarr 22:ef63c41689c2 768 float SP_0 = Setpoint[3]; // Reading the Mode Setpoint from the Array
louismarr 22:ef63c41689c2 769 char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14 Max amound of Characters)
louismarr 22:ef63c41689c2 770
louismarr 22:ef63c41689c2 771 int length = sprintf(buffer,"T=%.2F 'C",T); // print the temperature from the float variable T
louismarr 22:ef63c41689c2 772 if (length <= 14); // Ensuring string will fit on the screen (Printing at x=0)
louismarr 22:ef63c41689c2 773 lcd.printString(buffer,18,0); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 22:ef63c41689c2 774 //serial.printf(" T = %f C\n",T); // Debugging Print
louismarr 22:ef63c41689c2 775
louismarr 22:ef63c41689c2 776 length = sprintf(buffer,"SP=%.2f 'C",SP_0); // print the Setpoint from the Setpoint Variable
louismarr 22:ef63c41689c2 777 if (length <= 14) // Ensuring string will fit on the screen (Printing at x=0)
louismarr 22:ef63c41689c2 778 lcd.printString(buffer,13,1); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 22:ef63c41689c2 779 //serial.printf(" T = %f C\n",SP_1); // Debugging Print
louismarr 13:70f02d5e56f5 780 }
louismarr 22:ef63c41689c2 781 void HtgClg_Pg0()
louismarr 22:ef63c41689c2 782 {
louismarr 22:ef63c41689c2 783 /** Water Temperature Control
louismarr 22:ef63c41689c2 784 * Control Mode which enables LED's if the temperature goes outside
louismarr 22:ef63c41689c2 785 * of the +/- Setpoint Tolerance.
louismarr 22:ef63c41689c2 786 * Dependant on the Mode Application will depend on which setpoint is
louismarr 22:ef63c41689c2 787 * selected from the Setpoint Array
louismarr 22:ef63c41689c2 788 */
louismarr 22:ef63c41689c2 789
louismarr 22:ef63c41689c2 790 Setpoint[3] = SetP * 100; // Use Potentiometer for custom setpoint and assign value into the array
louismarr 20:3bc5958190cd 791
louismarr 22:ef63c41689c2 792 float T = Tmp.get_temperature(); // Reading Temperature as a floating variable
louismarr 22:ef63c41689c2 793 float SP_0 = Setpoint[3]; // Reading the Mode Setpoint from the Array
louismarr 22:ef63c41689c2 794 if (T > SP_0+1){ // If Temp is above the setpoint
louismarr 22:ef63c41689c2 795 Clg_LED = 0; // Enable the Cooling LED
louismarr 22:ef63c41689c2 796 Htg_LED = 1; // Disable other LED's
louismarr 22:ef63c41689c2 797 Ready_LED = 1;
louismarr 22:ef63c41689c2 798 //serial.printf("Cooling"); // Debugging Print
louismarr 22:ef63c41689c2 799 }
louismarr 22:ef63c41689c2 800 else if (T < SP_0-1){ // If Temp is below the setpoint
louismarr 22:ef63c41689c2 801 Htg_LED = 0; // Enable the Heating LED
louismarr 22:ef63c41689c2 802 Clg_LED = 1; // Disable other LED's
louismarr 22:ef63c41689c2 803 Ready_LED = 1;
louismarr 22:ef63c41689c2 804 //serial.printf("Heating"); // Debugging Print
louismarr 22:ef63c41689c2 805 }
louismarr 22:ef63c41689c2 806 else { // If none of the conditions are satisfied
louismarr 22:ef63c41689c2 807 Clg_LED = 1; // Disable Heating & cooling LED's
louismarr 22:ef63c41689c2 808 Htg_LED = 1;
louismarr 22:ef63c41689c2 809 }
louismarr 22:ef63c41689c2 810 }
louismarr 22:ef63c41689c2 811 void T_SP_Pg1()
louismarr 22:ef63c41689c2 812 {
louismarr 22:ef63c41689c2 813 /** Mode Select = Washing Water
louismarr 22:ef63c41689c2 814 * When a new mode is selected the LCD screen will update in order
louismarr 22:ef63c41689c2 815 * to assist the user with the water temperature in order to provide
louismarr 22:ef63c41689c2 816 * Assistance, Safety and Comfort
louismarr 22:ef63c41689c2 817 */
louismarr 22:ef63c41689c2 818
louismarr 22:ef63c41689c2 819 float T = Tmp.get_temperature(); // Reading Temperature as a floating variable
louismarr 22:ef63c41689c2 820 float SP_1 = Setpoint[1]; // Reading the Mode Setpoint from the Array
louismarr 22:ef63c41689c2 821 char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14 Max amound of Characters)
louismarr 22:ef63c41689c2 822
louismarr 22:ef63c41689c2 823 int length = sprintf(buffer,"T=%.2F 'C",T); // print the temperature from the float variable T
louismarr 22:ef63c41689c2 824 if (length <= 14); // Ensuring string will fit on the screen (Printing at x=0)
louismarr 22:ef63c41689c2 825 lcd.printString(buffer,18,0); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 22:ef63c41689c2 826 //serial.printf(" T = %f C\n",T); // Debugging Print
louismarr 20:3bc5958190cd 827
louismarr 20:3bc5958190cd 828 length = sprintf(buffer,"SP=%.2f 'C",SP_1); // print the Setpoint from the Setpoint Variable
louismarr 22:ef63c41689c2 829 if (length <= 14) // Ensuring string will fit on the screen (Printing at x=0)
louismarr 22:ef63c41689c2 830 lcd.printString(buffer,13,1); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 22:ef63c41689c2 831 //serial.printf(" T = %f C\n",SP_1); // Debugging Print
louismarr 20:3bc5958190cd 832 }
louismarr 20:3bc5958190cd 833 void HtgClg_Pg1()
louismarr 20:3bc5958190cd 834 {
louismarr 20:3bc5958190cd 835 /** Water Temperature Control
louismarr 20:3bc5958190cd 836 * Control Mode which enables LED's if the temperature goes outside
louismarr 20:3bc5958190cd 837 * of the +/- Setpoint Tolerance.
louismarr 20:3bc5958190cd 838 * Dependant on the Mode Application will depend on which setpoint is
louismarr 20:3bc5958190cd 839 * selected from the Setpoint Array
louismarr 20:3bc5958190cd 840 */
louismarr 22:ef63c41689c2 841
louismarr 22:ef63c41689c2 842 float T = Tmp.get_temperature(); // Reading Temperature as a floating variable
louismarr 22:ef63c41689c2 843 float SP_1 = Setpoint[1]; // Reading the Mode Setpoint from the Array
louismarr 22:ef63c41689c2 844 if (T > SP_1+2){ // If Temp is above the setpoint
louismarr 22:ef63c41689c2 845 Clg_LED = 0; // Enable the Cooling LED
louismarr 22:ef63c41689c2 846 Htg_LED = 1; // Disable other LED's
louismarr 20:3bc5958190cd 847 Ready_LED = 1;
louismarr 22:ef63c41689c2 848 //serial.printf("Cooling"); // Debugging Print
louismarr 20:3bc5958190cd 849 }
louismarr 22:ef63c41689c2 850 else if (T < SP_1-2){ // If Temp is below the setpoint
louismarr 22:ef63c41689c2 851 Htg_LED = 0; // Enable the Heating LED
louismarr 22:ef63c41689c2 852 Clg_LED = 1; // Disable other LED's
louismarr 20:3bc5958190cd 853 Ready_LED = 1;
louismarr 22:ef63c41689c2 854 //serial.printf("Heating"); // Debugging Print
louismarr 20:3bc5958190cd 855 }
louismarr 22:ef63c41689c2 856 else { // If none of the conditions are satisfied
louismarr 22:ef63c41689c2 857 Clg_LED = 1; // Disable Heating & cooling LED's
louismarr 20:3bc5958190cd 858 Htg_LED = 1;
louismarr 20:3bc5958190cd 859 }
louismarr 20:3bc5958190cd 860 }
louismarr 18:8e025b809dfb 861 void T_SP_Pg2()
louismarr 18:8e025b809dfb 862 {
louismarr 22:ef63c41689c2 863 /** Mode Select = Drinking Water
louismarr 19:00cdcf5a5b7a 864 * When a new mode is selected the LCD screen will update in order
louismarr 20:3bc5958190cd 865 * to assist the user with the water temperature in order to provide
louismarr 20:3bc5958190cd 866 * Assistance, Safety and Comfort
louismarr 19:00cdcf5a5b7a 867 */
louismarr 22:ef63c41689c2 868
louismarr 22:ef63c41689c2 869 float T = Tmp.get_temperature(); // Reading Temperature as a floating variable
louismarr 22:ef63c41689c2 870 float SP_2 = Setpoint[2]; // Reading the Mode Setpoint from the Array
louismarr 22:ef63c41689c2 871 char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14 Max amound of Characters)
louismarr 18:8e025b809dfb 872
louismarr 22:ef63c41689c2 873 int length = sprintf(buffer,"T=%.2F 'C",T); // print the temperature from the float variable T
louismarr 22:ef63c41689c2 874 if (length <= 14); // Ensuring string will fit on the screen (Printing at x=0)
louismarr 22:ef63c41689c2 875 lcd.printString(buffer,18,0); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 22:ef63c41689c2 876 //serial.printf(" T = %f C\n",T); // Debugging Print
louismarr 19:00cdcf5a5b7a 877
louismarr 20:3bc5958190cd 878 length = sprintf(buffer,"SP=%.2f 'C",SP_2); // print the Setpoint from the Setpoint Variable
louismarr 22:ef63c41689c2 879 if (length <= 14) // Ensuring string will fit on the screen (Printing at x=0)
louismarr 22:ef63c41689c2 880 lcd.printString(buffer,13,1); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 22:ef63c41689c2 881 //serial.printf(" T = %f C\n",SP_2); // Debugging Print
louismarr 18:8e025b809dfb 882 }
louismarr 18:8e025b809dfb 883 void HtgClg_Pg2()
louismarr 16:648f9012c47a 884 {
louismarr 19:00cdcf5a5b7a 885 /** Water Temperature Control
louismarr 19:00cdcf5a5b7a 886 * Control Mode which enables LED's if the temperature goes outside
louismarr 20:3bc5958190cd 887 * of the +/- Setpoint Tolerance.
louismarr 20:3bc5958190cd 888 * Dependant on the Mode Application will depend on which setpoint is
louismarr 20:3bc5958190cd 889 * selected from the Setpoint Array
louismarr 19:00cdcf5a5b7a 890 */
louismarr 22:ef63c41689c2 891
louismarr 22:ef63c41689c2 892 float T = Tmp.get_temperature(); // Reading Temperature as a floating variable
louismarr 22:ef63c41689c2 893 float SP_2 = Setpoint[2]; // Reading the Mode Setpoint from the Array
louismarr 20:3bc5958190cd 894 if (T > SP_2+1){ // If Temp is above the setpoint
louismarr 22:ef63c41689c2 895 Clg_LED = 0; // Enable the Cooling LED
louismarr 22:ef63c41689c2 896 Htg_LED = 1; // Disable other LED's
louismarr 18:8e025b809dfb 897 Ready_LED = 1;
louismarr 22:ef63c41689c2 898 //serial.printf("Cooling"); // Debugging Print
louismarr 19:00cdcf5a5b7a 899 }
louismarr 20:3bc5958190cd 900 else if (T < SP_2-1){ // If Temp is below the setpoint
louismarr 22:ef63c41689c2 901 Htg_LED = 0; // Enable the Heating LED
louismarr 22:ef63c41689c2 902 Clg_LED = 1; // Disable other LED's
louismarr 18:8e025b809dfb 903 Ready_LED = 1;
louismarr 22:ef63c41689c2 904 //serial.printf("Heating"); // Debugging Print
louismarr 19:00cdcf5a5b7a 905 }
louismarr 22:ef63c41689c2 906 else { // If none of the conditions are satisfied
louismarr 22:ef63c41689c2 907 Clg_LED = 1; // Disable Heating & cooling LED's
louismarr 20:3bc5958190cd 908 Htg_LED = 1;
louismarr 19:00cdcf5a5b7a 909 }
louismarr 21:bf02fb9876b3 910 }
louismarr 21:bf02fb9876b3 911 void T_SP_Pg3()
louismarr 21:bf02fb9876b3 912 {
louismarr 22:ef63c41689c2 913 /** Mode Select = Boiling water
louismarr 21:bf02fb9876b3 914 * When a new mode is selected the LCD screen will update in order
louismarr 21:bf02fb9876b3 915 * to assist the user with the water temperature in order to provide
louismarr 21:bf02fb9876b3 916 * Assistance, Safety and Comfort
louismarr 21:bf02fb9876b3 917 */
louismarr 22:ef63c41689c2 918
louismarr 22:ef63c41689c2 919 float T = Tmp.get_temperature(); // Reading Temperature as a floating variable
louismarr 22:ef63c41689c2 920 float SP_3 = Setpoint[2]; // Reading the Mode Setpoint from the Array
louismarr 22:ef63c41689c2 921 char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14 Max amound of Characters)
louismarr 21:bf02fb9876b3 922
louismarr 22:ef63c41689c2 923 int length = sprintf(buffer,"T=%.2F 'C",T); // print the temperature from the float variable T
louismarr 22:ef63c41689c2 924 if (length <= 14); // Ensuring string will fit on the screen (Printing at x=0)
louismarr 22:ef63c41689c2 925 lcd.printString(buffer,18,0); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 22:ef63c41689c2 926 //serial.printf(" T = %f C\n",T); // Debugging Print
louismarr 21:bf02fb9876b3 927
louismarr 21:bf02fb9876b3 928 length = sprintf(buffer,"SP=%.2f 'C",SP_3); // print the Setpoint from the Setpoint Variable
louismarr 22:ef63c41689c2 929 if (length <= 14) // Ensuring string will fit on the screen (Printing at x=0)
louismarr 22:ef63c41689c2 930 lcd.printString(buffer,13,1); // Display string on screen, Determine Co-ordinates (..,Column, Row)
louismarr 22:ef63c41689c2 931 //serial.printf(" T = %f C\n",SP_3); // Debugging Print
louismarr 21:bf02fb9876b3 932 }
louismarr 21:bf02fb9876b3 933 void HtgClg_Pg3()
louismarr 21:bf02fb9876b3 934 {
louismarr 21:bf02fb9876b3 935 /** Water Temperature Control
louismarr 21:bf02fb9876b3 936 * Control Mode which enables LED's if the temperature goes outside
louismarr 21:bf02fb9876b3 937 * of the +/- Setpoint Tolerance.
louismarr 21:bf02fb9876b3 938 * Dependant on the Mode Application will depend on which setpoint is
louismarr 21:bf02fb9876b3 939 * selected from the Setpoint Array
louismarr 21:bf02fb9876b3 940 */
louismarr 22:ef63c41689c2 941
louismarr 22:ef63c41689c2 942 float T = Tmp.get_temperature(); // Reading Temperature as a floating variable
louismarr 21:bf02fb9876b3 943 float SP_3 = Setpoint[2]; // Reading the Mode Setpoint from the Array
louismarr 21:bf02fb9876b3 944 if (T > SP_3+1){ // If Temp is above the setpoint
louismarr 22:ef63c41689c2 945 Clg_LED = 0; // Enable the Cooling LED
louismarr 22:ef63c41689c2 946 Htg_LED = 1; // Disable other LED's
louismarr 21:bf02fb9876b3 947 Ready_LED = 1;
louismarr 22:ef63c41689c2 948 //serial.printf("Cooling"); // Debugging Print
louismarr 21:bf02fb9876b3 949 }
louismarr 21:bf02fb9876b3 950 else if (T < SP_3-1){ // If Temp is below the setpoint
louismarr 22:ef63c41689c2 951 Htg_LED = 0; // Enable the Heating LED
louismarr 22:ef63c41689c2 952 Clg_LED = 1; // Disable other LED's
louismarr 21:bf02fb9876b3 953 Ready_LED = 1;
louismarr 22:ef63c41689c2 954 //serial.printf("Heating"); // Debugging Print
louismarr 21:bf02fb9876b3 955 }
louismarr 22:ef63c41689c2 956 else { // If none of the conditions are satisfied
louismarr 22:ef63c41689c2 957 Clg_LED = 1; // Disable Heating & cooling LED's
louismarr 21:bf02fb9876b3 958 Htg_LED = 1;
louismarr 21:bf02fb9876b3 959 }
louismarr 23:655780ba2686 960 }=======
louismarr 23:655780ba2686 961 >>>>>>> merge rev