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:
Thu Apr 24 03:29:32 2014 +0000
Parent:
2:aee9ee1296cd
Child:
4:99535d368a9f
Commit message:
Official Release of Open Source DSKY.

Changed in this revision

DS1302.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DS1302.lib	Thu Apr 24 03:29:32 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/DS1302/#c7cea2a415c3
--- a/main.cpp	Wed Apr 09 03:00:37 2014 +0000
+++ b/main.cpp	Thu Apr 24 03:29:32 2014 +0000
@@ -1,15 +1,8 @@
 /* Introduction
 MBED DSKY
 This is a personal project used developed by penguinos to mix old school technology with a modern twist.
-Version 0.02: March. 4 2014
-    Added Keypad Functionality
-        - Added fucntion for Verb
-        - Added function for Noun
-        - Added function for Enter
-        - Used goto in Verb and Noun to prevent any nestled Loops.
-        - Contains Button_Sort Function to move location based on button press
-    Cleaned certain parts of the code for efficentcy    
-
+Version 0.03: March. 8 2014
+    - Planning to add a DS1302 RTC into the platform
 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,
@@ -17,9 +10,41 @@
 
 Warning: This may contain author crude language, random memes, and random thoughts.
  */
+ 
+ /* Pin Usage
+Real Time Clock
+    SCLK    PTC5
+    IO      PTC4
+    CE      PTC3
+Keypad
+    Row0    PTD4
+    Row1    PTA12
+    Row2    PTD3
+    Row3    PTA5
+    Col1    PTA13
+    Col2    PTD5
+    Col3    PTD0
+    Col4    PTD2
+Shift Registers
+    Latch   PTC6
+    Clock   PTC10
+    Data    PTC11
+ */
+ 
+// For RTC 
+#define SCLK    PTC5
+#define IO      PTC4
+#define CE      PTC3
+
+// Comment Line if DS1302 is already running
+#define INITIAL_RUN
+
 using namespace std;
 #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
@@ -33,10 +58,12 @@
 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;
@@ -44,7 +71,7 @@
     0x00, 0x01, 0x02, 0x03, 0x04,
     0x05, 0x06, 0x07, 0x08, 0x09
 };
-
+// Keypad
 char Keytable[] = { '1', '2', '3', '+', // R0
                     '4', '5', '6', '-', // R1
                     '7', '8', '9', 'E', // R2
@@ -52,6 +79,11 @@
                   };
 //  C0   C1   C2   C3
 
+// RTC Variables
+int TIME_VALUE = 1397702161;
+int Time_Difference;
+
+// Button State
 int32_t Index = -1; // Button
 int     State;
 
@@ -64,13 +96,13 @@
 void blinkAll(int amount, int delay);// Function that Blinks all LED
 //void ShiftingOut(char myDataOut);
 
-// Program Name
+// Program Names
 void Ground_Elapse_Time(); // Ground Elapse Time
 
 // Pin modes for each pins
-DigitalOut LatchPin(PTC7); //Pin for ST_CP of 74HC595 Pin # 12
-DigitalOut ClockPin(PTC0); //Pin for SH_CP of 74HC595 Pin # 11
-DigitalOut DataPin(PTC3);  //Pin for to DS of 74HC595 Pin # 14
+DigitalOut LatchPin(PTC6); //Pin for ST_CP of 74HC595 Pin # 12
+DigitalOut ClockPin(PTC10); //Pin for SH_CP of 74HC595 Pin # 11
+DigitalOut DataPin(PTC11);  //Pin for to DS of 74HC595 Pin # 14
 
 DigitalOut myled(LED1);
 Serial pc(USBTX, USBRX); // tx, rx Serial Output to PC Enabling this WILL consume resources. Use only for debug
@@ -294,5 +326,18 @@
 // Need to fill this too...
 void Ground_Elapse_Time()
 {
+    #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);
+    }
 }
\ No newline at end of file