Iztech Fork
Fork of A2_Interface3_V_0_0 by
Embed:
(wiki syntax)
Show/hide line numbers
Timers.h
00001 /* 00002 Programmer: Roger McArdell 00003 Date: 02/08/2017 00004 Version 00005 V0.1 First version 00006 */ 00007 00008 DigitalOut led1(LED1); 00009 DigitalOut led2(LED2); 00010 DigitalOut led3(LED3); 00011 00012 Timer T1; 00013 Timer T2; 00014 Timer T3; 00015 00016 // Function Prototypes 00017 void TimeLoopaBox(); 00018 void TimeLoopShort(); 00019 void TimeLoopLong(); 00020 void TimeLoopSetup(); 00021 void CheckSyncs (); 00022 void SwitchOff(); 00023 00024 void TimeLoopSetup() 00025 { 00026 T1.start(); 00027 T2.start(); 00028 T3.start(); 00029 } 00030 00031 void TimeLoop() 00032 { 00033 if (T1.read_ms() >= 1000) //10 00034 { 00035 T1.reset(); 00036 TimeLoopaBox(); 00037 } 00038 if (T2.read_ms() >= 100) //100 00039 { 00040 T2.reset(); 00041 TimeLoopShort(); 00042 } 00043 if (T3.read_ms() >= 750) 00044 { 00045 T3.reset(); 00046 TimeLoopLong(); 00047 } 00048 } 00049 void TimeLoopaBox() 00050 { 00051 //led1 = !led1; 00052 00053 } 00054 void TimeLoopShort() 00055 { 00056 //led2 = !led2; 00057 char Result = GetConnectedStatus(); 00058 00059 if (Result && '\x01') //XXX1 00060 { 00061 if (!HDMI1Sync) 00062 { 00063 HDMI1Sync = 1; 00064 aboxPort.printf("DSY%d11\n", IDNumber); 00065 pc.printf("HDMI 1 On\r\n"); 00066 if (SystemState == IsOff) 00067 { 00068 WriteCEC(Button1Address, Green); 00069 SwitchMatrix(HDMI1, HDMI1); 00070 SystemState = IsHDMI1; 00071 } 00072 else 00073 WriteCEC(Button1Address, Blue); 00074 } 00075 } 00076 else 00077 { 00078 if (HDMI1Sync) 00079 { 00080 HDMI1Sync = 0; 00081 aboxPort.printf("DSY%d10\n", IDNumber); 00082 pc.printf("HDMI 1 Off\r\n"); 00083 WriteCEC(Button1Address, Off); 00084 if (SystemState == IsHDMI1) 00085 CheckSyncs(); //Check for another sync 00086 } 00087 } 00088 if (Result && '\x02') 00089 { 00090 if (!HDMI2Sync) 00091 { 00092 HDMI2Sync = 1; 00093 aboxPort.printf("DSY%d21\n", IDNumber); 00094 pc.printf("HDMI 2 On\r\n"); 00095 if (SystemState == IsOff) 00096 { 00097 WriteCEC(Button2Address, Green); 00098 SwitchMatrix(HDMI2, HDMI2); 00099 SystemState = IsHDMI2; 00100 } 00101 else 00102 WriteCEC(Button2Address, Blue); 00103 } 00104 } 00105 else 00106 { 00107 if (HDMI2Sync) 00108 { 00109 HDMI2Sync = 0; 00110 aboxPort.printf("DSY%d20\n", IDNumber); 00111 pc.printf("HDMI 2 Off\r\n"); 00112 WriteCEC(Button2Address, Off); 00113 if (SystemState == IsHDMI2) 00114 CheckSyncs(); //Check for another sync 00115 } 00116 00117 } 00118 if (Result && '\x04') 00119 { 00120 if (!HDMI3Sync) 00121 { 00122 HDMI3Sync = 1; 00123 aboxPort.printf("DSY%d31\n", IDNumber); 00124 pc.printf("HDMI 3 On\r\n"); 00125 if (SystemState == IsOff) 00126 { 00127 WriteCEC(Button3Address, Green); 00128 SwitchMatrix(HDMI3, HDMI3); 00129 SystemState = IsHDMI3; 00130 } 00131 else 00132 WriteCEC(Button3Address, Blue); 00133 } 00134 } 00135 else 00136 { 00137 if (HDMI3Sync) 00138 { 00139 HDMI3Sync = 0; 00140 aboxPort.printf("DSY%d30\n", IDNumber); 00141 pc.printf("HDMI 3 Off\r\n"); 00142 WriteCEC(Button3Address, Off); 00143 if (SystemState == IsHDMI3) 00144 CheckSyncs(); //Check for another sync 00145 } 00146 } 00147 if (Result && '\x08') 00148 { 00149 if (!HDMI4Sync) 00150 { 00151 HDMI4Sync = 1; 00152 aboxPort.printf("DSY%d41\n", IDNumber); 00153 pc.printf("HDMI 4 On\r\n"); 00154 if (SystemState == IsOff) 00155 { 00156 WriteCEC(Button4Address, Green); 00157 SwitchMatrix(HDMI4, HDMI4); 00158 SystemState = IsHDMI4; 00159 } 00160 else 00161 WriteCEC(Button4Address, Blue); 00162 } 00163 } 00164 else 00165 { 00166 if (HDMI4Sync) 00167 { 00168 HDMI4Sync = 0; 00169 aboxPort.printf("DSY%d40\n", IDNumber); 00170 pc.printf("HDMI 4 Off\r\n"); 00171 WriteCEC(Button4Address, Off); 00172 if (SystemState == IsHDMI4) 00173 CheckSyncs(); //Check for another sync 00174 } 00175 } 00176 } 00177 void TimeLoopLong() 00178 { 00179 //led3 = !led3; 00180 } 00181 void CheckSyncs () 00182 { 00183 //Check for another sync 00184 if (HDMI1Sync) 00185 { 00186 WriteCEC(Button1Address, Green); 00187 SwitchMatrix(HDMI1, HDMI1); 00188 SystemState = IsHDMI1; 00189 if (HDMI2Sync) 00190 WriteCEC(Button2Address, Blue); 00191 if (HDMI3Sync) 00192 WriteCEC(Button3Address, Blue); 00193 if (HDMI4Sync) 00194 WriteCEC(Button4Address, Blue); 00195 } 00196 else if (HDMI2Sync) 00197 { 00198 WriteCEC(Button2Address, Green); 00199 SwitchMatrix(HDMI2, HDMI2); 00200 SystemState = IsHDMI2; 00201 if (HDMI1Sync) 00202 WriteCEC(Button1Address, Blue); 00203 if (HDMI3Sync) 00204 WriteCEC(Button3Address, Blue); 00205 if (HDMI4Sync) 00206 WriteCEC(Button4Address, Blue); 00207 00208 } 00209 else if (HDMI3Sync) 00210 { 00211 WriteCEC(Button3Address, Green); 00212 SwitchMatrix(HDMI3, HDMI3); 00213 SystemState = IsHDMI3; 00214 if (HDMI1Sync) 00215 WriteCEC(Button1Address, Blue); 00216 if (HDMI2Sync) 00217 WriteCEC(Button2Address, Blue); 00218 if (HDMI4Sync) 00219 WriteCEC(Button4Address, Blue); 00220 } 00221 else if (HDMI4Sync) 00222 { 00223 WriteCEC(Button4Address, Green); 00224 SwitchMatrix(HDMI4, HDMI4); 00225 SystemState = IsHDMI4; 00226 if (HDMI1Sync) 00227 WriteCEC(Button1Address, Blue); 00228 if (HDMI2Sync) 00229 WriteCEC(Button2Address, Blue); 00230 if (HDMI3Sync) 00231 WriteCEC(Button3Address, Blue); 00232 } 00233 else if (ExternalSync) 00234 { 00235 aboxPort.printf("MAT%d00\n", IDNumber); 00236 } 00237 else SwitchOff(); 00238 } 00239 void SwitchOff() 00240 { 00241 SystemState = IsOff; 00242 aboxPort.printf("MAT%d00\n", IDNumber); 00243 }
Generated on Tue Aug 2 2022 20:48:37 by
1.7.2
