![](/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:
- 16:648f9012c47a
- Parent:
- 14:fa5f83f26ed7
- Child:
- 17:be8dd797e60b
diff -r fa5f83f26ed7 -r 648f9012c47a main.cpp --- a/main.cpp Sun Jan 16 17:29:18 2022 +0000 +++ b/main.cpp Sat Jan 22 11:49:28 2022 +0000 @@ -45,7 +45,8 @@ volatile int g_R_flag = 0; // g_ in order to show it is a global variable. volatile int g_L_flag = 0; // volatile flag as it will change within the isr volatile int g_A_flag = 0; // g_ in order to show it is a global variable. -volatile int g_Y_flag = 0; +volatile int g_Y_flag = 0; +//volatile int Setpoint /*======================= Void Declaration ===================================*/ void error(); // Error Hang Code Function void init_serial(); // Setup serial port Function @@ -59,7 +60,8 @@ void MenuNav(); void Page1(); void Page2(); - +void BP(); +void SP_Array(); /*======================== Main Function =====================================*/ int main() { @@ -69,9 +71,7 @@ tmp102.init(); // Initialise Temp Sensor lcd.init(); // Initialise LCD Joystick.init(); - - - + lcd.setContrast(0.4); // Setup the contrast for the LCD Screen R.fall(&R_isr); R.mode(PullDown); @@ -167,18 +167,31 @@ lcd.refresh(); wait(1); + 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("A Pressed"); + temp_SP(); + } } void Page2() { serial.printf(" Page 2 "); // Debugging Print lcd.clear(); // Clear Screen lcd.printString("< Page 2 ",0,0); // Print Information Screen - lcd.printString("Blood Pressure",0,1); - lcd.printString("Logging",0,2); + lcd.printString("Outside Air",0,1); + lcd.printString(" Recommends ",0,2); lcd.printString("Press A",0,3); lcd.refresh(); wait(1); + 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); + serial.printf("A Pressed"); + BP(); + wait(1); + } } void temp_SP() { @@ -190,11 +203,6 @@ 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(); - float B = 0; - if (1){ - float BP = d + 1; - serial.printf("BP = i%",BP); - } // Therefor strings csn not exceed the 14 Character Limit 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) @@ -295,22 +303,12 @@ if (select == 1){ Page1(); - 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("A Pressed"); - temp_SP(); - } + } 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(); - } + } } } @@ -330,12 +328,30 @@ wait(1); } } -/*void BP() +void BP() { - Direction d = Joystick.get_direction(); - float BP = 0; - if (d = 1){ - BP + 1; - serial.printf("BP = i%",BP); - } - */ \ No newline at end of file + int Setpoint[4] = {8,37.65,80,65}; + float BP_SP = Setpoint[0]; + float T = tmp102.get_temperature(); // Reading Temperature as a floating variable + serial.printf("SETPOINT = ",Setpoint[1]); + if (T > Setpoint[0]){ + serial.printf("SP = %.2f \n",BP_SP); + lcd.clear(); + char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14 Max amound of Characters) + int length = sprintf(buffer,"SP=%.2f",BP_SP); // 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",Setpoint[0]); + lcd.printString(" Wear ",0,2); // Print Information Screen + lcd.printString(" Warm ",0,3); + lcd.printString(" Clothing ",0,4); + lcd.refresh(); + wait(1); + } + +} +void SP_Array() +{ + int Setpoint[4] = {8,37.65,80,65}; + +} \ No newline at end of file