Remove delay from main loop and control motor updates with a specific delay

--- code/MotorController/MotorController.ino
+++ code/MotorController/MotorController.ino
@@ -37,23 +37,24 @@
 const uint32_t* maximumEepromAddress = (uint32_t*)1024 - 1;

 // Switches using the Bounce library for debouncing
-Bounce onOffSwitch = Bounce(onOffSwitchInPin, switchDebounceTime);
-Bounce directionSwitch = Bounce(directionSwitchInPin, switchDebounceTime);
-Bounce clockResetSwitch = Bounce(clockResetInPin, switchDebounceTime);
-Bounce debugDisplaySwitch = Bounce(debugDisplayInPin, switchDebounceTime);
+Bounce onOffSwitch = Bounce();
+Bounce directionSwitch = Bounce();
+Bounce clockResetSwitch = Bounce();
+Bounce debugDisplaySwitch = Bounce();

 LCDserNHD lcd(2, 16);

 // State variables
 int targetSpeed = 0;
 int currentSpeed = 0;
-int delayBetweenAdjustments = 15;
+int delayBetweenMotorUpdates = 15;
+unsigned long lastMotorUpdateTime = 0;
 boolean powerEnabled = false;
 int targetDirection = CLOCKWISE;
 int currentDirection = CLOCKWISE;
 volatile int motorTicks = 0;
+unsigned long lastClockTickTime = 0;
 unsigned long lastDisplayTime = 0;
-unsigned long nextClockTick = 0;
 unsigned long secondsOfOperation = 0;
 uint32_t* nextClockBufferLocation = 0;
 boolean showDebugDisplay = false;
@@ -81,7 +82,7 @@
   pinMode(debugDisplayInPin, INPUT_PULLUP);
   // We don't have to set pin mode for analog inputs

-   onOffSwitch.attach(onOffSwitchInPin);
+  onOffSwitch.attach(onOffSwitchInPin);
   onOffSwitch.interval(switchDebounceTime);
   directionSwitch.attach(directionSwitchInPin);
   directionSwitch.interval(switchDebounceTime);
@@ -117,6 +118,16 @@

 void loop()
 {
+  HandleInputs();
+
+  SetMotorState();
+
+  UpdateClock();
+  UpdateDisplay();
+}
+
+void HandleInputs()
+{
   clockResetSwitch.update();
   if (clockResetSwitch.fell())
   {
@@ -134,11 +145,7 @@
   {
     powerEnabled = !powerEnabled;

-    if (powerEnabled)
-    {
-      nextClockTick = millis() + 1000;
-    }
-    else
+    if (!powerEnabled)
     {
       WriteClock();
     }
@@ -161,8 +168,8 @@
     targetSpeed = 0;
   }

-  delayBetweenAdjustments = ReadPotentiometer(rateOfSpeedChangeInPin);
-  delayBetweenAdjustments = map(delayBetweenAdjustments, 0, potentiometerCeiling, minimumDelay, maximumDelay);
+  delayBetweenMotorUpdates = ReadPotentiometer(rateOfSpeedChangeInPin);
+  delayBetweenMotorUpdates = map(delayBetweenMotorUpdates, 0, potentiometerCeiling, minimumDelay, maximumDelay);
   int absoluteCurrentSpeed = abs(currentSpeed);
   if (absoluteCurrentSpeed > abs(targetSpeed) && absoluteCurrentSpeed < startOfStopDamping)
   {
@@ -170,33 +177,34 @@
     // doesn't work as well at low speed and we don't the bobbin to run ahead of
     // the flyer. So at the low end we start raising the delay toward max regardless
     // of what it's actually set to.
-    delayBetweenAdjustments = map(absoluteCurrentSpeed, minimumSpeed, startOfStopDamping, maximumDelay, delayBetweenAdjustments);
-  }
-
-  if (currentSpeed == 0 && currentDirection != targetDirection)
-  {
-    // We're at zero speed and want to switch directions.
-    digitalWrite(directionOutPin, targetDirection);
-    currentDirection = targetDirection;
-    UpdateDirectionDisplay();
+    delayBetweenMotorUpdates = map(absoluteCurrentSpeed, minimumSpeed, startOfStopDamping, maximumDelay, delayBetweenMotorUpdates);
+  }
+}
+
+void SetMotorState()
+{
+  unsigned long now = millis();
+  unsigned int timeSinceLastMotorUpdate = now - lastMotorUpdateTime;
+
+  if (timeSinceLastMotorUpdate > delayBetweenMotorUpdates)
+  {
+    lastMotorUpdateTime = now;
+
+    if (currentSpeed == 0 && currentDirection != targetDirection)
+    {
+      // We're at zero speed and want to switch directions.
+      digitalWrite(directionOutPin, targetDirection);
+      currentDirection = targetDirection;
+      UpdateDirectionDisplay();
+
+      // We don't want to actually start moving the other direction,
+      // wait for the user to hit the power button again
+      powerEnabled = false;
+    }

-    // We don't want to actually start moving the other direction,
-    // wait for the user to hit the power button again
-    powerEnabled = false;
-  }
-
-  currentSpeed += SlewToward(currentSpeed, targetSpeed);
-  analogWrite(speedOutPin, abs(currentSpeed));
-
-  UpdateClock();
-  UpdateDisplay();
-
-  // Rather than trying to write a fixed-delay loop we're being lazy and using a
-  // variable-deplay loop to control the rate at which we change the motor speed.
-  // This should be fine because we don't have anything urgent that we need to do
-  // in between adjustments anyway and the input response lag even at maximum delay
-  // will never be noticable to the user.
-  delay(delayBetweenAdjustments);
+    currentSpeed += SlewToward(currentSpeed, targetSpeed);
+    analogWrite(speedOutPin, abs(currentSpeed));
+  }
 }

 boolean CanChangePowerState()
@@ -245,14 +253,21 @@

 void UpdateClock()
 {
-  if (powerEnabled && millis() > nextClockTick)
-  {
-    nextClockTick += 1000;
-    secondsOfOperation++;
+  unsigned long now = millis();
+  unsigned int timeSinceLastClockTick = now - lastClockTickTime;
+
+  if (timeSinceLastClockTick > 1000)
+  {
+    lastClockTickTime = now;

-    if (secondsOfOperation % 60 == 0)
-    {
-      WriteClock();
+    if (powerEnabled)
+    {
+      secondsOfOperation++;
+
+      if (secondsOfOperation % 60 == 0)
+      {
+        WriteClock();
+      }
     }
   }
 }


WU 0F temp bug

WU 0F temp bug

--- hvacMonitor.ino
+++ hvacMonitor.ino
@@ -192,7 +192,7 @@
     Blynk.virtualWrite(5, dailyOutsideHigh);
   }

-  if (temp_f < dailyOutsideLow)
+  if (temp_f < dailyOutsideLow && temp_f > 0) // "> 0" screens out API zero errors
   {
     dailyOutsideLow = temp_f;
     Blynk.virtualWrite(13, dailyOutsideLow);


delete debug code

delete debug code

--- arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot_burger/turtlebot3_core/turtlebot3_core.ino
+++ arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot_burger/turtlebot3_core/turtlebot3_core.ino
@@ -151,8 +151,6 @@
   pinMode(13, OUTPUT);

   SerialBT2.begin(57600);
-
-  Serial.begin(57600);
 }

 /*******************************************************************************


couldnt find the dynamic filename function. Added timestamp. main loop only writes one time

--- Calibration/liveCode/overclockAccel/overclockAccel.ino
+++ Calibration/liveCode/overclockAccel/overclockAccel.ino
@@ -18,7 +18,8 @@
 sensors_event_t accel_event;
 sensors_vec_t   orientation;
 //data buffer for the accel and orientation readings
-char dataArray[80];
+//char dataArray[80];
+String dataString;

 void initAccel()
 {
@@ -65,13 +66,9 @@
   accel.getEvent(&accel_event);
   if (dof.accelGetOrientation(&accel_event, &orientation))
   {
-    sdWrite((String)accel_event.acceleration.x);
-    sdWrite((String)accel_event.acceleration.y);
-    sdWrite((String)accel_event.acceleration.z);
-    sdWrite((String)accel_event.orientation.roll);
-    sdWrite((String)accel_event.orientation.pitch);
-    sdWrite((String) accel_event.orientation.heading);
-    sdWriteNewline();
+    dataString = ((String) accel_event.acceleration.x) + ((String)accel_event.acceleration.y) + ((String)accel_event.acceleration.z)
+      + ((String)accel_event.orientation.roll) + ((String)accel_event.orientation.pitch) + ((String) accel_event.orientation.heading) + millis() + '\n';
+    sdWrite(dataString);
   }
 }
 bool sdWriteNewline() {
@@ -93,7 +90,7 @@
   // if the file is available, write to it:
   if (dataFile) {
     dataFile.print(data);
-    dataFile.print(", ");i
+    dataFile.print(", ");
     dataFile.close();
     // print to the serial port too:
   }


tidyup

tidyup

--- V0p2_Main/V0p2_Main.ino
+++ V0p2_Main/V0p2_Main.ino
@@ -97,7 +97,6 @@
   OTV0P2BASE::serialPrintlnAndFlush(s); // Print supplied detail text. // May fail.
   panic();
   }
-

 // Signal position in basic POST sequence as a small positive integer, or zero for done/none.
@@ -330,7 +329,6 @@
   // Assume no RX nor filtering on secondary radio.
 #endif // ENABLE_RADIO_SECONDARY_MODULE

-
 //  posPOST(1, F("Radio OK, checking buttons/sensors and xtal"));

 // Buttons should not be activated DURING boot for user-facing boards; an activated button implies a fault.
@@ -490,7 +488,6 @@
 #endif
 #endif

-
 #if !defined(ALT_MAIN_LOOP) && !defined(UNIT_TESTS)
   // Get current power supply voltage (internal sensor).
   const uint16_t Vcc = Supply_cV.read();
@@ -513,7 +510,6 @@
 #endif
 #endif

-
 #if !defined(ALT_MAIN_LOOP) && !defined(UNIT_TESTS)
 #if 0 && defined(DEBUG)
   DEBUG_SERIAL_PRINTLN_FLASHSTRING("Computing initial target/demand...");
@@ -523,7 +519,6 @@
   NominalRadValve.read();
 #endif
 #endif
-

   // Ensure that the unique node ID is set up (mainly on first use).
   // Have one attempt (don't want to stress an already failing EEPROM) to force-reset if not good, then panic.
@@ -534,9 +529,7 @@
       { panic(F("!Bad ID")); }
     }

-
-  // Initialised: turn heatcall UI LED off.
-//  pinMode(LED_HEATCALL, OUTPUT);
+  // Initialised: turn main/heatcall UI LED off.
   LED_HEATCALL_OFF();

 #if defined(ENABLE_CLI) && defined(ENABLE_CLI_HELP) && !defined(ALT_MAIN_LOOP) && !defined(UNIT_TESTS) && !defined(ENABLE_TRIMMED_MEMORY)
@@ -551,12 +544,6 @@
   setupOpenTRV();
 #endif
   }
-
-
-
-
-
-

 //========================================


updated arduino code to implement all the changes

also did:
- update unittest to cover getting a lot of data
- fixed post_changes to make sense
todo:
- write arduino function to do stuff on post request

--- WatSat_arduino_code.ino
+++ WatSat_arduino_code.ino
@@ -1,3 +1,5 @@
+#include <Wire.h>
+#include <SBoard.h>
 /*
 high pwm means low voltage
 low pwm means high voltage
@@ -6,15 +8,20 @@
 //All code is using variables, which can change
 //Figure out how data for magnetometers have to be handled (photodiodes and temp are just default

-
-int select = 1;  //value from 0 to 15, telling which line on the MUX to select and in this form to easily convert to binary that's need for control lines
-
+int NUM_BOARDS = 6;
 int control0 = 2;
 int control1 = 3;
 int control2 = 4;
 int control3 = 5;
+
+int in0 = 0;
+int in1 = 1;
+
+SBoard boards[6];
+Data d0;
+Data master [6];
+
 char req;
-boolean requestData;

 void setup() {
   Serial.begin(9600);
@@ -25,6 +32,13 @@
   pinMode(control3, OUTPUT);

   Serial.println("Started serial");
+  init_stuff();
+}
+
+void loop() {
+  while (Serial.available() > 0){
+    listenForRequest();
+  }

 }

@@ -35,9 +49,6 @@
     getRequest();
   }else if (req == 'p'){
     postRequest();
-  }else{
-    Serial.println(req);
-    Serial.println("No Data Recieved");
   }
 }

@@ -46,8 +57,9 @@
   What to do when a "post" request is sent.
   For example, will post the voltage required to apply to magentorquers
   */
-  delay(1120);
-  Serial.println("This is a post request");
+  delay(100);
+  float a = Serial.parseFloat()
+  Serial.println(a);
 }

 void getRequest(){
@@ -55,97 +67,53 @@
   What to do when a "get" request is sent.
   For example, will gather from all the sensors and pass that to comp using serial por
   */
- delay(1120);
- Serial.println("This is a get request");
+ readall();
+ outputall();
 }

-void loop() {
-/*
-  for(int i=1; i<16; i++){
-    Serial.println(i);
-    selectLine(i);
-    Serial.print(digitalRead(control3));
-    Serial.print(digitalRead(control2));
-    Serial.print(digitalRead(control1));
-    Serial.print(digitalRead(control0));
-    Serial.println();
-    delay(1000);
-  }
-*/
-
-  while (Serial.available() > 0){
-    listenForRequest();
-  }
-
+void init_stuff()
+{
+  // TODO: define all the sensors/boards
+  Sensor p0 = {0, 0000};
+  Sensor p1 = {0, 0001};
+  Sensor tmp = {0, 0010};
+  Sensor mxm = {0, 0011};
+  Sensor mxd = {0, 0100};
+  Sensor mym = {0, 0101};
+  Sensor myd = {0, 0110};
+  boards[0] = SBoard(p0, p1, tmp, mxm, mxd, mym, myd,
+    control0, control1, control2, control3);
+  boards[1] = SBoard(p0, p1, tmp, mxm, mxd, mym, myd,
+    control0, control1, control2, control3);
+  boards[2] = SBoard(p0, p1, tmp, mxm, mxd, mym, myd,
+    control0, control1, control2, control3);
+  boards[3] = SBoard(p0, p1, tmp, mxm, mxd, mym, myd,
+    control0, control1, control2, control3);
+  boards[4] = SBoard(p0, p1, tmp, mxm, mxd, mym, myd,
+    control0, control1, control2, control3);
+  boards[5] = SBoard(p0, p1, tmp, mxm, mxd, mym, myd,
+    control0, control1, control2, control3);
+
 }

-
-
-void selectLine(int inputNum){
-  //given number of the input lines we'd like, activate the control lines which select them
-  if(0 < inputNum && inputNum < 16){
-
-    if (inputNum >= 8){
-      digitalWrite(control3,HIGH);
-      inputNum = inputNum - 8;
-    }
-    else{
-      digitalWrite(control3,LOW);
-    }
-
-
-    if (inputNum >= 4){
-        digitalWrite(control2,HIGH);
-        inputNum = inputNum - 4;
-    }
-    else{
-        digitalWrite(control2,LOW);
-    }
-
-
-
-    if (inputNum >= 2){
-       digitalWrite(control1,HIGH);
-       inputNum = inputNum - 2;
-    }
-    else{
-      digitalWrite(control1,LOW);
-    }
-
-
-
-
-    if (inputNum >= 1){
-        digitalWrite(control0,HIGH);
-        inputNum = inputNum - 1;
-    }
-    else{
-        digitalWrite(control0,LOW);
-    }
-
-
+void readall(){
+  for (int i=0; i<(NUM_BOARDS/2); i++){
+    master[i] = boards[i].readData(in0);
+    master[i+1] = boards[i+1].readData(in1);
   }
 }

+void outputall(){
+  for (int i=0; i<NUM_BOARDS; i++){
+    Serial.print(i);
+    Serial.print("{photodiodes:");
+    Serial.print(master[i].pda);
+    Serial.print("; mag_x:");
+    Serial.print(master[i].ax);
+    Serial.print("; mag_y:");
+    Serial.print(master[i].ay);
+    Serial.print(";}");
+  }
+  Serial.print("\n");
+}

-
-
-
-
-/*
-
-float readPhotoDiode(int pin){
-  // read the input on analog pin 0:
-  int sensorValue = analogRead(A0);
-  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
-  float voltage = sensorValue * (5.0 / 1023.0);
-  // print out the value you read:
-  Serial.println(voltage);
-
-
-
-  sensorValue = analogRead(pin);
-  float voltage = sensorValue * (5.0 / 1023.0);
-  return voltage;
-}
-*/


Enhanced Wi-Fi connection reliability

Enhanced Wi-Fi connection reliability

Resolved Wi-Fi connection reliability by adding enableSTA(true) and enableAP(false). Without these the ESP32 will have difficulty connecting to a Wi-Fi network.

--- WeatherConsole_OLED.ino
+++ WeatherConsole_OLED.ino
@@ -320,6 +320,10 @@
     WiFi.disconnect(true);
     saqi = "No WiFi";
     delay(1000);
+    WiFi.enableSTA(true);
+    WiFi.enableAP(false);
+    delay(2000);
+
     WiFi.onEvent(WiFiEvent);
     WiFi.begin(ssid, password);
     if (debug) {


Doug Hilton - merge ShowAngles command into ShowAngle Command. add ShowInterval and HideInterval command.  Output to CSV format

--- XV_Lidar_Controller.ino
+++ XV_Lidar_Controller.ino
@@ -8,7 +8,14 @@
  Modified to add CRC checking - Doug Hilton, WD0UG November, 2015 mailto: six.speed (at) yahoo (dot) com
  Modified to add ShowErrors / HideErrors - DSH
  Modified to add ShowAngles - DSH
-
+ Modified SerialCommand.h to increase # of characters allowed to be input and command length - DSH
+           #define SERIALCOMMAND_BUFFER 100		// ORIGINAL: 32   MODIFIED BY DSH
+           #define SERIALCOMMAND_MAXCOMMANDLENGTH 20	// ORIGINAL: 8
+ ****************************************************************************************
+ NOTE: DON'T FORGET TO COPY THE NEW SerialCommand.h TO YOUR ARDUINO LIBRARY DIRECTORY!!!
+ ****************************************************************************************
+ Modified to merge ShowAngles command into ShowAngle Command - DSH
+ Modified to add ShowInterval and HideInterval command (show interval, in milliseconds, every revolution, at angle=0
  See README for additional information

  The F() macro in the Serial statements tells the compiler to keep your strings in PROGMEM
@@ -88,9 +95,9 @@
 const int VALID_PACKET = 0;
 const int INVALID_PACKET = VALID_PACKET + 1;
 const byte INVALID_DATA_FLAG = (1 << 7);   // Mask for byte 1 of each data quad "Invalid data"
+boolean bShowInterval;                     // true = show time interval, once per revolution, at angle=0

 boolean aryAngles[N_ANGLES];               // true if we're supposed to display the corresponding angle
-boolean bShowAnglesFromArray = false;      // true if we're supposed to display multiple angles

 /* REF: https://github.com/Xevel/NXV11/wiki
 The bit 7 of byte 1 seems to indicate that the distance could not be calculated.
@@ -152,7 +159,8 @@
   for (ixPacket = 0; ixPacket < PACKET_LENGTH; ixPacket++)  // Initialize
     Packet[ixPacket] = 0;
   ixPacket = 0;
-
+  setLowRPM(xv_config.rpm_min);                      // Make the motor go as slow as possible
+  //hideRaw();                                         // DSH ONLY!!!!!!!!!!!!
 }
 // Main loop (forever)
 void loop() {
@@ -187,80 +195,34 @@
             if (aryInvalidDataFlag[ix] == 0)
               processSignalStrength(ix);
           }
-          if (xv_config.show_dist) {                         // the 'ShowDistance' command is active
-            if (bShowAnglesFromArray) {                      // we're going to display only angles that are in 'aryAngles'
-              for (int ix = 0; ix < N_DATA_QUADS; ix++) {
-                if (aryAngles[startingAngle + ix]) {         // if we're supposed to display that angle
-                  if (aryInvalidDataFlag[ix] == 0) {         // make sure that the 'Invalid Data' flag is clear
-                    Serial.print(startingAngle + ix);
-                    Serial.print(F(": "));
-                    Serial.print(int(aryDist[ix]));
-                    Serial.print(F(" ("));
-                    Serial.print(aryQuality[ix]);
-                    Serial.println(F(")"));
+          if (xv_config.show_dist) {                           // the 'ShowDistance' command is active
+            for (int ix = 0; ix < N_DATA_QUADS; ix++) {
+              if (aryAngles[startingAngle + ix]) {             // if we're supposed to display that angle
+                if (aryInvalidDataFlag[ix] & BAD_DATA_MASK) {  // if LIDAR reported a data error...
+                  if (bShowErrors) {                           // if we're supposed to show data errors...
+                    Serial.print(F("A,"));
+                    Serial.print(startingAngle + ix);
+                    Serial.print(F(","));
+                    if (aryInvalidDataFlag[ix] & INVALID_DATA_FLAG)
+                      Serial.println(F("-2"));
+                    if (aryInvalidDataFlag[ix] & STRENGTH_WARNING_FLAG)
+                      Serial.println(F("-3"));
                   }
-                  else if (bShowErrors) {
-                    Serial.print(startingAngle + ix);
-                    Serial.print(F(": "));
-                    for (int jx = 0; jx < PACKET_LENGTH; jx++) {
-                      if (Packet[jx] < 0x10)
-                        Serial.print(F("0"));
-                      Serial.print(Packet[jx], HEX);
-                      Serial.print(F(" "));
-                    }
-                    if (aryInvalidDataFlag[ix] & INVALID_DATA_FLAG)
-                      Serial.print(F("{I}"));
-                    if (aryInvalidDataFlag[ix] & STRENGTH_WARNING_FLAG)
-                      Serial.print(F("{S}"));
-                    if (aryInvalidDataFlag[ix])
-                      Serial.println(F(""));
-                  }  // else if (bShowErrors)
-                }  // if (aryAngles[startingAngle + ix])
-              }  // for (int ix = 0; ix < N_DATA_QUADS; ix++)
-            }  // if (bShowAnglesFromArray)
-            else {
-              if (xv_config.show_angle == SHOW_ALL_ANGLES    // Are we showing all angles or just 1 angle?
-              || ((xv_config.show_angle >= startingAngle) && (xv_config.show_angle < startingAngle + N_DATA_QUADS))) {
-                for (int ix = 0; ix < N_DATA_QUADS; ix++) {  // process each of the (4) angles
-                  if ((xv_config.show_angle == SHOW_ALL_ANGLES) || (xv_config.show_angle == startingAngle + ix)) {
-                    if (aryInvalidDataFlag[ix] == 0) {       // make sure that the 'Invalid Data' flag is clear
-                      Serial.print(startingAngle + ix);
-                      Serial.print(F(": "));
-                      Serial.print(int(aryDist[ix]));
-                      Serial.print(F(" ("));
-                      Serial.print(aryQuality[ix]);
-                      Serial.println(F(")"));
-                    }
-                    else if (bShowErrors) {
-                      Serial.print(startingAngle + ix);
-                      Serial.print(F(": "));
-                      for (int jx = 0; jx < PACKET_LENGTH; jx++) {
-                        if (Packet[jx] < 0x10)
-                          Serial.print(F("0"));
-                        Serial.print(Packet[jx], HEX);
-                        Serial.print(F(" "));
-                      }
-                      if (aryInvalidDataFlag[ix] & INVALID_DATA_FLAG)
-                        Serial.print(F("{I}"));
-                      if (aryInvalidDataFlag[ix] & STRENGTH_WARNING_FLAG)
-                        Serial.print(F("{S}"));
-                      if (aryInvalidDataFlag[ix])
-                        Serial.println(F(""));
-                    }  // else if (bShowErrors)
-                  }  // if ((xv_config.show_angle == SHOW_ALL_ANGLES) ...
-                }  // or (int ix = 0; ix < N_DATA_QUADS; ix++)
-              }  // if (xv_config.show_angle == SHOW_ALL_ANGLES ...
-            }  // if (bShowAngles)
+                }
+                else {                                         // show clean data
+                  Serial.print(F("A,"));
+                  Serial.print(startingAngle + ix);
+                  Serial.print(F(","));
+                  Serial.print(int(aryDist[ix]));
+                  Serial.print(F(","));
+                  Serial.println(aryQuality[ix]);
+                }
+              }  // if (aryAngles[startingAngle + ix])
+            }  // for (int ix = 0; ix < N_DATA_QUADS; ix++)
           }  // if (xv_config.show_dist)
         }  // if (eValidatePacket() == 0
-        else if (bShowErrors) {
-          for (int ix = 0; ix < PACKET_LENGTH; ix++) {
-            if (Packet[ix] < 0x10)
-              Serial.print(F("0"));
-            Serial.print(Packet[ix], HEX);
-            Serial.print(F(" "));
-          }
-          Serial.println(F(" Bad CRC"));
+        else if (bShowErrors) {                                // we have encountered a CRC error
+          Serial.println(F("C,-1"));
         }
         // initialize a bunch of stuff before we switch back to State 1
         for (int ix = 0; ix < N_DATA_QUADS; ix++) {
@@ -296,6 +258,7 @@
  *             xv_config.show_dist = true if we're supposed to show distance
  *             curMillis = milliseconds, now
  *             lastMillis = milliseconds, last time through this subroutine
+ *             bShowInterval = true ==> display time interval once per revolution, at angle 0
  * Calls:      digitalWrite() - used to toggle LED pin
  *             Serial.print
  * Returns:    The first angle (of 4) in the current 'index' group
@@ -314,11 +277,9 @@
     digitalWrite(ledPin, ledState);
     if (xv_config.show_dist) {
       curMillis = millis();
-      if(xv_config.show_angle == SHOW_ALL_ANGLES) {
-        /*
-        Serial.print(F("Time Interval: "));
-        Serial.println(curMillis - lastMillis);
-        */
+      if(bShowInterval) {
+        Serial.print(F("T,"));                                // Time Interval in ms since last complete revolution
+        Serial.println(curMillis - lastMillis);
       }
       lastMillis = curMillis;
     }
@@ -341,9 +302,9 @@
   motor_rph = (motor_rph_high_byte << 8) | motor_rph_low_byte;
   motor_rpm = float( (motor_rph_high_byte << 8) | motor_rph_low_byte ) / 64.0;
   if (xv_config.show_rpm and startingAngle == 0) {
-    Serial.print(F("RPM: "));
+    Serial.print(F("RPM,"));
     Serial.print(motor_rpm);
-    Serial.print(F("  PWM: "));
+    Serial.print(F(",PWM,"));
     Serial.println(pwm_val);
   }
 }
@@ -479,34 +440,56 @@
   sCmd.addCommand("HideRPM",  hideRPM);
   sCmd.addCommand("ShowDist",  showDist);
   sCmd.addCommand("HideDist",  hideDist);
-  sCmd.addCommand("ShowAngles",  showAngles);      // this must be before "ShowAngle" to ensure correct match
-  sCmd.addCommand("HideAngles",  hideDist);
   sCmd.addCommand("ShowAngle",  showAngle);
   sCmd.addCommand("HideAngle",  hideDist);
   sCmd.addCommand("MotorOff", motorOff);
   sCmd.addCommand("MotorOn",  motorOn);
+  sCmd.addCommand("ShowRaw",  showRaw);
   sCmd.addCommand("HideRaw", hideRaw);
-  sCmd.addCommand("ShowRaw",  showRaw);
   sCmd.addCommand("ShowErrors", showErrors);
   sCmd.addCommand("HideErrors", hideErrors);
+  sCmd.addCommand("ShowInterval", showInterval);
+  sCmd.addCommand("HideInterval", hideInterval);
+}
+/*
+ * showInterval - enable display of Time interval (which happens once per revolution, at angle 0
+ */
+void showInterval() {
+  bShowInterval = true;
+  if (xv_config.show_dist == false) {                  // suppress activity message if we're executing 'show distance'
+    Serial.println(F(" "));
+    Serial.println(F("Showing time interval (ms per revolution)"));
+  }
+}
+/*
+ * hideInterval - suppress display of Time interval
+ */
+void hideInterval() {
+  bShowInterval = false;
+  if (xv_config.show_dist == false) {                  // suppress activity message if we're executing 'show distance'
+    Serial.println(F(" "));
+    Serial.println(F("Hiding time interval"));
+  }
 }
 /*
  * showErrors
  */
 void showErrors() {
   bShowErrors = true;                                  // enable error display
-  Serial.println(F(" "));
-  Serial.print(F("Showing errors"));
-  Serial.println(F(" "));
+  if (xv_config.show_dist == false) {                  // suppress activity message if we're executing 'show distance'
+    Serial.println(F(" "));
+    Serial.println(F("Showing errors"));
+  }
 }
 /*
  * hideErrors
  */
 void hideErrors() {                                    // disable error display
   bShowErrors = false;
-  Serial.println(F(" "));
-  Serial.print(F("Hiding errors"));
-  Serial.println(F(" "));
+  if (xv_config.show_dist == false) {                  // suppress activity message if we're executing 'show distance'
+    Serial.println(F(" "));
+    Serial.println(F("Hiding errors"));
+  }
 }
 /*
  * showRPM
@@ -516,90 +499,57 @@
   if (xv_config.raw_data == true) {
     hideRaw();
   }
-  Serial.println(F(" "));
-  Serial.print(F("Showing RPM data"));
-  Serial.println(F(" "));
+  if (xv_config.show_dist == false) {                  // suppress activity message if we're executing 'show distance'
+    Serial.println(F(" "));
+    Serial.println(F("Showing RPM data"));
+  }
 }
 /*
  * hideRPM
  */
 void hideRPM() {
   xv_config.show_rpm = false;
-  Serial.println(F(" "));
-  Serial.print(F("Hiding RPM data"));
-  Serial.println(F(" "));
+  if (xv_config.show_dist == false) {                  // suppress activity message if we're executing 'show distance'
+    Serial.println(F(" "));
+    Serial.println(F("Hiding RPM data"));
+  }
 }

 void showDist() {
+  showDist2();
+  for (int ix = 0; ix < N_ANGLES; ix++)
+    aryAngles[ix] = true;
+}
+void showDist2() {
+  hideRaw();
+  xv_config.show_angle = SHOW_ALL_ANGLES;
+  if (xv_config.show_dist == false) {                  // suppress activity message if we're executing 'show distance'
+    Serial.println(F(" "));
+    Serial.println(F("Code,Angle,Distance(mm),Signal strength"));
+  }
   xv_config.show_dist = true;
-  if (xv_config.raw_data == true) {
-    hideRaw();
-  }
-  xv_config.show_angle = SHOW_ALL_ANGLES;
-  Serial.println(F(" "));
-  Serial.print(F("Showing Distance data <Angle>: <dist mm> (quality)}"));
-  Serial.println(F(" "));
 }

 void hideDist() {
   xv_config.show_dist = false;
-  xv_config.show_angle = SHOW_ALL_ANGLES;              // set default back to 'show all angles'
-  Serial.println(F(" "));
-  Serial.print(F("Hiding Distance data"));
-  Serial.println(F(" "));
-}
-
-void showAngle() {
-  bShowAnglesFromArray = false;                        // disable multi-angle display
-  showDist();
-  double sVal = 0.0;
-  char *arg;
-  boolean syntax_error = false;
-
-  arg = sCmd.next();
-  if (arg != NULL) {
-    sVal = atoi(arg);    // Converts a char string to a int
-    if (sVal < 0 or sVal > SHOW_ALL_ANGLES) {
-      syntax_error = true;
-    }
-  }
-  else {
-    syntax_error = true;
-  }
-
-  arg = sCmd.next();
-  if (arg != NULL) {
-    syntax_error = true;
-  }
-
-  if (syntax_error) {
-    Serial.println(F(" "));
-    Serial.print(F("Incorrect syntax.  Example: ShowAngle 0 (0 - 359 or 360 for all)"));
-    Serial.println(F(" "));
-  }
-  else {
-    xv_config.show_angle = sVal;
-    Serial.println(F(" "));
-    if (xv_config.show_angle == SHOW_ALL_ANGLES)
-      Serial.print(F("Showing All Angles"));
-    else {
-      Serial.print(F("Showing Only Angle: "));
-      Serial.println(sVal);
-    }
-    Serial.println(F(" "));
-  }  // if (syntax_error)
-}
-/*
- * doShowAngles - Multi-angle range(s) implementation - DSH
+  for (int ix = 0; ix < N_ANGLES; ix++)
+    aryAngles[ix] = false;
+  xv_config.show_angle = 0;
+  if (xv_config.show_dist == false) {                  // suppress activity message if we're executing 'show distance'
+    Serial.println(F(" "));
+    Serial.println(F("Hiding Distance data"));
+  }
+}
+/*
+ * doShowAngle - Multi-angle range(s) implementation - DSH
  * Command: ShowAngles ddd, ddd-ddd, etc.
- * Command: HideAngles (remember to clear out aryAngles)
  * Enter with: N/A
  * Uses:       aryAngles (an array of 360 booleans) is set to appropriate values
  * Calls:      showDist
  * Exits with: N/A
  * TEST THIS STRING:  ShowAngles 16-20, 300-305, 123-124, 10
  */
-void showAngles() {
+void showAngle() {
   double sVal = 0.0;
   char c, *arg;
   boolean syntax_error = false;
@@ -620,7 +570,7 @@
     lToken = strlen(arg);                                // get the length of the current token
     for (ix = 0; ix < lToken; ix++) {
       c = arg[ix];
-      if (c == ',') {                                     // optional trailing comma
+      if (c == ',') {                                    // optional trailing comma
         doing_from_to = 0;
         break;
       }
@@ -675,37 +625,37 @@

   // Handle syntax errors
   if (syntax_error) {
-    bShowAnglesFromArray = false;                      // syntax error: disable multi-angle display
-    Serial.println(F(" "));
-    Serial.print(F("Incorrect syntax.  Example: ShowAngles 0, 15-30, 45-50, 10"));
-    Serial.println(F(" "));
-    Serial.print(F("Use a space after each comma. No particular order is required."));
-    Serial.println(F(" "));
-    Serial.print(F("In a from-to pair, the 1st value must be lowest."));
-    Serial.println(F(" "));
+    Serial.println(F(" "));
+    Serial.println(F("Incorrect syntax"));
+    Serial.println(F("  Example: ShowAngle 0, 15-30, 45-50, 10"));
+    Serial.println(F("  Example: ShowAngle 0-359 to show all angles."));
+    Serial.println(F("Notes: Use a space after each comma"));
+    Serial.println(F("       No particular order is required"));
+    Serial.println(F("       In a from-to pair, the 1st value must be lowest. From-to pairs can overlap ranges."));
   }
   else {                                                  // no errors detected, display the angles and start
     // We're ready to process multiple angles
     Serial.println(F(""));
     Serial.print(F("Angles:"));
+    xv_config.show_angle == SHOW_ALL_ANGLES;              // start by assuming 'all angles'
     for (int ix = 0; ix < N_ANGLES; ix++) {               // display the angle array
       if(aryAngles[ix]) {
         Serial.print(ix, DEC);
         Serial.print(F(","));
       }
-    }
-    Serial.println(F(""));
-    bShowAnglesFromArray = true;                          // show multiple angles is enabled
-    showDist();
-  }  // if (syntax_error)
+      else
+        xv_config.show_angle == 0;                        // disable 'display all angles'
+    }
+    Serial.println(F(""));
+    showDist2();
+  }  // if not (syntax_error)
 }

 void motorOff() {
   xv_config.motor_enable = false;
   Timer3.pwm(xv_config.motor_pwm_pin, 0);
   Serial.println(F(" "));
-  Serial.print(F("Motor off"));
-  Serial.println(F(" "));
+  Serial.println(F("Motor off"));
 }

 void motorOn() {
@@ -713,8 +663,7 @@
   Timer3.pwm(xv_config.motor_pwm_pin, pwm_val);
   rpm_err = 0;  // reset rpm error
   Serial.println(F(" "));
-  Serial.print(F("Motor on"));
-  Serial.println(F(" "));
+  Serial.println(F("Motor on"));
 }

 void motorCheck() {  // Make sure the motor RPMs are good else shut it down
@@ -737,20 +686,21 @@

 void hideRaw() {
   xv_config.raw_data = false;
-  Serial.println(F(" "));
-  Serial.print(F("Raw lidar data disabled"));
-  Serial.println(F(" "));
+  //Serial.println(F(" "));
+  //Serial.println(F("Raw lidar data disabled"));
 }

 void showRaw() {
   xv_config.raw_data = true;
   hideDist();
   hideRPM();
-  Serial.println(F(" "));
-  Serial.print(F("Lidar data enabled"));
-  Serial.println(F(" "));
-}
-
+  //Serial.println(F(" "));
+  //Serial.println(F("Lidar data enabled"));
+}
+
+void setLowRPM(double sVal) {
+  xv_config.rpm_setpoint = sVal;
+}
 void setRPM() {
   double sVal = 0.0;
   char *arg;
@@ -763,15 +713,13 @@
       sVal = xv_config.rpm_min;
       Serial.println(F(" "));
       Serial.print(F("RPM too low. Setting to minimum "));
-      Serial.print(xv_config.rpm_min);
-      Serial.println(F(" "));
+      Serial.println(xv_config.rpm_min);
     }
     if (sVal > xv_config.rpm_max) {
       sVal = xv_config.rpm_max;
       Serial.println(F(" "));
       Serial.print(F("RPM too high. Setting to maximum "));
-      Serial.print(xv_config.rpm_max);
-      Serial.println(F(" "));
+      Serial.println(xv_config.rpm_max);
     }
   }
   else {
@@ -785,8 +733,7 @@

   if (syntax_error) {
     Serial.println(F(" "));
-    Serial.print(F("Incorrect syntax.  Example: SetRPM 300"));
-    Serial.println(F(" "));
+    Serial.println(F("Incorrect syntax.  Example: SetRPM 200"));
   }
   else {
     Serial.print(F("Old RPM setpoint:"));
@@ -795,7 +742,6 @@
     //Serial.println(F(" "));
     Serial.print(F("New RPM setpoint: "));
     Serial.println(sVal);
-    Serial.println(F(" "));
   }
 }

@@ -819,14 +765,12 @@

   if (syntax_error) {
     Serial.println(F(" "));
-    Serial.print(F("Incorrect syntax.  Example: SetKp 1.0"));
-    Serial.println(F(" "));
+    Serial.println(F("Incorrect syntax.  Example: SetKp 1.0"));
   }
   else {
     Serial.println(F(" "));
     Serial.print(F("Setting Kp to: "));
     Serial.println(sVal);
-    Serial.println(F(" "));
     xv_config.Kp = sVal;
     rpmPID.SetTunings(xv_config.Kp, xv_config.Ki, xv_config.Kd);
   }
@@ -852,14 +796,12 @@

   if (syntax_error) {
     Serial.println(F(" "));
-    Serial.print(F("Incorrect syntax.  Example: SetKi 0.5"));
-    Serial.println(F(" "));
+    Serial.println(F("Incorrect syntax.  Example: SetKi 0.5"));
   }
   else {
     Serial.println(F(" "));
     Serial.print(F("Setting Ki to: "));
     Serial.println(sVal);
-    Serial.println(F(" "));
     xv_config.Ki = sVal;
     rpmPID.SetTunings(xv_config.Kp, xv_config.Ki, xv_config.Kd);
   }
@@ -885,14 +827,12 @@

   if (syntax_error) {
     Serial.println(F(" "));
-    Serial.print(F("Incorrect syntax.  Example: SetKd 0.001"));
-    Serial.println(F(" "));
+    Serial.println(F("Incorrect syntax.  Example: SetKd 0.001"));
   }
   else {
     Serial.println(F(" "));
     Serial.print(F("Setting Kd to: "));
     Serial.println(sVal);
-    Serial.println(F(" "));
     xv_config.Kd = sVal;
     rpmPID.SetTunings(xv_config.Kp, xv_config.Ki, xv_config.Kd);
   }
@@ -918,14 +858,12 @@

   if (syntax_error) {
     Serial.println(F(" "));
-    Serial.print(F("Incorrect syntax.  Example: SetSampleTime 20"));
-    Serial.println(F(" "));
+    Serial.println(F("Incorrect syntax.  Example: SetSampleTime 20"));
   }
   else {
     Serial.println(F(" "));
     Serial.print(F("Setting Sample time to: "));
     Serial.println(sVal);
-    Serial.println(F(" "));
     xv_config.sample_time = sVal;
     rpmPID.SetSampleTime(xv_config.sample_time);
   }
@@ -946,30 +884,38 @@
   Serial.println(F(" "));

   Serial.println(F("List of available commands (case sensitive)"));
+  Serial.println(F("  HideRaw       - Stop outputting the raw data from the lidar"));
+  Serial.println(F("  ShowRaw       - Enable the output of the raw lidar data (default)"));
+  Serial.println(F("  ShowDist      - Show the distance data"));
+  Serial.println(F("  HideDist      - Hide the distance data"));
+  Serial.println(F("  ShowAngle     - Show distance data for a multiple angles (Ex: ShowAngle 0, 15-30, 45-50, 10)"));
+  Serial.println(F("  HideAngle     - Hide distance data for all angles"));
+  Serial.println(F("  ShowErrors    - Show all error messages"));
+  Serial.println(F("  HideErrors    - Hide error messages"));
   Serial.println(F("  ShowConfig    - Show the running configuration"));
   Serial.println(F("  SaveConfig    - Save the running configuration to EEPROM"));
   Serial.println(F("  ResetConfig   - Restore the original configuration"));
-  Serial.println(F("  SetRPM        - Set the desired rotation speed (min: 200, max: 300)"));
+  Serial.println(F("  SetRPM        - Set the desired rotation speed (min: 180, max: 349)"));
   Serial.println(F("  SetKp         - Set the proportional gain"));
   Serial.println(F("  SetKi         - Set the integral gain"));
   Serial.println(F("  SetKd         - Set the derivative gain"));
   Serial.println(F("  SetSampleTime - Set the frequency the PID is calculated (ms)"));
   Serial.println(F("  ShowRPM       - Show the rotation speed"));
   Serial.println(F("  HideRPM       - Hide the rotation speed"));
-  Serial.println(F("  ShowDist      - Show the distance data"));
-  Serial.println(F("  HideDist      - Hide the distance data"));
-  Serial.println(F("  ShowAngle     - Show distance data for a specific angle (0 - 359 or 360 for all)"));
-  Serial.println(F("  HideAngle     - Hide distance data for all angles"));
-  Serial.println(F("  ShowAngles    - Show distance data for a multiple angles (ShowAngles 0, 15-30, 45-50, 10)"));
-  Serial.println(F("  HideAngles    - Hide distance data for all angles"));
-  Serial.println(F("  ShowErrors    - Show all error messages"));
-  Serial.println(F("  HideErrors    - Hide error messages"));
+  Serial.println(F("  ShowInterval  - Show time interval per revolution in ms, at angle=0"));
+  Serial.println(F("  HideInterval  - Hide time interval"));
   Serial.println(F("  MotorOff      - Stop spinning the lidar"));
   Serial.println(F("  MotorOn       - Enable spinning of the lidar"));
-  Serial.println(F("  HideRaw       - Stop outputting the raw data from the lidar"));
-  Serial.println(F("  ShowRaw       - Enable the output of the raw lidar data"));
-
-  Serial.println(F(" "));
+  Serial.println(F(" "));
+  Serial.println(F("Output comma-separated format:"));
+  Serial.println(F("  A,<Angle>,<Distance in mm>,<Strength>"));
+  Serial.println(F("  C,-1 means CRC error was generated by LIDAR"));
+  Serial.println(F("  T,<Time interval in milliseconds>"));
+  Serial.println(F(" "));
+  Serial.println(F("Errors:"));
+  Serial.println(F("  -1 = CRC Error"));
+  Serial.println(F("  -2 = LIDAR reports Invalid data for this angle"));
+  Serial.println(F("  -3 = LIDAR reports Poor signal strength for this angle"));
   Serial.println(F(" "));
 }

@@ -1015,16 +961,15 @@
   Serial.println(xv_config.show_dist);
   Serial.print(F("Show RPM Data: "));
   Serial.println(xv_config.show_rpm);
-  Serial.print(F("Show Angle: "));
-  Serial.println(xv_config.show_angle);
-
-  Serial.println(F(" "));
-  Serial.println(F(" "));
-
+  //Serial.print(F("Show Angle: "));
+  //Serial.println(xv_config.show_angle);
+
+  Serial.println(F(" "));
+  Serial.println(F(" "));
 }

 void saveConfig() {
   EEPROM_writeAnything(0, xv_config);
-  Serial.print(F("Config Saved."));
-}
-
+  Serial.println(F("Config Saved."));
+}
+


Replaced repeated millis() with a variable.

--- arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot3_waffle/turtlebot3_core/turtlebot3_core.ino
+++ arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot3_waffle/turtlebot3_core/turtlebot3_core.ino
@@ -234,29 +234,29 @@
    */
   uint32_t t = millis();
   update_time();
-  if ((millis()-tTime[0]) >= (1000 / CONTROL_MOTOR_SPEED_PERIOD))
+  if ((t-tTime[0]) >= (1000 / CONTROL_MOTOR_SPEED_PERIOD))
   {
     controlMotorSpeed();
-    tTime[0] = millis();
-  }
-
-  if ((millis()-tTime[1]) >= (1000 / CMD_VEL_PUBLISH_PERIOD))
+    tTime[0] = t;
+  }
+
+  if ((t-tTime[1]) >= (1000 / CMD_VEL_PUBLISH_PERIOD))
   {
     cmd_vel_rc100_pub.publish(&cmd_vel_rc100_msg);
-    tTime[1] = millis();
-  }
-
-  if ((millis()-tTime[2]) >= (1000 / DRIVE_INFORMATION_PUBLISH_PERIOD))
+    tTime[1] = t;
+  }
+
+  if ((t-tTime[2]) >= (1000 / DRIVE_INFORMATION_PUBLISH_PERIOD))
   {
     publishSensorStateMsg();
     publishDriveInformation();
-    tTime[2] = millis();
-  }
-
-  if ((millis()-tTime[3]) >= (1000 / IMU_PUBLISH_PERIOD))
+    tTime[2] = t;
+  }
+
+  if ((t-tTime[3]) >= (1000 / IMU_PUBLISH_PERIOD))
   {
     publishImuMsg();
-    tTime[3] = millis();
+    tTime[3] = t;
   }

   // Check push button pressed for simple test drive


corrects use of softAPIP() in esp32 example

--- examples/ESP32-DMX_rdm/ESP32-DMX_rdm.ino
+++ examples/ESP32-DMX_rdm/ESP32-DMX_rdm.ino
@@ -96,6 +96,11 @@
 WiFiUDP aUDP;
 WiFiUDP sUDP;

+// the following appear to be ESP32's default AP address/subnet mask
+// required to specify as WiFi.localIP() returns 0.0.0.0 when in AP mode and must use softAPIP() instead
+IPAddress local_ip_address = IPAddress(192,168,4,1);
+IPAddress local_subnet_mask = IPAddress(255,255,255,0);
+
 // direction output from network/input to network
 uint8_t dmx_direction = 0;

@@ -399,10 +404,6 @@

   dmx_direction = DMXWiFiConfig.inputToNetworkMode();
   rdm_enabled   = DMXWiFiConfig.rdmMode();
-  // the following appear to be ESP32's default AP address/subnet mask
-  // required to specify as WiFi.localIP() seems to return 0.0.0.0 when in AP mode
-  IPAddress local_ip_address = IPAddress(192,168,4,1);
-  IPAddress local_subnet_mask = IPAddress(255,255,255,0);

   if ( DMXWiFiConfig.APMode() ) {            // WiFi startup
     Serial.print("AP_MODE ");
@@ -413,12 +414,13 @@

     if ( digitalRead(STARTUP_MODE_PIN) != 0 ) {
       WiFi.softAPConfig(DMXWiFiConfig.apIPAddress(), DMXWiFiConfig.apGateway(), DMXWiFiConfig.apSubnet());
-      local_ip_address = DMXWiFiConfig.apIPAddress();
       local_subnet_mask = DMXWiFiConfig.apSubnet();
     } else {
       Serial.print(" default AP settings ");
       Serial.println(DMXWiFiConfig.nodeName());
-    }
+    };
+
+    local_ip_address = WiFi.softAPIP();

     Serial.print(" accessPoint SSID ");
     Serial.print(DMXWiFiConfig.SSID());
@@ -631,7 +633,7 @@
     xSemaphoreGive( ESP32DMX.lxDataLock );

     if ( multicast ) {
-      interface->sendDMX(iUDP, DMXWiFiConfig.inputAddress(), WiFi.localIP());
+      interface->sendDMX(iUDP, DMXWiFiConfig.inputAddress(), local_ip_address);
     } else {
       interface->sendDMX(iUDP, DMXWiFiConfig.inputAddress(), INADDR_NONE);
     }


Whitespace tidy

Whitespace tidy

--- examples/TeensyDMXSend/TeensyDMXSend.ino
+++ examples/TeensyDMXSend/TeensyDMXSend.ino
@@ -23,6 +23,6 @@
 }

 void loop() {
-  Dmx.setChannels(0,DMXVal,1);
+  Dmx.setChannels(0, DMXVal, 1);
   Dmx.loop();
 }


Restored knight_rider2 example

Restored knight_rider2 example

--- examples/knight_rider2/knight_rider2.ino
+++ examples/knight_rider2/knight_rider2.ino
@@ -2,7 +2,7 @@
 #include "Atm_sweep.h"

 Atm_sweep sweep;
-Atm_analog pot;
+Atm_button button;
 Appliance app;

 void setup() {
@@ -14,15 +14,12 @@
   );

   app.component(
-    pot.begin( A0 )
-      .range( 10, 200 )
-      .onChange( []( int idx, int v, int up ) {
-        sweep.speed( v );
-      })
+    button.begin( 2 )
+      .onPress( sweep, sweep.EVT_TOGGLE )
   );

 }

 void loop() {
   app.run();
-}
+}


Delete Nil_L9110S_Demo.ino

Delete Nil_L9110S_Demo.ino

--- Nil_L9110S_Demo.ino
+++ Nil_L9110S_Demo.ino
@@ -1,46 +0,0 @@
-// file     Nil_L9110S_Demo.ino v0.1
-// by nil (nil.baltimore@gmail.com)
-// provide some useful function make it easy to control car with DC motors use L9110s
-// Copyright (c) 2017 Nil Baltimore
-// MIT License
-
-#include <Nil_L9110S.h>
-
-// pin = leftSpeed (PWM), leftDir, rightSpeed (PWM), rightDir
-Nil_L9110S motor (11,12,10,8);
-
-
-void setup () {
-	Serial.begin(9600);
-	delay (5000);
-	Serial.println("start");
-
-}
-
-void loop () {
-	Serial.println("TURN RIGHT 150,150");
-	motor.changeDir(Direction::FORWARD, Direction::REVERSE);
-	motor.control(150,150);
-	delay (8000);
-	motor.brake();
-	delay (3000);
-	Serial.println("TURN LEFT 150,150");
-	motor.changeDir(Direction::REVERSE, Direction::FORWARD);
-	motor.control(150,150);
-	delay (8000);
-	motor.brake();
-	delay (3000);
-	Serial.println("GO 200,200");
-	motor.changeDir(Direction::FORWARD, Direction::FORWARD);
-	motor.control(200,200);
-	delay (8000);
-	motor.brake();
-	delay (3000);
-	Serial.println("REVERSE 150,150");
-	motor.changeDir(Direction::REVERSE, Direction::REVERSE);
-	motor.control(150,150);
-	delay (8000);
-	motor.brake();
-	delay (3000);
-}
-


Cleanup code a bit

Cleanup code a bit

--- home_02_garage/home_02_garage.ino
+++ home_02_garage/home_02_garage.ino
@@ -17,21 +17,27 @@
 ISR(WDT_vect) { Sleepy::watchdogEvent(); }

-//#define DEBUG          // Comment out to disable
-#define JEELINK_ID 1   // Jeelink is id 1 (or 0 to broadcast)
-#define NETGROUP 100   // Netgroup everyone is on
-#define NODE_ID 2      // id of THIS node
+// user settings
+//#define DEBUG        // Comment out to disable
+const int JEELINK_ID = 1;   // Jeelink is id 1 (or 0 to broadcast)
+const int NETGROUP = 100;   // Netgroup everyone is on
+const int NODE_ID = 2;      // id of THIS node

-#define DOOR_OPEN 1    // 1 means open
-#define DOOR_CLOSED 0  // 0 means closed
-#define DIO_OFFSET 3   // DIO is port num + 3

-//Basic macro for debugging
+// sketch constants
+const int DOOR_OPEN = HIGH;    // Door open when signal is HIGH
+const int DOOR_CLOSED = LOW;   // Door closed when LOW
+const int DIO_OFFSET = 3;      // DIO is port num + 3
+
+
+// Basic macro for debugging
+// Ideally change this to a function once I figure out how to accept anything
 #ifdef DEBUG
   #define DEBUG_PRINT(x) Serial.println(x)
 #else
   #define DEBUG_PRINT(x)
 #endif
+

 // TEMP421 code thanks to http://ka1kjz.com (my bookmark no longer points to the source
 // posting though, should still be on there somewhere
@@ -40,35 +46,44 @@
 // G - pin1
 // + - pin2
 // A - pin4
-PortI2C temp_port1 (1 /*, PortI2C::KHZ400 */); // Not sure what the commented out part is for
-DeviceI2C temperature1 (temp_port1, 0x2A);  // I2C Address of 0x2A
+
+// Secong parameter that's commented out is the rate of communication
+// Can be KHZMAX (default), KHZ400, or KHZ100
+PortI2C temp_port1 (1 /*, PortI2C::KHZ400 */);
+DeviceI2C temp_dev1 (temp_port1, 0x2A);  // I2C Address of 0x2A
+

 // Currently just have sensor connected to port 4
 //int DIO1 = 1 + DIO_OFFSET;
 //int DIO2 = 2 + DIO_OFFSET;
 //int DIO3 = 3 + DIO_OFFSET;
-int DIO4 = 4 + DIO_OFFSET;
+const int DIO4 = 4 + DIO_OFFSET;

-int temp_lo = 0;
-int temp_high = 0;
-float tempc = 0;

-void get_temperature() {
-  temperature1.send();
-  temperature1.write(0x00); // high byte is on register 0
-  temperature1.receive();
-  temp_high = temperature1.read(1);
-  temperature1.stop();
+// Returns the temperature of tempdev where tempdev is a DeviceI2C object
+int get_temperature(DeviceI2C tempdev) {
+  int temp_lo = 0;
+  int temp_high = 0;
+  float tempc = 0;
+
+  tempdev.send();
+  tempdev.write(0x00); // high byte is on register 0
+  tempdev.receive();
+  temp_high = tempdev.read(1);
+  tempdev.stop();

-  temperature1.send();
-  temperature1.write(0x10); // low byte on register 0x10
-  temperature1.receive();
-  temp_lo = temperature1.read(1);
-  temperature1.stop();
+  tempdev.send();
+  tempdev.write(0x10); // low byte on register 0x10
+  tempdev.receive();
+  temp_lo = tempdev.read(1);
+  tempdev.stop();

   tempc = (float)temp_lo / 256;
   tempc = tempc + temp_high;
+
+  return tempc;
 }
+

 void setup() {
 #ifdef DEBUG
@@ -76,13 +91,14 @@
 #endif
   DEBUG_PRINT("Initializing");

-  rf12_initialize(2, RF12_915MHZ, 100);
+  rf12_initialize(NODE_ID, RF12_915MHZ, NETGROUP);

-  pinMode(DIO4, INPUT);
-  digitalWrite(DIO4, HIGH);  // turn on pull up
+  pinMode(DIO4, INPUT_PULLUP);
 }

+
 void loop() {
+  float tempc = 0;
   int door_status_4 = digitalRead(DIO4);
   word payload[4] = {0,0,0,0};

@@ -98,10 +114,8 @@
   }
 #endif

-  get_temperature();
-
+  tempc = get_temperature(temp_dev1);
   DEBUG_PRINT(tempc);
-
   payload[0] = int(tempc * 100);

   rf12_sleep(RF12_WAKEUP);
@@ -111,5 +125,3 @@

   Sleepy::loseSomeTime(60000);
 }
-
-


Sending colors in hex to LEDOS controller

--- VeronicaLedLamp.ino
+++ VeronicaLedLamp.ino
@@ -163,6 +163,11 @@
         for(int i = 0; i < server.args(); ++i) {
             if ( server.argName(i) == "a" ) { // Current color
                 EEPROM.write( 25, server.arg(i).toInt() % 255 );
+                char preset[3], color[6];
+                EEPROM.get(1 + server.arg(i).toInt() % 8 * 3, preset);
+                snprintf(color, 6, "%02x%02x%02x", preset[0], preset[1], preset[2]);
+                Serial.print('b');
+                Serial.println(color);
             } else if ( server.argName(i) == "m") { // Current mode
                 int wmode = server.arg(i).toInt() % 255;
                 if ( wmode == 7 ) { // Speed Toggle
@@ -213,6 +218,8 @@
                       // Convert hex color to byte array
                       temp = server.arg(i);
                       temp.remove(6);
+                      Serial.print('b');
+                      Serial.println(temp);
                       const char *src = temp.c_str();
                       byte color[3];
                       for(int k = 0; k < 3; ++k) {


Firmware updated for new version of tarakan.

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -17,7 +17,14 @@
 #define PIN_MOTOR_LEFT 5
 #define PIN_MOTOR_RIGHT 3

-const int motor_speed_max = 240;
+/*1*/ const int SERV_R_STOP = 89, SERV_L_STOP = 89, SERV_R_FORW = 180, SERV_L_FORW = 180, SERV_R_BACK = 0, SERV_L_BACK = 0;
+///*2*/ const int SERV_R_STOP = 89, SERV_L_STOP = 89, SERV_R_FORW = 180, SERV_L_FORW = 180, SERV_R_BACK = 0, SERV_L_BACK = 0;
+///*3*/ const int SERV_R_STOP = 89, SERV_L_STOP = 89, SERV_R_FORW = 180, SERV_L_FORW = 180, SERV_R_BACK = 0, SERV_L_BACK = 0;
+///*4*/ const int SERV_R_STOP = 89, SERV_L_STOP = 89, SERV_R_FORW = 180, SERV_L_FORW = 180, SERV_R_BACK = 0, SERV_L_BACK = 0;
+///*5*/ const int SERV_R_STOP = 89, SERV_L_STOP = 89, SERV_R_FORW = 180, SERV_L_FORW = 180, SERV_R_BACK = 0, SERV_L_BACK = 0;
+///*6*/ const int SERV_R_STOP = 89, SERV_L_STOP = 89, SERV_R_FORW = 180, SERV_L_FORW = 180, SERV_R_BACK = 0, SERV_L_BACK = 0;
+///*7*/ const int SERV_R_STOP = 89, SERV_L_STOP = 89, SERV_R_FORW = 180, SERV_L_FORW = 180, SERV_R_BACK = 0, SERV_L_BACK = 0;
+
 String input_buffer = "";

 unsigned long moving_time = 0;
@@ -28,17 +35,24 @@
 bool is_rotation = false;
 bool is_forward = false;

-int interval_gabarit = 0;
-int interval_direction = 0;
-int intensity_gabarit = 0;
-int intensity_direction = 0;
+const int light_pins[2][4] = {
+  {LED_PIN_GABARIT_1, LED_PIN_GABARIT_2, LED_PIN_GABARIT_3, LED_PIN_GABARIT_4},
+  {LED_PIN_FORWARD_1, LED_PIN_FORWARD_2, LED_PIN_BACKWARD_1, LED_PIN_BACKWARD_2}
+};
+int light_intervals[2][4] = {
+  {0, 0, 0, 0}, //gabarit
+  {0, 0, 0, 0}  //direction
+};
+int light_states[2][4] = {
+  {LOW, LOW, LOW, LOW},
+  {LOW, LOW, LOW, LOW}
+};
+int light_previous_time[2][4] = {
+  {0, 0, 0, 0},
+  {0, 0, 0, 0}
+};

 unsigned long current_millis;
-unsigned long previous_millis_gabarit = 0;
-unsigned long previous_millis_direction = 0;
-int led_state_gabarit = LOW;
-int led_state_direction = LOW;
-
 bool is_hand_control = false;

 Servo servo_left;
@@ -62,8 +76,6 @@
   pinMode(LED_PIN_GABARIT_3, OUTPUT);
   pinMode(LED_PIN_GABARIT_4, OUTPUT);

-//////////////////////////////////////////
-
   digitalWrite(TRIG_BEGIN, LOW);
   digitalWrite(ECHO_BEGIN, LOW);
   digitalWrite(TRIG_END, LOW);
@@ -80,10 +92,10 @@
   digitalWrite(LED_PIN_GABARIT_4, LOW);

   servo_left.attach(PIN_MOTOR_LEFT);
-  servo_left.write(89);
+  servo_left.write(SERV_L_STOP);

   servo_right.attach(PIN_MOTOR_RIGHT);
-  servo_right.write(90);
+  servo_right.write(SERV_R_STOP);
 }

 void loop() {
@@ -113,32 +125,35 @@
             break;
           case '5': //changeLightMode
             {
-              int intensity;
+              int led_state;
               int period;
-              if (input_buffer[2] == '1') {
-                intensity = 255;
+              if (input_buffer[3] == '1') {
+                led_state = HIGH;
                 period = input_buffer.substring(3, last_char).toInt();
               } else {
-                intensity = 0;
+                led_state = LOW;
                 period = 0;
               }
+
+              int group_index;
+              if (input_buffer[1] == '1') {
+                group_index = 1;
+              } else {
+                group_index = 0;
+              }

-              if (input_buffer[1] == '1') {
-                interval_direction = period;
-                intensity_direction = intensity;
-
-                if (!period) {
-                  setStateLedDirection(intensity);
+              int led_index = input_buffer[1] - 48;
+              if ((led_index >= 0) && (led_index <= 4)) {
+                if (led_index) {
+                  led_index--;
+                  changeOneLedState(group_index, led_index, led_state, period);
+                } else {
+                  changeGroupLedState(group_index, led_state, period);
                 }
+                sendShortAnswer(true);
               } else {
-                interval_gabarit = period;
-                intensity_gabarit = intensity;
-
-                if (!period) {
-                  setStateLedGabarit(intensity);
-                }
+                sendShortAnswer(false);
               }
-              sendShortAnswer(true);
             }
             break;
           case '6': //getDistanceObstacle
@@ -150,11 +165,8 @@
             {
               is_hand_control = true;

-              interval_direction = 0;
-              interval_gabarit = 0;
-              setStateLedGabarit(0);
-              setStateLedDirection(0);
-
+              changeGroupLedState(0, HIGH, 0);
+              changeGroupLedState(1, LOW, 0);
               sendShortAnswer(true);
             }
             break;
@@ -163,10 +175,8 @@
               is_hand_control = false;
               robotStop();

-              interval_direction = 0;
-              interval_gabarit = 0;
-              setStateLedGabarit(0);
-              setStateLedDirection(0);
+              changeGroupLedState(0, LOW, 0);
+              changeGroupLedState(1, LOW, 0);

               sendShortAnswer(true);
             }
@@ -177,11 +187,9 @@
                 case '1':
                   {
                     if (input_buffer[2] == '0') {
-                      setStateLedGabarit(255);
-                      setStateLedDirection(255);
+                      changeGroupLedState(0, HIGH, 0);
                     } else {
-                      setStateLedGabarit(0);
-                      setStateLedDirection(0);
+                      changeGroupLedState(0, LOW, 0);
                       robotStop();
                     }
                   }
@@ -230,45 +238,36 @@
     }
   }

-  if (interval_gabarit) {
-    current_millis = millis();
-    if (current_millis - previous_millis_gabarit > interval_gabarit) {
-      previous_millis_gabarit = current_millis;
-      if (led_state_gabarit) {
-        led_state_gabarit = 0;
-      } else {
-        led_state_gabarit = intensity_gabarit;
+  for (int i = 0; i < 2; i++) {
+    for (int j = 0; i < 4; i++) {
+      if (!light_intervals[i][j]) {
+        current_millis = millis();
+        if (current_millis - light_previous_time[i][j] > light_intervals[i][j]) {
+          light_previous_time[i][j] = current_millis;
+          if (light_states[i][j]) {
+            light_states[i][j] = LOW;
+          } else {
+            light_states[i][j] = HIGH;
+          }
+          digitalWrite(light_pins[i][j], light_states[i][j]);
+        }
       }
-      setStateLedGabarit(led_state_gabarit);
-    }
-  }
-
-  if (interval_direction){
-    current_millis = millis();
-    if(current_millis - previous_millis_direction > interval_direction) {
-      previous_millis_direction = current_millis;
-      if (led_state_direction) {
-        led_state_direction = 0;
-      } else {
-        led_state_direction = intensity_direction;
-      }
-      setStateLedDirection(led_state_direction);
     }
   }
 }

-void setStateLedDirection(int value) {
-  analogWrite(LED_PIN_FORWARD_1, value);
-  analogWrite(LED_PIN_FORWARD_2, value);
-  analogWrite(LED_PIN_BACKWARD_1, value);
-  analogWrite(LED_PIN_BACKWARD_2, value);
-}
-
-void setStateLedGabarit(int value) {
-  analogWrite(LED_PIN_GABARIT_1, value);
-  analogWrite(LED_PIN_GABARIT_2, value);
-  analogWrite(LED_PIN_GABARIT_3, value);
-  analogWrite(LED_PIN_GABARIT_4, value);
+void changeOneLedState(int group, int index, int state, int period) {
+  if (!period) {
+    digitalWrite(index, state);
+    light_states[group][index] = state;
+  }
+  light_intervals[group][index] = period;
+}
+
+void changeGroupLedState(int group, int state, int period) {
+  for (int i = 0; i < 4; i++) {
+    changeOneLedState(group, i, state, period);
+  }
 }

 void robotMove(bool forward){
@@ -300,22 +299,22 @@
   previous_millis_moving = millis();
 }
 void robotStop(){
-  servo_left.write(89);
-  servo_right.write(90);
+  servo_left.write(SERV_L_STOP);
+  servo_right.write(SERV_R_STOP);
   is_moving = false;
   delay(500);
 }
 void motorForwardLeft(){
-  servo_left.write(180);
+  servo_left.write(SERV_L_FORW);
 }
 void motorForwardRight(){
-  servo_right.write(180);
+  servo_right.write(SERV_R_FORW);
 }
 void motorBackwardLeft(){
-  servo_left.write(0);
+  servo_left.write(SERV_L_BACK);
 }
 void motorBackwardRight(){
-  servo_right.write(0);
+  servo_right.write(SERV_R_BACK);
 }
 int distanceIK(boolean check_forward){
   unsigned int delay_time = millis() - last_time_obstacle_check;


v0.39

v0.39

Replaced by EEPROM_operations.ino

--- EEPROM_management.ino
+++ EEPROM_management.ino
@@ -1,151 +0,0 @@
-//*********************************************************************
-// EEPROM management fuctions
-//
-// Parameter data structure
-// Address	Data				Length
-//  0		FLBThresholdPWM		byte
-//	1		debounceCount		byte
-//	2		pumpMinPWM			byte
-//	3		pumpMaxPWM			byte
-//	4		mlPerFlowMeterPulse
-//	8		unionThreshold
-//	12		Kpp					double (4 bytes)
-//	16		Kpi					double (4 bytes)
-//	20		Kpd					double (4 bytes)
-//	24		Kfp					double (4 bytes)
-//	28		Kfi					double (4 bytes)
-//	32		Kfd					double (4 bytes)
-//	36		layerPIFlowRate		byte
-//	37		slayerMainPWM		byte
-//	38		slayerPIPeriod		byte
-//
-// 	Profile data structure
-//	97		Size of PWMprofile	byte
-//	98		Size of Pressure p.	byte
-//	99		Size of Flow prof.	byte
-//	100-301	PWM Profile			bytes (2 per second)
-//	302-503	Pressure Profile	bytes (2 per second)
-//	504-705	Flow Profile		bytes (2 per second)
-//
-//  Assaf
-//  39      slayerMaxPWM		byte
-//
-//
-//*********************************************************************
-
-// Store PWM, pressure and flow Profiles in EEPROM
-void storeProfilesinEEPROM()
-{
-  EEPROM.update(97, (byte)sizeof(g_PWMProfile)); // Always 201
-  EEPROM.update(98, (byte)sizeof(g_pressureProfile)); //Always 201
-  EEPROM.update(99, (byte)sizeof(g_flowProfile)); // Always 201
-
-  int shiftAddr = 100; // Start writing arrays  at 10th byte
-  int shiftPP = shiftAddr + sizeof(g_PWMProfile);
-  int shiftFP = shiftPP + sizeof(g_pressureProfile);
-
-  // Write PWM Profile
-  for (int addr = 0; addr < sizeof(g_PWMProfile); addr++)
-  {
-    EEPROM.update(addr + shiftAddr, g_PWMProfile[addr]);
-    EEPROM.update(addr + shiftPP, g_pressureProfile[addr]);
-    EEPROM.update(addr + shiftFP, g_flowProfile[addr]);
-  }
-}
-
-// Retrieve PWM, pressure and flow Profiles from EEPROM
-void readProfilesfromEEPROM()
-{
-  int PWMProfileSize = EEPROM.read(97);
-  int pressureProfileSize = EEPROM.read(98);
-  int flowProfileSize = EEPROM.read(99);
-
-  int shiftAddr = 100; // Start reading arrays at 10th byte (should match similar decleration at storeProfilesinEEPROM()
-  int shiftPP = shiftAddr + PWMProfileSize;
-  int shiftFP = shiftPP + pressureProfileSize;
-
-  for (int addr = 0; addr < PWMProfileSize; addr++)
-  {
-    g_PWMProfile[addr] = EEPROM.read(addr + shiftAddr);
-    g_pressureProfile[addr] = EEPROM.read(addr + shiftPP);
-    g_flowProfile[addr] = EEPROM.read(addr + shiftFP);
-  }
-}
-
-// Retrieve software parameters from EEPROM
-void readSWParametersfromEEPROM()
-{
-  Serial.println("Retrieving EEPROM Paramaters");
-  FLBThresholdPWM = (unsigned) EEPROM.read(0) * 4;
-  Serial.print("FLBThresholdPWM = ");
-  Serial.print(EEPROM.read(0));
-  Serial.print(" ");
-  Serial.println(FLBThresholdPWM);
-  debounceCount = EEPROM.read(1);
-  pumpMinPWM = (unsigned)((long)EEPROM.read(2) * 400 / 255);
-  Serial.print("pumpMinPWM = ");
-  Serial.print(EEPROM.read(2));
-  Serial.print(" ");
-  Serial.println(pumpMinPWM);
-  pumpMaxPWM = (unsigned)((long)EEPROM.read(3) * 400 / 255);
-  Serial.print("pumpMaxPWM = ");
-  Serial.print(EEPROM.read(3));
-  Serial.print(" ");
-  Serial.println(pumpMaxPWM);
-  EEPROM.get(4, mlPerFlowMeterPulse);
-  Serial.print("mlPerFlowMeterPulse = ");
-  Serial.println(mlPerFlowMeterPulse);
-  EEPROM.get(8, unionThreshold);
-  EEPROM.get(12, Kpp);
-  EEPROM.get(16, Kpi);
-  EEPROM.get(20, Kpd);
-  EEPROM.get(24, Kfp);
-  EEPROM.get(28, Kfi);
-  EEPROM.get(32, Kfd);
-}
-
-// Update software parameters in EEPROM
-void writeSWParameterstoEEPROM()
-{
-  EEPROM.update(0, (byte)(FLBThresholdPWM / 4));
-  Serial.print("FLBThresholdPWM = ");
-  Serial.print(FLBThresholdPWM);
-  Serial.print(" Stored as: ");
-  Serial.println(EEPROM.read(0));
-  EEPROM.update(1, debounceCount);
-  EEPROM.update(2, (byte)((long)pumpMinPWM * 255 / 400));
-  Serial.print("pumpMinPWM = ");
-  Serial.print(pumpMinPWM);
-  Serial.print(" Stored as: ");
-  Serial.println(EEPROM.read(2));
-  EEPROM.update(3, (byte)((long)pumpMaxPWM * 255 / 400));
-  Serial.print("pumpMaxPWM = ");
-  Serial.println(pumpMaxPWM);
-  Serial.print(" Stored as: ");
-  Serial.print(EEPROM.read(3));
-  EEPROM.put(4, (float)mlPerFlowMeterPulse);
-  EEPROM.put(8, (float)unionThreshold);
-  EEPROM.put(12, Kpp);
-  EEPROM.put(16, Kpi);
-  EEPROM.put(20, Kpd);
-  EEPROM.put(24, Kfp);
-  EEPROM.put(28, Kfi);
-  EEPROM.put(32, Kfd);
-}
-
-// Update Slayer parameters to EEPROM
-
-void readSlayerParametersfromEEPROM()
-{
-  slayerPIFlowRate = EEPROM.read(36);
-  slayerMainPWM = (unsigned) EEPROM.read(37) * 400 / 255;
-  slayerPIPeriod = EEPROM.read(38);
-}
-
-void writeSlayerParameterstoEEPROM()
-{
-  EEPROM.update(36, slayerPIFlowRate);
-  EEPROM.update(37, (byte) slayerMainPWM * 255 / 400);
-  EEPROM.update(38, slayerPIPeriod);
-  EEPROM.update(39, (byte)slayerMaxPWM * 255 / 400);
-}


fixed joystick pins

fixed joystick pins

no biggie

--- MotorsTX/MotorsTX.ino
+++ MotorsTX/MotorsTX.ino
@@ -10,13 +10,13 @@
 int data [16];    // to send bytes
 int start [2];

-int Pin1A = A0;
+int Pin1A = A2;
 int Joystick1A;   // crab

 int Pin1B = A1;
 int Joystick1B;   // up down numbers are backwards

-int Pin1C = A2;
+int Pin1C = A0;
 int Joystick1C;   // pitch

 int Pin2A = A3;


removed #define to save space

removed #define to save space

Not needed for new RTC library

--- NTPclock/NTPclock.ino
+++ NTPclock/NTPclock.ino
@@ -10,7 +10,6 @@
 // License - Mozilla Public License 2.0 (Do what you want, credit the author, must release under same license)
 //----------------------------------------------------------------------------------------------------------------

-#include <pgmspace.h>     // Used by RTC Library.  Specific for ESP8266
 #include <DS3232RTC.h>    // RTC Library
 #include <Wire.h>         // Incuded here so that Arduino library object file references work
 #include <LedControl.h>   // MAX7219 display control library


Arduino up and running :clap:  :joy:

Arduino up and running :clap:  :joy:

--- arduino/medox/medox.ino
+++ arduino/medox/medox.ino
@@ -29,7 +29,7 @@
 #define    trayLimit    A4
 #define    upLimit      A5

-#define    releaseBillDelay 1000 //to wait untill bill released
+#define    releaseBillDelay 3000 //to wait untill bill released
 #define    getBillDelay     1000 //to wait until bill catched for sure
 #define    upStepperDelay   3    //to wait before up/down steps
 #define    roStepperDelay   10   //to wait before rotation steps
@@ -43,10 +43,10 @@
 #include <Servo.h>
 Servo drawerServo;// create servo object to control a servo
 Servo warehouseServo;// create servo object to control a servo
-#define drawerServoOpen     10
-#define drawerServoClose    100
-#define WarehouseServoOpen  10
-#define WarehouseServoClose 100
+#define drawerServoOpen     100
+#define drawerServoClose    10
+#define WarehouseServoOpen  100
+#define WarehouseServoClose 10

 //variables definition
 char  serialData;             //for storing serial string
@@ -64,12 +64,8 @@
                 {0,0,0,1},
                 {1,0,0,1} };

-
 void setup() {
   //Setting input/output Pins
-  //servos
-  drawerServo.attach(drawer);        // attaches the doorServo on pin Arduino pin
-  warehouseServo.attach(warehouse);  // attaches the warehouseServo on pin Arduino pin
   //outputs
   pinMode(  upPin1,     OUTPUT);
   pinMode(  upPin2,     OUTPUT);
@@ -80,6 +76,10 @@
   pinMode(  roPin3,     OUTPUT);
   pinMode(  roPin4,     OUTPUT);
   pinMode(  pump,       OUTPUT);
+
+  pinMode(  drawer,     OUTPUT);
+  pinMode(  warehouse,  OUTPUT);
+
   //inputs
   pinMode(  infrared,    INPUT);
   pinMode(  doorSwitch,  INPUT);
@@ -89,12 +89,16 @@
   //initialize Serial Communication to communicate with RPI, with Baud rate=9600
   Serial.begin(9600);

+  //servos
+  drawerServo.attach(drawer);        // attaches the doorServo on pin Arduino pin
+  warehouseServo.attach(warehouse);  // attaches the warehouseServo on pin Arduino pin
+
   //define drawer limit switch pin as interrupt pin to secure drawer automatically
   attachInterrupt(digitalPinToInterrupt(doorSwitch), closeDoor, RISING);

   pinMode(  trayLimit,  INPUT);
   pinMode(  upLimit,    INPUT);
-  initialization();
+  //initialization();
 }

 //Check serial buffer for any strings from RPI and call Corresponding Function
@@ -111,6 +115,26 @@
       sendSensorData();
     else if(serialData == 'c')
       closeWarehouse();
+
+    //for debugging
+    else if(serialData == 'f')
+      closeDoor();
+    else if(serialData == 'o')
+      moveToWarehouse(0);
+    else if(serialData == 't')
+      moveToWarehouse(1);
+    else if(serialData == 'y')
+      moveToWarehouse(2);
+      else if(serialData == 'u')
+      moveToWarehouse(3);
+      else if(serialData == 'i')
+      moveToWarehouse(4);
+    else if(serialData == 'q')
+      moveOneStep();
+    else if(serialData == 'r')
+      getBill();
+    else if(serialData == 'm')
+      stopMotors();
   }
 }

@@ -154,11 +178,12 @@

 void sendSensorData(){
   tempFloat = analogRead(temperature);
-  tempFloat = tempFloat * (5 / 1024); //converting binary number to voltage (0-1024)->(0-5)
+  tempFloat = (tempFloat * 5) /1024; //converting binary number to voltage (0-1024)->(0-5)
+  tempFloat = (tempFloat)*100; //converting voltage to temperature
   Serial.print(tempFloat);
   Serial.print("\r\n");
   tempFloat = analogRead(lightLevel);
-  tempFloat = tempFloat * (5 / 1024); //converting binary number to voltage (0-1024)->(0-5)
+  tempFloat = ( (tempFloat * 5) / 1024); //converting binary number to voltage (0-1024)->(0-5)
   Serial.print(tempFloat);
   Serial.print("\r\n");
 }
@@ -190,7 +215,7 @@
 void hardwareDispense(){
   int bills[4];
   int total = 0;
-  for (int i = 0; i<=4; i++){
+  for (int i = 0; i<4; i++){
     while(Serial.available() <= 0){ //wait until RPI sends voltage on serial buffer
     }
     serialData = Serial.read(); //get the desired count from serial
@@ -220,9 +245,11 @@
 //dispense one bill from given warehouse number
 void dispenseOneBill(int warehouseNumber){
   moveToWarehouse(warehouseNumber); //move to drug warehouse
+  //stopMotors(); //to solve power issue but now not needed
   getBill(); //get one bill using pump
   moveToWarehouse(0); //return to empty warehouse
   releaseBill(); //release bill to the door
+  //stopMotors(); //to solve power issue but now not needed
 }

 //move to given warehouse number
@@ -245,6 +272,7 @@
   digitalWrite(pump, HIGH); //activates the pump
   while(/*getCurrent() < currentThreeshold &&*/ steps < maxUpSteps){ //go down until gets one bill
     stepDown(); //move one step down
+    steps++;
   }
   delay(getBillDelay); //to wait until bill catched for sure
   for(int i = 0; i<steps; i++){ //retun to initial position
@@ -260,8 +288,9 @@

 //moves 72 degree to select next warehouse
 void moveOneStep(){
+
   for(int i = 0; i < step72; i++){
-    for(int j = 0; j <= 7; j++){
+    for(int j = 7; j >= 0; j--){
       digitalWrite(roPin1, seq[j][0]);
       digitalWrite(roPin2, seq[j][1]);
       digitalWrite(roPin3, seq[j][2]);


Delete _01_kidSerie_sketch_01.HelloBT.ino

--- _01_kidSerie_sketch_01.HelloBT.ino
+++ _01_kidSerie_sketch_01.HelloBT.ino
@@ -1,69 +0,0 @@
-/*
-  Project name:
-     01 #kidSerie - Arduino & MIT App Instaler 2 & HC-06
-     (Smart Phone App!)
-     Flavour I -
-     Hex File: _01_kidSerie_sketch_01.HelloBT.ino
-   Revision History:
-     20161008:
-       - board found on Arduino e Cia Examples
-      (connect everything on HC-06 to access smart phone)
-
-   Description:
-        A Simple bluetooth app communicating smart phone & arduino & MIT App Inventor 2!!!
-
-   MCU:                  Arduino 1.6.12 - @16MHz       http://www.arduino.cc/
-   IC Chip:              Bluetooth Datasheet - HC-06   https://goo.gl/s9ZcNC
-
-   Connections:
-      See Official youtube channel vids: https://youtu.be/u1xqW6qtFXs
-
-
-   Based on:   Módulo Bluetooth JY-MCU - HC-06 - Configuração (Arduino e Cia)
-   https://goo.gl/W13Qnn
-   Code by Arduino e Cia
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License v3 as published by
-   the Free Software Foundation
-*/
-#include <SoftwareSerial.h>
-
-
-SoftwareSerial mySerial(10, 11);        // RX, TX
-String command = "";                    // Stores response of bluetooth device
-                                        // which simply allows \n between each
-                                        // response.
-
-void setup()
-{
-                                        // Open serial communications and wait for port to open:
-  Serial.begin(9600);                   // Default firmware
-  //Serial.begin(115200);               // I changed to this baudrate...
-  Serial.println("Type AT commands!");
-                                        // SoftwareSerial "com port" data rate. JY-MCU v1.03 defaults to 9600.
-  mySerial.begin(9600);
-  //mySerial.begin(115200);             // ...and do not forget to match baudrate
-}
-
-void loop()
-{
-                                        // Read device output if available.
-  if (mySerial.available())
-  {
-     while(mySerial.available())
-     {                                  // While there is more to be read, keep reading.
-       command += (char)mySerial.read();
-     }
-   Serial.println(command);
-   command = "";                        // No repeats
-  }
-
-                                        // Read user input if available.
-  if (Serial.available())
-  {
-    delay(10);                          // The DELAY!
-    mySerial.write(Serial.read());
-  }
-
-}                                       // END loop()


increasing wakeup interrupt duration

increasing wakeup interrupt duration

--- motion-tracker/main.ino
+++ motion-tracker/main.ino
@@ -17,7 +17,7 @@

 #define MY_NAME "AssetTracker"

-#define CLICKTHRESHHOLD 20
+#define CLICKTHRESHHOLD 100

 int lastSecond = 0;
@@ -222,4 +222,4 @@
         + "}";

     Particle.publish(MY_NAME + String("_location"), gps_line, 60, PRIVATE);
-}+}


Move more to program storage to increase stack space in SRAM

--- projects/arduino/led_matrix_256/led_matrix_256.ino
+++ projects/arduino/led_matrix_256/led_matrix_256.ino
@@ -16,18 +16,16 @@
 //int sensorPin = A5;    // select the input pin for the potentiometer
 //int sensorValue = 0;  // variable to store the value coming from the sensor

-uint8_t d = 0;
-uint8_t b = pow(2,7);
-uint8_t g = pow(2,15);
-uint8_t r = pow(2,23);
-uint8_t p = b+r;
-uint8_t y = g+r;
-uint8_t a = b+g;
-uint8_t w = b+g+r;
+const uint8_t d = 0;
+const uint8_t b = pow(2,7);
+const uint8_t g = pow(2,15);
+const uint8_t r = pow(2,23);
+const uint8_t p = b+r;
+const uint8_t y = g+r;
+const uint8_t a = b+g;
+const uint8_t w = b+g+r;

-
-
-const uint8_t frames[][NUM_OF_PIXELS] = { {
+const PROGMEM uint8_t frames[][NUM_OF_PIXELS] = { {
         d,d,w,w,d,d,d,d,d,d,d,d,d,d,d,d,
         d,d,d,d,d,d,d,d,d,d,d,w,d,w,d,d,
         d,d,d,w,d,w,d,d,d,d,d,d,d,d,d,d,


Added Heltec WiFi-Kit-8 with 0.91" display

--- usermods/Wemos_D1_mini+Wemos32_mini_shield/wled06_usermod.ino
+++ usermods/Wemos_D1_mini+Wemos32_mini_shield/wled06_usermod.ino
@@ -2,7 +2,8 @@
 #include <DallasTemperature.h> //Dallastemperature sensor
 #ifdef ARDUINO_ARCH_ESP32 //ESP32 boards
 uint8_t SCL_PIN = 22;
-uint8_t SDA_PIN = 21;
+uint8_t SDA_PIN = 21;
+// uint8_t RST_PIN = 16; // Uncoment for Heltec WiFi-Kit-8
 OneWire oneWire(23);
 #else //ESP8266 boards
 uint8_t SCL_PIN = 5;
@@ -13,7 +14,7 @@
 //ESP8266 Wemos D1 mini board use SCL=5 SDA=4 while ESP32 Wemos32 mini board use SCL=22 SDA=21
 #define U8X8_PIN_SCL SCL_PIN
 #define U8X8_PIN_SDA SDA_PIN
-
+//#define U8X8_PIN_RESET RST_PIN // Uncoment for Heltec WiFi-Kit-8
 // Dallas sensor
 DallasTemperature sensor(&oneWire);
 long temptimer = millis();
@@ -29,6 +30,8 @@
 U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(U8X8_PIN_NONE, U8X8_PIN_SCL, U8X8_PIN_SDA); // Pins are Reset, SCL, SDA
 // --> Second choise of cheap I2C OLED 128X64 0.96" or 1.3"
 //U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(U8X8_PIN_NONE, U8X8_PIN_SCL, U8X8_PIN_SDA); // Pins are Reset, SCL, SDA
+// --> Third choise Heltec WiFi-Kit-8 with build-in OLED 128X32 0.91"
+//U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(U8X8_PIN_RESET, U8X8_PIN_SCL, U8X8_PIN_SDA); // Constracor for Heltec WiFi-Kit-8
 // gets called once at boot. Do all initialization that doesn't depend on
 // network here
 void userSetup() {


Left Hand Code Updated

Left Hand Code Updated

Format Changed

--- BitBangingMpu6050/LeftHand.ino
+++ BitBangingMpu6050/LeftHand.ino
@@ -6,11 +6,19 @@
 #define I2C_TIMEOUT 100
 #define I2C_FASTMODE 1

-// ! = Thumb
+// ! = Thumb
 // & = Index Finger
 // * = Middle Finger
 // ( = Ring Finger
 // ) = Pinky Finger
+
+//% = Pinky Finger
+// @ = Thumb
+// ^ = Index
+// # = Middle
+// $ = Ring
+
+
 #include "SoftWire.h"

 #include <SoftwareSerial.h>
@@ -1080,8 +1088,8 @@
     address=105;
     Wire.beginTransmission(address);
       error = Wire.endTransmission();
-    mySerial.println("The error is : ");
-    mySerial.println(error);
+   /* mySerial.println("The error is : ");
+    mySerial.println(error);*/
        if (error == 0)
         {
           /*Serial.print("MPU number : ");
@@ -1240,14 +1248,25 @@
   Serial.print(unfiltered_gyro_angle_y, 2);
   Serial.print(F(","));
   Serial.print(unfiltered_gyro_angle_z, 2);*/
-  mySerial.println("It has reached here : ");
-  mySerial.println(F("!"));             //Filtered angle
-  mySerial.print(angle_x, DEC);
-  mySerial.println(F(""));
-  mySerial.print(angle_y, DEC);
-  mySerial.println(F(""));
-  mySerial.print(angle_z, DEC);
-  mySerial.println(F(""));
+  int x,y,z;
+  x=(int)(angle_x);
+  y=(int)(angle_y);
+  z=(int)(angle_z);
+  String a=String(x);
+  String b=String(y);
+  String c=String(z);
+  String acc_x=String((int)accel_t_gyro.value.x_accel);
+  String acc_y=String((int)accel_t_gyro.value.y_accel);
+  String acc_z=String((int)accel_t_gyro.value.z_accel);
+
+
+  mySerial.println(F("@"));
+  mySerial.println(acc_x);
+    mySerial.println(acc_y);
+  mySerial.println(acc_z);
+  mySerial.println(a);
+  mySerial.println(b);
+  mySerial.println(c);

   // Delay so we don't swamp the serial port

@@ -1281,8 +1300,8 @@
     address=105;
     Wire.beginTransmission(address);
       error = Wire.endTransmission();
-       mySerial.println("The error is : ");
-    mySerial.println(error);
+      /* mySerial.println("The error is : ");
+    mySerial.println(error);*/
       if (error == 0)
         {
           /*Serial.print("MPU number : ");
@@ -1441,14 +1460,25 @@
   Serial.print(unfiltered_gyro_angle_y, 2);
   Serial.print(F(","));
   Serial.print(unfiltered_gyro_angle_z, 2);*/
-  mySerial.println(F("&"));             //Filtered angle
-  mySerial.print(angle_x, DEC);
-  mySerial.println(F(","));
-  mySerial.print(angle_y, DEC);
-  mySerial.println(F(","));
-  mySerial.print(angle_z, DEC);
-  mySerial.println(F(""));
-
+ int x,y,z;
+  x=(int)(angle_x);
+  y=(int)(angle_y);
+  z=(int)(angle_z);
+  String a=String(x);
+  String b=String(y);
+  String c=String(z);
+  String acc_x=String((int)accel_t_gyro.value.x_accel);
+  String acc_y=String((int)accel_t_gyro.value.y_accel);
+  String acc_z=String((int)accel_t_gyro.value.z_accel);
+
+
+  mySerial.println(F("^"));
+  mySerial.println(acc_x);
+  mySerial.println(acc_y);
+  mySerial.println(acc_z);
+  mySerial.println(a);
+  mySerial.println(b);
+  mySerial.println(c);
   // Delay so we don't swamp the serial port

          // nDevices++;
@@ -1480,8 +1510,8 @@
     address=105;
     Wire.beginTransmission(address);
       error = Wire.endTransmission();
-       mySerial.println("The error is : ");
-    mySerial.println(error);
+       /*mySerial.println("The error is : ");
+    mySerial.println(error);*/
       if (error == 0)
         {
           /*Serial.print("MPU number : ");
@@ -1640,13 +1670,25 @@
   Serial.print(unfiltered_gyro_angle_y, 2);
   Serial.print(F(","));
   Serial.print(unfiltered_gyro_angle_z, 2);*/
-  mySerial.println(F("*"));             //Filtered angle
-  mySerial.print(angle_x, DEC);
-  mySerial.println(F(","));
-  mySerial.print(angle_y, DEC);
-  mySerial.println(F(","));
-  mySerial.print(angle_z, DEC);
-  mySerial.println(F(""));
+  int x,y,z;
+  x=(int)(angle_x);
+  y=(int)(angle_y);
+  z=(int)(angle_z);
+  String a=String(x);
+  String b=String(y);
+  String c=String(z);
+  String acc_x=String((int)accel_t_gyro.value.x_accel);
+  String acc_y=String((int)accel_t_gyro.value.y_accel);
+  String acc_z=String((int)accel_t_gyro.value.z_accel);
+
+
+  mySerial.println(F("#"));
+  mySerial.println(acc_x);
+  mySerial.println(acc_y);
+  mySerial.println(acc_z);
+  mySerial.println(a);
+  mySerial.println(b);
+  mySerial.println(c);

   // Delay so we don't swamp the serial port

@@ -1679,8 +1721,8 @@
     address=105;
     Wire.beginTransmission(address);
       error = Wire.endTransmission();
-       mySerial.println("The error is : ");
-    mySerial.println(error);
+      /* mySerial.println("The error is : ");
+    mySerial.println(error);*/
       if (error == 0)
         {
           /*Serial.print("MPU number : ");
@@ -1840,13 +1882,25 @@
   Serial.print(unfiltered_gyro_angle_y, 2);
   Serial.print(F(","));
   Serial.print(unfiltered_gyro_angle_z, 2);*/
-  mySerial.println(F("("));             //Filtered angle
-  mySerial.print(angle_x, DEC);
-  mySerial.println(F(","));
-  mySerial.print(angle_y, DEC);
-  mySerial.println(F(","));
-  mySerial.print(angle_z, DEC);
-  mySerial.println(F(""));
+ int x,y,z;
+  x=(int)(angle_x);
+  y=(int)(angle_y);
+  z=(int)(angle_z);
+  String a=String(x);
+  String b=String(y);
+  String c=String(z);
+  String acc_x=String((int)accel_t_gyro.value.x_accel);
+  String acc_y=String((int)accel_t_gyro.value.y_accel);
+  String acc_z=String((int)accel_t_gyro.value.z_accel);
+
+
+  mySerial.println(F("$"));
+  mySerial.println(acc_x);
+    mySerial.println(acc_y);
+  mySerial.println(acc_z);
+  mySerial.println(a);
+  mySerial.println(b);
+  mySerial.println(c);

   // Delay so we don't swamp the serial port

@@ -1879,9 +1933,9 @@
     address=105;
     Wire.beginTransmission(address);
       error = Wire.endTransmission();
-       mySerial.println("The error is : ");
-    mySerial.println(error);
-      if (error == 0)
+       /*mySerial.println("The error is : ");
+    mySerial.println(error);*/
+    if(error==0)
         {
           /*Serial.print("MPU number : ");
           Serial.println(flag-5);
@@ -2039,13 +2093,25 @@
   Serial.print(unfiltered_gyro_angle_y, 2);
   Serial.print(F(","));
   Serial.print(unfiltered_gyro_angle_z, 2);*/
-  mySerial.println(F(")"));             //Filtered angle
-  mySerial.print(angle_x, DEC);
-  mySerial.println(F(","));
-  mySerial.print(angle_y, DEC);
-  mySerial.println(F(","));
-  mySerial.print(angle_z, DEC);
-  mySerial.println(F(""));
+int x,y,z;
+  x=(int)(angle_x);
+  y=(int)(angle_y);
+  z=(int)(angle_z);
+  String a=String(x);
+  String b=String(y);
+  String c=String(z);
+  String acc_x=String((int)accel_t_gyro.value.x_accel);
+  String acc_y=String((int)accel_t_gyro.value.y_accel);
+  String acc_z=String((int)accel_t_gyro.value.z_accel);
+
+
+  mySerial.println(F("%"));
+  mySerial.println(acc_x);
+    mySerial.println(acc_y);
+  mySerial.println(acc_z);
+  mySerial.println(a);
+  mySerial.println(b);
+  mySerial.println(c);

   // Delay so we don't swamp the serial port


Update quick start dht

Update quick start dht

--- examples/03_Quick_start_anto_dht11/03_Quick_start_anto_dht11.ino
+++ examples/03_Quick_start_anto_dht11/03_Quick_start_anto_dht11.ino
@@ -2,7 +2,7 @@
  * This example is meant to be used as a starting point
  * for working with Anto.io services and DHT sensor module
  *
- * 2017/02/08
+ * 2017/06/17
  * by Anto.io team
  *
  */
@@ -13,6 +13,8 @@
 #define DHTPIN 2    //port D4
 #define DHTTYPE DHT11

+const char *ssid = "your access point SSID";
+const char *pass = "access point password";
 const char *user = "your username";
 const char *token = "your token";
 const char *thing = "your thing";
@@ -20,9 +22,7 @@
 // initialize AntoIO instance
 AntoIO anto(user, token, thing);

-String Antosend;
-char buf[5];
-
+//initialize dht instance
 DHT dht(DHTPIN,DHTTYPE);

 void setup() {
@@ -34,15 +34,12 @@
   Serial.print("Anto library version: ");
   Serial.println(anto.getVersion());

+  Serial.print("\nTrying to connect ");
+  Serial.print(ssid);
+  Serial.println("...");

-  // Connect to your WiFi access point
-  anto.wifi.smartConfig();
-
-  Serial.println();
-  Serial.println("WiFi connected, trying to connect to broker...");
-
-  while (!anto.mqtt.connect());
-  Serial.println("\nConnected");
+  anto.begin(ssid, pass, messageReceived);
+  Serial.println("\nConnected Anto done");

   //dht start
   dht.begin();
@@ -65,11 +62,11 @@
   Serial.println(humid);

   if(temp >= 0){
-     anto.mqtt.pub("Temp",temp);           //ใช้ buf ส่งค่าขึ้นไป
+     anto.pub("Temp",temp);
   }

   if(humid >= 0){
-     anto.mqtt.pub("Humid",humid);
+     anto.pub("Humid",humid);
   }

   delay(1000);


Fix #423: don't get stuck if LMIC is busy

--- examples/compliance-otaa-halconfig/compliance-otaa-halconfig.ino
+++ examples/compliance-otaa-halconfig/compliance-otaa-halconfig.ino
@@ -537,6 +537,7 @@
     // Check if there is not a current TX/RX job running
     if (LMIC.opmode & OP_TXRXPEND) {
         Serial.println(F("OP_TXRXPEND, not sending"));
+        sendComplete(j, 0);
     } else if (g_fTestMode) {
         Serial.println(F("test mode, not sending"));
     } else {


BasicStepping: Say the DO pin is not needed.

--- examples/BasicStepping/BasicStepping.ino
+++ examples/BasicStepping/BasicStepping.ino
@@ -4,8 +4,8 @@
 It shows how to initialize the dirver, set the current limit, set
 the micro-stepping mode, and enable the driver.  It shows how to
 send pulses to the step pin to get the driver to take steps and
-how to switch directions over SPI.  (The DIR pin is not used and
-does not need to be connected.)
+how to switch directions over SPI.  The DO and DIR pins are not
+used and do not need to be connected.

 Before using this example, be sure to change the
 setCurrentMilliamps line to have an appropriate current limit for


we have a stop-watering-plants method now

--- plantstation.ino
+++ plantstation.ino
@@ -28,7 +28,7 @@
 } SoilMeasurement;
 SoilMeasurement sm;

-//===== For digital thermo, humidity sensor =====
+//===== For digital thermo/humidity sensor =====
 #include "DHT.h"
 const byte dhtPin = 2;
 DHT myDHT(dhtPin, DHT11);
@@ -50,26 +50,29 @@
 //===== For hygrometer ==========================
 const byte hygroPin = A1;
 // todo - find right value for this
-const int moistureThreshold = 500; // <- made this up
+const int moistureThreshold = 1000; // <- made this up
 int moistureSensorVal;

-//===== For water ===============================
+//===== For water level sensor ===================
 const byte waterSensorPin = A2;
 // todo - find right value for this
 const int waterLevelThreshold = 400; // <- made this up
+int waterLevelVal;
+
+//===== For water pump ===========================
 boolean waterPumpIsOn = false;
-int waterLevelVal;
 unsigned long wateringSeconds = 10000;
 unsigned long prevWatering = 0;
 String waterLevel = "OK";

 //===== For timed events =========================
-long prevMinOneMillis = 0;
-long minOneInterval = 60000;
-long prevMinFiveMillis = 0;
-long minFiveInterval = 300000;
-long prevHourTwelveMillis = 0;
-long hourTwelveInterval = 43200000;
+// todo - timed events use regule marers for 1 min 1 hour etc and divide blah
+unsigned long prevMinOneMillis = 0;
+unsigned long minOneInterval = 60000;
+unsigned long prevMinFiveMillis = 0;
+unsigned long minFiveInterval = 300000;
+unsigned long prevHourTwelveMillis = 0;
+unsigned long hourTwelveInterval = 43200000;

 void setup() {
   pinMode(LightSwitch, OUTPUT);
@@ -100,7 +103,7 @@
     prevMinOneMillis = currentMillis;

     sendToKeen();
-    waterPlants();
+    waterPlantStarts();
   }

   // these happen every five minutes (or so)
@@ -114,31 +117,31 @@
   if (currentMillis - prevHourTwelveMillis > hourTwelveInterval) {
     prevHourTwelveMillis = currentMillis;

-    waterPlants();
-  }
-
-  if (waterPumpIsOn && currentMillis >= prevWatering + 10000) {
+    waterPlantStarts();
+  }
+  waterPlantStops(currentMillis);
+}
+
+void waterPlantStarts() {
+  // todo - figure out how to send a water pump is on event for log even thou its off at time.
+  if (!waterPumpIsOn && waterLevel == "OK" && moistureThreshold > moistureSensorVal) {
+    prevWatering = millis();
+    waterPumpIsOn = true;
+    Console.println("Watering started");
+  }
+}
+
+void waterPlantStops(unsigned long currentMillis) {
+    if (waterPumpIsOn && currentMillis >= prevWatering + wateringSeconds) {
     waterPumpIsOn = false;
     Console.println("Watering stopped");
-  }
-}
-
-void waterPlants() {
-
-  // todo - implement all the sensors (water level, moisture)
-  // todo - figure out how to send a water pump is on event for log even thou its off at time.
-  // todo - leave a trail that pump ran for event log
-  // todo - cleanup vars
-
-  // todo - timed events use regule marers for 1 min 1 hour etc and divide blah
-
-  prevWatering = millis();
-  if (!waterPumpIsOn) {
-    waterPumpIsOn = true;
-    Console.println("Watering started");
-  }
-
-
+  } else if (waterPumpIsOn && moistureThreshold < moistureSensorVal) {
+    waterPumpIsOn = false;
+    Console.println("Watering stopped");
+  } else if (waterPumpIsOn && waterLevel == "LOW") {
+    waterPumpIsOn = false;
+    Console.println("Watering stopped");
+  }
 }

 void switchLights() {


adding first test skel with serial tube

adding first test skel with serial tube

--- test/serial_test.ino
+++ test/serial_test.ino
@@ -50,5 +50,17 @@
       }
     case 'G': {
       }
+    case 'S': {
+      Serial.println(F("Creating SERIAL TUBE"));
+        while (1) {
+          while (Serial.available()) {
+            delay(1);
+            serial->write(Serial.read());
+          }
+          if (serial->available()) {
+            Serial.write(serial->read());
+          }
+        }
+      }
   }
 }


firmware: code cleanup

firmware: code cleanup

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -21,8 +21,9 @@

 String inputString = "";         // a string to hold incoming data
 boolean stringComplete = false;  // whether the string is complete
-boolean writingToFlash = false;  // whether we are currently writing to MAX1464 flash memory
-unsigned long flashLinesWritten = 0; // count hex lines during flash loop
+boolean writingToFlash = false;  // whether we are currently writing to MAX1464
+                                 // flash memory
+unsigned long hexLinesWritten = 0; // count hex lines written during flash loop
 MAX1464 maxim(10);

 void printIden() {
@@ -30,40 +31,24 @@
 }

 void setup() {
-    // initialize serial:
     Serial.begin(115200);
     printIden();
-    // reserve 200 bytes for the inputString:
     inputString.reserve(200);

 //    maxim.setPins(11,12,13); // only for software SPI
     maxim.begin();
 }

-/*
-SerialEvent occurs whenever a new data comes in the
-hardware serial RX.  This routine is run between each
-time loop() runs, so using delay inside loop can delay
-response.  Multiple bytes of data may be available.
-*/
 void serialEvent() {
     while (Serial.available()) {
-        // get the new byte:
         char inChar = (char)Serial.read();
-        // if the incoming character is a newline, set a flag
-        // so the main loop can do something about it:
         if (inChar == '\n') {
             stringComplete = true;
         }
         else {
-            // add it to the inputString:
             inputString += inChar;
         }
     }
-}
-
-void writeToFlashMemory() {
-
 }

 void loop() {
@@ -81,9 +66,9 @@
             }
             else {
                 Serial.print(".");
-                flashLinesWritten++;
-                if(flashLinesWritten>80) {
-                    flashLinesWritten = 0;
+                hexLinesWritten++;
+                if(hexLinesWritten>80) {
+                    hexLinesWritten = 0;
                     Serial.println();
                 }
                 if(maxim.hasEOFBeenReached()) {
@@ -142,7 +127,7 @@
                 partition = atoi(partition_cp);
             }
             writingToFlash = true;
-            flashLinesWritten = 0;
+            hexLinesWritten = 0;
             maxim.startWritingToFlashMemory(partition);
             Serial.println("Writing to flash memory...");
         }


Some speed adjustments to s4EDU on straight FW move

--- _04_s4a_edu_ff_and_t_proximity/_04_s4a_edu_ff_and_t_proximity.ino
+++ _04_s4a_edu_ff_and_t_proximity/_04_s4a_edu_ff_and_t_proximity.ino
@@ -17,6 +17,11 @@
 #define MOTOR_DIRECTION_BACKWARDS 0
 #define FORWARD_TIME          10000
 #define TOO_CLOSE_DISTANCE    6
+#define MOTOR_RIGHT_FW_SPEED 91
+#define MOTOR_LEFT_FW_SPEED  100
+#define MOTOR_RIGHT_BW_SPEED 91
+#define MOTOR_LEFT_BW_SPEED  100
+#define ROTATE_TIME 150

 // the setup function runs once when you press reset or power the board
 void setup() {
@@ -73,7 +78,7 @@
   moveBackwards();
   doBlink(2,100);
   rotateLeft();
-  doBlink(2, 250);
+  doBlink(2, ROTATE_TIME);

   limitMillis = millis() + FORWARD_TIME;
   moveForward();
@@ -120,14 +125,14 @@

 void moveForward(){
   Serial.println("Moving FORWARD...");
-  setMotor(MOTOR_LEFT, MOTOR_DIRECTION_FORWARD, 100);
-  setMotor(MOTOR_RIGHT, MOTOR_DIRECTION_FORWARD, 100);
+  setMotor(MOTOR_LEFT, MOTOR_DIRECTION_FORWARD, MOTOR_LEFT_FW_SPEED);
+  setMotor(MOTOR_RIGHT, MOTOR_DIRECTION_FORWARD, MOTOR_RIGHT_FW_SPEED);
 }

 void moveBackwards(){
   Serial.println("Moving BACKWARDS...");
-  setMotor(MOTOR_LEFT, MOTOR_DIRECTION_BACKWARDS, 100);
-  setMotor(MOTOR_RIGHT, MOTOR_DIRECTION_BACKWARDS, 100);
+  setMotor(MOTOR_LEFT, MOTOR_DIRECTION_BACKWARDS, MOTOR_LEFT_BW_SPEED);
+  setMotor(MOTOR_RIGHT, MOTOR_DIRECTION_BACKWARDS, MOTOR_RIGHT_BW_SPEED);
 }

 void rotateRight(){


WDRC_8BandFIR_Full: fix comment

WDRC_8BandFIR_Full: fix comment

--- examples/05-FullSystems/WDRC_8BandFIR_full/WDRC_8BandFIR_full.ino
+++ examples/05-FullSystems/WDRC_8BandFIR_full/WDRC_8BandFIR_full.ino
@@ -46,12 +46,12 @@

 // Define the number of channels! Make sure DSL_GHA_Preset0.h and DSL_GHA_Preset1.h have enough values
 // (it needs N_CHAN or more values) defined for each compressor parameter.  If not, it'll bomb at run time!
-const int N_CHAN = 8;
+const int N_CHAN = 8;                   // number of frequency bands and compression channels

 // Create audio classes and make audio connections
 Tympan    myTympan(TympanRev::E, audio_settings);  //choose TympanRev::D or TympanRev::E
 #include "AudioConnections.h"                      //let's put them in their own file for clarity
-                         // number of frequency bands (channels)
+

 // Create classes for controlling the system
 #include      "SerialManager.h"


Remove extraneous test

Remove extraneous test

--- moros/moros.ino
+++ moros/moros.ino
@@ -178,7 +178,7 @@
         // Unrecognized button interrupt
         serprintf("received interrupt %d, but no player has a button on that interrupt!\r\n", interrupt_fired);

-      } else if (player_who_pressed != NONE && (active_player == NONE || player_who_pressed == active_player)) {
+      } else if (active_player == NONE || player_who_pressed == active_player) {
         // either it was nobody's turn, or the active player pressed their button
         // switch to the opposite player from the one whose button was pressed
         active_player = (player_who_pressed+1) % 2;


Remove dead code

Remove dead code

--- moros/moros.ino
+++ moros/moros.ino
@@ -100,8 +100,6 @@
 } Clock;

 typedef struct {
-  char display_time[12];
-  int display_width_chars;
   Clock *clock;
   Button *button;
   Screen *screen;
@@ -109,15 +107,11 @@

 Player players[2] = {
   {
-    .display_time = {},
-    .display_width_chars = 0,
     .clock = new Clock,
     .button = &buttons[0],
     .screen = screens[0]
   },
   {
-    .display_time = {},
-    .display_width_chars = 0,
     .clock = new Clock,
     .button = &buttons[1],
     .screen = screens[1]


refined feedback and tested reset pin to restart


Working Low voltage shift out

Working Low voltage shift out

--- bolt-arduino.ino
+++ bolt-arduino.ino
@@ -1,15 +1,16 @@
 const int P_LED_VCC = 5;
-const int P_LED_DATA = 9;
-const int P_LED_CLOCK = 10;
-const int P_LED_LATCH = 11;
+const int P_LED_DATA = 8;
+const int P_LED_CLOCK = 12;
+const int P_LED_LATCH = 13;

-const uint8_t LED_TWO_VOLTS = 255;
+//Value to adjust for optimal output voltage
+const uint8_t LED_VCC_PWM = 105;

 //const uint8_t LED_STATE_OFF = 0;
 //const uint8_t LED_STATE_ON = 1;

-byte val = B01010110;
+byte val = B01000000;

 //byte states[8];

@@ -22,33 +23,42 @@
   pinMode(P_LED_CLOCK, OUTPUT);
   pinMode(P_LED_LATCH, OUTPUT);

-  analogWrite(P_LED_VCC, LED_TWO_VOLTS);
+  shiftOut();
+  delay(5000);

-  delay(1000);
-
-  //states[0] = LED_STATE_ON;
-
-  digitalWrite(P_LED_LATCH, LOW);
+  val = B11111111;
   shiftOut();
-  digitalWrite(P_LED_LATCH, HIGH);
-
 }

 void loop() {}

 void shiftOut() {
+  //Latch Low vcc high
+  digitalWrite(P_LED_VCC, HIGH);
+  digitalWrite(P_LED_LATCH, LOW);
+
+
+  //Shift out
   for (uint8_t i = 0; i < 8; i++)  {
-    if (!!(val & (1 << i))){
+    if (!!(val & (1 << i))) {
       digitalWrite(P_LED_DATA, HIGH);
     } else {
       digitalWrite(P_LED_DATA, LOW);
     }
-
+

     digitalWrite(P_LED_CLOCK, HIGH);
     digitalWrite(P_LED_CLOCK, LOW);
   }
+
+  //If data is left on high drop to low, so that the final voltage is not altered
+  digitalWrite(P_LED_DATA, LOW);
+
+  //Latch high, vcc adjust
+  digitalWrite(P_LED_LATCH, HIGH);
+  analogWrite(P_LED_VCC, LED_VCC_PWM);
+

   /*analogWrite(P_LED_CLOCK, LOW);

@@ -75,8 +85,5 @@
     analogWrite(P_LED_CLOCK, LOW);
     }
   */
-
-
-  Serial.println("Done");
 }


Fixed logic problem with the multi-board code

--- arduino_practice_target.ino
+++ arduino_practice_target.ino
@@ -30,7 +30,7 @@

 	for(int i=0; i<lenTargets; i++)
 	{
-		servoNum = i % SERVOPERBOARD
+		servoNum = i % SERVOPERBOARD;

 		if (servoNum == 0) {
 			pwm = Adafruit_PWMServoDriver(boardAddr++);