![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Rev 1.6 - Sample Period Work in progress
Dependencies: mbed Bitmap N5110 TMP102 Joystick
Diff: main.cpp
- Revision:
- 23:655780ba2686
- Parent:
- 22:ef63c41689c2
- Parent:
- 15:73383333229d
- Child:
- 24:0ae7d800d17d
--- a/main.cpp Fri Jan 28 13:54:13 2022 +0000 +++ b/main.cpp Fri Jan 28 13:55:38 2022 +0000 @@ -32,10 +32,20 @@ DigitalOut GRN_led(LED_GREEN); DigitalOut BLU_led(LED_BLUE); +<<<<<<< working copy DigitalOut Clg_LED(PTA2); // Green LED on PCB for Cooling DigitalOut Ready_LED(PTA1); // Green LED on PCB for when water is ready DigitalOut Htg_LED(PTC3); // Red LED on PCB for Cooling DigitalOut Boil_LED(PTD3); +======= +//DigitalOut Grn1(PTA1); +//DigitalOut Grn2(PTA2); +//DigitalOut Grn3(PTC2); + +//DigitalOut Red1(PTD3); +//DigitalOut Red2(PTC4); +//DigitalOut Red3(PTC3); +>>>>>>> merge rev InterruptIn sw2(SW2); // On-board K64F Switches InterruptIn sw3(SW3); @@ -100,12 +110,20 @@ init_serial(); // Initialise Serial Port Tmp.init(); // Initialise Temp Sensor Libraries lcd.init(); // Initialise LCD +<<<<<<< working copy Joystick.init(); // Initialise Joystick lcd.setContrast(0.4); // Setup the contrast for the LCD Screen R.fall(&R_isr); // Flipping the Interrupt Function R.mode(PullDown); // When the PCB Button is Pulled Down +======= + Joystick.init(); + + lcd.setContrast(0.4); // Setup the contrast for the LCD Screen + R.fall(&R_isr); + R.mode(PullDown); +>>>>>>> merge rev L.fall(&L_isr); L.mode(PullDown); @@ -115,6 +133,7 @@ Y.fall(&Y_isr); Y.mode(PullDown); +<<<<<<< working copy Clg_LED = 1; // Disabling the LED's Ready_LED = 1; @@ -123,6 +142,17 @@ while (1) { MenuNav(); +======= + + while (1) { + + MenuNav(); // Call the info function + Page1(); + Page2(); + temp_SP(); + + +>>>>>>> merge rev } } @@ -268,11 +298,31 @@ } } void Page2() +<<<<<<< working copy { /** Printing Page 2 * Pre-defined Page 2 to be printed when called upon */ +======= +{ + serial.printf(" Page 2 "); // Debugging Print + lcd.clear(); // Clear Screen + lcd.printString("< Page 2 ",0,0); // Print Information Screen + lcd.printString("Outside Air Mode",0,1); + lcd.printString("=",0,2); + lcd.printString("Press A",0,3); + + lcd.refresh(); + wait(1); +} +void temp_SP() +{ + float T = tmp102.get_temperature(); // Reading Temperature as a floating variable + float Set = SP * 100; // Reading Potentiometer as a floating variable. Multiplied by 100 to give larger range +>>>>>>> merge rev + +<<<<<<< working copy //serial.printf(" Page 2 "); // Debugging Print lcd.clear(); // Clear Screen lcd.printString("< Page 2 >",0,0); // Print Information Screen @@ -296,7 +346,19 @@ /** Printing Page 3 * Pre-defined Page 3 to be printed when called upon */ +======= + lcd.clear(); // clearing the LCD buffer at the begining of the loop + 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) + char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14 Max amound of Characters) + Direction d = Joystick.get_direction(); + + int length = sprintf(buffer,"T=%.2F 'C",T); // print the temperature from the float variable T + if (length <= 14) // Ensuring string will fit on the screen (Printing at x=0) + lcd.printString(buffer,0,1); // display on screen + serial.printf("T = %f C\n",T); // Printing the Temperature over Serial Port +>>>>>>> merge rev +<<<<<<< working copy //serial.printf(" Page 3 "); // Debugging Print lcd.clear(); // Clear Screen lcd.printString("< Page 3",0,0); // Print Information Screen @@ -315,8 +377,32 @@ wait(1); } } +======= + length = sprintf(buffer,"SP=%.2F 'C",Set); // Print the Setpoint from the Float Variable Set + if (length <= 14) // Ensuring string will fit on the screen (Printing at x=0) + lcd.printString(buffer,0,2); // display on screen + serial.printf(" SP = %f", Set); // + lcd.refresh(); + wait(10); + if (Set < T){ // Condition to change over into new loop + lcd.clear(); // clearing the LCD buffer at the begining of the loop + lcd.printString("Over Heating",3,2); // Print New Message + serial.printf("OverTemp"); // Debugging Print + lcd.refresh(); + if (g_Y_flag){ // Condition to change over into new loop + g_Y_flag = 0; // When the R Flag has been pressed + Y.rise(&Y_isr); + serial.printf("Y Pressed"); + //Page1(); + wait(3); + } + +} +} +>>>>>>> merge rev void MenuNav() { +<<<<<<< working copy /** Menu Navigation Function * Using the Joystick and a Switch-Case Function Operation * in order to build the menu system that will be printing @@ -327,6 +413,12 @@ lcd.refresh(); // Refresh & Display printed strings to LCD int Mode = 0; // Initialise Mode to 0 +======= + lcd.clear(); + lcd.refresh(); + + int select = 0; +>>>>>>> merge rev while (1){ //serial.printf("Direction = %i ",d); // Debugging Print @@ -348,6 +440,7 @@ } break; // Break out from Loop into Main Switch +<<<<<<< working copy case 1: // Main Initial Case instance - When at Page 1 switch(d) { // Looking at the Joystick Direction for internal switch case W: // If the direction is W (Left) carry out Case W @@ -451,6 +544,25 @@ lcd.printString(" Adjusting ",0,2); // Display string on screen, Determine Co-ordinates (..,Column, Row) lcd.printString(" Water Temp ",0,3); lcd.printString(" Please Wait! ",4,4); +======= + if (select == 2){ + Page2(); + if (g_A_flag){ // Condition to change over into new loop + g_A_flag = 0; // When the R Flag has been pressed + A.rise(&A_isr); + serial.printf("Y Pressed"); + info(); + } + } +} +} +//} +void Menu() +{ + if (g_R_flag){ // Condition to change over into new loop + g_R_flag = 0; // When the R Flag has been pressed + R.rise(&R_isr); +>>>>>>> merge rev lcd.refresh(); // Refresh & Display printed strings to LCD wait(1); @@ -484,6 +596,7 @@ } } } +<<<<<<< working copy void WWtr() { /** Warm Washing Water Mode @@ -844,4 +957,5 @@ Clg_LED = 1; // Disable Heating & cooling LED's Htg_LED = 1; } -} \ No newline at end of file +}======= +>>>>>>> merge rev