Time: 17:33 Date: 10/12/2017 Description: Task 1,7,8 Currently Functioning
Dependencies: BME280 BMP280 TextLCD
Working Repository
LCD_COMMAND.cpp@48:244d6d81bb52, 2018-01-09 (annotated)
- Committer:
- thomasmorris
- Date:
- Tue Jan 09 00:37:01 2018 +0000
- Revision:
- 48:244d6d81bb52
HOLY SHIT IT WORKS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 48:244d6d81bb52 | 1 | #include "LCD_COMMAND.hpp" |
thomasmorris | 48:244d6d81bb52 | 2 | void LCD_Write_Year() |
thomasmorris | 48:244d6d81bb52 | 3 | { |
thomasmorris | 48:244d6d81bb52 | 4 | Time_Lock_Main.lock();//Appling lock for critial section |
thomasmorris | 48:244d6d81bb52 | 5 | if(Log_Value == 1){pc.printf("In LCD_Write_Year Time lock taken\n");} |
thomasmorris | 48:244d6d81bb52 | 6 | time_t Time = time(NULL); |
thomasmorris | 48:244d6d81bb52 | 7 | tm* Time_Pointer = localtime(&Time); |
thomasmorris | 48:244d6d81bb52 | 8 | int Years = 1900 + Time_Pointer->tm_year; |
thomasmorris | 48:244d6d81bb52 | 9 | Time_Lock_Main.unlock();//Releasing lock for critial section |
thomasmorris | 48:244d6d81bb52 | 10 | if(Log_Value == 1){pc.printf("In LCD_Write_Year Time lock released\n");} |
thomasmorris | 48:244d6d81bb52 | 11 | stringstream ss; |
thomasmorris | 48:244d6d81bb52 | 12 | ss << Years; |
thomasmorris | 48:244d6d81bb52 | 13 | string Year_String = ss.str(); |
thomasmorris | 48:244d6d81bb52 | 14 | LCD.DDRAM_Address(0x00); |
thomasmorris | 48:244d6d81bb52 | 15 | LCD.Write_String("Set Year"); |
thomasmorris | 48:244d6d81bb52 | 16 | LCD.DDRAM_Address(0x40); |
thomasmorris | 48:244d6d81bb52 | 17 | LCD.Write_String(Year_String); |
thomasmorris | 48:244d6d81bb52 | 18 | } |
thomasmorris | 48:244d6d81bb52 | 19 | void LCD_Write_Month() |
thomasmorris | 48:244d6d81bb52 | 20 | { |
thomasmorris | 48:244d6d81bb52 | 21 | Time_Lock_Main.lock();//Appling lock for critial section |
thomasmorris | 48:244d6d81bb52 | 22 | if(Log_Value == 1){pc.printf("In LCD_Write_Month Time lock taken\n");} |
thomasmorris | 48:244d6d81bb52 | 23 | time_t Time = time(NULL); |
thomasmorris | 48:244d6d81bb52 | 24 | tm* Time_Pointer = localtime(&Time); |
thomasmorris | 48:244d6d81bb52 | 25 | int Months = 1 + Time_Pointer->tm_mon; |
thomasmorris | 48:244d6d81bb52 | 26 | Time_Lock_Main.unlock();//Releasing lock for critial section |
thomasmorris | 48:244d6d81bb52 | 27 | if(Log_Value == 1){pc.printf("In LCD_Write_Month Time lock released\n");} |
thomasmorris | 48:244d6d81bb52 | 28 | stringstream ss; |
thomasmorris | 48:244d6d81bb52 | 29 | ss << Months; |
thomasmorris | 48:244d6d81bb52 | 30 | string Month_String = ss.str(); |
thomasmorris | 48:244d6d81bb52 | 31 | LCD.DDRAM_Address(0x00); |
thomasmorris | 48:244d6d81bb52 | 32 | LCD.Write_String("Set Month"); |
thomasmorris | 48:244d6d81bb52 | 33 | LCD.DDRAM_Address(0x40); |
thomasmorris | 48:244d6d81bb52 | 34 | LCD.Write_String(Month_String); |
thomasmorris | 48:244d6d81bb52 | 35 | } |
thomasmorris | 48:244d6d81bb52 | 36 | void LCD_Write_Day() |
thomasmorris | 48:244d6d81bb52 | 37 | { |
thomasmorris | 48:244d6d81bb52 | 38 | Time_Lock_Main.lock();//Appling lock for critial section |
thomasmorris | 48:244d6d81bb52 | 39 | if(Log_Value == 1){pc.printf("In LCD_Write_Day Time lock taken\n");} |
thomasmorris | 48:244d6d81bb52 | 40 | time_t Time = time(NULL); |
thomasmorris | 48:244d6d81bb52 | 41 | tm* Time_Pointer = localtime(&Time); |
thomasmorris | 48:244d6d81bb52 | 42 | int Days = Time_Pointer->tm_mday; |
thomasmorris | 48:244d6d81bb52 | 43 | Time_Lock_Main.unlock();//Releasing lock for critial section |
thomasmorris | 48:244d6d81bb52 | 44 | if(Log_Value == 1){pc.printf("In LCD_Write_Day Time lock released\n");} |
thomasmorris | 48:244d6d81bb52 | 45 | stringstream ss; |
thomasmorris | 48:244d6d81bb52 | 46 | ss << Days; |
thomasmorris | 48:244d6d81bb52 | 47 | string Day_String = ss.str(); |
thomasmorris | 48:244d6d81bb52 | 48 | LCD.DDRAM_Address(0x00); |
thomasmorris | 48:244d6d81bb52 | 49 | LCD.Write_String("Set Day"); |
thomasmorris | 48:244d6d81bb52 | 50 | LCD.DDRAM_Address(0x40); |
thomasmorris | 48:244d6d81bb52 | 51 | LCD.Write_String(Day_String); |
thomasmorris | 48:244d6d81bb52 | 52 | } |
thomasmorris | 48:244d6d81bb52 | 53 | void LCD_Write_Hour() |
thomasmorris | 48:244d6d81bb52 | 54 | { |
thomasmorris | 48:244d6d81bb52 | 55 | Time_Lock_Main.lock();//Appling lock for critial section |
thomasmorris | 48:244d6d81bb52 | 56 | if(Log_Value == 1){pc.printf("In LCD_Write_Hour Time lock taken\n");} |
thomasmorris | 48:244d6d81bb52 | 57 | time_t Time = time(NULL); |
thomasmorris | 48:244d6d81bb52 | 58 | tm* Time_Pointer = localtime(&Time); |
thomasmorris | 48:244d6d81bb52 | 59 | int Hours = Time_Pointer->tm_hour; |
thomasmorris | 48:244d6d81bb52 | 60 | Time_Lock_Main.unlock();//Releasing lock for critial section |
thomasmorris | 48:244d6d81bb52 | 61 | if(Log_Value == 1){pc.printf("In LCD_Write_Hour Time lock released\n");} |
thomasmorris | 48:244d6d81bb52 | 62 | stringstream ss; |
thomasmorris | 48:244d6d81bb52 | 63 | ss << Hours; |
thomasmorris | 48:244d6d81bb52 | 64 | string Hour_String = ss.str(); |
thomasmorris | 48:244d6d81bb52 | 65 | LCD.DDRAM_Address(0x00); |
thomasmorris | 48:244d6d81bb52 | 66 | LCD.Write_String("Set Hour"); |
thomasmorris | 48:244d6d81bb52 | 67 | LCD.DDRAM_Address(0x40); |
thomasmorris | 48:244d6d81bb52 | 68 | LCD.Write_String(Hour_String); |
thomasmorris | 48:244d6d81bb52 | 69 | } |
thomasmorris | 48:244d6d81bb52 | 70 | void LCD_Write_Minute() |
thomasmorris | 48:244d6d81bb52 | 71 | { |
thomasmorris | 48:244d6d81bb52 | 72 | Time_Lock_Main.lock();//Appling lock for critial section |
thomasmorris | 48:244d6d81bb52 | 73 | if(Log_Value == 1){pc.printf("In LCD_Write_Minute Time lock taken\n");} |
thomasmorris | 48:244d6d81bb52 | 74 | time_t Time = time(NULL); |
thomasmorris | 48:244d6d81bb52 | 75 | tm* Time_Pointer = localtime(&Time); |
thomasmorris | 48:244d6d81bb52 | 76 | int Minutes = Time_Pointer->tm_min; |
thomasmorris | 48:244d6d81bb52 | 77 | Time_Lock_Main.unlock();//Releasing lock for critial section |
thomasmorris | 48:244d6d81bb52 | 78 | if(Log_Value == 1){pc.printf("In LCD_Write_Minute Time lock released\n");} |
thomasmorris | 48:244d6d81bb52 | 79 | stringstream ss; |
thomasmorris | 48:244d6d81bb52 | 80 | ss << Minutes; |
thomasmorris | 48:244d6d81bb52 | 81 | string Minute_String = ss.str(); |
thomasmorris | 48:244d6d81bb52 | 82 | LCD.DDRAM_Address(0x00); |
thomasmorris | 48:244d6d81bb52 | 83 | LCD.Write_String("Set Minute"); |
thomasmorris | 48:244d6d81bb52 | 84 | LCD.DDRAM_Address(0x40); |
thomasmorris | 48:244d6d81bb52 | 85 | LCD.Write_String(Minute_String); |
thomasmorris | 48:244d6d81bb52 | 86 | } |
thomasmorris | 48:244d6d81bb52 | 87 | void LCD_Write_Seconds() |
thomasmorris | 48:244d6d81bb52 | 88 | { |
thomasmorris | 48:244d6d81bb52 | 89 | Time_Lock_Main.lock();//Appling lock for critial section |
thomasmorris | 48:244d6d81bb52 | 90 | if(Log_Value == 1){pc.printf("In LCD_Write_Seconds Time lock taken\n");} |
thomasmorris | 48:244d6d81bb52 | 91 | time_t Time = time(NULL); |
thomasmorris | 48:244d6d81bb52 | 92 | tm* Time_Pointer = localtime(&Time); |
thomasmorris | 48:244d6d81bb52 | 93 | int Seconds = Time_Pointer->tm_sec; |
thomasmorris | 48:244d6d81bb52 | 94 | Time_Lock_Main.unlock();//Releasing lock for critial section |
thomasmorris | 48:244d6d81bb52 | 95 | if(Log_Value == 1){pc.printf("In LCD_Write_Seconds Time lock released\n");} |
thomasmorris | 48:244d6d81bb52 | 96 | stringstream ss; |
thomasmorris | 48:244d6d81bb52 | 97 | ss << Seconds; |
thomasmorris | 48:244d6d81bb52 | 98 | string Second_String = ss.str(); |
thomasmorris | 48:244d6d81bb52 | 99 | LCD.DDRAM_Address(0x00); |
thomasmorris | 48:244d6d81bb52 | 100 | LCD.Write_String("Set Second"); |
thomasmorris | 48:244d6d81bb52 | 101 | LCD.DDRAM_Address(0x40); |
thomasmorris | 48:244d6d81bb52 | 102 | LCD.Write_String(Second_String); |
thomasmorris | 48:244d6d81bb52 | 103 | } |
thomasmorris | 48:244d6d81bb52 | 104 | |
thomasmorris | 48:244d6d81bb52 | 105 | |
thomasmorris | 48:244d6d81bb52 | 106 | void LCD_Print_Output() |
thomasmorris | 48:244d6d81bb52 | 107 | { |
thomasmorris | 48:244d6d81bb52 | 108 | |
thomasmorris | 48:244d6d81bb52 | 109 | if(mode == 0)//Default mode |
thomasmorris | 48:244d6d81bb52 | 110 | { |
thomasmorris | 48:244d6d81bb52 | 111 | if(Log_Value == 1){pc.printf("In Default Mode\n");} |
thomasmorris | 48:244d6d81bb52 | 112 | |
thomasmorris | 48:244d6d81bb52 | 113 | Thread::wait(Default_Mode_Toggle_Time);//Wait for this amount of time |
thomasmorris | 48:244d6d81bb52 | 114 | if(Log_Value == 1){pc.printf("Writing Data to LCD\n");} |
thomasmorris | 48:244d6d81bb52 | 115 | sprintf (LCD_buffer, "%1.1f %1.0f %1.2f",Data_Active.get_temperature(),Data_Active.get_pressure(),Data_Active.get_light());//Used for converting to a sting |
thomasmorris | 48:244d6d81bb52 | 116 | |
thomasmorris | 48:244d6d81bb52 | 117 | LCD.DDRAM_Address(0x00); |
thomasmorris | 48:244d6d81bb52 | 118 | LCD.Write_String("Temp Pres Lite"); |
thomasmorris | 48:244d6d81bb52 | 119 | LCD.DDRAM_Address(0x40); |
thomasmorris | 48:244d6d81bb52 | 120 | LCD.Write_String(LCD_buffer);//Print out current data values to the LCD |
thomasmorris | 48:244d6d81bb52 | 121 | |
thomasmorris | 48:244d6d81bb52 | 122 | Thread::wait(Default_Mode_Toggle_Time); //Wait for this amount of time |
thomasmorris | 48:244d6d81bb52 | 123 | if(Log_Value == 1){pc.printf("Writing Time and Date to LCD\n");} |
thomasmorris | 48:244d6d81bb52 | 124 | Time_Lock_Main.lock();//lock Time_lock for critial section |
thomasmorris | 48:244d6d81bb52 | 125 | time_t Time = Data_Active.get_time(); |
thomasmorris | 48:244d6d81bb52 | 126 | tm* Time_Pointer = localtime(&Time); |
thomasmorris | 48:244d6d81bb52 | 127 | LCD.Display_Clear(); |
thomasmorris | 48:244d6d81bb52 | 128 | sprintf (LCD_buffer, "%02d:%02d %02d,%d",Time_Pointer->tm_hour,Time_Pointer->tm_min,(Time_Pointer->tm_mon+1),(Time_Pointer->tm_year+1900));//Used for converting to a sting |
thomasmorris | 48:244d6d81bb52 | 129 | Time_Lock_Main.unlock();//unlock Time_lock for critial section |
thomasmorris | 48:244d6d81bb52 | 130 | |
thomasmorris | 48:244d6d81bb52 | 131 | LCD.DDRAM_Address(0x00); |
thomasmorris | 48:244d6d81bb52 | 132 | LCD.Write_String("Current Time:"); |
thomasmorris | 48:244d6d81bb52 | 133 | LCD.DDRAM_Address(0x40); |
thomasmorris | 48:244d6d81bb52 | 134 | LCD.Write_String(LCD_buffer);//Print the current time to the LCD |
thomasmorris | 48:244d6d81bb52 | 135 | |
thomasmorris | 48:244d6d81bb52 | 136 | if(Log_Value == 1){pc.printf("Checking Switches for next mode\n");} |
thomasmorris | 48:244d6d81bb52 | 137 | if(SW1.read() & SW2.read() == 1) |
thomasmorris | 48:244d6d81bb52 | 138 | { |
thomasmorris | 48:244d6d81bb52 | 139 | mode = 1; |
thomasmorris | 48:244d6d81bb52 | 140 | } |
thomasmorris | 48:244d6d81bb52 | 141 | } |
thomasmorris | 48:244d6d81bb52 | 142 | else if(mode == 1)//Choose either date setting or time setting |
thomasmorris | 48:244d6d81bb52 | 143 | { |
thomasmorris | 48:244d6d81bb52 | 144 | if(Log_Value == 1){pc.printf("Choose Time or Date Mode 1\n");} |
thomasmorris | 48:244d6d81bb52 | 145 | LCD.Display_Clear(); |
thomasmorris | 48:244d6d81bb52 | 146 | while(1) |
thomasmorris | 48:244d6d81bb52 | 147 | { |
thomasmorris | 48:244d6d81bb52 | 148 | LCD.DDRAM_Address(0x00); |
thomasmorris | 48:244d6d81bb52 | 149 | LCD.Write_String("Date Time"); |
thomasmorris | 48:244d6d81bb52 | 150 | LCD.DDRAM_Address(0x40); |
thomasmorris | 48:244d6d81bb52 | 151 | LCD.Write_String("< >"); |
thomasmorris | 48:244d6d81bb52 | 152 | Thread::wait(1000); |
thomasmorris | 48:244d6d81bb52 | 153 | if(Log_Value == 1){pc.printf("Checking SW1 to go to Date setting\n");} |
thomasmorris | 48:244d6d81bb52 | 154 | if(SW1.read() == 1 & SW2.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 155 | { |
thomasmorris | 48:244d6d81bb52 | 156 | mode = 2;//Date Setting |
thomasmorris | 48:244d6d81bb52 | 157 | break; |
thomasmorris | 48:244d6d81bb52 | 158 | } |
thomasmorris | 48:244d6d81bb52 | 159 | if(Log_Value == 1){pc.printf("Checking SW2 to go to Time setting\n");} |
thomasmorris | 48:244d6d81bb52 | 160 | if(SW2.read() == 1 & SW1.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 161 | { |
thomasmorris | 48:244d6d81bb52 | 162 | mode = 5;//Time Setting |
thomasmorris | 48:244d6d81bb52 | 163 | break; |
thomasmorris | 48:244d6d81bb52 | 164 | } |
thomasmorris | 48:244d6d81bb52 | 165 | } |
thomasmorris | 48:244d6d81bb52 | 166 | } |
thomasmorris | 48:244d6d81bb52 | 167 | else if(mode == 2)//Set the Year |
thomasmorris | 48:244d6d81bb52 | 168 | { |
thomasmorris | 48:244d6d81bb52 | 169 | if(Log_Value == 1){pc.printf("In Year Setting Mode\n");} |
thomasmorris | 48:244d6d81bb52 | 170 | LCD.Display_Clear(); |
thomasmorris | 48:244d6d81bb52 | 171 | while(1) |
thomasmorris | 48:244d6d81bb52 | 172 | { |
thomasmorris | 48:244d6d81bb52 | 173 | LCD_Write_Year(); |
thomasmorris | 48:244d6d81bb52 | 174 | Thread::wait(1000); |
thomasmorris | 48:244d6d81bb52 | 175 | if(Log_Value == 1){pc.printf("Checking SW1 and SW2 to go to Month setting\n");} |
thomasmorris | 48:244d6d81bb52 | 176 | if(SW1.read() & SW2.read() == 1) |
thomasmorris | 48:244d6d81bb52 | 177 | { |
thomasmorris | 48:244d6d81bb52 | 178 | mode = 3; |
thomasmorris | 48:244d6d81bb52 | 179 | break; |
thomasmorris | 48:244d6d81bb52 | 180 | } |
thomasmorris | 48:244d6d81bb52 | 181 | if(Log_Value == 1){pc.printf("Checking SW1 to add Year\n");} |
thomasmorris | 48:244d6d81bb52 | 182 | if(SW1.read() == 1 & SW2.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 183 | { |
thomasmorris | 48:244d6d81bb52 | 184 | Add_Year(); |
thomasmorris | 48:244d6d81bb52 | 185 | } |
thomasmorris | 48:244d6d81bb52 | 186 | if(Log_Value == 1){pc.printf("Checking SW2 to subtract Year\n");} |
thomasmorris | 48:244d6d81bb52 | 187 | else if(SW2.read() == 1 & SW1.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 188 | { |
thomasmorris | 48:244d6d81bb52 | 189 | Subtract_Year(); |
thomasmorris | 48:244d6d81bb52 | 190 | } |
thomasmorris | 48:244d6d81bb52 | 191 | LCD_Write_Year(); |
thomasmorris | 48:244d6d81bb52 | 192 | } |
thomasmorris | 48:244d6d81bb52 | 193 | } |
thomasmorris | 48:244d6d81bb52 | 194 | else if(mode == 3)//Set the Month |
thomasmorris | 48:244d6d81bb52 | 195 | { |
thomasmorris | 48:244d6d81bb52 | 196 | if(Log_Value == 1){pc.printf("In Month Setting Mode\n");} |
thomasmorris | 48:244d6d81bb52 | 197 | LCD.Display_Clear(); |
thomasmorris | 48:244d6d81bb52 | 198 | while(1) |
thomasmorris | 48:244d6d81bb52 | 199 | { |
thomasmorris | 48:244d6d81bb52 | 200 | LCD_Write_Month(); |
thomasmorris | 48:244d6d81bb52 | 201 | Thread::wait(1000); |
thomasmorris | 48:244d6d81bb52 | 202 | if(Log_Value == 1){pc.printf("Checking SW1 and SW2 to go to Day setting\n");} |
thomasmorris | 48:244d6d81bb52 | 203 | if(SW1.read() & SW2.read() == 1) |
thomasmorris | 48:244d6d81bb52 | 204 | { |
thomasmorris | 48:244d6d81bb52 | 205 | mode = 4; |
thomasmorris | 48:244d6d81bb52 | 206 | break; |
thomasmorris | 48:244d6d81bb52 | 207 | } |
thomasmorris | 48:244d6d81bb52 | 208 | if(Log_Value == 1){pc.printf("Checking SW1 to add Month\n");} |
thomasmorris | 48:244d6d81bb52 | 209 | if(SW1.read() == 1 & SW2.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 210 | { |
thomasmorris | 48:244d6d81bb52 | 211 | Add_Month(); |
thomasmorris | 48:244d6d81bb52 | 212 | } |
thomasmorris | 48:244d6d81bb52 | 213 | if(Log_Value == 1){pc.printf("Checking SW2 to subtract Month\n");} |
thomasmorris | 48:244d6d81bb52 | 214 | else if(SW2.read() == 1 & SW1.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 215 | { |
thomasmorris | 48:244d6d81bb52 | 216 | Subtract_Month(); |
thomasmorris | 48:244d6d81bb52 | 217 | } |
thomasmorris | 48:244d6d81bb52 | 218 | |
thomasmorris | 48:244d6d81bb52 | 219 | } |
thomasmorris | 48:244d6d81bb52 | 220 | } |
thomasmorris | 48:244d6d81bb52 | 221 | else if(mode == 4)//Set the Day |
thomasmorris | 48:244d6d81bb52 | 222 | { |
thomasmorris | 48:244d6d81bb52 | 223 | if(Log_Value == 1){pc.printf("In Day Setting Mode\n");} |
thomasmorris | 48:244d6d81bb52 | 224 | LCD.Display_Clear(); |
thomasmorris | 48:244d6d81bb52 | 225 | while(1) |
thomasmorris | 48:244d6d81bb52 | 226 | { |
thomasmorris | 48:244d6d81bb52 | 227 | LCD_Write_Day(); |
thomasmorris | 48:244d6d81bb52 | 228 | Thread::wait(1000); |
thomasmorris | 48:244d6d81bb52 | 229 | if(Log_Value == 1){pc.printf("Checking SW1 and SW2 to go Default setting\n");} |
thomasmorris | 48:244d6d81bb52 | 230 | if(SW1.read() & SW2.read() == 1) |
thomasmorris | 48:244d6d81bb52 | 231 | { |
thomasmorris | 48:244d6d81bb52 | 232 | mode = 0; |
thomasmorris | 48:244d6d81bb52 | 233 | break; |
thomasmorris | 48:244d6d81bb52 | 234 | } |
thomasmorris | 48:244d6d81bb52 | 235 | if(Log_Value == 1){pc.printf("Checking SW1 to add Day\n");} |
thomasmorris | 48:244d6d81bb52 | 236 | if(SW1.read() == 1 & SW2.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 237 | { |
thomasmorris | 48:244d6d81bb52 | 238 | Add_Day(); |
thomasmorris | 48:244d6d81bb52 | 239 | } |
thomasmorris | 48:244d6d81bb52 | 240 | if(Log_Value == 1){pc.printf("Checking SW2 to subtract Day\n");} |
thomasmorris | 48:244d6d81bb52 | 241 | else if(SW2.read() == 1 & SW1.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 242 | { |
thomasmorris | 48:244d6d81bb52 | 243 | Subtract_Day(); |
thomasmorris | 48:244d6d81bb52 | 244 | } |
thomasmorris | 48:244d6d81bb52 | 245 | } |
thomasmorris | 48:244d6d81bb52 | 246 | } |
thomasmorris | 48:244d6d81bb52 | 247 | else if(mode == 5)//Set the Hour |
thomasmorris | 48:244d6d81bb52 | 248 | { |
thomasmorris | 48:244d6d81bb52 | 249 | if(Log_Value == 1){pc.printf("In Hour Setting Mode\n");} |
thomasmorris | 48:244d6d81bb52 | 250 | LCD.Display_Clear(); |
thomasmorris | 48:244d6d81bb52 | 251 | while(1) |
thomasmorris | 48:244d6d81bb52 | 252 | { |
thomasmorris | 48:244d6d81bb52 | 253 | LCD_Write_Hour(); |
thomasmorris | 48:244d6d81bb52 | 254 | Thread::wait(1000); |
thomasmorris | 48:244d6d81bb52 | 255 | if(Log_Value == 1){pc.printf("Checking SW1 and SW2 to go Minute setting\n");} |
thomasmorris | 48:244d6d81bb52 | 256 | if(SW1.read() & SW2.read() == 1) |
thomasmorris | 48:244d6d81bb52 | 257 | { |
thomasmorris | 48:244d6d81bb52 | 258 | mode = 6; |
thomasmorris | 48:244d6d81bb52 | 259 | break; |
thomasmorris | 48:244d6d81bb52 | 260 | } |
thomasmorris | 48:244d6d81bb52 | 261 | if(Log_Value == 1){pc.printf("Checking SW1 to add Hour\n");} |
thomasmorris | 48:244d6d81bb52 | 262 | if(SW1.read() == 1 & SW2.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 263 | { |
thomasmorris | 48:244d6d81bb52 | 264 | Add_Hour(); |
thomasmorris | 48:244d6d81bb52 | 265 | } |
thomasmorris | 48:244d6d81bb52 | 266 | if(Log_Value == 1){pc.printf("Checking SW2 to subtract Hour\n");} |
thomasmorris | 48:244d6d81bb52 | 267 | else if(SW2.read() == 1 & SW1.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 268 | { |
thomasmorris | 48:244d6d81bb52 | 269 | Subtract_Hour(); |
thomasmorris | 48:244d6d81bb52 | 270 | } |
thomasmorris | 48:244d6d81bb52 | 271 | } |
thomasmorris | 48:244d6d81bb52 | 272 | } |
thomasmorris | 48:244d6d81bb52 | 273 | else if(mode == 6)//Set the Minute |
thomasmorris | 48:244d6d81bb52 | 274 | { |
thomasmorris | 48:244d6d81bb52 | 275 | if(Log_Value == 1){pc.printf("In Minute Setting Mode\n");} |
thomasmorris | 48:244d6d81bb52 | 276 | LCD.Display_Clear(); |
thomasmorris | 48:244d6d81bb52 | 277 | while(1) |
thomasmorris | 48:244d6d81bb52 | 278 | { |
thomasmorris | 48:244d6d81bb52 | 279 | LCD_Write_Minute(); |
thomasmorris | 48:244d6d81bb52 | 280 | Thread::wait(1000); |
thomasmorris | 48:244d6d81bb52 | 281 | if(Log_Value == 1){pc.printf("Checking SW1 and SW2 to go Seconds setting\n");} |
thomasmorris | 48:244d6d81bb52 | 282 | if(SW1.read() & SW2.read() == 1) |
thomasmorris | 48:244d6d81bb52 | 283 | { |
thomasmorris | 48:244d6d81bb52 | 284 | mode = 7; |
thomasmorris | 48:244d6d81bb52 | 285 | break; |
thomasmorris | 48:244d6d81bb52 | 286 | } |
thomasmorris | 48:244d6d81bb52 | 287 | if(Log_Value == 1){pc.printf("Checking SW1 to add Minute\n");} |
thomasmorris | 48:244d6d81bb52 | 288 | if(SW1.read() == 1 & SW2.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 289 | { |
thomasmorris | 48:244d6d81bb52 | 290 | Add_Minute(); |
thomasmorris | 48:244d6d81bb52 | 291 | } |
thomasmorris | 48:244d6d81bb52 | 292 | if(Log_Value == 1){pc.printf("Checking SW2 to subtract Minute\n");} |
thomasmorris | 48:244d6d81bb52 | 293 | else if(SW2.read() == 1 & SW1.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 294 | { |
thomasmorris | 48:244d6d81bb52 | 295 | Subtract_Minute(); |
thomasmorris | 48:244d6d81bb52 | 296 | } |
thomasmorris | 48:244d6d81bb52 | 297 | } |
thomasmorris | 48:244d6d81bb52 | 298 | } |
thomasmorris | 48:244d6d81bb52 | 299 | else if(mode == 7)//Set the Seconds |
thomasmorris | 48:244d6d81bb52 | 300 | { |
thomasmorris | 48:244d6d81bb52 | 301 | if(Log_Value == 1){pc.printf("In Second Setting Mode\n");} |
thomasmorris | 48:244d6d81bb52 | 302 | LCD.Display_Clear(); |
thomasmorris | 48:244d6d81bb52 | 303 | while(1) |
thomasmorris | 48:244d6d81bb52 | 304 | { |
thomasmorris | 48:244d6d81bb52 | 305 | LCD_Write_Seconds(); |
thomasmorris | 48:244d6d81bb52 | 306 | Thread::wait(1000); |
thomasmorris | 48:244d6d81bb52 | 307 | if(Log_Value == 1){pc.printf("Checking SW1 and SW2 to go Default setting\n");} |
thomasmorris | 48:244d6d81bb52 | 308 | if(SW1.read() & SW2.read() == 1) |
thomasmorris | 48:244d6d81bb52 | 309 | { |
thomasmorris | 48:244d6d81bb52 | 310 | mode = 0; |
thomasmorris | 48:244d6d81bb52 | 311 | break; |
thomasmorris | 48:244d6d81bb52 | 312 | } |
thomasmorris | 48:244d6d81bb52 | 313 | if(Log_Value == 1){pc.printf("Checking SW1 to add Second\n");} |
thomasmorris | 48:244d6d81bb52 | 314 | if(SW1.read() == 1 & SW2.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 315 | { |
thomasmorris | 48:244d6d81bb52 | 316 | Add_Second(); |
thomasmorris | 48:244d6d81bb52 | 317 | } |
thomasmorris | 48:244d6d81bb52 | 318 | if(Log_Value == 1){pc.printf("Checking SW1 to subtract Second\n");} |
thomasmorris | 48:244d6d81bb52 | 319 | else if(SW2.read() == 1 & SW1.read() == 0) |
thomasmorris | 48:244d6d81bb52 | 320 | { |
thomasmorris | 48:244d6d81bb52 | 321 | Subtract_Second(); |
thomasmorris | 48:244d6d81bb52 | 322 | } |
thomasmorris | 48:244d6d81bb52 | 323 | } |
thomasmorris | 48:244d6d81bb52 | 324 | } |
thomasmorris | 48:244d6d81bb52 | 325 | else |
thomasmorris | 48:244d6d81bb52 | 326 | { |
thomasmorris | 48:244d6d81bb52 | 327 | if(Log_Value == 1){pc.printf("Mode Error occured mode now set to 0\n");} |
thomasmorris | 48:244d6d81bb52 | 328 | mode = 0; |
thomasmorris | 48:244d6d81bb52 | 329 | } |
thomasmorris | 48:244d6d81bb52 | 330 | } |
thomasmorris | 48:244d6d81bb52 | 331 | |
thomasmorris | 48:244d6d81bb52 | 332 | |
thomasmorris | 48:244d6d81bb52 | 333 |