Browse Source

Merge branch 'develop'

Klaas, Wilfried 3 years ago
parent
commit
f3ae03a241
5 changed files with 57 additions and 28 deletions
  1. 8 0
      README.md
  2. 39 20
      SPS/SPS.ino
  3. 7 7
      SPS/prgmode.ino
  4. 1 1
      SimpleSPS/SImpleSPS/SImpleSPS.ino
  5. 2 0
      git_push_all.cmd

+ 8 - 0
README.md

@@ -8,12 +8,20 @@ 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.4**
+  11.06.2021
+
+  - bug: pop not working
+  - bug: a = not a not working
+
 **Version 0.12.3**
   10.06.2021
+
   - adding auto programming feature for the SPS Emulator
 
 **Version 0.12.2**
   07.06.2021
+
   - bug with servo in 4-bit mode, evaluate the full 8 bit.
 
 **Version 0.12.1**

+ 39 - 20
SPS/SPS.ino

@@ -1,5 +1,9 @@
 /*
   SPS System mit dem Arduino.
+  Version 0.12.4
+  10.06.2021
+  - bug: pop not working
+
   Version 0.12.3
   10.06.2021
   - adding auto programming feature for the SPS Emulator
@@ -91,16 +95,16 @@
    #define SPS_SERIAL_PRG: activates the serial programming feature
 */
 // Program im Debugmodus kompilieren, dann werden zus. Ausgaben auf die serielle Schnittstelle geschrieben.
-#define debug
+//#define debug
 
 // defining different hardware platforms
 #ifdef __AVR_ATmega328P__
 //#define SPS_USE_DISPLAY
 //#define SPS_RECEIVER
-//#define SPS_ENHANCEMENT
-//#define SPS_SERIAL_PRG
-//#define SPS_SERVO
-//#define SPS_TONE
+#define SPS_ENHANCEMENT
+#define SPS_SERIAL_PRG
+#define SPS_SERVO
+#define SPS_TONE
 #endif
 
 #ifdef __AVR_ATtiny84__
@@ -196,9 +200,8 @@ Servo servo1;
 Servo servo2;
 #endif
 
-byte prog = 0;
 byte data = 0;
-byte com = 0;
+byte cmd = 0;
 
 void setup() {
   pinMode(Dout_0, OUTPUT);
@@ -270,6 +273,10 @@ void doReset() {
 #ifdef SPS_ENHANCEMENT
   e = 0;
   f = 0;
+  stackCnt = 0;
+  for (int i = 0; i < SAVE_CNT; i++) {
+    stack[i] = 0;
+  }
 #endif
 }
 
@@ -302,27 +309,29 @@ void readProgram() {
       if (data >= 8) {
         data = data - 8;
         subs[data] = addr + 1;
+        dbgOut(", sub def ");
+        dbgOut(data);
       }
     }
 #ifdef SPS_SERVO
     if ((cmd == IS_A) && (data == 0x0B)) {
       if (!servo1.attached()) {
-        dbgOutLn(": attach Srv1");
+        dbgOut(": attach Srv1");
         servo1.attach(SERVO_1);
       }
     } else if ((cmd == CMD_BYTE) && (data == 0x06)) {
       if (!servo1.attached()) {
-        dbgOutLn(": attach Srv1");
+        dbgOut(": attach Srv1");
         servo1.attach(SERVO_1);
       }
     } else if ((cmd == IS_A) && (data == 0x0C)) {
       if (!servo2.attached()) {
-        dbgOutLn(": attach Srv2");
+        dbgOut(": attach Srv2");
         servo2.attach(SERVO_2);
       }
     } else if ((cmd == CMD_BYTE) && (data == 0x07)) {
       if (!servo2.attached()) {
-        dbgOutLn(": attach Srv2");
+        dbgOut(": attach Srv2");
         servo2.attach(SERVO_2);
       }
     }
@@ -348,8 +357,8 @@ void loop() {
   }
 #endif
   byte value = readbyte(addr);
-  byte cmd = (value & 0xF0);
-  byte data = (value & 0x0F);
+  cmd = (value & 0xF0);
+  data = (value & 0x0F);
 
   debugOutputRegister();
 
@@ -409,11 +418,17 @@ void loop() {
 }
 
 void debugOutputRegister() {
-  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(addr, HEX); dbgOut(":"); dbgOut2(cmd>>4, HEX); dbgOut(","); dbgOut2(data, HEX); 
+  dbgOut(",reg:"); dbgOut2(a, HEX); dbgOut(","); dbgOut2(b, HEX); dbgOut(",");
   dbgOut2(c, HEX); dbgOut(","); dbgOut2(d, HEX); dbgOut(",");
-  dbgOut2(e, HEX); dbgOut(","); dbgOut2(f, HEX); dbgOutLn();
+#ifdef SPS_ENHANCEMENT
+  dbgOut2(e, HEX); dbgOut(","); dbgOut2(f, HEX); 
+  dbgOut(", s:"); dbgOut2(stackCnt, HEX); dbgOut(":");
+  for (int i = 0; i < SAVE_CNT; i++) {
+    dbgOut2(stack[i],HEX);dbgOut(",");
+  }
+#endif
+  dbgOutLn();
 }
 
 /*
@@ -577,7 +592,7 @@ void doAIs(byte data) {
       dbgOutLn(a);
       break;
 #endif
-#ifdef SPS_ENHANCMENT
+#ifdef SPS_ENHANCEMENT
     case 13:
       a = e;
       break;
@@ -585,6 +600,8 @@ void doAIs(byte data) {
       a = f;
       break;
     case 15:
+      dbgOut("pop ");
+      dbgOutLn(stackCnt);
       if (stackCnt > 0) {
         stackCnt -= 1;
         a = stack[stackCnt];
@@ -670,6 +687,8 @@ void doIsA(byte data) {
       f = a;
       break;
     case 15:
+      dbgOut("push ");
+      dbgOutLn(stackCnt);
       if (stackCnt < SAVE_CNT) {
         stack[stackCnt] = a;
         stackCnt += 1;
@@ -720,7 +739,7 @@ void doCalc(byte data) {
       a = a ^ b;
       break;
     case 10:
-      a = !a;
+      a = ~a;
       break;
 #ifdef SPS_ENHANCEMENT
     case 11:
@@ -760,7 +779,7 @@ void doPage(byte data) {
 void doJump(byte data) {
 #ifdef debug
   dbgOut("J");
-  dbgOut2(page, HEX);
+  dbgOut2(page>>4, HEX);
   dbgOutLn2(data, HEX);
 #endif
   addr = page + data;

+ 7 - 7
SPS/prgmode.ino

@@ -63,19 +63,19 @@ void programMode() {
 
       byte Eebyte = readbyte(addr);
       data = Eebyte & 15;
-      com = Eebyte >> 4;
+      cmd = Eebyte >> 4;
 
       blinkD3();
       prgMode = COMMAND;
-      dbgOutLn("com");
-      doPort(com); //show command
+      dbgOutLn("cmd");
+      doPort(cmd); //show command
 
       do {
         if (digitalRead(SW_SEL) == 0) {
           delay(KEY_DELAY);
-          com += 1;
-          com = com & 0x0F;
-          doPort(com);
+          cmd += 1;
+          cmd = cmd & 0x0F;
+          doPort(cmd);
         }
       }
       while (digitalRead(SW_PRG) == 1);
@@ -97,7 +97,7 @@ void programMode() {
       while (digitalRead(SW_PRG) == 1); // S2 = 1
       delay(DEBOUNCE);
 
-      byte newValue = (com << 4) + data;
+      byte newValue = (cmd << 4) + data;
       if (newValue != Eebyte) {
         writebyte(addr, newValue); //           Writeeeprom Eebyte , Addr
         blinkAll();

+ 1 - 1
SimpleSPS/SImpleSPS/SImpleSPS.ino

@@ -390,7 +390,7 @@ void doCalc(byte data) {
       a = a ^ b;
       break;
     case 10:
-      a = !a;
+      a = ~a;
       break;
     default:
       break;

+ 2 - 0
git_push_all.cmd

@@ -0,0 +1,2 @@
+git push --all
+git push origin --tags