Ver código fonte

adding automatic demo programm to new ArduinoSPS

Willie 5 anos atrás
pai
commit
8d97179cec
2 arquivos alterados com 23 adições e 1 exclusões
  1. 3 0
      SPS/SPS.ino
  2. 20 1
      SPS/prgmode.ino

+ 3 - 0
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) {

+ 20 - 1
SPS/prgmode.ino

@@ -6,10 +6,29 @@
 #define SHOW_DELAY 1000
 #define KEY_DELAY 250
 
+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
@@ -76,7 +95,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