Revert "Added latest behaviours."

Revert "Added latest behaviours."

This reverts commit dfb9ae11c17b2384380fe79bc9895ca23cf52b0a.

--- src/MonsterSketch/MonsterSketch.ino
+++ src/MonsterSketch/MonsterSketch.ino
@@ -70,8 +70,6 @@
 float force[5];
 float magnitude[5];
 float location[5];
-int monsterTimer;
-

 float dampening;
 float springValue;
@@ -95,8 +93,6 @@
   ////////////////////////////dampening value (1= no dampening, 0 = full dampening (no movement)) Usually .9 or so.
   dampening = 0.9;
   //////////////////////////////////////////////////////////////////////
-
-  monsterTimer=0;

   for (int i=0; i<5; i++){
     target[i] = 0.1;
@@ -138,7 +134,7 @@

 }

-void loop(){
+void loop() {

   // RUN JOINT CALIBRATION ROUTINE
 #ifdef CALIBRATING
@@ -173,111 +169,67 @@
   /////////////////////////////////////////////
   // Set Robot
   /////////////////////////////////////////////
-  monsterTimer = monsterTimer + 1;
-
   //////////////////HARDCODING VALUES TO JOINTS BASED ON COMMON SENSOR VALUES BELOW////////////////////////
   // X maps to joint 0
-  if(g_fX > -.1){
-    iPwmValue = mapfloat(g_fX, -.1, -0.6, g_poDataMonster->m_apJoinArray[0]->m_fPwmMin, g_poDataMonster->m_apJoinArray[0]->m_fPwmMin + 5);  ///////<-hardcoded!
+  if(g_fX < -.1){
+    iPwmValue = mapfloat(g_fX, -.1, -0.6, g_poDataMonster->m_apJoinArray[0]->m_fPwmMin, g_poDataMonster->m_apJoinArray[0]->m_fPwmMin + 50);  ///////<-hardcoded!

   }
-  else if(g_fX < 0.1){
-    iPwmValue = mapfloat(g_fX, 0.1, 0.6, g_poDataMonster->m_apJoinArray[0]->m_fPwmMax , g_poDataMonster->m_apJoinArray[0]->m_fPwmMax - 5); ///////<-hardcoded!
+  else if(g_fX > 0.1){
+    iPwmValue = mapfloat(g_fX, 0.1, 0.6, g_poDataMonster->m_apJoinArray[0]->m_fPwmMax , g_poDataMonster->m_apJoinArray[0]->m_fPwmMax - 50); ///////<-hardcoded!
   }
   else{
     iPwmValue = mapfloat(g_fX, SENSOR_X_MIN, SENSOR_X_MAX, g_poDataMonster->m_apJoinArray[0]->m_fPwmMin, g_poDataMonster->m_apJoinArray[0]->m_fPwmMax);
   }
- ///////////////////////////////////////////////////
-  ////what to do
-  if (monsterTimer <= 160){
   target[0]= iPwmValue;
- // Serial.println(monsterTimer);
-  }
-    if ((target[0] - iPwmValue > 2.5) || (target[0] - iPwmValue < -2.5 )){
- monsterTimer =0;
-    }
-// Serial.println(monsterTimer);
-
-  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

   // Z maps to joint 1
   if(g_fZ >= 0 && g_fZ < 0.1){
-    iPwmValue = mapfloat(g_fX, 0, (.1), g_poDataMonster->m_apJoinArray[1]->m_fPwmMin, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax-10);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fX, 0, (.1), g_poDataMonster->m_apJoinArray[1]->m_fPwmMin, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax-50);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.1 && g_fZ< 0.2){
-    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[1]->m_fPwmMin, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax-10);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[1]->m_fPwmMin + 50, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.2 && g_fZ< 0.3){
-    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[1]->m_fPwmMin, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax-5);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[1]->m_fPwmMin + 30, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.3 && g_fZ< 0.6){
-    iPwmValue = mapfloat(g_fZ, 0.3, 0.6, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax-10, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0.3, 0.6, g_poDataMonster->m_apJoinArray[1]->m_fPwmMin, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax);  ///////<-hardcoded!
   }
   else{
     iPwmValue = mapfloat(g_fZ, SENSOR_Z_MIN, SENSOR_Z_MAX, g_poDataMonster->m_apJoinArray[1]->m_fPwmMin, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax);
   }
-
-  //////////////////what to do
-   if (monsterTimer <= 105){
   target[1]= iPwmValue;
-  }
-  else if (monsterTimer <= 165){
-    target[1] = g_poDataMonster->m_apJoinArray[1]->m_fPwmMin;
-  }
-else{
- target[1] = g_poDataMonster->m_apJoinArray[1]->m_fPwmMax;
-}
-
-
-
-
-
-
-
-
-
-  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-//  // Z maps to joint 2
+
+  // Z maps to joint 2
   if(g_fZ >= 0 && g_fZ < 0.1){
-    iPwmValue = mapfloat(g_fZ, 0, (.1), g_poDataMonster->m_apJoinArray[2]->m_fPwmMax-10, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin);  ///////<-hardcoded!
-  }
-  else if(g_fZ >= 0.1 && g_fZ< 0.3){
-    iPwmValue = mapfloat(g_fZ, 0.1, 0.3, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax-5, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0, (.1), g_poDataMonster->m_apJoinArray[2]->m_fPwmMin, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax-50);  ///////<-hardcoded!
+  }
+  else if(g_fZ >= 0.1 && g_fZ< 0.2){
+    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin + 50, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax);  ///////<-hardcoded!
+  }
+  else if(g_fZ >= 0.2 && g_fZ< 0.3){
+    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin + 30, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.3 && g_fZ< 0.6){
-    iPwmValue = mapfloat(g_fZ, 0.3, 0.6, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0.3, 0.6, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax);  ///////<-hardcoded!
   }
   else{
-    iPwmValue = mapfloat(g_fZ, SENSOR_Z_MIN, SENSOR_Z_MAX, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin+5);
-  }
-  if (target[1] < g_poDataMonster->m_apJoinArray[1]->m_fPwmMax-10)
-  target[2] = target[1];
-
-
-   if (monsterTimer <= 120){
+    iPwmValue = mapfloat(g_fZ, SENSOR_Z_MIN, SENSOR_Z_MAX, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax);
+
+  }
   target[2]= iPwmValue;
-  }
-  else {
-    target[2] = g_poDataMonster->m_apJoinArray[1]->m_fPwmMin;
-  }
-
-
-
-
-
-  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

   // Z maps to joint 3
   if(g_fZ >= 0 && g_fZ < 0.1){
-    iPwmValue = mapfloat(g_fZ, 0, (.1), g_poDataMonster->m_apJoinArray[3]->m_fPwmMax, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax-10);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0, (.1), g_poDataMonster->m_apJoinArray[3]->m_fPwmMin, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.1 && g_fZ< 0.2){
-    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax, g_poDataMonster->m_apJoinArray[3]->m_fPwmMin+10);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[3]->m_fPwmMin, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.2 && g_fZ< 0.3){
-    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax-10);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[3]->m_fPwmMin, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.3 && g_fZ< 0.6){
     iPwmValue = mapfloat(g_fZ, 0.3, 0.6, g_poDataMonster->m_apJoinArray[3]->m_fPwmMin, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax);  ///////<-hardcoded!
@@ -285,62 +237,26 @@
   else{
     iPwmValue = mapfloat(g_fZ, SENSOR_Z_MIN, SENSOR_Z_MAX, g_poDataMonster->m_apJoinArray[3]->m_fPwmMin, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax);
   }
-     if (monsterTimer <= 110){
   target[3]= iPwmValue;
-  }
-  else if (monsterTimer <= 130){
-  target[3]= 25;
-  }
-    else if (monsterTimer <= 150){
-  target[3]= 10;
-  }
-     else if (monsterTimer <= 160){
-  target[3]= g_poDataMonster->m_apJoinArray[3]->m_fPwmMax;
-  }
-     else if (monsterTimer <= 175){
-  target[3]= g_poDataMonster->m_apJoinArray[3]->m_fPwmMin;
-  }
-  else{
-    target[3]= iPwmValue;
-  }
-  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

   // Y maps to joint 4
-  if(g_fY >= 0 && g_fY < 0.1){
-    iPwmValue = mapfloat(g_fY, 0, (.1), g_poDataMonster->m_apJoinArray[4]->m_fPwmMax, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax-5);  ///////<-hardcoded!
-  }
-  else if(g_fY >= 0.1 && g_fY< 0.2){
-    iPwmValue = mapfloat(g_fY, 0.1, 0.2, g_poDataMonster->m_apJoinArray[4]->m_fPwmMin , g_poDataMonster->m_apJoinArray[4]->m_fPwmMax-5);  ///////<-hardcoded!
-  }
-  else if(g_fY >= 0.2 && g_fY< 0.3){
-    iPwmValue = mapfloat(g_fY, 0.1, 0.2, g_poDataMonster->m_apJoinArray[4]->m_fPwmMin + 8, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax);  ///////<-hardcoded!
-  }
-  else if(g_fY >= 0.3 && g_fY< 0.6){
-    iPwmValue = mapfloat(g_fY, 0.3, 0.6, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax-5, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax);  ///////<-hardcoded!
+  if(g_fZ >= 0 && g_fZ < 0.1){
+    iPwmValue = mapfloat(g_fY, 0, (.1), g_poDataMonster->m_apJoinArray[4]->m_fPwmMin, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax-50);  ///////<-hardcoded!
+  }
+  else if(g_fZ >= 0.1 && g_fZ< 0.2){
+    iPwmValue = mapfloat(g_fY, 0.1, 0.2, g_poDataMonster->m_apJoinArray[4]->m_fPwmMin + 50, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax);  ///////<-hardcoded!
+  }
+  else if(g_fZ >= 0.2 && g_fZ< 0.3){
+    iPwmValue = mapfloat(g_fY, 0.1, 0.2, g_poDataMonster->m_apJoinArray[4]->m_fPwmMin + 30, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax);  ///////<-hardcoded!
+  }
+  else if(g_fZ >= 0.3 && g_fZ< 0.6){
+    iPwmValue = mapfloat(g_fY, 0.3, 0.6, g_poDataMonster->m_apJoinArray[4]->m_fPwmMin, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax);  ///////<-hardcoded!
   }
   else{
     iPwmValue = mapfloat(g_fY, SENSOR_X_MIN, SENSOR_X_MAX, g_poDataMonster->m_apJoinArray[4]->m_fPwmMin, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax);
-  }
-
-  //target[4]= iPwmValue;
-  // target[4]= 15;
-
-     if (monsterTimer <= 90){
+
+  }
   target[4]= iPwmValue;
-  }
-  else if(monsterTimer <= 105){
-target[4] = g_poDataMonster->m_apJoinArray[4]->m_fPwmMax-2;
-  }
-    else if(monsterTimer <=160){
-target[4] = g_poDataMonster->m_apJoinArray[4]->m_fPwmMin+10;
-    }
-   else {
-     target[4]= g_poDataMonster->m_apJoinArray[4]->m_fPwmMax-2;
-   }
-
-  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- //Dampening code

   for (int i=0; i<5; i++){
     magnitude[i] = target[i] - location[i];
@@ -357,19 +273,17 @@

  ///// Set Dampening couter/reset
 dampening = (dampening - 0.0005);
-if (dampening < 0.8){
-  dampening = 0.8;
+if (dampening < 0.6){
+  dampening = 0.6;
 }
 if (g_bGotTweet == true){
- dampening = .95;
+ dampening = 1.0;
 }

   // Orient the robot towards the object
-  if(monsterTimer <=190){
   g_poDataMonster->setPosture(location[0],  location[1],  location[2], location[3], location [4], g_bGotTweet);
-  }
-
+
 #endif

 }


swapped sonoff-dual relays

swapped sonoff-dual relays

--- sonoff-homie-dual/sonoff-homie-dual.ino
+++ sonoff-homie-dual/sonoff-homie-dual.ino
@@ -25,8 +25,8 @@

 void setRelays() {
   byte b = 0;
-  if (relay1) b++;
-  if (relay2) b += 2;
+  if (relay2) b++;
+  if (relay1) b += 2;

   Serial.write((byte)0xA0);
   Serial.write((byte)0x04);


Use Gas value for display

Use Gas value for display

--- e-kettcar.ino
+++ e-kettcar.ino
@@ -37,7 +37,7 @@
 void updateDisplay() {
   lcd.setCursor(0, 0);
   lcd.print("Geschw: ");
-  lcd.print(map(motor.getSpeed(), 0, 255, 0, 100));
+  lcd.print(map(smoothGas.getValue(), 0, 255, 0, 100));
   lcd.print("%   ");

   lcd.setCursor(0, 1);


v8.3 Minor clean-up

v8.3 Minor clean-up

--- WeatherDisplay.ino
+++ WeatherDisplay.ino
@@ -4,9 +4,6 @@
 //            12/29/16                                               //
 //     Based on the following:                                       //
 // http://educ8s.tv/art-deco-weather-forecast-display/               //
-//                                                                   //
-//     See the following for a description on JSON decoding:         //                                                    //
-// https://www.arduino.cc/en/Tutorial.WiFi101WeatherAudioNotifier    //
 //                                                                   //
 ///////////////////////////////////////////////////////////////////////

@@ -108,14 +105,8 @@

   if (counter >= GETDATACOUNT) //Get new data
   {
-    // If we lost WiFi connection (it sometimes happens), restart the nodeMCU
-    if (WiFi.status() != WL_CONNECTED) {
-      ESP.restart();
-    }
-    else {
-      counter = 0;
-      getWeatherData();
-    }
+    counter = 0;
+    getWeatherData();
   }
   else {
     counter++;
@@ -130,7 +121,7 @@
     Serial.println(counter);
 #endif
   }
-}
+} // loop

 void getWeatherData() //client function to send/receive GET request data.
 {
@@ -165,14 +156,16 @@
     char c = client.read(); // Gets byte from WIFI buffer
     result = result + c;
   }
-
   client.stop(); //stop client
+
+#ifdef DEBUG
+  Serial.println(result);
+#endif
   result.replace('[', ' ');
   result.replace(']', ' ');
-#ifdef DEBUG
-  Serial.println(result);
-#endif
-
+
+// See the following for a description on JSON decoding:
+// https://www.arduino.cc/en/Tutorial.WiFi101WeatherAudioNotifier
   char jsonArray [result.length() + 1];
   result.toCharArray(jsonArray, sizeof(jsonArray));
   jsonArray[result.length() + 1] = '\0';


v6.0 Enhance Weather Aux display

v6.0 Enhance Weather Aux display

--- WeatherDisplay.ino
+++ WeatherDisplay.ino
@@ -313,41 +313,73 @@
   tft.setTextSize(1);
   tft.setCursor(0, 0);
   tft.print("Location: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
   tft.println(location);
+  tft.setTextColor(textColor[randomColor]);
   tft.print("Temperature: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
   tft.print(temperature.toInt());
   tft.println(" F");
+  tft.setTextColor(textColor[randomColor]);
   tft.print("Humidity: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
   tft.print(humidity.toInt());
   tft.println("% RH");
-  tft.print("Weather ID ");
+  tft.setTextColor(textColor[randomColor]);
+  tft.print("Weather ID: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
   tft.println(weatherID);
+  tft.setTextColor(textColor[randomColor]);
   tft.print("Sky: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
   if ((sizeof("Sky: ") + description.length()) >= 21 /*Length of line*/) description.replace(' ', '\n');
   tft.println(description);
+  tft.setTextColor(textColor[randomColor]);
   tft.print("Wind Spd: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
   tft.print(windSpeed.toInt());
   tft.println(" Knots");
+  tft.setTextColor(textColor[randomColor]);
   tft.print("Wind Dir: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
   tft.print(windDirection.toInt());
   tft.println(" Degs");
-  tft.setTextColor(textColor[anotherRandomColor]);
+  tft.setTextColor(textColor[randomColor]);
   tft.print("Time LU: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
   tft.println(time);
+  tft.setTextColor(textColor[randomColor]);
   tft.print("UTC: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
   tft.println(timeUTC);
+  tft.setTextColor(textColor[randomColor]);
   tft.print("Date: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
   tft.println(dateS);
   tft.setTextColor(textColor[randomColor]);
   tft.print("Sunrise: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
   tft.print(rise);
   tft.println(":00am");
+  tft.setTextColor(textColor[randomColor]);
   tft.print("Sunset: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
   tft.print(set);
   tft.println(":00pm");
-  tft.println((DST) ? "It's DST" : "It's ST");
-  tft.println("Today is " + getDayOfWeek(dayOfWeek(yearI, monthI, dayI)));
-  tft.println((night) ? "It is Night time" : "It is Day time");
+  tft.setTextColor(textColor[randomColor]);
+  tft.print("It's ");
+  tft.setTextColor(textColor[anotherRandomColor]);
+  tft.println((DST) ? "DST" : "ST");
+  tft.setTextColor(textColor[randomColor]);
+  tft.print("Today is ");
+  tft.setTextColor(textColor[anotherRandomColor]);
+  tft.println(getDayOfWeek(dayOfWeek(yearI, monthI, dayI)));
+  tft.setTextColor(textColor[randomColor]);
+  tft.print("It is ");
+  tft.setTextColor(textColor[anotherRandomColor]);
+  tft.print((night) ? "Night " : "Day ");
+  tft.setTextColor(textColor[randomColor]);
+  tft.println("time");
 }

 // Displays the main weather


I have given up on commit messages. Deal with it.


Fix naming of member variables.

Fix naming of member variables.

--- examples/seq/seq.ino
+++ examples/seq/seq.ino
@@ -157,18 +157,18 @@
     widgets_slew_->attach_click_callback(s_slew_click_callback);
     container_outer_->attach_child(widgets_slew_, 5);

-    slew_filter = new DUINO_Filter(DUINO_Filter::LowPass, 1.0, 0.0);
-
-    stage = step = 0;
-    gate = false;
-
-    last_gate = false;
-    last_stage = 0;
-    last_diradd_mode = false;
-    last_reverse = false;
-    last_half_clock = false;
-
-    reverse = false;
+    slew_filter_ = new DUINO_Filter(DUINO_Filter::LowPass, 1.0, 0.0);
+
+    stage_ = step_ = 0;
+    gate_ = false;
+
+    last_gate_ = false;
+    last_stage_ = 0;
+    last_diradd_mode_ = false;
+    last_reverse_ = false;
+    last_half_clock_ = false;
+
+    reverse_ = false;

     Clock.begin();
     Clock.attach_clock_callback(clock_callback);
@@ -212,7 +212,7 @@
     {
       widget_save_->params.vals.slew_rate = SLEW_RATE_MAX / 2;
     }
-    slew_filter->set_frequency(slew_hz(widget_save_->params.vals.slew_rate));
+    slew_filter_->set_frequency(slew_hz(widget_save_->params.vals.slew_rate));

     if (widget_save_->params.vals.clock_bpm < 0 || widget_save_->params.vals.clock_bpm > CLOCK_BPM_MAX)
     {
@@ -231,7 +231,7 @@
     {
       widget_save_->params.vals.gate_time = GATE_TIME_MAX / 2;
     }
-    gate_ms = widget_save_->params.vals.gate_time * (uint16_t)(Clock.get_period() / GATE_TIME_DIV);
+    gate_ms_ = widget_save_->params.vals.gate_time * (uint16_t)(Clock.get_period() / GATE_TIME_DIV);

     // draw global elements
     for (uint8_t i = 0; i < 6; ++i)
@@ -286,12 +286,12 @@
   virtual void function_loop()
   {
     // cache stage, step, and clock gate (so that each loop is "atomic")
-    const uint8_t cached_stage = stage;
-    const uint8_t cached_step = step;
-    cached_clock_gate = Clock.state();
-    cached_retrigger = Clock.retrigger();
-
-    if (cached_retrigger)
+    const uint8_t cached_stage = stage_;
+    const uint8_t cached_step = step_;
+    cached_clock_gate_ = Clock.state();
+    cached_retrigger_ = Clock.retrigger();
+
+    if (cached_retrigger_)
     {
       // drop gate at start of stage
       if (!cached_step)
@@ -303,55 +303,55 @@
       gt_out(GT2, false);

       // update step clock time
-      clock_time = millis();
+      clock_time_ = millis();
     }

     // set gate state
     switch ((GateMode)(widget_save_->params.vals.stage_gate[cached_stage]))
     {
       case GATE_NONE:
-        gate = false;
+        gate_ = false;
         break;
       case GATE_1SHT:
         if (!cached_step)
         {
-          gate = partial_gate();
+          gate_ = partial_gate();
         }
         break;
       case GATE_REPT:
-        gate = partial_gate();
+        gate_ = partial_gate();
         break;
       case GATE_LONG:
         if (cached_step == widget_save_->params.vals.stage_steps[cached_stage] - 1)
         {
-          gate = partial_gate();
+          gate_ = partial_gate();
         }
         else
         {
-          gate = true;
+          gate_ = true;
         }
         break;
       case GATE_EXT1:
-        gate = gt_read(CI3);
+        gate_ = gt_read(CI3);
         break;
       case GATE_EXT2:
-        gate = gt_read(CI4);
+        gate_ = gt_read(CI4);
         break;
     }

     // set pitch CV state
     const float pitch_cv = note_to_cv(widget_save_->params.vals.stage_pitch[cached_stage]);
     const bool slew_on = (bool)((widget_save_->params.vals.stage_slew >> cached_stage) & 1);
-    cv_out(CO1, slew_on ? slew_filter->filter(pitch_cv) : pitch_cv);
+    cv_out(CO1, slew_on ? slew_filter_->filter(pitch_cv) : pitch_cv);

     // set gate and clock states
-    gt_out(GT1, gate);
-    gt_out(GT2, cached_clock_gate);
+    gt_out(GT1, gate_);
+    gt_out(GT2, cached_clock_gate_);

     // update reverse setting
     if (!widget_save_->params.vals.diradd_mode)
     {
-      reverse = gt_read(CI1);
+      reverse_ = gt_read(CI1);
     }

     // update half clock setting
@@ -360,39 +360,39 @@
     widget_loop();

     // display reverse/address
-    if (widget_save_->params.vals.diradd_mode != last_diradd_mode
-        || (!widget_save_->params.vals.diradd_mode && reverse != last_reverse)
-        || (widget_save_->params.vals.diradd_mode && stage != last_stage))
+    if (widget_save_->params.vals.diradd_mode != last_diradd_mode_
+        || (!widget_save_->params.vals.diradd_mode && reverse_ != last_reverse_)
+        || (widget_save_->params.vals.diradd_mode && stage_ != last_stage_))
     {
       display_reverse_address(30, 12);
-      last_diradd_mode = widget_save_->params.vals.diradd_mode;
-      last_reverse = reverse;
+      last_diradd_mode_ = widget_save_->params.vals.diradd_mode;
+      last_reverse_ = reverse_;
       Display.display(30, 34, 1, 2);
     }

     // display half clock
     const bool half_clock = Clock.get_divider() == 2;
-    if (half_clock != last_half_clock)
+    if (half_clock != last_half_clock_)
     {
       display_half_clock(41, 12, half_clock);
-      last_half_clock = half_clock;
+      last_half_clock_ = half_clock;
       Display.display(41, 51, 1, 2);
     }

     // display gate
-    if (gate != last_gate || stage != last_stage)
-    {
-      const uint8_t last_stage_cached = last_stage;
-      last_gate = gate;
-      last_stage = stage;
-
-      if (gate)
+    if (gate_ != last_gate_ || stage_ != last_stage_)
+    {
+      const uint8_t last_stage_cached = last_stage_;
+      last_gate_ = gate_;
+      last_stage_ = stage_;
+
+      if (gate_)
       {
-        if (stage != last_stage_cached)
+        if (stage_ != last_stage_cached)
         {
           display_gate(last_stage_cached, DUINO_SH1106::Black);
         }
-        display_gate(stage, DUINO_SH1106::White);
+        display_gate(stage_, DUINO_SH1106::White);
       }
       else
       {
@@ -400,7 +400,7 @@
       }

       Display.display(16 * last_stage_cached + 6, 16 * last_stage_cached + 9, 3, 3);
-      Display.display(16 * stage + 6, 16 * stage + 9, 3, 3);
+      Display.display(16 * stage_ + 6, 16 * stage_ + 9, 3, 3);
     }
   }

@@ -411,7 +411,7 @@

   void reset_callback()
   {
-    stage = step = 0;
+    stage_ = step_ = 0;
     Clock.reset();
   }

@@ -419,13 +419,13 @@
   {
     if (Clock.state())
     {
-      step++;
-      step %= widget_save_->params.vals.stage_steps[stage];
-      if (!step)
+      step_++;
+      step_ %= widget_save_->params.vals.stage_steps[stage_];
+      if (!step_)
       {
-        stage = widget_save_->params.vals.diradd_mode ? address_to_stage() : (reverse ?
-            (stage ? stage - 1 : widget_save_->params.vals.stage_count - 1) : stage + 1);
-        stage %= widget_save_->params.vals.stage_count;
+        stage_ = widget_save_->params.vals.diradd_mode ? address_to_stage() : (reverse_ ?
+            (stage_ ? stage_ - 1 : widget_save_->params.vals.stage_count - 1) : stage_ + 1);
+        stage_ %= widget_save_->params.vals.stage_count;
       }
     }
   }
@@ -469,7 +469,7 @@
   {
     if (adjust<int8_t>(widget_save_->params.vals.slew_rate, delta, 0, SLEW_RATE_MAX))
     {
-      slew_filter->set_frequency(slew_hz(widget_save_->params.vals.slew_rate));
+      slew_filter_->set_frequency(slew_hz(widget_save_->params.vals.slew_rate));
       widget_save_->mark_changed();
       widget_save_->display();
       Display.fill_rect(widget_slew_->x() + 2, widget_slew_->y() + 2, 16, 5, DUINO_SH1106::White);
@@ -483,7 +483,7 @@
   {
     if (adjust<int8_t>(widget_save_->params.vals.gate_time, delta, 0, GATE_TIME_MAX))
     {
-      gate_ms = widget_save_->params.vals.gate_time * (uint16_t)(Clock.get_period() / GATE_TIME_DIV);
+      gate_ms_ = widget_save_->params.vals.gate_time * (uint16_t)(Clock.get_period() / GATE_TIME_DIV);
       widget_save_->mark_changed();
       widget_save_->display();
       Display.fill_rect(widget_gate_->x() + 2, widget_gate_->y() + 2, 16, 5, DUINO_SH1106::White);
@@ -505,7 +505,7 @@
       {
         Clock.set_external();
       }
-      gate_ms = widget_save_->params.vals.gate_time * (uint16_t)(Clock.get_period() / GATE_TIME_DIV);
+      gate_ms_ = widget_save_->params.vals.gate_time * (uint16_t)(Clock.get_period() / GATE_TIME_DIV);
       widget_save_->mark_changed();
       widget_save_->display();
       Display.fill_rect(widget_clock_->x() + 1, widget_clock_->y() + 1, 17, 7, DUINO_SH1106::White);
@@ -614,9 +614,9 @@
 private:
   bool partial_gate()
   {
-    return (Clock.get_external() && cached_clock_gate)
-           || cached_retrigger
-           || ((millis() - clock_time) < gate_ms);
+    return (Clock.get_external() && cached_clock_gate_)
+           || cached_retrigger_
+           || ((millis() - clock_time_) < gate_ms_);
   }

   float note_to_cv(int8_t note)
@@ -700,11 +700,11 @@

     if (widget_save_->params.vals.diradd_mode)
     {
-      Display.draw_char(30, 12, '1' + stage, DUINO_SH1106::White);
+      Display.draw_char(30, 12, '1' + stage_, DUINO_SH1106::White);
     }
     else
     {
-      Display.draw_char(30, 12, 0x10 + (unsigned char)reverse, DUINO_SH1106::White);
+      Display.draw_char(30, 12, 0x10 + (unsigned char)reverse_, DUINO_SH1106::White);
     }
   }

@@ -719,9 +719,9 @@
     }
   }

-  void display_gate(uint8_t stage, DUINO_SH1106::Color color)
-  {
-    Display.fill_rect(16 * stage + 6, 26, 4, 4, color);
+  void display_gate(uint8_t stage_, DUINO_SH1106::Color color)
+  {
+    Display.fill_rect(16 * stage_ + 6, 26, 4, 4, color);
   }

   struct ParameterValues
@@ -750,23 +750,23 @@
   DUINO_MultiDisplayWidget<8> * widgets_gate_;
   DUINO_MultiDisplayWidget<8> * widgets_slew_;

-  DUINO_Filter * slew_filter;
-
-  volatile uint8_t stage, step;
-  volatile bool gate;
-
-  bool cached_clock_gate, cached_retrigger;
-  unsigned long clock_time;
-
-  bool last_gate;
-  uint8_t last_stage;
-  bool last_diradd_mode;
-  bool last_reverse;
-  bool last_half_clock;
-
-  bool reverse;
-
-  uint16_t gate_ms;
+  DUINO_Filter * slew_filter_;
+
+  volatile uint8_t stage_, step_;
+  volatile bool gate_;
+
+  bool cached_clock_gate_, cached_retrigger_;
+  unsigned long clock_time_;
+
+  bool last_gate_;
+  uint8_t last_stage_;
+  bool last_diradd_mode_;
+  bool last_reverse_;
+  bool last_half_clock_;
+
+  bool reverse_;
+
+  uint16_t gate_ms_;
 };

 DU_SEQ_Function * function;


Delete Movmement_code.ino

Delete Movmement_code.ino

--- Movmement_code.ino
+++ Movmement_code.ino
@@ -1,155 +0,0 @@
-void setup() {     //does not return anything
-  Serial.begin(9600);  // begin serial to computer
-
-
-
-  Serial3.begin(9600);    // begin serial to BASE ARDUINO
-  Serial1.begin(9600);    // begin serial to SD card
-
-
-  delay(100);  //delay of .1 seconds so that you do not compile errors
-  // find_red2();
-  // setTime(7,0,0,1,1,1);    // (hr,min,sec,day,month,yr)
-}
-
-void loop() {
- //float results[4];
-
- //Relative_ang(results,270);
-//
-//getData(results); /* the getData function should take a 'char *' paramenter */
-//
-//Serial.println(results[0]);
-//Serial.println(results[1]);
-//Serial.println(results[2]);
-//Serial.println(results[3]);
-//Serial.println("------------------------------------");
-//Serial.println("------------------------------------");
-//Serial.println("2: %i", results[1]);
-//Serial.println("3: %i", results[2]);
-//Serial.println("4: %i", results[3]);
-wheel_speeds(40,300);
-
-delay(1000);
-}
-
-
-//void getData(float *dest)
-//{
-//    dest[0] = 1;
-//    dest[1] = 2;
-//    dest[2] = 3;
-//    dest[3] = 4;
-//}
-//
-
-
-
-void wheel_speeds(float tot_spd, float ang){
-  float results[4];
-  Relative_ang(results,ang);
-
-  float Motor_2 = ((((-1/sqrt(3))*tan((results[0]/180)*M_PI))-1)*(tot_spd/(1/cos((results[0]/180)*M_PI))));
-  float Motor_1 = -1*((((1/sqrt(3))*tan((results[0]/180)*M_PI))-1)*(tot_spd/(1/cos((results[0]/180)*M_PI))));
-
-  float Motor_Comp = .0018*pow(results[0],3) - 0.1019*pow(results[0],2) + 2.446*results[0] + 0.8571;
-
-int a = abs(results[1])-1;
-int b = abs(results[2])-1;
-int c = abs(results[3])-1;
-
- float motors[3];
- motors[a]= (results[1]/(abs(results[1]))) * Motor_1;
- motors[b]= Motor_2;
- motors[c]= Motor_Comp;
-
-//Serial.println(results[0]);
-//Serial.println(results[1]);
-//Serial.println(results[2]);
-//Serial.println(results[3]);
-//Serial.println("------------------------------------");
-//Serial.println("--------------Motors---------------");
-//Serial.println("------------------------------------");
-//Serial.println(motors[0]);
-//Serial.println(motors[1]);
-//Serial.println(motors[2]);
-//Serial.println("------------------------------------");
-//Serial.println("--------------Results---------------");
-//Serial.println("------------------------------------");
-
-//   motospd(motors[0],motors[1],motors[2]); //At Min Speed, set compensator to 18.
-}
-
-
-void Relative_ang(float *ptr, float ang){
-//float a,b,c,d;
-// float new_config[4]={0,0,0,0};
-// float *ptr[4];
- float new_ang;
-
-
-    if(ang >= 0 && ang<= 30){
-      new_ang = ang;
-     //new_config = {new_ang, 3,2,1};
-      ptr[0] = new_ang;
-      ptr[1] = 3;
-      ptr[2] = 2;
-      ptr[3] = 1;
-
-    }
-     else if(ang >= 330 && ang<= 360){
-      new_ang = ang;
-     //new_config = {new_ang, 3,2,1};
-      ptr[0] = new_ang - 360;
-      ptr[1] = 3;
-      ptr[2] = 2;
-      ptr[3] = 1;
-
-    }
-    else if (ang > 30 && ang <= 90){
-     new_ang = ang - 60;
-    //new_config = {new_ang, -2,-1,3};
-     ptr[0] = new_ang;
-      ptr[1] = -2;
-      ptr[2] = -1;
-      ptr[3] = 3;
-    }
-    else if (ang > 90 && ang <= 150){
-      new_ang = ang - 120;
-     //new_config = {new_ang, 3,1,2};
-      ptr[0] = new_ang;
-      ptr[1] = 3;
-      ptr[2] = 1;
-      ptr[3] = 2;
-    }
-    else if(ang > 150 && ang<= 210){
-      new_ang = ang - 180;
-     // new_config = {new_ang, -3,-2,1};
-      ptr[0] = new_ang;
-      ptr[1] = -3;
-      ptr[2] = -2;
-      ptr[3] = 1;
-    }
-    else if(ang > 210 && ang<= 270){
-      new_ang = ang - 240;
-     // new_config = {new_ang, 2,1,3};
-      ptr[0] = new_ang;
-      ptr[1] = 2;
-      ptr[2] = 1;
-      ptr[3] = 3;
-    }
-    else if(ang > 270 && ang< 330){
-      new_ang = ang - 300;
-     // new_config = {new_ang, -3,-1,2};
-      ptr[0] = new_ang;
-      ptr[1] = -3;
-      ptr[2] = -1;
-      ptr[3] = 2;
-     }
-
-
- return 0;
-
-
-}
-


Delete GatewayRF4.ino

Delete GatewayRF4.ino

--- GatewayRF4.ino
+++ GatewayRF4.ino
@@ -1,80 +0,0 @@
-#include <ESP8266WiFi.h>
-#include <WiFiClient.h>
-#include <ESP8266WiFiMulti.h>
-#include <ESP8266mDNS.h>
-#include <ESP8266WebServer.h>   // Include the WebServer library
-#include <EX_RCSwitch.h>
-
-#define SERVER_PORT 80
-const int pulse = 360; //μs
-#define UP6_SIZE 67
-byte up6[] = {1,1,0,0,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0};
-#define pin 4  //GPIO4 = 2
-#define NUM_ATTEMPTS 3
-#define TRACE 1  // 0= trace off 1 = trace on Do we want to see trace for debugging purposes
-void trc(String msg);              // function prototypes
-void transmit_code(char code[]);
-
-
-mySwitch.enableTransmit(pin);
-mySwitch.setPulseLength(pulse);
-mySwitch.setRepeatTransmit(3);
-
-
-
-ESP8266WiFiMulti wifiMulti;     // Create an instance of the ESP8266WiFiMulti class, called 'wifiMulti'
-
-ESP8266WebServer server(80);    // Create a webserver object that listens for HTTP request on port 80
-
-void setup(void){
-  pinMode(pin,OUTPUT);
-  Serial.begin(115200);         // Start the Serial communication to send messages to the computer
-  delay(10);
-  Serial.println('\n');
-
-  wifiMulti.addAP("MTT_2.4", "999999999");   // add Wi-Fi networks you want to connect to
-
-  Serial.println("Connecting ...");
-  int i = 0;
-  while (wifiMulti.run() != WL_CONNECTED) { // Wait for the Wi-Fi to connect: scan for Wi-Fi networks, and connect to the strongest of the networks above
-    delay(250);
-    Serial.print('.');
-  }
-  Serial.println('\n');
-  Serial.print("Connected to ");
-  Serial.println(WiFi.SSID());              // Tell us what network we're connected to
-  Serial.print("IP address:\t");
-  Serial.println(WiFi.localIP());           // Send the IP address of the ESP8266 to the computer
-
-  if (MDNS.begin("esp8266")) {              // Start the mDNS responder for esp8266.local
-    Serial.println("mDNS responder started");
-  } else {
-    Serial.println("Error setting up MDNS responder!");
-  }
-  server.on("/", HTTP_GET, []() { transmit_code(up6);
-                                  server.send(200, "text/html", "<h1> Gateway Rf </h1> <p>"+server.uri()+"</p> ");
-                                });
-  server.onNotFound([]() { server.send(404, "text/plain", "404: Not Found"); });
-  server.begin();                           // Actually start the server
-  Serial.println("HTTP server started");
-
-
-
-
-}
-
-void loop(void){
-  server.handleClient();                    // Listen for HTTP requests from clients
-}
-
-// trace function
-void trc(String msg){if (TRACE) { Serial.println(msg); } }
-
-void transmit_code(byte code[]){
- // Examples where Pulse Length is not used
- mySwitch.send("0000011010100110100101100110010110101010100110101010");
-
- }
-
- trc("transmit preamble");
-}


changed pins assignment for ethernet shield compatibility

--- zamek.ino
+++ zamek.ino
@@ -41,11 +41,8 @@
 	#define BUFSIZE 6+LENGTH
 #endif

-//pin on bottom right at Atmega8, the first one PWM-enabled
-const int pinServo = 9;
-//pin above servo pin, the second one PWM-enabled
-const int pinPiezo = 10;
-const int pinLed = 13;
+const int pinServo = 5;
+const int pinPiezo = 6;

 const int pinButtonSwitch = 2;
 const int pinReedSwitch = 3;
@@ -76,8 +73,6 @@
 	//enable internal pull-ups
 	digitalWrite(pinButtonSwitch, HIGH);
 	digitalWrite(pinReedSwitch, HIGH);
-	//set mode output for led
-	pinMode(pinLed, OUTPUT);
 }

@@ -213,14 +208,12 @@
 }

 void unlockDoor(){
-	digitalWrite(pinLed, HIGH);
     servoDo(clockwise);
     isDoorLocked = false;
 }

 void lockDoor(){
 	cleanBuffer();
-	digitalWrite(pinLed, LOW);
 	servoDo(counterClockwise);
 	isDoorLocked = true;
 }


examples/send: Typo

examples/send: Typo

standard flame -> standard frame

--- examples/send/send.ino
+++ examples/send/send.ino
@@ -30,7 +30,7 @@
 unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
 void loop()
 {
-    // send data:  id = 0x00, standrad flame, data len = 8, stmp: data buf
+    // send data:  id = 0x00, standrad frame, data len = 8, stmp: data buf
     CAN.sendMsgBuf(0x00, 0, 8, stmp);
     delay(100);                       // send data per 100ms
 }


working ultrasonic

working ultrasonic

--- RosChatter.ino
+++ RosChatter.ino
@@ -16,6 +16,7 @@
 char msg[30];
 int messagedelay = 0;

+
 float ultrasonic(void) {
   digitalWrite(23, LOW);
   delayMicroseconds(2);
@@ -23,17 +24,17 @@
   delayMicroseconds(10);
   digitalWrite(23, LOW);

-  duration = pulseIn(22,HIGH,1740);   // 1740 uS => 30 cm
-  distacne_cm = duration / 58;
+  long duration = pulseIn(22,HIGH,1740);   // 1740 uS => 30 cm
+  long distance_cm = duration / 58;

-  if (distacne_cm > 0 && distacne_cm < 15) {
-    return 0;
+  if (distance_cm > 0 && distance_cm < 15) {
+    return 0.0;
   }
-  else if (distacne_cm < 30) {
-    return (distacne_cm-15)/15;
+  else if (distance_cm > 0 && distance_cm < 30) {
+    return (float) (distance_cm-15)/15.0;
   }
   else {
-    return 1;
+    return 1.0;
   }
 }

@@ -46,35 +47,44 @@
   int rot = (int)(twist_msg.angular.z * 255.0);
   lspd -= rot;
   rspd += rot;
+
+  //sprintf(msg, "lspd = %d", lspd);
+  //str_msg.data = msg;
+  //debug.publish(&str_msg);

-  dist_factor = (int) ultrasonic();
+  float dist_factor = ultrasonic();
+
+  lspd = (int) lspd * dist_factor;
+  rspd = (int) rspd * dist_factor;
+
+

   if (rspd > 255)
-    rspd = dist_factor * 255;
+    rspd = 255;
   if (rspd < -255)
-    rspd = dist_factor * -255;
+    rspd = -255;
   if (lspd > 255)
-    lspd = dist_factor * 255;
+    lspd = 255;
   if (lspd < -255)
-    lspd = dist_factor * -255;
+    lspd = -255;

-  sprintf(msg, "l=%d, r=%d", lspd, rspd);
-  str_msg.data = msg;
-  debug.publish(&str_msg);
+  //sprintf(msg, "factor = %d", dist_factor);
+  //str_msg.data = msg;
+  //debug.publish(&str_msg);

   if (lspd < 0) {
+    analogWrite(7, 0);
+    analogWrite(6, -lspd);
+  } else {
     analogWrite(6, 0);
-    analogWrite(7, -lspd);
-  } else {
-    analogWrite(7, 0);
-    analogWrite(6, lspd);
+    analogWrite(7, lspd);
   }
   if (rspd < 0) {
+    analogWrite(3, 0);
+    analogWrite(2, -rspd);
+  } else {
     analogWrite(2, 0);
-    analogWrite(3, -rspd);
-  } else {
-    analogWrite(3, 0);
-    analogWrite(2, rspd);
+    analogWrite(3, rspd);
   }
 }


correct sign of PID pitch output

correct sign of PID pitch output

--- Pegasus_vehicle/Pegasus_vehicle.ino
+++ Pegasus_vehicle/Pegasus_vehicle.ino
@@ -67,18 +67,19 @@

 // throttle-thrust correction
 CurveRemap tt;
+
 #define FLTTLENGTH 2
 unsigned short FL_tt_x[FLTTLENGTH] = {0,65535};
-unsigned short FL_tt_y[FLTTLENGTH] = {0,65535};
+unsigned short FL_tt_y[FLTTLENGTH] = {3195,65535};
 #define FRTTLENGTH 2
 unsigned short FR_tt_x[FRTTLENGTH] = {0,65535};
-unsigned short FR_tt_y[FRTTLENGTH] = {0,65535};
+unsigned short FR_tt_y[FRTTLENGTH] = {3195,65535};
 #define BRTTLENGTH 2
 unsigned short BR_tt_x[BRTTLENGTH] = {0,65535};
-unsigned short BR_tt_y[BRTTLENGTH] = {0,65535};
+unsigned short BR_tt_y[BRTTLENGTH] = {3195,65535};
 #define BLTTLENGTH 2
 unsigned short BL_tt_x[BLTTLENGTH] = {0,65535};
-unsigned short BL_tt_y[BLTTLENGTH] = {0,65535};
+unsigned short BL_tt_y[BLTTLENGTH] = {3195,65535};
 /*
 #define FLTTLENGTH 14
 unsigned short FL_tt_x[FLTTLENGTH] = {0,1843,25384,25465,26711,32691,37411,44993,45244,47404,53389,60687,62966,65535};
@@ -94,13 +95,12 @@
 unsigned short BL_tt_y[BLTTLENGTH] = {3195,3894,24949,26229,26919,28269,40086,44674,45374,46146,55350};
 */
 // timers
-//primes 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199
 unsigned long elapsed_ms;

 unsigned short longPeriod = 500;
 unsigned long lastLongTime = millis();

-byte loggerPeriod = 37;
+byte loggerPeriod = 40;
 unsigned long lastloggerTime = millis();

 byte midPeriod = 21;
@@ -246,21 +246,24 @@
     //print("Compass "); print(lastShortTimeMS); print(" ");print(accel.mx); print(" "); print(accel.y); print(" "); print(accel.z); print("\n");
     gyro.correctXY(accel.x, accel.y);
     //if(freshMag){ gyro.correctZ(accel.z); }
-    print("IMU "); print(lastShortTimeMS); print(" "); print(gyro.posX); print(" "); print(gyro.posY); print(" "); print(gyro.posZ); print("\n");
+    //print("IMU "); print(lastShortTimeMS); print(" "); print(gyro.posX); print(" "); print(gyro.posY); print(" "); print(gyro.posZ); print("\n");
     updateMotor();
   }

-  /*elapsed_ms = millis() - lastloggerTime;
+  elapsed_ms = millis() - lastloggerTime;
   if (elapsed_ms >= loggerPeriod) {
     lastloggerTime = millis();
-    if(ctrl.live){
+    /*if(ctrl.live){
         logger.append_IMU(lastloggerTime, gyro.posX, gyro.posY, gyro.posZ);
         logger.append_PID(lastloggerTime, op_roll, op_pitch, op_yaw);
-        //logger.append_MP(lastloggerTime, power_FL, power_FR, power_BR, power_BL);
-        //logger.append_RX(lastloggerTime, ctrl.rollf, ctrl.pitchf, ctrl.yawf, ctrl.throttle);
-        logger.writeOnFull();
-    }
-  }*/
+        logger.append_MP(lastloggerTime, power_FL, power_FR, power_BR, power_BL);
+        logger.append_RX(lastloggerTime, ctrl.rollf, ctrl.pitchf, ctrl.yawf, ctrl.throttle);
+        logger.writeOnFull();
+    }*/
+    print("IMU "); print(lastShortTimeMS); print(" "); print(gyro.posX); print(" "); print(gyro.posY); print(" "); print(gyro.posZ); print("\n");
+    print("PID "); print(lastShortTimeMS); print(" "); print(op_roll); print(" "); print(op_pitch); print(" "); print(op_yaw); print("\n");
+    print("MP "); print(lastShortTimeMS); print(" "); print(power_FL); print(" "); print(power_FR); print(" "); print(power_BR); print(" "); print(power_BL); print("\n");
+  }
 }

 bool checkRX() {
@@ -313,81 +316,73 @@

 void updateMotor() {
   // update PID & scale to power
-  //print("Roll "); print(ctrl.rollf); print(" - ");
+  //print("PID_R "); print(lastShortTimeMS); print(" "); print(ctrl.rollf); print(" ");
   switch (ctrl.navRotModeRoll) {
     case ctrl.FLY_STAB:
       op_roll = long(PID_roll.compute( ctrl.rollf, gyro.posX));
-      //print(gyro.posX); print("\n");
+      //print(gyro.posX); print(" ");
       break;
     case ctrl.FLY_ACRO:
       op_roll = long(PID_roll.compute( ctrl.rollf, gyro.rateX));
-      //print(gyro.rateX); print("\n");
+      //print(gyro.rateX); print(" ");
       break;
   }
-  //print("\t e:"); print(PID_roll.getError()); print(" * kP:"); print(ctrl.Kp_roll); print(" = "); print(ctrl.Kp_roll * PID_roll.getError()); print("\n")
-  //print("\t i:"); print(PID_roll.getIntegral()); print(" * kI:"); print(ctrl.Ki_roll); print(" = "); print(ctrl.Ki_roll * PID_roll.getIntegral()); print("\n")
-  //print("\t d:"); print(PID_roll.getDerivative()); print(" * kD:"); print(ctrl.Kd_roll); print(" = "); print(ctrl.Kd_roll * PID_roll.getDerivative()); print("\n")
-  //print("\t output:"); print(op_roll); print("\n");
-
-  //print("Pitch "); print(ctrl.pitchf); print(" - ");
+  //print(PID_roll.getError()); print(" "); print(ctrl.Kp_roll); print(" "); print(ctrl.Kp_roll * PID_roll.getError()); print(" ")
+  //print(PID_roll.getIntegral()); print(" "); print(ctrl.Ki_roll); print(" "); print(ctrl.Ki_roll * PID_roll.getIntegral()); print(" ")
+  //print(PID_roll.getDerivative()); print(" "); print(ctrl.Kd_roll); print(" "); print(ctrl.Kd_roll * PID_roll.getDerivative()); print(" ")
+  //print(op_roll); print("\n");
+
+  //print("PID_P "); print(lastShortTimeMS); print(" "); print(ctrl.pitchf); print(" ");
   switch (ctrl.navRotModePitch) {
     case ctrl.FLY_STAB:
       op_pitch = long(PID_pitch.compute( ctrl.pitchf, gyro.posY));
-      //print(gyro.posY); print("\n");
+      //print(gyro.posY); print(" ");
       break;
     case ctrl.FLY_ACRO:
       op_pitch = long(PID_pitch.compute( ctrl.pitchf, gyro.rateY));
-      //print(gyro.rateY); print("\n");
+      //print(gyro.rateY); print(" ");
       break;
   }
-  //print("\t e:"); print(PID_pitch.getError()); print(" * kP:"); print(ctrl.Kp_pitch); print(" = "); print(ctrl.Kp_pitch * PID_pitch.getError()); print("\n")
-  //print("\t i:"); print(PID_pitch.getIntegral()); print(" * kI:"); print(ctrl.Ki_pitch); print(" = "); print(ctrl.Ki_pitch * PID_pitch.getIntegral()); print("\n")
-  //print("\t d:"); print(PID_pitch.getDerivative()); print(" * kD:"); print(ctrl.Kd_pitch); print(" = "); print(ctrl.Kd_pitch * PID_pitch.getDerivative()); print("\n")
-  //print("\t output:"); print(op_pitch); print("\n");
-
-  //print("Yaw "); print(ctrl.yawf); print(" - ");
+  //print(PID_pitch.getError()); print(" "); print(ctrl.Kp_pitch); print(" "); print(ctrl.Kp_pitch * PID_pitch.getError()); print(" ")
+  //print(PID_pitch.getIntegral()); print(" "); print(ctrl.Ki_pitch); print(" "); print(ctrl.Ki_pitch * PID_pitch.getIntegral()); print(" ")
+  //print(PID_pitch.getDerivative()); print(" "); print(ctrl.Kd_pitch); print(" "); print(ctrl.Kd_pitch * PID_pitch.getDerivative()); print(" ")
+  //print(op_pitch); print("\n");
+
+  //print("PID_Y "); print(lastShortTimeMS); print(" "); print(ctrl.yawf); print(" ");
   switch (ctrl.navRotModeYaw) {
     case ctrl.FLY_STAB: // use angle position for "stable" mode
       op_yaw = long(PID_yaw.compute( ctrl.yawf, gyro.posZ));
-      //print(gyro.posZ); print("\n");
+      //print(gyro.posZ); print(" ");
       break;
     case ctrl.FLY_ACRO: // use angle rate for "acrobatic" mode
       op_yaw = long(PID_yaw.compute( ctrl.yawf, gyro.rateZ));
-      //print(gyro.rateZ); print("\n");
+      //print(gyro.rateZ); print(" ");
       break;
   }
-  //print("\t e:"); print(PID_yaw.getError()); print(" * kP:"); print(ctrl.Kp_yaw); print(" = "); print(ctrl.Kp_yaw * PID_yaw.getError()); print("\n")
-  //print("\t i:"); print(PID_yaw.getIntegral()); print(" * kI:"); print(ctrl.Ki_yaw); print(" = "); print(ctrl.Ki_yaw * PID_yaw.getIntegral()); print("\n")
-  //print("\t d:"); print(PID_yaw.getDerivative()); print(" * kD:"); print(ctrl.Kd_yaw); print(" = "); print(ctrl.Kd_yaw * PID_yaw.getDerivative()); print("\n")
-  //print("\t output:"); print(op_yaw); print("\n");
+  //print(PID_yaw.getError()); print(" "); print(ctrl.Kp_yaw); print(" "); print(ctrl.Kp_yaw * PID_yaw.getError()); print(" ")
+  //print(PID_yaw.getIntegral()); print(" "); print(ctrl.Ki_yaw); print(" "); print(ctrl.Ki_yaw * PID_yaw.getIntegral()); print(" ")
+  //print(PID_yaw.getDerivative()); print(" "); print(ctrl.Kd_yaw); print(" "); print(ctrl.Kd_yaw * PID_yaw.getDerivative()); print(" ")
+  //print(op_yaw); print("\n");

   op_throttle = ctrl.throttle;
-
+
   //    roll
   // fl-----fr
   // |  yaw  | pitch
   // bl-----br
-  power_FL = op_throttle - op_pitch + op_roll - op_yaw;
-  power_FR = op_throttle - op_pitch - op_roll + op_yaw;
-  power_BR = op_throttle + op_pitch - op_roll - op_yaw;
-  power_BL = op_throttle + op_pitch + op_roll + op_yaw;
-  power_FL = constrain(power_FL, 0, throttleMax);
-  power_FR = constrain(power_FR, 0, throttleMax);
-  power_BR = constrain(power_BR, 0, throttleMax);
-  power_BL = constrain(power_BL, 0, throttleMax);
+  power_FL = op_throttle + op_pitch + op_roll - op_yaw;
+  power_FR = op_throttle + op_pitch - op_roll + op_yaw;
+  power_BR = op_throttle - op_pitch - op_roll - op_yaw;
+  power_BL = op_throttle - op_pitch + op_roll + op_yaw;
   /*
   power_FL = tt.interp(power_FL, FL_tt_x, FL_tt_y, FLTTLENGTH);
   power_FR = tt.interp(power_FR, FR_tt_x, FR_tt_y, FRTTLENGTH);
   power_BR = tt.interp(power_BR, BR_tt_x, BR_tt_y, BRTTLENGTH);
   power_BL = tt.interp(power_BL, BL_tt_x, BL_tt_y, BLTTLENGTH);
   */
-  print("MP ");
-  print(lastShortTimeMS); print(" ");
-  print(power_FL); print(" ");
-  print(power_FR); print(" ");
-  print(power_BR); print(" ");
-  print(power_BL); print("\n");
-
+
+  //print("MP "); print(lastShortTimeMS); print(" "); print(power_FL); print(" "); print(power_FR); print(" "); print(power_BR); print(" "); print(power_BL); print("\n");
+
   if (ctrl.live) {
     esc.update(motorPin_FL, power_FL);
     esc.update(motorPin_FR, power_FR);


SerialThMeter: Modbus RTU support

SerialThMeter: Modbus RTU support


Add more transponders, also make changing transponder id easier


PW0 was not properly sent to slaves

PW0 was not properly sent to slaves

Before the heartbeat HB FF sequence began, Dongle didn't send PW0 to
slaves. The bug sometimes resulted in a strange state of all the slaves
are power on but the master off.

--- d_BacpacCommands.ino
+++ d_BacpacCommands.ino
@@ -1,4 +1,4 @@
-#define MEWPRO_VERSION_STRING "2015091800"
+#define MEWPRO_VERSION_STRING "2015100800"

 void cameraCommand()
 {
@@ -123,9 +123,7 @@
   case SET_CAMERA_POWER_STATE:
     if (recv[3] == 0) {
       if (!dontSendPW) {
-        if (heartBeatIsOn) { // send to slaves
-          Serial.println(F("PW00"));
-        }
+        Serial.println(F("PW00")); // send to slaves
         digitalWrite(BUILTINLED, HIGH);
         digitalWrite(HBUSRDY, LOW);
       }


Added comments to DHI sketch.

Added comments to DHI sketch.

--- dhi.ino
+++ dhi.ino
@@ -9,6 +9,9 @@
 MQTT mqtt(&esp);
 boolean wifiConnected = false;

+/**
+* Callback to deal with WiFi connection
+*/
 void wifiCb(void* response)
 {
   uint32_t status;
@@ -29,6 +32,9 @@
   }
 }

+/**
+* Callback to deal with MQTT server when connected
+*/
 void mqttConnected(void* response)
 {
   debugPort.println("Connected");
@@ -38,11 +44,17 @@

 }

+/**
+* Callback to deal with MQTT server when disconnection
+*/
 void mqttDisconnected(void* response)
 {
 	// What to do when disconnected.
 }

+/**
+* Callback to deal with MQTT server when data is received
+*/
 void mqttData(void* response)
 {
   // Parse response
@@ -62,11 +74,17 @@

 }

+/**
+* Callback to deal with MQTT server when published a message
+*/
 void mqttPublished(void* response)
 {
 	// What to do when published.
 }

+/**
+* Setup before main loop begins
+*/
 void setup() {
   // Setup Serial sockets:
   Serial.begin(19200);
@@ -107,6 +125,9 @@
   debugPort.println("ARDUINO: system started");
 }

+/**
+* Main loop
+*/
 void loop() {
   esp.process();
   if(wifiConnected) {


remove unneeded init call

remove unneeded init call

--- mocap_usbtext/mocap_usbtext.ino
+++ mocap_usbtext/mocap_usbtext.ino
@@ -12,7 +12,6 @@
   while (!Serial)
     ; // wait until somebody is there

-  sen.initialize();
   connection = sen.testConnection();
   Serial.println(  connection  ? "OK" : "FAILED");

@@ -43,7 +42,7 @@
    orientation_t *o =
        AHRSupdate(m.gx, m.gy, m.gz,
                   m.ax, m.ay, m.az,
-                  m.mx, m.my, m.mz,
+                  m.mx, m.my, -m.mz,
                   time/1e6);

    if (isnan(o->q0)) { // let's reset


Config.

Config.

--- sketch/arduino-butler/arduino-butler.ino
+++ sketch/arduino-butler/arduino-butler.ino
@@ -45,7 +45,7 @@
 #include "switch_controller.h"

 EthernetServer server(SERVER_PORT);
-SwitchCollection<11> switch_collection;
+SwitchCollection<15> switch_collection;

 void initialize_switches(RCSwitch* rc_switch) {
   CustomSwitch1::SetRCSwitch(rc_switch);
@@ -96,6 +96,22 @@
   PlainSwitchController<CustomSwitch1>* switch10 = new PlainSwitchController<CustomSwitch1>();
   switch10->Backend().Index(0).Modcode(1);
   switch_collection.SetSwitch(switch10, 10);
+
+  PlainSwitchController<CustomSwitch1>* switch11 = new PlainSwitchController<CustomSwitch1>();
+  switch11->Backend().Index(1).Modcode(1);
+  switch_collection.SetSwitch(switch11, 11);
+
+  PlainSwitchController<CustomSwitch1>* switch12 = new PlainSwitchController<CustomSwitch1>();
+  switch12->Backend().Index(2).Modcode(1);
+  switch_collection.SetSwitch(switch12, 12);
+
+  PlainSwitchController<CustomSwitch1>* switch13 = new PlainSwitchController<CustomSwitch1>();
+  switch13->Backend().Index(3).Modcode(1);
+  switch_collection.SetSwitch(switch13, 13);
+
+  PlainSwitchController<CustomSwitch1>* switch14 = new PlainSwitchController<CustomSwitch1>();
+  switch14->Backend().Index(0).Modcode(2);
+  switch_collection.SetSwitch(switch14, 14);
 }


Delete eliot_gr1.ino

Delete eliot_gr1.ino

--- eliot-demo-gr1/eliot_gr1/example/eliot_gr1/eliot_gr1.ino
+++ eliot-demo-gr1/eliot_gr1/example/eliot_gr1/eliot_gr1.ino
@@ -1,269 +0,0 @@
-/*
-  Main program used to connect a sensor to eliot using GR-1 extension
-*/
-#include <TheAirBoard.h>
-
-// Supported sensors: uncomment the one you want to use
-//#define TEMP 0x01         // Temperature & humidity grove sensor
-#define BAROMETER 0x02    // Barometer grove sensor
-//#define WATER 0x03        // Water level grove sensor
-//#define GPS 0x04          // Gps grove sensor
-//#define ULTRASONIC 0x05   // Ultrasonic ranger grove sensor
-//#define MOISTURE 0x06     // Moisture grove sensor
-//#define GAS 0x07          // Gas grove sensor
-//#define MOTION 0x08
-//#define GESTURE 0x09
-//#define ACCELEROMETER 0x0A
-//#define BUTTON 0x0B
-//#define LIGHT 0x0C
-//#define NUNCHUCK 0x0D
-//#define POTENTIOMETER 0x0E
-//#define LOUDNESS 0x0F
-
-// Supported networks: uncomment the one you want to use
-//#define LORA 0x01
-// #define SIGFOX 0x02
-#define WIFI 0x03
-
-// Uncomment to activate deep sleep (NOT IMPLEMENTED YET!)
-//#define DEEP_SLEEP
-
-// Uncomment to activate debug mode
-#define DEBUG
-
-/*
- * Sensors configuration
- */
-#ifdef TEMP
-#include <Eliot_temp.h>
-#define DATA_FREQ 10000
-int sensor_code = TEMP;
-#elif BAROMETER
-#include <Eliot_barometer.h>
-#define DATA_FREQ 30000
-int sensor_code = BAROMETER;
-#elif WATER
-#include <Eliot_water.h>
-#define DATA_FREQ 1000
-int sensor_code = WATER;
-#elif GPS
-#include <Eliot_gps.h>
-#define DATA_FREQ 10000
-int sensor_code = GPS;
-#elif ULTRASONIC
-#include <Eliot_ultrasonic.h>
-#define DATA_FREQ 2000
-int sensor_code = ULTRASONIC;
-#elif MOISTURE
-#include <Eliot_moisture.h>
-#define DATA_FREQ 10000
-int sensor_code = MOISTURE;
-#elif GAS
-#include <Eliot_gas.h>
-#define DATA_FREQ 1000
-int sensor_code = GAS;
-#elif LIGHT
-#include <Eliot_light.h>
-#define DATA_FREQ 1000
-int sensor_code = LIGHT;
-#elif LOUDNESS
-#include <Eliot_loudness.h>
-#define DATA_FREQ 1000
-int sensor_code = LOUDNESS;
-#endif
-
-/*
- * Wireless configuration
- */
-#ifdef LORA
-#include "Eliot_lora.h"
-Eliot_lora wireless;
-#define PERIOD 120000
-#elif SIGFOX
-#include "Eliot_sigfox.h"
-Eliot_sigfox wireless;
-#define PERIOD 600000
-#elif WIFI
-#include "Eliot_wifi.h"
-Eliot_wifi wireless;
-char ssid[32] = "eliot4plexus_zero";
-char pwd[32] = "0CAFFED00D0";
-#define PERIOD 60000
-#endif
-
-/*
- * Uncomment to activate debug
- */
-#ifdef DEBUG
-#include <SoftwareSerial.h>
-SoftwareSerial debug(7, 8);
-#endif
-
-// Experimentation values
-#define EXPERIMENTATION 0x00
-#define DEVICE_CODE 0X00
-
-Eliot_sensor sensor;
-TheAirBoard board;
-
-void setup() {
-#ifdef DEBUG
-  debug.begin(9600);
-  debug.print(F("["));
-  debug.print(millis());
-  debug.println(F("] Start setup"));
-#endif
-  init_board();
-  sensor.init();
-  sensor.set_frequency(DATA_FREQ);
-#ifdef WIFI
-  wireless.set_params(ssid, pwd);
-#endif
-  wireless.init();
-  wireless.set_interval(PERIOD);
-  read_from_sensor();
-  send_data();
-#ifdef DEBUG
-  debug.print(F("["));
-  debug.print(millis());
-  debug.println(F("] End setup"));
-  debug.println();
-#endif
-}
-
-void loop() {
-  unsigned long start = millis();
-#ifdef DEBUG
-  debug.print(F("["));
-  debug.print(start);
-  debug.println(F("] Start loop"));
-#endif
-
-  // Reading loop
-  while ((millis() - start) < wireless.get_interval()) {
-    read_from_sensor();
-    delay(sensor.get_frequency());
-  }
-  send_data();
-#ifdef DEBUG
-  unsigned long real = millis() - start;
-  debug.print(F("["));
-  debug.print(millis());
-  debug.print(F("] End of loop with duration: "));
-  debug.println(real);
-  debug.println();
-#endif
-}
-
-void read_from_sensor(){
-#ifdef DEBUG
-    debug.print(F("["));
-    debug.print(millis());
-    debug.print(F("] Reading data from sensor, result code: "));
-#endif
-    short result = sensor.read();
-#ifdef DEBUG
-    debug.println(result);
-#endif
-}
-
-void send_data(){
-  // Get data from sensor
-#ifdef DEBUG
-  debug.println();
-  debug.print(F("["));
-  debug.print(millis());
-  debug.println(F("] Getting data from sensor..."));
-#endif
-  int data[10];
-  short lenght = sensor.get_data(data);
-  // Send data to wireless module
-  float b = board.batteryChk();
-  int batt = int(b * 100);
-#ifdef DEBUG
-  debug.print(F("["));
-  debug.print(millis());
-  debug.print("] Data count: ");
-  debug.println(lenght);
-  debug.print(F("["));
-  debug.print(millis());
-  debug.print("] Data: ");
-  for(int i=0; i<lenght; i++){
-    debug.print(data[i]);
-    debug.print(" ");
-  }
-  debug.println();
-  debug.print(F("["));
-  debug.print(millis());
-  debug.print("] Battery: ");
-  debug.print(b);
-  debug.println(F("V"));
-  debug.print(F("["));
-  debug.print(millis());
-  debug.println("] Start sending data...");
-#endif
-  short result = wireless.send(EXPERIMENTATION, DEVICE_CODE, batt, sensor_code, lenght, data);
-#ifdef DEBUG
-  debug.print(F("["));
-  debug.print(millis());
-  debug.println(F("Results:"));
-  debug.print(F("["));
-  debug.print(millis());
-  debug.print(F("] Data from sensor: "));
-  for (int i = 0; i < lenght; i++) {
-    debug.print(data[i]);
-    debug.print(" ");
-  }
-  debug.println();
-  debug.print(F("["));
-  debug.print(millis());
-  debug.print("] Result code: ");
-  debug.println(result);
-  debug.println();
-#endif
-  // Show data sending result
-  if (result == 1) {
-    show(GREEN, 3);
-  } else if (result == 0) {
-    show(RED, 3);
-  } else {
-    show(RED, 5);
-  }
-}
-
-// Method to initialize The AirBoard
-void init_board() {
-  // Init The AirBoard pins
-  pinMode(RED, OUTPUT);
-  pinMode(GREEN, OUTPUT);
-  pinMode(BLUE, OUTPUT);
-  pinMode(RF, OUTPUT);
-  digitalWrite(RED, LOW);
-  digitalWrite(GREEN, LOW);
-  digitalWrite(BLUE, LOW);
-
-  // Blink LEDs
-  digitalWrite(RED, HIGH);
-  delay(500);
-  digitalWrite(RED, LOW);
-  delay(500);
-  digitalWrite(GREEN, HIGH);
-  delay(500);
-  digitalWrite(GREEN, LOW);
-  delay(500);
-  digitalWrite(BLUE, HIGH);
-  delay(500);
-  digitalWrite(BLUE, LOW);
-  delay(500);
-}
-
-// Method to use red, green or blue led to show an operation result
-void show(short led, short time) {
-  for (int i = 0; i < time; i++) {
-    digitalWrite(led, HIGH);
-    delay(500);
-    digitalWrite(led, LOW);
-    delay(500);
-  }
-}
-


Update RF24MeshMaster.ino

Update RF24MeshMaster.ino

--- examples/NanoRFMeshNet/RF24MeshMaster/RF24MeshMaster.ino
+++ examples/NanoRFMeshNet/RF24MeshMaster/RF24MeshMaster.ino
@@ -21,7 +21,7 @@
 #include <EEPROM.h>

 /***** Configure the chosen CE,CS pins *****/
-RF24 radio(10, 9);//NanoRF (7,8)
+RF24 radio(7, 8);//NanoRF (7,8)
 RF24Network network(radio);
 RF24Mesh mesh(radio, network);


updated the delay time

updated the delay time

--- src/SerialPrint/SerialPrint.ino
+++ src/SerialPrint/SerialPrint.ino
@@ -8,7 +8,7 @@
 DeviceAddress red   = { 0x28, 0xFF, 0xA9, 0xB4, 0x62, 0x15, 0x03, 0x0C };
 DeviceAddress green = { 0x28, 0xFF, 0xF5, 0xB3, 0x62, 0x15, 0x03, 0x3E };

-const int delayTime = 500;
+const int delayTime = 1000;

 void setup() {
   Serial.begin(9600);


Update sketch.ino

Update sketch.ino

--- dragino/sketch.ino
+++ dragino/sketch.ino
@@ -1,3 +1,14 @@
+//Hello!, this is a sketch to get remote control to your dragino device by bridge mode
+//The original source and Pubsubclient code comes from:
+//https://github.com/knolleary/pubsubclient
+//this is a modified sketch from those repository
+//
+//Hola ! Este es un sketch de prueba para tomar control remoto de su dispositivo dragino en modo bridge
+//la libreria Pubsubclient.* y el codigo fuente proviene desde:
+//https://github.com/knolleary/pubsubclient
+//y este es un sketch modificado desde el repositorio origen y adaptado para funcionar con nuestra
+//plataforma ior.redlibre.cl
+
 #include <SPI.h>
 #include <PubSubClient.h>
 #include <YunClient.h>


issue data reading

issue data reading

needs further debugging
are all variables being read?

--- arduino_control/arduino_control.ino
+++ arduino_control/arduino_control.ino
@@ -31,7 +31,6 @@

 // Statemachine State variable and initial value
 byte State = Startup;
-byte variables = Position;

 // the cs pin of the version after v1.1 is default to D9
 // v0.9b and v1.0 is default D10
@@ -323,9 +322,21 @@

     switch (canId)
     {
+      case 0x181:
+        Serial.println("-----------------------------");
+        Serial.print("CORRENTE: ");
+        Serial.println(canId, HEX);
+
+        for(int i = 0; i<len; i++)    // print the data
+        {
+            Serial.print(buf[i], HEX);
+            Serial.print("\t");
+        }
+        Serial.println();
+        break;
       case 0x381:
         Serial.println("-----------------------------");
-        Serial.print("POSICAO");
+        Serial.print("POSICAO: ");
         Serial.println(canId, HEX);

         for(int i = 0; i<len; i++)    // print the data
@@ -337,7 +348,7 @@
         break;
       case 0x321:
         Serial.println("-----------------------------");
-        Serial.print("AMPLIFICACAO");
+        Serial.print("AMPLIFICACAO: ");
         Serial.println(canId, HEX);

         for(int i = 0; i<len; i++)    // print the data
@@ -347,19 +358,7 @@
         }
         Serial.println();
         break;
-      case 0x181:
-        Serial.println("-----------------------------");
-        Serial.print("CORRENTE");
-        Serial.println(canId, HEX);
-
-        for(int i = 0; i<len; i++)    // print the data
-        {
-            Serial.print(buf[i], HEX);
-            Serial.print("\t");
-        }
-        Serial.println();
-        break;
-    }
+      }
   }
 }


Must initialize gate time after clock.

Must initialize gate time after clock.

--- examples/seq/seq.ino
+++ examples/seq/seq.ino
@@ -268,12 +268,6 @@
     }
     seq_values.slew_rate = params.vals.slew_rate;

-    if(params.vals.gate_time < 0 || params.vals.gate_time > 16)
-    {
-      params.vals.gate_time = 8;
-    }
-    seq_values.gate_ms = params.vals.gate_time * (uint16_t)(seq_values.clock_period / 8000);
-
     if(params.vals.clock_bpm < 0 || params.vals.clock_bpm > 30)
     {
       params.vals.clock_bpm = 0;
@@ -282,6 +276,12 @@
     seq_values.clock_ext = !(bool)params.vals.clock_bpm;
     Timer1.initialize();
     update_clock();
+
+    if(params.vals.gate_time < 0 || params.vals.gate_time > 16)
+    {
+      params.vals.gate_time = 8;
+    }
+    seq_values.gate_ms = params.vals.gate_time * (uint16_t)(seq_values.clock_period / 8000);

     // draw global elements
     for(uint8_t i = 0; i < 6; ++i)


Print out the accessory state to the terminal

--- Accessory_Controller/Accessory_Controller.ino
+++ Accessory_Controller/Accessory_Controller.ino
@@ -327,5 +327,20 @@
   else text += "Unknown";
   text += "       \n";

+  text += "Aux Lights: ";
+  if ( aux_light_state == Aux_Light_Off ) text += "OFF";
+  else if ( aux_light_state == Aux_Light_Low ) text += "LOW";
+  else if ( aux_light_state == Aux_Light_Low ) text += "HIGH";
+  text += "   \n";
+
+  text += "Jacket: ";
+  if ( heated_jacket_state == Heated_Jacket_State_Off ) text += "OFF";
+  else if ( heated_jacket_state == Heated_Jacket_State_1 ) text += "1";
+  else if ( heated_jacket_state == Heated_Jacket_State_2 ) text += "2";
+  else if ( heated_jacket_state == Heated_Jacket_State_3 ) text += "3";
+  else if ( heated_jacket_state == Heated_Jacket_State_4 ) text += "4";
+  else if ( heated_jacket_state == Heated_Jacket_State_5 ) text += "5";
+  text += "   \n";
+
   Serial.println(text);
 }


Moving one by one version

Moving one by one version

--- code/arduino/_1rev/_1rev.ino
+++ code/arduino/_1rev/_1rev.ino
@@ -1,66 +1,90 @@
 #include <AccelStepper.h>
+
+boolean calibrated = false;

 // Steppers 1, 2 and 4 on big easy driver, stepper 3 on easydriver

-String s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";
+String s0 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";
+String s1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";
+String s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";
+String s3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";

-AccelStepper stepper1(1,12,13);
-AccelStepper stepper2(1,10,11);
-AccelStepper stepper3(1,6,7);
-AccelStepper stepper4(1,8,9);
-
-boolean calibrated = false;
+AccelStepper stepper0(1,12,13);
+AccelStepper stepper1(1,10,11);
+AccelStepper stepper2(1,6,7);
+AccelStepper stepper3(1,8,9);

 char serialdata[4];
-    int lf = 10;
+int lf = 10;

 void setup()
 {
-   Serial.begin(9600);
-   Keyboard.begin();
-   while (!Serial) {
+  Serial.begin(9600);
+  Keyboard.begin();
+  while (!Serial) {
     ; // wait for serial port to connect. Needed for Leonardo only
   }
+
+  Serial.write("Flip-Flap Ready!");
+  Serial.println("Enter the 4 characters that the flipflap is displaying:");

-  Serial.write("Flip-Flap Ready!");
-      Serial.println("Enter the 4 characters that the flipflap is displaying:");
+  stepper0.setMaxSpeed(12000);
+  stepper0.setAcceleration(24000.0);
+  stepper1.setMaxSpeed(12000);
+  stepper1.setAcceleration(24000.0);
+  stepper2.setMaxSpeed(12000);
+  stepper2.setAcceleration(24000.0);
+  stepper3.setMaxSpeed(12000);
+  stepper3.setAcceleration(24000.0);
+}

-   stepper1.setMaxSpeed(12000);
-   stepper1.setAcceleration(24000.0);
-
-   stepper2.setMaxSpeed(12000);
-   stepper2.setAcceleration(24000.0);
-
-   stepper3.setMaxSpeed(12000);
-   stepper3.setAcceleration(24000.0);
-
-   stepper4.setMaxSpeed(12000);
-   stepper4.setAcceleration(24000.0);
-}
 void loop()
 {
-   if (Serial.available() > 0) {
+  if (Serial.available() > 0) {

     Serial.readBytesUntil(lf, serialdata, 4);

-    char inChar = serialdata[3];
-    int p = s.indexOf(inChar);
-
+    int p0 = s0.indexOf(0);
+    int p1 = s1.indexOf(1);
+    int p2 = s2.indexOf(2);
+    int p3 = s3.indexOf(3);
+
+    Serial.println(p0);
+    Serial.println(p1);
+    Serial.println(p2);
+    Serial.println(p3);
+
     if (calibrated) {
       // read incoming serial data:
-      if (p >= 0) {
-        stepper1.runToNewPosition(480 * p);
+      if (p0 >= 0) {
+        stepper0.runToNewPosition(480 * p0);
+        stepper0.setCurrentPosition(0);
+        s0 = s0.substring(p0) + s0.substring(0,p0);
+      }
+      if (p1 >= 0) {
+        stepper1.runToNewPosition(480 * p1);
         stepper1.setCurrentPosition(0);
-        s = s.substring(p) + s.substring(0,p);
-      } else if (inChar == '`') {
-        stepper1.runToNewPosition(480);
-        stepper1.setCurrentPosition(0);
+        s1 = s1.substring(p1) + s1.substring(0,p1);
+      }
+      if (p2 >= 0) {
+        stepper2.runToNewPosition(480 * p2);
+        stepper2.setCurrentPosition(0);
+        s2 = s2.substring(p2) + s2.substring(0,p2);
+      }
+      if (p3 >= 0) {
+        stepper3.runToNewPosition(480 * p3);
+        stepper3.setCurrentPosition(0);
+        s3 = s3.substring(p3) + s3.substring(0,p3);
       }
     } else {
-      s = s.substring(p) + s.substring(0,p);
+      s0 = s0.substring(p0) + s0.substring(0,p0);
+      s1 = s1.substring(p1) + s1.substring(0,p1);
+      s2 = s2.substring(p2) + s2.substring(0,p2);
+      s3 = s3.substring(p2) + s3.substring(0,p3);
       calibrated = true;
     }
-
+
   }

 }
+


Changing pin mode has immediate effects now.

git-svn-id: d8bfcd070c2c81762cca1b3912331324182919ba@16119 0d6f1817-ed0e-0410-87c9-987e46238f29

--- zimodem/zcommand.ino
+++ zimodem/zcommand.ino
@@ -2126,7 +2126,7 @@
              case 56:
                pinModeDecoder(sval,&dsrActive,&dsrInactive,DEFAULT_DSR_HIGH,DEFAULT_DSR_LOW);
                if(pinSupport[pinDSR])
-                 digitalWrite(pinDSR,riActive);
+                 digitalWrite(pinDSR,dsrActive);
                break;
              case 57:
                if((sval >= 0) && (sval <= MAX_PIN_NO) && pinSupport[sval])
@@ -2134,7 +2134,7 @@
                else
                  result=ZERROR;
                if(pinSupport[pinDSR])
-                 digitalWrite(pinDSR,riActive);
+                 digitalWrite(pinDSR,dsrActive);
                break;
              case 60:
                if(sval >= 0)


[feat] Preparing to have multiple counter inputs. Now also counter and advance ad measurement sending to IoT cloud.

--- heater_control.ino
+++ heater_control.ino
@@ -12,6 +12,7 @@

 #define AD_SAMPLECNT 10
 #define FLAGS_DATACHANGE 0x01
+#define FLAGS_TIMEOUT 0x02

 byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
 // mx2 credentials are stored with a tcpip config connection
@@ -146,6 +147,7 @@
 {
   static int cnt=0;
   boolean timeouts=false;
+  boolean cntTimeouts,cntChanges;
   boolean changes=false;
   time_t ts=now();
   int chcnt=(sizeof(adArr) / sizeof(struct ad));
@@ -156,13 +158,18 @@
   cnt++;
   if ((cnt % AD_SAMPLECNT)==0) {
     sched.oscillate(13,150, LOW,2);
-    timeouts=chkAdTimeouts(adArr,chcnt, ts, false);
+    cntTimeouts=chkCntTimeouts(ts,false);
+    cntChanges=chkCntChanged();
+    timeouts=chkAdTimeouts(adArr,chcnt, ts, (cntTimeouts || cntChanges));
     changes=chkAdChange(adArr,chcnt);
-    // if there is something to send, advance other channel sends
+    // if there is something to send, advance other channel sends,
     // in case they are enough near with timeout. This way we get
-    // more values to send in same packet.
-    if (timeouts || changes)
+    // more values to send in same m2x packet.
+    if (timeouts || changes) {
+      if (!cntTimeouts)
+	chkCntTimeouts(ts,true);
       chkAdTimeouts(adArr,chcnt, ts, true);
+    }
     calcAdChannels(adArr,chcnt);
     calcKw();
     sendM2X(adArr,chcnt);
@@ -246,6 +253,44 @@
   cntArr[index].prevsnd.analog=cntArr[index].measured.analog;
   cntArr[index].avg_samples=0;
   cntArr[index].avg_counter=0;
+  cntArr[index].flags &= ~FLAGS_DATACHANGE;
+  cntArr[index].flags &= ~FLAGS_TIMEOUT;
+}
+
+boolean chkCntTimeouts(time_t ts,boolean advance)
+{
+  boolean ret=false;
+  int timeout;
+
+  timeout= measTimeout;
+  if (advance)
+    timeout-=300;
+
+  for (int i=0;i<(sizeof(cntArr) / sizeof(struct cnt)); i++) {
+    if (ts-cntArr[i].last_send > timeout) {
+      cntArr[i].flags |= FLAGS_TIMEOUT;
+      ret=true;
+    }
+  }
+  return ret;
+}
+
+boolean chkCntChanged()
+{
+  float limit;
+  bool changed;
+  float diff;
+  boolean ret=false;
+
+  for (int i=0;i<(sizeof(cntArr) / sizeof(struct cnt));i++) {
+    diff = abs(cntArr[i].measured.analog-cntArr[i].prevsnd.analog);
+    limit = cntArr[i].diff.analog * (1.0 + cntArr[i].measured.analog * cntArr[i].diff_factor.analog);
+    if (diff > limit) {
+      cntArr[i].flags |= FLAGS_DATACHANGE;
+      ret=true;
+    }
+  }
+  return ret;
 }

 void sendM2X(struct ad *ad,int cnt)
@@ -253,9 +298,8 @@
   char chbuf[22];
   char prevtime[22];
   int response;
-  boolean timeout=false;
   time_t ts;
-  boolean sendingad=false;
+  float val;

   ts=now();
   buildTime(ts,chbuf);
@@ -267,51 +311,41 @@
       iot.name(ad[chan].name);
       iot.addValue(ad[chan].measured.analog,chbuf);
       iot.next();
-      sendingad=true;
     }
   }

   // counter build part
-  if (sendingad) // if already sending ad values, add counters a bit earlier to same packet
-    timeout=(ts-cntArr[0].last_send > measTimeout-300);
-  else
-    timeout=(ts-cntArr[0].last_send > measTimeout);
-  float diff=abs(cntArr[0].measured.analog-cntArr[0].prevsnd.analog);
-  bool changed;
-  float limit;
-  float val;
-
-  limit = cntArr[0].diff.analog * (1.0 + cntArr[0].measured.analog * cntArr[0].diff_factor.analog);
-  changed=(diff > limit);
-  if (changed) {
-    if (ts-cntArr[0].last_send > 30) {
-      if (cntArr[0].avg_samples > 3) {
-        // calculate average from previous samples
-	val=(cntArr[0].avg_counter / cntArr[0].avg_samples) / (cntArr[0].scale.digital * cntArr[0].scale.analog);
+  for (int i=0;i<(sizeof(cntArr) / sizeof(struct cnt));i++) {
+    if (cntArr[i].flags & FLAGS_DATACHANGE) {
+      if (ts-cntArr[i].last_send > 30) { // value changed and there is more than 30 seconds after prev
+	if (cntArr[i].avg_samples > 3) {
+	  // calculate average from previous samples
+	  val=(cntArr[i].avg_counter / cntArr[i].avg_samples) / (cntArr[i].scale.digital * cntArr[i].scale.analog);
+	}
+	else
+	  val=cntArr[i].prev.analog;
+
+	buildTime(ts-10,prevtime);
+	iot.name(cntArr[i].name);
+	iot.addValue(val,prevtime);
+	iot.addValue(cntArr[i].measured.analog,chbuf);
+	iot.next();
+	cntPrepareForNext(i,ts);
       }
-      else
-	val=cntArr[0].prev.analog;
-
-      buildTime(ts-10,prevtime);
-      iot.name(cntArr[0].name);
-      iot.addValue(val,prevtime);
-      iot.addValue(cntArr[0].measured.analog,chbuf);
+      else { // value changed quicly after prev
+	iot.name(cntArr[i].name);
+	iot.addValue(cntArr[i].measured.analog,chbuf);
+	iot.next();
+	cntPrepareForNext(i,ts);
+      }
+    }
+    else if (cntArr[i].flags & FLAGS_TIMEOUT) { // no big changes, only timeout
+      val=(cntArr[i].avg_counter / cntArr[i].avg_samples) / (cntArr[i].scale.digital * cntArr[i].scale.analog);
+      iot.name(cntArr[i].name);
+      iot.addValue(val,chbuf);
       iot.next();
-      cntPrepareForNext(0,ts);
-     }
-    else {
-      iot.name(cntArr[0].name);
-      iot.addValue(cntArr[0].measured.analog,chbuf);
-      iot.next();
-      cntPrepareForNext(0,ts);
-    }
-  }
-  else if (timeout) {
-    val=(cntArr[0].avg_counter / cntArr[0].avg_samples) / (cntArr[0].scale.digital * cntArr[0].scale.analog);
-    iot.name(cntArr[0].name);
-    iot.addValue(val,chbuf);
-    iot.next();
-    cntPrepareForNext(0,ts);
+      cntPrepareForNext(i,ts);
+    }
   }


keep state consistent while debugging

keep state consistent while debugging

--- particle/examples/local-compile/local-compile.ino
+++ particle/examples/local-compile/local-compile.ino
@@ -112,7 +112,7 @@
     Serial.print(configSize);
     Serial.print(F(" bytes written while broadcasting pins"));
   }
-
+
   Spark.process();
 }

@@ -129,6 +129,8 @@
 }

 void connectToServer() {
+  hasAuthenticated = false;
+
   Serial.println(F("Connecting to the server."));
   Serial.flush();

@@ -143,6 +145,7 @@
 }

 void connectToLocalServer() {
+  hasAuthenticated = false;
   Serial.println(F("Connecting to local server."));
   Serial.flush();


license

license

--- dev/utils/motorTest/motorTest.ino
+++ dev/utils/motorTest/motorTest.ino
@@ -1,4 +1,22 @@
-/**
+/*
+The OpenTRV project licenses this file to you
+under the Apache Licence, Version 2.0 (the "Licence");
+you may not use this file except in compliance
+with the Licence. You may obtain a copy of the Licence at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the Licence is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the Licence for the
+specific language governing permissions and limitations
+under the Licence.
+
+Author(s) / Copyright (s): Deniz Erbilgin 2016
+*/
+
+/*
  * @brief Test the DRV8850 for basic functioning using a REV11.
  */


Fixed unexpected HTTP/1.0 (closes #944)

Fixed unexpected HTTP/1.0 (closes #944)

--- examples/JsonHttpClient/JsonHttpClient.ino
+++ examples/JsonHttpClient/JsonHttpClient.ino
@@ -59,7 +59,8 @@
   // Check HTTP status
   char status[32] = {0};
   client.readBytesUntil('\r', status, sizeof(status));
-  if (strcmp(status, "HTTP/1.1 200 OK") != 0) {
+  // It should be "HTTP/1.0 200 OK" or "HTTP/1.1 200 OK"
+  if (strcmp(status + 9, "200 OK") != 0) {
     Serial.print(F("Unexpected response: "));
     Serial.println(status);
     return;


Reworked INO file

Reworked INO file


Corrected and error where the data bit is captured
to stop overun errors at th eend of bytes causing
the whole packet to be dumped.

It shoudl read the last bit of the last byte without,
what happens after that wrecking it.

--- DebugManchester.ino
+++ DebugManchester.ino
@@ -1,16 +1,12 @@
 /*
  Manchester Decoding, reading by delay rather than interrupt
- Rob Ward July 2014
+ Rob Ward August 2014
  This example code is in the public domain.
  Use at your own risk, I will take no responsibility for any loss whatsoever its deployment.
  Visit https://github.com/robwlakes/ArduinoWeatherOS for the latest version and
- documentation. Filename: DebugManchester.ino ReadMe: DebugMan.md
-
- NB: Choosing the wrong polarity will still provide "data", but will be incorrect
- even thought the two delays are working properly!!!
- Remember to check both Polarity settings for sensible data.
+ documentation. Filename: DebugManchester.ino

- DebugVersion_09, 28tyh July 2014
+ DebugVersion_10, 1stAugust 2014

  */

@@ -19,11 +15,10 @@
 int ledPin          = 13;  //The number of the onboard LED pin

 // Variables for Manchester Receiver Logic:
-word    sDelay     = 240;  //Small Delay about 1/4 of bit duration try like 220 to 480
-word    lDelay     = 480;  //Long Delay about 1/2 of bit duration  try like 440 to 880, 1/4 + 1/2 = 3/4
+word    sDelay     = 250;  //Small Delay about 1/4 of bit duration  try like 250 to 500
+word    lDelay     = 500;  //Long Delay about 1/2 of bit duration  try like 500 to 1000, 1/4 + 1/2 = 3/4
 byte    polarity   = 1;    //0 for lo->hi==1 or 1 for hi->lo==1 for Polarity, sets tempBit at start
-byte    tempBit       ;    //Reflects the required transition polarity
-byte    bitState      ;    //State of the RxPin 3/4 way through Bit Waveform
+byte    tempBit    = 1;    //Reflects the required transition polarity
 byte    discards   = 0;    //how many leading "bits" need to be dumped, usually just a zero if anything eg discards=1
 boolean firstZero  = false;//has it processed the first zero yet?  This a "sync" bit.
 boolean noErrors   = true; //flags if signal does not follow Manchester conventions
@@ -33,7 +28,7 @@
 //Variables for Byte storage
 byte    dataByte   = 0;    //Accumulates the bit information
 byte    nosBits    = 0;    //Counts to 8 bits within a dataByte
-byte    maxBytes   = 6;    //Set the bytes collected after each header. NB if set too high, any end noise will cause an error
+byte    maxBytes   = 5;    //Set the bytes collected after each header. NB if set too high, any end noise will cause an error
 byte    nosBytes   = 0;    //Counter stays within 0 -> maxBytes
 //Variables for multiple packets
 byte    bank       = 0;    //Points to the array of 0 to 3 banks of results from up to 4 last data downloads
@@ -61,7 +56,7 @@
   Serial.begin(115200);//make it fast so it dumps quick!
   pinMode(RxPin, INPUT);
   pinMode(ledPin, OUTPUT);
-  Serial.println("Debug Manchester Version GIT-Hub V01");
+  Serial.println("Debug Manchester Version 09");
   lDelay=2*sDelay;//just to make sure the 1:2 ratio is established. They can have some other ratio if required
   Serial.print("Using a delay of 1/4 bitWaveform ");// +-15% and they still seem to work ok, pretty tolerant!
   Serial.print(sDelay,DEC);
@@ -91,7 +86,7 @@

 // Main routines, find header, then sync in with it, get a packet, and decode data in it, plus report any errors.
 void loop(){
-  tempBit=polarity^1; //these begin as opposites for each packet
+  tempBit=polarity^1; //these begin the opposites for a packet
   noErrors=true;
   firstZero=false;
   headerHits=0;
@@ -108,18 +103,16 @@
       noErrors=false;//something has gone wrong, polarity has changed too early, ie always an error
     }//exit and retry
     else{
-      //now grab the bitState before setting up for next bit & correct for polarity
-      bitState = tempBit ^ polarity;//Polarity=1, invert OR Polarity=0, ignore
-      //Now work on what the next bit waveform is going to be
+      byte bitState = tempBit ^ polarity;//if polarity=1, invert the tempBit or if polarity=0, leave it alone.
       delayMicroseconds(lDelay);
       //now 1 quarter into the next bit pattern,
-      if(digitalRead(RxPin)==tempBit){ //if RxPin has NOT swapped, then next data bit value IS swapping
+      if(digitalRead(RxPin)==tempBit){ //if RxPin has not swapped, then bitWaveform is swapping
         //If the header is done, then it means data change is occuring ie 1->0, or 0->1
-        //data transition detection must swap, so it loops for the opposite transition in the next bit waveform
+        //data transition detection must swap, so it loops for the opposite transitions
         tempBit = tempBit^1;
-      }//end of detecting no transition at end of bit waveform
-
-      //Now process the tempBit state and interept data as definite 0 or 1's, (Polarity corrected by now)
+      }//end of detecting no transition at end of bit waveform, ie end of previous bit waveform same as start of next bitwaveform
+
+      //Now process the tempBit state and make data definite 0 or 1's, allow possibility of Pos or Neg Polarity
       if(bitState==1){ //1 data could be header or packet
         if(!firstZero){
           headerHits++;
@@ -142,7 +135,6 @@
           //we have our header, chewed up any excess and here is a zero
           if ((!firstZero)&&(headerHits>=headerBits)){ //if first zero, it has not been found previously
             firstZero=true;
-            //Serial.print("!");
           }//end of finding first zero
           add(bitState);
         }//end of dealing with a zero
@@ -170,7 +162,7 @@
       //Serial.print("B");
     }
     if(nosBytes==maxBytes){
-      hexBinDump();//for debug purposes dump out in hex and bainary
+      hexBinDump();//for debug purposes dump out in hex and binary
       //analyseData();//later on develop your own analysis routines
     }
   }
@@ -212,3 +204,18 @@

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


Update DMASpi_example2.ino

Update DMASpi_example2.ino

--- examples/DMASpi_example2/DMASpi_example2.ino
+++ examples/DMASpi_example2/DMASpi_example2.ino
@@ -16,7 +16,7 @@
 /** Hardware setup:
  Teensy LC: DOUT (pin 0) connected to DIN (pin 1)
  Teensy 3.5, 3.6: DOUT (pin 0) connected to DIN (pin 1)
- Pin 0 is used as a chip select pin, don't connect anything there.
+ Pin 2 is used as a chip select pin, don't connect anything there.
 **/

 /** buffers to send from and to receive to **/


bluetooth_blink updated

bluetooth_blink updated

--- examples/bluetooth_blink/bluetooth_blink.ino
+++ examples/bluetooth_blink/bluetooth_blink.ino
@@ -1,22 +1,25 @@
-//www.elegoo.com
-//2016.09.19
+#include "Arduino.h"

-int LED=13;//Define 13 pin for LED
-volatile int state = LOW;//The initial state of the function is defined as a low level
-char getstr;    //Defines a function that receives the Bluetooth character
+#include <EBot.h>
+
+EBot eBot = EBot();
+
+bool state = LOW;
+char getstr;
+
 void setup() {
- pinMode(LED, OUTPUT);
-Serial.begin(9600);
+  pinMode(LED_BUILTIN, OUTPUT);
+  Serial.begin(115200);
 }
-/*Control LED sub function*/
-void stateChange()
-{
+
+void stateChange() {
   state = !state;
-  digitalWrite(LED, state);
+  digitalWrite(LED_BUILTIN, state);
 }
+
 void loop() {
-    getstr=Serial.read();//The Bluetooth serial port to receive the data in the function
-    if(getstr=='A'){
+  getstr=Serial.read();//The Bluetooth serial port to receive the data in the function
+  if(getstr=='A'){
     stateChange();
   }
 }


cc3200 example update

cc3200 example update

--- examples/microblu_cc3200/microblu_cc3200.ino
+++ examples/microblu_cc3200/microblu_cc3200.ino
@@ -53,21 +53,21 @@
 StreamBuffer stream(write, read);
 StreamBuffer externalaccess(read, write);

-char ssid[] = "yournetworkname";     //  your network SSID (name)
-char pass[] = "yourpassword";  // your WPA network password
+#define MESHBLU_HOST "meshblu.octoblu.com"
+#define MESHBLU_PORT 1883
+#define UUID  "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
+#define TOKEN "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
+
+#define WIFI_SSID       "yournetworkname"
+#define WIFI_PASSWORD   "yourpassword"
+
 unsigned int timeout = 30000;             // Milliseconds
-
-char server[] = "meshblu.octoblu.com";
-
-//Your 'firmware' type UUID and token for Microblu //TODO where to get one
-char UUID[]  = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
-char TOKEN[] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

 //SFE_CC3000 wifi = SFE_CC3000(CC3000_INT, CC3000_EN, CC3000_CS);
 //SFE_CC3000_Client client = SFE_CC3000_Client(wifi);
 WiFiClient client;

-PubSubClient microblu(server, 1883, onMessage, client);
+PubSubClient microblu(MESHBLU_HOST, MESHBLU_PORT, onMessage, client);

 // move the following defines to Firmata.h?
 #define I2C_WRITE B00000000
@@ -601,6 +601,8 @@
     // skip SPI pins for Ethernet/Wifi Shield //JJR
     //if ( (i==CC3000_INT) || (i==CC3000_EN) || (i==CC3000_CS) || (i==MOSI) || (i==MISO) || (i==SCK) || (i==SS) )
     //  continue;
+    if (IS_PIN_I2C(i))
+      continue;

     if (IS_PIN_ANALOG(i)) {
       // turns off pullup, configures everything
@@ -680,7 +682,7 @@

   Serial.begin(9600);

-  wifiConnect(ssid, pass, timeout);
+  wifiConnect(WIFI_SSID, WIFI_PASSWORD, timeout);
   /*;
   if ( wifi.init() ) {
     Serial.println(F("CC3000 initialization complete"));
@@ -775,27 +777,25 @@
     delay(10000);

     // attempt to connect to Wifi network:
-    if(wifiConnect(ssid, pass, timeout)) {
-
-      String clientIdStr = "microblu_" + String(random(500000)) + "_" + String(random(500000));
+    if(wifiConnect(WIFI_SSID, WIFI_PASSWORD, timeout)) {
+
+      String clientIdStr = "mb" + String(random(500000));
       int clientId_len = clientIdStr.length() + 1;
       char clientId[clientId_len];
       clientIdStr.toCharArray(clientId, clientId_len);

       if (microblu.connect(clientId, UUID, TOKEN)){
-
         //success!
         Serial.println(F("connected"));

         //you need to subscribe to your uuid to get messages for you
         microblu.subscribe(UUID);

-      }
-
-    }else
-    {
-        Serial.print(F("couldnt connect to: "));
-        Serial.println(ssid);
+      }else
+      {
+          Serial.print(F("couldnt connect to: "));
+          Serial.println(WIFI_SSID);
+      }
     }
   }
 }


Add sequencing function logic.

Add sequencing function logic.

--- examples/seq/seq.ino
+++ examples/seq/seq.ino
@@ -24,6 +24,9 @@
 #include <du-ino_interface.h>
 #include <TimerOne.h>
 #include <avr/pgmspace.h>
+#include <util/atomic.h>
+
+#define DIGITAL_THRESH 1.25 // V

 enum GateMode {
   GATE_NONE = 0,
@@ -67,11 +70,15 @@
   bool diradd_mode;
   float slew_rate;
   float gate_time;
-  float clock_period;
+  uint16_t clock_period;
   bool clock_ext;
 };

-DU_SEQ_Values seq_values;
+volatile DU_SEQ_Values seq_values;
+
+volatile uint8_t stage;
+volatile uint8_t step;
+volatile bool clock_gate, retrigger;

 void clock_isr();
 void reset_isr();
@@ -89,7 +96,86 @@

   virtual void loop()
   {
-  }
+    // cache stage and step
+    uint8_t cached_stage, cached_step;
+    ATOMIC_BLOCK(ATOMIC_FORCEON)
+    {
+      cached_stage = stage;
+      cached_step = step;
+    }
+
+    // drop gate and clock on retrigger
+    if(retrigger)
+    {
+      gt_out(GT_MULTI | (1 << GT5) | (1 << GT6), false);
+      clock_time = millis();
+    }
+
+    // set gate state
+    bool gate = false;
+    switch(seq_values.stage_gate[cached_stage])
+    {
+      case GATE_NONE:
+        gate = false;
+        break;
+      case GATE_1SHT:
+        if(!cached_step)
+        {
+          gate = partial_gate();
+        }
+        break;
+      case GATE_REPT:
+        gate = partial_gate();
+        break;
+      case GATE_LONG:
+        if(cached_step == seq_values.stage_steps[cached_stage] - 1)
+        {
+          gate = partial_gate();
+        }
+        else
+        {
+          gate = true;
+        }
+        break;
+      case GATE_EXT1:
+        gate = cv_read(CI2) > DIGITAL_THRESH;
+        break;
+      case GATE_EXT2:
+        gate = cv_read(CI3) > DIGITAL_THRESH;
+        break;
+    }
+
+    // set pitch CV state
+    cv_out(CO1, seq_values.stage_cv[cached_stage]);
+
+    // set gate and clock states
+    if(gate && (clock_gate || retrigger))
+    {
+      gt_out(GT_MULTI | (1 << GT5) | (1 << GT6), true);
+    }
+    else
+    {
+      gt_out(GT5, gate);
+      gt_out(GT6, clock_gate || retrigger);
+    }
+
+    // reset retrigger
+    if(retrigger)
+    {
+      retrigger = false;
+    }
+  }
+
+ private:
+  bool partial_gate()
+  {
+    uint16_t elapsed = millis() - clock_time;
+    return (seq_values.clock_ext && clock_gate)
+           || (elapsed < (seq_values.gate_time * seq_values.clock_period / 16))
+           || retrigger;
+  }
+
+  unsigned long clock_time;
 };

 class DU_SEQ_Interface : public DUINO_Interface {
@@ -417,9 +503,9 @@
     return ((float)note - 36.0) / 12.0;
   }

-  float bpm_to_ms(uint8_t bpm)
-  {
-    return 600000.0 / (float)bpm;
+  uint16_t bpm_to_ms(uint8_t bpm)
+  {
+    return 600000 / bpm;
   }

   void display_slew_rate(int16_t x, int16_t y, uint8_t rate, DUINO_SSD1306::SSD1306Color color)
@@ -553,10 +639,24 @@

 void clock_isr()
 {
+  clock_gate = function->gt_read(GT3);
+  if(clock_gate)
+  {
+    step++;
+    step %= seq_values.stage_steps[stage];
+    if(!step)
+    {
+      stage++;
+      stage %= seq_values.stage_count;
+    }
+    retrigger = true;
+  }
 }

 void reset_isr()
 {
+  stage = step = 0;
+  retrigger = true;
 }

 void timer_isr()


More JSON formatted return values

More JSON formatted return values

--- weather_station/dashboard/arduino/weather_station_02.ino
+++ weather_station/dashboard/arduino/weather_station_02.ino
@@ -46,7 +46,7 @@

   // Compute heat index
   // Must send in temp in Fahrenheit!
-  float hi = dht.computeHeatIndex(f, h);
+  float hif = dht.computeHeatIndex(f, h);

   // How cold? (temperature and humidity with Arduino)
   // http://wodieskodie.com/how-cold-temperature-and-humidity-with-arduino/
@@ -63,7 +63,10 @@
         client.println("Access-Control-Allow-Origin: *");

         // JSON response
-        client.print("{\"type\":\"temperature\",\"scale\":\"fahrenheit\",\"title\":\"Fahrenheit\", \"value\":\"");
+        client.print("{\"type\":\"temperature\",");
+        client.print("\"scale\":\"fahrenheit\",");
+        client.print("\"title\":\"Fahrenheit\",");
+        client.print("\"value\":\"");
         client.print(f);
         client.print("\"}");
       }
@@ -73,24 +76,57 @@
         client.println("Content-type: text/javascript");
         client.println("Access-Control-Allow-Origin: *");

-        client.print("{\"type\":\"tempature!\"}");
-        client.print("{\"title\":\"Celsius\"}");
-        client.print("{\"value\":\"f\"}");
+        // JSON response
+        client.print("{\"type\":\"temperature\",");
+        client.print("\"scale\":\"celsius\",");
+        client.print("\"title\":\"Celsius\",");
+        client.print("\"value\":\"");
+        client.print(c);
+        client.print("\"}");
       }
-     if (request == "tempc") {
-      //client.print("
Current Temperature: ");
-      client.print(c);
-      //client.print(" degrees C");
-     }
-     if (request == "tempk") {
-      //client.print("
Current Temperature: ");
-      client.print(k);
-      //client.print(" degrees K");
-     }
-     if (request == "hum") {
-      //client.print("
Current Humidity: ");
-      client.print(h);
-     }
+
+      if (request == "tempk") {
+        client.println("HTTP/1.1 200 OK");
+        client.println("Content-type: text/javascript");
+        client.println("Access-Control-Allow-Origin: *");
+
+        // JSON response
+        client.print("{\"type\":\"temperature\",");
+        client.print("\"scale\":\"kelvin\",");
+        client.print("\"title\":\"Kelvin\",");
+        client.print("\"value\":\"");
+        client.print(k);
+        client.print("\"}");
+      }
+
+      if (request == "hum") {
+        client.println("HTTP/1.1 200 OK");
+        client.println("Content-type: text/javascript");
+        client.println("Access-Control-Allow-Origin: *");
+
+        // JSON response
+        client.print("{\"type\":\"humidity\",");
+        client.print("\"scale\":\"%\",");
+        client.print("\"title\":\"Humidity\",");
+        client.print("\"value\":\"");
+        client.print(h);
+        client.print("\"}");
+      }
+
+      if (request == "hif") {
+        client.println("HTTP/1.1 200 OK");
+        client.println("Content-type: text/javascript");
+        client.println("Access-Control-Allow-Origin: *");
+
+        // JSON response
+        client.print("{\"type\":\"index\",");
+        client.print("\"scale\":\"\",");
+        client.print("\"title\":\"Apparent Temperature (Heat Index) in Fahrenheit\",");
+        client.print("\"value\":\"");
+        client.print(hif);
+        client.print("\"}");
+      }
+
      if (request == "hi") {
       //client.print("
Heat Index: ");
       client.print(hi);


Potard as color switch (no more on/off switch in intech local…)

--- pug.ino
+++ pug.ino
@@ -10,7 +10,7 @@
 #define leftMotorPin1 8
 #define leftMotorPin2 9

-#define colorPin 2
+#define colorAnalogPin 1
 #define jumperPin 3

 #define enemyLedPin 13
@@ -43,7 +43,7 @@
  * Returns true if robot is on green side.
  **/
 boolean isGreen() {
-  return digitalRead(colorPin);
+  return analogRead(colorAnalogPin) > 500;
 }

 /**
@@ -151,9 +151,6 @@
   motorTimer.begin(_motorsLivecycle, 30);
   ultraTimer.begin(_ultrasonLivecycle, 50000);

-  // Color switch
-  pinMode(colorPin, INPUT);
-
   // Debug led
   pinMode(enemyLedPin, OUTPUT);
   pinMode(6, OUTPUT);


Add logs

Add logs

--- pug.ino
+++ pug.ino
@@ -8,7 +8,7 @@

 #define starterServoPin 18

-#define rotateTime 750
+#define rotateTime 600

 // Globals vars
 Servo starterServo;
@@ -180,15 +180,25 @@
 {
   switch (serialInput[0])
   {
+    case 'i':
     case 'I': // Initialize
-      setLeftSpeed(20);
-      break;
+      initializeTimer1();
+      break;
+
+    case 'r':
     case 'R': // Rotation
-      if (serialInput[1] == 'L') rotateLeft();
-      else rotateRight();
-      break;
-
+      if (serialInput[1] == 'L' || serialInput[1] == 'l'){
+        rotateLeft();
+        Serial.println("Step left!");
+        }
+      else {
+        rotateRight();
+        Serial.println("Step right!");
+        }
+      break;
+    case 'f':
     case 'F': // Front direction
+    Serial.println("Go!");
       setLeftSpeed( serialInput[1] * 100 + serialInput[2] * 10 + serialInput[3]);
       setRightSpeed( serialInput[1] * 100 + serialInput[2] * 10 + serialInput[3]);
       delay(1500);
@@ -197,23 +207,27 @@
       delay(400);
       stopMotors();
       break;
-
+    case 'b':
     case 'B': // Back direction
+    Serial.println("Revert revert revert!");
       setLeftSpeed( (serialInput[1] * 100 + serialInput[2] * 10 + serialInput[3]) * -1);
       setRightSpeed( (serialInput[1] * 100 + serialInput[2] * 10 + serialInput[3]) * -1);

       break;
-
+    case 's':
     case 'S': // Starting block
+    Serial.println("Lock'n'load!");
       prepareToStart();
       break;
-
+    case 'g':
     case 'G': // GO !!!
+    Serial.println("Smooth splosh");
       smoothSploch();
       break;
-
+    case 'W':
     case 'w': // Emergy stop
-      stopMotors();
+     Serial.println("Emergency Stop!!");
+               stopMotors();
       break;

     default:


changed some scale values

changed some scale values

--- 03_Illuminar.ino
+++ 03_Illuminar.ino
@@ -4,8 +4,8 @@
 float irSensorVal=0;

 int irDelta=100;
-int irBase=25;
-int irMax=200;
+int irBase=20;
+int irMax=190;

 int t1=0;
@@ -148,7 +148,8 @@

   Serial.print(irSensorVal);

-
+   Serial.print("   DIMVAL: ");
+   Serial.print(dimVal);

   Serial.println("");


remove accelerometer

remove accelerometer

--- longboard-ctl.ino
+++ longboard-ctl.ino
@@ -20,25 +20,26 @@
 #define BluetoothSerialSpeed 9600
 // serial config is default: 8, 1, n

+#define AccelerometerIntegration 0

 #if AccelerometerIntegration
 // Pin that defines the address of accelerometer, (is grounded?)
 #define SA0 1
-#endif

 #include <Wire.h>
 #include <MMA8452.h>
 //#include <MMA8452Reg.h>
-
-#define AccelerometerIntegration 0
+#endif

 // Software Filter for acceleration
 #define AccelerometerSoftFilter 1

+#if AccelerometerIntegration
 // accuracy: +- 2, +- 4, +- 8
 #define AccelerationRange MMA_RANGE_2G
 #define AccelerationDataRate MMA_12_5hz
 #define AccelerometerNewDataInterrupt 1
+#endif

 #if AccelerometerSoftFilter and AccelerometerIntegration
 #include <FilterOnePole.h>
@@ -55,6 +56,7 @@

 // GLOBALS

+#if AccelerometerIntegration
 // Accelerometer
 MMA8452 mma = MMA8452();

@@ -74,6 +76,7 @@
 float lastAccValue = 0.0;
 unsigned long lastAccTime = 0;
 float xVelocity = 0.0;
+#endif

 int throttleBluetoothOut = 0;

@@ -109,9 +112,9 @@
     setupBluetooth();

     // Connect i2c accelerometer
+#if AccelerometerIntegration
     //setupAccelerometer();

-#if AccelerometerIntegration
     // get initial values
     lastAccTime = micros();
     float x, y, z;
@@ -177,6 +180,7 @@
     analogWrite(ThrottleOut, (byte) ((throttleBluetoothOut > 126) ? throttleBluetoothOut : throttleSensorOut) );
 }

+#if AccelerometerIntegration
 inline float getUnfilteredXAcc() {
     float x, y, z;

@@ -196,6 +200,7 @@
     x += zeroOffset;
     return x;
 }
+#endif

 int getThrottleSample() {
     int throttleIn = 0; // avarage accumulator
@@ -213,6 +218,7 @@
     return throttleIn;
 }

+#if AccelerometerIntegration
 inline float getXAccSample() {
     float x = getUnfilteredXAcc();

@@ -236,6 +242,7 @@
 #endif
     return x;
 }
+#endif

 // Stop and blink when error occurs
@@ -249,6 +256,7 @@
     }
 }

+#if AccelerometerIntegration
 bool setupAccelerometer() {
     Wire.begin();

@@ -279,12 +287,14 @@
     Serial.println("DAccelerometer active.");
     return true;
 }
+#endif

 void setupBluetooth() {
     Bluetooth.begin(BluetoothSerialSpeed);
     Bluetooth.println("DBluetooth module active.");
 }

+#if AccelerometerIntegration
 void calibrateZeroVel() {
     Bluetooth.println("DCalibrating zero-speed");

@@ -297,6 +307,7 @@
     Bluetooth.print("DCalibrated: ");
     Bluetooth.println(zeroOffset*1000);
 }
+#endif

 float trapezoidalRule(float fa, float fb, int dt) {
     return ((float) dt) * (fa + fb) * 0.5;


Fixed speedCharacteristic bug

Fixed speedCharacteristic bug

--- Motor_v2.ino
+++ Motor_v2.ino
@@ -2,16 +2,16 @@
 #define MOTOR_PIN 6

 BLEPeripheral blePeripheral;
-BLEService motorService = BLEService("5762");
+BLEService motorService = BLEService("FF10");

 // switchCharacteristic controls motor's on/off state
 BLECharCharacteristic switchCharacteristic =
-  BLECharCharacteristic("5763", BLERead | BLEWrite);
+  BLECharCharacteristic("FF11", BLERead | BLEWrite);
 BLEDescriptor switchDescriptor = BLEDescriptor("2901", "Switch");

 // speedCharacteristic controls the motor's speed
 BLECharCharacteristic speedCharacteristic =
-  BLECharCharacteristic("5764", BLERead | BLEWrite);
+  BLECharCharacteristic("FF12", BLERead | BLEWrite);
 BLEDescriptor speedDescriptor = BLEDescriptor("2901", "Speed");

 void setup() {
@@ -58,7 +58,6 @@
 }

 void speedCharacteristicWritten(BLECentral& central, BLECharacteristic& characteristic) {
-  Serial.println(F("HERE"));
   Serial.print(F("Motor set to: "));
   Serial.println(speedCharacteristic.value());


cleand utils

cleand utils

--- utils/TestLCDdim/TestLCDdim.ino
+++ utils/TestLCDdim/TestLCDdim.ino
@@ -1,35 +0,0 @@
-// test LCD screen dimensions with 2 pots connected on A0 and A1 (x, y)
-
-#include <UTFT.h>
-#define DEBUG 0
-
-
-int x, y;
-
-UTFT lcd(CTE32HR,38,39,40,41);
-
-void setup(){
-  lcd.InitLCD();
-  if(DEBUG)Serial.begin(9600);
-  lcd.fillScr(VGA_BLACK);
-}
-
-void loop(){
-  x = analogRead(A0);
-  y = analogRead(A1);
-
-  if(DEBUG){
-    Serial.print("x: ");
-    Serial.print(x);
-    Serial.print(" | y: ");
-    Serial.println(y);
-  }
-
-
-//  lcd.fillScr(VGA_BLACK);
-  //lcd.clrScr();
-  lcd.setColor(VGA_GREEN);
-  lcd.fillRect(0, 0, x, y);
-
-  delay(50);
-}