blink switch led between sleep intervals, keep trellis sleeping

--- musicbox/musicbox.ino
+++ musicbox/musicbox.ino
@@ -54,10 +54,12 @@
 #define HEADSET_LEVEL_PIN      A3   // Voltage level indicates headset plugin
 #define HEADSET_THRESHOLD     100   // Plugged-in: ~20, Unplugged: ~890

-// Rotary Encoder with Switch
+// Rotary Encoder with Switch and LED
 #define ENCODER_A           A0
 #define ENCODER_B           A1
 #define ENCODER_SWITCH      A2
+#define GREEN_LED_PIN       A4
+#define BLUE_LED_PIN        A5

 // States
 #define IDLE_LIGHT_UP   1
@@ -107,8 +109,16 @@
   initializePlayer();
   initializeTrellis();
   initializeTimer();
+  initializeSwitchLed();

   onEnterIdle(0);
+}
+
+void initializeSwitchLed() {
+  pinMode(GREEN_LED_PIN, OUTPUT);
+  pinMode(BLUE_LED_PIN, OUTPUT);
+  digitalWrite(GREEN_LED_PIN, HIGH);
+  digitalWrite(BLUE_LED_PIN, HIGH);
 }

 void initializeAmplifier() {
@@ -274,20 +284,14 @@
   trellis.clear();
   trellis.writeDisplay();
   trellis.sleep();
-  //player.setVolume(255, 255);

   state = TIMEOUT_WAIT;
 }

 void onWatchdogPing() {
-  trellis.wakeup();
-  trellis.setBrightness(BRIGHTNESS_SLEEPTICK);
-  trellis.setLED(nextLED);
-  trellis.writeDisplay();
-  LowPower.powerDown(SLEEP_15MS, ADC_OFF, BOD_OFF);
-  trellis.clrLED(nextLED);
-  trellis.writeDisplay();
-  nextLED = (nextLED + 1) % NUMKEYS;
+  digitalWrite(BLUE_LED_PIN, LOW); // LED on
+  delay(1);
+  digitalWrite(BLUE_LED_PIN, HIGH); // LED off
 }

 void trellisIsr() {
@@ -296,7 +300,6 @@
 }

 void onSleepWake() {
-  //player.softReset();
   trellis.wakeup();
   waitForNoKeyPressed();
   onEnterIdle(0);


Working

Working

First Working Version. Displays Only 1111 Constantly.

--- Slave_Orig/Slave_Orig.ino
+++ Slave_Orig/Slave_Orig.ino
@@ -23,9 +23,7 @@
 };
 int digitBuffer[4] = {
   0};
-int digitScan = 0, flag=0,  soft_scaler = 0;
-;
-float tempK, tempC, tempF, temp;
+int digitScan = 0;

 void setup(){
   for(int i=0;i<4;i++)
@@ -61,10 +59,10 @@
 }

 void loop(){
-  digitBuffer[3] = int(tempC)/1000;
-  digitBuffer[2] = (int(tempC)%1000)/100;
-  digitBuffer[1] = (int(tempC)%100)/10;
-  digitBuffer[0] = (int(tempC)%100)%10;
+  digitBuffer[3] = 1;
+  digitBuffer[2] = 1;
+  digitBuffer[1] = 1;
+  digitBuffer[0] = 1;
   updateDisp();
   delay(2);
 }


delay for 1sec

delay for 1sec

--- _03-hx711-scale/_03-hx711-scale-v3-adaptor/_03-hx711-scale-pro-mini/_03-hx711-scale-pro-mini.ino
+++ _03-hx711-scale/_03-hx711-scale-v3-adaptor/_03-hx711-scale-pro-mini/_03-hx711-scale-pro-mini.ino
@@ -58,7 +58,7 @@
     Serial.println(measured);
   }
   nofchecked++;
-  delay(100);
+  delay(200);
 }

 void requestEvent()


limit max

limit max

--- _03-hx711-scale/_03-hx711-scale-v3-adaptor/_03-hx711-scale-pro-mini/_03-hx711-scale-pro-mini.ino
+++ _03-hx711-scale/_03-hx711-scale-v3-adaptor/_03-hx711-scale-pro-mini/_03-hx711-scale-pro-mini.ino
@@ -4,10 +4,11 @@

 HX711 scale(A0, A1);

-#define DEBUG_OUT 1
+#define DEBUG_OUT 0

 const int nemoisonPin = 9;
-volatile int measured = 0;
+volatile int isSent;
+int measured = 0;
 volatile int tosend   = 0;
 long startMills;

@@ -24,13 +25,14 @@
   pinMode(nemoisonPin, OUTPUT);
   digitalWrite(nemoisonPin, LOW);

+  Wire.begin(2);
+  Wire.onRequest(requestEvent);
+
   delay(5000);
+  isSent = LOW;

   scale.set_scale(23040.f);
   scale.tare();
-
-  Wire.begin(2);
-  Wire.onRequest(requestEvent);
 }

@@ -40,22 +42,24 @@
     Serial.print((millis() - startMills) * 0.001, 2);
     Serial.print("\t: ");
   }
-
-  float fmeasured = scale.get_units(10) ;
-  measured = int(fmeasured * 1000) ;

-  if ( DEBUG_OUT ) {
-    Serial.print(fmeasured, 5);
-    Serial.print("\t: ");
-    Serial.print(measured);
+  if ( isSent == LOW ) {
+    float fmeasured = scale.get_units(10) ;
+    measured = int(fmeasured * 1000) ;
+    if ( DEBUG_OUT ) {
+      Serial.print(fmeasured, 5);
+      Serial.print("\t: ");
+      Serial.print(measured);
+    }
   }
-
-  if ( DEBUG_OUT ) {
-    Serial.print("\t:\t");
-    Serial.println(measured);
+
+  if (( isSent == LOW ) && ( measured < 7000 )) {
+    tosend = measured;
+    if ( DEBUG_OUT ) {
+      Serial.print("\t:\t");
+      Serial.println(tosend);
+    }
   }
-
-  tosend = measured;

   if ( measured > 500 )
   {
@@ -64,13 +68,14 @@
     digitalWrite(nemoisonPin, LOW);
   }

-  //scale.power_down();
-  delay(200);
-  //scale.power_up();
+  scale.power_down();
+  delay(50);
+  scale.power_up();
 }

 void requestEvent()
 {
+  isSent = HIGH;
   byte myArray[3];
   myArray[0] = (abs(tosend) >> 8 ) & 0xFF;
   myArray[1] = abs(tosend) & 0xFF;
@@ -81,4 +86,5 @@
   }

   Wire.write(myArray, 3);
+  isSent = LOW;
 }


Fix coment

Fix coment

--- arduino_src/SerialReadLineExample/SerialReadLineExample.ino
+++ arduino_src/SerialReadLineExample/SerialReadLineExample.ino
@@ -16,7 +16,7 @@
   strInputLine.reserve(MAX_RECV_LINE_LENGTH);
 }

-//  strCommands - input string that contains a CVS string ($LED,1,0,1,0,2)
+//  strCommands - input string that contains a CVS string ($LED,1,0,1,0,1)
 //  strTab - has the splited input (strTab[0]="$LED",strTab[1]="1",strTab[2]="0")
 //  maxItems -  the maximum commands to parse
 //  Return the number of read items


Neopixel ring chasing

Neopixel ring chasing

--- neopixel/neopixel.ino
+++ neopixel/neopixel.ino
@@ -13,7 +13,13 @@

 Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, PIN_NEO, NEO_GRB + NEO_KHZ800);

+byte r;
+byte g;
+byte b;

+byte pixel_cri = 0;
+byte pixel_midtide = 0;
+byte pixel_longtide = 0;

 void setup()
 {
@@ -28,9 +34,29 @@

 void loop()
 {
-  show_cri();
-  show_midtide();
-  show_longtide();
+  cri();
+  midtide();
+  longtide();
+
+  for (byte n = 0; n < NUM_PIXELS; n++) {
+    if (n == pixel_cri) {
+      r = 255;
+    } else {
+      r = 0;
+    }
+    if (n == pixel_midtide) {
+      g = 255;
+    } else {
+      g = 0;
+    }
+    if (n == pixel_longtide) {
+      b = 255;
+    } else {
+      b = 0;
+    }
+    strip.setPixelColor(n, r, g, b);
+  }
+  strip.show();
 }

 /**
@@ -41,17 +67,19 @@
  * 1000 / 2.933333 = 340.9
  * so an interval of 341
  */
-void show_cri() {
+void cri() {
   static unsigned long last = 0;
   static long interval = 341;
+  static byte n = 0;

   unsigned long now = millis();
   if (now - last > interval) {
-    last = now;
-    for (byte n = 0; n < NUM_PIXELS; n++) {
-       strip.setPixelColor(n, 255, 0, 0);
+    last = now;
+    n++;
+    if (n >= NUM_PIXELS) {
+       n = 0;
     }
-    strip.show();
+    pixel_cri = n;
   }
 }

@@ -63,17 +91,19 @@
  * 1000 / 0.6 = 1666.666
  * so an interval of 1667
  */
-void show_midtide() {
+void midtide() {
   static unsigned long last = 0;
   static long interval = 1667;
+  static byte n = 0;

   unsigned long now = millis();
   if (now - last > interval) {
-    last = now;
-    for (byte n = 0; n < NUM_PIXELS; n++) {
-       strip.setPixelColor(n, 0, 255, 0);
+    last = now;
+    n++;
+    if (n >= NUM_PIXELS) {
+       n = 0;
     }
-    strip.show();
+    pixel_midtide = n;
   }
 }

@@ -82,17 +112,19 @@
  * 100 / 16 = 6.25 seconds per pixel
  * so an interval of 6250
  */
-void show_longtide() {
+void longtide() {
   static unsigned long last = 0;
   static long interval = 6250;
+  static byte n = 0;

   unsigned long now = millis();
   if (now - last > interval) {
-    last = now;
-    for (byte n = 0; n < NUM_PIXELS; n++) {
-       strip.setPixelColor(n, 0, 255, 0);
+    last = now;
+    n++;
+    if (n >= NUM_PIXELS) {
+       n = 0;
     }
-    strip.show();
+    pixel_longtide = n;
   }
 }


Update ArduCAM_Shield_V2_Video_Streaming.ino

--- ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Video_Streaming/ArduCAM_Shield_V2_Video_Streaming.ino
+++ ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Video_Streaming/ArduCAM_Shield_V2_Video_Streaming.ino
@@ -66,8 +66,14 @@
 Serial.println(F("ACK CMD ArduCAM Start! END"));
 // set the CS as an output:
 pinMode(SPI_CS, OUTPUT);
+ digitalWrite(SPI_CS, HIGH);
 // initialize SPI:
 SPI.begin();
+//Reset the CPLD
+myCAM.write_reg(0x07, 0x80);
+delay(100);
+myCAM.write_reg(0x07, 0x00);
+delay(100);
 while(1){
   //Check if the ArduCAM SPI bus is OK
   myCAM.write_reg(ARDUCHIP_TEST1, 0x55);


Some code cleanup, add 2 neopixels to venting light, remove dialog randomizer

Dialog randomizer was destabalizing the code. I'm not sure why but for
now I'm removing that bit. Will find another way to do it. TBH it wasn't
that random anyway.

--- Arduino/Neutrino_Wand/Neutrino_Wand.ino
+++ Arduino/Neutrino_Wand/Neutrino_Wand.ino
@@ -10,18 +10,20 @@
 #define HIGH 0x1
 #define LOW  0x0

+// neopixel pins / setup
 #define NEO_POWER 2 // for cyclotron and powercell
-Adafruit_NeoPixel powerStick = Adafruit_NeoPixel(46, NEO_POWER, NEO_GRB + NEO_KHZ800);
-
-// neopixel pins / setup
+Adafruit_NeoPixel powerStick = Adafruit_NeoPixel(48, NEO_POWER, NEO_GRB + NEO_KHZ800);
+
 #define NEO_NOSE 3 // for nose of wand
 Adafruit_NeoPixel noseJewel = Adafruit_NeoPixel(7, NEO_NOSE, NEO_GRB + NEO_KHZ800);

-// neopixel pins / setup
 #define NEO_WAND 4 // for nose of wand
 Adafruit_NeoPixel wandLights = Adafruit_NeoPixel(4, NEO_WAND, NEO_GRB + NEO_KHZ800);

 // LED indexes into the neopixel powerstick chain for the cyclotron
+const int powercellLedCount = 14;                                         // total number of led's in the animation
+const int powercellIndexOffset = 1;                                       // first led offset into the led chain for the animation
+
 int c1Start = 16;
 int c1End = 22;
 int c2Start = 23;
@@ -31,7 +33,7 @@
 int c4Start = 37;
 int c4End = 43;
 int ventStart = 44;
-int ventEnd = 45;
+int ventEnd = 47;

 // inputs for switches and buttons
 const int THEME_SWITCH = 5;
@@ -56,14 +58,14 @@
 const bool useDialogTracks = true;          // set to true if you want the dialog tracks to play after firing for 5 seconds

 // Possible Pack states
-bool powerBooted = false; // has the pack booted up
+bool powerBooted = false;   // has the pack booted up
 bool isFiring = false;      // keeps track of the firing state
 bool shouldWarn = false;    // track the warning state for alert audio
 bool shuttingDown = false;  // is the pack in the process of shutting down
-bool poweredDown = true;
-bool venting = false;
-
-// current switch states
+bool poweredDown = true;    // is the pack powered down
+bool venting = false;       // is the pack venting
+
+// physical switch states
 bool startup = false;
 bool theme = false;
 bool safety = false;
@@ -84,7 +86,6 @@
 const String choreTrack =     "T10     WAV";
 const String toolsTrack =     "T11     WAV";
 const String listenTrack =    "T12     WAV";
-const String goodTrack =      "T13     WAV";
 const String thatTrack =      "T14     WAV";
 const String neutronizedTrack="T17     WAV";
 const String boxTrack =       "T18     WAV";
@@ -92,14 +93,13 @@

 // this queue holds a shuffled list of dialog tracks we can pull from so we don't
 // play the same ones twice
-QueueArray <int> dialogQueue;
-int numDialog = 8;
-int dialogArray[8] = {1,2,3,4,5,6,7,8};
-
-// dialog trigger times/states
-unsigned long startDialogMillis;
-const int dialogWaitTime = 5000; // how long to hold down fire for a dialog to play
-const int warnWaitTime = 10000;  // how long to hold down fire before warning sounds
+QueueArray <int> dialogQueue;
+int numDialog = 7;
+
+// timer trigger times/states
+unsigned long firingStateMillis;
+const int firingWarmWaitTime = 5000;  // how long to hold down fire for lights to speed up
+const int firingWarnWaitTime = 10000;  // how long to hold down fire before warning sounds

 // Arduino setup function
 void setup() {
@@ -117,16 +117,17 @@

   // configure nose jewel
   noseJewel.begin();
-  powerStick.setBrightness(80);
+  noseJewel.setBrightness(50);
   noseJewel.show(); // Initialize all pixels to 'off'

   // configure powercell/cyclotron
   powerStick.begin();
-  powerStick.setBrightness(20);
+  powerStick.setBrightness(10);
   powerStick.show(); // Initialize all pixels to 'off'

+  // configure wand lights
   wandLights.begin();
-  wandLights.setBrightness(40);
+  wandLights.setBrightness(10);
   wandLights.show();

   // set the modes for the switches/buttons
@@ -158,32 +159,45 @@
   }
 }

-int getRandomTrack(){
-  if ( !dialogQueue.isEmpty() ){
-    // pull the next dialog
-    return dialogQueue.dequeue();
-  }else{
-    randomSeed(micros() +  ss.read());
-
-    for (int i=0; i<numDialog; i++){
-      int pos = random(numDialog);
-      int t = dialogArray[i];
-      dialogArray[i] = dialogArray[pos];
-      dialogArray[pos] = t;
-    }
-
-    for (int i=0; i<numDialog; i++){
-      dialogQueue.enqueue(dialogArray[i]);
-    }
-
-    return dialogQueue.dequeue();
+void playDialogTrack(){
+  // if the queue is empty reseed it
+  if ( dialogQueue.isEmpty() ){
+    for (int i=1; i<=numDialog; i++){
+      dialogQueue.enqueue(i);
+    }
+  }
+
+  switch (dialogQueue.dequeue()){
+    case (1):
+      playTrack(texTrack);
+      break;
+    case (2):
+      playTrack(listenTrack);
+      break;
+    case (3):
+      playTrack(choreTrack);
+      break;
+    case (4):
+      playTrack(boxTrack);
+      break;
+    case (6):
+      playTrack(thatTrack);
+      break;
+    case (8):
+      playTrack(neutronizedTrack);
+      break;
+    case (9):
+      playTrack(toolsTrack);
+      break;
+    default:
+      playTrack(endTrack);
+      break;
   }
 }

 /* ************* Main Loop ************* */
-// helper function to set light states for the cyclotron
 int cyclotronRunningFadeOut = 255;  // we reset this variable every time we change the cyclotron index so the fade effect works
-int cyclotronRunningFadeIn = 0;  // we reset this variable every time we change the cyclotron index so the fade effect works
+int cyclotronRunningFadeIn = 0;     // we reset this to 0 to fade the cyclotron in from nothing

 // intervals that can be adjusted in real time to speed up animations
 int pwr_interval = 60;        // interval at which to cycle lights for the powercell. We update this in the loop to speed up the animation so must be declared here (milliseconds)
@@ -222,21 +236,23 @@
     if (playing == 1 && startup == true) {
       playTrack(idleTrack);
     }
-
+
     // choose the right powercell animation sequence for booted/on
     if ( powerBooted == true ) {
+      // standard idle power sequence for the pack
       poweredDown = false;
       shuttingDown = false;
+      venting = false;
+      setWandLightState(3, 0, 0); //set sloblow red
+      setVentLightState(ventStart, ventEnd, 2);
       powerSequenceOne(currentMillis, pwr_interval, cyc_interval, cyc_fade_interval);
-      setWandLightState(3, 0, 0);               //set sloblow red
-      venting = false;
-      setVentLightState(ventStart, ventEnd, 2);
     } else {
+      // boot up the pack. powerSequenceBoot will set powerBooted when complete
+      powerSequenceBoot(currentMillis);
       setWandLightState(3, 7, currentMillis);   //set sloblow red blinking
-      powerSequenceBoot(currentMillis);
-    }
-
-    // if we are not started up we should play the startup sound first
+    }
+
+    // if we are not started up we should play the startup sound and begin the boot sequence
     if (startup == false) {
       startup = true;
       playTrack(startupTrack);
@@ -246,7 +262,7 @@
         safety = true;
       }
     }
-
+
     if( startup == true && safety_switch == 1 ){
       if( venting == false && powerBooted == true ){
         setWandLightState(1, 2, 0);    //  set back light orange
@@ -255,73 +271,62 @@
         setWandLightState(1, 4, 0);    //  set back light off
         setWandLightState(2, 4, 0);    //  set body led off
       }
-    }
-
-    // if the safety switch is set off then we can fire when the button is pressed
-    if ( safety_switch == 1 && fire_button == 0) {
-      // if the button is just pressed we clear all led's to start the firing animations
-      if ( isFiring == false ) {
-        shutdown_leds();
-        isFiring = true;
-      }
-
-      // show the firing bargraph sequence
-      barGraphSequenceTwo(currentMillis);
-    } else { // if we were firing and are no longer reset the leds
-      if ( isFiring == true ) {
-        shutdown_leds();
-        isFiring = false;
-      }
-
-      // and do the standard bargraph sequence
-      barGraphSequenceOne(currentMillis);
-    }
-
-    // if we are started up fire loop
-    if (startup == true && safety_switch == 1)
-    {
-      // if the safety was just changed play the click track
-      if (safety == false) {
-        safety = true;
-        playTrack(chargeTrack);
-      }
-
-      // if the fire button is pressed
-      if (fire_button == 0) {
-        fireStrobe(currentMillis); // strobe the nose pixels
-
+
+      // if the safety switch is set off then we can fire when the button is pressed
+      if ( fire_button == 0) {
+        // if the button is just pressed we clear all led's to start the firing animations
+        if ( isFiring == false ) {
+          shutdown_leds();
+          isFiring = true;
+        }
+
+        // show the firing bargraph sequence
+        barGraphSequenceTwo(currentMillis);
+
+        // strobe the nose pixels
+        fireStrobe(currentMillis);
+
+        // now powercell/cyclotron/wand lights
         // if this is the first time reset some variables and play the blast track
         if (fire == false) {
           shouldWarn = false;
           fire = true;
-          startDialogMillis = millis();
+          firingStateMillis = millis();
           playTrack(blastTrack);
         } else {
           // find out what our timing is
-          long diff = millis() - startDialogMillis;
-          // if we are in the warn interval
-          if ( diff > warnWaitTime) {
-            pwr_interval = 10;    // speed up the powercell animation
-            firing_interval = 20; // speed up the bar graph animation
-            cyc_interval = 50;    // really speed up cyclotron
-            cyc_fade_interval = 5;
+          long diff = millis() - firingStateMillis;
+
+          if ( diff > firingWarnWaitTime) { // if we are in the fire warn interval
+            pwr_interval = 10;      // speed up the powercell animation
+            firing_interval = 20;   // speed up the bar graph animation
+            cyc_interval = 50;      // really speed up cyclotron
+            cyc_fade_interval = 5;  // speed up the fade of the cyclotron
             if (playing == 1 || shouldWarn == false ) {
               shouldWarn = true;
               playTrack(warnTrack); // play the firing track with the warning
             }
-            setWandLightState(0, 8, currentMillis);    // set top light red flashing
-          } else if ( diff > dialogWaitTime) { // if we are in the dialog playing interval
-            pwr_interval = 30;    // speed up the powercell animation
-            firing_interval = 30; // speed up the bar graph animation
-            cyc_interval = 200;   // speed up cyclotron
-            cyc_fade_interval = 10;
+            setWandLightState(0, 8, currentMillis);    // set top light red flashing fast
+          } else if ( diff > firingWarmWaitTime) { // if we are in the dialog playing interval
+            pwr_interval = 30;      // speed up the powercell animation
+            firing_interval = 30;   // speed up the bar graph animation
+            cyc_interval = 200;     // speed up cyclotron
+            cyc_fade_interval = 10; // speed up the fade of the cyclotron
             if (playing == 1) {
               playTrack(blastTrack); // play the normal blast track
             }
             setWandLightState(0, 6, currentMillis);    // set top light orange flashing
           }
         }
-      } else { // now the button is no longer pressed
+      } else { // if we were firing and are no longer reset the leds
+        if ( isFiring == true ) {
+          shutdown_leds();
+          isFiring = false;
+        }
+
+        // and do the standard bargraph sequence
+        barGraphSequenceOne(currentMillis);
+
         if (fire == true) { // if we were firing let's reset the animations and play the correct final firing track
           clearFireStrobe();
           setWandLightState(0, 4, currentMillis);    // set top light off
@@ -333,44 +338,15 @@
           fire = false;

           // see if we've been firing long enough to get the dialog or vent sounds
-          long diff = millis() - startDialogMillis;
-
-          if ( diff > warnWaitTime) { // if we are past the warning let's vent the pack
+          long diff = millis() - firingStateMillis;
+
+          if ( diff > firingWarnWaitTime) { // if we are past the warning let's vent the pack
             playTrack(ventTrack);
             venting = true;
             clearPowerStrip(); // play the boot animation on the powercell
-          } else if ( diff > dialogWaitTime) { // if in the dialog time play the dialog in sequence
+          } else if ( diff > firingWarmWaitTime) { // if in the dialog time play the dialog in sequence
             if( useDialogTracks == true ){
-              switch (getRandomTrack())
-              {
-                case (1):
-                  playTrack(choreTrack);
-                  break;
-                case (2):
-                  playTrack(toolsTrack);
-                  break;
-                case (3):
-                  playTrack(texTrack);
-                  break;
-                case (4):
-                  playTrack(listenTrack);
-                  break;
-                case (5):
-                  playTrack(goodTrack);
-                  break;
-                case (6):
-                  playTrack(thatTrack);
-                  break;
-                case (8):
-                  playTrack(neutronizedTrack);
-                  break;
-                case (9):
-                  playTrack(boxTrack);
-                  break;
-                default:
-                  playTrack(endTrack);
-                  break;
-              }
+              playDialogTrack();
             }else{
               playTrack(endTrack);
             }
@@ -380,11 +356,17 @@
           }
         }
       }
+
+      // if the safety was just changed play the click track
+      if (safety == false) {
+        safety = true;
+        playTrack(chargeTrack);
+      }
     } else {
       // if the safety is switched off play the click track
       if (safety == true) {
-        setWandLightState(1, 4, 0);    //  set back light off
-        setWandLightState(2, 4, 0);    //set body off
+        setWandLightState(1, 4, 0);    // set back light off
+        setWandLightState(2, 4, 0);    // set body off
         safety = false;
         playTrack(clickTrack);
       }
@@ -415,6 +397,7 @@
 bool flashState = false;
 int wandFastFlashInterval = 100; // interval at which we flash the top led on the wand
 int wandMediumFlashInterval = 500; // interval at which we flash the top led on the wand
+
 void setWandLightState(int lednum, int state, int currentMillis){
   switch ( state ) {
     case 0: // set led red
@@ -523,8 +506,6 @@
 unsigned long prevFadeCycMillis = 0;    // last time we changed a cyclotron light in the idle sequence

 // LED tracking variables
-const int powercellLedCount = 15;                                         // total number of led's in the animation
-const int powercellIndexOffset = 0;                                       // first led offset into the led chain for the animation
 const int powerSeqTotal = powercellLedCount;                              // total number of led's for powercell 0 based
 int powerSeqNum = powercellIndexOffset;                                   // current running powercell sequence led
 int powerShutdownSeqNum = powercellLedCount - powercellIndexOffset;       // shutdown sequence counts down


Resolved build breaks 	modified:   ../../../Arduino/Simple_Ferm_Chamber/Simple_Ferm_Chamber.ino

--- Arduino/Simple_Ferm_Chamber/Simple_Ferm_Chamber.ino
+++ Arduino/Simple_Ferm_Chamber/Simple_Ferm_Chamber.ino
@@ -13,8 +13,8 @@
  * external software program.  It only sends output out to the
  * wire for monitoring purposes.
  */
-//#undef _DEBUG
-#define _DEBUG
+#undef _DEBUG
+//#define _DEBUG
 int TempReadPin = 3;
 int CoolingRelayPin = 4;
 int CoolingDisplayPin = 5;
@@ -42,7 +42,7 @@

 //Setup values
 float g_PrimaryTemperatureBand = 1.3;
-float g_PrimaryTargetTemperature = 68;
+float g_PrimaryTargetTemperature = 80;
 unsigned long g_CompressorRunTime = 30000; //30 Seconds
 unsigned long g_CompressorOffTime = 240000; //4 Minutes
 unsigned long g_HeatingOffTime = 300000;    //5 Minutes
@@ -252,9 +252,9 @@
 #ifdef _DEBUG
    //Print out the temperature
    Serial.print("Primary Temperature: ");
-   Serial.println(g_PrimarySensor->GetTemperature());
+   Serial.println(g_InternalFermentorSensor->GetTemperature());
    Serial.print("Ambient Extneral Temperature: ");
-   Serial.println(g_AmbientExternalSensor->GetTemperature());
+   Serial.println(g_ExternalFermentorSensor->GetTemperature());
    Serial.print("Ambient Internal Temperature: ");
    Serial.println(g_AmbientInternalSensor->GetTemperature());
 #endif


Comments and clarity for command timeout

--- Wild_Thumper_Controller/Wild_Thumper_Controller.ino
+++ Wild_Thumper_Controller/Wild_Thumper_Controller.ino
@@ -432,7 +432,7 @@
     }
   }

-  if ((leftMode != BRAKE || rightMode != BRAKE) && millis() - lastCommandTime > COMMANDTIMEOUT) {
+  if ((leftMode != BRAKE || rightMode != BRAKE) && (millis() - lastCommandTime > COMMANDTIMEOUT)) {
     // Prevent runaway when connection drops
     stop();
   }
@@ -447,6 +447,7 @@
   } while (data<0);
 }

+// Stop by applying brakes
 void stop() {
   leftMode = BRAKE;
   leftPWM = 255;


Delete charlieCube.ino

Delete charlieCube.ino


Distance sensor turns off if 0 input

Distance sensor turns off if 0 input

--- Modules/Sensor/DistanceSensor/ArduinoCodes/DistanceSensorNewATtiny/DistanceSensorNewATtiny.ino
+++ Modules/Sensor/DistanceSensor/ArduinoCodes/DistanceSensorNewATtiny/DistanceSensorNewATtiny.ino
@@ -10,7 +10,7 @@
 **  Arduino Pin Configurations:
 **
 **  Pin 1 (Reset): N/U                   Pin 8 (PWR):         5V
-**  Pin 2 (D3/A3): Module Input          Pin 7 (D2/A1/SCK):   N/U
+**  Pin 2 (D3/A3): Module Input          Pin 7 (D2/A1/SCK):   IR LED
 **  Pin 3 (D4/A2): IR Receiver           Pin 6 (D1/PWM/MISO): Module Output
 **  Pin 4 (GND):   GND                   Pin 5 (D0/PWM/MOSI): N/U
 **
@@ -18,7 +18,7 @@
 **  Created on 7/5/16.
 **  By Alex Jiao
 **
-**  Based on original code by Ricardo Ouvina
+**  Based on code by Ricardo Ouvina: http://www.instructables.com/id/Simple-IR-proximity-sensor-with-Arduino/
 **
 **  MakerWear Link:
 **  Github Link:      github.com/myjeeed/MakerWear
@@ -38,41 +38,44 @@
 SignalProcessing input(input_pin, filter_size);

 void setup(){
-  Serial.begin(9600);         // initializing Serial monitor
-  pinMode(IRemitter,OUTPUT);  // IR emitter LED on digital pin 2
-  digitalWrite(IRemitter,LOW);// setup IR LED as off
-  pinMode(11,OUTPUT);         // buzzer in digital pin 11
+  //Serial.begin(9600);         // initializing Serial monitor
+  pinMode(led_pin, OUTPUT);     // IR emitter LED on digital pin 2
+  digitalWrite(led_pin, LOW);   // setup IR LED as off
 }

 void loop(){
   int input_val = cutAndMap(input.filteredAnalogRead(AVERAGE), 50, 975, 0, 1023);
-  int val = readIR(15);                        // calling the function that will read the distance and passing the "accuracy" to it
+  if(input_val < 1){
+    digitalWrite(led_pin, LOW);
+    return;
+  }
+  int val = readIR(20);                        // calling the function that will read the distance and passing the "accuracy" to it
   int distance = A*pow(val, B);                //converting to distance
   //Serial.println(distance);
   int output_val = cutAndMap(distance, 5, 65, input_val/4, 0);
-  Serial.println(output_val);
+  //Serial.println(output_val);
   analogWrite(output_pin, output_val);
 }

 int readIR(int times){
   int value[times];                // array to store the IR values
   int total = 0;
-  int ambientIR;                // variable to store the IR coming from the ambient
-  int obstacleIR;               // variable to store the IR coming from the object
+  int ambientIR;                   // variable to store the IR coming from the ambient
+  int obstacleIR;                  // variable to store the IR coming from the object

   for(int x = 0; x < times; x++){
-    digitalWrite(IRemitter,LOW);           // turning the IR LEDs off to read the IR coming from the ambient
-    delay(1);                                             // minimum delay necessary to read values
-    ambientIR = analogRead(IRpin);  // storing IR coming from the ambient
-    digitalWrite(IRemitter,HIGH);          // turning the IR LEDs on to read the IR coming from the obstacle
-    delay(1);                                             // minimum delay necessary to read values
-    obstacleIR = analogRead(IRpin);  // storing IR coming from the obstacle
-    value[x] = ambientIR-obstacleIR;   // calculating changes in IR values and storing it for future average
+    digitalWrite(led_pin,LOW);           // turning the IR LEDs off to read the IR coming from the ambient
+    delay(1);                            // minimum delay necessary to read values
+    ambientIR = analogRead(ir_pin);      // storing IR coming from the ambient
+    digitalWrite(led_pin,HIGH);          // turning the IR LEDs on to read the IR coming from the obstacle
+    delay(1);                            // minimum delay necessary to read values
+    obstacleIR = analogRead(ir_pin);     // storing IR coming from the obstacle
+    value[x] = ambientIR-obstacleIR;     // calculating changes in IR values and storing it for future average
   }

-  for(int x = 0; x < times; x++){        // calculating the average based on the "accuracy"
+  for(int x = 0; x < times; x++){
     total += value[x];
   }
-  return(total/times);            // return the final value
+  return(total/times);                   // return the average
 }


Now it can works basically

Now it can works basically

--- sketch_yunba/sketch_yunba.ino
+++ sketch_yunba/sketch_yunba.ino
@@ -11,21 +11,21 @@
 uint8_t mac[] = {0xb0, 0x5a, 0xda, 0x3a, 0x2e, 0x7e};

 boolean g_net_status = false;
-char url[32];
-
-char broker_addr[32];
+char url[24];
+
+char broker_addr[24];
 uint16_t port;

 unsigned int g_last_check_ms = 0;
-char client_id[32];
-char username[32];
-char password[32];
+char client_id[24];
+char username[24];
+char password[16];

 EthernetClient net;
 MQTTClient client;
 StaticJsonBuffer<64> jsonBuffer;

-bool get_ip_pair(const char *url, char *addr, uint16_t *port) {
+bool get_ip_port(const char *url, char *addr, uint16_t *port) {
   char *p = strstr(url, "tcp://");
   if (p) {
     p += 6;
@@ -36,6 +36,10 @@
         memcpy(addr, p, len);
         //sprintf(addr, "%.*s", len, p);
         *port = atoi(q + 1);
+        Serial.print("i:");
+        Serial.println(addr);
+        Serial.print("p:");
+        Serial.println(*port);
         return true;
       }
     }
@@ -47,6 +51,29 @@
   EthernetClient net_client;

   while (0 == net_client.connect(host, port)) {
+    Serial.println("c");
+    delay(1000);
+  }
+  delay(100);
+
+  net_client.write(buf, *len);
+  net_client.flush();
+
+  while (!net_client.available()) {
+    Serial.println("a");
+    delay(1000);
+  }
+
+  *len = net_client.read(buf, BUFSIZE - 1);
+  buf[*len] = 0;
+
+  net_client.stop();
+}
+
+void simple_send_recv2(uint8_t *buf, uint16_t *len, IPAddress ip, uint16_t port) {
+  EthernetClient net_client;
+
+  while (0 == net_client.connect(ip, port)) {
     Serial.println("c");
     delay(1000);
   }
@@ -84,7 +111,10 @@
   buf[len] = 0;
   Serial.println((char *)buf + 3);

-  simple_send_recv(buf, &len, "tick-t.yunba.io", 9977);
+//  simple_send_recv(buf, &len, "tick-t.yunba.io", 9977);
+
+  IPAddress ip(101, 200, 229, 48);
+  simple_send_recv2(buf, &len, ip, 9977);

   if (len > 0) {
     len = (uint16_t)(((uint8_t)buf[1] << 8) | (uint8_t)buf[2]);
@@ -130,7 +160,10 @@
   buf[len] = 0;
   Serial.println((char *)buf + 3);

-  simple_send_recv(buf, &len, "reg-t.yunba.io", 9944);
+//  simple_send_recv(buf, &len, "reg-t.yunba.io", 9944);
+
+  IPAddress ip(182, 92, 105, 230);
+  simple_send_recv2(buf, &len, ip, 9944);

   if (len > 0) {
     len = (uint16_t)(((uint8_t)buf[1] << 8) | (uint8_t)buf[2]);
@@ -163,14 +196,14 @@
   }

 //  Serial.println("\nconnected!");
-//  client.subscribe(topic);
+//  client.subscribe(g_topic);
   set_alias(g_devid);
 }

 void check_connect() {
   if (millis() - g_last_check_ms > 2000) {
     boolean st = client.connected();
-    Serial.println(st);
+//    Serial.println(st);
     if (st != g_net_status) {
       Serial.print("cst:");
       g_net_status = st;
@@ -184,7 +217,7 @@
   }
 }

-void messageReceived(String topic, String payload, char * bytes, unsigned int length) {
+void messageReceived(String topic, String payload, char *bytes, unsigned int length) {
   Serial.println("m");
 }

@@ -218,7 +251,7 @@

   //TODO: if we can't get reg info and tick info
   get_host_v2(g_appkey, url);
-  get_ip_pair(url, broker_addr, &port);
+  get_ip_port(url, broker_addr, &port);

   setup_with_appkey_and_devid(g_appkey, g_devid);


Implemented a method to change the channel the robot is in, assuming it is on the "lost robots" channel.

--- firmware/2016/teste_communication/teste_communication.ino
+++ firmware/2016/teste_communication/teste_communication.ino
@@ -18,7 +18,7 @@
   radio.setChannel(108);

   radio.openReadingPipe(1,pipe[my_pipe]);
-  radio.openWritingPipe(pipe[1]);    //n0->central pelo pipe0
+  radio.openWritingPipe(pipe[my_pipe+1]);    //n0->central pelo pipe0

   radio.startListening();
 }
@@ -38,18 +38,36 @@

 int msg_from_central[2] = {0,0};

-void test_receive() {
+bool test_receive() {
   if(radio.available()){
     while (radio.available()) {
       radio.read(&msg_from_central, sizeof(msg_from_central));
     }
     Serial.println(msg_from_central[0]);
     Serial.println(msg_from_central[1]);
+    return true;
   }
+  return false;
+}
+
+
+void set_channel() {
+  radio.stopListening();
+
+  my_pipe = msg_from_central[1];
+
+  radio.openReadingPipe(1,pipe[my_pipe]);
+  radio.openWritingPipe(pipe[my_pipe+1]);
+
+  radio.startListening();
 }

 void loop() {
-  test_receive();
+  bool has_received_message = test_receive();
+  if (my_pipe == 0) {
+    if (has_received_message)
+      set_channel();
+  }
   delay(10);
 }


Move proceedTrigger = true; flag set to deal with interrupt setting to true on startup.

--- Software/BasicController/ArduinoSketch/SerialSequenceUploader/SerialSequenceUploader.ino
+++ Software/BasicController/ArduinoSketch/SerialSequenceUploader/SerialSequenceUploader.ino
@@ -103,6 +103,8 @@
   digitalWrite(outPin, LOW);
   DDRC = B11111111;

+
+
 }

 // ------------------------------------------------------ //
@@ -730,7 +732,8 @@
           cycleNum = 0;
         }
       }
-
+
+   proceedTrigger = true;
    }

      else {
@@ -739,7 +742,7 @@

      LEDToggle = !LEDToggle;

-     proceedTrigger = true;
+
 }

 /*


Revert "arduino pwm"

Revert "arduino pwm"

This reverts commit 23d2cdbd5562185affb1ee0ce5561f0459913964.

--- arduino/cherdak/cherdak.ino
+++ arduino/cherdak/cherdak.ino
@@ -1,10 +1,6 @@
 /* Home Automation Script
    based on Webduino library
    Vasily Klenov, 2014 */
-
-   /* надо переписать пины на массивы
-      и digitalWrite делать только при изменении значения
-    */

 #include "SPI.h"
 #include "Ethernet.h"
@@ -33,27 +29,17 @@
 #define PIN_6 46
 #define PIN_7 47

-#define PWM_PIN_1 8
-
-int pin_1_value = RELAY_OFF;
-int pin_2_value = RELAY_OFF;
-int pin_3_value = RELAY_OFF;
-int pin_4_value = RELAY_OFF;
-int pin_5_value = RELAY_OFF;
-int pin_6_value = RELAY_OFF;
-int pin_7_value = RELAY_OFF;
-
-int pwm_pin_1_value = LOW;
+int pin_1_value = RELAY_OFF;
+int pin_2_value = RELAY_OFF;
+int pin_3_value = RELAY_OFF;
+int pin_4_value = RELAY_OFF;
+int pin_5_value = RELAY_OFF;
+int pin_6_value = RELAY_OFF;
+int pin_7_value = RELAY_OFF;

 /* store the HTML in program memory using the P macro */
 P(On) = "<status>ON</status>";
 P(Off) = "<status>OFF</status>";
-
-// переписать тоже на макрос?
-void printPwmStatus(pwm_value){
-  P(pwmMsg) = "<status></status>"; // дописать
-  server.printP(pwmMsg);
-}

 void httpNotFound(WebServer &server){
   P(failMsg) =
@@ -79,10 +65,7 @@
         if(strcmp(url_path[1], "ON") == 0){
          value = RELAY_ON;
         }
-
-        // тут надо преобразовать строку к числу, это если в запросе передается значение для пвм пина
-        pwm_value = atol(url_path[1]);
-
+
         pin_number = atol(url_path[0]);

         switch (pin_number) {
@@ -104,11 +87,8 @@
           case PIN_6:
             pin_6_value = value;
             break;
-          case PIN_7:
+         case PIN_7:
             pin_7_value = value;
-            break;
-          case PWM_PIN_1:
-            pwm_pin_1_value = pwm_value;
             break;
          }

@@ -120,57 +100,48 @@
   {
     boolean is_on = false;
     int pin_number;
-    int pwm_value = -1;

     pin_number = atol(url_path[0]);

-    switch (pin_number) {
-      case PIN_1:
-        if(pin_1_value == RELAY_ON)
-        {is_on = true;}
-        break;
-      case PIN_2:
-        if(pin_2_value == RELAY_ON)
-        {is_on = true;}
-        break;
-       case PIN_3:
-        if(pin_3_value == RELAY_ON)
-        {is_on = true;}
-        break;
-       case PIN_4:
-        if(pin_4_value == RELAY_ON)
-        {is_on = true;}
-        break;
-      case PIN_5:
-        if(pin_5_value == RELAY_ON)
-        {is_on = true;}
-        break;
-      case PIN_6:
-        if(pin_6_value == RELAY_ON)
-        {is_on = true;}
-        break;
-      case PIN_7:
-        if(pin_7_value == RELAY_ON)
-        {is_on = true;}
-        break;
-      case PWM_PIN_1:
-        pwm_value = pwm_pin_1_value;
-        break;
-    }
-
-    if (pwm_value >= 0)
-    {
-      printPwmStatus( pwm_value );
-    } else
-    {
-      if(is_on)
-      {
-        server.printP( On );
-      } else
-      {
-        server.printP( Off );
-      }
-    }
+     switch (pin_number) {
+          case PIN_1:
+            if(pin_1_value == RELAY_ON)
+            {is_on = true;}
+            break;
+          case PIN_2:
+            if(pin_2_value == RELAY_ON)
+            {is_on = true;}
+            break;
+           case PIN_3:
+            if(pin_3_value == RELAY_ON)
+            {is_on = true;}
+            break;
+           case PIN_4:
+            if(pin_4_value == RELAY_ON)
+            {is_on = true;}
+            break;
+          case PIN_5:
+            if(pin_5_value == RELAY_ON)
+            {is_on = true;}
+            break;
+          case PIN_6:
+            if(pin_6_value == RELAY_ON)
+            {is_on = true;}
+            break;
+          case PIN_7:
+            if(pin_7_value == RELAY_ON)
+            {is_on = true;}
+            break;
+         }
+
+
+    if(is_on)
+   {
+     server.printP( On );
+   } else
+   {
+     server.printP( Off );
+   }

   }
 }
@@ -192,9 +163,6 @@
   pinMode(PIN_5, OUTPUT);
   pinMode(PIN_6, OUTPUT);
   pinMode(PIN_7, OUTPUT);
-
-  digitalWrite(PWM_PIN_1, LOW);
-  pinMode(PWM_PIN_1, OUTPUT);

   //Serial.begin(9600);

@@ -224,7 +192,6 @@
   digitalWrite(PIN_5, pin_5_value);
   digitalWrite(PIN_6, pin_6_value);
   digitalWrite(PIN_7, pin_7_value);
-
-  analogWrite(PWM_PIN_1, pwm_pin_1_value);
+
 }


Use a positive condition.

Use a positive condition.

--- printer.ino
+++ printer.ino
@@ -148,7 +148,7 @@

 // -- Flag to indicate whether we've encountered an irrecoverable error

-boolean systemError = false;
+boolean systemOK = true;

 // -- Check for new data and download if found

@@ -159,7 +159,7 @@

 void abortDueToCacheFailure() {
   flashErrorLEDs(3, 500);
-  systemError = true;
+  systemOK = false;
   digitalWrite(errorLED, HIGH);
 }

@@ -294,7 +294,7 @@
 Bounce bouncer = Bounce(buttonPin, 5); // 5 millisecond debounce

 void loop() {
-  if (!systemError) {
+  if (systemOK) {
     if (downloadWaiting) {
       bouncer.update();
       if (bouncer.read() == HIGH) {


DRY'd up some of the includes

DRY'd up some of the includes

--- Arduino/linkit_duo_led6/linkit_duo_led6.ino
+++ Arduino/linkit_duo_led6/linkit_duo_led6.ino
@@ -1,24 +1,8 @@
-#include <PololuLedStrip.h>
-#include <random_seed.h>
-#include <auto_brightness.h>
-#include <color_math.h>
-#include <colors.h>
-#include <command_processor.h>
-#include <power_ease.h>
-#include <elastic_ease.h>
-#include <blink_effects.h>
-#include <breathe_effects.h>
-#include <effects_processor.h>
-#include <buffer.h>
-#include <render.h>
-#include "command_defs.h"
-#include "commands.h"
+#include "config.h"
+#include "dependencies.h"
 #include "dispatch_command.h"

-#include "config.h"
 Config config;
-
-#include "dependencies.h"
 Dependencies dependencies;

 void setup() {


perhaps we could try refering recent data instead of hte same record all the time...

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -151,7 +151,6 @@
   if(loopCounter == TICK_MONITOR) {
     updateSensorData(monitorData);
     delay(500);
-    if(SEND_DATA) postSensorData(monitorData);
   }
   if(loopCounter == TICK_WIFI_DEBUG) {
     Serial.print("SSID: "); Serial.print(apSSID);
@@ -501,6 +500,8 @@

   if(GOT_LIGHT_SENSOR)
     getLight(&now->lux);
+
+  if(SEND_DATA) postSensorData(&monitorData[monitorCursor]);

   if(++monitorCursor == MONITOR_POINTS)
     monitorCursor = 0;


Move motor control from servo to pwm

Move motor control from servo to pwm

--- firmware/sketchbook/lisa_firmware/lisa_firmware.ino
+++ firmware/sketchbook/lisa_firmware/lisa_firmware.ino
@@ -5,35 +5,57 @@
 #include <geometry_msgs/Twist.h>

 ros::NodeHandle  nh;
+static int motor_pwm_pin = 21;
+static int motor_dir_pin = 22;

 Servo servo_steering;
-Servo servo_motor;

 static int steering_midpoint = 90;
-static int motor_midpoint = 90;
+static unsigned int watchdog = 0;

 void velocity_cb(const geometry_msgs::Twist& cmd_msg){
-  servo_motor.write(motor_midpoint + cmd_msg.linear.x * 300);
-  servo_steering.write(steering_midpoint + cmd_msg.angular.z * 40);
+  watchdog = 0;
+  servo_steering.write(steering_midpoint + cmd_msg.angular.z * 40);
+  if (cmd_msg.linear.x > 0) {
+    digitalWrite(motor_dir_pin, HIGH);
+  } else {
+    digitalWrite(motor_dir_pin, LOW);
+  }
+  analogWrite(motor_pwm_pin, int(abs(cmd_msg.linear.x)));
+}
+
+void reset_car() {
+  digitalWrite(motor_pwm_pin, LOW);
+  digitalWrite(motor_dir_pin, HIGH);
+  analogWrite(motor_pwm_pin, 0);
+  servo_steering.write(steering_midpoint);
 }

-ros::Subscriber<geometry_msgs::Twist> velocity_sub("/cmd_vel_mux/input/teleop", velocity_cb);
+ros::Subscriber<geometry_msgs::Twist> velocity_sub("/cmd_vel_mux/motor_raw", velocity_cb);

 void setup(){
-  pinMode(13, OUTPUT);
+  pinMode(13, OUTPUT); // led
+  pinMode(motor_pwm_pin, OUTPUT); // motor pwm
+  pinMode(motor_dir_pin, OUTPUT); // motor direction
+  digitalWrite(motor_pwm_pin, LOW);
+  digitalWrite(motor_dir_pin, HIGH);

   nh.initNode();
   nh.subscribe(velocity_sub);

   servo_steering.attach(20);
-  servo_motor.attach(21);
+  servo_steering.write(steering_midpoint);

-  servo_steering.write(steering_midpoint);
-  servo_motor.write(motor_midpoint);
+  watchdog = 0;
 }

 void loop(){
   nh.spinOnce();
   delay(1);
+  watchdog ++;
+
+  if (watchdog >= 1000) {
+    reset_car();
+  }
 }


Fixed master delay period

Fixed master delay period

--- RS485/UtilClient/UtilMaster/UtilMaster.ino
+++ RS485/UtilClient/UtilMaster/UtilMaster.ino
@@ -76,7 +76,7 @@
   else digitalWrite(PIN_DEBUG_LED, LOW);

   int elapsed = millis() - start;
-  delay(PERIOD - (elapsed > 0 ? elapsed : 0));
+  delay(PERIOD <= elapsed ? 0 : PERIOD - elapsed);
   cycle++;
 }


add debug code

add debug code

--- arduino/opencr_arduino/opencr/libraries/turtlebot3/examples/turtlebot3_burger/turtlebot3_core/turtlebot3_core.ino
+++ arduino/opencr_arduino/opencr/libraries/turtlebot3/examples/turtlebot3_burger/turtlebot3_core/turtlebot3_core.ino
@@ -112,6 +112,14 @@
     tTime[4] = t;
   }

+#ifdef DEBUG
+  if ((t-tTime[5]) >= (1000 / DEBUG_LOG_FREQUENCY))
+  {
+    sendDebuglog();
+    tTime[5] = t;
+  }
+#endif
+
   // Send log message after ROS connection
   sendLogMsg();

@@ -132,10 +140,6 @@

   // Update Voltage
   battery_state = diagnosis.updateVoltageCheck(setup_end);
-
-#ifdef DEBUG
-  sendDebuglog();
-#endif

   // Call all the callbacks waiting to be called at that point in time
   nh.spinOnce();
@@ -443,22 +447,22 @@

   delta_theta = theta - last_theta;

-  v = delta_s / step_time;
-  w = delta_theta / step_time;
-
-  last_velocity[LEFT]  = wheel_l / step_time;
-  last_velocity[RIGHT] = wheel_r / step_time;
-
   // compute odometric pose
   odom_pose[0] += delta_s * cos(odom_pose[2] + (delta_theta / 2.0));
   odom_pose[1] += delta_s * sin(odom_pose[2] + (delta_theta / 2.0));
   odom_pose[2] += delta_theta;

   // compute odometric instantaneouse velocity
+
+  v = delta_s / step_time;
+  w = delta_theta / step_time;
+
   odom_vel[0] = v;
   odom_vel[1] = 0.0;
   odom_vel[2] = w;

+  last_velocity[LEFT]  = wheel_l / step_time;
+  last_velocity[RIGHT] = wheel_r / step_time;
   last_theta = theta;

   return true;
@@ -480,14 +484,14 @@
   if (buttons & (1<<0))
   {
     move[LINEAR] = true;
-    saved_tick[RIGHT] = sensor_state_msg.right_encoder;
+    saved_tick[RIGHT] = current_tick[RIGHT];

     diff_encoder = TEST_DISTANCE / (0.207 / 4096); // (Circumference of Wheel) / (The number of tick per revolution)
   }
   else if (buttons & (1<<1))
   {
     move[ANGULAR] = true;
-    saved_tick[RIGHT] = sensor_state_msg.right_encoder;
+    saved_tick[RIGHT] = current_tick[RIGHT];

     diff_encoder = (TEST_RADIAN * TURNING_RADIUS) / (0.207 / 4096);
   }
@@ -700,31 +704,42 @@
 {
   DEBUG_SERIAL.println("---------------------------------------");
   DEBUG_SERIAL.println("EXTERNAL SENSORS");
-  DEBUG_SERIAL.println("---------------------------------------\n");
-  DEBUG_SERIAL.println("bumper : ");
-  DEBUG_SERIAL.println("cliff : ");
-  DEBUG_SERIAL.println("sonar : ");
-  DEBUG_SERIAL.println("illumination : ");
-  DEBUG_SERIAL.println("led : ");
+  DEBUG_SERIAL.println("---------------------------------------");
+  DEBUG_SERIAL.print("Bumper : "); DEBUG_SERIAL.println(sensors.getPushedBumper());
+  DEBUG_SERIAL.print("Cliff : "); DEBUG_SERIAL.println(sensors.getIRsensorData());
+  DEBUG_SERIAL.print("Sonar : "); DEBUG_SERIAL.println(sensors.getSonarData());
+  DEBUG_SERIAL.print("Illumination : "); DEBUG_SERIAL.println(sensors.getIlluminationData());

   DEBUG_SERIAL.println("---------------------------------------");
   DEBUG_SERIAL.println("OpenCR SENSORS");
-  DEBUG_SERIAL.println("---------------------------------------\n");
-  DEBUG_SERIAL.println("battery : ");
-  DEBUG_SERIAL.println("button : ");
-  DEBUG_SERIAL.println("imu : ");
+  DEBUG_SERIAL.println("---------------------------------------");
+  DEBUG_SERIAL.print("Battery : "); DEBUG_SERIAL.println(sensors.checkVoltage());
+  DEBUG_SERIAL.println("Button : " + String(sensors.checkPushButton()));
+
+  float* quat = sensors.getOrientation();
+
+  DEBUG_SERIAL.println("IMU : ");
+  DEBUG_SERIAL.print("    w : "); DEBUG_SERIAL.println(quat[0]);
+  DEBUG_SERIAL.print("    x : "); DEBUG_SERIAL.println(quat[1]);
+  DEBUG_SERIAL.print("    y : "); DEBUG_SERIAL.println(quat[2]);
+  DEBUG_SERIAL.print("    z : "); DEBUG_SERIAL.println(quat[3]);

   DEBUG_SERIAL.println("---------------------------------------");
   DEBUG_SERIAL.println("DYNAMIXELS");
-  DEBUG_SERIAL.println("---------------------------------------\n");
-  DEBUG_SERIAL.println("torque : ");
-  DEBUG_SERIAL.println("left_encoder : ");
-  DEBUG_SERIAL.println("right_encoder : ");
+  DEBUG_SERIAL.println("---------------------------------------");
+  DEBUG_SERIAL.println("Torque : " + String(motor_driver.getTorque()));
+
+  int32_t encoder[WHEEL_NUM] = {0, 0};
+  motor_driver.readEncoder(encoder[LEFT], encoder[RIGHT]);
+
+  DEBUG_SERIAL.println("Encoder(left) : " + String(encoder[LEFT]));
+  DEBUG_SERIAL.println("Encoder(right) : " + String(encoder[RIGHT]));

   DEBUG_SERIAL.println("---------------------------------------");
   DEBUG_SERIAL.println("TurtleBot3");
-  DEBUG_SERIAL.println("---------------------------------------\n");
-  DEBUG_SERIAL.println("odometry : ");
-
-  // Serial.println("   id : " + String(scanned_id[i]) + "   Model Name : " + String(dxl_wb.getModelName(scanned_id[i])));
+  DEBUG_SERIAL.println("---------------------------------------");
+  DEBUG_SERIAL.println("Odometry : ");
+  DEBUG_SERIAL.print("         x : "); DEBUG_SERIAL.println(odom_pose[0]);
+  DEBUG_SERIAL.print("         y : "); DEBUG_SERIAL.println(odom_pose[1]);
+  DEBUG_SERIAL.print("     theta : "); DEBUG_SERIAL.println(odom_pose[2]);
 }


Removed delays in PLL comms

Removed delays in PLL comms

--- src/Arduino/_23cm-trx/PLL.ino
+++ src/Arduino/_23cm-trx/PLL.ino
@@ -117,20 +117,23 @@
 /*
  * Sends the lower 3 bytes in the given long,
  * most significant bit first.
+ *
+ * No delays, as the CPU clock is 16Mhz.
+ * See page 15: The maximum allowable serial clock rate is 20 MHz.
+ * This means that the maximum update rate possible for the device
+ * is 833 kHz, or one update every 1.2 μs. This rate is more than
+ * adequate for systems that have typical lock times in the
+ * hundreds of microseconds.
  */
 void writePLL(unsigned long reg) {
   for (int i=0; i<24; i++) {
     digitalWrite(DATA, (reg & 0x800000) );
-    delayMicroseconds(1);
     digitalWrite(CLK, HIGH);
-    delayMicroseconds(1);
     digitalWrite(CLK, LOW);
     reg <<= 1;
   }

-   delayMicroseconds(1);
    digitalWrite(LE,HIGH);
-   delayMicroseconds(1);
    digitalWrite(LE,LOW);
 }


changed default version of controlling interface

--- src/sonoff-eeprom.ino
+++ src/sonoff-eeprom.ino
@@ -247,7 +247,8 @@
   saveDurationBetweenConnectionAttempts(sonoffDefault.duration_between_connection_attempts);
   saveDurationBetweenNextConnectionAttemptsSeries(sonoffDefault.duration_between_next_connection_attempts_series);

-  saveInterface(1);
+  /* Default interface to control swich is set to manual */
+  saveInterface(INTERFACE_NONE);

   saveDebuggable(0);


Remove

Remove

--- L298N_Dual_H_Bridge_Keyboard_Control_Reichenstein7/L298N_Dual_H_Bridge_Keyboard_Control_Reichenstein7.ino
+++ L298N_Dual_H_Bridge_Keyboard_Control_Reichenstein7/L298N_Dual_H_Bridge_Keyboard_Control_Reichenstein7.ino
@@ -1,109 +0,0 @@
-//Code by Reichenstein7 (thejamerson.com)
-
-//Keyboard Controls:
-//
-// 1 -Motor 1 Left
-// 2 -Motor 1 Stop
-// 3 -Motor 1 Right
-//
-// 4 -Motor 2 Left
-// 5 -Motor 2 Stop
-// 6 -Motor 2 Right
-
-// Declare L298N Dual H-Bridge Motor Controller directly since there is not a library to load.
-
-// Motor 1
-int dir1PinA = 2;
-int dir2PinA = 3;
-int speedPinA = 9; // Needs to be a PWM pin to be able to control motor speed
-
-// Motor 2
-int dir1PinB = 4;
-int dir2PinB = 5;
-int speedPinB = 10; // Needs to be a PWM pin to be able to control motor speed
-
-void setup() {  // Setup runs once per reset
-// initialize serial communication @ 9600 baud:
-Serial.begin(9600);
-
-//Define L298N Dual H-Bridge Motor Controller Pins
-
-pinMode(dir1PinA,OUTPUT);
-pinMode(dir2PinA,OUTPUT);
-pinMode(speedPinA,OUTPUT);
-pinMode(dir1PinB,OUTPUT);
-pinMode(dir2PinB,OUTPUT);
-pinMode(speedPinB,OUTPUT);
-
-}
-
-void loop() {
-
-// Initialize the Serial interface:
-
-if (Serial.available() > 0) {
-int inByte = Serial.read();
-int speed; // Local variable
-
-switch (inByte) {
-
-//______________Motor 1______________
-
-case '1': // Motor 1 Forward
-analogWrite(speedPinA, 255);//Sets speed variable via PWM
-digitalWrite(dir1PinA, LOW);
-digitalWrite(dir2PinA, HIGH);
-Serial.println("Motor 1 Forward"); // Prints out “Motor 1 Forward” on the serial monitor
-Serial.println("   "); // Creates a blank line printed on the serial monitor
-break;
-
-case '2': // Motor 1 Stop (Freespin)
-analogWrite(speedPinA, 0);
-digitalWrite(dir1PinA, LOW);
-digitalWrite(dir2PinA, HIGH);
-Serial.println("Motor 1 Stop");
-Serial.println("   ");
-break;
-
-case '3': // Motor 1 Reverse
-analogWrite(speedPinA, 255);
-digitalWrite(dir1PinA, HIGH);
-digitalWrite(dir2PinA, LOW);
-Serial.println("Motor 1 Reverse");
-Serial.println("   ");
-break;
-
-//______________Motor 2______________
-
-case '4': // Motor 2 Forward
-analogWrite(speedPinB, 255);
-digitalWrite(dir1PinB, LOW);
-digitalWrite(dir2PinB, HIGH);
-Serial.println("Motor 2 Forward");
-Serial.println("   ");
-break;
-
-case '5': // Motor 1 Stop (Freespin)
-analogWrite(speedPinB, 0);
-digitalWrite(dir1PinB, LOW);
-digitalWrite(dir2PinB, HIGH);
-Serial.println("Motor 2 Stop");
-Serial.println("   ");
-break;
-
-case '6': // Motor 2 Reverse
-analogWrite(speedPinB, 255);
-digitalWrite(dir1PinB, HIGH);
-digitalWrite(dir2PinB, LOW);
-Serial.println("Motor 2 Reverse");
-Serial.println("   ");
-break;
-
-default:
-// turn all the connections off if an unmapped key is pressed:
-for (int thisPin = 2; thisPin < 11; thisPin++) {
-digitalWrite(thisPin, LOW);
-}
-  }
-    }
-      }


small ajusting

small ajusting

--- testing/arduino/self-driving-v3.ino
+++ testing/arduino/self-driving-v3.ino
@@ -14,7 +14,6 @@

 const uint8_t motorPin2_1 = 7;
 const uint8_t motorPin2_2 = 8;
-

 const uint8_t motorEnablePin = 3;

@@ -108,7 +107,7 @@
 {
     long range = GetUltrasoundRange();

-    int motorSpeed = 1 * 255;
+    uint8_t motorSpeed = 1 * 255;
     uint32_t color = LEDStrip.Color(0, 255, 0);
     if(range < rangeLimit_Warning1) { motorSpeed = 0.6 * 255; color = LEDStrip.Color(127, 255, 0);}
     if(range < rangeLimit_Warning2) { motorSpeed = 0.5 * 255; color = LEDStrip.Color(255, 255, 0); }


clean up display

clean up display

--- examples/RF12/rf12compat/rf12compat.ino
+++ examples/RF12/rf12compat/rf12compat.ino
@@ -12,16 +12,16 @@

 void loop() {
   if (rf12_recvDone()) {
-    Serial.print("OK dst: ");
+    Serial.print(rf12_crc == 0 ? "OK" : " ?");
+    Serial.print(" dst: ");
     Serial.print(rf12_dst, HEX);
     Serial.print(" hdr: ");
     Serial.print(rf12_hdr, HEX);
     Serial.print(' ');
-    for (int i = 0; i < rf12_len; ++i) {
+    for (int i = 0; i < rf12_len && i < 66; ++i) {
       Serial.print(rf12_data[i] >> 4, HEX);
       Serial.print(rf12_data[i] & 0xF, HEX);
     }
-    Serial.print(" crc: ");
-    Serial.println(rf12_crc, HEX);
+    Serial.println();
   }
 }


Added support for meta characters and more whitespace characters


Added heartbeat and one-wire config dump to FreezerMote.

--- freezer_mote_v0_1/freezer_mote_v0_1.ino
+++ freezer_mote_v0_1/freezer_mote_v0_1.ino
@@ -45,7 +45,8 @@
 #define APIN_LDR        1  // data connection for photocell
 #define DPIN_ONEWIRE    3  // data connection for the Dallas OneWire bus
 #define DPIN_HALL       7  // data connection for hall effect
-#define DPIN_RF_LED     9  // led indicating rf traffic
+#define DPIN_RF_LED     2  // rf activiyy indicator LED
+#define DPIN_MOTE_LED   9  // moteinos have LEDs on D9
 #define VOLTAGE         3.3

 #define MEASURE_PERIOD  100
@@ -118,6 +119,8 @@
 // main processing loop
 //
 void loop() {
+
+    heartbeat(DPIN_MOTE_LED);

     switch (scheduler.pollWaiting()) {

@@ -148,6 +151,30 @@
 }

 //------------------------------------------------------------------------------
+// simulates a heartbeat to show activity
+//
+static void heartbeat(int pin) {
+    int rate = 25;
+    int pmw = 255;
+    for(int i = 0; i < pmw; i++) {
+        analogWrite(pin,i);
+        delay(((60000/rate)*.1)/pmw);
+    }
+    for (int i = pmw; i > 0; i--){
+        analogWrite(pin,i);
+        delay(((60000/rate)*.2)/pmw);
+    }
+    for(int i = 0; i < pmw; i++) {
+        analogWrite(pin,i);
+        delay(((60000/rate)*.1)/pmw);
+    }
+    for (int i = pmw; i > 0; i--){
+        analogWrite(pin,i);
+        delay(((60000/rate)*.6)/pmw);
+    }
+}
+
+//------------------------------------------------------------------------------
 // flushes the serial port
 //
 static void serialFlush () {
@@ -253,7 +280,20 @@
     #if DEBUG
         Serial.println("setup sensors");
     #endif
+
     pinMode(APIN_LDR, INPUT);
     pinMode(DPIN_HALL, INPUT);
-    oneWireSensors.begin();
-}
+
+    // configure one-wire bus
+    oneWireSensors.begin();
+    #if DEBUG
+        Serial.print("Locating devices...");
+        Serial.print("Found ");
+        Serial.print(oneWireSensors.getDeviceCount(), DEC);
+        Serial.println(" devices.");
+
+        Serial.print("Parasite power is: ");
+        if (oneWireSensors.isParasitePowerMode()) Serial.println("ON");
+        else Serial.println("OFF");
+    #endif
+}


Add unencapsulated business logic for file I/O

--- payload/payload.ino
+++ payload/payload.ino
@@ -17,11 +17,11 @@

 custom::Bmp180 bmp;
 File file; // file object
-//SdFatSdio sd_card; // MicroSD card
+SdFatSdio sd_card; // MicroSD card

 // Array of pointers to Setupable-implementing objects which require
 // initialization logic to take place in setup() function.
-// For more info, see "Setupable.h".
+// For more info, see "setupable.h".
 custom::Setupable* setupables[] = { &bmp };

 void setup() {
@@ -42,6 +42,15 @@
   delay(512);
   Serial.println(".");
   Serial.println();
+  delay(512);
+
+  // Setup MicroSD card I/O.
+  if(!sd_card.begin()) {
+    Serial.println("ERROR: SD card could not be found.");
+  }
+  else {
+    Serial.println("SD card ready.");
+  }

   // Setup() the custom data structures.
   for (custom::Setupable* obj : setupables) {
@@ -51,6 +60,22 @@
   Serial.println();
   Serial.println("SETUP COMPLETE.");
   Serial.println();
+}
+
+void write_to_sd(void) {
+  auto log_path = "nolan-tests\\nolan-test.log";
+  sd_card.remove(log_path); // remove file from last time.
+
+  File file = sd_card.open(log_path, FILE_WRITE); // Open a new file for writing.
+
+  // Initiate file for writing.
+  if(!file) {
+    Serial.println("File could not be initialized.");
+  }
+  else {
+    file.println("I'm text in a file!");
+    file.close(); // Close when finished.
+  }
 }

 void printBmpData(void) {
@@ -68,8 +93,14 @@
   Serial.println();
 }

+bool written = false;
+
 void loop() {
   printBmpData();
+  if (!written) {
+    write_to_sd();
+    written = true;
+  }
   delay(1000);
 }


Use interrupts for display driving

Use interrupts for display driving

--- telepulssi_driver.ino
+++ telepulssi_driver.ino
@@ -1,8 +1,10 @@
+
 /*
   Telepulssi TP-KN10 slave LED screen driver
 */

 #include <SPI.h>
+#include <TimerOne.h>

 static uint8_t koira14[] = {
   0x09, 0x00, 0x01, 0x00, 0x12, 0x04, 0x04, 0x04, 0x05, 0x00, 0x00, 0x00,
@@ -23,12 +25,17 @@
 	DDRD = 0xFF;
 	// initialize SPI:
 	SPI.begin();
+	Timer1.initialize(200);
+	Timer1.attachInterrupt(driveDisplay);
 }

 uint8_t col_i = 0;
 uint8_t row_i = 0;

 void loop() {
+}
+
+void driveDisplay() {
 	// Main screen turn off
 	PORTC = 0xFF;
 	PORTD = 0xFF; // Latch data on pin 5 at the same time
@@ -62,6 +69,5 @@
 	digitalWrite(5, LOW);

 	// Send new data and sleep a bit. FIXME use clock interrupt
-	SPI.transfer(koira14[8*row_i+col_i]);
-	delayMicroseconds(200);
+	SPDR = koira14[8*row_i+col_i];
 }


Fix undeclared currentStatusValue variables

--- GarHAge.ino
+++ GarHAge.ino
@@ -116,7 +116,7 @@
 // Functions that run in loop() to check door statuses (open/closed) each loop and publish any change

 void check_door1_status() {
-  currentStatusValue = digitalRead(door1_statusPin);
+  int currentStatusValue = digitalRead(door1_statusPin);
   if (currentStatusValue != door1_lastStatusValue) {
     if (digitalRead(door1_statusPin) == HIGH) {
       Serial.print(door1_alias);
@@ -137,7 +137,7 @@
 }

 void check_door2_status() {
-  currentStatusValue = digitalRead(door2_statusPin);
+  int currentStatusValue = digitalRead(door2_statusPin);
   if (currentStatusValue != door2_lastStatusValue) {
     if (digitalRead(door2_statusPin) == HIGH) {
       Serial.print(door2_alias);


Added esc key

Added esc key


modified note

modified note

--- arduino/opencr_arduino/opencr/libraries/turtlebot3/examples/turtlebot3_burger/turtlebot3_core/turtlebot3_core.ino
+++ arduino/opencr_arduino/opencr/libraries/turtlebot3/examples/turtlebot3_burger/turtlebot3_core/turtlebot3_core.ino
@@ -143,7 +143,7 @@
 }

 /*******************************************************************************
-* Callback function for cmd_vel msg
+* Callback function for sound msg
 *******************************************************************************/
 void soundCallback(const turtlebot3_msgs::Sound& sound_msg)
 {


Delete JsonServer.ino

Delete JsonServer.ino

--- src/third-party/arduino-json-5.1.1/examples/JsonServer/JsonServer.ino
+++ src/third-party/arduino-json-5.1.1/examples/JsonServer/JsonServer.ino
@@ -1,74 +0,0 @@
-// Sample Arduino Json Web Server
-// Created by Benoit Blanchon.
-// Heavily inspired by "Web Server" from David A. Mellis and Tom Igoe
-
-#include <SPI.h>
-#include <Ethernet.h>
-#include <ArduinoJson.h>
-
-byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
-IPAddress ip(192, 168, 0, 177);
-EthernetServer server(80);
-
-bool readRequest(EthernetClient& client) {
-  bool currentLineIsBlank = true;
-  while (client.connected()) {
-    if (client.available()) {
-      char c = client.read();
-      if (c == '\n' && currentLineIsBlank) {
-        return true;
-      } else if (c == '\n') {
-        currentLineIsBlank = true;
-      } else if (c != '\r') {
-        currentLineIsBlank = false;
-      }
-    }
-  }
-  return false;
-}
-
-JsonObject& prepareResponse(JsonBuffer& jsonBuffer) {
-  JsonObject& root = jsonBuffer.createObject();
-
-  JsonArray& analogValues = root.createNestedArray("analog");
-  for (int pin = 0; pin < 6; pin++) {
-    int value = analogRead(pin);
-    analogValues.add(value);
-  }
-
-  JsonArray& digitalValues = root.createNestedArray("digital");
-  for (int pin = 0; pin < 14; pin++) {
-    int value = digitalRead(pin);
-    digitalValues.add(value);
-  }
-
-  return root;
-}
-
-void writeResponse(EthernetClient& client, JsonObject& json) {
-  client.println("HTTP/1.1 200 OK");
-  client.println("Content-Type: application/json");
-  client.println("Connection: close");
-  client.println();
-
-  json.prettyPrintTo(client);
-}
-
-void setup() {
-  Ethernet.begin(mac, ip);
-  server.begin();
-}
-
-void loop() {
-  EthernetClient client = server.available();
-  if (client) {
-    bool success = readRequest(client);
-    if (success) {
-      StaticJsonBuffer<500> jsonBuffer;
-      JsonObject& json = prepareResponse(jsonBuffer);
-      writeResponse(client, json);
-    }
-    delay(1);
-    client.stop();
-  }
-}


add OTA support

add OTA support

Not tested

--- AI-Thinker_RGBW_Bulb.ino
+++ AI-Thinker_RGBW_Bulb.ino
@@ -7,19 +7,20 @@
 #include <ESP8266WiFi.h>          // https://github.com/esp8266/Arduino
 #include <PubSubClient.h>         // https://github.com/knolleary/pubsubclient
 #include <ArduinoJson.h>          // https://github.com/bblanchon/ArduinoJson
+#include <ArduinoOTA.h>
 #include "AI-Thinker_RGBW_Bulb.h"

 #if defined(DEBUG_TELNET)
-  WiFiServer  telnetServer(23);
-  WiFiClient  telnetClient;
-  #define     DEBUG_PRINT(x)    telnetClient.print(x)
-  #define     DEBUG_PRINTLN(x)  telnetClient.println(x)
+WiFiServer  telnetServer(23);
+WiFiClient  telnetClient;
+#define     DEBUG_PRINT(x)    telnetClient.print(x)
+#define     DEBUG_PRINTLN(x)  telnetClient.println(x)
 #elif defined(DEBUG_SERIAL)
-  #define     DEBUG_PRINT(x)    Serial.print(x)
-  #define     DEBUG_PRINTLN(x)  Serial.println(x)
+#define     DEBUG_PRINT(x)    Serial.print(x)
+#define     DEBUG_PRINTLN(x)  Serial.println(x)
 #else
-  #define     DEBUG_PRINT(x)
-  #define     DEBUG_PRINTLN(x)
+#define     DEBUG_PRINT(x)
+#define     DEBUG_PRINTLN(x)
 #endif

 AIRGBWBulb    bulb;
@@ -49,6 +50,62 @@
 #endif

 ///////////////////////////////////////////////////////////////////////////
+//   OTA
+///////////////////////////////////////////////////////////////////////////
+#if defined(OTA)
+void setupOTA() {
+#if defined(OTA_HOSTNAME)
+  ArduinoOTA.setHostname(OTA_HOSTNAME);
+  DEBUG_PRINT(F("INFO: OTA hostname sets to: "));
+  DEBUG_PRINTLN(OTA_HOSTNAME);
+#endif
+
+#if defined(OTA_PORT)
+  ArduinoOTA.setPort(OTA_PORT);
+  DEBUG_PRINT(F("INFO: OTA port sets to: "));
+  DEBUG_PRINTLN(OTA_PORT);
+#endif
+
+#if defined(OTA_PASSWORD)
+  ArduinoOTA.setPassword((const char *)OTA_PASSWORD);
+  DEBUG_PRINT(F("INFO: OTA password sets to: "));
+  DEBUG_PRINTLN(OTA_PASSWORD);
+#endif
+
+  ArduinoOTA.onStart([]() {
+    DEBUG_PRINTLN(F("INFO: OTA starts"));
+  });
+  ArduinoOTA.onEnd([]() {
+    DEBUG_PRINTLN(F("INFO: OTA ends"));
+  });
+  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
+    DEBUG_PRINT(F("INFO: OTA progresses: "));
+    DEBUG_PRINT(progress / (total / 100));
+    DEBUG_PRINTLN(F("%"));
+  });
+  ArduinoOTA.onError([](ota_error_t error) {
+    DEBUG_PRINT(F("ERROR: OTA error: "));
+    DEBUG_PRINTLN(error);
+    if (error == OTA_AUTH_ERROR)
+      DEBUG_PRINTLN(F("ERROR: OTA auth failed"));
+    else if (error == OTA_BEGIN_ERROR)
+      DEBUG_PRINTLN(F("ERROR: OTA begin failed"));
+    else if (error == OTA_CONNECT_ERROR)
+      DEBUG_PRINTLN(F("ERROR: OTA connect failed"));
+    else if (error == OTA_RECEIVE_ERROR)
+      DEBUG_PRINTLN(F("ERROR: OTA receive failed"));
+    else if (error == OTA_END_ERROR)
+      DEBUG_PRINTLN(F("ERROR: OTA end failed"));
+  });
+  ArduinoOTA.begin();
+}
+
+void handleOTA() {
+  ArduinoOTA.handle();
+}
+#endif
+
+///////////////////////////////////////////////////////////////////////////
 //   MQTT
 ///////////////////////////////////////////////////////////////////////////

@@ -64,6 +121,10 @@
   telnetServer.setNoDelay(true);
 #endif

+#if defined(OTA)
+  setupOTA();
+#endif
+
   bulb.init();
 }

@@ -74,6 +135,12 @@
 #endif

   yield();
-
+
+#if defined(OTA)
+  handleOTA();
+#endif
+
+  yield();
+
   bulb.loop();
 }


Removed speed parser. Now it accepts all values from 0 to 400

--- rover/rover.ino
+++ rover/rover.ino
@@ -5,7 +5,6 @@

 #define BUFFSIZE   128
 #define MAX_POWER  400
-#define MIN_POWER -400

 // Command interpreter logic
 const static boolean DEBUG = false;
@@ -54,13 +53,13 @@
   if (adk.isReady()) {
       adk.read(&bytesRead, BUFFSIZE, buffer);
     if (bytesRead > 0) {
-      jeepCommandInterpreter(buffer[0] - 48, buffer[1] - 48);
+      jeepCommandInterpreter(extractMovement(), extractSpeed());
     }
   }
 }

 void jeepCommandInterpreter(uint8_t commandMovement, uint8_t commandSpeed) {
-  int vPower = speedToPower(commandSpeed);
+  int vPower = motorProtection(commandSpeed);
   Serial.print("Required power: ");Serial.println(vPower);

   switch(commandMovement) {
@@ -138,31 +137,9 @@
   motor.setM2Speed(0);
 }

-// Movement helpers
-int speedToPower(uint8_t speed) {
-  int v;
-  switch(speed) {
-    case 1:
-      v = 150;
-      break;
-    case 2:
-      v = 250;
-      break;
-    case 3:
-      v = 300;
-      break;
-    default:
-      v = 0;
-      break;
-  }
-
-  // Return a safe motor power
-  return motorProtection(v);
-}
-
 // Emergency checks
 int motorProtection(int v) {
-  if (v <= MAX_POWER && v >= MIN_POWER) {
+  if (v >= 0 && v <= MAX_POWER) {
     return v;
   } else {
     Serial.println("DANGER: too much V!");
@@ -183,7 +160,7 @@

   if (bytesRead == 2) {
     // Send commands to internal controller
-    jeepCommandInterpreter(buffer[0] - 48, buffer[1] - 48);
+    jeepCommandInterpreter(extractMovement(), extractSpeed());
     resetBuffer();
   }
 }
@@ -206,3 +183,19 @@
   }
 }

+uint8_t extractMovement() {
+  return buffer[0] - 48;
+}
+
+uint8_t extractSpeed() {
+  uint8_t speedBuffer[3] = { 45, 45, 45 };
+
+  int i = 0;
+  while (buffer[i + 2] >= 48 && i < 3) {
+    speedBuffer[i] = buffer[i + 2];
+    i++;
+  }
+
+  return atoi((char*)speedBuffer);
+}
+


Additional clean for EEPROM added

Additional clean for EEPROM added

--- ArduCAM_OSD/OSD_Config_Func.ino
+++ ArduCAM_OSD/OSD_Config_Func.ino
@@ -62,12 +62,20 @@

 // Write our latest FACTORY settings to EEPROM
 void writeSettings() {
+static int i;
+
 	// Writing all default parameters to EEPROM, ON = panel enabled
 	// All panels have 3 values:
 	//  - Enable/Disable
 	//  - X coordinate on screen
 	//  - Y coordinate on screen
 	uint16_t offset = OffsetBITpanel * panel;
+
+	// cleanup EEPROM first
+	for (i = panCenter_en_ADDR; i <= panDistance_y_ADDR; ++i) {
+		writeEEPROM(off, i + offset);
+	}
+
 	//    writeEEPROM(off, panCenter_en_ADDR + offset);
 	//    writeEEPROM(13, panCenter_x_ADDR + offset);
 	//    writeEEPROM(7,  panCenter_y_ADDR + offset);
@@ -107,9 +115,9 @@
 	writeEEPROM(on, panHomeDis_en_ADDR + offset);
 	writeEEPROM(22, panHomeDis_x_ADDR + offset);
 	writeEEPROM(1,  panHomeDis_y_ADDR + offset);
-	//writeEEPROM(off,panWPDir_en_ADDR);
-	//writeEEPROM(27,  panWPDir_x_ADDR);
-	//writeEEPROM(12,  panWPDir_y_ADDR);
+	writeEEPROM(off,panWPDir_en_ADDR);
+	writeEEPROM(27,  panWPDir_x_ADDR);
+	writeEEPROM(12,  panWPDir_y_ADDR);
 	writeEEPROM(off,panWPDis_en_ADDR);
 	writeEEPROM(9,  panWPDis_x_ADDR);
 	writeEEPROM(14, panWPDis_y_ADDR);
@@ -194,8 +202,8 @@
 	writeEEPROM(1,current_calibration_div_A_ADDR);
 	writeEEPROM(0,current_offset_A_ADDR);

-        writeEEPROM(1, temperature_calibration_ADDR);
-        writeEEPROM(0, temperature_offset_ADDR);
+    writeEEPROM(1, temperature_calibration_ADDR);
+    writeEEPROM(0, temperature_offset_ADDR);

 }
 void readSettings() {


full brightness!

full brightness!

--- Arduino/adrilight/adrilight.ino
+++ Arduino/adrilight/adrilight.ino
@@ -4,8 +4,8 @@
 #define LED_DATA_PIN 3
 #define NUM_BYTES (NUM_LEDS*3) // 3 colors

-#define BRIGHTNESS 100
-#define UPDATES_PER_SECOND 100
+#define BRIGHTNESS 255
+#define UPDATES_PER_SECOND 60

 #define TIMEOUT 3000


Constant tweaks

Constant tweaks

--- Cymatic-Triangles/Mic.ino
+++ Cymatic-Triangles/Mic.ino
@@ -18,8 +18,8 @@

 #define BRIGHTNESS_GRAVITY (6.0 / ANIMATE_SECS_PER_TICK)
 #define BRIGHTNESS_INITIAL_VEL_COEFF 6
-#define ROTATION_ACCEL (0.3 / ANIMATE_SECS_PER_TICK)
-#define ROTATION_FRICTION (0.03 / ANIMATE_SECS_PER_TICK)
+#define ROTATION_ACCEL (0.1 / ANIMATE_SECS_PER_TICK)
+#define ROTATION_FRICTION (0.10 / ANIMATE_SECS_PER_TICK)
 /* Between 0 and 1, when the particle starts to accelerate on the amplitude
    scale */
 #define ACCELERATION_THRESHOLD 0.1


Update tclab2.ino

Update tclab2.ino

--- 0_Test_Device/Python/tclab2/tclab2.ino
+++ 0_Test_Device/Python/tclab2/tclab2.ino
@@ -1,7 +1,7 @@
 /*
   TCLab Temperature Control Lab Firmware
-  Jeffrey Kantor
-  February, 2019
+  Jeffrey Kantor, Bill Tubbs, John Hedengren
+  May 2019

   This firmware provides a high level interface to the Temperature Control Lab. The
   firmware scans the serial port for commands. Commands are case-insensitive. Any
@@ -58,6 +58,7 @@
       1.4.2 fix bug with X command
       1.4.3 required Arduino IDE Version >= 1.0.0
       1.5.0 remove webusb
+      1.6.0 average 10 temperature measurements to reduce noise
 */

 #include "Arduino.h"
@@ -141,7 +142,11 @@

 // return thermister temperature in °C
 inline float readTemperature(int pin) {
-  return analogRead(pin) * 0.3223 - 50.0;
+  float read_sum = 0.;
+  for(i=0;i<10;i++) {
+    read_sum += analogRead(pin) * 0.3223 - 50.0
+  }
+  return read_sum / 10;
 }

 void parseCommand(void) {
@@ -313,4 +318,4 @@
   dispatchCommand();
   checkAlarm();
   updateStatus();
-}+}


send FSM status to BLE app on connection

--- sploder.ino
+++ sploder.ino
@@ -78,6 +78,17 @@
     }
     if (bleStatus == ACI_EVT_CONNECTED) {
       info("BLE connected");
+      // Immediately send the current state of the FSM
+      // Have to use the library print() helper, as the current status has not been updated yet
+      if (stateMachine.isInState(readyState)) {
+        BluetoothLESerial.print("ready");
+      }
+      if (stateMachine.isInState(armedState)) {
+        BluetoothLESerial.print("armed");
+      }
+      if (stateMachine.isInState(firingState)) {
+        BluetoothLESerial.print("firing");
+      }
     }
     if (bleStatus == ACI_EVT_DISCONNECTED) {
       info("BLE disconnected");


Test.ino: Made it use PololuHD44780 instead of a custom class.  Made it display well in the default Arduino IDE width of 65 characters.

--- PololuHD44780/examples/Test/Test.ino
+++ PololuHD44780/examples/Test/Test.ino
@@ -1,64 +1,12 @@
-#include <Wire.h>
-#include <FastGPIO.h>
-#include <USBPause.h>  // TODO: change to UsbPause.h after that library is released
+/** Test program for the PololuHD44780 library which test all of
+ * the functions it defines.  This program is mainly meant as a
+ * test suite for library developers who want to make sure that
+ * their changes did not break any previously-working features of
+ * the library. */
+
 #include <PololuHD44780.h>
-#include <util/delay.h>
-
-// TODO: change this to use PololuHD44780, remove this class and make sure PololuHD44780 works
-
-class MyLCD : public PololuHD44780Base
-{
-    static const uint8_t rs = 7;
-    static const uint8_t e = 8;
-    static const uint8_t db4 = 14;
-    static const uint8_t db5 = 17;
-    static const uint8_t db6 = 13;
-    static const uint8_t db7 = IO_D5;
-
-public:
-
-    virtual void initPins()
-    {
-        FastGPIO::Pin<e>::setOutputLow();
-    }
-
-    virtual void send(uint8_t data, bool rsValue, bool only4bits)
-    {
-        FastGPIO::Pin<rs>::setOutput(rsValue);
-
-        USBPause usbPause;
-        FastGPIO::PinLoan<db4> loanDB4;
-        FastGPIO::PinLoan<db5> loanDB5;
-        FastGPIO::PinLoan<db6> loanDB6;
-        FastGPIO::PinLoan<db7> loanDB7;
-
-        if (!only4bits)
-        {
-            sendNibble(data >> 4);
-        }
-        sendNibble(data & 0x0F);
-    }
-
-private:
-    void sendNibble(uint8_t data)
-    {
-        FastGPIO::Pin<db4>::setOutput(data >> 0 & 1);
-        FastGPIO::Pin<db5>::setOutput(data >> 1 & 1);
-        FastGPIO::Pin<db6>::setOutput(data >> 2 & 1);
-        FastGPIO::Pin<db7>::setOutput(data >> 3 & 1);
-
-        // Send a pulse on the Enable line.  According to the "Bus
-        // Timing Characteristics" section of the HD44780 datasheet,
-        // 450 ns is the minimum enable pulse width (PW_EH) and the
-        // minimum enable cycle time is 1000 ns.
-        FastGPIO::Pin<e>::setOutputHigh();
-        _delay_us(1);   // At least 450 ns.
-        FastGPIO::Pin<e>::setOutputLow();
-        _delay_us(1);   // At least 550 ns.
-    }
-};
-
-MyLCD lcd;
+
+PololuHD44780 lcd(7, 6, 5, 4, 3, 2);

 void loadCustomCharacters()
 {
@@ -75,8 +23,9 @@
     };
     lcd.loadCustomCharacter(smiley, 0);

-    // Make sure that old code that uses 'char' for the pictures still works
-    // because the OrangutanLCD function took char* instead of uint8_t*.
+    // Make sure that old code that uses 'char' for the pictures
+    // still works because the OrangutanLCD function took char*
+    // instead of uint8_t*.
     static const char back_arrow[] PROGMEM = {
 	0b00000,
 	0b00010,
@@ -104,11 +53,11 @@

 void setup()
 {
-  loadCustomCharacters();
-}
-
-// Prints the ID of the screen we are currently showing and waits for
-// the user to send input on the serial monitor before continuing.
+}
+
+// Prints the ID of the screen we are currently showing and waits
+// for the user to send input on the serial monitor before
+// continuing.
 void wait(uint16_t id)
 {
   SERIAL_PORT_MONITOR.println(id);
@@ -119,6 +68,7 @@
 void loop()
 {
   lcd.reinitialize();
+  loadCustomCharacters();

   // Test both overloads of write
   // Expected screen: "Hello   "
@@ -137,7 +87,7 @@
   lcd.write("1:\x01");
   wait(10);

-  // Test print and goto
+  // Test print and gotoXY
   // Expected screen: "Hi there"
   //                  "12345678"
   lcd.clear();
@@ -186,36 +136,42 @@
   wait(90);

   // Test scrollDisplayLeft.
-  // Expected screen: "i there " (with a blinking cursor on the second column)
+  // Expected screen: "i there "
   //                  "23456789"
+  // (with a blinking cursor on the second column, top row)
   lcd.scrollDisplayLeft();
   wait(100);

   // Test scrollDisplayLeft.
-  // Expected screen: " there  " (with a blinking cursor on the first column)
+  // Expected screen: " there  "
   //                  "3456789a"
+  // (with a blinking cursor on the first column, top row)
   lcd.scrollDisplayLeft();
   wait(110);

   // Test scrollDisplayRight.
-  // Expected screen: "i there " (with a blinking cursor on the second column)
+  // Expected screen: "i there "
   //                  "23456789"
+  // (with a blinking cursor on the second column, top row)
   lcd.scrollDisplayRight();
   wait(120);

   // Test home.
-  // Expected screen: "Hi there" (with a blinking cursor over H)
+  // Expected screen: "Hi there"
   //                  "12345678"
+  // (with a blinking cursor on the H)
   lcd.home();
   wait(130);

-  // Test clear().  The screen should be empty except for a blinking cursor in the upper left.
+  // Test clear().  The screen should be empty except for a
+  // blinking cursor in the upper left.
   lcd.clear();
   wait(140);

   // Test leftToRight and rightToLeft
   // Expected screen: "abcdef  "
   //                  "        "
+  // (with a blinking cursor)
   lcd.print("abXX");
   lcd.rightToLeft();
   lcd.print("Xdc");
@@ -233,14 +189,16 @@
   lcd.print("klmn");
   wait(160);

-  // Test that the screen can really hold 40 characters on each line,
-  // and that it can display the last 4 columns with the first 4 columns.
+  // Test that the screen can really hold 40 characters on each
+  // line, and that it can display the last 4 columns with the
+  // first 4 columns.
   // Expected screen: "!@#$abcd"
   //                  "%^&*ABCD"
-  lcd.clear();
-  lcd.print("abcdefghijklmnopqrstuvwxyz0123456789!@#$--");
+  // (with a blinking cursor over the a)
+  lcd.clear();
+  lcd.print("abcdefghijklmnopqrstuvwxyz0123456789!@#$");
   lcd.gotoLine(1);
-  lcd.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789%^&*--");
+  lcd.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789%^&*");
   lcd.scrollDisplayRight();
   lcd.scrollDisplayRight();
   lcd.scrollDisplayRight();


Added play area border and scoreboard.

Added play area border and scoreboard.

--- snack/snack.ino
+++ snack/snack.ino
@@ -26,11 +26,12 @@

 Player p1;
 Coords foodLocation;
+Coords previousPosition;

 int maxX = 127;
 int minX = 0;
-int maxY = 63;
-int minY = 0;
+int maxY = 53;
+int minY = 10;

 int score = 0;
 int arrayPosition = 0;
@@ -101,9 +102,14 @@
       }
       else
       {
-        tailPosition = 0;
+        tailPosition = p1.Len -1;
       }
    }
+}
+
+void DrawFrame()
+{
+  arduboy.drawRect(minX,minY, maxX, maxY, WHITE);
 }

 // This function runs once in your game.
@@ -114,7 +120,7 @@

   // here we set the framerate to 15, we do not need to run at
   // default 60 and it saves us battery life
-  arduboy.setFrameRate(15);
+  arduboy.setFrameRate(10);

  StartGame();
 }
@@ -130,6 +136,8 @@
   // first we clear our screen to black
   arduboy.clear();

+  DrawFrame();
+
   CollisionDetection();

   if(arduboy.pressed(RIGHT_BUTTON)) {
@@ -180,11 +188,21 @@
   arduboy.drawPixel(p1.X, p1.Y, 1);
   arduboy.drawPixel(foodLocation.X, foodLocation.Y, 1);
   DrawTail();
-  LogMove();
-
-  arduboy.setCursor(0, 0);
+  if(p1.X != previousPosition.X || p1.Y != previousPosition.Y)
+  {
+    previousPosition.X = p1.X;
+    previousPosition.Y = p1.Y;
+    LogMove();
+  }
+
+
+  arduboy.setCursor(63, 0);
   arduboy.print("Score ");
-  arduboy.print(score);
+
+  char scoreBuff[5];
+  sprintf(scoreBuff, "%05d", score);
+
+  arduboy.print(scoreBuff);

   // then we finaly we tell the arduboy to display what we just wrote to the display


WS only

WS only

--- interocitor/interocitor.ino
+++ interocitor/interocitor.ino
@@ -362,8 +362,6 @@

 void stop_note(byte pitch, byte channel) {
   // Stop _all notes with the specified pitch
-
-
   byte start = 0;
   byte end = 4;


Delete soundSynth.ino

Delete soundSynth.ino


Calibrate ultrason

Calibrate ultrason

--- pug.ino
+++ pug.ino
@@ -12,6 +12,10 @@
 #define starterServoPin 18

 #define rotateTime 600
+
+int ultraBuffer[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+int ultraCompteur;
+int ultraSum;

 // Globals vars
 Servo starterServo;
@@ -28,22 +32,29 @@
   digitalWrite(rightMotorPin2, HIGH);
 }

-boolean ultraCheck(){
+long ultraMesure() {
   /* Utilisation du capteur Ultrason HC-SR04 */

-long lecture_echo;
-long cm;
+  long lecture_echo;
+  long cm;

   digitalWrite(ultraTrig, HIGH);
   delayMicroseconds(10);
   digitalWrite(ultraTrig, LOW);
   lecture_echo = pulseIn(ultraEcho, HIGH);
-  cm = lecture_echo / 58;
-  Serial.print("Distancem : ");
-  Serial.print(cm);
-  Serial.println("cm");
-  delay(10);
-  }
+  cm = lecture_echo/29;
+
+  return cm;
+}
+
+void ultraCheck(int ultraBuffer[10]) {
+  long cm = 0;
+  for (int i = 0; i < 10; i++) {
+    cm += ultraBuffer[i] / 10;
+  }
+
+  Serial.println(cm);
+}

 void stopRight() {
   digitalWrite(rightMotorPin1, LOW);
@@ -155,11 +166,16 @@
   // Motor Left
   pinMode(rightMotorPin1, OUTPUT);
   pinMode(rightMotorPin2, OUTPUT);
-
+
   // Ultrason
   pinMode(ultraTrig, OUTPUT);
   digitalWrite(ultraTrig, LOW);
   pinMode(ultraEcho, INPUT);
+  ultraCompteur = 1;
+  ultraSum = 0;
+
+  //DebugLed
+  pinMode(13,OUTPUT);

   // Serial
   Serial.begin(9600);
@@ -169,7 +185,20 @@

 void loop() {
   // TODO Script to win here ;)
-  ultraCheck();
+  int i = ultraCompteur % 10;
+  int first_i = (ultraCompteur + 1) % 10;
+  ultraBuffer[i] = ultraMesure();
+  ultraSum += ultraBuffer[i];
+  ultraSum -= ultraBuffer[first_i];
+
+if (ultraSum/10 < 20){
+  digitalWrite(13,HIGH);
+  } else {
+    digitalWrite(13,LOW);
+    }
+  ultraCompteur++;
+
+
 }

 // Serial
@@ -213,18 +242,18 @@

     case 'r':
     case 'R': // Rotation
-      if (serialInput[1] == 'L' || serialInput[1] == 'l'){
+      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!");
+      Serial.println("Go!");
       setLeftSpeed( serialInput[1] * 100 + serialInput[2] * 10 + serialInput[3]);
       setRightSpeed( serialInput[1] * 100 + serialInput[2] * 10 + serialInput[3]);
       delay(1500);
@@ -235,25 +264,25 @@
       break;
     case 'b':
     case 'B': // Back direction
-    Serial.println("Revert revert revert!");
+      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!");
+      Serial.println("Lock'n'load!");
       prepareToStart();
       break;
     case 'g':
     case 'G': // GO !!!
-    Serial.println("Smooth splosh");
+      Serial.println("Smooth splosh");
       smoothSploch();
       break;
     case 'W':
     case 'w': // Emergy stop
-     Serial.println("Emergency Stop!!");
-               stopMotors();
+      Serial.println("Emergency Stop!!");
+      stopMotors();
       break;

     default:


Removed legacy serial parameter editing code

--- ReFilament/ReFilament.ino
+++ ReFilament/ReFilament.ino
@@ -7,15 +7,9 @@
 const byte HOT_LED = 6;

-// Serial input parameter editing for PID
-boolean input_complete = false;
-float input_param = 0;
-String input = "";
-
-
 // Extruder motor globals
 boolean extruder_active = 1;
-byte ex_power = 80;
+byte ex_power = 70;

 // Time related
@@ -23,9 +17,9 @@

 // Heater control globals
-long over_temp_mv = 2480;
-long temp_mv = 0;
-int temp_deg = 87;
+int over_temp_mv = 2550;
+int temp_mv = 0;
+int temp_deg = 0;
 byte temp_hi_limit = 210;
 byte temp_lo_limit = 190;
 bool heater_on = false;
@@ -34,12 +28,13 @@
 byte spl_kp = 0;
 byte spl_ki = 0;
 byte spl_kd = 0;
+byte spl_power = 5;

 // Serial variables
 byte serialBuffer[256];
-byte heater_activated = 0;
-byte motors_activated = 0;
+byte heater_activated = 1;
+byte motors_activated = 1;
 int current_temp = 200; // in degrees celcius
 int current_diam = 1750; // in micrometers

@@ -79,6 +74,8 @@
   pinMode(SPL_PIN, OUTPUT); // Spooling Motor
   pinMode(HTR_PIN, OUTPUT); // Heater
   pinMode(ENBL_PIN, OUTPUT); // Power Supply Enable
+  pinMode(HTR_LED, OUTPUT);
+  pinMode(HOT_LED, OUTPUT);
   pinMode(clockPin, INPUT);
   pinMode(dataPin, INPUT);

@@ -93,6 +90,8 @@
   digitalWrite(SPL_PIN, LOW);
   digitalWrite(HTR_PIN, LOW);
   digitalWrite(ENBL_PIN, LOW);
+  digitalWrite(HTR_LED, HIGH);
+  digitalWrite(HOT_LED, HIGH);
   delay(6000);
   digitalWrite(ENBL_PIN, HIGH);

@@ -109,13 +108,18 @@
   if (temp_mv >= over_temp_mv) {
     heater_shutdown();
   }
-  long temp_deg = temp_mv / 0.9181 - 2483;
+  temp_deg = temp_mv / 0.9181 - 2483;
+  if (temp_deg > -800) {
+    digitalWrite(HOT_LED, LOW);
+  } else {
+    digitalWrite(HOT_LED, HIGH);
+  }
   if (heater_activated) {
     update_temp();
   }
-
-  analogWrite(SPL_PIN, 3);
-  analogWrite(EXT_PIN, 40);
+
+  analogWrite(SPL_PIN, spl_power);
+  analogWrite(EXT_PIN, ex_power);
   delay(10);

   printSerialData();
@@ -125,16 +129,17 @@

 void heater_shutdown() {
   digitalWrite(HTR_PIN, LOW);
-  heater_activated = 0;
+  digitalWrite(HTR_LED, HIGH);
+  heater_activated = false;
 }

 void update_temp() {
-  if (temp_deg <= 180) {
+  if (temp_deg < 200) {
     digitalWrite(HTR_PIN, HIGH);
-    heater_on = true;
-  } else if (temp_deg >= 220) {
+    digitalWrite(HTR_LED, HIGH);
+  } else if (temp_deg >= 210) {
     digitalWrite(HTR_PIN, LOW);
-    heater_on = false;
+    digitalWrite(HTR_LED, LOW);
   }
 }

@@ -154,9 +159,9 @@
 void printSerialData()
 {
   // printSerialData prints the
-  Serial.print(current_temp); //
+  Serial.print(temp_deg); //
   Serial.print(",");
-  Serial.println(current_diam);
+  Serial.println(temp_mv);
 }

 void readSerialData()


Add battery voltage to the Status response.

--- gsm_tracker/gsm_tracker.ino
+++ gsm_tracker/gsm_tracker.ino
@@ -259,9 +259,12 @@
         } else if (strcmp(sms_buffer, "Status") == 0) {
           Serial.println(F("  Responding with status... "));

-          char sms_response[8];
+          char sms_response[16];
+          uint16_t vbat;
+          fona.getBattVoltage(&vbat);
+
           uint8_t rssi = fona.getRSSI();
-          sprintf (sms_response, "%d bars.", barsFromRSSI(rssi));
+          sprintf (sms_response, "%d bars.\n%d mV", barsFromRSSI(rssi), vbat);

           // reply...
           if (fona.sendSMS(MY_PHONE_NUMBER, sms_response)) {


Formatting

Formatting

--- staff/staff.ino
+++ staff/staff.ino
@@ -170,35 +170,35 @@
     }

     if (patternId == DISCO_BARBER_1) {
-      leds[k] += CHSV(hue * 10 + k / 2, discoBarberSaturation, _brightness);                             // Then assign a hue to any that are bright enough.
+      leds[k] += CHSV(hue * 10 + k / 2, discoBarberSaturation, _brightness);
     } else {
-      leds[k] += CHSV(hue * -20 + k / 4, discoBarberSaturation, _brightness);                       // Then assign a hue to any that are bright enough.
-    }
-  }
-}
-
-uint8_t thishue = 0;                                          // You can change the starting hue value for the first wave.
-uint8_t thisrot = 18;                                          // You can change how quickly the hue rotates for this wave. Currently 0.
-uint8_t allsat = 255;                                         // I like 'em fully saturated with colour.
-bool thisdir = 0;                                             // You can change direction.
-int8_t thisspeed = 16;                                         // You can change the speed, and use negative values.
-uint8_t allfreq = 1;                                         // You can change the frequency, thus overall width of bars.
-int thisphase = 0;                                            // Phase change value gets calculated.
-uint8_t thiscutoff = 200;                                     // You can change the cutoff value to display this wave. Lower value = longer wave.
+      leds[k] += CHSV(hue * -20 + k / 4, discoBarberSaturation, _brightness);
+    }
+  }
+}
+
+int thisphase = 0;                // Phase change value gets calculated.
+bool fadeUp = 0;
+bool thisdir = 0;                 // You can change direction.
+int8_t thisspeed = 16;            // You can change the speed, and use negative values.
+uint8_t thishue = 0;              // You can change the starting hue value for the first wave.
+uint8_t thisrot = 18;             // You can change how quickly the hue rotates for this wave. Currently 0.
+uint8_t allsat = 255;             // I like 'em fully saturated with colour.
+uint8_t allfreq = 1;              // You can change the frequency, thus overall width of bars.
+uint8_t thiscutoff = 200;         // You can change the cutoff value to display this wave. Lower value = longer wave.
 uint8_t fade = 200;
-bool fadeUp = 0;

 void discoTwirl() {

   if (firstTimeRunningThroughPattern) {
-    thishue = 0;                                          // You can change the starting hue value for the first wave.
-    thisrot = 18;                                          // You can change how quickly the hue rotates for this wave. Currently 0.
-    allsat = 180;                                         // I like 'em fully saturated with colour.
-    thisdir = 0;                                             // You can change direction.
-    thisspeed = 8;                                         // You can change the speed, and use negative values.
-    allfreq = 4;                                         // You can change the frequency, thus overall width of bars.
-    thisphase = 0;                                            // Phase change value gets calculated.
-    thiscutoff = 200;                                     // You can change the cutoff value to display this wave. Lower value = longer wave.
+    thishue = 0;           // You can change the starting hue value for the first wave.
+    thisrot = 18;          // You can change how quickly the hue rotates for this wave. Currently 0.
+    allsat = 180;          // I like 'em fully saturated with colour.
+    thisdir = 0;           // You can change direction.
+    thisspeed = 8;         // You can change the speed, and use negative values.
+    allfreq = 4;           // You can change the frequency, thus overall width of bars.
+    thisphase = 0;         // Phase change value gets calculated.
+    thiscutoff = 200;      // You can change the cutoff value to display this wave. Lower value = longer wave.
     fade = 200;
     fadeUp = 1;
     fadeToBlackBy(leds, NUM_LEDS, 255);


Shrimp writes data now to his own database

--- Sources/Shrimp/Shrimp.ino
+++ Sources/Shrimp/Shrimp.ino
@@ -1,14 +1,32 @@
+//
+//     FILE: Shrimp.ino
+//   AUTHOR: Philip de Bruin
+//  VERSION: 0.1
+//  PURPOSE: For school assesment
+//
+//
+
+// Include temperature and humidity sensor library
 #include <dht11.h>
+// Include libraries for database
+#include <EEPROM.h>
+#include <DB.h>
+
+#define TABLE 1

 // Pins
 const int ledPin = 13;
 const int dhc11Pin = 8;

-
 // Variables
 dht11 DHT11;
+DB db;
 int travelTime = 0; // Total travel time in s
 int logInterval = 0; // Hoe vaak willen we loggen?
+struct MyRec {
+  int humidity;
+  double temperature;
+} myrec;

 void setup() {
   // Initialize pins
@@ -16,24 +34,42 @@

   DHT11.attach(dhc11Pin);
   Serial.begin(9600);
+
+  db.create(TABLE, sizeof(myrec));
+  db.open(TABLE);
 }

 void loop() {
   // put your main code here, to run repeatedly:
   int chk = DHT11.read();
-  switch (chk)
-  {
-    case 0: Serial.println("OK"); break;
-    case -1: Serial.println("Checksum error"); break;
-    case -2: Serial.println("Time out error"); break;
-    default: Serial.println("Unknown error"); break;
-  }
+//  switch (chk) {
+//    case 0: Serial.println("OK"); break;
+//    case -1: Serial.println("Checksum error"); break;
+//    case -2: Serial.println("Time out error"); break;
+//    default: Serial.println("Unknown error"); break;
+//  }

-  Serial.print("Humidity (%): ");
-  Serial.println((int)DHT11.humidity, DEC);
+//  Serial.print("Humidity (%): ");
+//  Serial.println((int)DHT11.humidity, DEC);
+  myrec.humidity = (int) DHT11.humidity;

-  Serial.print("Temperature (°C): ");
-  Serial.println((float)DHT11.temperature, DEC);
+//  Serial.print("Temperature (°C): ");
+//  Serial.println((double)DHT11.temperature, DEC);
+  myrec.temperature = (double) DHT11.temperature;

+  db.append(DB_REC myrec);
+  selectAll();
   delay(2000);
 }
+
+void selectAll() {
+  if (db.nRecs()) Serial.println("-----");
+  for (int i = 1; i <= db.nRecs(); i++)
+  {
+    db.read(i, DB_REC myrec);
+    Serial.print("Recnum: "); Serial.println(i);
+    Serial.print("Humidity: "); Serial.println(myrec.humidity);
+    Serial.print("Temperature: "); Serial.println(myrec.temperature);
+    Serial.println("-----");
+  }
+}


Updating PID

Updating PID

--- syde362_pid.ino
+++ syde362_pid.ino
@@ -11,9 +11,9 @@
 double Setpoint, Input, Output;

 //Specify the links and initial tuning parameters
-double Kp = 32609.0;
-double Ki = 34517.0;
-double Kd = 7086;
+double Kp = 0.1; //32609.0;
+double Ki = 5.0; //34517.0;
+double Kd = 1; //7086;

 PID pid(&Input, &Output, &Setpoint, Kp,Ki,Kd, DIRECT);

@@ -70,8 +70,12 @@
 void loop() {

   double yellow_dist = pollProximity();
-  yellow_dist /= 10000;
-  double black_dist = -yellow_dist;
+  double black_dist = FIDELITY - yellow_dist;
+  yellow_dist /= 10; // 10000;
+  black_dist  /= 10; // 10000;
+
+
+
   if(yellow_dist > 0.003){
     Input = yellow_dist;
   }else if(black_dist > 0.003){
@@ -79,11 +83,12 @@
   }else{
     Input = 0.0;
   }
+
   pid.Compute();
-  Serial.print("Output of PID: "); Serial.println(Output, DEC);
-  Serial.print("Input to PID: "); Serial.println(Input, DEC);
-  Serial.print("Ylw: "); Serial.print(yellow_dist, DEC); Serial.print("\tBlk: "); Serial.println(black_dist, DEC);
-  delay(1000);
+  Serial.print("Input: "); Serial.print(Input, DEC); Serial.print("\t Output: "); Serial.print(Output, DEC); Serial.print("\r");
+  //Serial.print("Input to PID: "); Serial.println(Input, DEC);
+  //Serial.print("Ylw: "); Serial.print(yellow_dist, DEC); Serial.print("\tBlk: "); Serial.println(black_dist, DEC);
+  delay(100);
 }

 /*
@@ -153,8 +158,9 @@
   Setpoint = 0;

   //tell the PID to range between 0 and the full window size
-  pid.SetOutputLimits(0, 1);
+  pid.SetOutputLimits(0, 255);

   //turn the PID on
   pid.SetMode(AUTOMATIC);
+  pid.SetSampleTime(1);
 }


JsonHttpClient: use HTTP 1.0 instead of 1.1 (issue #397, PR #399 by @Chris685)

Downgrading to HTTP 1.0 to prevent HTTP Chunked Transfer Encoding.

--- examples/JsonHttpClient/JsonHttpClient.ino
+++ examples/JsonHttpClient/JsonHttpClient.ino
@@ -87,7 +87,7 @@

   client.print("GET ");
   client.print(resource);
-  client.println(" HTTP/1.1");
+  client.println(" HTTP/1.0");
   client.print("Host: ");
   client.println(server);
   client.println("Connection: close");


Adding a LCD benchmark to CosaLCDspeed.

Adding a LCD benchmark to CosaLCDspeed.

--- examples/LCD/CosaLCDspeed/CosaLCDspeed.ino
+++ examples/LCD/CosaLCDspeed/CosaLCDspeed.ino
@@ -28,8 +28,8 @@
 // Select the LCD device for the benchmark
 #include "Cosa/LCD/Driver/HD44780.hh"
 // HD44780::Port port;
-HD44780::SR3W port;
-// HD44780::MJKDZ port;
+// HD44780::SR3W port;
+HD44780::MJKDZ port;
 // HD44780::DFRobot port;
 HD44780 lcd(&port);

@@ -50,6 +50,7 @@
 void write_pstr(uint16_t nr);
 void write_dec_uint16(uint16_t nr);
 void write_bin_uint16(uint16_t nr);
+void write_pos(uint16_t nr);

 // Measurement support
 void measure(const char* name, benchmark_t fn, uint16_t nr);
@@ -83,6 +84,7 @@
   MEASURE(write_char, 1000);
   MEASURE(write_str, 1000);
   MEASURE(write_pstr, 1000);
+  MEASURE(write_pos, 10);
   MEASURE(write_dec_uint16, 10000);
   MEASURE(write_bin_uint16, 1000);
 }
@@ -156,6 +158,27 @@
   }
 }

+void write_pos(uint16_t nr)
+{
+#if defined(__COSA_LCD_DRIVER_HD44780_HH__) || defined(__COSA_VLCD_HH__)
+  const uint8_t WIDTH = 16;
+  const uint8_t HEIGHT = 2;
+#else
+  const uint8_t WIDTH = lcd.WIDTH / lcd.get_text_font()->get_width(' ');
+  const uint8_t HEIGHT = lcd.LINES;
+#endif
+  while (nr--) {
+    for (uint8_t c = 'A'; c < 'F'; c++) {
+      for (uint8_t height = 0; height < HEIGHT; height++) {
+	for (uint8_t width = 0; width < WIDTH; width++) {
+	  lcd.set_cursor(width, height);
+	  lcd.putchar(c);
+	}
+      }
+    }
+  }
+}
+
 void measure(const char* name, benchmark_t fn, uint16_t nr)
 {
   lcd.display_clear();


bizzare problem at 100 Hz: output climbs to infinity

--- src/sketch.ino
+++ src/sketch.ino
@@ -25,7 +25,7 @@
   Wire.onRequest(writeVoltage);
   controller.SetMode(AUTOMATIC);
   controller.SetOutputLimits(-635,635);
-  controller.SetSampleTime(10);
+  controller.SetSampleTime(100);
 }

 void loop(){
@@ -71,7 +71,6 @@
       controller.SetMode(AUTOMATIC);
     }
     setParam(incoming, &speed);
-    speed /= 10;
     break;
   case PTERM:
     setParam(incoming, &pterm);


Use floating point division to compute temperatures

stupid integers

--- lcd_temperature_display.ino
+++ lcd_temperature_display.ino
@@ -93,9 +93,21 @@
   }

   // Compute the average, scaled from ADC value to temperature.
-  *averageval  = (float)(bigsum >> AVERAGE_BINS_BITS);
+  *averageval  = float(bigsum) / float(AVERAGE_BINS);
   *averageval *= (float)TEMPERATURE_MULTIPLIER;
   *averageval += TEMPERATURE_ADDEND;
+
+  #ifdef DEBUG
+    Serial.print("getTemperature: readval=");
+    Serial.print(readval);
+    Serial.print(" currentVoltageBin=");
+    Serial.print(currentVoltageBin);
+    Serial.print(" bigsum=");
+    Serial.print(bigsum);
+    Serial.print(" *averageval=");
+    Serial.print(*averageval);
+    Serial.println("");
+  #endif
 }

 void getColorByName(ColorValue* result, ColorName color)