Browse Source

Merge remote-tracking branch 'origin/master'

Willie 3 years ago
parent
commit
4bd73a788d
3 changed files with 59 additions and 7 deletions
  1. 20 0
      README.md
  2. 5 2
      SPS/SPS.ino
  3. 34 5
      SPS/prgmode.ino

+ 20 - 0
README.md

@@ -8,6 +8,26 @@ http://www.rcarduino.de/doku.php?id=en:arduino:arduinosps
 And there is now a print book at amazon 
 https://www.amazon.com/dp/1731232535
 
+**Version 0.12.1**
+  03.09.2019
+  - changing the variable names in debug mode
+  - release
+
+**Version 0.12**
+  27.01.2019
+  - Release
+  - automatically adding demo program to new mcu
+  11.01.2018
+  - some refactoring
+  
+  07.01.2018
+  - programming: 1/2 duty cycle for 0 values in address display
+
+**Version 0.11**
+  17.12.2018
+  - adding Shift left and shift right to register A
+
+
 **Version 0.10**
   9.12.2018
   - Release

+ 5 - 2
SPS/SPS.ino

@@ -1,6 +1,8 @@
 /*
   SPS System mit dem Arduino.
   Version 0.12
+  27.01.2019
+  - adding demo program,
   11.01.2018
   - some refactoring
   
@@ -216,6 +218,7 @@ void setup() {
   initDebug();
 #endif
 
+  prgDemoPrg();
   doReset();
 
   if (digitalRead(SW_PRG) == 0) {
@@ -388,8 +391,8 @@ void loop() {
 }
 
 void debugOutputRegister() {
-  dbgOut2(addr, HEX); dbgOut(":"); dbgOut2(value, HEX); dbgOut(",");
-  dbgOut2(cmd, HEX); dbgOut(","); dbgOut2(data, HEX); dbgOut(",a:");
+  dbgOut2(addr, HEX); dbgOut(":"); dbgOut2(prog, HEX); dbgOut(",");
+  dbgOut2(com, HEX); dbgOut(","); dbgOut2(data, HEX); dbgOut(",a:");
   dbgOut2(a, HEX); dbgOut(","); dbgOut2(b, HEX); dbgOut(",");
   dbgOut2(c, HEX); dbgOut(","); dbgOut2(d, HEX); dbgOut(",");
   dbgOut2(e, HEX); dbgOut(","); dbgOut2(f, HEX); dbgOutLn();

+ 34 - 5
SPS/prgmode.ino

@@ -5,11 +5,31 @@
 #define BLINK_DELAY 500
 #define SHOW_DELAY 1000
 #define KEY_DELAY 250
+#define ADDR_LOOP 50
+
+const byte demoPrg[] = { 0x4F, 0x59, 0x1F, 0x29, 0x10, 0x29, 0x5A, 0x40,
+                         0x59, 0x64, 0x54, 0x29, 0x4F, 0x59, 0x10, 0xCD,
+                         0x11, 0x28, 0xCC, 0x18, 0x28, 0x4F, 0x59, 0x5A,
+                         0x72, 0x26, 0xC0, 0x35, 0x80, 0x90, 0xFF
+                       };
+
 
 enum PROGRAMMING_MODE {ADDRESS, COMMAND, DATA};
 
 PROGRAMMING_MODE prgMode;
 
+void prgDemoPrg() {
+  byte value = EEPROM.read(0);
+  if (value == 0xFF) {
+    value = EEPROM.read(1);
+    if (value == 0xFF) {
+      for (byte i = 0; i < sizeof(demoPrg); i++) {
+        EEPROM.write(i, demoPrg[i]);
+      }
+    }
+  }
+}
+
 void programMode() {
   // checking if advance programmer board connected?
 #ifdef SPS_ENHANCEMENT
@@ -32,14 +52,14 @@ void programMode() {
       dbgOut("Adr:");
       dbgOutLn(addr);
       // LoNibble Adresse anzeigen
-      doPort(addr);
-      delay(SHOW_DELAY);
+      doAddr(addr);
+      //delay(SHOW_DELAY);
 
       blinkD2();
       // HiNibble Adresse anzeigen
       data = (addr & 0xf0) >> 4;                                  //Adresse anzeigen
-      doPort(data);
-      delay(SHOW_DELAY);
+      doAddr(data);
+      //delay(SHOW_DELAY);
 
       byte Eebyte = EEPROM.read(addr);
       data = Eebyte & 15;
@@ -76,7 +96,7 @@ void programMode() {
       }
       while (digitalRead(SW_PRG) == 1); // S2 = 1
       delay(DEBOUNCE);
-      
+
       byte newValue = (com << 4) + data;
       if (newValue != Eebyte) {
         EEPROM.write(addr, newValue); //           Writeeeprom Eebyte , Addr
@@ -128,3 +148,12 @@ void blinkNull() {
   doPort(0x00);
   delay(BLINK_DELAY);
 }
+
+void doAddr(byte value) {
+  for (byte i = ADDR_LOOP; i > 0; i--) {
+    doPort(value);
+    delay(19);
+    doPort(0x0F);
+    delay(1);
+  }
+}