A twist to the computer that landed man on the moon. More information can be found at http://hackaday.io/project/294-Open-Source-DSKY
Dependencies: DS1302 keypad mbed
main.cpp@7:3d06d866878c, 2014-08-20 (annotated)
- Committer:
- VivaPenguinos
- Date:
- Wed Aug 20 03:43:12 2014 +0000
- Revision:
- 7:3d06d866878c
- Parent:
- 6:3019f2f7e9d4
EXPERIMENTAL BUILD.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
VivaPenguinos | 7:3d06d866878c | 1 | /* |
VivaPenguinos | 7:3d06d866878c | 2 | ***EXPERIMENTAL BUILD*** |
VivaPenguinos | 7:3d06d866878c | 3 | Introduction |
VivaPenguinos | 2:aee9ee1296cd | 4 | MBED DSKY |
VivaPenguinos | 0:3ff58b093415 | 5 | This is a personal project used developed by penguinos to mix old school technology with a modern twist. |
VivaPenguinos | 6:3019f2f7e9d4 | 6 | Version 0.06: August. 15 2014 |
VivaPenguinos | 6:3019f2f7e9d4 | 7 | NO_Light() function has now case 8 for Indicator lights |
VivaPenguinos | 6:3019f2f7e9d4 | 8 | - P00 Improvements |
VivaPenguinos | 6:3019f2f7e9d4 | 9 | - P06 CMC Power Down Completed |
VivaPenguinos | 6:3019f2f7e9d4 | 10 | - CMC_Powerdown() Added |
VivaPenguinos | 6:3019f2f7e9d4 | 11 | - CMC_PowerInput() Added |
VivaPenguinos | 0:3ff58b093415 | 12 | Notable Credits: |
VivaPenguinos | 0:3ff58b093415 | 13 | NASA! - Release of technical documentations regarding the AGC and DSKY |
VivaPenguinos | 0:3ff58b093415 | 14 | Ron Burkley and Contributers of "Virtual AGC — AGS — LVDC — Gemini" - Providing Technical documentations, Source Code, explanations, |
VivaPenguinos | 0:3ff58b093415 | 15 | and refrences on other sites to make this project successful |
VivaPenguinos | 4:99535d368a9f | 16 | Warning: This may contain author's crude language, and random thoughts. |
VivaPenguinos | 4:99535d368a9f | 17 | |
VivaPenguinos | 6:3019f2f7e9d4 | 18 | Software Licenses: |
VivaPenguinos | 6:3019f2f7e9d4 | 19 | Keypad.h - Author Copyrighted 2012 but it is under the Open Source License Agreement. |
VivaPenguinos | 6:3019f2f7e9d4 | 20 | Source: http://mbed.org/cookbook/Keypad |
VivaPenguinos | 6:3019f2f7e9d4 | 21 | DS1302.h - Open Source License |
VivaPenguinos | 6:3019f2f7e9d4 | 22 | Source: http://mbed.org/components/DS1302-Timekeeping-Chip/ |
VivaPenguinos | 6:3019f2f7e9d4 | 23 | |
VivaPenguinos | 4:99535d368a9f | 24 | Pin Usage: |
VivaPenguinos | 4:99535d368a9f | 25 | |
VivaPenguinos | 3:29cff763ae36 | 26 | Real Time Clock |
VivaPenguinos | 3:29cff763ae36 | 27 | SCLK PTC5 |
VivaPenguinos | 3:29cff763ae36 | 28 | IO PTC4 |
VivaPenguinos | 3:29cff763ae36 | 29 | CE PTC3 |
VivaPenguinos | 3:29cff763ae36 | 30 | Keypad |
VivaPenguinos | 3:29cff763ae36 | 31 | Row0 PTD4 |
VivaPenguinos | 3:29cff763ae36 | 32 | Row1 PTA12 |
VivaPenguinos | 3:29cff763ae36 | 33 | Row2 PTD3 |
VivaPenguinos | 3:29cff763ae36 | 34 | Row3 PTA5 |
VivaPenguinos | 3:29cff763ae36 | 35 | Col1 PTA13 |
VivaPenguinos | 3:29cff763ae36 | 36 | Col2 PTD5 |
VivaPenguinos | 3:29cff763ae36 | 37 | Col3 PTD0 |
VivaPenguinos | 3:29cff763ae36 | 38 | Col4 PTD2 |
VivaPenguinos | 3:29cff763ae36 | 39 | Shift Registers |
VivaPenguinos | 3:29cff763ae36 | 40 | Latch PTC6 |
VivaPenguinos | 3:29cff763ae36 | 41 | Clock PTC10 |
VivaPenguinos | 3:29cff763ae36 | 42 | Data PTC11 |
VivaPenguinos | 5:5f08974ef8bb | 43 | Statues Indicator |
VivaPenguinos | 5:5f08974ef8bb | 44 | Uplink ACTY PTE5 |
VivaPenguinos | 5:5f08974ef8bb | 45 | NO ATT PTE4 |
VivaPenguinos | 5:5f08974ef8bb | 46 | STBY PTE3 |
VivaPenguinos | 5:5f08974ef8bb | 47 | KEY REL PTE2 |
VivaPenguinos | 5:5f08974ef8bb | 48 | OPP ERR PTB11 |
VivaPenguinos | 5:5f08974ef8bb | 49 | TEMP PTB10 |
VivaPenguinos | 5:5f08974ef8bb | 50 | GIMBAL LOCK PTB9 |
VivaPenguinos | 5:5f08974ef8bb | 51 | PROG PTB8 |
VivaPenguinos | 5:5f08974ef8bb | 52 | RESTART PTC12 |
VivaPenguinos | 5:5f08974ef8bb | 53 | TRACKER PTC13 |
VivaPenguinos | 5:5f08974ef8bb | 54 | R1+ PTC16 |
VivaPenguinos | 5:5f08974ef8bb | 55 | R2+ PTC17 |
VivaPenguinos | 5:5f08974ef8bb | 56 | R3+ PTA16 |
VivaPenguinos | 5:5f08974ef8bb | 57 | R1- PTA17 |
VivaPenguinos | 5:5f08974ef8bb | 58 | R2- PTE31 |
VivaPenguinos | 5:5f08974ef8bb | 59 | R3- PTC6 |
VivaPenguinos | 5:5f08974ef8bb | 60 | COMP ACTY PTC7 |
VivaPenguinos | 6:3019f2f7e9d4 | 61 | |
VivaPenguinos | 6:3019f2f7e9d4 | 62 | Push Button |
VivaPenguinos | 6:3019f2f7e9d4 | 63 | PRO_BUTT PTB1 |
VivaPenguinos | 6:3019f2f7e9d4 | 64 | CLR_BUTT PTB2 |
VivaPenguinos | 6:3019f2f7e9d4 | 65 | KEYREL_BUTT PTB3 |
VivaPenguinos | 4:99535d368a9f | 66 | |
VivaPenguinos | 4:99535d368a9f | 67 | Shift Registers Data: |
VivaPenguinos | 4:99535d368a9f | 68 | Because the project contains 11 shift registers, All data must be properly formatted before shifting out. each shift register controls 2 7 segments. |
VivaPenguinos | 4:99535d368a9f | 69 | R1_A [P_A | P_B] |
VivaPenguinos | 4:99535d368a9f | 70 | R1_B |
VivaPenguinos | 4:99535d368a9f | 71 | R1_C [V_A | V_B] [N_A | N_B] |
VivaPenguinos | 4:99535d368a9f | 72 | R1_D |
VivaPenguinos | 4:99535d368a9f | 73 | R1_E [R3_E | R3_D | R3_C | R3_B | R3_A] |
VivaPenguinos | 4:99535d368a9f | 74 | R2_A |
VivaPenguinos | 4:99535d368a9f | 75 | R2_B [R2_E | R2_D | R2_C | R2_B | R2_A] |
VivaPenguinos | 4:99535d368a9f | 76 | R2_C |
VivaPenguinos | 4:99535d368a9f | 77 | R2_D [R1_E | R1_D | R1_C | R1_B | R1_A] |
VivaPenguinos | 4:99535d368a9f | 78 | R2_E |
VivaPenguinos | 4:99535d368a9f | 79 | R3_A |
VivaPenguinos | 4:99535d368a9f | 80 | R3_B |
VivaPenguinos | 4:99535d368a9f | 81 | R3_C |
VivaPenguinos | 4:99535d368a9f | 82 | R3_D |
VivaPenguinos | 4:99535d368a9f | 83 | R3_E |
VivaPenguinos | 4:99535d368a9f | 84 | V_A |
VivaPenguinos | 4:99535d368a9f | 85 | V_B |
VivaPenguinos | 4:99535d368a9f | 86 | N_A |
VivaPenguinos | 4:99535d368a9f | 87 | N_B |
VivaPenguinos | 4:99535d368a9f | 88 | P_A |
VivaPenguinos | 4:99535d368a9f | 89 | P_B |
VivaPenguinos | 6:3019f2f7e9d4 | 90 | |
VivaPenguinos | 6:3019f2f7e9d4 | 91 | Program Added: |
VivaPenguinos | 6:3019f2f7e9d4 | 92 | P01 - PRELAUNCH OR SERVICE - INITIALIZATION PROGRAM |
VivaPenguinos | 6:3019f2f7e9d4 | 93 | P02 - PRELAUNCH OR SERVICE - GYROCOMPASSING PROGRAM |
VivaPenguinos | 6:3019f2f7e9d4 | 94 | |
VivaPenguinos | 6:3019f2f7e9d4 | 95 | Program In Progress (Not completed) |
VivaPenguinos | 6:3019f2f7e9d4 | 96 | P00 - CMC IDLING PROGRAM |
VivaPenguinos | 6:3019f2f7e9d4 | 97 | P06 - CMC POWER DOWN PROGRAM |
VivaPenguinos | 3:29cff763ae36 | 98 | */ |
VivaPenguinos | 3:29cff763ae36 | 99 | |
VivaPenguinos | 3:29cff763ae36 | 100 | // For RTC |
VivaPenguinos | 3:29cff763ae36 | 101 | #define SCLK PTC5 |
VivaPenguinos | 3:29cff763ae36 | 102 | #define IO PTC4 |
VivaPenguinos | 3:29cff763ae36 | 103 | #define CE PTC3 |
VivaPenguinos | 3:29cff763ae36 | 104 | |
VivaPenguinos | 3:29cff763ae36 | 105 | // Comment Line if DS1302 is already running |
VivaPenguinos | 3:29cff763ae36 | 106 | #define INITIAL_RUN |
VivaPenguinos | 3:29cff763ae36 | 107 | |
VivaPenguinos | 0:3ff58b093415 | 108 | using namespace std; |
VivaPenguinos | 0:3ff58b093415 | 109 | #include "mbed.h" |
VivaPenguinos | 1:24446776f0d2 | 110 | #include "Keypad.h" // Keypad |
VivaPenguinos | 3:29cff763ae36 | 111 | #include "DS1302.h" // RTC for DS1032 |
VivaPenguinos | 4:99535d368a9f | 112 | |
VivaPenguinos | 3:29cff763ae36 | 113 | DS1302 clk(SCLK, IO, CE); //DS1302 clk(SCLK, IO, PTC3); |
VivaPenguinos | 0:3ff58b093415 | 114 | |
VivaPenguinos | 0:3ff58b093415 | 115 | //Declare Variables |
VivaPenguinos | 4:99535d368a9f | 116 | // int shift = 0; // Shift Data |
VivaPenguinos | 0:3ff58b093415 | 117 | // In the Arduino Version it uses a String. Will use an Int instead to see if this works on Mbed |
VivaPenguinos | 1:24446776f0d2 | 118 | int Verb_Number1 = 0; |
VivaPenguinos | 1:24446776f0d2 | 119 | int Verb_Number2 = 0; |
VivaPenguinos | 1:24446776f0d2 | 120 | int Noun_Number1 = 0; |
VivaPenguinos | 1:24446776f0d2 | 121 | int Noun_Number2 = 0; |
VivaPenguinos | 1:24446776f0d2 | 122 | int Enter_Number1 = 0; |
VivaPenguinos | 1:24446776f0d2 | 123 | int Enter_Number2 = 0; |
VivaPenguinos | 1:24446776f0d2 | 124 | int Verb; // DSKY Verb |
VivaPenguinos | 1:24446776f0d2 | 125 | int Noun; // DSkY Noun |
VivaPenguinos | 1:24446776f0d2 | 126 | int Enter; // DSKY Enter |
VivaPenguinos | 4:99535d368a9f | 127 | |
VivaPenguinos | 4:99535d368a9f | 128 | // For shift register use. Refer to shift register data for additional information. |
VivaPenguinos | 4:99535d368a9f | 129 | int R1_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 130 | int R1_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 131 | int R1_C = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 132 | int R1_D = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 133 | int R1_E = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 134 | int R2_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 135 | int R2_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 136 | int R2_C = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 137 | int R2_D = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 138 | int R2_E = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 139 | int R3_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 140 | int R3_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 141 | int R3_C = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 142 | int R3_D = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 143 | int R3_E = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 144 | int V_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 145 | int V_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 146 | int N_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 147 | int N_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 148 | int P_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 149 | int P_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 150 | |
VivaPenguinos | 5:5f08974ef8bb | 151 | // For R use. |
VivaPenguinos | 5:5f08974ef8bb | 152 | int R_Pos = 0; |
VivaPenguinos | 5:5f08974ef8bb | 153 | int R_Neg = 0; |
VivaPenguinos | 4:99535d368a9f | 154 | int RA = 0; |
VivaPenguinos | 4:99535d368a9f | 155 | int RB = 0; |
VivaPenguinos | 4:99535d368a9f | 156 | int RC = 0; |
VivaPenguinos | 4:99535d368a9f | 157 | int RD = 0; |
VivaPenguinos | 4:99535d368a9f | 158 | int RE = 0; |
VivaPenguinos | 5:5f08974ef8bb | 159 | int RP = 0; |
VivaPenguinos | 4:99535d368a9f | 160 | int RVA = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 161 | int RVB = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 162 | int RVC = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 163 | int RVD = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 164 | int RVE = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 165 | int R_Position = 1; |
VivaPenguinos | 4:99535d368a9f | 166 | int R1_Position = 1; |
VivaPenguinos | 4:99535d368a9f | 167 | int R2_Position = 1; |
VivaPenguinos | 4:99535d368a9f | 168 | int R3_Position = 1; |
VivaPenguinos | 4:99535d368a9f | 169 | int GET_Config_Time = 0; |
VivaPenguinos | 4:99535d368a9f | 170 | |
VivaPenguinos | 5:5f08974ef8bb | 171 | // For N Use. |
VivaPenguinos | 5:5f08974ef8bb | 172 | int NA = 0x0f; |
VivaPenguinos | 5:5f08974ef8bb | 173 | int NB = 0x0f; |
VivaPenguinos | 5:5f08974ef8bb | 174 | int N_Position = 1; |
VivaPenguinos | 5:5f08974ef8bb | 175 | |
VivaPenguinos | 5:5f08974ef8bb | 176 | // PC Variables (Future use) |
VivaPenguinos | 5:5f08974ef8bb | 177 | int IMUPWR = 1; |
VivaPenguinos | 5:5f08974ef8bb | 178 | |
VivaPenguinos | 5:5f08974ef8bb | 179 | // DSKY Variables |
VivaPenguinos | 5:5f08974ef8bb | 180 | int LAUNCHAZ = 0; // LAUNCH AZIMUTH |
VivaPenguinos | 5:5f08974ef8bb | 181 | int R1_COMP; |
VivaPenguinos | 5:5f08974ef8bb | 182 | |
VivaPenguinos | 3:29cff763ae36 | 183 | // Keypad |
VivaPenguinos | 1:24446776f0d2 | 184 | char Keytable[] = { '1', '2', '3', '+', // R0 |
VivaPenguinos | 1:24446776f0d2 | 185 | '4', '5', '6', '-', // R1 |
VivaPenguinos | 1:24446776f0d2 | 186 | '7', '8', '9', 'E', // R2 |
VivaPenguinos | 1:24446776f0d2 | 187 | 'V', '0', 'N', 'R', // R3 |
VivaPenguinos | 1:24446776f0d2 | 188 | }; |
VivaPenguinos | 4:99535d368a9f | 189 | // C0 C1 C2 C3 |
VivaPenguinos | 1:24446776f0d2 | 190 | |
VivaPenguinos | 3:29cff763ae36 | 191 | // RTC Variables |
VivaPenguinos | 3:29cff763ae36 | 192 | int TIME_VALUE = 1397702161; |
VivaPenguinos | 4:99535d368a9f | 193 | int Time_Difference = 0%60; |
VivaPenguinos | 3:29cff763ae36 | 194 | |
VivaPenguinos | 3:29cff763ae36 | 195 | // Button State |
VivaPenguinos | 1:24446776f0d2 | 196 | int32_t Index = -1; // Button |
VivaPenguinos | 1:24446776f0d2 | 197 | int State; |
VivaPenguinos | 0:3ff58b093415 | 198 | |
VivaPenguinos | 0:3ff58b093415 | 199 | // Function Declaration |
VivaPenguinos | 5:5f08974ef8bb | 200 | void Interruption(); |
VivaPenguinos | 1:24446776f0d2 | 201 | void Verb_Button(); |
VivaPenguinos | 1:24446776f0d2 | 202 | void Noun_Button(); |
VivaPenguinos | 1:24446776f0d2 | 203 | void Enter_Button(); |
VivaPenguinos | 1:24446776f0d2 | 204 | void compare(); |
VivaPenguinos | 0:3ff58b093415 | 205 | void blinkAll(int amount, int delay);// Function that Blinks all LED |
VivaPenguinos | 4:99535d368a9f | 206 | void Shift(); // Function that shifts all data |
VivaPenguinos | 5:5f08974ef8bb | 207 | void R_GET(int R); // Grab inputs for Rows |
VivaPenguinos | 5:5f08974ef8bb | 208 | void N_GET(); // Grab inputs for Noun |
VivaPenguinos | 5:5f08974ef8bb | 209 | void NO_Light(int L); // Configures shift registers to 0 |
VivaPenguinos | 5:5f08974ef8bb | 210 | void PreLaunch_Gyrocompassing_Configure(); // For the inputs of the PreLaunch_Gyrocompassing |
VivaPenguinos | 6:3019f2f7e9d4 | 211 | void CMC_PowerInput(); // For the Inputs of the CMC_Powerdown(); |
VivaPenguinos | 5:5f08974ef8bb | 212 | int Button_Sort(int sort); // Function that sorts Verb Values |
VivaPenguinos | 4:99535d368a9f | 213 | int R_Concatenate(int C); // Used for concatenating information |
VivaPenguinos | 0:3ff58b093415 | 214 | //void ShiftingOut(char myDataOut); |
VivaPenguinos | 0:3ff58b093415 | 215 | |
VivaPenguinos | 3:29cff763ae36 | 216 | // Program Names |
VivaPenguinos | 5:5f08974ef8bb | 217 | void Ground_Elapse_Time(); // Ground Elapse Time |
VivaPenguinos | 5:5f08974ef8bb | 218 | void Test_Lights(); // Test Lights |
VivaPenguinos | 5:5f08974ef8bb | 219 | void GET_Config(); // Configures Ground Elapse Time |
VivaPenguinos | 5:5f08974ef8bb | 220 | void CMC_Idle(); // P00 - CMC Idling Program |
VivaPenguinos | 5:5f08974ef8bb | 221 | void PreLaunch_Initialization(); // P01 - Prelaunch - Initialization Program |
VivaPenguinos | 5:5f08974ef8bb | 222 | void PreLaunch_Gyrocompassing(); // P02 - Prelaunch - Gyrocompassing Program |
VivaPenguinos | 6:3019f2f7e9d4 | 223 | void CMC_Powerdown(); // P06 - CMC Power Down Program |
VivaPenguinos | 5:5f08974ef8bb | 224 | int R1_Component(); // Load Component into R1 |
VivaPenguinos | 1:24446776f0d2 | 225 | |
VivaPenguinos | 6:3019f2f7e9d4 | 226 | // CMC_Idle Variables |
VivaPenguinos | 6:3019f2f7e9d4 | 227 | // Time of State Vector Being Integrated |
VivaPenguinos | 6:3019f2f7e9d4 | 228 | int ToSSeconds = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 229 | int ToSMinutes = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 230 | int ToSHours = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 231 | |
VivaPenguinos | 6:3019f2f7e9d4 | 232 | // Temp Variables or functions. (This should generally have nothing every revision. Either remove or move the items) |
VivaPenguinos | 6:3019f2f7e9d4 | 233 | int PRO = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 234 | void CMC_Poweron(); |
VivaPenguinos | 6:3019f2f7e9d4 | 235 | int Button_Detect = 0; // Used for detecting button presses. |
VivaPenguinos | 6:3019f2f7e9d4 | 236 | |
VivaPenguinos | 0:3ff58b093415 | 237 | // Pin modes for each pins |
VivaPenguinos | 6:3019f2f7e9d4 | 238 | DigitalOut LatchPin (PTC6); //Pin for ST_CP of 74HC595 Pin # 12 |
VivaPenguinos | 6:3019f2f7e9d4 | 239 | DigitalOut ClockPin (PTC10); //Pin for SH_CP of 74HC595 Pin # 11 |
VivaPenguinos | 6:3019f2f7e9d4 | 240 | DigitalOut DataPin (PTC11); //Pin for to DS of 74HC595 Pin # 14 |
VivaPenguinos | 0:3ff58b093415 | 241 | |
VivaPenguinos | 5:5f08974ef8bb | 242 | // Indicator Lights |
VivaPenguinos | 6:3019f2f7e9d4 | 243 | DigitalOut UPLINK_ACTY (PTE5); |
VivaPenguinos | 6:3019f2f7e9d4 | 244 | DigitalOut NO_ATT (PTE4); |
VivaPenguinos | 6:3019f2f7e9d4 | 245 | DigitalOut STBY (PTE3); |
VivaPenguinos | 6:3019f2f7e9d4 | 246 | DigitalOut KEY_REL (PTE2); |
VivaPenguinos | 6:3019f2f7e9d4 | 247 | DigitalOut OPP_ERR (PTB11); |
VivaPenguinos | 6:3019f2f7e9d4 | 248 | DigitalOut TEMP (PTB10); |
VivaPenguinos | 6:3019f2f7e9d4 | 249 | DigitalOut GIMBAL_LOCK (PTB9); |
VivaPenguinos | 6:3019f2f7e9d4 | 250 | DigitalOut PROG (PTB8); |
VivaPenguinos | 6:3019f2f7e9d4 | 251 | DigitalOut RESTART (PTC12); |
VivaPenguinos | 6:3019f2f7e9d4 | 252 | DigitalOut TRACKER (PTC13); |
VivaPenguinos | 6:3019f2f7e9d4 | 253 | DigitalOut R1_POS (PTC16); |
VivaPenguinos | 6:3019f2f7e9d4 | 254 | DigitalOut R2_POS (PTC17); |
VivaPenguinos | 6:3019f2f7e9d4 | 255 | DigitalOut R3_POS (PTA16); |
VivaPenguinos | 6:3019f2f7e9d4 | 256 | DigitalOut R1_NEG (PTA17); |
VivaPenguinos | 6:3019f2f7e9d4 | 257 | DigitalOut R2_NEG (PTE31); |
VivaPenguinos | 6:3019f2f7e9d4 | 258 | DigitalOut R3_NEG (PTD6); |
VivaPenguinos | 6:3019f2f7e9d4 | 259 | DigitalOut COMP_ACTY (PTD7); |
VivaPenguinos | 5:5f08974ef8bb | 260 | |
VivaPenguinos | 6:3019f2f7e9d4 | 261 | // Push Buttons |
VivaPenguinos | 6:3019f2f7e9d4 | 262 | DigitalIn PRO_BUTT (PTB1); |
VivaPenguinos | 6:3019f2f7e9d4 | 263 | DigitalIn CLR_BUTT (PTB2); |
VivaPenguinos | 6:3019f2f7e9d4 | 264 | DigitalIn KEYREL_BUTT (PTB3); |
VivaPenguinos | 6:3019f2f7e9d4 | 265 | |
VivaPenguinos | 6:3019f2f7e9d4 | 266 | // LED |
VivaPenguinos | 0:3ff58b093415 | 267 | DigitalOut myled(LED1); |
VivaPenguinos | 6:3019f2f7e9d4 | 268 | |
VivaPenguinos | 0:3ff58b093415 | 269 | Serial pc(USBTX, USBRX); // tx, rx Serial Output to PC Enabling this WILL consume resources. Use only for debug |
VivaPenguinos | 1:24446776f0d2 | 270 | |
VivaPenguinos | 4:99535d368a9f | 271 | unsigned concatenate(unsigned x, unsigned y); |
VivaPenguinos | 4:99535d368a9f | 272 | |
VivaPenguinos | 1:24446776f0d2 | 273 | uint32_t cbAfterInput(uint32_t index) |
VivaPenguinos | 1:24446776f0d2 | 274 | { |
VivaPenguinos | 1:24446776f0d2 | 275 | Index = index; |
VivaPenguinos | 1:24446776f0d2 | 276 | return 0; |
VivaPenguinos | 1:24446776f0d2 | 277 | } |
VivaPenguinos | 1:24446776f0d2 | 278 | |
VivaPenguinos | 0:3ff58b093415 | 279 | int main() |
VivaPenguinos | 0:3ff58b093415 | 280 | { |
VivaPenguinos | 4:99535d368a9f | 281 | pc.printf("Initialization...\n"); |
VivaPenguinos | 0:3ff58b093415 | 282 | wait(1); |
VivaPenguinos | 4:99535d368a9f | 283 | pc.printf("Testing shift registers.\n"); |
VivaPenguinos | 0:3ff58b093415 | 284 | blinkAll(4,1); |
VivaPenguinos | 4:99535d368a9f | 285 | pc.printf("Shift Register: PASS \n"); |
VivaPenguinos | 0:3ff58b093415 | 286 | wait(1); |
VivaPenguinos | 4:99535d368a9f | 287 | pc.printf("Energizing keypad\n"); |
VivaPenguinos | 1:24446776f0d2 | 288 | State = 1; |
VivaPenguinos | 1:24446776f0d2 | 289 | // r0 r1 r2 r3 c0 c1 c2 c3 |
VivaPenguinos | 1:24446776f0d2 | 290 | Keypad keypad(PTD4, PTA12, PTD3, PTA5, PTA13, PTD5, PTD0, PTD2, 20); |
VivaPenguinos | 1:24446776f0d2 | 291 | keypad.attach(&cbAfterInput); |
VivaPenguinos | 1:24446776f0d2 | 292 | keypad.start(); // energize the columns c0-c3 of the keypad |
VivaPenguinos | 4:99535d368a9f | 293 | pc.printf("Keypad: PASS \n"); |
VivaPenguinos | 4:99535d368a9f | 294 | pc.printf("Initialize RTC Clock. \n"); |
VivaPenguinos | 4:99535d368a9f | 295 | #ifdef INITIAL_RUN |
VivaPenguinos | 4:99535d368a9f | 296 | clk.set_time(TIME_VALUE); |
VivaPenguinos | 4:99535d368a9f | 297 | #endif |
VivaPenguinos | 4:99535d368a9f | 298 | //char storedByte = clk.recallByte(0); |
VivaPenguinos | 4:99535d368a9f | 299 | //clk.storeByte(0, storedByte + 1); |
VivaPenguinos | 4:99535d368a9f | 300 | pc.printf("RTC: PASS \n"); |
VivaPenguinos | 4:99535d368a9f | 301 | pc.printf("Welcome to DSKY!\n"); |
VivaPenguinos | 1:24446776f0d2 | 302 | while (1) { |
VivaPenguinos | 6:3019f2f7e9d4 | 303 | // Input side |
VivaPenguinos | 6:3019f2f7e9d4 | 304 | // Keypad: |
VivaPenguinos | 1:24446776f0d2 | 305 | __wfi(); |
VivaPenguinos | 1:24446776f0d2 | 306 | if (Index >-1) { |
VivaPenguinos | 1:24446776f0d2 | 307 | pc.printf("Interrupted"); |
VivaPenguinos | 1:24446776f0d2 | 308 | pc.printf("Index:%d => Key:%c\r\n", Index, Keytable[Index]); |
VivaPenguinos | 1:24446776f0d2 | 309 | if (Index == 12) { // Index 12 = Verb Button |
VivaPenguinos | 4:99535d368a9f | 310 | Verb_Button(); // Goes to Verb_Button |
VivaPenguinos | 1:24446776f0d2 | 311 | } |
VivaPenguinos | 1:24446776f0d2 | 312 | if (Index == 14) { // Index 14 = Noun Button |
VivaPenguinos | 1:24446776f0d2 | 313 | Noun_Button(); // Goes to Noun_Button |
VivaPenguinos | 1:24446776f0d2 | 314 | } |
VivaPenguinos | 1:24446776f0d2 | 315 | if (Index == 11) { // Index 11 = Enter Button |
VivaPenguinos | 4:99535d368a9f | 316 | Enter_Button(); // Goes to Enter_Button |
VivaPenguinos | 1:24446776f0d2 | 317 | } |
VivaPenguinos | 1:24446776f0d2 | 318 | Index = -1; |
VivaPenguinos | 1:24446776f0d2 | 319 | } |
VivaPenguinos | 6:3019f2f7e9d4 | 320 | // Button: |
VivaPenguinos | 6:3019f2f7e9d4 | 321 | if ((Button_Detect == 0) && (PRO_BUTT == 0)){ |
VivaPenguinos | 6:3019f2f7e9d4 | 322 | wait_ms(25); |
VivaPenguinos | 6:3019f2f7e9d4 | 323 | pc.printf("Pro Button Pressed\n"); |
VivaPenguinos | 6:3019f2f7e9d4 | 324 | } |
VivaPenguinos | 6:3019f2f7e9d4 | 325 | else if (CLR_BUTT == 0){ |
VivaPenguinos | 6:3019f2f7e9d4 | 326 | wait_ms(25); |
VivaPenguinos | 6:3019f2f7e9d4 | 327 | pc.printf("Clr Button Pressed\n"); |
VivaPenguinos | 6:3019f2f7e9d4 | 328 | } |
VivaPenguinos | 6:3019f2f7e9d4 | 329 | else if (KEYREL_BUTT == 0){ |
VivaPenguinos | 6:3019f2f7e9d4 | 330 | wait_ms(25); |
VivaPenguinos | 6:3019f2f7e9d4 | 331 | pc.printf("Key Rel Button Pressed\n"); |
VivaPenguinos | 6:3019f2f7e9d4 | 332 | } |
VivaPenguinos | 6:3019f2f7e9d4 | 333 | |
VivaPenguinos | 6:3019f2f7e9d4 | 334 | myled = PRO_BUTT; |
VivaPenguinos | 1:24446776f0d2 | 335 | // Debug use only |
VivaPenguinos | 1:24446776f0d2 | 336 | //pc.printf("%c", Keytable[Verb_Number1]); |
VivaPenguinos | 1:24446776f0d2 | 337 | //pc.printf("%c", Keytable[Verb_Number2]); |
VivaPenguinos | 1:24446776f0d2 | 338 | //pc.printf("%c", Keytable[Noun_Number1]); |
VivaPenguinos | 1:24446776f0d2 | 339 | //pc.printf("%c", Keytable[Noun_Number2]); |
VivaPenguinos | 0:3ff58b093415 | 340 | } |
VivaPenguinos | 1:24446776f0d2 | 341 | } |
VivaPenguinos | 1:24446776f0d2 | 342 | |
VivaPenguinos | 5:5f08974ef8bb | 343 | void Interruption() |
VivaPenguinos | 5:5f08974ef8bb | 344 | { |
VivaPenguinos | 5:5f08974ef8bb | 345 | pc.printf("Interrupted"); |
VivaPenguinos | 5:5f08974ef8bb | 346 | pc.printf("Index:%d => Key:%c\r\n", Index, Keytable[Index]); |
VivaPenguinos | 5:5f08974ef8bb | 347 | if (Index == 12) { // Index 12 = Verb Button |
VivaPenguinos | 5:5f08974ef8bb | 348 | Verb_Button(); // Goes to Verb_Button |
VivaPenguinos | 5:5f08974ef8bb | 349 | } |
VivaPenguinos | 5:5f08974ef8bb | 350 | if (Index == 14) { // Index 14 = Noun Button |
VivaPenguinos | 5:5f08974ef8bb | 351 | Noun_Button(); // Goes to Noun_Button |
VivaPenguinos | 5:5f08974ef8bb | 352 | } |
VivaPenguinos | 5:5f08974ef8bb | 353 | if (Index == 11) { // Index 11 = Enter Button |
VivaPenguinos | 5:5f08974ef8bb | 354 | Enter_Button(); // Goes to Enter_Button |
VivaPenguinos | 5:5f08974ef8bb | 355 | } |
VivaPenguinos | 5:5f08974ef8bb | 356 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 357 | } |
VivaPenguinos | 5:5f08974ef8bb | 358 | |
VivaPenguinos | 1:24446776f0d2 | 359 | /* This function is used when the Verb Button has been pressed. Take the inputs of the button twice and determine if the buttons are integers. |
VivaPenguinos | 1:24446776f0d2 | 360 | If other buttons are pressed send it to their perspective locations. |
VivaPenguinos | 1:24446776f0d2 | 361 | */ |
VivaPenguinos | 1:24446776f0d2 | 362 | void Verb_Button(){ |
VivaPenguinos | 1:24446776f0d2 | 363 | Verbz: // Don't Ask |
VivaPenguinos | 1:24446776f0d2 | 364 | // All Variables for Verb, Noun and Enter are zeroed out |
VivaPenguinos | 4:99535d368a9f | 365 | Verb_Number1 = 0; |
VivaPenguinos | 4:99535d368a9f | 366 | Verb_Number2 = 0; |
VivaPenguinos | 4:99535d368a9f | 367 | Noun_Number1 = 0; |
VivaPenguinos | 4:99535d368a9f | 368 | Noun_Number2 = 0; |
VivaPenguinos | 4:99535d368a9f | 369 | Enter_Number1 = 0; |
VivaPenguinos | 4:99535d368a9f | 370 | Enter_Number2 = 0; |
VivaPenguinos | 1:24446776f0d2 | 371 | pc.printf("Please enter a Verb Number"); |
VivaPenguinos | 1:24446776f0d2 | 372 | __wfi(); |
VivaPenguinos | 1:24446776f0d2 | 373 | Verb_Number1 = Index; |
VivaPenguinos | 1:24446776f0d2 | 374 | if (Verb_Number1 == 12){ // This is section is used on atleast one of the two Verb_Number variabels to prevent a Nestled If within if within if. |
VivaPenguinos | 1:24446776f0d2 | 375 | goto Verbz; // Line 110 |
VivaPenguinos | 4:99535d368a9f | 376 | } else { |
VivaPenguinos | 4:99535d368a9f | 377 | V_A = Button_Sort(Verb_Number1); |
VivaPenguinos | 4:99535d368a9f | 378 | Shift(); |
VivaPenguinos | 1:24446776f0d2 | 379 | } |
VivaPenguinos | 1:24446776f0d2 | 380 | //pc.printf("%c", Verb_Number1); |
VivaPenguinos | 1:24446776f0d2 | 381 | //pc.printf("%c", Keytable[Index]); |
VivaPenguinos | 1:24446776f0d2 | 382 | __wfi(); |
VivaPenguinos | 1:24446776f0d2 | 383 | Verb_Number2 = Index; |
VivaPenguinos | 4:99535d368a9f | 384 | V_B = Button_Sort(Verb_Number2); |
VivaPenguinos | 4:99535d368a9f | 385 | Shift(); |
VivaPenguinos | 1:24446776f0d2 | 386 | //pc.printf("%c", Verb_Number2); |
VivaPenguinos | 1:24446776f0d2 | 387 | //pc.printf("%c", Verb_Number1); |
VivaPenguinos | 1:24446776f0d2 | 388 | //pc.printf("%c\n", Verb_Number2); |
VivaPenguinos | 0:3ff58b093415 | 389 | } |
VivaPenguinos | 1:24446776f0d2 | 390 | |
VivaPenguinos | 1:24446776f0d2 | 391 | /* This Function is used when the Verb Button has been Pressed. Take the inputs of the button twice and determine if the buttons are integers. |
VivaPenguinos | 1:24446776f0d2 | 392 | If other buttons are pressed send it to their perspective locations. |
VivaPenguinos | 1:24446776f0d2 | 393 | */ |
VivaPenguinos | 1:24446776f0d2 | 394 | void Noun_Button() |
VivaPenguinos | 1:24446776f0d2 | 395 | { |
VivaPenguinos | 1:24446776f0d2 | 396 | Nounz: |
VivaPenguinos | 1:24446776f0d2 | 397 | pc.printf("Please enter a Noun Number"); |
VivaPenguinos | 1:24446776f0d2 | 398 | __wfi(); |
VivaPenguinos | 1:24446776f0d2 | 399 | Noun_Number1 = Index; |
VivaPenguinos | 1:24446776f0d2 | 400 | if (Noun_Number1 == 14) {// This is section is used on atleast one of the two Noun_Number variabels to prevent a Nestled If within if within if. |
VivaPenguinos | 4:99535d368a9f | 401 | goto Nounz; |
VivaPenguinos | 0:3ff58b093415 | 402 | } |
VivaPenguinos | 1:24446776f0d2 | 403 | else{ |
VivaPenguinos | 4:99535d368a9f | 404 | N_A = Button_Sort(Noun_Number1); |
VivaPenguinos | 4:99535d368a9f | 405 | Shift(); |
VivaPenguinos | 0:3ff58b093415 | 406 | } |
VivaPenguinos | 1:24446776f0d2 | 407 | __wfi(); |
VivaPenguinos | 1:24446776f0d2 | 408 | Noun_Number2 = Index; |
VivaPenguinos | 4:99535d368a9f | 409 | N_B = Button_Sort(Noun_Number2); |
VivaPenguinos | 4:99535d368a9f | 410 | Shift(); |
VivaPenguinos | 1:24446776f0d2 | 411 | } |
VivaPenguinos | 1:24446776f0d2 | 412 | |
VivaPenguinos | 1:24446776f0d2 | 413 | /* This function is used wen the Enter button has been pressed. This function is a special circumstance since it will be checking both the Verb and Noun variables before entering variable to Enter. |
VivaPenguinos | 1:24446776f0d2 | 414 | */ |
VivaPenguinos | 1:24446776f0d2 | 415 | void Enter_Button() |
VivaPenguinos | 1:24446776f0d2 | 416 | { |
VivaPenguinos | 1:24446776f0d2 | 417 | Enterz: |
VivaPenguinos | 4:99535d368a9f | 418 | pc.printf("Checking Whether there is a variable stored in Noun or Verb 35\n"); |
VivaPenguinos | 5:5f08974ef8bb | 419 | if (Noun_Number1 == 0 && Noun_Number2 == 0 && Verb_Number1 != 2 && Verb_Number2 != 5){ // N00V35 // Test Lights |
VivaPenguinos | 1:24446776f0d2 | 420 | pc.printf("Please enter a Enter Number"); |
VivaPenguinos | 1:24446776f0d2 | 421 | __wfi(); |
VivaPenguinos | 1:24446776f0d2 | 422 | Enter_Number1 = Index; |
VivaPenguinos | 1:24446776f0d2 | 423 | if (Enter_Number1 == 11) { // This section is used on atleast one of the two Enter_Number variable to prevent a nestled if within if within if. |
VivaPenguinos | 1:24446776f0d2 | 424 | goto Enterz; |
VivaPenguinos | 1:24446776f0d2 | 425 | } |
VivaPenguinos | 1:24446776f0d2 | 426 | else{ |
VivaPenguinos | 1:24446776f0d2 | 427 | Button_Sort(Enter_Number1); |
VivaPenguinos | 1:24446776f0d2 | 428 | } |
VivaPenguinos | 1:24446776f0d2 | 429 | __wfi(); |
VivaPenguinos | 1:24446776f0d2 | 430 | Enter_Number2 = Index; |
VivaPenguinos | 1:24446776f0d2 | 431 | Button_Sort(Enter_Number2); |
VivaPenguinos | 1:24446776f0d2 | 432 | } |
VivaPenguinos | 6:3019f2f7e9d4 | 433 | // This is for P00 |
VivaPenguinos | 5:5f08974ef8bb | 434 | else if(Noun_Number1 == 0 && Noun_Number2 == 0 && Verb_Number1 == 2 && Verb_Number2 == 8){ //N00V37 |
VivaPenguinos | 6:3019f2f7e9d4 | 435 | pc.printf("This is the P00 program \n"); |
VivaPenguinos | 5:5f08974ef8bb | 436 | pc.printf("Please enter a Enter Number\n"); |
VivaPenguinos | 5:5f08974ef8bb | 437 | //Noun_Number1 = 0x0f; |
VivaPenguinos | 5:5f08974ef8bb | 438 | //Noun_Number2 = 0x0f; |
VivaPenguinos | 5:5f08974ef8bb | 439 | NO_Light(5); |
VivaPenguinos | 5:5f08974ef8bb | 440 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 441 | do { |
VivaPenguinos | 5:5f08974ef8bb | 442 | N_GET(); |
VivaPenguinos | 5:5f08974ef8bb | 443 | V_A = 0x03; |
VivaPenguinos | 5:5f08974ef8bb | 444 | V_B = 0x07; |
VivaPenguinos | 5:5f08974ef8bb | 445 | N_GET(); |
VivaPenguinos | 5:5f08974ef8bb | 446 | Shift(); |
VivaPenguinos | 5:5f08974ef8bb | 447 | wait(.5); |
VivaPenguinos | 5:5f08974ef8bb | 448 | N_GET(); |
VivaPenguinos | 5:5f08974ef8bb | 449 | NO_Light(4); // No Light Verb |
VivaPenguinos | 5:5f08974ef8bb | 450 | NO_Light(5); |
VivaPenguinos | 5:5f08974ef8bb | 451 | N_GET(); |
VivaPenguinos | 5:5f08974ef8bb | 452 | NO_Light(5); |
VivaPenguinos | 5:5f08974ef8bb | 453 | Shift(); |
VivaPenguinos | 5:5f08974ef8bb | 454 | wait(.5); |
VivaPenguinos | 5:5f08974ef8bb | 455 | } while (N_Position != 3); |
VivaPenguinos | 5:5f08974ef8bb | 456 | V_A = 3; |
VivaPenguinos | 5:5f08974ef8bb | 457 | V_B = 7; |
VivaPenguinos | 5:5f08974ef8bb | 458 | N_A = Enter_Number1; |
VivaPenguinos | 5:5f08974ef8bb | 459 | N_B = Enter_Number2; |
VivaPenguinos | 5:5f08974ef8bb | 460 | Shift(); |
VivaPenguinos | 5:5f08974ef8bb | 461 | compare(); |
VivaPenguinos | 5:5f08974ef8bb | 462 | pc.printf("Out of P01, Waiting for Orders\n"); |
VivaPenguinos | 5:5f08974ef8bb | 463 | // pc.printf("V1 %d \n", Verb_Number1); |
VivaPenguinos | 5:5f08974ef8bb | 464 | // pc.printf("V2 %d \n", Verb_Number2); |
VivaPenguinos | 5:5f08974ef8bb | 465 | // pc.printf("N1 %d \n", Noun_Number1); |
VivaPenguinos | 5:5f08974ef8bb | 466 | // pc.printf("N2 %d \n", Noun_Number2); |
VivaPenguinos | 5:5f08974ef8bb | 467 | // pc.printf("E1 %d \n", Enter_Number1); |
VivaPenguinos | 5:5f08974ef8bb | 468 | // pc.printf("E2 %d \n", Enter_Number2); |
VivaPenguinos | 5:5f08974ef8bb | 469 | N_Position = 1; |
VivaPenguinos | 5:5f08974ef8bb | 470 | __wfi(); |
VivaPenguinos | 5:5f08974ef8bb | 471 | if (Index == 11) { // 11 = Enter Button |
VivaPenguinos | 5:5f08974ef8bb | 472 | pc.printf("Compare\n"); |
VivaPenguinos | 5:5f08974ef8bb | 473 | compare(); |
VivaPenguinos | 5:5f08974ef8bb | 474 | } |
VivaPenguinos | 5:5f08974ef8bb | 475 | else if (Index == 14) { |
VivaPenguinos | 5:5f08974ef8bb | 476 | Noun_Button(); |
VivaPenguinos | 5:5f08974ef8bb | 477 | } |
VivaPenguinos | 5:5f08974ef8bb | 478 | else if (Index == 12) { |
VivaPenguinos | 5:5f08974ef8bb | 479 | Verb_Button(); |
VivaPenguinos | 5:5f08974ef8bb | 480 | } |
VivaPenguinos | 5:5f08974ef8bb | 481 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 482 | } |
VivaPenguinos | 4:99535d368a9f | 483 | else {// (Noun_Number1 != 0 && Noun_Number2 != 0){ |
VivaPenguinos | 1:24446776f0d2 | 484 | pc.printf("Check completed, Executing"); |
VivaPenguinos | 4:99535d368a9f | 485 | Index = -1; |
VivaPenguinos | 1:24446776f0d2 | 486 | compare(); |
VivaPenguinos | 1:24446776f0d2 | 487 | } |
VivaPenguinos | 1:24446776f0d2 | 488 | |
VivaPenguinos | 1:24446776f0d2 | 489 | } |
VivaPenguinos | 1:24446776f0d2 | 490 | |
VivaPenguinos | 1:24446776f0d2 | 491 | // This function is used to sort the button press for Verb and Noun. |
VivaPenguinos | 4:99535d368a9f | 492 | int Button_Sort(int Sort) |
VivaPenguinos | 1:24446776f0d2 | 493 | { |
VivaPenguinos | 4:99535d368a9f | 494 | if (Sort == 0){ // Index 0 - Char 1 |
VivaPenguinos | 4:99535d368a9f | 495 | return 0x01; |
VivaPenguinos | 1:24446776f0d2 | 496 | } |
VivaPenguinos | 4:99535d368a9f | 497 | else if (Sort == 1) { // Index 1 - Char 2 |
VivaPenguinos | 4:99535d368a9f | 498 | return 0x02; |
VivaPenguinos | 1:24446776f0d2 | 499 | } |
VivaPenguinos | 4:99535d368a9f | 500 | else if (Sort == 2) { // Index 2 - Char 3 |
VivaPenguinos | 4:99535d368a9f | 501 | return 0x03; |
VivaPenguinos | 4:99535d368a9f | 502 | } |
VivaPenguinos | 4:99535d368a9f | 503 | else if (Sort == 3) { // Index 3 - Char + comparing the array number NOT what value in the array it is. Actual Array value is + |
VivaPenguinos | 1:24446776f0d2 | 504 | pc.printf("+"); |
VivaPenguinos | 5:5f08974ef8bb | 505 | return 0x10; |
VivaPenguinos | 1:24446776f0d2 | 506 | } |
VivaPenguinos | 4:99535d368a9f | 507 | else if (Sort == 4) { // Index 4 - Char 4 |
VivaPenguinos | 4:99535d368a9f | 508 | return 0x04; |
VivaPenguinos | 4:99535d368a9f | 509 | } |
VivaPenguinos | 4:99535d368a9f | 510 | else if (Sort == 5) { // Index 5 - Char 5 |
VivaPenguinos | 4:99535d368a9f | 511 | return 0x05; |
VivaPenguinos | 4:99535d368a9f | 512 | } |
VivaPenguinos | 4:99535d368a9f | 513 | else if (Sort == 6) { // Index 6 - Char 6 |
VivaPenguinos | 4:99535d368a9f | 514 | return 0x06; |
VivaPenguinos | 4:99535d368a9f | 515 | } |
VivaPenguinos | 4:99535d368a9f | 516 | else if (Sort == 7) { // Index 7 - Char - comparing the array number NOT what value in the array it is. Actual Array value is - |
VivaPenguinos | 1:24446776f0d2 | 517 | pc.printf("-"); |
VivaPenguinos | 5:5f08974ef8bb | 518 | return 0x11; |
VivaPenguinos | 1:24446776f0d2 | 519 | } |
VivaPenguinos | 4:99535d368a9f | 520 | else if (Sort == 8) { // Index 8 - Char 7 |
VivaPenguinos | 4:99535d368a9f | 521 | return 0x07; |
VivaPenguinos | 4:99535d368a9f | 522 | } |
VivaPenguinos | 4:99535d368a9f | 523 | else if (Sort == 9) { // Index 9 - Char 8 |
VivaPenguinos | 4:99535d368a9f | 524 | return 0x08; |
VivaPenguinos | 4:99535d368a9f | 525 | } |
VivaPenguinos | 4:99535d368a9f | 526 | else if (Sort == 10) { // Index 10 - Char 9 |
VivaPenguinos | 4:99535d368a9f | 527 | return 0x09; |
VivaPenguinos | 4:99535d368a9f | 528 | } |
VivaPenguinos | 4:99535d368a9f | 529 | else if (Sort == 12){ // Index 12 - Char V comparing the array number NOT what value in the array it is. Actual Array value is V |
VivaPenguinos | 4:99535d368a9f | 530 | Verb_Button(); |
VivaPenguinos | 4:99535d368a9f | 531 | } |
VivaPenguinos | 4:99535d368a9f | 532 | else if (Sort == 13) { // Index 13 - Char 0 |
VivaPenguinos | 4:99535d368a9f | 533 | return 0x00; |
VivaPenguinos | 4:99535d368a9f | 534 | } |
VivaPenguinos | 4:99535d368a9f | 535 | else if (Sort == 14) { // Index 14 - Char N comparing the array number NOT what value in the array it is. Actual Array value is N |
VivaPenguinos | 4:99535d368a9f | 536 | Noun_Button(); |
VivaPenguinos | 4:99535d368a9f | 537 | } |
VivaPenguinos | 1:24446776f0d2 | 538 | else if (Sort == 15) { //comparing the array number NOT what value in the array it is. Actual Array value is R |
VivaPenguinos | 1:24446776f0d2 | 539 | pc.printf("R"); |
VivaPenguinos | 1:24446776f0d2 | 540 | } |
VivaPenguinos | 4:99535d368a9f | 541 | return 0; |
VivaPenguinos | 1:24446776f0d2 | 542 | } |
VivaPenguinos | 4:99535d368a9f | 543 | |
VivaPenguinos | 1:24446776f0d2 | 544 | // Compares the button to what program the DSKY should be running. This section will be inefficent until I can improve on my programming skills :] |
VivaPenguinos | 1:24446776f0d2 | 545 | void compare() |
VivaPenguinos | 1:24446776f0d2 | 546 | { |
VivaPenguinos | 1:24446776f0d2 | 547 | if (Verb_Number1 == 0 && Verb_Number2 == 6 && Noun_Number1 == 2 && Noun_Number2 == 6 && Enter_Number1 == 0 && Enter_Number2 == 0) {// Verb 16, Noun 36, Enter 00 |
VivaPenguinos | 4:99535d368a9f | 548 | // Configure GET |
VivaPenguinos | 6:3019f2f7e9d4 | 549 | pc.printf("Display GET\n"); |
VivaPenguinos | 1:24446776f0d2 | 550 | Ground_Elapse_Time(); |
VivaPenguinos | 4:99535d368a9f | 551 | } else if (Verb_Number1 == 2 && Verb_Number2 == 5 && Noun_Number1 == 0 && Noun_Number2 == 0 && Enter_Number1 == 0 && Enter_Number2 == 0) { // Verb 35 Noun 00 Enter 00 |
VivaPenguinos | 4:99535d368a9f | 552 | // Test Lights |
VivaPenguinos | 6:3019f2f7e9d4 | 553 | pc.printf("Testing Lights\n"); |
VivaPenguinos | 4:99535d368a9f | 554 | Test_Lights(); |
VivaPenguinos | 4:99535d368a9f | 555 | } else if (Verb_Number1 == 1 && Verb_Number2 == 5 && Noun_Number1 == 2 && Noun_Number2 == 6 && Enter_Number1 == 0 && Enter_Number2 == 0) { // Verb 25, Noun 36, Enter 00 |
VivaPenguinos | 4:99535d368a9f | 556 | // GET COnfiguration |
VivaPenguinos | 6:3019f2f7e9d4 | 557 | pc.printf("GET configuration\n"); |
VivaPenguinos | 4:99535d368a9f | 558 | GET_Config(); |
VivaPenguinos | 5:5f08974ef8bb | 559 | } else if (Verb_Number1 == 2 && Verb_Number2 == 8 && Noun_Number1 == 0 && Noun_Number2 == 0 && Enter_Number1 == 0 && Enter_Number2 == 0) { // Verb 37, Noun 00, Enter 00 |
VivaPenguinos | 5:5f08974ef8bb | 560 | // CMC Idling Program |
VivaPenguinos | 6:3019f2f7e9d4 | 561 | pc.printf("CMC Idling Program\n"); |
VivaPenguinos | 5:5f08974ef8bb | 562 | CMC_Idle(); |
VivaPenguinos | 5:5f08974ef8bb | 563 | } else if (Verb_Number1 == 2 && Verb_Number2 == 8 && Noun_Number1 == 0 && Noun_Number2 == 0 && Enter_Number1 == 0 && Enter_Number2 == 1) { // Verb 37, Noun 00, Enter 01 |
VivaPenguinos | 6:3019f2f7e9d4 | 564 | pc.printf("Prelaunch or Service - Initialization Program\n"); |
VivaPenguinos | 5:5f08974ef8bb | 565 | PreLaunch_Initialization(); |
VivaPenguinos | 6:3019f2f7e9d4 | 566 | } else if (Verb_Number1 == 2 && Verb_Number2 == 8 && Noun_Number1 == 0 && Noun_Number2 == 0 && Enter_Number1 == 0 && Enter_Number2 == 6) { |
VivaPenguinos | 6:3019f2f7e9d4 | 567 | pc.printf("CMC Power Down Program\n"); |
VivaPenguinos | 6:3019f2f7e9d4 | 568 | CMC_Powerdown(); |
VivaPenguinos | 6:3019f2f7e9d4 | 569 | } |
VivaPenguinos | 6:3019f2f7e9d4 | 570 | //else if (Verb_Number1 == 1 && Verb_Number2 == 0 && Noun_Number1 == 0 && Noun_Number2 == 0 && Enter_Number1 == 0 && Enter_Number2 == 0) { // Verb 21, Noun 00, Enter 00 |
VivaPenguinos | 5:5f08974ef8bb | 571 | // R1_Component(); |
VivaPenguinos | 5:5f08974ef8bb | 572 | //} |
VivaPenguinos | 5:5f08974ef8bb | 573 | else { |
VivaPenguinos | 5:5f08974ef8bb | 574 | pc.printf("Failed"); |
VivaPenguinos | 0:3ff58b093415 | 575 | } |
VivaPenguinos | 1:24446776f0d2 | 576 | } |
VivaPenguinos | 0:3ff58b093415 | 577 | |
VivaPenguinos | 1:24446776f0d2 | 578 | void ShiftingOut(int myDataOut) |
VivaPenguinos | 1:24446776f0d2 | 579 | { |
VivaPenguinos | 0:3ff58b093415 | 580 | // This shifts 8 bits out to the MSB first, The the rising edge of the clock, while clock idles low. |
VivaPenguinos | 0:3ff58b093415 | 581 | // Internal Fucntions |
VivaPenguinos | 0:3ff58b093415 | 582 | DataPin = 0; |
VivaPenguinos | 0:3ff58b093415 | 583 | ClockPin = 0; |
VivaPenguinos | 0:3ff58b093415 | 584 | int i= 0; |
VivaPenguinos | 0:3ff58b093415 | 585 | int pinState; |
VivaPenguinos | 0:3ff58b093415 | 586 | // Clears Everything within shift registers |
VivaPenguinos | 0:3ff58b093415 | 587 | DataPin = 0; |
VivaPenguinos | 0:3ff58b093415 | 588 | ClockPin = 0; |
VivaPenguinos | 1:24446776f0d2 | 589 | |
VivaPenguinos | 4:99535d368a9f | 590 | for (i=3; i>= 0; i--) { |
VivaPenguinos | 0:3ff58b093415 | 591 | ClockPin = 0; |
VivaPenguinos | 1:24446776f0d2 | 592 | |
VivaPenguinos | 0:3ff58b093415 | 593 | // Value passed to my data out |
VivaPenguinos | 0:3ff58b093415 | 594 | if ( myDataOut & (1<<i)) { |
VivaPenguinos | 0:3ff58b093415 | 595 | pinState = 1; |
VivaPenguinos | 0:3ff58b093415 | 596 | myled = 1; |
VivaPenguinos | 4:99535d368a9f | 597 | //pc.printf("1"); |
VivaPenguinos | 1:24446776f0d2 | 598 | } else { |
VivaPenguinos | 0:3ff58b093415 | 599 | pinState = 0; |
VivaPenguinos | 0:3ff58b093415 | 600 | myled = 0; |
VivaPenguinos | 4:99535d368a9f | 601 | //pc.printf("0"); |
VivaPenguinos | 0:3ff58b093415 | 602 | } |
VivaPenguinos | 0:3ff58b093415 | 603 | DataPin = pinState; |
VivaPenguinos | 0:3ff58b093415 | 604 | ClockPin = 1; |
VivaPenguinos | 0:3ff58b093415 | 605 | DataPin = 0; |
VivaPenguinos | 1:24446776f0d2 | 606 | } |
VivaPenguinos | 4:99535d368a9f | 607 | //pc.printf("\n"); |
VivaPenguinos | 0:3ff58b093415 | 608 | ClockPin = 0; |
VivaPenguinos | 0:3ff58b093415 | 609 | DataPin = 1; |
VivaPenguinos | 1:24446776f0d2 | 610 | } |
VivaPenguinos | 0:3ff58b093415 | 611 | |
VivaPenguinos | 4:99535d368a9f | 612 | // This function is used for shifting all Shift_X variables into the 7 segment display. |
VivaPenguinos | 4:99535d368a9f | 613 | void Shift() |
VivaPenguinos | 4:99535d368a9f | 614 | { |
VivaPenguinos | 4:99535d368a9f | 615 | LatchPin = 0; |
VivaPenguinos | 4:99535d368a9f | 616 | ShiftingOut(P_B); |
VivaPenguinos | 4:99535d368a9f | 617 | ShiftingOut(P_A); |
VivaPenguinos | 4:99535d368a9f | 618 | ShiftingOut(V_B); |
VivaPenguinos | 4:99535d368a9f | 619 | ShiftingOut(V_A); |
VivaPenguinos | 4:99535d368a9f | 620 | ShiftingOut(N_B); |
VivaPenguinos | 4:99535d368a9f | 621 | ShiftingOut(N_A); |
VivaPenguinos | 4:99535d368a9f | 622 | ShiftingOut(R3_E); |
VivaPenguinos | 4:99535d368a9f | 623 | ShiftingOut(R3_D); |
VivaPenguinos | 4:99535d368a9f | 624 | ShiftingOut(R3_C); |
VivaPenguinos | 4:99535d368a9f | 625 | ShiftingOut(R3_B); |
VivaPenguinos | 4:99535d368a9f | 626 | ShiftingOut(R3_A); |
VivaPenguinos | 4:99535d368a9f | 627 | ShiftingOut(R2_E); |
VivaPenguinos | 4:99535d368a9f | 628 | ShiftingOut(R2_D); |
VivaPenguinos | 4:99535d368a9f | 629 | ShiftingOut(R2_C); |
VivaPenguinos | 4:99535d368a9f | 630 | ShiftingOut(R2_B); |
VivaPenguinos | 4:99535d368a9f | 631 | ShiftingOut(R2_A); |
VivaPenguinos | 4:99535d368a9f | 632 | ShiftingOut(R1_E); |
VivaPenguinos | 4:99535d368a9f | 633 | ShiftingOut(R1_D); |
VivaPenguinos | 4:99535d368a9f | 634 | ShiftingOut(R1_C); |
VivaPenguinos | 4:99535d368a9f | 635 | ShiftingOut(R1_B); |
VivaPenguinos | 4:99535d368a9f | 636 | ShiftingOut(R1_A); |
VivaPenguinos | 4:99535d368a9f | 637 | LatchPin = 1; |
VivaPenguinos | 4:99535d368a9f | 638 | } |
VivaPenguinos | 4:99535d368a9f | 639 | |
VivaPenguinos | 1:24446776f0d2 | 640 | //blinks the whole registered based on the number of times you want to blink with a certain delay |
VivaPenguinos | 1:24446776f0d2 | 641 | void blinkAll(int amount, int delay) |
VivaPenguinos | 1:24446776f0d2 | 642 | { |
VivaPenguinos | 4:99535d368a9f | 643 | LatchPin = 0; // Before shift |
VivaPenguinos | 4:99535d368a9f | 644 | //ShiftingOut(0); |
VivaPenguinos | 4:99535d368a9f | 645 | //ShiftingOut(0); |
VivaPenguinos | 4:99535d368a9f | 646 | LatchPin = 1; // Done shift |
VivaPenguinos | 0:3ff58b093415 | 647 | wait(0.2); |
VivaPenguinos | 0:3ff58b093415 | 648 | for (int x = 0; x < amount; x++) { |
VivaPenguinos | 0:3ff58b093415 | 649 | LatchPin = 0; |
VivaPenguinos | 4:99535d368a9f | 650 | pc.printf("sending\n"); |
VivaPenguinos | 4:99535d368a9f | 651 | for (int s = 0; s < 22; s++) |
VivaPenguinos | 4:99535d368a9f | 652 | { |
VivaPenguinos | 4:99535d368a9f | 653 | ShiftingOut(0x08); |
VivaPenguinos | 5:5f08974ef8bb | 654 | UPLINK_ACTY = 1; |
VivaPenguinos | 5:5f08974ef8bb | 655 | NO_ATT = 1; |
VivaPenguinos | 5:5f08974ef8bb | 656 | STBY = 1; |
VivaPenguinos | 5:5f08974ef8bb | 657 | KEY_REL = 1; |
VivaPenguinos | 5:5f08974ef8bb | 658 | OPP_ERR = 1; |
VivaPenguinos | 5:5f08974ef8bb | 659 | TEMP = 1; |
VivaPenguinos | 5:5f08974ef8bb | 660 | GIMBAL_LOCK = 1; |
VivaPenguinos | 5:5f08974ef8bb | 661 | PROG = 1; |
VivaPenguinos | 5:5f08974ef8bb | 662 | RESTART = 1; |
VivaPenguinos | 5:5f08974ef8bb | 663 | TRACKER = 1; |
VivaPenguinos | 5:5f08974ef8bb | 664 | R1_POS = 1; |
VivaPenguinos | 5:5f08974ef8bb | 665 | R2_POS = 1; |
VivaPenguinos | 5:5f08974ef8bb | 666 | R3_POS = 1; |
VivaPenguinos | 5:5f08974ef8bb | 667 | R1_NEG = 1; |
VivaPenguinos | 5:5f08974ef8bb | 668 | R2_NEG = 1; |
VivaPenguinos | 5:5f08974ef8bb | 669 | R3_NEG = 1; |
VivaPenguinos | 5:5f08974ef8bb | 670 | COMP_ACTY = 1; |
VivaPenguinos | 4:99535d368a9f | 671 | } |
VivaPenguinos | 0:3ff58b093415 | 672 | LatchPin = 1; |
VivaPenguinos | 0:3ff58b093415 | 673 | wait(delay); |
VivaPenguinos | 0:3ff58b093415 | 674 | LatchPin = 0; |
VivaPenguinos | 4:99535d368a9f | 675 | for (int s = 0; s < 22; s++) |
VivaPenguinos | 4:99535d368a9f | 676 | { |
VivaPenguinos | 5:5f08974ef8bb | 677 | ShiftingOut(0x0f); |
VivaPenguinos | 5:5f08974ef8bb | 678 | UPLINK_ACTY = 0; |
VivaPenguinos | 5:5f08974ef8bb | 679 | NO_ATT = 0; |
VivaPenguinos | 5:5f08974ef8bb | 680 | STBY = 0; |
VivaPenguinos | 5:5f08974ef8bb | 681 | KEY_REL = 0; |
VivaPenguinos | 5:5f08974ef8bb | 682 | OPP_ERR = 0; |
VivaPenguinos | 5:5f08974ef8bb | 683 | TEMP = 0; |
VivaPenguinos | 5:5f08974ef8bb | 684 | GIMBAL_LOCK = 0; |
VivaPenguinos | 5:5f08974ef8bb | 685 | PROG = 0; |
VivaPenguinos | 5:5f08974ef8bb | 686 | RESTART = 0; |
VivaPenguinos | 5:5f08974ef8bb | 687 | TRACKER = 0; |
VivaPenguinos | 5:5f08974ef8bb | 688 | R1_POS = 0; |
VivaPenguinos | 5:5f08974ef8bb | 689 | R2_POS = 0; |
VivaPenguinos | 5:5f08974ef8bb | 690 | R3_POS = 0; |
VivaPenguinos | 5:5f08974ef8bb | 691 | R1_NEG = 0; |
VivaPenguinos | 5:5f08974ef8bb | 692 | R2_NEG = 0; |
VivaPenguinos | 5:5f08974ef8bb | 693 | R3_NEG = 0; |
VivaPenguinos | 5:5f08974ef8bb | 694 | COMP_ACTY = 0; |
VivaPenguinos | 4:99535d368a9f | 695 | } |
VivaPenguinos | 0:3ff58b093415 | 696 | LatchPin = 1; |
VivaPenguinos | 0:3ff58b093415 | 697 | wait(delay); |
VivaPenguinos | 1:24446776f0d2 | 698 | } |
VivaPenguinos | 1:24446776f0d2 | 699 | } |
VivaPenguinos | 1:24446776f0d2 | 700 | |
VivaPenguinos | 4:99535d368a9f | 701 | // The Ground Elapse Time is refrence to range zero or the last integeral before liftoff. |
VivaPenguinos | 4:99535d368a9f | 702 | // Page CM-9 |
VivaPenguinos | 4:99535d368a9f | 703 | // 00XXX h |
VivaPenguinos | 4:99535d368a9f | 704 | // 000XX min |
VivaPenguinos | 4:99535d368a9f | 705 | // 0XX.XX s (Code current does not follow this format) |
VivaPenguinos | 1:24446776f0d2 | 706 | void Ground_Elapse_Time() |
VivaPenguinos | 1:24446776f0d2 | 707 | { |
VivaPenguinos | 4:99535d368a9f | 708 | NO_Light(7); // Clears all the 7 Segment first. |
VivaPenguinos | 4:99535d368a9f | 709 | // Displays V16N36 on the 7 segments |
VivaPenguinos | 4:99535d368a9f | 710 | V_A = 0x01; |
VivaPenguinos | 4:99535d368a9f | 711 | V_B = 0x06; |
VivaPenguinos | 4:99535d368a9f | 712 | N_A = 0x03; |
VivaPenguinos | 4:99535d368a9f | 713 | N_B = 0x06; |
VivaPenguinos | 4:99535d368a9f | 714 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 715 | int GET_FLAG = 1; |
VivaPenguinos | 4:99535d368a9f | 716 | while(GET_FLAG == 1) { |
VivaPenguinos | 4:99535d368a9f | 717 | int minute = 0; |
VivaPenguinos | 4:99535d368a9f | 718 | int Seconds = 0; |
VivaPenguinos | 4:99535d368a9f | 719 | int Hours = 0; |
VivaPenguinos | 4:99535d368a9f | 720 | int minutemod = 0; // Minute Modulo |
VivaPenguinos | 4:99535d368a9f | 721 | int R1D = 0x00; |
VivaPenguinos | 4:99535d368a9f | 722 | int R1E = 0x00; |
VivaPenguinos | 4:99535d368a9f | 723 | int R2D = 0x00; |
VivaPenguinos | 4:99535d368a9f | 724 | int R2E = 0x00; |
VivaPenguinos | 4:99535d368a9f | 725 | int R3D = 0x00; |
VivaPenguinos | 4:99535d368a9f | 726 | int R3E = 0x00; |
VivaPenguinos | 4:99535d368a9f | 727 | time_t seconds = clk.time(NULL); |
VivaPenguinos | 4:99535d368a9f | 728 | pc.printf ("S = %d\n", seconds); |
VivaPenguinos | 4:99535d368a9f | 729 | Time_Difference = (seconds + GET_Config_Time) - TIME_VALUE; |
VivaPenguinos | 4:99535d368a9f | 730 | printf("TIME=%d \n", Time_Difference); // Displays time elapsed based on seconds elapsed. |
VivaPenguinos | 4:99535d368a9f | 731 | Hours = Time_Difference/3600; // Divide seconds by 3600 seconds |
VivaPenguinos | 4:99535d368a9f | 732 | Seconds = Time_Difference%60; // Get the remainder of time difference after 60 seconds |
VivaPenguinos | 4:99535d368a9f | 733 | minute = Time_Difference/60; // Divide the seconds by 3600 |
VivaPenguinos | 4:99535d368a9f | 734 | // Comments: 7 Segments Location |
VivaPenguinos | 4:99535d368a9f | 735 | minutemod = minute%60; // Get the remainder of the minutemod after 60 seconds |
VivaPenguinos | 4:99535d368a9f | 736 | R3D = (Hours%60)/10; // Get the modulo of the hour variable then divde by 10 to get single digit [][][][x][] |
VivaPenguinos | 4:99535d368a9f | 737 | R3E = Hours%10; // Get the modulo of the Hours variable by 10 to get single digit [][][][][x] |
VivaPenguinos | 4:99535d368a9f | 738 | R2D = minutemod/10; // Divide the minute variable by 10 to get single digit [][][][x][] |
VivaPenguinos | 4:99535d368a9f | 739 | R2E = minute%10; // Get the remainder of the minute variable to get single digit [][][][][x] |
VivaPenguinos | 4:99535d368a9f | 740 | R1D = Seconds/10; // Divide the seconds variable by 10 to get single digit [][][][x][] |
VivaPenguinos | 4:99535d368a9f | 741 | R1E = Time_Difference%10; // Get the remainder of the Time_Difference to get single digit [][][][][x] |
VivaPenguinos | 4:99535d368a9f | 742 | // Debug Use: |
VivaPenguinos | 4:99535d368a9f | 743 | // pc.printf("%d \n", minute); |
VivaPenguinos | 4:99535d368a9f | 744 | // pc.printf("%o \n", R2E); |
VivaPenguinos | 4:99535d368a9f | 745 | // pc.printf("%o \n", R2D); |
VivaPenguinos | 4:99535d368a9f | 746 | R3_E = R3E; |
VivaPenguinos | 4:99535d368a9f | 747 | R3_D = R3D; |
VivaPenguinos | 4:99535d368a9f | 748 | R1_E = R1E; |
VivaPenguinos | 4:99535d368a9f | 749 | R1_D = R1D; |
VivaPenguinos | 4:99535d368a9f | 750 | R2_E = R2E; |
VivaPenguinos | 4:99535d368a9f | 751 | R2_D = R2D; |
VivaPenguinos | 4:99535d368a9f | 752 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 753 | //pc.printf("%i \n",(Time_Difference%10) + ((Time_Difference/10)<<4)); // Decimal to BCD |
VivaPenguinos | 4:99535d368a9f | 754 | //printf("Time as a basic string = %s\r", ctime(&seconds)); |
VivaPenguinos | 4:99535d368a9f | 755 | if (Index >-1) { |
VivaPenguinos | 4:99535d368a9f | 756 | GET_FLAG = 0; |
VivaPenguinos | 4:99535d368a9f | 757 | pc.printf("Interrupted"); |
VivaPenguinos | 4:99535d368a9f | 758 | pc.printf("Index:%d => Key:%c\r\n", Index, Keytable[Index]); |
VivaPenguinos | 4:99535d368a9f | 759 | if (Index == 12) { // Index 12 = Verb Button |
VivaPenguinos | 4:99535d368a9f | 760 | Verb_Button(); // Goes to Verb_Button |
VivaPenguinos | 4:99535d368a9f | 761 | GET_FLAG = 0; |
VivaPenguinos | 4:99535d368a9f | 762 | break; |
VivaPenguinos | 4:99535d368a9f | 763 | } else if (Index == 14) { // Index 14 = Noun Button |
VivaPenguinos | 4:99535d368a9f | 764 | Noun_Button(); // Goes to Noun_Button |
VivaPenguinos | 4:99535d368a9f | 765 | GET_FLAG = 0; |
VivaPenguinos | 4:99535d368a9f | 766 | break; |
VivaPenguinos | 4:99535d368a9f | 767 | } else if (Index == 11) { // Index 11 = Enter Button |
VivaPenguinos | 4:99535d368a9f | 768 | Enter_Button(); // Goes to Enter_Button |
VivaPenguinos | 4:99535d368a9f | 769 | GET_FLAG = 0; |
VivaPenguinos | 4:99535d368a9f | 770 | break; |
VivaPenguinos | 4:99535d368a9f | 771 | } |
VivaPenguinos | 4:99535d368a9f | 772 | Index = -1; |
VivaPenguinos | 4:99535d368a9f | 773 | GET_FLAG = 0; |
VivaPenguinos | 4:99535d368a9f | 774 | break; |
VivaPenguinos | 4:99535d368a9f | 775 | } |
VivaPenguinos | 4:99535d368a9f | 776 | wait(1); |
VivaPenguinos | 4:99535d368a9f | 777 | } |
VivaPenguinos | 4:99535d368a9f | 778 | } |
VivaPenguinos | 4:99535d368a9f | 779 | |
VivaPenguinos | 4:99535d368a9f | 780 | // This function tells the shift registers to not display anything on the 7 segments. The integer L is used to specificy which area to zero. |
VivaPenguinos | 4:99535d368a9f | 781 | // 1 = Row 1 |
VivaPenguinos | 4:99535d368a9f | 782 | // 2 = Row 2 |
VivaPenguinos | 4:99535d368a9f | 783 | // 3 = Row 3 |
VivaPenguinos | 4:99535d368a9f | 784 | // 4 = Verb |
VivaPenguinos | 4:99535d368a9f | 785 | // 5 = Nouns |
VivaPenguinos | 4:99535d368a9f | 786 | // 6 = Program Number |
VivaPenguinos | 4:99535d368a9f | 787 | // 7 = All lights off |
VivaPenguinos | 4:99535d368a9f | 788 | void NO_Light(int L) |
VivaPenguinos | 4:99535d368a9f | 789 | { |
VivaPenguinos | 4:99535d368a9f | 790 | |
VivaPenguinos | 4:99535d368a9f | 791 | switch(L) { |
VivaPenguinos | 4:99535d368a9f | 792 | case 1: |
VivaPenguinos | 4:99535d368a9f | 793 | R1_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 794 | R1_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 795 | R1_C = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 796 | R1_D = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 797 | R1_E = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 798 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 799 | case 2: |
VivaPenguinos | 4:99535d368a9f | 800 | R2_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 801 | R2_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 802 | R2_C = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 803 | R2_D = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 804 | R2_E = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 805 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 806 | case 3: |
VivaPenguinos | 4:99535d368a9f | 807 | R3_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 808 | R3_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 809 | R3_C = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 810 | R3_D = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 811 | R3_E = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 812 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 813 | case 4: |
VivaPenguinos | 4:99535d368a9f | 814 | V_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 815 | V_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 816 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 817 | case 5: |
VivaPenguinos | 4:99535d368a9f | 818 | N_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 819 | N_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 820 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 821 | case 6: |
VivaPenguinos | 4:99535d368a9f | 822 | P_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 823 | P_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 824 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 825 | case 7: |
VivaPenguinos | 4:99535d368a9f | 826 | R1_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 827 | R1_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 828 | R1_C = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 829 | R1_D = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 830 | R1_E = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 831 | R2_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 832 | R2_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 833 | R2_C = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 834 | R2_D = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 835 | R2_E = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 836 | R3_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 837 | R3_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 838 | R3_C = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 839 | R3_D = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 840 | R3_E = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 841 | V_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 842 | V_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 843 | N_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 844 | N_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 845 | P_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 846 | P_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 847 | Shift(); |
VivaPenguinos | 6:3019f2f7e9d4 | 848 | case 8: |
VivaPenguinos | 6:3019f2f7e9d4 | 849 | UPLINK_ACTY = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 850 | NO_ATT = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 851 | STBY = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 852 | KEY_REL = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 853 | OPP_ERR = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 854 | TEMP = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 855 | GIMBAL_LOCK = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 856 | PROG = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 857 | RESTART = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 858 | TRACKER = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 859 | R1_POS = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 860 | R2_POS = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 861 | R3_POS = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 862 | R1_NEG = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 863 | R2_NEG = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 864 | R3_NEG = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 865 | COMP_ACTY = 0; |
VivaPenguinos | 4:99535d368a9f | 866 | } |
VivaPenguinos | 4:99535d368a9f | 867 | } |
VivaPenguinos | 4:99535d368a9f | 868 | |
VivaPenguinos | 4:99535d368a9f | 869 | // Test lights is to make sure all the 7 segments and indicator lights worked prior to lift-off. |
VivaPenguinos | 4:99535d368a9f | 870 | void Test_Lights() |
VivaPenguinos | 4:99535d368a9f | 871 | { |
VivaPenguinos | 4:99535d368a9f | 872 | for(int x = 0; x < 7; x++) { |
VivaPenguinos | 4:99535d368a9f | 873 | R1_A = 0x08; |
VivaPenguinos | 4:99535d368a9f | 874 | R1_B = 0x08; |
VivaPenguinos | 4:99535d368a9f | 875 | R1_C = 0x08; |
VivaPenguinos | 4:99535d368a9f | 876 | R1_D = 0x08; |
VivaPenguinos | 4:99535d368a9f | 877 | R1_E = 0x08; |
VivaPenguinos | 4:99535d368a9f | 878 | R2_A = 0x08; |
VivaPenguinos | 4:99535d368a9f | 879 | R2_B = 0x08; |
VivaPenguinos | 4:99535d368a9f | 880 | R2_C = 0x08; |
VivaPenguinos | 4:99535d368a9f | 881 | R2_D = 0x08; |
VivaPenguinos | 4:99535d368a9f | 882 | R2_E = 0x08; |
VivaPenguinos | 4:99535d368a9f | 883 | R3_A = 0x08; |
VivaPenguinos | 4:99535d368a9f | 884 | R3_B = 0x08; |
VivaPenguinos | 4:99535d368a9f | 885 | R3_C = 0x08; |
VivaPenguinos | 4:99535d368a9f | 886 | R3_D = 0x08; |
VivaPenguinos | 4:99535d368a9f | 887 | R3_E = 0x08; |
VivaPenguinos | 4:99535d368a9f | 888 | V_A = 0x08; |
VivaPenguinos | 4:99535d368a9f | 889 | V_B = 0x08; |
VivaPenguinos | 4:99535d368a9f | 890 | N_A = 0x08; |
VivaPenguinos | 4:99535d368a9f | 891 | N_B = 0x08; |
VivaPenguinos | 4:99535d368a9f | 892 | P_A = 0x08; |
VivaPenguinos | 4:99535d368a9f | 893 | P_B = 0x08; |
VivaPenguinos | 4:99535d368a9f | 894 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 895 | wait(1); |
VivaPenguinos | 4:99535d368a9f | 896 | V_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 897 | V_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 898 | N_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 899 | N_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 900 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 901 | wait(1); |
VivaPenguinos | 4:99535d368a9f | 902 | } |
VivaPenguinos | 4:99535d368a9f | 903 | } |
VivaPenguinos | 4:99535d368a9f | 904 | |
VivaPenguinos | 4:99535d368a9f | 905 | // This configs the Ground Elapse Time |
VivaPenguinos | 4:99535d368a9f | 906 | // This portion of code converts the value retrived into seconds and replaces the value in the RTC module. |
VivaPenguinos | 4:99535d368a9f | 907 | // Process: |
VivaPenguinos | 4:99535d368a9f | 908 | // V25N36 |
VivaPenguinos | 4:99535d368a9f | 909 | // Displays V21N36 |
VivaPenguinos | 4:99535d368a9f | 910 | // +-00XXX 750 hours max (equates to 31.25 days) Longest Apollo mission was only 12 hours, 13 hours. So 750 Hours is more than enough. |
VivaPenguinos | 4:99535d368a9f | 911 | // Displays V22N36 |
VivaPenguinos | 4:99535d368a9f | 912 | // +-000XX 60 Minutes Max |
VivaPenguinos | 4:99535d368a9f | 913 | // Displays V23N36 |
VivaPenguinos | 4:99535d368a9f | 914 | // +-0XXXX 60 Seconds Max, Currently follows 000XX will change in future revisions |
VivaPenguinos | 4:99535d368a9f | 915 | void GET_Config() |
VivaPenguinos | 4:99535d368a9f | 916 | { |
VivaPenguinos | 4:99535d368a9f | 917 | int GET_Hours = 0; |
VivaPenguinos | 4:99535d368a9f | 918 | int GET_Minute = 0; |
VivaPenguinos | 4:99535d368a9f | 919 | int GET_Seconds = 0; |
VivaPenguinos | 4:99535d368a9f | 920 | // Configures Hours, Minutes, and Seconds for RTC |
VivaPenguinos | 4:99535d368a9f | 921 | NO_Light(3); |
VivaPenguinos | 4:99535d368a9f | 922 | do { |
VivaPenguinos | 4:99535d368a9f | 923 | NO_Light(3); |
VivaPenguinos | 4:99535d368a9f | 924 | pc.printf("Debug"); |
VivaPenguinos | 4:99535d368a9f | 925 | R_GET(3); |
VivaPenguinos | 4:99535d368a9f | 926 | V_A = 0x02; |
VivaPenguinos | 4:99535d368a9f | 927 | V_B = 0x01; |
VivaPenguinos | 4:99535d368a9f | 928 | N_A = 0x03; |
VivaPenguinos | 4:99535d368a9f | 929 | N_B = 0x06; |
VivaPenguinos | 4:99535d368a9f | 930 | R_GET(3); |
VivaPenguinos | 4:99535d368a9f | 931 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 932 | wait(.5); |
VivaPenguinos | 4:99535d368a9f | 933 | R_GET(3); |
VivaPenguinos | 4:99535d368a9f | 934 | V_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 935 | V_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 936 | N_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 937 | N_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 938 | R_GET(3); |
VivaPenguinos | 4:99535d368a9f | 939 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 940 | wait(.5); |
VivaPenguinos | 5:5f08974ef8bb | 941 | } while (R3_Position != 7); |
VivaPenguinos | 4:99535d368a9f | 942 | R_Position = 1; |
VivaPenguinos | 4:99535d368a9f | 943 | RVA = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 944 | RVB = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 945 | RVC = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 946 | RVD = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 947 | RVE = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 948 | do { |
VivaPenguinos | 4:99535d368a9f | 949 | pc.printf("Debug R2"); |
VivaPenguinos | 4:99535d368a9f | 950 | R_GET(2); |
VivaPenguinos | 4:99535d368a9f | 951 | V_A = 0x02; |
VivaPenguinos | 4:99535d368a9f | 952 | V_B = 0x02; |
VivaPenguinos | 4:99535d368a9f | 953 | N_A = 0x03; |
VivaPenguinos | 4:99535d368a9f | 954 | N_B = 0x06; |
VivaPenguinos | 4:99535d368a9f | 955 | R_GET(2); |
VivaPenguinos | 4:99535d368a9f | 956 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 957 | wait(.5); |
VivaPenguinos | 4:99535d368a9f | 958 | R_GET(2); |
VivaPenguinos | 4:99535d368a9f | 959 | V_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 960 | V_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 961 | N_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 962 | N_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 963 | R_GET(2); |
VivaPenguinos | 4:99535d368a9f | 964 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 965 | wait(.5); |
VivaPenguinos | 5:5f08974ef8bb | 966 | } while(R2_Position != 7); |
VivaPenguinos | 4:99535d368a9f | 967 | R_Position = 1; |
VivaPenguinos | 4:99535d368a9f | 968 | RVA = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 969 | RVB = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 970 | RVC = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 971 | RVD = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 972 | RVE = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 973 | do { |
VivaPenguinos | 4:99535d368a9f | 974 | pc.printf("Debug R1"); |
VivaPenguinos | 4:99535d368a9f | 975 | R_GET(1); |
VivaPenguinos | 4:99535d368a9f | 976 | V_A = 0x02; |
VivaPenguinos | 4:99535d368a9f | 977 | V_B = 0x03; |
VivaPenguinos | 4:99535d368a9f | 978 | N_A = 0x03; |
VivaPenguinos | 4:99535d368a9f | 979 | N_B = 0x06; |
VivaPenguinos | 4:99535d368a9f | 980 | R_GET(1); |
VivaPenguinos | 4:99535d368a9f | 981 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 982 | wait(.5); |
VivaPenguinos | 4:99535d368a9f | 983 | R_GET(1); |
VivaPenguinos | 4:99535d368a9f | 984 | V_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 985 | V_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 986 | N_A = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 987 | N_B = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 988 | R_GET(1); |
VivaPenguinos | 4:99535d368a9f | 989 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 990 | wait(.5); |
VivaPenguinos | 5:5f08974ef8bb | 991 | } while(R1_Position != 7); |
VivaPenguinos | 4:99535d368a9f | 992 | R_Position = 1; |
VivaPenguinos | 4:99535d368a9f | 993 | RVA = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 994 | RVB = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 995 | RVC = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 996 | RVD = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 997 | RVE = 0x0f; |
VivaPenguinos | 4:99535d368a9f | 998 | |
VivaPenguinos | 4:99535d368a9f | 999 | // The Actual Configuration of GET |
VivaPenguinos | 4:99535d368a9f | 1000 | // Concatenate the values from each row based on it's value |
VivaPenguinos | 4:99535d368a9f | 1001 | GET_Hours = R_Concatenate(3); |
VivaPenguinos | 4:99535d368a9f | 1002 | GET_Minute = R_Concatenate(2); |
VivaPenguinos | 4:99535d368a9f | 1003 | GET_Seconds = R_Concatenate(1); |
VivaPenguinos | 4:99535d368a9f | 1004 | |
VivaPenguinos | 5:5f08974ef8bb | 1005 | // Checks if value exceeds the Hours, Minute, and Seconds and verifies if Rows are in Positive |
VivaPenguinos | 5:5f08974ef8bb | 1006 | if (GET_Hours > 750 or GET_Minute > 60 or GET_Seconds > 60 or R1_POS != 1 or R2_POS != 1 or R3_POS != 1) { |
VivaPenguinos | 4:99535d368a9f | 1007 | pc.printf("Error! Check your Hours, Minute, and Seconds Value"); |
VivaPenguinos | 4:99535d368a9f | 1008 | R3_Position = 1; |
VivaPenguinos | 4:99535d368a9f | 1009 | GET_Config(); |
VivaPenguinos | 4:99535d368a9f | 1010 | } else { |
VivaPenguinos | 4:99535d368a9f | 1011 | pc.printf("Pass!, Going to configure RTC Now"); |
VivaPenguinos | 4:99535d368a9f | 1012 | GET_Config_Time = GET_Hours * 3600; |
VivaPenguinos | 4:99535d368a9f | 1013 | GET_Config_Time += GET_Minute * 60; |
VivaPenguinos | 4:99535d368a9f | 1014 | GET_Config_Time += GET_Seconds; |
VivaPenguinos | 4:99535d368a9f | 1015 | pc.printf("Time Conversion is %d", GET_Config_Time); |
VivaPenguinos | 4:99535d368a9f | 1016 | } |
VivaPenguinos | 4:99535d368a9f | 1017 | |
VivaPenguinos | 4:99535d368a9f | 1018 | // Reconfigures the timee so the values can be resetted. |
VivaPenguinos | 3:29cff763ae36 | 1019 | #ifdef INITIAL_RUN |
VivaPenguinos | 3:29cff763ae36 | 1020 | clk.set_time(TIME_VALUE); |
VivaPenguinos | 3:29cff763ae36 | 1021 | #endif |
VivaPenguinos | 1:24446776f0d2 | 1022 | |
VivaPenguinos | 4:99535d368a9f | 1023 | // Debug Use Only |
VivaPenguinos | 4:99535d368a9f | 1024 | //pc.printf("%d\n", GET_Hours); |
VivaPenguinos | 4:99535d368a9f | 1025 | //pc.printf("%d\n", GET_Minute); |
VivaPenguinos | 4:99535d368a9f | 1026 | //pc.printf("%d\n", GET_Seconds); |
VivaPenguinos | 4:99535d368a9f | 1027 | Ground_Elapse_Time(); |
VivaPenguinos | 4:99535d368a9f | 1028 | } |
VivaPenguinos | 6:3019f2f7e9d4 | 1029 | |
VivaPenguinos | 6:3019f2f7e9d4 | 1030 | /* |
VivaPenguinos | 6:3019f2f7e9d4 | 1031 | This is the CMC Idling Program Page CM-39 |
VivaPenguinos | 6:3019f2f7e9d4 | 1032 | P00 - CMC IDLING PROGRAM |
VivaPenguinos | 6:3019f2f7e9d4 | 1033 | Purpose: |
VivaPenguinos | 6:3019f2f7e9d4 | 1034 | 1. To maintain the CMC in a condition of readiness for entry into other programs |
VivaPenguinos | 6:3019f2f7e9d4 | 1035 | 2. To update the CSM and LM state vectors every four time steps. |
VivaPenguinos | 6:3019f2f7e9d4 | 1036 | Assumptions: |
VivaPenguinos | 6:3019f2f7e9d4 | 1037 | 1. This program is automatially selected by V96E, which may be done during any program. |
VivaPenguinos | 6:3019f2f7e9d4 | 1038 | State vector integration is permanently inhibited following V96E. |
VivaPenguinos | 6:3019f2f7e9d4 | 1039 | Normal integration functions will resume after selection of any program or extented verb. |
VivaPenguinos | 6:3019f2f7e9d4 | 1040 | P00 Integration will resume when P00 is reselected. |
VivaPenguinos | 6:3019f2f7e9d4 | 1041 | Usage of V96 can cause incorrect W-matrix and state vector synchronication. |
VivaPenguinos | 6:3019f2f7e9d4 | 1042 | 2. Program changes are inhibited during integration periods and program alarm 1520sub(8) will occur if a chance is attempted when inhibited. |
VivaPenguinos | 6:3019f2f7e9d4 | 1043 | Process: |
VivaPenguinos | 6:3019f2f7e9d4 | 1044 | 1. User Input Verb 37 Enter 00 |
VivaPenguinos | 6:3019f2f7e9d4 | 1045 | 2. Display P00 |
VivaPenguinos | 6:3019f2f7e9d4 | 1046 | 3. Verb 06 Noun 38 |
VivaPenguinos | 6:3019f2f7e9d4 | 1047 | 4. Optional Display: |
VivaPenguinos | 6:3019f2f7e9d4 | 1048 | 5. Verb 06 Noun 38 - |
VivaPenguinos | 6:3019f2f7e9d4 | 1049 | 6. Time of State Vector being Integrated |
VivaPenguinos | 6:3019f2f7e9d4 | 1050 | 00xxx hours |
VivaPenguinos | 6:3019f2f7e9d4 | 1051 | 000xx minutes |
VivaPenguinos | 6:3019f2f7e9d4 | 1052 | 0xx.xx seconds |
VivaPenguinos | 6:3019f2f7e9d4 | 1053 | */ |
VivaPenguinos | 5:5f08974ef8bb | 1054 | void CMC_Idle() |
VivaPenguinos | 5:5f08974ef8bb | 1055 | { |
VivaPenguinos | 6:3019f2f7e9d4 | 1056 | int CMC_Idle = 0; |
VivaPenguinos | 5:5f08974ef8bb | 1057 | NO_Light(7); |
VivaPenguinos | 5:5f08974ef8bb | 1058 | P_A = 0x00; |
VivaPenguinos | 5:5f08974ef8bb | 1059 | P_B = 0x00; |
VivaPenguinos | 5:5f08974ef8bb | 1060 | Shift(); |
VivaPenguinos | 6:3019f2f7e9d4 | 1061 | do { |
VivaPenguinos | 5:5f08974ef8bb | 1062 | __wfi(); |
VivaPenguinos | 6:3019f2f7e9d4 | 1063 | if (Index == 12) { // Index 12 = Verb Button |
VivaPenguinos | 6:3019f2f7e9d4 | 1064 | Verb_Button(); // Goes to Verb_Button |
VivaPenguinos | 6:3019f2f7e9d4 | 1065 | }// Index == 12 |
VivaPenguinos | 6:3019f2f7e9d4 | 1066 | if (Index == 14) { // Index 14 = Noun Button |
VivaPenguinos | 6:3019f2f7e9d4 | 1067 | Noun_Button(); // Goes to Noun_Button |
VivaPenguinos | 6:3019f2f7e9d4 | 1068 | }// Index == 14 |
VivaPenguinos | 6:3019f2f7e9d4 | 1069 | if (Index == 11) { // Index 11 = Enter Button |
VivaPenguinos | 6:3019f2f7e9d4 | 1070 | if (Verb_Number1 == 13 && Verb_Number2 == 6 && Noun_Number1 == 2 && Noun_Number2 == 9 && Enter_Number1 == 0 && Enter_Number2 == 0) { //V06N38E00 |
VivaPenguinos | 6:3019f2f7e9d4 | 1071 | while(1) { |
VivaPenguinos | 6:3019f2f7e9d4 | 1072 | // Time of State Vector Data. |
VivaPenguinos | 6:3019f2f7e9d4 | 1073 | // Time of State Hours |
VivaPenguinos | 6:3019f2f7e9d4 | 1074 | R3_E = ToSHours%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1075 | R3_D = (ToSHours/10)%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1076 | R3_C = (ToSHours/100)%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1077 | R3_B = (ToSHours/1000)%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1078 | R3_A = (ToSHours/10000)%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1079 | |
VivaPenguinos | 6:3019f2f7e9d4 | 1080 | // Time of State Minutes |
VivaPenguinos | 6:3019f2f7e9d4 | 1081 | R2_E = ToSMinutes%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1082 | R2_D = (ToSMinutes/10)%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1083 | R2_C = (ToSMinutes/100)%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1084 | R2_B = (ToSMinutes/1000)%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1085 | R2_A = (ToSMinutes/10000)%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1086 | |
VivaPenguinos | 6:3019f2f7e9d4 | 1087 | // Time of State Seconds |
VivaPenguinos | 6:3019f2f7e9d4 | 1088 | R3_E = ToSSeconds%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1089 | R3_D = (ToSSeconds/10)%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1090 | R3_C = (ToSSeconds/100)%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1091 | R3_B = (ToSSeconds/1000)%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1092 | R3_A = (ToSSeconds/10000)%10; |
VivaPenguinos | 6:3019f2f7e9d4 | 1093 | |
VivaPenguinos | 6:3019f2f7e9d4 | 1094 | wait(1); |
VivaPenguinos | 6:3019f2f7e9d4 | 1095 | } |
VivaPenguinos | 6:3019f2f7e9d4 | 1096 | } else { |
VivaPenguinos | 6:3019f2f7e9d4 | 1097 | Enter_Button(); // Goes to Enter_Button |
VivaPenguinos | 6:3019f2f7e9d4 | 1098 | }// Else statement |
VivaPenguinos | 6:3019f2f7e9d4 | 1099 | }// Index == 11 |
VivaPenguinos | 6:3019f2f7e9d4 | 1100 | Index = -1; |
VivaPenguinos | 6:3019f2f7e9d4 | 1101 | } while(CMC_Idle == 0); |
VivaPenguinos | 6:3019f2f7e9d4 | 1102 | |
VivaPenguinos | 6:3019f2f7e9d4 | 1103 | }// void CMC_Idle() |
VivaPenguinos | 5:5f08974ef8bb | 1104 | |
VivaPenguinos | 5:5f08974ef8bb | 1105 | /* |
VivaPenguinos | 5:5f08974ef8bb | 1106 | P01 - Prelaunch or Service - Initialization Program CM-39 |
VivaPenguinos | 5:5f08974ef8bb | 1107 | Purpose: |
VivaPenguinos | 5:5f08974ef8bb | 1108 | 1. To intialize the platform for the prelaunch programs. |
VivaPenguinos | 5:5f08974ef8bb | 1109 | 2. To provide an initial stable member orientation for Gyrocompassing (P02) |
VivaPenguinos | 5:5f08974ef8bb | 1110 | Assumptions: |
VivaPenguinos | 5:5f08974ef8bb | 1111 | Erasble location has been Properly initialized. |
VivaPenguinos | 5:5f08974ef8bb | 1112 | Azimuth, +1 |
VivaPenguinos | 5:5f08974ef8bb | 1113 | Latitude, +1 |
VivaPenguinos | 5:5f08974ef8bb | 1114 | LaunchAZ +1 |
VivaPenguinos | 5:5f08974ef8bb | 1115 | IMU compenstaion parameters |
VivaPenguinos | 5:5f08974ef8bb | 1116 | */ |
VivaPenguinos | 5:5f08974ef8bb | 1117 | void PreLaunch_Initialization() |
VivaPenguinos | 5:5f08974ef8bb | 1118 | { |
VivaPenguinos | 5:5f08974ef8bb | 1119 | P_A = 0x00; |
VivaPenguinos | 5:5f08974ef8bb | 1120 | P_B = 0x01; |
VivaPenguinos | 5:5f08974ef8bb | 1121 | Shift(); |
VivaPenguinos | 5:5f08974ef8bb | 1122 | |
VivaPenguinos | 5:5f08974ef8bb | 1123 | if (IMUPWR == 1) { |
VivaPenguinos | 5:5f08974ef8bb | 1124 | NO_ATT = 0; |
VivaPenguinos | 5:5f08974ef8bb | 1125 | wait(9); |
VivaPenguinos | 5:5f08974ef8bb | 1126 | pc.printf("Course Align IMU\n"); |
VivaPenguinos | 5:5f08974ef8bb | 1127 | NO_ATT = 1; |
VivaPenguinos | 5:5f08974ef8bb | 1128 | wait(10); |
VivaPenguinos | 5:5f08974ef8bb | 1129 | pc.printf("Course Align IMU complete\n"); |
VivaPenguinos | 5:5f08974ef8bb | 1130 | NO_ATT = 0; |
VivaPenguinos | 5:5f08974ef8bb | 1131 | wait(2); |
VivaPenguinos | 5:5f08974ef8bb | 1132 | PreLaunch_Gyrocompassing(); |
VivaPenguinos | 5:5f08974ef8bb | 1133 | } else { |
VivaPenguinos | 5:5f08974ef8bb | 1134 | // NO_ATT is off for 8 seconds, with one COMP_ACTY light. |
VivaPenguinos | 5:5f08974ef8bb | 1135 | PROG = 1; |
VivaPenguinos | 5:5f08974ef8bb | 1136 | wait(6); |
VivaPenguinos | 5:5f08974ef8bb | 1137 | COMP_ACTY = 1; |
VivaPenguinos | 5:5f08974ef8bb | 1138 | wait(0.5); |
VivaPenguinos | 5:5f08974ef8bb | 1139 | COMP_ACTY = 0; |
VivaPenguinos | 5:5f08974ef8bb | 1140 | wait(1.5); |
VivaPenguinos | 5:5f08974ef8bb | 1141 | // NO_ATT is on for 6 seconds, No COMP_ACTY light. |
VivaPenguinos | 5:5f08974ef8bb | 1142 | NO_ATT = 1; |
VivaPenguinos | 5:5f08974ef8bb | 1143 | wait(6); |
VivaPenguinos | 5:5f08974ef8bb | 1144 | NO_ATT = 0; |
VivaPenguinos | 5:5f08974ef8bb | 1145 | P_A = 0x0f; |
VivaPenguinos | 5:5f08974ef8bb | 1146 | P_B = 0x0f; |
VivaPenguinos | 5:5f08974ef8bb | 1147 | Shift(); |
VivaPenguinos | 5:5f08974ef8bb | 1148 | } |
VivaPenguinos | 5:5f08974ef8bb | 1149 | } |
VivaPenguinos | 5:5f08974ef8bb | 1150 | |
VivaPenguinos | 5:5f08974ef8bb | 1151 | /* |
VivaPenguinos | 5:5f08974ef8bb | 1152 | P02 - Prelaunch or Service - Gyrocompassing Program CM-39 |
VivaPenguinos | 5:5f08974ef8bb | 1153 | Purpose: |
VivaPenguinos | 5:5f08974ef8bb | 1154 | 1. Provide proper stable member orientation for launch |
VivaPenguinos | 5:5f08974ef8bb | 1155 | Assumptions: |
VivaPenguinos | 5:5f08974ef8bb | 1156 | 1. Program may be interuppted to perform the prelaunch or service - optical verification of gyrocompassing program (P03) |
VivaPenguinos | 5:5f08974ef8bb | 1157 | 2. V75 will be keyed in and displaed during this program to permit crew backup of the liftoff discrete. |
VivaPenguinos | 5:5f08974ef8bb | 1158 | 3. Program is automatically selected by the Initialization Program (P01). |
VivaPenguinos | 5:5f08974ef8bb | 1159 | 4. This program has capability (Via V78E) to change the luanch azimuth of the stable memeber while gyrocompassing. |
VivaPenguinos | 5:5f08974ef8bb | 1160 | Process: |
VivaPenguinos | 5:5f08974ef8bb | 1161 | 1. After P01 is completed |
VivaPenguinos | 5:5f08974ef8bb | 1162 | 2. Display P02 |
VivaPenguinos | 5:5f08974ef8bb | 1163 | 3. Flashing V06 N29 / Display LAUNCHAZ in R3 |
VivaPenguinos | 5:5f08974ef8bb | 1164 | 4. User input V21E |
VivaPenguinos | 5:5f08974ef8bb | 1165 | 5. Flash V21N29 This is R1_Component May be for future use. |
VivaPenguinos | 5:5f08974ef8bb | 1166 | 6. User inputs values for LAUNCHAZ |
VivaPenguinos | 5:5f08974ef8bb | 1167 | 7. Flash V06 N29 / Display LAUNCHAZ in R3 |
VivaPenguinos | 5:5f08974ef8bb | 1168 | 8. Input Pro |
VivaPenguinos | 5:5f08974ef8bb | 1169 | 9. Pulses Gyros |
VivaPenguinos | 5:5f08974ef8bb | 1170 | Programming Notes: |
VivaPenguinos | 5:5f08974ef8bb | 1171 | Void PreLaunch_Gyrocomapssing() and PreLaunch_Gyrocompassing_Configure() are tied together |
VivaPenguinos | 5:5f08974ef8bb | 1172 | |
VivaPenguinos | 5:5f08974ef8bb | 1173 | */ |
VivaPenguinos | 5:5f08974ef8bb | 1174 | void PreLaunch_Gyrocompassing () |
VivaPenguinos | 5:5f08974ef8bb | 1175 | { |
VivaPenguinos | 5:5f08974ef8bb | 1176 | // Process 1 |
VivaPenguinos | 5:5f08974ef8bb | 1177 | // Process 2 |
VivaPenguinos | 5:5f08974ef8bb | 1178 | NO_Light(7); |
VivaPenguinos | 5:5f08974ef8bb | 1179 | P_A = 0x00; |
VivaPenguinos | 5:5f08974ef8bb | 1180 | P_B = 0x02; |
VivaPenguinos | 5:5f08974ef8bb | 1181 | Shift(); |
VivaPenguinos | 5:5f08974ef8bb | 1182 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 1183 | R3_E = LAUNCHAZ%10; |
VivaPenguinos | 5:5f08974ef8bb | 1184 | R3_D = (LAUNCHAZ/10)%10; |
VivaPenguinos | 5:5f08974ef8bb | 1185 | R3_C = (LAUNCHAZ/100)%10; |
VivaPenguinos | 5:5f08974ef8bb | 1186 | R3_B = (LAUNCHAZ/1000)%10; |
VivaPenguinos | 5:5f08974ef8bb | 1187 | R3_A = (LAUNCHAZ/10000)%10; |
VivaPenguinos | 5:5f08974ef8bb | 1188 | Shift(); |
VivaPenguinos | 5:5f08974ef8bb | 1189 | while(1) { |
VivaPenguinos | 5:5f08974ef8bb | 1190 | // Process 3; |
VivaPenguinos | 5:5f08974ef8bb | 1191 | PreLaunch_Gyrocompassing_Configure(); |
VivaPenguinos | 5:5f08974ef8bb | 1192 | COMP_ACTY = 1; |
VivaPenguinos | 5:5f08974ef8bb | 1193 | PreLaunch_Gyrocompassing_Configure(); |
VivaPenguinos | 5:5f08974ef8bb | 1194 | wait(0.5); |
VivaPenguinos | 5:5f08974ef8bb | 1195 | PreLaunch_Gyrocompassing_Configure(); |
VivaPenguinos | 5:5f08974ef8bb | 1196 | COMP_ACTY = 0; |
VivaPenguinos | 5:5f08974ef8bb | 1197 | PreLaunch_Gyrocompassing_Configure(); |
VivaPenguinos | 5:5f08974ef8bb | 1198 | wait(0.5); |
VivaPenguinos | 5:5f08974ef8bb | 1199 | pc.printf("spam\n"); |
VivaPenguinos | 5:5f08974ef8bb | 1200 | pc.printf("Index %d\n", Index); |
VivaPenguinos | 5:5f08974ef8bb | 1201 | } // While 1 |
VivaPenguinos | 5:5f08974ef8bb | 1202 | } // prelaunch configuration |
VivaPenguinos | 5:5f08974ef8bb | 1203 | |
VivaPenguinos | 5:5f08974ef8bb | 1204 | // This is used for the configuration of PreLaunch_Gyrocompassing(); |
VivaPenguinos | 5:5f08974ef8bb | 1205 | // This has to be used since it awaits for the input of the astronauts. |
VivaPenguinos | 5:5f08974ef8bb | 1206 | void PreLaunch_Gyrocompassing_Configure() |
VivaPenguinos | 5:5f08974ef8bb | 1207 | { |
VivaPenguinos | 5:5f08974ef8bb | 1208 | int Azimuth; |
VivaPenguinos | 5:5f08974ef8bb | 1209 | while(1){ |
VivaPenguinos | 5:5f08974ef8bb | 1210 | if (Index >-1) { |
VivaPenguinos | 5:5f08974ef8bb | 1211 | if (Index == 12) { |
VivaPenguinos | 5:5f08974ef8bb | 1212 | Verb_Button(); //For V21 use |
VivaPenguinos | 5:5f08974ef8bb | 1213 | } |
VivaPenguinos | 5:5f08974ef8bb | 1214 | if (Index == 11) { |
VivaPenguinos | 5:5f08974ef8bb | 1215 | if (Verb_Number1 == 1 && Verb_Number2 == 0 && Noun_Number1 == 0 && Noun_Number2 == 0 && Enter_Number1 == 0 && Enter_Number2 == 0) { // Verb 21, Noun 00, Enter 00 |
VivaPenguinos | 5:5f08974ef8bb | 1216 | //Flash V21N29 and Get user inputs under R3 |
VivaPenguinos | 5:5f08974ef8bb | 1217 | // Process 5 and 6 |
VivaPenguinos | 5:5f08974ef8bb | 1218 | Azimuth = R1_Component(); // Goes to R1 Component |
VivaPenguinos | 5:5f08974ef8bb | 1219 | if(Azimuth < 90000 && R3_POS == 1 && R1_NEG == 0) { // Error Checking Checks if it's over 90000 or 90 degrees and that R3_POS is lit and not R3_NEG |
VivaPenguinos | 5:5f08974ef8bb | 1220 | // If it passes |
VivaPenguinos | 5:5f08974ef8bb | 1221 | LAUNCHAZ = Azimuth; |
VivaPenguinos | 5:5f08974ef8bb | 1222 | PreLaunch_Gyrocompassing();// This is suppose to go to PreLaunch_Gyrocompassing |
VivaPenguinos | 5:5f08974ef8bb | 1223 | }// if Azimuth = R1 |
VivaPenguinos | 5:5f08974ef8bb | 1224 | else{ |
VivaPenguinos | 5:5f08974ef8bb | 1225 | pc.printf("Failed"); |
VivaPenguinos | 5:5f08974ef8bb | 1226 | } // Error checking |
VivaPenguinos | 5:5f08974ef8bb | 1227 | } // V21 N00 E00 |
VivaPenguinos | 5:5f08974ef8bb | 1228 | } // Enter BUtton |
VivaPenguinos | 5:5f08974ef8bb | 1229 | if (Index == 99){ // This is Prog Button |
VivaPenguinos | 5:5f08974ef8bb | 1230 | // Error checks just in case |
VivaPenguinos | 5:5f08974ef8bb | 1231 | if (LAUNCHAZ > 0 && R3_POS == 1){ |
VivaPenguinos | 5:5f08974ef8bb | 1232 | // Because there are no Phsyical Gyro's present, This section of code is just going to simulate gyros pulsing |
VivaPenguinos | 5:5f08974ef8bb | 1233 | for (int x = 0; x > 21; x++){ |
VivaPenguinos | 5:5f08974ef8bb | 1234 | pc.printf("Pulsing Gyros...\n"); |
VivaPenguinos | 5:5f08974ef8bb | 1235 | COMP_ACTY = 1; |
VivaPenguinos | 5:5f08974ef8bb | 1236 | wait(.5); |
VivaPenguinos | 5:5f08974ef8bb | 1237 | COMP_ACTY = 0; |
VivaPenguinos | 5:5f08974ef8bb | 1238 | wait(.5); |
VivaPenguinos | 5:5f08974ef8bb | 1239 | }// Pulsing Gyro simulation |
VivaPenguinos | 5:5f08974ef8bb | 1240 | pc.printf("Done!"); |
VivaPenguinos | 5:5f08974ef8bb | 1241 | }// Prog Error checking |
VivaPenguinos | 5:5f08974ef8bb | 1242 | }// Prog Button |
VivaPenguinos | 5:5f08974ef8bb | 1243 | } // Index > -1 |
VivaPenguinos | 5:5f08974ef8bb | 1244 | } // While(1) |
VivaPenguinos | 5:5f08974ef8bb | 1245 | } // PreLaunh_Gyrocompassing_Configure(); |
VivaPenguinos | 5:5f08974ef8bb | 1246 | |
VivaPenguinos | 6:3019f2f7e9d4 | 1247 | /* |
VivaPenguinos | 6:3019f2f7e9d4 | 1248 | P06 - CMC Power Down Program |
VivaPenguinos | 6:3019f2f7e9d4 | 1249 | Purpose: |
VivaPenguinos | 6:3019f2f7e9d4 | 1250 | 1. To transfer the CMC from the operate to the standby position |
VivaPenguinos | 6:3019f2f7e9d4 | 1251 | Assumptions: |
VivaPenguinos | 6:3019f2f7e9d4 | 1252 | 1. If the computer power is switched off, the AGC Update program (P27) would have to be done to update the state vector and computer clock time. |
VivaPenguinos | 6:3019f2f7e9d4 | 1253 | 2. The AGC is capable of maintaining an accurate value of ground elapsed time (GET) for only 23 hours when in the standby mode. |
VivaPenguinos | 6:3019f2f7e9d4 | 1254 | If the AGC is not brought out of the standby position to the running condition atleast once within 23 hours, the AGC value of get must be updated. |
VivaPenguinos | 6:3019f2f7e9d4 | 1255 | 3. Once the program has been selected, the AGC must be put in standby. When P06 appears, the AGC will not honor a new program request (V37EXXE), |
VivaPenguinos | 6:3019f2f7e9d4 | 1256 | a terminate (V34E), or an ENTER in response to the request for standby. |
VivaPenguinos | 6:3019f2f7e9d4 | 1257 | Sequence of Events: |
VivaPenguinos | 6:3019f2f7e9d4 | 1258 | 1. User Input V37E06 |
VivaPenguinos | 6:3019f2f7e9d4 | 1259 | 2. Flashing V50N25 R3 = 00062 |
VivaPenguinos | 6:3019f2f7e9d4 | 1260 | 3. PRO until standby light on |
VivaPenguinos | 6:3019f2f7e9d4 | 1261 | 4. PRO until standby light off |
VivaPenguinos | 6:3019f2f7e9d4 | 1262 | 5. Flashing V37 |
VivaPenguinos | 6:3019f2f7e9d4 | 1263 | 6. User input 00E (Select P00) |
VivaPenguinos | 6:3019f2f7e9d4 | 1264 | 6.A No ATT Light of 90 Seconds |
VivaPenguinos | 6:3019f2f7e9d4 | 1265 | 7. Go to P00 |
VivaPenguinos | 6:3019f2f7e9d4 | 1266 | */ |
VivaPenguinos | 6:3019f2f7e9d4 | 1267 | void CMC_Powerdown() |
VivaPenguinos | 6:3019f2f7e9d4 | 1268 | { |
VivaPenguinos | 6:3019f2f7e9d4 | 1269 | // Process 2 |
VivaPenguinos | 6:3019f2f7e9d4 | 1270 | P_A = 0x00; |
VivaPenguinos | 6:3019f2f7e9d4 | 1271 | P_B = 0x06; |
VivaPenguinos | 6:3019f2f7e9d4 | 1272 | R3_E = 0x00; |
VivaPenguinos | 6:3019f2f7e9d4 | 1273 | R3_D = 0x00; |
VivaPenguinos | 6:3019f2f7e9d4 | 1274 | R3_C = 0x00; |
VivaPenguinos | 6:3019f2f7e9d4 | 1275 | R3_B = 0x06; |
VivaPenguinos | 6:3019f2f7e9d4 | 1276 | R3_A = 0x02; |
VivaPenguinos | 6:3019f2f7e9d4 | 1277 | Shift(); |
VivaPenguinos | 6:3019f2f7e9d4 | 1278 | while(1) { |
VivaPenguinos | 6:3019f2f7e9d4 | 1279 | // Process 2 |
VivaPenguinos | 6:3019f2f7e9d4 | 1280 | CMC_PowerInput(); |
VivaPenguinos | 6:3019f2f7e9d4 | 1281 | V_A = 0x05; |
VivaPenguinos | 6:3019f2f7e9d4 | 1282 | V_B = 0x00; |
VivaPenguinos | 6:3019f2f7e9d4 | 1283 | N_A = 0x02; |
VivaPenguinos | 6:3019f2f7e9d4 | 1284 | N_B = 0x05; |
VivaPenguinos | 6:3019f2f7e9d4 | 1285 | Shift(); |
VivaPenguinos | 6:3019f2f7e9d4 | 1286 | CMC_PowerInput(); |
VivaPenguinos | 6:3019f2f7e9d4 | 1287 | wait(.5); |
VivaPenguinos | 6:3019f2f7e9d4 | 1288 | CMC_PowerInput(); |
VivaPenguinos | 6:3019f2f7e9d4 | 1289 | NO_Light(4); |
VivaPenguinos | 6:3019f2f7e9d4 | 1290 | NO_Light(5); |
VivaPenguinos | 6:3019f2f7e9d4 | 1291 | CMC_PowerInput(); |
VivaPenguinos | 6:3019f2f7e9d4 | 1292 | wait(.5); |
VivaPenguinos | 6:3019f2f7e9d4 | 1293 | }// While 1 |
VivaPenguinos | 6:3019f2f7e9d4 | 1294 | }// CMC_Powerdown() |
VivaPenguinos | 6:3019f2f7e9d4 | 1295 | |
VivaPenguinos | 6:3019f2f7e9d4 | 1296 | void CMC_PowerInput() |
VivaPenguinos | 6:3019f2f7e9d4 | 1297 | { |
VivaPenguinos | 6:3019f2f7e9d4 | 1298 | int PowerInput = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 1299 | if(PRO == 1) { |
VivaPenguinos | 6:3019f2f7e9d4 | 1300 | NO_Light(7); |
VivaPenguinos | 6:3019f2f7e9d4 | 1301 | NO_Light(8); |
VivaPenguinos | 6:3019f2f7e9d4 | 1302 | // Process 3 |
VivaPenguinos | 6:3019f2f7e9d4 | 1303 | STBY = 1; |
VivaPenguinos | 6:3019f2f7e9d4 | 1304 | PRO = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 1305 | do { |
VivaPenguinos | 6:3019f2f7e9d4 | 1306 | if(PRO == 1) { |
VivaPenguinos | 6:3019f2f7e9d4 | 1307 | // Process 4 |
VivaPenguinos | 6:3019f2f7e9d4 | 1308 | STBY = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 1309 | //N00V37 |
VivaPenguinos | 6:3019f2f7e9d4 | 1310 | Noun_Number1 = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 1311 | Noun_Number2 = 0; |
VivaPenguinos | 6:3019f2f7e9d4 | 1312 | Verb_Number1 = 2; |
VivaPenguinos | 6:3019f2f7e9d4 | 1313 | Verb_Number2 = 8; |
VivaPenguinos | 6:3019f2f7e9d4 | 1314 | // Process 5-7 |
VivaPenguinos | 6:3019f2f7e9d4 | 1315 | Enter_Button(); |
VivaPenguinos | 6:3019f2f7e9d4 | 1316 | PowerInput = 1; |
VivaPenguinos | 6:3019f2f7e9d4 | 1317 | }// 2nd PRO For turning on. |
VivaPenguinos | 6:3019f2f7e9d4 | 1318 | }while (PowerInput == 0);// While 1 |
VivaPenguinos | 6:3019f2f7e9d4 | 1319 | }//PRO == 1 |
VivaPenguinos | 6:3019f2f7e9d4 | 1320 | } |
VivaPenguinos | 5:5f08974ef8bb | 1321 | |
VivaPenguinos | 5:5f08974ef8bb | 1322 | // Load Component 1 into R1 |
VivaPenguinos | 5:5f08974ef8bb | 1323 | int R1_Component() |
VivaPenguinos | 5:5f08974ef8bb | 1324 | { |
VivaPenguinos | 5:5f08974ef8bb | 1325 | R1_POS = 0; |
VivaPenguinos | 5:5f08974ef8bb | 1326 | R1_NEG = 0; |
VivaPenguinos | 5:5f08974ef8bb | 1327 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 1328 | do { |
VivaPenguinos | 5:5f08974ef8bb | 1329 | R_GET(3); |
VivaPenguinos | 5:5f08974ef8bb | 1330 | V_A = 0x02; |
VivaPenguinos | 5:5f08974ef8bb | 1331 | V_B = 0x01; |
VivaPenguinos | 5:5f08974ef8bb | 1332 | N_A = 0x02; |
VivaPenguinos | 5:5f08974ef8bb | 1333 | N_B = 0x09; |
VivaPenguinos | 5:5f08974ef8bb | 1334 | R_GET(3); |
VivaPenguinos | 5:5f08974ef8bb | 1335 | Shift(); |
VivaPenguinos | 5:5f08974ef8bb | 1336 | wait(.5); |
VivaPenguinos | 5:5f08974ef8bb | 1337 | R_GET(3); |
VivaPenguinos | 5:5f08974ef8bb | 1338 | NO_Light(4); |
VivaPenguinos | 5:5f08974ef8bb | 1339 | NO_Light(5); |
VivaPenguinos | 5:5f08974ef8bb | 1340 | R_GET(3); |
VivaPenguinos | 5:5f08974ef8bb | 1341 | wait(.5); |
VivaPenguinos | 5:5f08974ef8bb | 1342 | } while (R3_Position != 7); |
VivaPenguinos | 5:5f08974ef8bb | 1343 | R_Position = 1; |
VivaPenguinos | 5:5f08974ef8bb | 1344 | |
VivaPenguinos | 5:5f08974ef8bb | 1345 | return R_Concatenate(3); |
VivaPenguinos | 5:5f08974ef8bb | 1346 | } |
VivaPenguinos | 4:99535d368a9f | 1347 | |
VivaPenguinos | 4:99535d368a9f | 1348 | // This is used to concatenate Row 3, Useful for when verifying inputs. |
VivaPenguinos | 4:99535d368a9f | 1349 | int R_Concatenate(int C) { |
VivaPenguinos | 4:99535d368a9f | 1350 | |
VivaPenguinos | 4:99535d368a9f | 1351 | // Used for concatenation only |
VivaPenguinos | 4:99535d368a9f | 1352 | int RAB = 0; |
VivaPenguinos | 4:99535d368a9f | 1353 | int RCD = 0; |
VivaPenguinos | 4:99535d368a9f | 1354 | int RABCD = 0; |
VivaPenguinos | 4:99535d368a9f | 1355 | int RABCDE = 0; |
VivaPenguinos | 4:99535d368a9f | 1356 | |
VivaPenguinos | 4:99535d368a9f | 1357 | // Actual Physical Interaces, Row Physical |
VivaPenguinos | 4:99535d368a9f | 1358 | int RPA = 0; |
VivaPenguinos | 4:99535d368a9f | 1359 | int RPB = 0; |
VivaPenguinos | 4:99535d368a9f | 1360 | int RPC = 0; |
VivaPenguinos | 4:99535d368a9f | 1361 | int RPD = 0; |
VivaPenguinos | 4:99535d368a9f | 1362 | int RPE = 0; |
VivaPenguinos | 4:99535d368a9f | 1363 | |
VivaPenguinos | 4:99535d368a9f | 1364 | // This if Statement compares which rows to concatenate then replaces the variables with the correct one. |
VivaPenguinos | 4:99535d368a9f | 1365 | if (C == 3) { |
VivaPenguinos | 4:99535d368a9f | 1366 | RPA = R3_A; |
VivaPenguinos | 4:99535d368a9f | 1367 | RPB = R3_B; |
VivaPenguinos | 4:99535d368a9f | 1368 | RPC = R3_C; |
VivaPenguinos | 4:99535d368a9f | 1369 | RPD = R3_D; |
VivaPenguinos | 4:99535d368a9f | 1370 | RPE = R3_E; |
VivaPenguinos | 4:99535d368a9f | 1371 | } |
VivaPenguinos | 4:99535d368a9f | 1372 | if (C == 2) { |
VivaPenguinos | 4:99535d368a9f | 1373 | RPA = R2_A; |
VivaPenguinos | 4:99535d368a9f | 1374 | RPB = R3_B; |
VivaPenguinos | 4:99535d368a9f | 1375 | RPC = R2_C; |
VivaPenguinos | 4:99535d368a9f | 1376 | RPD = R2_D; |
VivaPenguinos | 4:99535d368a9f | 1377 | RPE = R2_E; |
VivaPenguinos | 4:99535d368a9f | 1378 | } |
VivaPenguinos | 4:99535d368a9f | 1379 | if (C == 1) { |
VivaPenguinos | 4:99535d368a9f | 1380 | RPA = R1_A; |
VivaPenguinos | 4:99535d368a9f | 1381 | RPB = R1_B; |
VivaPenguinos | 4:99535d368a9f | 1382 | RPC = R1_C; |
VivaPenguinos | 4:99535d368a9f | 1383 | RPD = R1_D; |
VivaPenguinos | 4:99535d368a9f | 1384 | RPE = R1_E; |
VivaPenguinos | 3:29cff763ae36 | 1385 | } |
VivaPenguinos | 4:99535d368a9f | 1386 | RAB = concatenate(RPA, RPB); // R3A + R3B |
VivaPenguinos | 4:99535d368a9f | 1387 | RCD = concatenate(RPC, RPD); // R3C + R3D |
VivaPenguinos | 4:99535d368a9f | 1388 | RABCD = concatenate(RAB, RCD); // R3AB + R3CD |
VivaPenguinos | 4:99535d368a9f | 1389 | RABCDE = concatenate(RABCD, RPE); // R3ABCD = R3E |
VivaPenguinos | 4:99535d368a9f | 1390 | //Debug Use: |
VivaPenguinos | 4:99535d368a9f | 1391 | //pc.printf("%d\n", RAB); |
VivaPenguinos | 4:99535d368a9f | 1392 | //pc.printf("%d\n", RCD); |
VivaPenguinos | 4:99535d368a9f | 1393 | //pc.printf("%d\n", RABCD); |
VivaPenguinos | 4:99535d368a9f | 1394 | //pc.printf("%d\n", RABCDE); |
VivaPenguinos | 4:99535d368a9f | 1395 | return RABCDE; |
VivaPenguinos | 4:99535d368a9f | 1396 | } |
VivaPenguinos | 4:99535d368a9f | 1397 | |
VivaPenguinos | 4:99535d368a9f | 1398 | |
VivaPenguinos | 4:99535d368a9f | 1399 | // Concatenate two Integers. Credits to Mooing Duck. http://stackoverflow.com/questions/12700497/how-to-concatenate-two-integers-in-c |
VivaPenguinos | 4:99535d368a9f | 1400 | // Decided not modify the code to do 5 at a time since I can use it to concatenate the Verb, Noun, and Program Number. |
VivaPenguinos | 4:99535d368a9f | 1401 | unsigned concatenate(unsigned x, unsigned y) { |
VivaPenguinos | 4:99535d368a9f | 1402 | unsigned pow = 10; |
VivaPenguinos | 4:99535d368a9f | 1403 | while(y >= pow) |
VivaPenguinos | 4:99535d368a9f | 1404 | pow *= 10; |
VivaPenguinos | 4:99535d368a9f | 1405 | return x * pow + y; |
VivaPenguinos | 4:99535d368a9f | 1406 | } |
VivaPenguinos | 4:99535d368a9f | 1407 | |
VivaPenguinos | 4:99535d368a9f | 1408 | void R_GET(int R) |
VivaPenguinos | 4:99535d368a9f | 1409 | { |
VivaPenguinos | 4:99535d368a9f | 1410 | if (R == 3) { |
VivaPenguinos | 5:5f08974ef8bb | 1411 | R3_POS = R_Pos; |
VivaPenguinos | 5:5f08974ef8bb | 1412 | R3_NEG = R_Neg; |
VivaPenguinos | 4:99535d368a9f | 1413 | R3_A = RVA; |
VivaPenguinos | 4:99535d368a9f | 1414 | R3_B = RVB; |
VivaPenguinos | 4:99535d368a9f | 1415 | R3_C = RVC; |
VivaPenguinos | 4:99535d368a9f | 1416 | R3_D = RVD; |
VivaPenguinos | 4:99535d368a9f | 1417 | R3_E = RVE; |
VivaPenguinos | 4:99535d368a9f | 1418 | R3_Position = R_Position; |
VivaPenguinos | 4:99535d368a9f | 1419 | } |
VivaPenguinos | 4:99535d368a9f | 1420 | if (R == 2) { |
VivaPenguinos | 5:5f08974ef8bb | 1421 | R2_POS = R_Pos; |
VivaPenguinos | 5:5f08974ef8bb | 1422 | R2_NEG = R_Neg; |
VivaPenguinos | 4:99535d368a9f | 1423 | R2_A = RVA; |
VivaPenguinos | 4:99535d368a9f | 1424 | R2_B = RVB; |
VivaPenguinos | 4:99535d368a9f | 1425 | R2_C = RVC; |
VivaPenguinos | 4:99535d368a9f | 1426 | R2_D = RVD; |
VivaPenguinos | 4:99535d368a9f | 1427 | R2_E = RVE; |
VivaPenguinos | 4:99535d368a9f | 1428 | R2_Position = R_Position; |
VivaPenguinos | 4:99535d368a9f | 1429 | } |
VivaPenguinos | 4:99535d368a9f | 1430 | if (R == 1) { |
VivaPenguinos | 5:5f08974ef8bb | 1431 | R1_POS = R_Pos; |
VivaPenguinos | 5:5f08974ef8bb | 1432 | R1_NEG = R_Neg; |
VivaPenguinos | 4:99535d368a9f | 1433 | R1_A = RVA; |
VivaPenguinos | 4:99535d368a9f | 1434 | R1_B = RVB; |
VivaPenguinos | 4:99535d368a9f | 1435 | R1_C = RVC; |
VivaPenguinos | 4:99535d368a9f | 1436 | R1_D = RVD; |
VivaPenguinos | 4:99535d368a9f | 1437 | R1_E = RVE; |
VivaPenguinos | 4:99535d368a9f | 1438 | R1_Position = R_Position; |
VivaPenguinos | 4:99535d368a9f | 1439 | } |
VivaPenguinos | 4:99535d368a9f | 1440 | |
VivaPenguinos | 5:5f08974ef8bb | 1441 | switch (R_Position) { |
VivaPenguinos | 4:99535d368a9f | 1442 | case 1: |
VivaPenguinos | 4:99535d368a9f | 1443 | if (Index >-1) { |
VivaPenguinos | 5:5f08974ef8bb | 1444 | pc.printf("Plus-Minus\n"); |
VivaPenguinos | 5:5f08974ef8bb | 1445 | RP = Button_Sort(Index); |
VivaPenguinos | 5:5f08974ef8bb | 1446 | if (RP == 0x10) { |
VivaPenguinos | 5:5f08974ef8bb | 1447 | R_Pos = 1; |
VivaPenguinos | 5:5f08974ef8bb | 1448 | pc.printf("+"); |
VivaPenguinos | 5:5f08974ef8bb | 1449 | } else if (RP == 0x11) { |
VivaPenguinos | 5:5f08974ef8bb | 1450 | R_Neg = 1; |
VivaPenguinos | 5:5f08974ef8bb | 1451 | } |
VivaPenguinos | 5:5f08974ef8bb | 1452 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 1453 | R_Position = 2; |
VivaPenguinos | 5:5f08974ef8bb | 1454 | } |
VivaPenguinos | 5:5f08974ef8bb | 1455 | |
VivaPenguinos | 5:5f08974ef8bb | 1456 | case 2: |
VivaPenguinos | 5:5f08974ef8bb | 1457 | if (Index >-1) { |
VivaPenguinos | 4:99535d368a9f | 1458 | pc.printf("RA\n"); |
VivaPenguinos | 4:99535d368a9f | 1459 | RA = Button_Sort(Index); |
VivaPenguinos | 4:99535d368a9f | 1460 | RVA = RA; |
VivaPenguinos | 4:99535d368a9f | 1461 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 1462 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 1463 | R_Position = 3; |
VivaPenguinos | 4:99535d368a9f | 1464 | } |
VivaPenguinos | 5:5f08974ef8bb | 1465 | case 3: |
VivaPenguinos | 4:99535d368a9f | 1466 | if (Index >-1) { |
VivaPenguinos | 4:99535d368a9f | 1467 | pc.printf("RB\n"); |
VivaPenguinos | 4:99535d368a9f | 1468 | RB = Button_Sort(Index); |
VivaPenguinos | 4:99535d368a9f | 1469 | RVB = RB; |
VivaPenguinos | 4:99535d368a9f | 1470 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 1471 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 1472 | R_Position = 4; |
VivaPenguinos | 4:99535d368a9f | 1473 | } |
VivaPenguinos | 5:5f08974ef8bb | 1474 | case 4: |
VivaPenguinos | 4:99535d368a9f | 1475 | if (Index >-1) { |
VivaPenguinos | 4:99535d368a9f | 1476 | pc.printf("RC\n"); |
VivaPenguinos | 4:99535d368a9f | 1477 | RC = Button_Sort(Index); |
VivaPenguinos | 4:99535d368a9f | 1478 | RVC = RC; |
VivaPenguinos | 4:99535d368a9f | 1479 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 1480 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 1481 | R_Position = 5; |
VivaPenguinos | 4:99535d368a9f | 1482 | } |
VivaPenguinos | 5:5f08974ef8bb | 1483 | case 5: |
VivaPenguinos | 4:99535d368a9f | 1484 | if (Index >-1) { |
VivaPenguinos | 4:99535d368a9f | 1485 | pc.printf("RD\n"); |
VivaPenguinos | 4:99535d368a9f | 1486 | RD = Button_Sort(Index); |
VivaPenguinos | 4:99535d368a9f | 1487 | RVD = RD; |
VivaPenguinos | 4:99535d368a9f | 1488 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 1489 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 1490 | R_Position = 6; |
VivaPenguinos | 4:99535d368a9f | 1491 | } |
VivaPenguinos | 5:5f08974ef8bb | 1492 | case 6: |
VivaPenguinos | 4:99535d368a9f | 1493 | if (Index >-1) { |
VivaPenguinos | 4:99535d368a9f | 1494 | pc.printf("RE\n"); |
VivaPenguinos | 4:99535d368a9f | 1495 | RE = Button_Sort(Index); |
VivaPenguinos | 4:99535d368a9f | 1496 | RVE = RE; |
VivaPenguinos | 4:99535d368a9f | 1497 | Shift(); |
VivaPenguinos | 4:99535d368a9f | 1498 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 1499 | R_Position = 7; |
VivaPenguinos | 5:5f08974ef8bb | 1500 | } |
VivaPenguinos | 5:5f08974ef8bb | 1501 | } |
VivaPenguinos | 5:5f08974ef8bb | 1502 | } |
VivaPenguinos | 5:5f08974ef8bb | 1503 | |
VivaPenguinos | 5:5f08974ef8bb | 1504 | // When a value is required for Enter, The output is displayed via the Noun display Hence the Name N_GET not E_GET |
VivaPenguinos | 5:5f08974ef8bb | 1505 | void N_GET() |
VivaPenguinos | 5:5f08974ef8bb | 1506 | { |
VivaPenguinos | 5:5f08974ef8bb | 1507 | N_A = NA; |
VivaPenguinos | 5:5f08974ef8bb | 1508 | N_B = NB; |
VivaPenguinos | 5:5f08974ef8bb | 1509 | |
VivaPenguinos | 5:5f08974ef8bb | 1510 | switch (N_Position) { |
VivaPenguinos | 5:5f08974ef8bb | 1511 | case 1: |
VivaPenguinos | 5:5f08974ef8bb | 1512 | if (Index > -1) { |
VivaPenguinos | 5:5f08974ef8bb | 1513 | pc.printf("NA\n"); |
VivaPenguinos | 5:5f08974ef8bb | 1514 | NA = Button_Sort(Index); |
VivaPenguinos | 5:5f08974ef8bb | 1515 | Enter_Number1 = NA; |
VivaPenguinos | 5:5f08974ef8bb | 1516 | Shift(); |
VivaPenguinos | 5:5f08974ef8bb | 1517 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 1518 | N_Position = 2; |
VivaPenguinos | 5:5f08974ef8bb | 1519 | } |
VivaPenguinos | 5:5f08974ef8bb | 1520 | case 2: |
VivaPenguinos | 5:5f08974ef8bb | 1521 | if (Index > -1) { |
VivaPenguinos | 5:5f08974ef8bb | 1522 | pc.printf("NB\n"); |
VivaPenguinos | 5:5f08974ef8bb | 1523 | NB = Button_Sort(Index); |
VivaPenguinos | 5:5f08974ef8bb | 1524 | Enter_Number2 = NB; |
VivaPenguinos | 5:5f08974ef8bb | 1525 | Shift(); |
VivaPenguinos | 5:5f08974ef8bb | 1526 | Index = -1; |
VivaPenguinos | 5:5f08974ef8bb | 1527 | N_Position = 3; |
VivaPenguinos | 4:99535d368a9f | 1528 | } |
VivaPenguinos | 4:99535d368a9f | 1529 | } |
VivaPenguinos | 4:99535d368a9f | 1530 | |
VivaPenguinos | 4:99535d368a9f | 1531 | } |
VivaPenguinos | 4:99535d368a9f | 1532 |