Rev 1.6 - Sample Period Work in progress

Dependencies:   mbed Bitmap N5110 TMP102 Joystick

Committer:
louismarr
Date:
Sat Jan 22 11:49:28 2022 +0000
Revision:
16:648f9012c47a
Parent:
14:fa5f83f26ed7
Child:
17:be8dd797e60b
2.1.1;

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 7:ef1dab708752 14 #include "mbed.h" // Mbed OS Library
louismarr 7:ef1dab708752 15 #include "TMP102.h" // TMP102 Header File
louismarr 7:ef1dab708752 16 #include "N5110.h" // N5110 Header File
louismarr 7:ef1dab708752 17 #include "Bitmap.h" // Bitmap Header File
louismarr 12:1c821d6d50f9 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 7:ef1dab708752 25 TMP102 tmp102(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 7:ef1dab708752 28 AnalogIn SP(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 9:77a6ea988e01 31 //Timer timer(); // USE FOR LOGGING BETWEEN 0-10s
louismarr 13:70f02d5e56f5 32 Ticker joystickDelay;
louismarr 7:ef1dab708752 33
louismarr 7:ef1dab708752 34 DigitalOut RED_led(LED_RED); // On-board K64F LED'S
louismarr 7:ef1dab708752 35 DigitalOut GRN_led(LED_GREEN);
louismarr 7:ef1dab708752 36 DigitalOut BLU_led(LED_BLUE);
louismarr 7:ef1dab708752 37
louismarr 7:ef1dab708752 38 InterruptIn sw2(SW2); // On-board K64F Switches
louismarr 5:138a91e25e1c 39 InterruptIn sw3(SW3);
louismarr 9:77a6ea988e01 40 InterruptIn R(PTB3); // Right Bumper Button
louismarr 9:77a6ea988e01 41 InterruptIn L(PTB18); // Left Bumper Button
louismarr 13:70f02d5e56f5 42 InterruptIn A(PTB9); // Right Bumper Button
louismarr 13:70f02d5e56f5 43 InterruptIn Y(PTC12); // Left Bumper Button
louismarr 0:f8a8c6a8a5c3 44
louismarr 9:77a6ea988e01 45 volatile int g_R_flag = 0; // g_ in order to show it is a global variable.
louismarr 9:77a6ea988e01 46 volatile int g_L_flag = 0; // volatile flag as it will change within the isr
louismarr 13:70f02d5e56f5 47 volatile int g_A_flag = 0; // g_ in order to show it is a global variable.
louismarr 16:648f9012c47a 48 volatile int g_Y_flag = 0;
louismarr 16:648f9012c47a 49 //volatile int Setpoint
louismarr 7:ef1dab708752 50 /*======================= Void Declaration ===================================*/
louismarr 7:ef1dab708752 51 void error(); // Error Hang Code Function
louismarr 7:ef1dab708752 52 void init_serial(); // Setup serial port Function
louismarr 7:ef1dab708752 53 void init_K64F(); // K64F Disabling Onboard Components Function
louismarr 9:77a6ea988e01 54 void R_isr();
louismarr 9:77a6ea988e01 55 void L_isr();
louismarr 13:70f02d5e56f5 56 void A_isr();
louismarr 13:70f02d5e56f5 57 void Y_isr();
louismarr 10:d98b2dd7ba09 58 void info();
louismarr 12:1c821d6d50f9 59 void temp_SP();
louismarr 14:fa5f83f26ed7 60 void MenuNav();
louismarr 13:70f02d5e56f5 61 void Page1();
louismarr 13:70f02d5e56f5 62 void Page2();
louismarr 16:648f9012c47a 63 void BP();
louismarr 16:648f9012c47a 64 void SP_Array();
louismarr 7:ef1dab708752 65 /*======================== Main Function =====================================*/
louismarr 0:f8a8c6a8a5c3 66 int main()
louismarr 0:f8a8c6a8a5c3 67 {
louismarr 6:117edd5dc0a0 68
louismarr 7:ef1dab708752 69 init_K64F(); // Initialise K64F Board
louismarr 7:ef1dab708752 70 init_serial(); // Initialise Serial Port
louismarr 7:ef1dab708752 71 tmp102.init(); // Initialise Temp Sensor
louismarr 7:ef1dab708752 72 lcd.init(); // Initialise LCD
louismarr 12:1c821d6d50f9 73 Joystick.init();
louismarr 16:648f9012c47a 74
louismarr 9:77a6ea988e01 75 lcd.setContrast(0.4); // Setup the contrast for the LCD Screen
louismarr 9:77a6ea988e01 76 R.fall(&R_isr);
louismarr 9:77a6ea988e01 77 R.mode(PullDown);
louismarr 9:77a6ea988e01 78
louismarr 9:77a6ea988e01 79 L.fall(&L_isr);
louismarr 9:77a6ea988e01 80 L.mode(PullDown);
louismarr 0:f8a8c6a8a5c3 81
louismarr 13:70f02d5e56f5 82 A.fall(&A_isr);
louismarr 13:70f02d5e56f5 83 A.mode(PullDown);
louismarr 13:70f02d5e56f5 84
louismarr 13:70f02d5e56f5 85 Y.fall(&Y_isr);
louismarr 13:70f02d5e56f5 86 Y.mode(PullDown);
louismarr 13:70f02d5e56f5 87
louismarr 12:1c821d6d50f9 88 while (1) {
louismarr 8:9c5ef970de26 89 //timer.start();
louismarr 8:9c5ef970de26 90 //for(i = 0; i < 10; i++){
louismarr 5:138a91e25e1c 91 // read temperature and print over serial port
louismarr 13:70f02d5e56f5 92
louismarr 13:70f02d5e56f5 93
louismarr 14:fa5f83f26ed7 94 MenuNav(); // Call the info function
louismarr 13:70f02d5e56f5 95 Page1();
louismarr 13:70f02d5e56f5 96 Page2();
louismarr 13:70f02d5e56f5 97 temp_SP();
louismarr 13:70f02d5e56f5 98
louismarr 12:1c821d6d50f9 99
louismarr 0:f8a8c6a8a5c3 100 }
louismarr 13:70f02d5e56f5 101
louismarr 9:77a6ea988e01 102 }
louismarr 13:70f02d5e56f5 103
louismarr 5:138a91e25e1c 104
louismarr 7:ef1dab708752 105 /*
louismarr 7:ef1dab708752 106 =========================== Void Setup =========================================
louismarr 7:ef1dab708752 107 Custom Function's are called Void's, which are called upon inside the of the
louismarr 7:ef1dab708752 108 Main Function Code
louismarr 7:ef1dab708752 109 */
louismarr 0:f8a8c6a8a5c3 110
louismarr 0:f8a8c6a8a5c3 111 void init_serial() {
louismarr 9:77a6ea988e01 112 // Baud Rate Communication for CoolTerm Debugging
louismarr 7:ef1dab708752 113 serial.baud(9600);
louismarr 0:f8a8c6a8a5c3 114 }
louismarr 0:f8a8c6a8a5c3 115
louismarr 5:138a91e25e1c 116 void init_K64F()
louismarr 0:f8a8c6a8a5c3 117 {
louismarr 7:ef1dab708752 118 // on-board LEDs are active when 0, so setting the pin to 1 turns them off.
louismarr 7:ef1dab708752 119 RED_led = 1;
louismarr 7:ef1dab708752 120 GRN_led = 1;
louismarr 9:77a6ea988e01 121 BLU_led = 1;
louismarr 9:77a6ea988e01 122 /* since the on-board switches have external pull-ups, disable the
louismarr 9:77a6ea988e01 123 * internal pull-down resistors that are enabled by default using
louismarr 9:77a6ea988e01 124 * the InterruptIn Command */
louismarr 5:138a91e25e1c 125 sw2.mode(PullNone);
louismarr 5:138a91e25e1c 126 sw3.mode(PullNone);
louismarr 9:77a6ea988e01 127 }
louismarr 0:f8a8c6a8a5c3 128
louismarr 9:77a6ea988e01 129 void R_isr() // Right Bumper Interrupt Service
louismarr 9:77a6ea988e01 130 {
louismarr 9:77a6ea988e01 131 g_R_flag = 1; // set flag in ISR
louismarr 0:f8a8c6a8a5c3 132 }
louismarr 9:77a6ea988e01 133
louismarr 9:77a6ea988e01 134 void L_isr() // Left Bumper Interrupt Service
louismarr 9:77a6ea988e01 135 {
louismarr 9:77a6ea988e01 136 g_L_flag = 1; // set flag in ISR
louismarr 9:77a6ea988e01 137 }
louismarr 13:70f02d5e56f5 138 void A_isr() // Left Bumper Interrupt Service
louismarr 13:70f02d5e56f5 139 {
louismarr 13:70f02d5e56f5 140 g_A_flag = 1; // set flag in ISR
louismarr 13:70f02d5e56f5 141 }
louismarr 13:70f02d5e56f5 142 void Y_isr() // Left Bumper Interrupt Service
louismarr 13:70f02d5e56f5 143 {
louismarr 13:70f02d5e56f5 144 g_Y_flag = 1; // set flag in ISR
louismarr 13:70f02d5e56f5 145 }
louismarr 10:d98b2dd7ba09 146 void info()
louismarr 10:d98b2dd7ba09 147 {
louismarr 14:fa5f83f26ed7 148
louismarr 10:d98b2dd7ba09 149 serial.printf(" Information Page Selected "); // Debugging Print
louismarr 10:d98b2dd7ba09 150 lcd.clear(); // Clear Screen
louismarr 10:d98b2dd7ba09 151 lcd.printString("Info Page",0,0); // Print Information Screen
louismarr 10:d98b2dd7ba09 152 lcd.printString("Author:",0,1);
louismarr 10:d98b2dd7ba09 153 lcd.printString("Louis M",0,2);
louismarr 10:d98b2dd7ba09 154 lcd.printString("18689006",0,3);
louismarr 13:70f02d5e56f5 155 lcd.printString("Version 1.9.1",0,4);
louismarr 14:fa5f83f26ed7 156 lcd.refresh();
louismarr 14:fa5f83f26ed7 157 wait(1);
louismarr 12:1c821d6d50f9 158 }
louismarr 12:1c821d6d50f9 159 void Page1()
louismarr 7:ef1dab708752 160 {
louismarr 12:1c821d6d50f9 161 serial.printf(" Page 1 "); // Debugging Print
louismarr 12:1c821d6d50f9 162 lcd.clear(); // Clear Screen
louismarr 14:fa5f83f26ed7 163 lcd.printString("< Page 1 >",0,0); // Print Information Screen
louismarr 12:1c821d6d50f9 164 lcd.printString("Temperature",0,1);
louismarr 12:1c821d6d50f9 165 lcd.printString("Logging",0,2);
louismarr 14:fa5f83f26ed7 166 lcd.printString("Press A",0,3);
louismarr 14:fa5f83f26ed7 167
louismarr 13:70f02d5e56f5 168 lcd.refresh();
louismarr 14:fa5f83f26ed7 169 wait(1);
louismarr 16:648f9012c47a 170 if (g_A_flag){ // Condition to change over into new loop
louismarr 16:648f9012c47a 171 g_A_flag = 0; // When the R Flag has been pressed
louismarr 16:648f9012c47a 172 A.rise(&A_isr);
louismarr 16:648f9012c47a 173 serial.printf("A Pressed");
louismarr 16:648f9012c47a 174 temp_SP();
louismarr 16:648f9012c47a 175 }
louismarr 9:77a6ea988e01 176 }
louismarr 12:1c821d6d50f9 177 void Page2()
louismarr 14:fa5f83f26ed7 178 {
louismarr 12:1c821d6d50f9 179 serial.printf(" Page 2 "); // Debugging Print
louismarr 12:1c821d6d50f9 180 lcd.clear(); // Clear Screen
louismarr 14:fa5f83f26ed7 181 lcd.printString("< Page 2 ",0,0); // Print Information Screen
louismarr 16:648f9012c47a 182 lcd.printString("Outside Air",0,1);
louismarr 16:648f9012c47a 183 lcd.printString(" Recommends ",0,2);
louismarr 14:fa5f83f26ed7 184 lcd.printString("Press A",0,3);
louismarr 14:fa5f83f26ed7 185
louismarr 13:70f02d5e56f5 186 lcd.refresh();
louismarr 14:fa5f83f26ed7 187 wait(1);
louismarr 16:648f9012c47a 188 if (g_R_flag){ // Condition to change over into new loop
louismarr 16:648f9012c47a 189 g_R_flag = 0; // When the R Flag has been pressed
louismarr 16:648f9012c47a 190 R.rise(&R_isr);
louismarr 16:648f9012c47a 191 serial.printf("A Pressed");
louismarr 16:648f9012c47a 192 BP();
louismarr 16:648f9012c47a 193 wait(1);
louismarr 16:648f9012c47a 194 }
louismarr 14:fa5f83f26ed7 195 }
louismarr 12:1c821d6d50f9 196 void temp_SP()
louismarr 12:1c821d6d50f9 197 {
louismarr 13:70f02d5e56f5 198
louismarr 12:1c821d6d50f9 199 float T = tmp102.get_temperature(); // Reading Temperature as a floating variable
louismarr 12:1c821d6d50f9 200 float Set = SP * 100; // Reading Potentiometer as a floating variable. Multiplied by 100 to give larger range
louismarr 12:1c821d6d50f9 201
louismarr 12:1c821d6d50f9 202 lcd.clear(); // clearing the LCD buffer at the begining of the loop
louismarr 12:1c821d6d50f9 203 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 204 char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14 Max amound of Characters)
louismarr 13:70f02d5e56f5 205 Direction d = Joystick.get_direction();
louismarr 12:1c821d6d50f9 206
louismarr 12:1c821d6d50f9 207 int length = sprintf(buffer,"T=%.2F 'C",T); // print the temperature from the float variable T
louismarr 12:1c821d6d50f9 208 if (length <= 14) // Ensuring string will fit on the screen (Printing at x=0)
louismarr 12:1c821d6d50f9 209 lcd.printString(buffer,0,1); // display on screen
louismarr 12:1c821d6d50f9 210 serial.printf("T = %f C\n",T); // Printing the Temperature over Serial Port
louismarr 12:1c821d6d50f9 211
louismarr 12:1c821d6d50f9 212 length = sprintf(buffer,"SP=%.2F 'C",Set); // Print the Setpoint from the Float Variable Set
louismarr 12:1c821d6d50f9 213 if (length <= 14) // Ensuring string will fit on the screen (Printing at x=0)
louismarr 12:1c821d6d50f9 214 lcd.printString(buffer,0,2); // display on screen
louismarr 12:1c821d6d50f9 215 serial.printf(" SP = %f", Set); //
louismarr 13:70f02d5e56f5 216 lcd.refresh();
louismarr 13:70f02d5e56f5 217 wait(1);
louismarr 12:1c821d6d50f9 218 if (Set < T){ // Condition to change over into new loop
louismarr 12:1c821d6d50f9 219 lcd.clear(); // clearing the LCD buffer at the begining of the loop
louismarr 12:1c821d6d50f9 220 lcd.printString("Over Heating",3,2); // Print New Message
louismarr 12:1c821d6d50f9 221 serial.printf("OverTemp"); // Debugging Print
louismarr 13:70f02d5e56f5 222 lcd.refresh();
louismarr 13:70f02d5e56f5 223 wait(1);
louismarr 13:70f02d5e56f5 224 }
louismarr 14:fa5f83f26ed7 225
louismarr 12:1c821d6d50f9 226 }
louismarr 14:fa5f83f26ed7 227 void MenuNav()
louismarr 14:fa5f83f26ed7 228 {
louismarr 14:fa5f83f26ed7 229 lcd.clear();
louismarr 14:fa5f83f26ed7 230 lcd.refresh();
louismarr 14:fa5f83f26ed7 231
louismarr 14:fa5f83f26ed7 232 int select = 0;
louismarr 13:70f02d5e56f5 233 while (1){
louismarr 13:70f02d5e56f5 234
louismarr 14:fa5f83f26ed7 235
louismarr 13:70f02d5e56f5 236 //serial.printf("Direction = %i ",d);
louismarr 14:fa5f83f26ed7 237 Direction d = Joystick.get_direction();
louismarr 14:fa5f83f26ed7 238
louismarr 13:70f02d5e56f5 239 //while (1) {
louismarr 12:1c821d6d50f9 240 switch(select) {
louismarr 12:1c821d6d50f9 241 case 0:
louismarr 12:1c821d6d50f9 242 switch(d) {
louismarr 14:fa5f83f26ed7 243 case W:
louismarr 14:fa5f83f26ed7 244 wait(0.5);
louismarr 14:fa5f83f26ed7 245 select = 0;
louismarr 14:fa5f83f26ed7 246 serial.printf("LEFT.0");
louismarr 12:1c821d6d50f9 247 break;
louismarr 14:fa5f83f26ed7 248 case E:
louismarr 14:fa5f83f26ed7 249 wait(0.5);
louismarr 14:fa5f83f26ed7 250 select = 1;
louismarr 14:fa5f83f26ed7 251 serial.printf("RIGHT.0");
louismarr 12:1c821d6d50f9 252 break;
louismarr 12:1c821d6d50f9 253 }
louismarr 14:fa5f83f26ed7 254 break;
louismarr 12:1c821d6d50f9 255 case 1:
louismarr 12:1c821d6d50f9 256 switch(d) {
louismarr 14:fa5f83f26ed7 257 case W:
louismarr 14:fa5f83f26ed7 258 wait(0.5);
louismarr 14:fa5f83f26ed7 259 select = 0;
louismarr 14:fa5f83f26ed7 260 serial.printf("LEFT.1");
louismarr 12:1c821d6d50f9 261 break;
louismarr 14:fa5f83f26ed7 262 case E:
louismarr 14:fa5f83f26ed7 263 wait(0.5);
louismarr 14:fa5f83f26ed7 264 select = 2;
louismarr 14:fa5f83f26ed7 265 serial.printf("RIGHT.1");
louismarr 12:1c821d6d50f9 266 break;
louismarr 14:fa5f83f26ed7 267 }
louismarr 14:fa5f83f26ed7 268 break;
louismarr 12:1c821d6d50f9 269 case 2:
louismarr 12:1c821d6d50f9 270 switch(d) {
louismarr 14:fa5f83f26ed7 271 case W:
louismarr 14:fa5f83f26ed7 272 wait(0.5);
louismarr 14:fa5f83f26ed7 273 select = 1;
louismarr 14:fa5f83f26ed7 274 serial.printf("LEFT.2");
louismarr 12:1c821d6d50f9 275 break;
louismarr 14:fa5f83f26ed7 276 case E:
louismarr 14:fa5f83f26ed7 277 wait(0.5);
louismarr 14:fa5f83f26ed7 278 select = 2;
louismarr 14:fa5f83f26ed7 279 serial.printf("RIGHT.2");
louismarr 12:1c821d6d50f9 280 break;
louismarr 14:fa5f83f26ed7 281 }
louismarr 14:fa5f83f26ed7 282 break;
louismarr 12:1c821d6d50f9 283 }
louismarr 14:fa5f83f26ed7 284 wait(0.1);
louismarr 12:1c821d6d50f9 285
louismarr 12:1c821d6d50f9 286 if (select == 0){
louismarr 12:1c821d6d50f9 287 lcd.clear(); // Clear Screen
louismarr 14:fa5f83f26ed7 288 serial.printf("WelcomeMENU");
louismarr 14:fa5f83f26ed7 289 lcd.printString(" Navigate >",0,0);
louismarr 14:fa5f83f26ed7 290 lcd.printString(" Welcome ",0,2); // Print Information Screen
louismarr 14:fa5f83f26ed7 291 lcd.printString(" Main ",0,3);
louismarr 14:fa5f83f26ed7 292 lcd.printString(" Menu ",0,4);
louismarr 14:fa5f83f26ed7 293 lcd.printString(" Y for Info ",0,5);
louismarr 14:fa5f83f26ed7 294 lcd.refresh();
louismarr 14:fa5f83f26ed7 295 wait(1);
louismarr 14:fa5f83f26ed7 296 }
louismarr 14:fa5f83f26ed7 297 if (g_Y_flag){ // Condition to change over into new loop
louismarr 14:fa5f83f26ed7 298 g_Y_flag = 0; // When the R Flag has been pressed
louismarr 14:fa5f83f26ed7 299 Y.rise(&Y_isr);
louismarr 14:fa5f83f26ed7 300 serial.printf("Y Pressed");
louismarr 14:fa5f83f26ed7 301 info();
louismarr 12:1c821d6d50f9 302 }
louismarr 14:fa5f83f26ed7 303
louismarr 14:fa5f83f26ed7 304 if (select == 1){
louismarr 12:1c821d6d50f9 305 Page1();
louismarr 16:648f9012c47a 306
louismarr 14:fa5f83f26ed7 307 }
louismarr 14:fa5f83f26ed7 308
louismarr 14:fa5f83f26ed7 309 if (select == 2){
louismarr 12:1c821d6d50f9 310 Page2();
louismarr 16:648f9012c47a 311
louismarr 12:1c821d6d50f9 312 }
louismarr 12:1c821d6d50f9 313 }
louismarr 14:fa5f83f26ed7 314 }
louismarr 14:fa5f83f26ed7 315
louismarr 13:70f02d5e56f5 316 void Menu()
louismarr 13:70f02d5e56f5 317 {
louismarr 13:70f02d5e56f5 318 if (g_R_flag){ // Condition to change over into new loop
louismarr 13:70f02d5e56f5 319 g_R_flag = 0; // When the R Flag has been pressed
louismarr 13:70f02d5e56f5 320 R.rise(&R_isr);
louismarr 13:70f02d5e56f5 321
louismarr 13:70f02d5e56f5 322 lcd.clear(); // Clear Screen
louismarr 13:70f02d5e56f5 323 serial.printf("Welcome");
louismarr 13:70f02d5e56f5 324 lcd.printString(" Welcome ",0,1); // Print Information Screen
louismarr 13:70f02d5e56f5 325 lcd.printString("Main Menu",0,3);
louismarr 13:70f02d5e56f5 326 lcd.printString("Page Down",0,5);
louismarr 13:70f02d5e56f5 327 lcd.refresh();
louismarr 13:70f02d5e56f5 328 wait(1);
louismarr 13:70f02d5e56f5 329 }
louismarr 13:70f02d5e56f5 330 }
louismarr 16:648f9012c47a 331 void BP()
louismarr 13:70f02d5e56f5 332 {
louismarr 16:648f9012c47a 333 int Setpoint[4] = {8,37.65,80,65};
louismarr 16:648f9012c47a 334 float BP_SP = Setpoint[0];
louismarr 16:648f9012c47a 335 float T = tmp102.get_temperature(); // Reading Temperature as a floating variable
louismarr 16:648f9012c47a 336 serial.printf("SETPOINT = ",Setpoint[1]);
louismarr 16:648f9012c47a 337 if (T > Setpoint[0]){
louismarr 16:648f9012c47a 338 serial.printf("SP = %.2f \n",BP_SP);
louismarr 16:648f9012c47a 339 lcd.clear();
louismarr 16:648f9012c47a 340 char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14 Max amound of Characters)
louismarr 16:648f9012c47a 341 int length = sprintf(buffer,"SP=%.2f",BP_SP); // print the temperature from the float variable T
louismarr 16:648f9012c47a 342 if (length <= 14) // Ensuring string will fit on the screen (Printing at x=0)
louismarr 16:648f9012c47a 343 lcd.printString(buffer,0,1); // display on screen
louismarr 16:648f9012c47a 344 serial.printf("T = %f C\n",Setpoint[0]);
louismarr 16:648f9012c47a 345 lcd.printString(" Wear ",0,2); // Print Information Screen
louismarr 16:648f9012c47a 346 lcd.printString(" Warm ",0,3);
louismarr 16:648f9012c47a 347 lcd.printString(" Clothing ",0,4);
louismarr 16:648f9012c47a 348 lcd.refresh();
louismarr 16:648f9012c47a 349 wait(1);
louismarr 16:648f9012c47a 350 }
louismarr 16:648f9012c47a 351
louismarr 16:648f9012c47a 352 }
louismarr 16:648f9012c47a 353 void SP_Array()
louismarr 16:648f9012c47a 354 {
louismarr 16:648f9012c47a 355 int Setpoint[4] = {8,37.65,80,65};
louismarr 16:648f9012c47a 356
louismarr 16:648f9012c47a 357 }