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

Hardware

Files at this revision

API Documentation at this revision

Comitter:
VivaPenguinos
Date:
Mon Jul 21 23:28:22 2014 +0000
Parent:
3:29cff763ae36
Child:
5:5f08974ef8bb
Commit message:
Contains GET, Configure GET, and Test Light;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Apr 24 03:29:32 2014 +0000
+++ b/main.cpp	Mon Jul 21 23:28:22 2014 +0000
@@ -1,17 +1,29 @@
 /* Introduction
 MBED DSKY
 This is a personal project used developed by penguinos to mix old school technology with a modern twist.
-Version 0.03: March. 8 2014
-    - Planning to add a DS1302 RTC into the platform
+Version 0.04: July. 5 2014
+    - DS1302 Added
+    - Shift Register Variable has been added
+    - void Button_Sort(int sort); is now int Button_Sort(int sort);
+        Button sort has 90% of all the variables in there.
+    - Void shifting out no longer takes 8 bits but rather 4 bits. (Makes things easier to compute)
+    - Added Concatenation Functionality
+    - Added NO_Lights Functionality
+    - Added R_GET Functionality
+    - Test Light Program working
+    - GET Program Working
+    - GET Configuration Working
+    
+    
 Notable Credits:
 NASA! - Release of technical documentations regarding the AGC and DSKY
 Ron Burkley and Contributers of "Virtual AGC — AGS — LVDC — Gemini" - Providing Technical documentations, Source Code, explanations,
     and refrences on other sites to make this project successful
 
-Warning: This may contain author crude language, random memes, and random thoughts.
- */
- 
- /* Pin Usage
+Warning: This may contain author's crude language, and random thoughts.
+
+Pin Usage:
+
 Real Time Clock
     SCLK    PTC5
     IO      PTC4
@@ -29,6 +41,30 @@
     Latch   PTC6
     Clock   PTC10
     Data    PTC11
+    
+Shift Registers Data:
+Because the project contains 11 shift registers, All data must be properly formatted before shifting out. each shift register controls 2 7 segments.
+R1_A                                           [P_A | P_B]
+R1_B                   
+R1_C                    [V_A | V_B]            [N_A | N_B]
+R1_D                    
+R1_E                    [R3_E | R3_D | R3_C | R3_B | R3_A]
+R2_A
+R2_B                    [R2_E | R2_D | R2_C | R2_B | R2_A]
+R2_C
+R2_D                    [R1_E | R1_D | R1_C | R1_B | R1_A]
+R2_E
+R3_A
+R3_B
+R3_C
+R3_D
+R3_E
+V_A
+V_B
+N_A
+N_B
+P_A
+P_B
  */
  
 // For RTC 
@@ -43,11 +79,11 @@
 #include "mbed.h"
 #include "Keypad.h" // Keypad
 #include "DS1302.h" // RTC for DS1032
-
+    
 DS1302 clk(SCLK, IO, CE); //DS1302 clk(SCLK, IO, PTC3);
 
 //Declare Variables
-int shift = 0; // Shift Data
+// int shift = 0; // Shift Data
 // In the Arduino Version it uses a String. Will use an Int instead to see if this works on Mbed
 int Verb_Number1 = 0;
 int Verb_Number2 = 0;
@@ -58,30 +94,58 @@
 int Verb; // DSKY Verb
 int Noun; // DSkY Noun
 int Enter; // DSKY Enter
-// GET USE
-int Set_GET_Seconds = 30; // Configure the Set Get in seconds. 1/100th of a second
-char Set_get_miliseconds = 10;
-char Set_Get_Seconds_Byte = 0;
-char Set_Get_Seconds_Byte2 = 0;
-// Shift Register
-char data = 0;
-char data2 = 0;
-char data3 = 0;
-char nibble[10] = { // Holds variables for nibbles for number 0-9 in hexes. nibble ALL the things!
-    0x00, 0x01, 0x02, 0x03, 0x04,
-    0x05, 0x06, 0x07, 0x08, 0x09
-};
+
+// For shift register use. Refer to shift register data for additional information.
+int R1_A = 0x0f;
+int R1_B = 0x0f;                   
+int R1_C = 0x0f;
+int R1_D = 0x0f;                    
+int R1_E = 0x0f;
+int R2_A = 0x0f;
+int R2_B = 0x0f;
+int R2_C = 0x0f;
+int R2_D = 0x0f;
+int R2_E = 0x0f;
+int R3_A = 0x0f;
+int R3_B = 0x0f;
+int R3_C = 0x0f;
+int R3_D = 0x0f;
+int R3_E = 0x0f;
+int V_A = 0x0f;
+int V_B = 0x0f;
+int N_A = 0x0f;
+int N_B = 0x0f;
+int P_A = 0x0f;
+int P_B = 0x0f;
+
+// For GET use. Refer to R3_GET, R2_GET, and R1_GET
+int RA = 0;
+int RB = 0;
+int RC = 0;
+int RD = 0;
+int RE = 0;
+int RVA = 0x0f;
+int RVB = 0x0f;
+int RVC = 0x0f;
+int RVD = 0x0f;
+int RVE = 0x0f;
+int R_Position = 1;
+int R1_Position = 1;
+int R2_Position = 1;
+int R3_Position = 1;
+int GET_Config_Time = 0;
+
 // Keypad
 char Keytable[] = { '1', '2', '3', '+', // R0
                     '4', '5', '6', '-', // R1
                     '7', '8', '9', 'E', // R2
                     'V', '0', 'N', 'R', // R3
                   };
-//  C0   C1   C2   C3
+                //  C0   C1   C2   C3
 
 // RTC Variables
 int TIME_VALUE = 1397702161;
-int Time_Difference;
+int Time_Difference = 0%60;
 
 // Button State
 int32_t Index = -1; // Button
@@ -92,12 +156,18 @@
 void Noun_Button();
 void Enter_Button();
 void compare();
-void Button_Sort(int sort); // Function that sorts Verb Values
+int Button_Sort(int sort); // Function that sorts Verb Values
 void blinkAll(int amount, int delay);// Function that Blinks all LED
+void Shift(); // Function that shifts all data
+void R_GET(int R); // Grab inputs for the Rows
+int R_Concatenate(int C); // Used for concatenating information
+void NO_Light(int L); // Configures shift registers to 0
 //void ShiftingOut(char myDataOut);
 
 // Program Names
-void Ground_Elapse_Time(); // Ground Elapse Time
+void Ground_Elapse_Time();  // Ground Elapse Time
+void Test_Lights();         // Test Lights
+void GET_Config();          // Configures Ground Elapse Time
 
 // Pin modes for each pins
 DigitalOut LatchPin(PTC6); //Pin for ST_CP of 74HC595 Pin # 12
@@ -107,6 +177,8 @@
 DigitalOut myled(LED1);
 Serial pc(USBTX, USBRX); // tx, rx Serial Output to PC Enabling this WILL consume resources. Use only for debug
 
+unsigned concatenate(unsigned x, unsigned y);
+
 uint32_t cbAfterInput(uint32_t index)
 {
     Index = index;
@@ -115,29 +187,40 @@
 
 int main()
 {
+    pc.printf("Initialization...\n");
     wait(1);
-    pc.printf("Shifting");
+    pc.printf("Testing shift registers.\n");
     blinkAll(4,1);
-    pc.printf("Done");
+    pc.printf("Shift Register: PASS \n");
     wait(1);
+    pc.printf("Energizing keypad\n");
     State = 1;
     //             r0   r1   r2   r3   c0   c1   c2   c3
     Keypad keypad(PTD4, PTA12, PTD3, PTA5, PTA13, PTD5, PTD0, PTD2, 20);
     keypad.attach(&cbAfterInput);
     keypad.start();  // energize the columns c0-c3 of the keypad
+    pc.printf("Keypad: PASS \n");
+    pc.printf("Initialize RTC Clock. \n");
+    #ifdef INITIAL_RUN
+    clk.set_time(TIME_VALUE);
+    #endif
+    //char storedByte = clk.recallByte(0);
+    //clk.storeByte(0, storedByte + 1);
+    pc.printf("RTC: PASS \n");
+    pc.printf("Welcome to DSKY!\n");
     while (1) {
         __wfi();
         if (Index >-1) {
             pc.printf("Interrupted");
             pc.printf("Index:%d => Key:%c\r\n", Index, Keytable[Index]);
             if (Index == 12) { // Index 12 = Verb Button
-                Verb_Button(); // Goes to Verb_Button 
+                Verb_Button(); // Goes to Verb_Button
             }
             if (Index == 14) { // Index 14 = Noun Button
                 Noun_Button(); // Goes to Noun_Button
             }
             if (Index == 11) { // Index 11 = Enter Button
-               Enter_Button(); // Goes to Enter_Button
+                Enter_Button(); // Goes to Enter_Button
             }
             Index = -1;
         }
@@ -155,28 +238,27 @@
 void Verb_Button(){
         Verbz: // Don't Ask
         // All Variables for Verb, Noun and Enter are zeroed out
-        Verb_Number1 = 0;
-        Verb_Number2 = 0;
-        Noun_Number1 = 0;
-        Noun_Number2 = 0;
-        Enter_Number1 = 0;
-        Enter_Number2 = 0;
+        Verb_Number1    = 0;
+        Verb_Number2    = 0;
+        Noun_Number1    = 0;
+        Noun_Number2    = 0;
+        Enter_Number1   = 0;
+        Enter_Number2   = 0;
         pc.printf("Please enter a Verb Number");          
         __wfi();
         Verb_Number1 = Index;
         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.
             goto Verbz; // Line 110
+        } else {
+            V_A = Button_Sort(Verb_Number1);
+            Shift();
         }
-        else{
-            Button_Sort(Verb_Number1);
-        }
-        //wait(0.01); // Is needed so that Verb_Number1 can store the variable from the keypad. Not sure why it requires an additional job for it to store the data.
         //pc.printf("%c", Verb_Number1);
         //pc.printf("%c", Keytable[Index]);
         __wfi();
         Verb_Number2 = Index;
-        Button_Sort(Verb_Number2);
-        //wait(0.01); // Is needed so that Verb_Number2 can store the variable form the keypad. Not sure why it requires an additional job for it to store the data.
+        V_B = Button_Sort(Verb_Number2);
+        Shift();
         //pc.printf("%c", Verb_Number2);
         //pc.printf("%c", Verb_Number1);
         //pc.printf("%c\n", Verb_Number2);
@@ -192,14 +274,16 @@
     __wfi();
     Noun_Number1 = Index;
     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.
-        goto Nounz; //Line 140
+        goto Nounz;
         }
     else{
-        Button_Sort(Noun_Number1);
+        N_A = Button_Sort(Noun_Number1);
+        Shift();
         }
     __wfi();
     Noun_Number2 = Index;
-    Button_Sort(Noun_Number2);
+    N_B = Button_Sort(Noun_Number2);
+    Shift();
 }
 
 /* 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.
@@ -207,8 +291,8 @@
 void Enter_Button()
 {
     Enterz:
-    pc.printf("Checking Whether there is a variable stored in Noun\n");
-    if (Noun_Number1 == 0 && Noun_Number2 == 0){
+    pc.printf("Checking Whether there is a variable stored in Noun or Verb 35\n");
+    if (Noun_Number1 == 0 && Noun_Number2 == 0 && Verb_Number1 != 2 && Verb_Number2 != 5){
         pc.printf("Please enter a Enter Number");
         __wfi();
         Enter_Number1 = Index;
@@ -222,44 +306,80 @@
         Enter_Number2 = Index;
         Button_Sort(Enter_Number2);
     }
-    if (Noun_Number1 != 0 && Noun_Number2 != 0){ 
+    else {// (Noun_Number1 != 0 && Noun_Number2 != 0){ 
         pc.printf("Check completed, Executing");
+        Index = -1;
         compare();
     }
     
 }
 
 // This function is used to sort the button press for Verb and Noun.
-void Button_Sort(int Sort)
+int Button_Sort(int Sort)
 {
-        // Determines what button are pressed before moving on to the 2nd button.
-    if (Sort == 12){ //comparing the array number NOT what value in the array it is. Actual Array value is V
-        Verb_Button();
+    if (Sort == 0){ // Index 0 - Char 1
+        return 0x01;
         }
-    else if (Sort == 14) { //comparing the array number NOT what value in the array it is. Actual Array value is N
-        Noun_Button();
+    else if (Sort == 1) { // Index 1 - Char 2
+        return 0x02;
         }
-    else if (Sort == 3) { //comparing the array number NOT what value in the array it is. Actual Array value is +
+    else if (Sort == 2) { // Index 2 - Char 3
+        return 0x03;
+        }
+    else if (Sort == 3) { // Index 3 - Char + comparing the array number NOT what value in the array it is. Actual Array value is +
         pc.printf("+");
         }
-    else if (Sort == 7) { //comparing the array number NOT what value in the array it is. Actual Array value is -
+    else if (Sort == 4) { // Index 4 - Char 4
+        return 0x04;
+        }
+    else if (Sort == 5) { // Index 5 - Char 5
+        return 0x05;
+        }
+    else if (Sort == 6) { // Index 6 - Char 6
+        return 0x06;
+        }
+    else if (Sort == 7) { // Index 7 - Char - comparing the array number NOT what value in the array it is. Actual Array value is -
         pc.printf("-");
         }
+    else if (Sort == 8) { // Index 8 - Char 7
+        return 0x07;
+        }
+    else if (Sort == 9) { // Index 9 - Char 8
+        return 0x08;
+        }
+    else if (Sort == 10) { // Index 10 - Char 9
+        return 0x09;
+        }
+    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
+        Verb_Button();
+        }    
+    else if (Sort == 13) { // Index 13 - Char 0
+        return 0x00;
+        }
+    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
+        Noun_Button();
+        }          
     else if (Sort == 15) { //comparing the array number NOT what value in the array it is. Actual Array value is R
         pc.printf("R");
         }
+    return 0;
 }
+
 // Compares the button to what program the DSKY should be running. This section will be inefficent until I can improve on my programming skills :]
 void compare()
 {
     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
-        //Configure GET
-        pc.printf("Configuring GET");
+        // Configure GET
+        pc.printf("Display GET");
         Ground_Elapse_Time();
-    } else if (Verb_Number1 == 3 && Verb_Number2 == 5 && Noun_Number1 == 0 && Noun_Number2 == 0) {
-        // Test Light
-    } else if (Verb == 25 && Noun == 36) {
-        // Configure GET
+    } 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
+        // Test Lights
+        pc.printf("Testing Lights");
+        Test_Lights();
+    } 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
+        // GET COnfiguration
+        pc.printf("GET configuration");
+        GET_Config();
     } else if (Verb == 37 && Enter == 00) {
         // Idle Program
     }
@@ -277,67 +397,529 @@
     DataPin = 0;
     ClockPin = 0;
 
-    for (i=7; i>= 0; i--) {
+    for (i=3; i>= 0; i--) {
         ClockPin = 0;
 
         // Value passed to my data out
         if ( myDataOut & (1<<i)) {
             pinState = 1;
             myled = 1;
-            pc.printf("1");
+            //pc.printf("1");
         } else {
             pinState = 0;
             myled = 0;
-            pc.printf("0");
+            //pc.printf("0");
         }
         DataPin = pinState;
         ClockPin = 1;
         DataPin = 0;
     }
+    //pc.printf("\n");
     ClockPin = 0;
     DataPin = 1;
 }
 
+// This function is used for shifting all Shift_X variables into the 7 segment display.
+void Shift()
+{
+    LatchPin = 0;
+    ShiftingOut(P_B);
+    ShiftingOut(P_A);
+    ShiftingOut(V_B);
+    ShiftingOut(V_A);
+    ShiftingOut(N_B);
+    ShiftingOut(N_A);
+    ShiftingOut(R3_E);
+    ShiftingOut(R3_D);
+    ShiftingOut(R3_C);
+    ShiftingOut(R3_B);
+    ShiftingOut(R3_A);
+    ShiftingOut(R2_E);
+    ShiftingOut(R2_D);
+    ShiftingOut(R2_C);
+    ShiftingOut(R2_B);
+    ShiftingOut(R2_A);
+    ShiftingOut(R1_E);
+    ShiftingOut(R1_D);
+    ShiftingOut(R1_C);
+    ShiftingOut(R1_B);
+    ShiftingOut(R1_A);
+    LatchPin = 1;
+}
+
 //blinks the whole registered based on the number of times you want to blink with a certain delay
 void blinkAll(int amount, int delay)
 {
-    LatchPin = 0;
-    ShiftingOut(0);
-    ShiftingOut(0);
-    LatchPin = 1;
+    LatchPin = 0; // Before shift
+    //ShiftingOut(0);
+    //ShiftingOut(0);
+    LatchPin = 1; // Done shift
     wait(0.2);
     for (int x = 0; x < amount; x++) {
         LatchPin = 0;
-        pc.printf("sending");
-        ShiftingOut(255);
-        ShiftingOut(255);
-        ShiftingOut(255);
+        pc.printf("sending\n");
+        for (int s = 0; s < 22; s++) 
+        {
+            ShiftingOut(0x08);
+        }
         LatchPin = 1;
         wait(delay);
         LatchPin = 0;
-        ShiftingOut(0);
-        ShiftingOut(0);
-        ShiftingOut(0);
+            for (int s = 0; s < 22; s++)
+            {
+            ShiftingOut(0xf);
+            }
         LatchPin = 1;
         wait(delay);
     }
 }
 
-// Need to fill this too...
+// The Ground Elapse Time is refrence to range zero or the last integeral before liftoff.
+// Page CM-9
+// 00XXX    h
+// 000XX    min
+// 0XX.XX   s (Code current does not follow this format)
 void Ground_Elapse_Time()
 {
+    NO_Light(7); // Clears all the 7 Segment first.
+    // Displays V16N36 on the 7 segments
+    V_A = 0x01;
+    V_B = 0x06;
+    N_A = 0x03;
+    N_B = 0x06;
+    Shift();
+    int GET_FLAG = 1;
+    while(GET_FLAG == 1) {
+        int minute = 0;
+        int Seconds = 0;
+        int Hours = 0;
+        int minutemod = 0; // Minute Modulo
+        int R1D = 0x00;
+        int R1E = 0x00;
+        int R2D = 0x00;
+        int R2E = 0x00;
+        int R3D = 0x00;
+        int R3E = 0x00;
+        time_t seconds = clk.time(NULL);
+        pc.printf ("S = %d\n", seconds);
+        Time_Difference = (seconds + GET_Config_Time) - TIME_VALUE;
+        printf("TIME=%d \n", Time_Difference);  // Displays time elapsed based on seconds elapsed.
+        Hours = Time_Difference/3600;   // Divide seconds by 3600 seconds
+        Seconds = Time_Difference%60;   // Get the remainder of time difference after 60 seconds
+        minute = Time_Difference/60;    // Divide the seconds by 3600
+                                    // Comments:                                                            7 Segments Location
+        minutemod = minute%60;      // Get the remainder of the minutemod after 60 seconds
+        R3D = (Hours%60)/10;        // Get the modulo of the hour variable then divde by 10 to get single digit     [][][][x][]
+        R3E = Hours%10;             // Get the modulo of the Hours variable by 10 to get single digit               [][][][][x]
+        R2D = minutemod/10;         // Divide the minute variable by 10 to get single digit                         [][][][x][]
+        R2E = minute%10;            // Get the remainder of the minute variable to get single digit                 [][][][][x]
+        R1D = Seconds/10;           // Divide the seconds variable by 10 to get single digit                        [][][][x][]
+        R1E = Time_Difference%10;   // Get the remainder of the Time_Difference to get single digit                 [][][][][x]
+        // Debug Use:
+        // pc.printf("%d \n", minute);
+        // pc.printf("%o \n", R2E);
+        // pc.printf("%o \n", R2D);
+        R3_E = R3E;
+        R3_D = R3D;
+        R1_E = R1E;
+        R1_D = R1D;
+        R2_E = R2E;
+        R2_D = R2D;
+        Shift();
+        //pc.printf("%i \n",(Time_Difference%10) + ((Time_Difference/10)<<4)); // Decimal to BCD
+        //printf("Time as a basic string = %s\r", ctime(&seconds));
+        if (Index >-1) {
+        GET_FLAG = 0;
+        pc.printf("Interrupted");
+        pc.printf("Index:%d => Key:%c\r\n", Index, Keytable[Index]);
+            if (Index == 12) { // Index 12 = Verb Button
+                Verb_Button(); // Goes to Verb_Button
+                GET_FLAG = 0;
+                break;
+            } else if (Index == 14) { // Index 14 = Noun Button
+                Noun_Button(); // Goes to Noun_Button
+                GET_FLAG = 0;
+                break;
+            } else if (Index == 11) { // Index 11 = Enter Button
+                Enter_Button(); // Goes to Enter_Button
+                GET_FLAG = 0;
+                break;
+            }
+            Index = -1;
+            GET_FLAG = 0;
+            break;
+        }
+        wait(1);
+    }
+}
+
+// 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.
+// 1 = Row 1
+// 2 = Row 2
+// 3 = Row 3
+// 4 = Verb
+// 5 = Nouns
+// 6 = Program Number
+// 7 = All lights off
+void NO_Light(int L)
+{
+
+    switch(L) {
+        case 1:
+            R1_A = 0x0f;
+            R1_B = 0x0f;
+            R1_C = 0x0f;
+            R1_D = 0x0f;
+            R1_E = 0x0f;
+            Shift();
+        case 2:
+            R2_A = 0x0f;
+            R2_B = 0x0f;
+            R2_C = 0x0f;
+            R2_D = 0x0f;
+            R2_E = 0x0f;
+            Shift();
+        case 3:
+            R3_A = 0x0f;
+            R3_B = 0x0f;
+            R3_C = 0x0f;
+            R3_D = 0x0f;
+            R3_E = 0x0f;
+            Shift();
+        case 4:
+            V_A = 0x0f;
+            V_B = 0x0f;
+            Shift();
+        case 5:
+            N_A = 0x0f;
+            N_B = 0x0f;
+            Shift();
+        case 6:
+            P_A = 0x0f;
+            P_B = 0x0f;
+            Shift();
+        case 7:
+            R1_A = 0x0f;
+            R1_B = 0x0f;
+            R1_C = 0x0f;
+            R1_D = 0x0f;
+            R1_E = 0x0f;
+            R2_A = 0x0f;
+            R2_B = 0x0f;
+            R2_C = 0x0f;
+            R2_D = 0x0f;
+            R2_E = 0x0f;
+            R3_A = 0x0f;
+            R3_B = 0x0f;
+            R3_C = 0x0f;
+            R3_D = 0x0f;
+            R3_E = 0x0f;
+            V_A = 0x0f;
+            V_B = 0x0f;
+            N_A = 0x0f;
+            N_B = 0x0f;
+            P_A = 0x0f;
+            P_B = 0x0f;
+            Shift();
+    }
+}
+    
+// Test lights is to make sure all the 7 segments and indicator lights worked prior to lift-off.
+void Test_Lights()
+{
+    for(int x = 0; x < 7; x++) {
+        R1_A = 0x08;
+        R1_B = 0x08;
+        R1_C = 0x08;
+        R1_D = 0x08;
+        R1_E = 0x08;
+        R2_A = 0x08;
+        R2_B = 0x08;
+        R2_C = 0x08;
+        R2_D = 0x08;
+        R2_E = 0x08;
+        R3_A = 0x08;
+        R3_B = 0x08;
+        R3_C = 0x08;
+        R3_D = 0x08;
+        R3_E = 0x08;
+        V_A = 0x08;
+        V_B = 0x08;
+        N_A = 0x08;
+        N_B = 0x08;
+        P_A = 0x08;
+        P_B = 0x08;
+        Shift();
+        wait(1);
+        V_A = 0x0f;
+        V_B = 0x0f;
+        N_A = 0x0f;
+        N_B = 0x0f;
+        Shift();
+        wait(1);
+    }    
+}
+
+// This configs the Ground Elapse Time
+// This portion of code converts the value retrived into seconds and replaces the value in the RTC module.
+// Process:
+// V25N36
+//      Displays V21N36
+// +-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.
+//      Displays V22N36
+// +-000XX 60 Minutes Max
+//      Displays V23N36
+// +-0XXXX 60 Seconds Max, Currently follows 000XX will change in future revisions
+void GET_Config()
+{
+    int GET_Hours   = 0;
+    int GET_Minute  = 0;
+    int GET_Seconds = 0;
+    // Configures Hours, Minutes, and Seconds for RTC
+    NO_Light(3);
+    do {
+        NO_Light(3);
+        pc.printf("Debug");
+        R_GET(3);
+        V_A = 0x02;
+        V_B = 0x01;
+        N_A = 0x03;
+        N_B = 0x06;
+        R_GET(3);
+        Shift();
+        wait(.5);
+        R_GET(3);
+        V_A = 0x0f;
+        V_B = 0x0f;
+        N_A = 0x0f;
+        N_B = 0x0f;
+        R_GET(3);
+        Shift();
+        wait(.5);
+    } while (R3_Position != 6);
+    R_Position = 1;
+    RVA = 0x0f;
+    RVB = 0x0f;
+    RVC = 0x0f;
+    RVD = 0x0f;
+    RVE = 0x0f;
+    do {
+        pc.printf("Debug R2");
+        R_GET(2);
+        V_A = 0x02;
+        V_B = 0x02;
+        N_A = 0x03;
+        N_B = 0x06;
+        R_GET(2);
+        Shift();
+        wait(.5);
+        R_GET(2);
+        V_A = 0x0f;
+        V_B = 0x0f;
+        N_A = 0x0f;
+        N_B = 0x0f;
+        R_GET(2);
+        Shift();
+        wait(.5);
+    } while(R2_Position != 6);
+    R_Position = 1;
+    RVA = 0x0f;
+    RVB = 0x0f;
+    RVC = 0x0f;
+    RVD = 0x0f;
+    RVE = 0x0f;
+    do {
+        pc.printf("Debug R1");
+        R_GET(1);
+        V_A = 0x02;
+        V_B = 0x03;
+        N_A = 0x03;
+        N_B = 0x06;
+        R_GET(1);
+        Shift();
+        wait(.5);
+        R_GET(1);
+        V_A = 0x0f;
+        V_B = 0x0f;
+        N_A = 0x0f;
+        N_B = 0x0f;
+        R_GET(1);
+        Shift();
+        wait(.5);
+    } while(R1_Position != 6);
+    R_Position = 1;
+    RVA = 0x0f;
+    RVB = 0x0f;
+    RVC = 0x0f;
+    RVD = 0x0f;
+    RVE = 0x0f;
+    
+    // The Actual Configuration of GET
+    // Concatenate the values from each row based on it's value
+    GET_Hours   = R_Concatenate(3);
+    GET_Minute  = R_Concatenate(2);
+    GET_Seconds = R_Concatenate(1);
+    
+    // Checks if value exceeds the Hours, Minute, and Seconds
+    if (GET_Hours > 750 or GET_Minute > 60 or GET_Seconds > 60) {
+        pc.printf("Error! Check your Hours, Minute, and Seconds Value");
+        R3_Position = 1;
+        GET_Config();
+    } else {
+        pc.printf("Pass!, Going to configure RTC Now");
+        GET_Config_Time =  GET_Hours * 3600;
+        GET_Config_Time += GET_Minute * 60;
+        GET_Config_Time += GET_Seconds;
+        pc.printf("Time Conversion is %d", GET_Config_Time);
+    }
+    
+    // Reconfigures the timee so the values can be resetted.
     #ifdef INITIAL_RUN
     clk.set_time(TIME_VALUE);
     #endif
-    char storedByte = clk.recallByte(0);
-    printf("\r\nStored byte was %d, now increasing by one\r\n", storedByte);
-    clk.storeByte(0, storedByte + 1);
     
-    while(1) {
-        time_t seconds = clk.time(NULL);
-        Time_Difference = seconds - TIME_VALUE;
-        printf("%d \n", Time_Difference);
-        //printf("Time as a basic string = %s\r", ctime(&seconds));
-        wait(1);
+    // Debug Use Only
+    //pc.printf("%d\n", GET_Hours);
+    //pc.printf("%d\n", GET_Minute);
+    //pc.printf("%d\n", GET_Seconds);
+    Ground_Elapse_Time();
+ }
+ 
+ // This is used to concatenate Row 3, Useful for when verifying inputs.
+ int R_Concatenate(int C) {
+     
+     // Used for concatenation only
+     int RAB       = 0;
+     int RCD       = 0;
+     int RABCD     = 0;
+     int RABCDE    = 0;
+     
+     // Actual Physical Interaces, Row Physical
+     int RPA    = 0;
+     int RPB    = 0;
+     int RPC    = 0;
+     int RPD    = 0;
+     int RPE    = 0;  
+     
+     // This if Statement compares which rows to concatenate then replaces the variables with the correct one.
+    if (C == 3) {
+        RPA = R3_A;
+        RPB = R3_B;
+        RPC = R3_C;
+        RPD = R3_D;
+        RPE = R3_E;
+    }
+    if (C == 2) {
+        RPA = R2_A;
+        RPB = R3_B;
+        RPC = R2_C;
+        RPD = R2_D;
+        RPE = R2_E;
+    }
+    if (C == 1) {
+        RPA = R1_A;
+        RPB = R1_B;
+        RPC = R1_C;
+        RPD = R1_D;
+        RPE = R1_E;
     }
-}
\ No newline at end of file
+     RAB = concatenate(RPA, RPB);        // R3A + R3B
+     RCD = concatenate(RPC, RPD);        // R3C + R3D
+     RABCD = concatenate(RAB, RCD);      // R3AB + R3CD
+     RABCDE = concatenate(RABCD, RPE);    // R3ABCD = R3E
+     //Debug Use:
+     //pc.printf("%d\n", RAB);
+     //pc.printf("%d\n", RCD);
+     //pc.printf("%d\n", RABCD);
+     //pc.printf("%d\n", RABCDE);
+     return RABCDE;
+}
+     
+ 
+ // Concatenate two Integers. Credits to Mooing Duck. http://stackoverflow.com/questions/12700497/how-to-concatenate-two-integers-in-c
+ // Decided not modify the code to do 5 at a time since I can use it to concatenate the Verb, Noun, and Program Number.
+ unsigned concatenate(unsigned x, unsigned y) {
+    unsigned pow = 10;
+    while(y >= pow)
+        pow *= 10;
+    return x * pow + y;        
+}
+ 
+void R_GET(int R)
+{
+    if (R == 3) {
+        R3_A = RVA;
+        R3_B = RVB;
+        R3_C = RVC;
+        R3_D = RVD;
+        R3_E = RVE;
+        R3_Position = R_Position;
+    }
+    if (R == 2) {
+        R2_A = RVA;
+        R2_B = RVB;
+        R2_C = RVC;
+        R2_D = RVD;
+        R2_E = RVE;
+        R2_Position = R_Position;
+    }
+    if (R == 1) {
+        R1_A = RVA;
+        R1_B = RVB;
+        R1_C = RVC;
+        R1_D = RVD;
+        R1_E = RVE;
+        R1_Position = R_Position;
+    }
+    
+    switch (R_Position){
+        case 1:
+            if (Index >-1) {
+                pc.printf("RA\n");
+                RA = Button_Sort(Index);
+                RVA = RA;
+                Shift();
+                Index = -1;
+                R_Position = 2;
+            }
+        case 2:
+            if (Index >-1) {
+                pc.printf("RB\n");
+                RB = Button_Sort(Index);
+                RVB = RB;
+                Shift();
+                Index = -1;
+                R_Position = 3;
+            }
+        case 3:
+            if (Index >-1) {
+                pc.printf("RC\n");
+                RC = Button_Sort(Index);
+                RVC = RC;
+                Shift();
+                Index = -1;
+                R_Position = 4;
+            }
+        case 4:
+            if (Index >-1) {
+                pc.printf("RD\n");
+                RD = Button_Sort(Index);
+                RVD = RD;
+                Shift();
+                Index = -1;
+                R_Position = 5;
+            }
+        case 5:
+            if (Index >-1) {
+                pc.printf("RE\n");
+                RE = Button_Sort(Index);
+                RVE = RE;
+                Shift();
+                Index = -1;
+                R_Position = 6;
+            }
+    }
+                
+
+}
+     
\ No newline at end of file