Fix error messages in STM32 clock cal code

--- examples/compliance-otaa-halconfig/compliance-otaa-halconfig.ino
+++ examples/compliance-otaa-halconfig/compliance-otaa-halconfig.ino
@@ -1091,7 +1091,7 @@
         {
         // Use original value
         Serial.println(
-            "?CatenaStm32L0::CalibrateSystemClock: can't calibrate"
+            "?CalibrateSystemClock: can't calibrate"
             );
         }


- add INSTRUMENT_TYPE_DEFAULT(same as used to be) - use int not uint16_t

--- ptw-wheel.ino
+++ ptw-wheel.ino
@@ -23,14 +23,15 @@
 int i = 0;  // 文字数のカウンタ

 // instrument types
-#define INSTRUMENT_TYPE_ONESHOT 0
-#define INSTRUMENT_TYPE_LONGSHOT 1
+#define INSTRUMENT_TYPE_DEFAULT 0
+#define INSTRUMENT_TYPE_ONESHOT 1
+#define INSTRUMENT_TYPE_LONGSHOT 2
 int i_type = INSTRUMENT_TYPE_ONESHOT;

 // instrument color
 int i_color_r = 255;
-int i_color_g = 255;
-int i_color_b = 255;
+int i_color_g = 0;
+int i_color_b = 0;

 // effect color
 int e_color_r = 0;
@@ -57,7 +58,7 @@
   if (0<Serial.available()) {
     String command = Serial.readStringUntil(':');
     String argument = Serial.readStringUntil(';');
-
+
     // set instrument type
     // "t:[0|1];"
     if(command=="t") {
@@ -76,7 +77,7 @@
     else if(command=="i") {
       Serial.println(command);
       if(argument.length()==11) {
-
+
         i_color_r = argument.substring(0,3).toInt();
         i_color_g = argument.substring(4,7).toInt();
         i_color_b = argument.substring(8,11).toInt();
@@ -110,7 +111,7 @@
     // set divide number
     // "d:[0-9];"
     else if(command=="d") {
-
+
       if(argument.length()==1) {
         // argument is int
         divide = argument.toInt();
@@ -181,23 +182,75 @@
   uint32_t effect_color = multiplicateBrightness(constrainValue(e_color_r), constrainValue(e_color_g), constrainValue(e_color_b));

   switch (i_type) {
-    case INSTRUMENT_TYPE_ONESHOT:
+
+    case INSTRUMENT_TYPE_DEFAULT:
+      // control divide and slit_position from iOS
       {
         float unit = (float) TOTAL_PIXELS / (float) divide;
         int unit_number = 1;
         int unit_start = 0;
-        bool effect_on = true;
-        for(uint16_t i=0; i<TOTAL_PIXELS;) {
+        for(int i=0; i<TOTAL_PIXELS;) {
           if(i<unit*unit_number){
             if(i<unit_start+unit*slit_position) {
+              strip.setPixelColor((uint16_t) i, instrument_color);
+            }
+            else {
+              strip.setPixelColor((uint16_t) i, effect_color);
+            }
+            i++;
+          }
+          else {
+            unit_number++;
+            unit_start = i;
+          }
+        }
+      }
+      break;
+
+    case INSTRUMENT_TYPE_ONESHOT:
+      {
+        float unit = (float) TOTAL_PIXELS/2.0;
+        int unit_number = 1;
+        int unit_start = 0;
+
+        float innerunit = (float) unit*0.5; // inner unit in instrument unit
+        int innerunit_number = 1;
+        int innerunit_start = 0;
+
+        bool effect_on = true;
+
+        for(int i=0; i<TOTAL_PIXELS;) {
+          if(i<unit*unit_number){
+            if(i<unit_start+unit*0.5) {
+
               // instrument section
-              strip.setPixelColor(i, instrument_color);
+              // for(int j=i; j<innerunit;) {
+              //   if(j<innerunit*innerunit_number){
+              //     if(j<innerunit_start+innerunit*0.5) {
+              //       // instrument section
+              //       strip.setPixelColor((uint16_t) j, instrument_color);
+              //     }
+              //     else {
+              //       // effect section
+              //       // 交互に色付く
+              //       uint32_t _color = effect_on ? effect_color : 0;
+              //       strip.setPixelColor((uint16_t) j, _color);
+              //       effect_on = !effect_on;
+              //     }
+              //     j++;
+              //   }
+              //   else {
+              //     innerunit_number++;
+              //     innerunit_start = j;
+              //   }
+              // }
+              strip.setPixelColor((uint16_t) i, instrument_color);
             }
             else {
               // effect section
               // 交互に色付く
               uint32_t _color = effect_on ? effect_color : 0;
-              strip.setPixelColor(i, _color);
+              strip.setPixelColor((uint16_t) i, _color);
               effect_on = !effect_on;
             }
             i++;
@@ -209,6 +262,7 @@
         }
       }
       break;
+
     case INSTRUMENT_TYPE_LONGSHOT:
       {
         divide = 5;
@@ -217,17 +271,17 @@
         int unit_number = 1;
         int unit_start = 0;
         bool effect_on = true;
-        for(uint16_t i=0; i<TOTAL_PIXELS;) {
+        for(int i=0; i<TOTAL_PIXELS;) {
           if(i<unit*unit_number){
             if(i<unit_start+unit*slit_position) {
               // instrument section
-              strip.setPixelColor(i, instrument_color);
+              strip.setPixelColor((uint16_t) i, instrument_color);
             }
             else {
               // effect section
               // 交互に色付く
               uint32_t _color = effect_on ? effect_color : 0;
-              strip.setPixelColor(i, _color);
+              strip.setPixelColor((uint16_t) i, _color);
               effect_on = !effect_on;
             }
             i++;
@@ -239,6 +293,7 @@
         }
       }
       break;
+
     default:
       Serial.println("[error] i_type is invalid");
       break;
@@ -252,7 +307,6 @@
   int b = (int) _b*brightness;
   return strip.Color(r, g, b);
 }
-

 // from Adafruit example

@@ -264,10 +318,10 @@
       delay(wait);
   }
 }
-
+
 void rainbow(uint8_t wait) {
   uint16_t i, j;
-
+
   for(j=0; j<256; j++) {
     for(i=0; i<strip.numPixels(); i++) {
       strip.setPixelColor(i, Wheel((i+j) & 255));
@@ -276,7 +330,7 @@
     delay(wait);
   }
 }
-
+
 // Input a value 0 to 255 to get a color value.
 // The colours are a transition r - g - b - back to r.
 uint32_t Wheel(byte WheelPos) {


Ensure initial valid config is loaded in EEPROM using check code.

--- src/main.ino
+++ src/main.ino
@@ -39,6 +39,7 @@
  */
 void loadFactoryDefaults() {
   // Light defaults
+  cfg.ic = INIT_HASH;
   cfg.is_on = LIGHT_STATE;
   cfg.brightness = LIGHT_BRIGHTNESS;
   cfg.color_temp = LIGHT_COLOR_TEMPERATURE;
@@ -68,6 +69,9 @@
  */
 void setup() {
   EEPROM.begin(SPI_FLASH_SEC_SIZE);
+  if (cfg.ic != INIT_HASH) {
+    loadFactoryDefaults();
+  }
   EEPROM_read(cfg);

 // Serial Port Initialization
@@ -75,7 +79,6 @@
   Serial.begin(115200);
   DEBUGLOG("\n");
   DEBUGLOG("\n");
-
   DEBUGLOG("Welcome to %s!\n", APP_NAME);
   DEBUGLOG("Firmware Version : %s\n", APP_VERSION);
   DEBUGLOG("Firmware Build   : %s - %s\n", __DATE__, __TIME__);


improperly named variabes

improperly named variabes

--- init.ino
+++ init.ino
@@ -4,8 +4,8 @@
   pinMode(STRIP_PIN_W1, OUTPUT);
   pinMode(STRIP_PIN_W2, OUTPUT);
   pinMode(STRIP_PIN_W3, OUTPUT);
-  pinMode(STRIP_PIN_D1, OUTPUT);
-  pinMode(STRIP_PIN_D2, OUTPUT);
+  pinMode(STRIP_PIN_DT, OUTPUT);
+  pinMode(STRIP_PIN_DB, OUTPUT);
 }

 void init_strips() {


Add /get_speed and /set_speed endpoints

Add /get_speed and /set_speed endpoints

Like proposed in https://github.com/toblum/McLighting/pull/49

--- Arduino/McLighting/McLighting.ino
+++ Arduino/McLighting/McLighting.ino
@@ -446,26 +446,21 @@
     DBG_OUTPUT_PORT.println(str_brightness);
   });

-  server.on("/set_delay", []() {
+  server.on("/set_speed", []() {
     if (server.arg("d").toInt() >= 0) {
       ws2812fx_speed = server.arg("d").toInt();
-    }
-    if (ws2812fx_speed > 255) {
-      ws2812fx_speed = 255;
-    }
-    if (ws2812fx_speed < 0) {
-      ws2812fx_speed = 0;
-    }
-    strip.setSpeed(ws2812fx_speed);
+      ws2812fx_speed = constrain(ws2812fx_speed, 0, 255);
+      strip.setSpeed(ws2812fx_speed);
+    }

     getStatusJSON();
   });

-  server.on("/get_delay", []() {
-    String str_delay = String(ws2812fx_speed);
-    server.send(200, "text/plain", str_delay );
-    DBG_OUTPUT_PORT.print("/get_delay: ");
-    DBG_OUTPUT_PORT.println(str_delay);
+  server.on("/get_speed", []() {
+    String str_speed = String(ws2812fx_speed);
+    server.send(200, "text/plain", str_speed );
+    DBG_OUTPUT_PORT.print("/get_speed: ");
+    DBG_OUTPUT_PORT.println(str_speed);
   });

   server.on("/get_switch", []() {


#define wasn't calculating correctly so i hard coded it for testing. now ADC reading works while the heater is on.

--- Firmware/JBC-Soldering-Controller/JBC-Soldering-Controller.ino
+++ Firmware/JBC-Soldering-Controller/JBC-Soldering-Controller.ino
@@ -134,11 +134,13 @@
   #define PWM_PERIOD_MS (PWM_PERIOD_US/1000)
   #define PWM_MAX_DUTY 1023 //the timer 1 libray scales the PWM duty cycle from 0 to 1023 where 0=0% and 1023=100%
   #define ADC_SAMPLE_WINDOW_US 1200 //1200us = 1.2ms //we need 1.2 ms to sample the ADC. assuming 860 SPS setting
-  #define ADC_SAMPLE_WINDOW_PWM_DUTY (((PWM_PERIOD_US-ADC_SAMPLE_WINDOW_US)*PWM_MAX_DUTY)/PWM_PERIOD_US)  // we set our PWM duty to as close to 100% as possible while still leaving enough time for the ADC sample.
+  #define ADC_SAMPLE_WINDOW_PWM_DUTY 961//(((PWM_PERIOD_US-ADC_SAMPLE_WINDOW_US)*PWM_MAX_DUTY)/PWM_PERIOD_US)  // we set our PWM duty to as close to 100% as possible while still leaving enough time for the ADC sample.
   #define MAX_HEATER_PWM_DUTY ADC_SAMPLE_WINDOW_PWM_DUTY //our maximum allowable heater PWM duty is equal to the sampling window PWM duty.

   Timer1.initialize(PWM_PERIOD_US);
   Timer1.pwm(LPINB, ADC_SAMPLE_WINDOW_PWM_DUTY);
+
+
   Timer1.pwm(LPINA, 60); //100% = 1023
   delay(PWM_PERIOD_MS); //make sure both PWM's have run at least one full period before enabling interrupts

@@ -262,7 +264,9 @@
  display.display();
  //Serial.print(millis());
  //Serial.print(" ");
- Serial.println(adc_copy);
+ Serial.print(adc_copy);
+ //  Serial.print("ADC_SAMPLE_WINDOW_PWM_DUTY");
+ // Serial.println(ADC_SAMPLE_WINDOW_PWM_DUTY);
  //Serial.print(" ");
  //Serial.println(tempfloat);
   //}


Adding debugging information and trying different thresholds.  Still does not quite work.

--- Latency_Hardware/OSVR_Latency_hardware_firmware/motion_turnaround_test/motion_turnaround_test.ino
+++ Latency_Hardware/OSVR_Latency_hardware_firmware/motion_turnaround_test/motion_turnaround_test.ino
@@ -103,8 +103,10 @@
 #define	BIT_RAW_RDY_EN		    0x01
 #define	BIT_I2C_IF_DIS              0x10

+// Debugging definitions.
 #undef VERBOSE
 #undef VERBOSE2
+#define PRINT_TRACE

 // pins used for the connection with the sensor
 // the other you need are controlled by the SPI library):
@@ -113,21 +115,32 @@
 // Thresholds
 const int ACCEL_CHANGE_THRESHOLD = 500;
 const int GYRO_THRESHOLD = 300;
-const int BRIGHTNESS_THRESHOLD = 3;
+const int GYRO_MIN_SPEED_THRESHOLD = 2000;
+const int BRIGHTNESS_THRESHOLD = 10;
 const int GYRO_CALIBRATION_THRESHOLD = 1000;
 const int BRIGHTNESS_CALIBRATION_THRESHOLD = 10;
 const unsigned long TIMEOUT_USEC = 2000000L;
 const unsigned long CALIBRATE_USEC = 1000000L;

+// Arrays to hold measurements surrounding the reversal for debugging
+#ifdef PRINT_TRACE
+const int TRACE_SIZE = 250;
+const int TRACE_SKIP = 5;
+static int trace_count = 0;
+static int trace_skip_count = 0;
+char trace_gyroY[TRACE_SIZE];
+unsigned char trace_bright[TRACE_SIZE];
+#endif
+
 //*****************************************************
 void setup()
 //*****************************************************
 {
   Serial.begin(9600);
-  Serial.print("OSVR_latency_hardware_firmware turnaround test v01.00.00\n");
+  Serial.print("OSVR_latency_hardware_firmware turnaround test v01.01.00\n");
   Serial.print(" Mount the photosensor rigidly on the eyepiece or screen.\n");
   Serial.print(" Rotate the inertial sensor along with the tracking hardware.\n");
-  Serial.print(" Make the app change very brightness darker in one direction and lighter in the other.\n");
+  Serial.print(" Make the app vary brightness darker in one direction and lighter in the other.\n");
   Serial.print(" Latencies reported in microseconds, 2-second timeout\n");
   Serial.print(" Hold the device still for 2 seconds.\n");

@@ -171,7 +184,8 @@
   // direction.  If so, then we set last_brightness_reach_end_time to
   // now.  Brightness change direction and last brightness to
   // reach the end should both be set to 0 when entering the
-  // S_REVERSE_BRIGHTNESS state.
+  // S_REVERSE_BRIGHTNESS state so that they will have to be
+  // filled in by actual changes.
   static int last_brightness_change_direction = 0;
   static unsigned long int last_brightness_reach_end_time = 0;

@@ -224,6 +238,19 @@
     tracking_axis = NULL;
     state = S_CALIBRATE;
   }
+
+#ifdef PRINT_TRACE
+  if ( (state != S_CALIBRATE) && (state != S_CALM) ) {
+    if (++trace_skip_count >= TRACE_SKIP) {
+      trace_skip_count = 0;
+      if (trace_count < TRACE_SIZE) {
+        trace_gyroY[trace_count] = gyroY/100;
+        trace_bright[trace_count] = brightness/4;
+        trace_count++;
+      }
+    }
+  }
+#endif

   switch (state) {
     // Wait for a period where there is no motion above
@@ -294,15 +321,15 @@
             state = S_REVERSE_DIRECTION;
             Serial.print("Calibration complete, measuring latencies on ");
             if (tracking_axis == &gyroX) {
-              Serial.print(" X axis");
+              Serial.print("X axis");
             } else if (tracking_axis == &gyroY) {
-              Serial.print(" Y axis");
+              Serial.print("Y axis");
             } else {
-              Serial.print(" Z axis");
+              Serial.print("Z axis");
             }
             Serial.print(" (brightness difference ");
             Serial.print(maxBright - minBright);
-            Serial.print("\n");
+            Serial.print(")\n");
             Serial.print("Continue periodic motion to test latency.\n");
           }
         }
@@ -313,12 +340,22 @@
     // but now have stopped.
     case S_REVERSE_DIRECTION:
       {
+        // Don't say that we were moving until we get to a speed that
+        // is above a larger threshold to keep us from getting lots
+        // of spurious false stopping estimates.
+        static bool have_moved_fast = false;
+
         // Keep track of when the gyroscope value most recently
         // dropped below threshold (was above threshold in the previous
         // time step and dropped below threshold this time).
         static int last_gyroscope_value = 0;
         if (tracking_axis != NULL) {
-          if ( (gyro_direction(*tracking_axis) == 0) &&
+          if ( (*tracking_axis > GYRO_MIN_SPEED_THRESHOLD) ||
+               (*tracking_axis < -GYRO_MIN_SPEED_THRESHOLD) ) {
+                 have_moved_fast = true;
+          }
+          if ( have_moved_fast &&
+               (gyro_direction(*tracking_axis) == 0) &&
                (gyro_direction(last_gyroscope_value) != 0) ) {
             last_gyroscope_settling_time = now;
           }
@@ -328,8 +365,16 @@
         }

         if (last_gyroscope_settling_time != 0) {
-          // Flush the change status so that we have to get a change in one direction
-          // followed by a change in the other starting now.
+          //Serial.print("Stopped\n");
+
+          // We have dropped to a stop, so we need to set the trigger for
+          // moving fast again and make sure we actually move before the
+          // last gyro value registers a move.
+          have_moved_fast = false;
+          last_gyroscope_value = 0;
+
+          // Flush the change status so that we have to get a brightness change
+          // in one direction followed by a change in the other starting now.
           last_brightness_reach_end_time = 0;
           last_brightness_change_direction = 0;
           state = S_REVERSE_BRIGHTNESS;
@@ -349,6 +394,17 @@
         if (this_change != 0) {
           if (this_change * last_brightness_change_direction == -1) {
             last_brightness_reach_end_time = last_brightness_change_time;
+            /*
+            if (this_change == -1) {
+              Serial.print(" +");
+            } else {
+              Serial.print(" -");
+            }
+            Serial.print(last_unchanged_brightness_value);
+            Serial.print("->");
+            Serial.print(brightness);
+            Serial.print("\n");
+            */
           }
           last_unchanged_brightness_value = brightness;
           last_brightness_change_direction = this_change;
@@ -359,15 +415,25 @@
           if (last_brightness_reach_end_time <= last_gyroscope_settling_time) {
             Serial.print("Error: Inverted settling times: gyro settling time ");
             Serial.print(last_gyroscope_settling_time);
-            Serial.print("\n");
+            Serial.print(" (resetting)\n");
             state = S_CALM;
           }
-
-          // Print this value.
+
+#ifdef PRINT_TRACE
+          Serial.print("GyroY/100*100,brightness/4*4\n");
+          for (int i = 0; i < trace_count; i++) {
+            Serial.print(static_cast<int>(trace_gyroY[i])*10);
+            Serial.print(",");
+            Serial.print(static_cast<int>(trace_bright[i])*4);
+            Serial.print("\n");
+          }
+          Serial.print("\n");
+          trace_count = 0;
+#endif
           unsigned long value = last_brightness_reach_end_time - last_gyroscope_settling_time;
           Serial.print(value);
           Serial.print("\n");
-
+
           // Track statistics;
           latency_count++;
           if (value < latency_min) { latency_min = value; }


Simon V1.0

Simon V1.0

--- sketchbook/SimonScreams/SimonScreams.ino
+++ sketchbook/SimonScreams/SimonScreams.ino
@@ -5,11 +5,21 @@
 Servo neckServo;

 const int kledPin = 11;
-const int kmicPin = A0;

-float filtMicValue;
-float avgMicValue;
-int samples;
+float lastNeckPos = 90;
+
+const int kMaxNeckPos = 135;
+const int kMinNeckPos = 45;
+const int kMaxJawPos = 135;
+const int kMinJawPos = 45;
+
+const int kcycles = 5;
+
+//const int kmicPin = A0;
+
+//float filtMicValue;
+//float avgMicValue;
+//int samples;

 void setup(){

@@ -18,65 +28,83 @@

   pinMode(kledPin, OUTPUT);

+
+
   Serial.begin(9600);
 }

 void loop() {

-  avgMicValue = 0.0;
-  filtMicValue = 0.0;
-  samples = 0;
+//  avgMicValue = 0.0;
+//  filtMicValue = 0.0;
+//  samples = 0;

-  while(1)
-  {
-    float micValue = analogRead(kmicPin);
-    if(micValue > 1 && micValue < 1024)
-    {
+//  while(1)
+//  {
+//    float micValue = analogRead(kmicPin);
+//    if(micValue > 1 && micValue < 1024)
+//    {
+//
+//      avgMicValue = ( (9.9*avgMicValue) + (0.1*micValue) )/10.0;
+//
+//      Serial.print(micValue);
+//      Serial.print("\t");
+//
+//      Serial.print(avgMicValue);
+//      Serial.print("\t");
+//
+//      micValue -= avgMicValue;
+//
+//      Serial.print(micValue);
+//      Serial.print("\t");
+//
+//      micValue = sq(micValue);
+//
+//      Serial.print(micValue);
+//      Serial.print("\t");
+//
+//      filtMicValue = ((9.5*filtMicValue) + (0.5*micValue))/10.0;
+//
+//      Serial.print(samples);
+//      Serial.print("\t");
+//
+//      Serial.println(filtMicValue);
+//
+//      if(samples > 200 && filtMicValue > 5000.0)
+//        break;
+//
+//      samples++;
+//    }
+//
+//    delay(10);
+//  }
+
+  float neckTargetPos = random(kMinNeckPos, kMaxNeckPos);
+
+  for(int i = 0; i < kcycles; i++)
+  {
+    if(i == kcycles - 1)
+      neckTargetPos  = 90;

-      avgMicValue = ( (9.9*avgMicValue) + (0.1*micValue) )/10.0;
-
-      Serial.print(micValue);
-      Serial.print("\t");
-
-      Serial.print(avgMicValue);
-      Serial.print("\t");
-
-      micValue -= avgMicValue;
-
-      Serial.print(micValue);
-      Serial.print("\t");
-
-      micValue = sq(micValue);
-
-      Serial.print(micValue);
-      Serial.print("\t");
-
-      filtMicValue = ((9.5*filtMicValue) + (0.5*micValue))/10.0;
-
-      Serial.print(samples);
-      Serial.print("\t");
-
-      Serial.println(filtMicValue);
-
-      if(samples > 200 && filtMicValue > 5000.0)
-        break;
-
-      samples++;
-    }
-
-    delay(10);
-  }
-
-  for(int i = 0; i < 5; i++)
-  {
     for(int j = 0; j < 2000; j++)
     {
-      jawServo.write(180.0 * ((1 + cos(6.28 * j/-1000.0))/2.0));
-      neckServo.write(180.0 * ((1 + sin(6.28 * j/2000.0))/2.0));
+      jawServo.write(map(180.0 * ((1 - cos(6.28 * j/500.0))/2.0), 0, 180, kMinJawPos, kMaxJawPos));
+
+      lastNeckPos = (0.999 * lastNeckPos) + (0.001 * neckTargetPos);
+      neckServo.write((int)lastNeckPos);

       analogWrite(kledPin, 255.0 * ((1 + cos(6.28 * j/500.0))/-2.0));

       delay(1);
     }
   }
+
+  //dim leds fully
+  analogWrite(kledPin, 0);
+
+  //delay(1000);
+  //delay for 30s
+  delay(30000);
+  //delay for 10s-30s
+  delay(random(10000,30000));
 }


remove testing

remove testing

--- examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino
+++ examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino
@@ -74,9 +74,6 @@
   //WiFiManager
   //Local intialization. Once its business is done, there is no need to keep it around
   WiFiManager wifiManager;
-
-  uint8_t menu[] = {wifiManager.MENU_WIFI,wifiManager.MENU_INFO,wifiManager.MENU_PARAM,wifiManager.MENU_CLOSE};
-  wifiManager.setMenu(menu);

   //set config save notify callback
   wifiManager.setSaveConfigCallback(saveConfigCallback);


fixed double sms notification

fixed double sms notification

--- sms_thermo/sms_thermo.ino
+++ sms_thermo/sms_thermo.ino
@@ -10,8 +10,8 @@
 SoftwareSerial SIM900 (10, 11);                   //SIM900 is connected to 10 & 11 PINs RX, TX
 #define ONE_WIRE_BUS 12                           //Dallas OneWire sensors is connected to 13 PIN

-String phone_number[]   = {"+79000000000"};       // Phone numbers for SMS notifications
-int HighAlarmTemp[]     = {26, 26, 26, 26};       // Highest temperature when user is notificated
+String phone_number[]   = {"+79057275840"};       // Phone numbers for SMS notifications
+int HighAlarmTemp[]     = {28, 28, 28, 28};       // Highest temperature when user is notificated
 int DestroyAlarmTemp[]  = {40, 40, 40, 40};       // Temperature used to make forecast
 int TargetTemp[]        = {24, 24, 24, 24};       // Temperature used to make forecast
 int LowAlarmTemp[]      = { -28, -28, -28, -28};  // Lowest thmperature when user is notificated
@@ -40,7 +40,6 @@
 boolean call_done;
 boolean message_done;
 boolean armed;
-boolean remore_access;
 tmElements_t tm;

@@ -63,10 +62,9 @@
   SIM900.begin(57600);                            //SIM900 console initialize at 56k
   sensors.begin();                                //sensors initialize;

-  call_done = false;
   // mode select
   armed = true;                                  //GSM activity
-  remore_access = true;
+

   SIM900.println("AT");                           //Sending "AT" to modem for auto baud rate sensing;

@@ -340,7 +338,7 @@
           Serial.print("[DBG] TREND "); Serial.print(sensor); Serial.print(":"); Serial.println(tempTrend[period][sensor]);
           makeForecast(sensor, true);
         }
-
+
         tempAvgPrev[period][sensor] = tempAvgCur[period][sensor];
         tempSumm[period][sensor] = 1;
         measuresCount[period] = 1;
@@ -385,14 +383,14 @@

   String datastring;
   datastring = String(toProgressBar(2, 30, gsm_signal));
-  datastring += String(" ");
+  datastring += String(" ");
   datastring += getShortTimeString ();
   datastring += String(" (") + getData(thermalSensor[sensor]) + String(") [");
   for (int period; period < 3; period++)
   {
     datastring += String(tempAvgCur[period][sensor]) + String("/");
   }
-  datastring += String("] ETA: ");
+  datastring += String("] ETA: ");
   datastring += minToDeath;
   datastring += String(" (min)");
   return datastring;
@@ -405,38 +403,39 @@

   if (sensors.hasAlarm(thermalSensor[deviceid]))
   {
+    Serial.print("ALARM:"); Serial.println(getData(thermalSensor[deviceid]));
     last_alarm_time = getShortTimeString();
- //   Serial.print(last_alarm_time);
- //   Serial.print(" ALARM: ");
- //   Serial.println(getData(thermalSensor[deviceid]));
+    //   Serial.print(last_alarm_time);
+    //   Serial.print(" ALARM: ");
+    //   Serial.println(getData(thermalSensor[deviceid]));
     if (armed)
     {
+      if (!message_done)
+      {
+        for (int i = 0; i < sizeof(phone_number) / sizeof (String); i++)
+        {
+          Serial.print("Sending SMS:"); Serial.println(phone_number[i]);
+          message_done =  sendSMS(phone_number[i], makeMessage(deviceid));
+          last_message_hour =  hour();
+        }
+      }
+      else
+      {
+        if (last_message_hour != hour())
+        {
+          Serial.println("Send delay expired ");
+          message_done = false;
+        }
+      }
       for (int i = 0; i < sizeof(phone_number) / sizeof (String); i++)
       {
         if (!call_done)
         {
-          Serial.print("Sending SMS:");
-          {
-            message_done =  sendSMS(phone_number[i], makeMessage(deviceid));
-          }
-          last_message_hour =  hour();
-        } else
-        {
-          if (last_message_hour != hour())
-          {
-            Serial.println("Send delay expired ");
-            message_done = false;
-          }
-        }
-
-        if (!call_done)
-        {
-
           Serial.print("Calling: ");
           call_done = makecall(phone_number[i]);
-
           last_call_hour =  hour();
-        } else
+        }
+        else
         {
           if (last_call_hour != hour())
           {
@@ -555,10 +554,9 @@
 // proceed a sending message to number
 boolean sendSMS(String number, String message)
 {
-  String readString;
+  String readString;
   SIM900.print("AT+CMGF=1\r");                              // AT command to send SMS message
   delay(100);
-
   SIM900.print("AT+CMGS=\"");
   SIM900.print(number);
   delay(1000);
@@ -572,33 +570,36 @@
   delay(30000);                                             // give module time to send SMS

   while (SIM900.available() > 0)
-    { char inchar = SIM900.read();
-      readString += inchar;
-      delay(10);
-    }
+  { char inchar = SIM900.read();
+    readString += inchar;
+    delay(10);
+  }
   Serial.println("[DBG] SEND SMS");
   Serial.println(readString);
   return true;
 }

-void readSMS( bool debug)
+int readSMS( bool debug)
 {
   bool isMsgExists;
   String readString;
   String resultString;
+  String info_phone_number;
+  int op_delay;

   for (int smsID = 1; smsID <= 10; smsID++)
   {
     readString = "";
     isMsgExists = false;
-
     SIM900.print("AT+CMGR="); SIM900.println(smsID);
     delay(1000);
+    op_delay += 1000;
     while (SIM900.available() > 0)
     { char inchar = SIM900.read();
       readString += inchar;
       delay(10);
+      op_delay += 10;
     }

     if (debug) {
@@ -611,41 +612,33 @@
     {
       for (int j = 0; j < sizeof(phone_number) / sizeof(phone_number[0]); j++)
       {
-
+
         if (readString.substring(i, i + 12) == phone_number[j])
         {
-          isMsgExists = true;
-          if (debug) {
-            Serial.print(" FOUND:");
-            Serial.println(readString.substring(i, i + 12));
+
+          info_phone_number = phone_number[j];
+          for (int k = i; k < 200 - i; k++)
+          {
+            if (readString.substring(k, k + 4) == "INFO")
+            {
+              for (int deviceid = 0; deviceid < sizeof(thermalSensor) / sizeof(DeviceAddress); deviceid++)
+              {
+                sendSMS(info_phone_number, makeMessage(deviceid));
+              if (debug) {
+                Serial.print("Sent info to:");
+                Serial.println(readString.substring(i, i + 12));
+              }
+              }
+            }
           }
-          for (int deviceid = 0; deviceid < sizeof(thermalSensor) / sizeof(DeviceAddress); deviceid++)
-          {
-            sendSMS(phone_number[j], makeMessage(deviceid));
-          }
+
         }
-        /*        if (isMsgExists)
-                {
-                  SIM900.print("AT+CMGD="); SIM900.println(smsID);
-                  for (int k = i; k < 200 - i; k++)
-                  {
-                    if (readString.substring(k, k + 4) == "INFO")
-                    {
-                      for (int deviceid = 0; deviceid < sizeof(thermalSensor) / sizeof(DeviceAddress); deviceid++)
-                      {
-                        sendSMS(phone_number[i], makeMessage(deviceid));
-                      }
-                      if (debug) {
-                        Serial.print("COMMAND:");
-                        Serial.println(resultString);
-                      }
-                    }
-                  }
-                }*/
-      }
-    }
-  }
-}
+      }
+    }
+
+  }
+}
+

@@ -653,7 +646,6 @@
 // main loop
 void loop()
 {
-
   sensors.requestTemperatures(); // Send the command to get temperatures
   updateStats(false);

@@ -662,10 +654,9 @@
     makeForecast(i, false);
     checkAlarm(i);
   }
-  readSMS(false);

   //printAlarms(t0); // Вывод пороговых значений на экран
-  delay(cycleDelay-1000);  // задержка проверки
+  delay(cycleDelay - readSMS(true)); // задержка проверки
   //getSIM900status(false);
   //getNetworkStatus(false); Serial.println(toProgressBar(2, 30, gsm_signal)); // Network signal quality print
 }


Update advanced_slave.ino

Update advanced_slave.ino

--- examples/advanced_slave/advanced_slave.ino
+++ examples/advanced_slave/advanced_slave.ino
@@ -5,46 +5,53 @@
  *
  *  Recommended Modbus Master: QModbus
  *  http://qmodbus.sourceforge.net/
+ *
+ *  Editado al español por LuxARTS
  */

+//Incluye la librería del protocolo Modbus
 #include <ModbusRtu.h>
 #define ID   1

-Modbus slave(ID, 0, 0); // this is slave ID and RS-232 or USB-FTDI
+//Crear instancia
+Modbus slave(ID, 0, 0); //ID del nodo. 0 para el master, 1-247 para esclavo
+                        //Puerto serie (0 = TX: 1 - RX: 0)
+                        //Protocolo serie. 0 para RS-232 + USB (default), cualquier pin mayor a 1 para RS-485
 boolean led;
 int8_t state = 0;
 unsigned long tempus;

-// data array for modbus network sharing
-uint16_t au16data[9];
+uint16_t au16data[9]; //La tabla de registros que se desea compartir por la red

-/**
- *  Setup procedure
- */
+/*********************************************************
+ Configuración del programa
+*********************************************************/
 void setup() {
-  io_setup(); // I/O settings
+  io_setup(); //configura las entradas y salidas

-  // start communication
-  slave.begin( 19200 );
-  tempus = millis() + 100;
-  digitalWrite(13, HIGH );
+  slave.begin(19200); //Abre la comunicación como esclavo
+  tempus = millis() + 100; //Guarda el tiempo actual + 100ms
+  digitalWrite(13, HIGH ); //Prende el led del pin 13 (el de la placa)
 }

-/**
- *  Loop procedure
- */
+/*********************************************************
+ Inicio del programa
+*********************************************************/
 void loop() {
-  // poll messages
-  // blink led pin on each valid message
-  state = slave.poll( au16data, 9 );
+  //Comprueba el buffer de entrada
+  state = slave.poll( au16data, 9 ); //Parámetros: Tabla de registros para el intercambio de info
+                                     //            Tamaño de la tabla de registros
+                                     //Devuelve 0 si no hay pedido de datos
+                                     //Devuelve 1 al 4 si hubo error de comunicación
+                                     //Devuelve mas de 4 si se procesó correctamente el pedido

-  if (state > 4) {
-    tempus = millis() + 50;
-    digitalWrite(13, HIGH);
+  if (state > 4) { //Si es mayor a 4 = el pedido fué correcto
+    tempus = millis() + 50; //Tiempo actual + 50ms
+    digitalWrite(13, HIGH);//Prende el led
   }
-  if (millis() > tempus) digitalWrite(13, LOW );
-
-  // link the Arduino pins to the Modbus array
+  if (millis() > tempus) digitalWrite(13, LOW );//Apaga el led 50ms después
+
+  //Actualiza los pines de Arduino con la tabla de Modbus
   io_poll();
 }

@@ -63,10 +70,9 @@
  * 14 - analog input
  * 15 - analog input
  *
- * pin 13 is reserved to show a successful query
+ * pin 13 reservado para ver el estado de la comunicación
  */
 void io_setup() {
-  // define i/o
   pinMode(2, INPUT);
   pinMode(3, INPUT);
   pinMode(4, INPUT);
@@ -83,37 +89,40 @@
   digitalWrite(7, LOW );
   digitalWrite(8, LOW );
   digitalWrite(9, LOW );
-  digitalWrite(13, HIGH ); // this is for the UNO led pin
-  analogWrite(10, 0 );
-  analogWrite(11, 0 );
+  digitalWrite(13, HIGH ); //Led del pin 13 de la placa
+  analogWrite(10, 0 ); //PWM 0%
+  analogWrite(11, 0 ); //PWM 0%
 }

-/**
- *  Link between the Arduino pins and the Modbus array
- */
+/*********************************************************
+Enlaza la tabla de registros con los pines
+*********************************************************/
 void io_poll() {
-  // get digital inputs -> au16data[0]
-  bitWrite( au16data[0], 0, digitalRead( 2 ));
+  // digital inputs -> au16data[0]
+  // Lee las entradas digitales y las guarda en bits de la primera variable del vector
+  // (es lo mismo que hacer una máscara)
+  bitWrite( au16data[0], 0, digitalRead( 2 )); //Lee el pin 2 de Arduino y lo guarda en el bit 0 de la variable au16data[0]
   bitWrite( au16data[0], 1, digitalRead( 3 ));
   bitWrite( au16data[0], 2, digitalRead( 4 ));
   bitWrite( au16data[0], 3, digitalRead( 5 ));

-  // set digital outputs -> au16data[1]
-  digitalWrite( 6, bitRead( au16data[1], 0 ));
+  // digital outputs -> au16data[1]
+  // Lee los bits de la segunda variable y los pone en las salidas digitales
+  digitalWrite( 6, bitRead( au16data[1], 0 )); //Lee el bit 0 de la variable au16data[1] y lo pone en el pin 6 de Arduino
   digitalWrite( 7, bitRead( au16data[1], 1 ));
   digitalWrite( 8, bitRead( au16data[1], 2 ));
   digitalWrite( 9, bitRead( au16data[1], 3 ));

-  // set analog outputs
-  analogWrite( 10, au16data[2] );
+  // Cambia el valor del PWM
+  analogWrite( 10, au16data[2] ); //El valor de au16data[2] se escribe en la salida de PWM del pin 10 de Arduino. (siendo 0=0% y 255=100%)
   analogWrite( 11, au16data[3] );

-  // read analog inputs
-  au16data[4] = analogRead( 0 );
+  // Lee las entradas analógicas (ADC)
+  au16data[4] = analogRead( 0 ); //El valor analógico leido en el pin A0 se guarda en au16data[4]. (siendo 0=0v y 1023=5v)
   au16data[5] = analogRead( 1 );

-  // diagnose communication
-  au16data[6] = slave.getInCnt();
-  au16data[7] = slave.getOutCnt();
-  au16data[8] = slave.getErrCnt();
+  // Diagnóstico de la comunicación (para debug)
+  au16data[6] = slave.getInCnt();  //Devuelve cuantos mensajes se recibieron
+  au16data[7] = slave.getOutCnt(); //Devuelve cuantos mensajes se transmitieron
+  au16data[8] = slave.getErrCnt(); //Devuelve cuantos errores hubieron
 }


Added header comments to EsploraPong

Added header comments to EsploraPong

--- libraries/Esplora/examples/Experts/EsploraPong/EsploraPong.ino
+++ libraries/Esplora/examples/Experts/EsploraPong/EsploraPong.ino
@@ -1,3 +1,24 @@
+/*
+  Esplora Pong
+
+ This  sketch connects serially to a Processing sketch to control a Pong game.
+ It sends the position of the slider and the states of three pushbuttons to the
+ Processing sketch serially, separated by commas. The Processing sketch uses that
+ data to control the graphics in the sketch.
+
+ The slider sets a paddle's height
+ Switch 1 is resets the game
+ Switch 2 resets the ball to the center
+ Switch 3 reverses the players
+
+ You can play this game with one or two Esploras.
+
+ Created on 22 Dec 2012
+ by Tom Igoe
+
+ This example is in the public domain.
+ */
+
 #include <Esplora.h>

 void setup() {


Use the correct wavetable's basefreq

Use the correct wavetable's basefreq

--- dds_playground/src/sketch.ino
+++ dds_playground/src/sketch.ino
@@ -92,7 +92,7 @@
     digitalWrite(13, HIGH);
     for (int i=0; i<N_WAVETABLES; i++) {
         if (wavetables[i].currentnote == NONOTE) {
-            wavetables[i].increment = note_to_increment(pitch, wavetables[0].basefreq);
+            wavetables[i].increment = note_to_increment(pitch, wavetables[i].basefreq);
             wavetables[i].currentnote = pitch;
             used_wavetables++;
             break;


Update ArduCAM_Mini_5MP_Plus_Multi_Capture2SD.ino

--- ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_Multi_Capture2SD/ArduCAM_Mini_5MP_Plus_Multi_Capture2SD.ino
+++ ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_Multi_Capture2SD/ArduCAM_Mini_5MP_Plus_Multi_Capture2SD.ino
@@ -16,7 +16,7 @@
 //IF the FRAMES_NUM is 0X04, take five photos
 //IF the FRAMES_NUM is 0X05, take six photos
 //IF the FRAMES_NUM is 0X06, take seven photos
-//IF the FRAMES_NUM is 0X07, continue shooting until the FIFO is full
+//IF the FRAMES_NUM is 0XFF, continue shooting until the FIFO is full
 //You can see the picture in the SD card.
 // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM_Mini_5MP_Plus
 // and use Arduino IDE 1.6.8 compiler or above


turning update

turning update


Add blank line to match other examples

Add blank line to match other examples

--- examples/RS485_HalfDuplex/RS485_HalfDuplex.ino
+++ examples/RS485_HalfDuplex/RS485_HalfDuplex.ino
@@ -25,6 +25,7 @@
   limitations under the License.

 */
+
 #include <ModbusMaster.h>

 /*!


Added 'punishment' for repeated button presses within cooldown period.

--- LikeJar_5.ino
+++ LikeJar_5.ino
@@ -5,6 +5,7 @@
 // Soldered on a perfboard with a Kingbright 3 digit 7 segment common cathode LED module.

 // Version history:
+// 0.92: Beta for 5th prototype (button pin changed to hardware interrupt pin).
 // 0.91: Beta for 2nd prototype.
 // 0.9: Beta version removed test code & redundant variables and improved documentation.

@@ -22,7 +23,6 @@
 // A   A
 // 3   2
 //  A5.
-
 // 9   1
 // 9   2
 //  10. 11
@@ -147,6 +147,11 @@
           coolDownTicks = 2000;
           eeprom_write_block((const void*)&likes, (void*)0, sizeof(likes));
         }
+        else
+        {
+          // Cooldown wasn't done, restart cooldown as 'punishment' for pressing to soon.
+          coolDownTicks = 2000;
+        }
       }
     }
     // save the current state as the last state,


added OK message for M117 command

added OK message for M117 command

--- uArm.ino
+++ uArm.ino
@@ -490,6 +490,7 @@
 					for (; *endptr == ' ' || *endptr == '\t'; ++endptr);
 					messageScrollSet(endptr);
 					messageScrollUpdate(true);
+					sendMsg(F("OK\n"));
 					break;
 				default:
 					sendMsg(String(F("ERROR: invalid M address parameter: ")) + String(code, DEC) + String(F("\n")));


Fixed flash bug introduced by new loop

Fixed flash bug introduced by new loop

Fixed conditions to include flash mode in new loop
Cleaned CSS and changed color selector to match buttons

--- esp32LightServerRGB.ino
+++ esp32LightServerRGB.ino
@@ -67,49 +67,43 @@

 // stylesheet for web pages
 const String css = "\n";
 // end of stylesheet for web pages

@@ -252,6 +246,9 @@
   Serial.println(attendF);
   Serial.print("Fois - ");
   Serial.println(flashfois / 2);
+  if (attendF == 0){
+    flashfois = 0;
+  }
   if (testteu != 0) {
     derncoul = testteu;
     long number = strtol( &testteu[1], NULL, 16);
@@ -1111,7 +1108,7 @@

 void loop1(void *pvParameters) {
   while (1) {
-    if ( r != rouge || g != vert || b != bleu) {
+    if ( r != rouge || g != vert || b != bleu || flashoufade != 0 ) {
       lumiereloop();
       vTaskDelay( 7 / portTICK_PERIOD_MS ); // wait / yield time to other tasks
     } else {
@@ -1169,7 +1166,7 @@
   server.on("/party", handleClignote);
   server.on("/version", []() {
     String addy = server.client().remoteIP().toString();
-    server.send(200, "text/html", "V2.8, Steve Olmstead sansillusion@gmail.com\n\n

"
+    server.send(200, "text/html", "V2.9, Steve Olmstead sansillusion@gmail.com\n\n

"
                 "Added fader function\nRemoved connection watchdog (better have good signal)\n
"
                 "Removed mDns (did not work anyway)\n\n

"
                 "Added smoother fading\n\n

"
@@ -1201,7 +1198,9 @@
                 "Changed /setup (removed use sensors and added use dht and use dallas checkboxes)\n
"
                 "Revamped /temp and lesliens() to accomodate new changes in setup\n\n

"
                 "Added User-Agernt information in logging and serial output of / and 404 not found page\n
"
-                "Fixed Bonjour service support you can now use ( http://lumiere.local ) if you have Bonjour V3 installed\n
" + liens);
+                "Fixed Bonjour service support you can now use ( http://lumiere.local ) if you have Bonjour V3 installed\n

"
+                "Moved fading to it's own core and loop
\n"
+                "Cleaned CSS and changed color selector to match buttons" + liens);
     Serial.println("");
     Serial.println(addy);
     Serial.println("Page de Version");


Fiddle with debug flags a bit

Fiddle with debug flags a bit

--- device.ino
+++ device.ino
@@ -1128,7 +1128,6 @@
     gps_sog.substring(0,gps_sog.length()).toCharArray(temp_string, 19);
     float_one = atof(temp_string);

-    //if(float_one > 0.0)  //  Always active for debugging
     if(float_one > 0.25)  //  Moving faster than a 1/4 knot?
     {
       #ifdef ACTIVE_DEBUG_ON


oh my fucking god

oh my fucking god

--- 2018-FirefighterL1/2018-FirefighterL1.ino
+++ 2018-FirefighterL1/2018-FirefighterL1.ino
@@ -66,6 +66,7 @@
 float gyroTargetAngle = 0;

 float angleThreshold = 3;
+float driftAngle = 30;

 unsigned long freqCount;
 double closeToWall = 2;   //defines how close the robot should be (inches) to the wall to register as being "too close"
@@ -157,6 +158,12 @@
 //adjusts the target angle based on how much we want to turn and turns the robot until that target is reached
 //use turn(0) to simply get the gyro back on track if it's off target
 void turn(int angle){
+  if(angle > driftAngle){
+    angle -= driftAngle;
+  }else if(angle < -driftAngle){
+    angle += driftAngle;
+  }
+
   gyroTargetAngle += angle;
   if(gyroTargetAngle >= 360){
     gyroTargetAngle = gyroTargetAngle - 360;
@@ -166,16 +173,16 @@
   }

   if(angle > 0){
+    leftMotor.set(-leftSpeed);
+    rightMotor.set(rightSpeed);
+  }else{
     leftMotor.set(leftSpeed);
     rightMotor.set(-rightSpeed);
-  }else{
-    leftMotor.set(-leftSpeed);
-    rightMotor.set(rightSpeed);
   }

   while(abs(getGyroAngle() - gyroTargetAngle) > angleThreshold){
     Serial.println(String(getGyroAngle()));
-    delay(25);
+    delay(5);
   }

   stopRobot();
@@ -319,7 +326,7 @@
     FreqCount.begin(200); // Begin measuring sound
     checkMicrophone();  //robot stays in setup until frequency is heard

-    moveForward(36);
+    turn(90);
   }
 }


Keep the global variables with their respective setup functions.

--- wee_printer.ino
+++ wee_printer.ino
@@ -6,14 +6,12 @@
 #include <SoftwareSerial.h>
 #include <Thermal.h>

-byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x86, 0x67 }; //physical mac address
-EthernetClient client;
-
 #define debug(a) Serial.print(millis()); Serial.print(": "); Serial.println(a);
 #define debug2(a, b) Serial.print(millis()); Serial.print(": "); Serial.print(a); Serial.println(b);

 const int greenPin = 6;
 const int redPin = 7;
+
 void initDiagnosticLEDs() {
   pinMode(greenPin, OUTPUT);
   pinMode(redPin, OUTPUT);
@@ -41,6 +39,9 @@
   SD.begin(SD_Pin);
 }

+byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x86, 0x67 }; //physical mac address
+EthernetClient client;
+
 void initNetwork() {
   // start the Ethernet connection:
   if (Ethernet.begin(mac) == 0) {
@@ -51,7 +52,6 @@
   // print your local IP address:
   debug2("IP address: ", Ethernet.localIP());
 }
-

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


Brakes now work on AnalogWrite, Steer still writeMicroseconds from Servo library

--- Elcano_C2_LowLevel/Elcano_C2_LowLevel.ino
+++ Elcano_C2_LowLevel/Elcano_C2_LowLevel.ino
@@ -10,7 +10,7 @@
 const int softwareRx = 7;   // not used
 //SoftwareSerial s7s(softwareRx, softwareTx);
 #define s7s Serial2
-Servo STEER_SERVO, BRAKE_SERVO;
+Servo STEER_SERVO;//, BRAKE_SERVO;

 #define LOOP_TIME_MS 400
@@ -225,7 +225,7 @@
 void setup()
 { //Set up pins
       STEER_SERVO.attach(STEER_OUT_PIN);
-      BRAKE_SERVO.attach(BRAKE_OUT_PIN);
+      //BRAKE_SERVO.attach(BRAKE_OUT_PIN);

       // SPI: set the slaveSelectPin as an output:
       pinMode (SelectAB, OUTPUT);
@@ -638,7 +638,7 @@
 // Input is not in brake dead zone
 boolean liveBrake(int brake)
 {
-      return (brake < MIDDLE_GO - DEAD_ZONE);
+      return (brake < MIDDLE - DEAD_ZONE);
 }

 // Emergency stop
@@ -677,16 +677,16 @@
 }
 void brake (unsigned long amount)
 {
-    STEER_SERVO.writeMicroseconds(STRAIGHT_TURN_OUT);
-    STEER_SERVO.detach();
+    //STEER_SERVO.writeMicroseconds(STRAIGHT_TURN_OUT);
+    //STEER_SERVO.detach();
     //BRAKE_SERVO.attach(BRAKE_OUT_PIN);
-    if(amount > 1000)
-      BRAKE_SERVO.write(20);
+    if(amount > (MIDDLE - DEAD_ZONE))
+      analogWrite(BRAKE_OUT_PIN, 240);//BRAKE_SERVO.write(20);
     else
-      BRAKE_SERVO.write(160);
+      analogWrite(BRAKE_OUT_PIN, 140);//BRAKE_SERVO.write(160);
       //BRAKE_SERVO.writeMicroseconds(amount);
       Serial.print("\tBraking to: \t"); Serial.println(amount);
-    STEER_SERVO.attach(STEER_OUT_PIN);
+    //STEER_SERVO.attach(STEER_OUT_PIN);
       //brake_control = amount;
 }
 /*---------------------------------------------------------------------------------------*/


defensive

defensive

--- WifiWeatherGuy.ino
+++ WifiWeatherGuy.ino
@@ -194,8 +194,10 @@

 bool update_conditions(JsonObject &root, struct Conditions &c) {
   JsonObject &current_observation = root[F("current_observation")];
-  time_t epoch = (time_t)atoi(current_observation[F("observation_epoch")]);
-  if (epoch == c.epoch)
+  if (!current_observation.success())
+    return false;
+  time_t epoch = (time_t)atoi(current_observation[F("observation_epoch")] | "0");
+  if (epoch == c.epoch || epoch == 0)
     return false;

   c.epoch = epoch;
@@ -248,28 +250,29 @@

 void update_forecasts(JsonObject &root) {
   JsonArray &days = root[F("forecast")][F("simpleforecast")][F("forecastday")];
-  for (int i = 0; i < days.size(); i++) {
-    JsonObject &day = days[i];
-    struct Forecast &f = forecasts[i];
-    f.epoch = (time_t)atoi(day[F("date")][F("epoch")]);
-    strlcpy(f.day, day[F("date")][F("weekday_short")] | "", sizeof(f.day));
-    if (cfg.metric) {
-      f.temp_high = atoi(day[F("high")][F("celsius")] | "0");
-      f.temp_low = atoi(day[F("low")][F("celsius")] | "0");
-      f.max_wind = day[F("maxwind")][F("kph")];
-      f.ave_wind = day[F("avewind")][F("kph")];
-    } else {
-      f.temp_high = atoi(day[F("high")][F("fahrenheit")] | "0");
-      f.temp_low = atoi(day[F("low")][F("fahrenheit")] | "0");
-      f.max_wind = day[F("maxwind")][F("mph")];
-      f.ave_wind = day[F("avewind")][F("mph")];
+  if (days.success())
+    for (int i = 0; i < days.size() && i < sizeof(forecasts)/sizeof(struct Forecast); i++) {
+      JsonObject &day = days[i];
+      struct Forecast &f = forecasts[i];
+      f.epoch = (time_t)atoi(day[F("date")][F("epoch")] | "0");
+      strlcpy(f.day, day[F("date")][F("weekday_short")] | "", sizeof(f.day));
+      if (cfg.metric) {
+        f.temp_high = atoi(day[F("high")][F("celsius")] | "0");
+        f.temp_low = atoi(day[F("low")][F("celsius")] | "0");
+        f.max_wind = day[F("maxwind")][F("kph")];
+        f.ave_wind = day[F("avewind")][F("kph")];
+      } else {
+        f.temp_high = atoi(day[F("high")][F("fahrenheit")] | "0");
+        f.temp_low = atoi(day[F("low")][F("fahrenheit")] | "0");
+        f.max_wind = day[F("maxwind")][F("mph")];
+        f.ave_wind = day[F("avewind")][F("mph")];
+      }
+      f.ave_humidity = day[F("avehumidity")];
+      f.wind_degrees = day[F("avewind")][F("degrees")];
+      strlcpy(f.wind_dir, day[F("avewind")][F("dir")] | "", sizeof(f.wind_dir));
+      strlcpy(f.conditions, day[F("conditions")] | "", sizeof(f.conditions));
+      strlcpy(f.icon, day[F("icon")] | "", sizeof(f.icon));
     }
-    f.ave_humidity = day[F("avehumidity")];
-    f.wind_degrees = day[F("avewind")][F("degrees")];
-    strlcpy(f.wind_dir, day[F("avewind")][F("dir")] | "", sizeof(f.wind_dir));
-    strlcpy(f.conditions, day[F("conditions")] | "", sizeof(f.conditions));
-    strlcpy(f.icon, day[F("icon")] | "", sizeof(f.icon));
-  }
 }

 void display_weather(struct Conditions &c) {


Fix timing problems with ASM (correct formatting)

Replaced the C with ASM for the 2 places in sendBit() where timing
matters because new versions of the compiler were mangling the C order.
This new version should compile and execute correctly on all versions of
the compiler.

--- SimpleNeopixelDemo/SimpleNeopixelDemo.ino
+++ SimpleNeopixelDemo/SimpleNeopixelDemo.ino
@@ -43,34 +43,53 @@
 #define DELAY_CYCLES(n) ( ((n)>0) ? __builtin_avr_delay_cycles( n ) :  __builtin_avr_delay_cycles( 0 ) )  // Make sure we never have a delay less than zero

-// Actually send a bit to the string. We turn off optimizations to make sure the compile does
+// Actually send a bit to the string. We must to drop to asm to enusre that the complier does
 // not reorder things and make it so the delay happens in the wrong place.

-void  sendBit(bool) __attribute__ ((optimize(0)));
-
 void sendBit( bool bitVal ) {

     if (  bitVal ) {

-      bitSet( PIXEL_PORT , PIXEL_BIT );
-
-      DELAY_CYCLES( NS_TO_CYCLES( T1H ) - 2 );       // 1-bit width less  overhead  for the actual bit setting
-                                                     // Note that this delay could be longer and everything would still work
-      bitClear( PIXEL_PORT , PIXEL_BIT );
-
-      DELAY_CYCLES( NS_TO_CYCLES( T1L ) - 10 );       // 1-bit gap less the overhead of the loop
+		asm volatile (
+			"sbi %[port], %[bit] \n\t"				// Set the output bit
+			".rept %[onCycles] \n\t"                                // Execute NOPs to delay exactly the specified number of cycles
+			"nop \n\t"
+			".endr \n\t"
+			"cbi %[port], %[bit] \n\t"                              // Clear the output bit
+			".rept %[offCycles] \n\t"                               // Execute NOPs to delay exactly the specified number of cycles
+			"nop \n\t"
+			".endr \n\t"
+			::
+			[port]		"I" (_SFR_IO_ADDR(PIXEL_PORT)),
+			[bit]		"I" (PIXEL_BIT),
+			[onCycles]	"I" (NS_TO_CYCLES(T1H) - 2),		// 1-bit width less overhead  for the actual bit setting, note that this delay could be longer and everything would still work
+			[offCycles] "I" (NS_TO_CYCLES(T1L) - 2)			// Minimum interbit delay. Note that we probably don't need this at all since the loop overhead will be enough, but here for correctness
+
+			);

     } else {

-      bitSet( PIXEL_PORT , PIXEL_BIT );
-
-      DELAY_CYCLES( NS_TO_CYCLES( T0H ) - 2 );      // 0-bit width less overhead
-                                                    // **************************************************************************
-                                                    // This line is really the only tight goldilocks timing in the whole program!
-                                                    // **************************************************************************
-      bitClear( PIXEL_PORT , PIXEL_BIT );
-
-      DELAY_CYCLES( NS_TO_CYCLES( T0L ) - 10  );      // 0-bit gap less overhead of the loop
+		// **************************************************************************
+		// This line is really the only tight goldilocks timing in the whole program!
+		// **************************************************************************
+
+
+		asm volatile (
+			"sbi %[port], %[bit] \n\t"				// Set the output bit
+			".rept %[onCycles] \n\t"				// Now timing actually matters. The 0-bit must be long enough to be detected but not too long or it will be a 1-bit
+			"nop \n\t"                                              // Execute NOPs to delay exactly the specified number of cycles
+			".endr \n\t"
+			"cbi %[port], %[bit] \n\t"                              // Clear the output bit
+			".rept %[offCycles] \n\t"                               // Execute NOPs to delay exactly the specified number of cycles
+			"nop \n\t"
+			".endr \n\t"
+			::
+			[port]		"I" (_SFR_IO_ADDR(PIXEL_PORT)),
+			[bit]		"I" (PIXEL_BIT),
+			[onCycles]	"I" (NS_TO_CYCLES(T0H) - 2),
+			[offCycles] "I" (NS_TO_CYCLES(T0L) - 2)
+
+			);

     }

@@ -124,7 +143,7 @@
 // Just wait long enough without sending any bots to cause the pixels to latch and display the last sent frame

 void show() {
-    DELAY_CYCLES( NS_TO_CYCLES(RES) );
+	_delay_us( (RES / 1000UL) + 1);				// Round up since the delay must be _at_least_ this long (too short might not work, too long not a problem)
 }


cosmetic enhance

cosmetic enhance

--- f_ATmegaTimer.ino
+++ f_ATmegaTimer.ino
@@ -19,11 +19,11 @@
  *
  */
 volatile uint16_t clock_stretch;
-volatile boolean firstcall5;
+volatile boolean firstcall;

 ISR(TIMER5_COMPC_vect) {
-  if (firstcall5) {
-    firstcall5 = false;
+  if (firstcall) {
+    firstcall = false;
     return;
   }
   // compare match interrupt service routine (Timer 5 C)
@@ -78,7 +78,7 @@
   TCCR5A |= _BV(COM5B1); // connect OC5B pin (the internal OC5B register is LOW)

   // * the first compare match interrupt call is bogus.
-  firstcall5 = true;
+  firstcall = true;

   if (stretch != 0) {
     // number of ticks the last HSYNC before VSYNC longer than others
@@ -133,7 +133,7 @@
 }

 // For Time Lapse
-// generating periodic TRIG by using Timer3 Compare Match C interrupt
+// generating periodic shutter by using Timer3 Compare Match C interrupt

 volatile int8_t lapse = -1;


convert step seq to MIDIUSB

convert step seq to MIDIUSB

--- examples/UNTZtrument_Step_Seq/UNTZtrument_Step_Seq.ino
+++ examples/UNTZtrument_Step_Seq/UNTZtrument_Step_Seq.ino
@@ -5,6 +5,7 @@
 #include <Wire.h>
 #include <Adafruit_Trellis.h>
 #include <Adafruit_UNTZtrument.h>
+#include "MIDIUSB.h"

 #define LED 13 // Pin for heartbeat LED (shows code is working)

@@ -71,6 +72,18 @@
   e.setValue(bpm * 4);              // *4's for encoder detents
 }

+void noteOn(byte channel, byte pitch, byte velocity) {
+  midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
+  MidiUSB.sendMIDI(noteOn);
+  MidiUSB.flush();
+}
+
+void noteOff(byte channel, byte pitch, byte velocity) {
+  midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
+  MidiUSB.sendMIDI(noteOff);
+  MidiUSB.flush();
+}
+
 // Turn on (or off) one column of the display
 void line(uint8_t x, boolean set) {
   for(uint8_t mask=1, y=0; y<8; y++, mask <<= 1) {
@@ -97,8 +110,7 @@
           if(grid[x] & mask) { // Already set?  Turn off...
             grid[x] &= ~mask;
             untztrument.clrLED(i);
-            usbMIDI.sendNoteOff(pgm_read_byte(&note[y]),
-              127, pgm_read_byte(&channel[y]));
+            noteOff(pgm_read_byte(&channel[y]), pgm_read_byte(&note[y]), 127);
           } else { // Turn on
             grid[x] |= mask;
             untztrument.setLED(i);
@@ -116,8 +128,7 @@
     line(col, false);
     for(uint8_t row=0, mask=1; row<8; row++, mask <<= 1) {
       if(grid[col] & mask) {
-        usbMIDI.sendNoteOff(pgm_read_byte(&note[row]), 127,
-          pgm_read_byte(&channel[row]));
+        noteOff(pgm_read_byte(&channel[row]), pgm_read_byte(&note[row]), 127);
       }
     }
     // Advance column counter, wrap around
@@ -126,8 +137,7 @@
     line(col, true);
     for(uint8_t row=0, mask=1; row<8; row++, mask <<= 1) {
       if(grid[col] & mask) {
-        usbMIDI.sendNoteOn(pgm_read_byte(&note[row]), 127,
-          pgm_read_byte(&channel[row]));
+          noteOn(pgm_read_byte(&channel[row]), pgm_read_byte(&note[row]), 127);
       }
     }
     prevBeatTime = t;
@@ -138,5 +148,4 @@

   if(refresh) untztrument.writeDisplay();

-  while(usbMIDI.read()); // Discard incoming MIDI messages
 }


added scoreboard, fixed bouncing bug. turns out the angle wasn't a float. d'oh

--- pong.ino
+++ pong.ino
@@ -6,7 +6,7 @@
 int playerPos = 32;

 int ballDir = 1;
-int ballAngle = -1;
+float ballAngle = -1;
 int stepCount = 0;

 int ballC[] = {65, 62};
@@ -41,7 +41,7 @@
     else {
       cpuPos = cpuPos;
     }
-//    movePaddles = false;
+    movePaddles = false;
   } else {
     movePaddles = true;
   }
@@ -50,12 +50,17 @@
     Logic for the ball
   */
   if (ballC[1] == 0 || ballC[1] == 63) { // if it hits a wall
-    ballAngle *= -1;
+    Serial.println("Before");
+    Serial.println(ballAngle);
+    Serial.println(ballC[1]);
+    ballAngle *= -1; // bounce
     ballC[1] += (ballC[1] > 32 ? -1 : 1);
+    Serial.println("After");
+    Serial.println(ballAngle);
+    Serial.println(ballC[1]);
+    Serial.println();
   }

-
-  Serial.println(ballAngle, DEC);
   // if it hits a paddle
   if (ballC[0] == 123 && abs(playerPos-ballC[1]) <= 5) {  // player
     ballDir *= -1;
@@ -135,11 +140,17 @@

   display.drawLine(3, cpuPos-5, 3, cpuPos+5, WHITE);
   display.drawLine(124, playerPos-5, 124, playerPos+5, WHITE);
+
+  display.setTextSize(2);
+  display.setCursor(30, 0);
+  display.print(CPUScore, DEC);
+  display.setCursor(96, 0);
+  display.println(playerScore, DEC);
+
   display.display();
 }

 void buildField() {
-  Serial.println("BUILDING");
   for (int i = 1; i < 63; i=i+2)
     display.drawPixel(63, i, WHITE);
 }


Added move to distance

Added move to distance

--- firefighter/firefighter.ino
+++ firefighter/firefighter.ino
@@ -314,24 +314,12 @@
 void driveToWhite() {
   int ri = colour_sensor.getColor('r');
   int r = ri;
-//  int g = colour_sensor.getColor('g');
-//  int b = colour_sensor.getColor('b');
-//  String colour = String(ri) + " " + String(g) + " " + String(b);
-//  Serial.println(colour);
   hDrive(.3,0,0);
-  Serial.print("Initial: ");
-  Serial.println(ri);

   while(r > ri - 70) {
     r = colour_sensor.getColor('r');
-//        String colour = String(r);
-//        Serial.println(colour);
-  }
-
-  Serial.print("Final: ");
-  Serial.println(r);
-
-//      Serial.println("Done");
+  }
+
   hDrive(0.0, 0.0, 0.0);
 }

@@ -423,12 +411,24 @@
 }

 void turnToAngle(double targetAngle, double speed) {
+  resetGyro('z');
+
+  hDrive(0.0, speed, 0.0);
+
+  while (abs(getAngle('z')) < abs(targetAngle)) {
+    // Serial.println(getAngle('z'));
+  }
+
+  hDrive(0.0, 0.0, 0.0);
+}
+
+void driveToDistance(double targetDistance, double speed) {
   resetEncoders();

-  hDrive(0.0, speed, 0.0);
-
-  while (abs(getAngle('z')) < abs(targetAngle)) {
-    Serial.println(getAngle('z'));
+  hDrive(speed, 0.0, 0.0);
+
+  while (abs(getDistanceLeft()) < abs(targetDistance) && abs(getDistanceRight()) < abs(targetDistance) ) {
+    // Serial.println(getDistanceLeft());
   }

   hDrive(0.0, 0.0, 0.0);


BasicGain_wApp: enabling serialPlotter by default

--- examples/06-AppTutorial/01-BasicGain_wApp/01-BasicGain_wApp.ino
+++ examples/06-AppTutorial/01-BasicGain_wApp/01-BasicGain_wApp.ino
@@ -128,7 +128,7 @@

   //add some pre-defined pages to the GUI
   myGUI.addPredefinedPage("serialMonitor");
-  myGUI.addPredefinedPage("plot");
+  myGUI.addPredefinedPage("serialPlotter");
 }

@@ -150,4 +150,4 @@

 void setButtonText(String btnId, String text) {
   myTympan.println("TEXT=BTN:" + btnId + ":"+text);
-}+}


Go back to the welcome message after testing the lcd

--- statusbot.ino
+++ statusbot.ino
@@ -35,21 +35,25 @@
   pinMode(G_PIN, OUTPUT);
   pinMode(B_PIN, OUTPUT);

+  Spark.function("backlight", netBacklight);
+  Spark.function("testLight", testBacklight);
+  Spark.function("printLCD", printLCD);
+
+  welcomeMessage();
+}
+
+void loop() {
+
+}
+
+void welcomeMessage() {
   backlight(WIZARD_ORANGE);
-    lcd.print("Wizard Dev");
+  lcd.print("Wizard Dev");
   lcd.setCursor(0,1);
   lcd.print("Hello Programs!");
   delay(1000);
   lcd.setCursor(0,1);
   lcd.print("StatusBot Online");
-
-  Spark.function("backlight", netBacklight);
-  Spark.function("testLight", testBacklight);
-  Spark.function("printLCD", printLCD);
-}
-
-void loop() {
-
 }

 int printLCD (String message) {
@@ -101,6 +105,7 @@
   backlight(WIZARD_GRAY);
   delay(500);

+  welcomeMessage();
   return 1;
 }


now recalibrates each time the state changes

--- src/transmit/transmit.ino
+++ src/transmit/transmit.ino
@@ -14,7 +14,7 @@
 #define TURNON_FLOWER_GREEN_PIN       4
 #define TURNON_FLOWER_BLUE_PIN        5
 #define TURNON_CALIBRATION_DURATION   5000
-#define TURNON_SQUEEZE_THRESHOLD      20
+#define TURNON_SQUEEZE_THRESHOLD      10
 #define TURNON_CYCLE_DURATION         250
 #define TURNON_HOLD_MILLIS            3000
 #define TURNON_ACK_TIMEOUT            2000
@@ -36,7 +36,7 @@
 RFM69 radio;

 void setup() {
-  // Serial.begin(9600);
+  Serial.begin(9600);
   pinMode(TURNON_TX_LED_PIN,        OUTPUT);
   pinMode(TURNON_FLOWER_RED_PIN,    OUTPUT);
   pinMode(TURNON_FLOWER_GREEN_PIN,  OUTPUT);
@@ -50,7 +50,8 @@

 void loop() {
   int sensorValue = analogRead(TURNON_SENSOR_PIN);
-
+  Serial.println(sensorValue);
+
   if(isCalibrating) {
     runCalibrationMode(sensorValue);
   } else {
@@ -89,7 +90,8 @@

 // Represents a single cycle of sensor calibration.
 void runCalibrationMode(int sensorValue) {
-
+  Serial.println("calibrating...");
+
   // Indicate we're in calibration mode
   digitalWrite(TURNON_FLOWER_BLUE_PIN, HIGH);

@@ -110,7 +112,6 @@
 // Given the sensor value, this function computes the current state
 // of the transmitter.
 void updateCurrentState(int sensorValue, byte colorBit) {
-//  Serial.println(sensorValue);

   // We've met the squeeze threshold.
   if(sensorValue > avgIdlePressure + TURNON_SQUEEZE_THRESHOLD) {
@@ -119,7 +120,7 @@
     // We've squeezed for a duration of at least TURNON_HOLD_MILLIS
     if(heldMillis >= TURNON_HOLD_MILLIS) {
       heldMillis  = 0;
-
+
       // Special case: if the color bit is 0,
       // reset the current state
       if(colorBit == 0) {
@@ -134,6 +135,11 @@
         // Flip the color state bit
         currentState ^= bit(colorBit);
       }
+
+      // Trigger recalibration
+      isCalibrating         = true;
+      calibrationIteration  = 0;
+      avgIdlePressure       = 0;
     }
   } else {
     heldMillis = 0;


Added basic navigation code

Added basic navigation code

--- gps_arduino/gps_arduino.ino
+++ gps_arduino/gps_arduino.ino
@@ -210,6 +210,8 @@
   }

   void executeCommand(int cmd){
+    float heading;
+    int distance;
     switch(cmd){
        case CMD_SHOW_POSITION:
          //Display current position
@@ -240,11 +242,26 @@
          lcd.print(compassHeading);
          lcd.setCursor(0,1);
          lcd.print("G:");
-         lcd.print(getHeading(mCurrentWayPoint, flat, flon));
+         heading = getHeading(mCurrentWayPoint, flat, flon);
+         lcd.print(heading);
          lcd.print(" ");
          lcd.print("D:");
-         lcd.print(formatDistance(getDistance(mCurrentWayPoint, flat, flon)));
-         //delay(100);
+         distance = getDistance(mCurrentWayPoint, flat, flon);
+         lcd.print(formatDistance(distance));
+         //Check if distance is less then 2 meters
+         if(distance < 2){
+           //Advance to next way point
+           mCurrentWayPoint++;
+         } else {
+           //Navigate to the way point
+           if(compassHeading == heading){
+              forward();
+           } else if (compassHeading > heading) {
+              left();
+           } else {
+              right();
+           }
+         }
        break;
        case CMD_ADD_WAY_POINT:
          mLat[mCurrentWayPoint] = flat;
@@ -261,6 +278,18 @@
     }

   }
+
+ void forward(){
+
+ }
+
+ void left(){
+
+ }
+
+ void right(){
+
+ }

  float formatDistance(int meters){
   return meters / (float) 1000;


Added sebbes changes

Added sebbes changes

--- ESP8266_Base.ino
+++ ESP8266_Base.ino
@@ -70,12 +70,12 @@
  */
 void handleRoot()
 {
-  server.send(200, "text/html", "
You are connected

Setup WLAN");
+  server.send(200, "text/html", "<!doctype html>
You are connected

Setup WLAN");
 }

 void handleWlanSetup()
 {
-  server.send(200, "text/html", "
You are connected
<form method='POST' action='/wlanSetupConfirm'>SSID<input type='text' name='ssid' />
 pwd<input type='text' name='password' />
 <input type='submit' value='Update' /></form>");
+  server.send(200, "text/html", "<!doctype html>
You are connected
<form method=\"POST\" action=\"/wlanSetupConfirm\">SSID<input id=\"ssid\" name=\"ssid\">
pwd<input id=\"pwd\" name=\"password\">
<input type=\"submit\" value=\"Update\"></form>");
 }

 void handlePwdPost()
@@ -89,7 +89,7 @@
   eepromContent.detectPattern = DETECT_MATCH_PATTERN;
   EEPROM_writeAnything(0, eepromContent);
   EEPROM.commit();
-  server.send(200, "text/html", "OK - Data stored to EEPROM.");
+  server.send(200, "text/html", "<!doctype html>OK - Data stored to EEPROM.");
 }

@@ -98,7 +98,7 @@
   String valStr = server.arg("value");
   Serial.print("new Value = " + valStr);
   curPwmOut = (uint16_t)valStr.toInt();
-  server.send(200, "text/html", "OK - Value Set to" + String(curPwmOut));
+  server.send(200, "application/json", "{\"status\":\"Value Set to" + String(curPwmOut) + "\",\"value\":"+curPwmOut+"}");
 }

@@ -257,8 +257,3 @@
   delay(1);

 }
-
-
-
-
-


not necessary

not necessary

--- status.ino
+++ status.ino
@@ -63,8 +63,6 @@
         else if (c == ";") {
             lastColor = atoi(current.c_str());
             desired[lastDyno] = lastColor;
-            lastColor = OFF;
-            lastDyno = 0;
         }
         else {
             current += c;


Add newline to the end of file

Add newline to the end of file

--- arduino/sensor.ino
+++ arduino/sensor.ino
@@ -57,4 +57,5 @@
   }

   delay(POSTRATE);
-}+}
+


Sample audio amplitude on pin 23 (A9).

Sample audio amplitude on pin 23 (A9).

--- usb-to-octows2811/usb-to-octows2811.ino
+++ usb-to-octows2811/usb-to-octows2811.ino
@@ -2,6 +2,7 @@
 #define USE_OCTOWS2811
 #include<OctoWS2811.h>
 #include<FastLED.h>
+#include<ADC.h>

 #define NUM_LEDS_STRIP_A 514
 #define NUM_LEDS_STRIP_B 370
@@ -26,11 +27,37 @@
 // Pin 13 has the LED on Teensy 3.0
 // give it a name:
 #define STATUS_LED 13
+
+// Pin A9 is audio in
+#define AUDIO_PIN A9
+
 int frame_count = 0;
+
+ADC *adc = new ADC();
+
+short adc0_count = 0;
+short adc0_min = 0;
+short adc0_max = 0;
+long adc0_total = 0;
+
+void adc0_isr(void) {
+    int v = adc->analogReadContinuous(ADC_0);
+    if (adc0_count <= 0) {
+        adc0_count = 0;
+        adc0_min = v;
+        adc0_max = v;
+        adc0_total = v;
+    } else {
+        adc0_min = min(adc0_min, v);
+        adc0_max = max(adc0_max, v);
+        adc0_total += v;
+    }
+    adc0_count++;
+}

 void setup() {
   pinMode(STATUS_LED, OUTPUT);
-  digitalWrite(STATUS_LED, HIGH);
+  digitalWriteFast(STATUS_LED, HIGH);

   Serial.begin(115200);
   FastLED.addLeds<OCTOWS2811>(leds, NUM_LEDS_STRIP_A);
@@ -49,7 +76,7 @@
   FastLED.show();

   delay(500);
-  digitalWrite(STATUS_LED, LOW);
+  digitalWriteFast(STATUS_LED, LOW);

   // Now turn the LED off, then pause
   leds[0] = CRGB::Black;
@@ -58,7 +85,16 @@
   FastLED.show();
   delay(500);

-  digitalWrite(STATUS_LED, HIGH);
+  pinMode(AUDIO_PIN, INPUT);
+
+  adc->setAveraging(32); // set number of averages
+  adc->setResolution(12); // set bits of resolution
+  adc->setConversionSpeed(ADC_LOW_SPEED); // change the conversion speed
+  adc->setSamplingSpeed(ADC_LOW_SPEED); // change the sampling speed
+  adc->enableInterrupts(ADC_0);
+  adc->startContinuous(AUDIO_PIN, ADC_0);
+
+  digitalWriteFast(STATUS_LED, HIGH);
 }

 long leds_mw_per_supply() {
@@ -104,11 +140,28 @@
   FastLED.show(brightness);

   frame_count++;
-  digitalWrite(STATUS_LED, (frame_count & 0x80) ? HIGH : LOW);
+  digitalWriteFast(STATUS_LED, (frame_count & 0x80) ? HIGH : LOW);
+
+  // Try to copy values quickly. This is a race condition with the interrupt.
+  short audio_count = adc0_count;
+  short audio_avg = adc0_total / max(1, audio_count);
+  short audio_min = adc0_min;
+  short audio_max = adc0_max;
+  // Reset the counter, which will cause the interrupt to clear other values.
+  adc0_count = 0;

   Serial.print(brightness);
   Serial.print("\t");
-  Serial.println(mw);
+  Serial.print(mw);
+  Serial.print("\t");
+  Serial.print(audio_count);
+  Serial.print("\t");
+  Serial.print(audio_min * 5000 / 4096);  // Return min in mV
+  Serial.print("\t");
+  Serial.print(audio_avg * 5000 / 4096);  // Return avg in mV
+  Serial.print("\t");
+  Serial.println(audio_max * 5000 / 4096);  // Return max in mV
+  Serial.send_now();
 }

 void loop() {


Included SPI.h for SD card.

Included SPI.h for SD card.

--- code/code.ino
+++ code/code.ino
@@ -3,6 +3,7 @@
 #define SD_CARD_PIN 53

 #include <SD.h>
+#include <SPI.h>
 #include <Wire.h>
 #include "PID.h"


ultrasonic sensor now working corectly

ultrasonic sensor now working corectly

--- LCD_temp_humidity/LCD_temp_humidity.ino
+++ LCD_temp_humidity/LCD_temp_humidity.ino
@@ -8,11 +8,10 @@

 #define trigPin 5
 #define echoPin 4
-int binHeight = 11.5;       //silo height is 18 cm
-float binPercent;
-float binPercenttwo;
-float binpercentThree;
-
+//ultrasonic variables
+int maximumRange = 50;
+long duration, distance, d1,d2,d3;
+int testDistance=15;

 const int pinRed = 9;        // initialize the danger pin
 const int pinNorm = 8;      // initialize normal pin
@@ -97,10 +96,13 @@

   DEBUG = true;         // enable debug serial

-  //Initializing the Pins of the Ultrasonic Sensor (Trig pin as the output and Echo pin as the input)
-  pinMode(trigPin, OUTPUT);
-  pinMode(echoPin, INPUT);
-
+//Initializing the Pins of the Ultrasonic Sensor (Trig pin as the output and Echo pin as the input)
+  Serial.begin (9600);
+  pinMode (trigPin, OUTPUT);
+  pinMode (echoPin, INPUT );
+
+
+
   Serial.begin(9600);                  // starts the serial
   pinMode(pinRed, INPUT);             // initialize the Danger Pin
   pinMode(pinNorm, INPUT);           // initialize the Normal  Pin
@@ -130,37 +132,35 @@

 int CheckDistance()
 {
- long duration, distance;
-  digitalWrite(trigPin, LOW);  // Added this line
-  delayMicroseconds(2); // Added this line
-  digitalWrite(trigPin, HIGH);
-//  delayMicroseconds(1000); - Removed this line
-  delayMicroseconds(10); // Added this line
-  digitalWrite(trigPin, LOW);
-  duration = pulseIn(echoPin, HIGH);
-  distance = (duration/2) / 29.1;
-  return distance;
+   digitalWrite(trigPin,LOW);
+    delayMicroseconds(2);
+
+    digitalWrite(trigPin,HIGH);
+    delayMicroseconds(10);
+
+    duration=pulseIn (echoPin,HIGH);
+
+    distance= duration/58.2;
+    delay (1000);
+    return distance;
 }
 // ====================================================================== loop

 void loop()
 {
   // Calculate percentages of Silo fill
-  int testDistance = CheckDistance();           /// get object distance using ping
-   float binPercent = 11.5 - testDistance;
-  float binPercenttwo = binPercent / 11.5;
-  float binpercentThree =  binPercenttwo * 100;
-
-  int siloHeight = binpercentThree;
-
-  if (binpercentThree > 90) /// if silo is more than 90% full
+  int d3 = CheckDistance();           /// get object distance using ping
+  d1=testDistance-d3;
+  d2=(d1 *6.66666667);
+
+
+  if (d2 > 90) /// if silo is more than 90% full
   {
     Serial.println("Silo is almost full");
   }
-  Serial.print(binPercent);
-  Serial.println("Empty");
-  Serial.print(testDistance);
-  Serial.println(" cm");
+   Serial.println(d2);
+   Serial.println("Percent full");
+
   delay(500);

@@ -174,8 +174,8 @@
     if (DEBUG)  Serial.println("Temp=" + String(t) + " *C");
     if (DEBUG) Serial.println("Humidity=" + String(h) + " %");

-   if (siloHeight>0){
-       thingSpeakWrite(t, h, siloHeight);                                     // Write values to thingspeak
+   if (d2>0){
+       thingSpeakWrite(t, h, d2);                                     // Write values to thingspeak
    }

   }
@@ -207,8 +207,3 @@
   delay(20000);     // thingspeak needs 15 sec delay between updates,
 }

-
-
-
-
-


Removed redundant Blynk notification at led signaling.

--- watertank.ino
+++ watertank.ino
@@ -401,8 +401,8 @@
                 if (waterTrend < -1 * WATER_TREND_MARGIN) waterStatus = WATER_STATUS_PUMPING;
                 if (waterStatusOld != waterStatus) {
 #ifdef BLYNK_NOTIFY_WATER
+                    // Push notification
                     String txtStatus;
-                    // Push notification
                     switch (waterStatus) {
                         case WATER_STATUS_STABLE:
                             txtStatus = String("stabilized");
@@ -424,7 +424,6 @@
                             ledWaterPump.off();
                             break;
                     }
-                    Blynk.notify(BLYNK_LABEL + String("Water tank has been ") + txtStatus);
 #endif
                     waterStatusOld = waterStatus;
                 }


adding i2c slave code

adding i2c slave code

--- IMUtest.ino
+++ IMUtest.ino
@@ -10,6 +10,11 @@

 #include <Wire.h>
 #include "IMU.h"
+
+// arduino I2C slave address: ensure no conflict with LSM303 or L3G addresses
+const byte slaveAdd = 0x44;
+int registerAddr;
+int data[12];      // I2C data registers 0x00 to 0x0b

 // speed settings
 int  msecPerCycle = 50;
@@ -29,6 +34,89 @@

 IMU withGyro;  // with accelerometer/gyro fusion
 IMU noGyro;    // just accelerometer
+
+
+void setup() {
+
+  Serial.begin(baud);
+
+  Wire.begin(slaveAdd);
+  Wire.onReceive(receiveRegister);
+  Wire.onRequest(respondData);
+  // I2C clock freq; don't set this register on DUE: there are currently issues
+  TWBR=100000L;
+
+  withGyro.init();
+  noGyro.init();
+
+  delay(100);
+
+  // true means gyro is used, followed by alpha
+  // 0 < alpha < 1;
+  // alpha ~ 1 weights gyro heavily, alpha ~ 0 weights accelerometer heavily
+  // if false, alpha is ignored, and no gyro data is used
+  withGyro.setWeightsAndGyro(true, 0.95);
+  noGyro.setWeightsAndGyro(false, 0.95); // no gyro, alpha is ignored
+
+  // mag, acc, calibration methods take three offsets, three scales
+  // 5/11/17 calibration, average of three
+  withGyro.setCalibrateMag(  -52, -158,   39,  1.00, 1.02, 1.16);
+  noGyro.setCalibrateMag(  -52, -158,   39,  1.00, 1.02, 1.16);
+
+  // 5/8/17 calibration values
+  withGyro.setCalibrateAcc(-1020,  -84, -700,  1.07, 1.07, 1.00);
+  noGyro.setCalibrateAcc(-1020,  -84, -700,  1.07, 1.07, 1.00);
+
+  // new gyro calibration here: offset, noise value, calibrated rate for each axis
+  //withGyro.setCalibrateGyro(off, off, off,  noise, noise, noise,  scal, scal, scal);
+
+  // NOTE: the rollAxis, rollReference vectors must be orthogonal for meaningful
+  // results; they can be non-normal: they are normalized internally
+  // WS 5/3/17: 'normal' chip settings, consistent with Pololu markings
+  // x chip axis is 'x', y chip axis is 'y'
+  // x axis is rollAxis, y axis is rollReference
+  withGyro.setIMUAxes  (1, 0, 0, 0, 1, 0);
+  noGyro.setIMUAxes  (1, 0, 0, 0, 1, 0);
+
+  // 5/4/17 experiment: this worked, with correct signs for angles
+  // -y chip axis is rollAxis 'x', x chip axis is rollReference 'y'
+  //withGyro.setIMUAxes      (0, -1, 0, 1, 0, 0);
+
+  // 5/4/17 experiment: this worked, with correct signs for angles
+  // z chip axis is rollAxis 'x', x chip axis is rollReference 'y'
+  //withGyro.setIMUAxes      (0, 0, 1, 1, 0, 0);
+}
+
+
+void loop() {
+
+  // do one or the other calibrations, not both together
+  if (CALIBACC) {withGyro.doCalibrateAcc(CALIB_TEST);}
+  if (CALIBMAG) {withGyro.doCalibrateMag(CALIB_TEST);}
+
+  if (PRINTSCREEN || RPH  || RPH2 || DEVTYPE) {
+    withGyro.getRollPitchHeading();
+    noGyro.getRollPitchHeading();
+    printResults();
+  }
+
+  delay(msecPerCycle);
+}
+
+
+void receiveRegister(int x) {
+  registerAddr = Wire.read();
+}
+
+
+void respondData(){
+  byte dataValue = 0x00;  // default value
+  if ((registerAddr >= 0x00) && (registerAddr < 0x0b)) {
+    dataValue = data[registerAddr];
+  }
+  Wire.write(dataValue);
+}
+

 void printResults() {

@@ -85,68 +173,3 @@
  }
 }

-
-void setup() {
-  Serial.begin(baud);
-  //Wire.begin();  // arduino as I2C master
-
-  // arduino I2C slave address: 0x44; no conflict with LSM303 or L3G addresses
-  Wire.begin(0x44);
-  // I2C clock frequency; don't set this register on DUE: there are issues
-  TWBR=100000L;
-
-  withGyro.init();
-  noGyro.init();
-
-  delay(100);
-
-  // true means gyro is used, followed by alpha
-  // 0 < alpha < 1;
-  // alpha ~ 1 weights gyro heavily, alpha ~ 0 weights accelerometer heavily
-  // if false, alpha is ignored, and no gyro data is used
-  withGyro.setWeightsAndGyro(true, 0.95);
-  noGyro.setWeightsAndGyro(false, 0.95); // no gyro, alpha is ignored
-
-  // mag, acc, calibration methods take three offsets, three scales
-  // 5/11/17 calibration, average of three
-  withGyro.setCalibrateMag(  -52, -158,   39,  1.00, 1.02, 1.16);
-  noGyro.setCalibrateMag(  -52, -158,   39,  1.00, 1.02, 1.16);
-
-  // 5/8/17 calibration values
-  withGyro.setCalibrateAcc(-1020,  -84, -700,  1.07, 1.07, 1.00);
-  noGyro.setCalibrateAcc(-1020,  -84, -700,  1.07, 1.07, 1.00);
-
-  // new gyro calibration here: offset, noise value, calibrated rate for each axis
-  //withGyro.setCalibrateGyro(off, off, off,  noise, noise, noise,  scal, scal, scal);
-
-  // NOTE: the rollAxis, rollReference vectors must be orthogonal for meaningful
-  // results; they can be non-normal: they are normalized internally
-  // WS 5/3/17: 'normal' chip settings, consistent with Pololu markings
-  // x chip axis is 'x', y chip axis is 'y'
-  // x axis is rollAxis, y axis is rollReference
-  withGyro.setIMUAxes  (1, 0, 0, 0, 1, 0);
-  noGyro.setIMUAxes  (1, 0, 0, 0, 1, 0);
-
-  // 5/4/17 experiment: this worked, with correct signs for angles
-  // -y chip axis is rollAxis 'x', x chip axis is rollReference 'y'
-  //withGyro.setIMUAxes      (0, -1, 0, 1, 0, 0);
-
-  // 5/4/17 experiment: this worked, with correct signs for angles
-  // z chip axis is rollAxis 'x', x chip axis is rollReference 'y'
-  //withGyro.setIMUAxes      (0, 0, 1, 1, 0, 0);
-}
-
-void loop() {
-
-  // do one or the other calibrations, not both together
-  if (CALIBACC) {withGyro.doCalibrateAcc(CALIB_TEST);}
-  if (CALIBMAG) {withGyro.doCalibrateMag(CALIB_TEST);}
-
-  if (PRINTSCREEN || RPH  || RPH2 || DEVTYPE) {
-    withGyro.getRollPitchHeading();
-    noGyro.getRollPitchHeading();
-    printResults();
-  }
-
-  delay(msecPerCycle);
-}


1.0 RC5

1.0 RC5

- Improved Swing detection
- Improved Clash detection
- Improved sound relaunch detection
- Improved RGB LEDs colors management
- 2ko less on produced hex files
- Added a "Wrist Twist" movement (in case you want to bury your saber in
an airlock)
- Added "Force effect" (short press on main button in action mode)
- Corrected a major bug that prevented LSOS from building in ArduinoIDE
- Code cleaning  (again)
- Many minor bug correction

--- Lightsaber.ino
+++ Lightsaber.ino
@@ -28,8 +28,8 @@
  */
 #define CONFIG_VERSION 		"L01"
 #define MEMORYBASE 			32
-#define SWING_SUPPRESS 		10
-#define CLASH_SUPPRESS 		40
+#define SWING_SUPPRESS 		7
+#define CLASH_SUPPRESS 		7
 #define CLASH_PASSES 		20
 #define BRAKE_PASSES 		3

@@ -62,7 +62,7 @@
 #ifdef LUXEON
 /* COLORS
  * Number of colors to chose from
- * Range : 6-600
+ * Range : 6<->600
  */
 #define COLORS		 		48
 #define LED_RED 			3
@@ -525,8 +525,8 @@
 		if (abs(quaternion.w) > storage.swingTreshold and !swingSuppress
 				and aaWorld.z < 0
 				and abs(quaternion.z) < (9 / 2) * storage.swingTreshold
-				and (abs(quaternion.x) > (5 / 2) * storage.swingTreshold
-						or abs(quaternion.y) > (5 / 2) * storage.swingTreshold)	// We don't want to treat blade Z axe rotations as a swing
+				and (abs(quaternion.x) > 3 * storage.swingTreshold
+						or abs(quaternion.y) > 3 * storage.swingTreshold)	// We don't want to treat blade Z axe rotations as a swing
 				) {
 			/*
 			 *  THIS IS A SWING !
@@ -548,8 +548,8 @@
 		} else if (abs(quaternion.w) > storage.swingTreshold and !swingSuppress
 				and (aaWorld.z > 0
 						and abs(quaternion.z) > (13 / 2) * storage.swingTreshold
-						and abs(quaternion.x) < (5 / 2) * storage.swingTreshold
-						and abs(quaternion.y) < (5 / 2) * storage.swingTreshold)// We specifically  treat blade Z axe rotations as a swing
+						and abs(quaternion.x) < 3 * storage.swingTreshold
+						and abs(quaternion.y) < 3 * storage.swingTreshold)// We specifically  treat blade Z axe rotations as a swing
 				) {
 			/*
 			 *  THIS IS A WRIST TWIST !


Updated for V3.1 PCB

Updated for V3.1 PCB

--- OxFloodNet_Sensor/OxFloodNet_Sensor.ino
+++ OxFloodNet_Sensor/OxFloodNet_Sensor.ino
@@ -20,10 +20,16 @@
 #include <OneWire.h>
 #include <DallasTemperature.h>

-#define VERSION_STRING "V0.9"
+#define VERSION_STRING "V1.0"

 // Number of readings before a battery reading is taken
 #define BATTERY_READ_INTERVAL 10
+
+// Polling interval values
+#define FIFTEENMINS 0
+#define TENMINS 1
+#define FIVEMINS 2
+#define TWENTYSEC 3

 // Hardware pin defines
 // Enable SRF
@@ -58,36 +64,60 @@
 uint8_t inPin[] = { 9, 10, 11, 12, 13 };

 int batteryCountDown = BATTERY_READ_INTERVAL;
+int pollingInterval = FIFTEENMINS;

 uint8_t enterCommandMode();
-// Node ID, default R0, set by input pins
+// Node ID, default 00, set by input pins
 // Stricly speaking this should only be digits, according to the Ciseco LLAP spec.
-char nodeId[2] = { 'R', '1' };
-
-// Some functions to get the configured node address
-void readNodeId() {
+char nodeId[2] = { '0', '0' };
+
+// Some functions to get the configured node address and polling
+void readJumpers() {
   // Set analog input pins to read digital values, set internal pullup
+  // ugly - refactor in loop.
   pinMode(A0, INPUT);
   pinMode(A1, INPUT);
   pinMode(A2, INPUT);
   pinMode(A3, INPUT);
   pinMode(A4, INPUT);
   pinMode(A5, INPUT);
+  pinMode(9,INPUT);
+  pinMode(10,INPUT);
+  pinMode(12,INPUT);
+  pinMode(13,INPUT);
   digitalWrite(A0, HIGH);
   digitalWrite(A1, HIGH);
   digitalWrite(A2, HIGH);
   digitalWrite(A3, HIGH);
   digitalWrite(A4, HIGH);
   digitalWrite(A5, HIGH);
+  digitalWrite(9, HIGH);
+  digitalWrite(10, HIGH);
+  digitalWrite(12, HIGH);
+  digitalWrite(13, HIGH);

   // Read input and parse value
-  //
+  int digit2 = ((PINB & 0x30) >> 4) | ((PINC & 0x03) << 2);
+  digit2 ^= 0x0f;
+  int digit1 = (PINC & 0x3c) >> 2;
+  digit1 ^= 0x0f;
+  nodeId[0] = '0' + min(digit1,9);
+  nodeId[1] = '0' + min(digit2,9);
+  pollingInterval = ((PINB & 0x06) >> 1) ^ 0x03;
+
+  Serial.println(PINB,HEX);
+  Serial.println(PINC,HEX);
+
+  Serial.println(pollingInterval,DEC);
+
+  Serial.println(digit1,DEC);
+  Serial.println(digit2,DEC);
+  // A0, A1 are first part, R, S, T, W
+  // A2 - A5 are 0-9, A-F
+/*
   int a = PINC & 0x3F;
   a ^= 0x3F;
-
-  // A0, A1 are first part, R, S, T, W
-  // A2 - A5 are 0-9, A-F
-    int id1 = a & 0x03;
+  int id1 = a & 0x03;
   switch( id1 ) {
     case 0: nodeId[0] = 'R'; break;
     case 1: nodeId[0] = 'S'; break;
@@ -99,6 +129,7 @@
     nodeId[1] = '0' + id2;
   else
     nodeId[1] = 'A' + (id2-10);
+*/

   // Reset analog inputs to set internal pullup off
   digitalWrite(A0, LOW);
@@ -107,6 +138,10 @@
   digitalWrite(A3, LOW);
   digitalWrite(A4, LOW);
   digitalWrite(A5, LOW);
+  digitalWrite(9, LOW);
+  digitalWrite(10, LOW);
+  digitalWrite(12, LOW);
+  digitalWrite(13, LOW);
 }

 // **************************************
@@ -244,10 +279,26 @@
     if (!enterCommandMode()) return 1;
   }
   // Use D9 & D10 links to determine polling interval
-  // TODO
+  // Select polling interval based on jumpers
+  switch( pollingInterval ) {
+    case TWENTYSEC:
+      if (!sendCommand("ATSD4E20")) return 2;	// 20 seconds
+      break;
+ //   case ONEMIN:
+ //     if (!sendCommand("ATSDEA60")) return 2;	// 1 Minute
+ //     break;
+    case FIVEMINS:
+      if (!sendCommand("ATSD493E0")) return 2;	// 5 minutes
+      break;
+    case TENMINS:
+      if (!sendCommand("ATSD927C0")) return 2;	// 10 minutes
+      break;
+    default:
+      if (!sendCommand("ATSDDBBA0")) return 2;	// 15 minutes
+  }
   //if (!sendCommand("ATSDDBBA0")) return 2;	// 15 minutes
   //if (!sendCommand("ATSD927C0")) return 2;	// 10 minutes
-  if (!sendCommand("ATSD493E0")) return 2;	// 5 minutes
+  //if (!sendCommand("ATSD493E0")) return 2;	// 5 minutes
   //if (!sendCommand("ATSD4E20")) return 2;	// 20 seconds
   //if (!sendCommand("ATSD1388")) return 2;	// 5 seconds
   //if (!sendCommand("ATSD3E8")) return 2;	// 1 seconds
@@ -296,7 +347,7 @@
   // initialise serial:
   Serial.begin(115200);
   // Get device ID
-  readNodeId();
+  readJumpers();
   // Initialise the LLAPSerial library
   LLAP.init( nodeId );
   analogReference(DEFAULT);


Update SW01_Pressure_Measurement.ino

Update SW01_Pressure_Measurement.ino

--- examples/SW01_Pressure_Measurement/SW01_Pressure_Measurement.ino
+++ examples/SW01_Pressure_Measurement/SW01_Pressure_Measurement.ino
@@ -45,7 +45,7 @@
 }

 void loop(){
-	// Create a variable to store the data read from SW03
+	// Create a variable to store the data read from SW01
 	float pressure;
 	pressure = 0;


Working array for led states

Working array for led states

--- bolt-arduino.ino
+++ bolt-arduino.ino
@@ -1,18 +1,22 @@
-const int P_LED_VCC = 5;
-const int P_LED_DATA = 8;
-const int P_LED_CLOCK = 12;
-const int P_LED_LATCH = 13;
+//CONSTANTS
+const uint8_t P_LED_VCC = 5;
+const uint8_t P_LED_DATA = 8;
+const uint8_t P_LED_CLOCK = 12;
+const uint8_t P_LED_LATCH = 13;

 //Value to adjust for optimal output voltage
 const uint8_t LED_VCC_PWM = 105;

-//const uint8_t LED_STATE_OFF = 0;
-//const uint8_t LED_STATE_ON = 1;
+//0 is always default value
+const uint8_t LED_STATE_OFF = 0;
+const uint8_t LED_STATE_ON = 1;

+const uint8_t NUMBER_OF_BITS = 8;

-byte val = B01000000;
+//PROCEDURE

-//byte states[8];
+//Array keeping track of states
+uint8_t states[NUMBER_OF_BITS];

 void setup() {
   Serial.begin(115200);
@@ -23,28 +27,29 @@
   pinMode(P_LED_CLOCK, OUTPUT);
   pinMode(P_LED_LATCH, OUTPUT);

-  shiftOut();
-  delay(5000);
-
-  val = B11111111;
+  states[1] = LED_STATE_ON;
+  states[4] = LED_STATE_ON;
+  states[5] = LED_STATE_ON;
   shiftOut();
 }

 void loop() {}

-
 void shiftOut() {
-  //Latch Low vcc high
+  //Latch Low. VCC high
   digitalWrite(P_LED_VCC, HIGH);
   digitalWrite(P_LED_LATCH, LOW);
-
+

   //Shift out
-  for (uint8_t i = 0; i < 8; i++)  {
-    if (!!(val & (1 << i))) {
-      digitalWrite(P_LED_DATA, HIGH);
-    } else {
-      digitalWrite(P_LED_DATA, LOW);
+  for (uint8_t i = NUMBER_OF_BITS; i <= NUMBER_OF_BITS; i--)  {
+    switch (states[i]) {
+      case LED_STATE_OFF:
+        digitalWrite(P_LED_DATA, LOW);
+        break;
+      case LED_STATE_ON:
+        digitalWrite(P_LED_DATA, HIGH);
+        break;
     }

@@ -52,38 +57,11 @@
     digitalWrite(P_LED_CLOCK, LOW);
   }

-  //If data is left on high drop to low, so that the final voltage is not altered
+  //If data is left on high drop to low, so that the final output voltage is not altered
   digitalWrite(P_LED_DATA, LOW);

-  //Latch high, vcc adjust
+  //Latch high. VCC adjust to two volts
   digitalWrite(P_LED_LATCH, HIGH);
   analogWrite(P_LED_VCC, LED_VCC_PWM);
-
-
-  /*analogWrite(P_LED_CLOCK, LOW);
-
-    //Loop for every byte
-    for (uint8_t i = 0; i < 8; i++)  {
-    Serial.println("Index : " + String(i) + ". State : OFF " + String(!!(val & (1 << i))));
-    digitalWrite(P_LED_DATA, !!(val & (1 << i)));
-    //Write byte
-
-    switch (states[i]) {
-      case LED_STATE_OFF:
-        Serial.println("Index : " + String(i) + ". State : OFF " + String(states[i]));
-        analogWrite(P_LED_DATA, LOW);
-        break;
-      case LED_STATE_ON:
-        Serial.println("Index : " + String(i) + ". State : ON " + String(states[i]));
-        analogWrite(P_LED_DATA, LED_TWO_VOLTS);
-        break;
-    }
-
-
-    //Clock
-    analogWrite(P_LED_CLOCK, HIGH);
-    analogWrite(P_LED_CLOCK, LOW);
-    }
-  */
 }


minimized sites handler

minimized sites handler

--- src/AFE-Sites-Handlers.ino
+++ src/AFE-Sites-Handlers.ino
@@ -7,77 +7,12 @@
 	#include "WProgram.h"
 #endif

-#include <AFE-Configuration-Panel.h>
 #include <Streaming.h>

+void handleFavicon() {}

-void handleFavicon() {
-}
-
-void handleRoot() {
-    AFEConfigurationPanel ConfigurationPanel;
-		if (WebServer.getUrlCommand()==SERVER_CMD_SAVE) {
-			Serial << endl << "INFO: Saveing";
-		}
-    String site = ConfigurationPanel.getDeviceConfigurationSite();
-		WebServer.publishHTML(site);
-}
-
-void handleNotFound() {
-	  String site = "404 Page Not Found";
-		WebServer.publishHTML(site);
-}
-
-void handleMQTTConfiguration() {
-	AFEConfigurationPanel ConfigurationPanel;
-	String site = ConfigurationPanel.getMQTTConfigurationSite();
-	WebServer.publishHTML(site);
-}
-
-void handleRelayConfiguration() {
-	AFEConfigurationPanel ConfigurationPanel;
-	String site = ConfigurationPanel.getRelayConfigurationSite();
-	WebServer.publishHTML(site);
-}
-
-void handleDS18B20Configuration() {
-	AFEConfigurationPanel ConfigurationPanel;
-	String site = ConfigurationPanel.getDS18B20ConfigurationSite();
-	WebServer.publishHTML(site);
-}
-
-void handleSwitchConfiguration() {
-	AFEConfigurationPanel ConfigurationPanel;
-	String site = ConfigurationPanel.getSwitchConfigurationSite();
-	WebServer.publishHTML(site);
-}
-
-void handleDomoticzConfiguration() {
-	AFEConfigurationPanel ConfigurationPanel;
-	String site = ConfigurationPanel.getDomoticzConfigurationSite();
-	WebServer.publishHTML(site);
-}
-
-void handleUpdateConfiguration() {
-	AFEConfigurationPanel ConfigurationPanel;
-	String site = ConfigurationPanel.getUpdateConfigurationSite();
-	WebServer.publishHTML(site);
-}
-
-void handleResetConfiguration() {
-	AFEConfigurationPanel ConfigurationPanel;
-	String site = ConfigurationPanel.getResetConfigurationSite();
-	WebServer.publishHTML(site);
-}
-
-void handleExitConfiguration() {
-	AFEConfigurationPanel ConfigurationPanel;
-	String site = ConfigurationPanel.getExitConfigurationSite();
-	WebServer.publishHTML(site);
-}
-
-void handleSave() {
-
+void handleHTTPRequests() {
+	 WebServer.generate();
 }

 #endif


First LED output is done

First LED output is done

--- digit4/digit4.ino
+++ digit4/digit4.ino
@@ -11,6 +11,170 @@
 const int SEGMENT_F_PIN = 7;
 const int SEGMENT_G_PIN = 13;

+const byte DIGIT_OFF = 255;
+const byte DIGIT_ON = 10; // increase the value to reduce current
+
+const short MINUS = -1;
+const short DEGREE = -2;
+
+int currentDigitIndex = 0;
+short digits[4];
+
+void activateDigit(int digit) {
+  switch (digit) {
+    case 0:
+      analogWrite(DIGIT_1_PIN, DIGIT_ON);
+      analogWrite(DIGIT_2_PIN, DIGIT_OFF);
+      analogWrite(DIGIT_3_PIN, DIGIT_OFF);
+      analogWrite(DIGIT_4_PIN, DIGIT_OFF);
+      break;
+    case 1:
+      analogWrite(DIGIT_1_PIN, DIGIT_OFF);
+      analogWrite(DIGIT_2_PIN, DIGIT_ON);
+      analogWrite(DIGIT_3_PIN, DIGIT_OFF);
+      analogWrite(DIGIT_4_PIN, DIGIT_OFF);
+      break;
+    case 2:
+      analogWrite(DIGIT_1_PIN, DIGIT_OFF);
+      analogWrite(DIGIT_2_PIN, DIGIT_OFF);
+      analogWrite(DIGIT_3_PIN, DIGIT_ON);
+      analogWrite(DIGIT_4_PIN, DIGIT_OFF);
+      break;
+    case 3:
+      analogWrite(DIGIT_1_PIN, DIGIT_OFF);
+      analogWrite(DIGIT_2_PIN, DIGIT_OFF);
+      analogWrite(DIGIT_3_PIN, DIGIT_OFF);
+      analogWrite(DIGIT_4_PIN, DIGIT_ON);
+      break;
+    default:
+      analogWrite(DIGIT_1_PIN, DIGIT_OFF);
+      analogWrite(DIGIT_2_PIN, DIGIT_OFF);
+      analogWrite(DIGIT_3_PIN, DIGIT_OFF);
+      analogWrite(DIGIT_4_PIN, DIGIT_OFF);
+  }
+}
+
+void drawDigit(short value) {
+  switch (value) {
+    case DEGREE:
+      digitalWrite(SEGMENT_A_PIN, HIGH);
+      digitalWrite(SEGMENT_B_PIN, HIGH);
+      digitalWrite(SEGMENT_C_PIN, LOW);
+      digitalWrite(SEGMENT_D_PIN, LOW);
+      digitalWrite(SEGMENT_E_PIN, LOW);
+      digitalWrite(SEGMENT_F_PIN, HIGH);
+      digitalWrite(SEGMENT_G_PIN, HIGH);
+      break;
+    case MINUS:
+      digitalWrite(SEGMENT_A_PIN, LOW);
+      digitalWrite(SEGMENT_B_PIN, LOW);
+      digitalWrite(SEGMENT_C_PIN, LOW);
+      digitalWrite(SEGMENT_D_PIN, LOW);
+      digitalWrite(SEGMENT_E_PIN, LOW);
+      digitalWrite(SEGMENT_F_PIN, LOW);
+      digitalWrite(SEGMENT_G_PIN, HIGH);
+      break;
+    case 0:
+      digitalWrite(SEGMENT_A_PIN, HIGH);
+      digitalWrite(SEGMENT_B_PIN, HIGH);
+      digitalWrite(SEGMENT_C_PIN, HIGH);
+      digitalWrite(SEGMENT_D_PIN, HIGH);
+      digitalWrite(SEGMENT_E_PIN, HIGH);
+      digitalWrite(SEGMENT_F_PIN, HIGH);
+      digitalWrite(SEGMENT_G_PIN, LOW);
+      break;
+    case 1:
+      digitalWrite(SEGMENT_A_PIN, LOW);
+      digitalWrite(SEGMENT_B_PIN, HIGH);
+      digitalWrite(SEGMENT_C_PIN, HIGH);
+      digitalWrite(SEGMENT_D_PIN, LOW);
+      digitalWrite(SEGMENT_E_PIN, LOW);
+      digitalWrite(SEGMENT_F_PIN, LOW);
+      digitalWrite(SEGMENT_G_PIN, LOW);
+      break;
+    case 2:
+      digitalWrite(SEGMENT_A_PIN, HIGH);
+      digitalWrite(SEGMENT_B_PIN, HIGH);
+      digitalWrite(SEGMENT_C_PIN, LOW);
+      digitalWrite(SEGMENT_D_PIN, HIGH);
+      digitalWrite(SEGMENT_E_PIN, HIGH);
+      digitalWrite(SEGMENT_F_PIN, LOW);
+      digitalWrite(SEGMENT_G_PIN, HIGH);
+      break;
+    case 3:
+      digitalWrite(SEGMENT_A_PIN, HIGH);
+      digitalWrite(SEGMENT_B_PIN, HIGH);
+      digitalWrite(SEGMENT_C_PIN, HIGH);
+      digitalWrite(SEGMENT_D_PIN, HIGH);
+      digitalWrite(SEGMENT_E_PIN, LOW);
+      digitalWrite(SEGMENT_F_PIN, LOW);
+      digitalWrite(SEGMENT_G_PIN, HIGH);
+      break;
+    case 4:
+      digitalWrite(SEGMENT_A_PIN, LOW);
+      digitalWrite(SEGMENT_B_PIN, HIGH);
+      digitalWrite(SEGMENT_C_PIN, HIGH);
+      digitalWrite(SEGMENT_D_PIN, LOW);
+      digitalWrite(SEGMENT_E_PIN, LOW);
+      digitalWrite(SEGMENT_F_PIN, HIGH);
+      digitalWrite(SEGMENT_G_PIN, HIGH);
+      break;
+    case 5:
+      digitalWrite(SEGMENT_A_PIN, HIGH);
+      digitalWrite(SEGMENT_B_PIN, LOW);
+      digitalWrite(SEGMENT_C_PIN, HIGH);
+      digitalWrite(SEGMENT_D_PIN, HIGH);
+      digitalWrite(SEGMENT_E_PIN, LOW);
+      digitalWrite(SEGMENT_F_PIN, HIGH);
+      digitalWrite(SEGMENT_G_PIN, HIGH);
+      break;
+    case 6:
+      digitalWrite(SEGMENT_A_PIN, HIGH);
+      digitalWrite(SEGMENT_B_PIN, LOW);
+      digitalWrite(SEGMENT_C_PIN, HIGH);
+      digitalWrite(SEGMENT_D_PIN, HIGH);
+      digitalWrite(SEGMENT_E_PIN, HIGH);
+      digitalWrite(SEGMENT_F_PIN, HIGH);
+      digitalWrite(SEGMENT_G_PIN, HIGH);
+      break;
+    case 7:
+      digitalWrite(SEGMENT_A_PIN, HIGH);
+      digitalWrite(SEGMENT_B_PIN, HIGH);
+      digitalWrite(SEGMENT_C_PIN, HIGH);
+      digitalWrite(SEGMENT_D_PIN, LOW);
+      digitalWrite(SEGMENT_E_PIN, LOW);
+      digitalWrite(SEGMENT_F_PIN, LOW);
+      digitalWrite(SEGMENT_G_PIN, LOW);
+      break;
+    case 8:
+      digitalWrite(SEGMENT_A_PIN, HIGH);
+      digitalWrite(SEGMENT_B_PIN, HIGH);
+      digitalWrite(SEGMENT_C_PIN, HIGH);
+      digitalWrite(SEGMENT_D_PIN, HIGH);
+      digitalWrite(SEGMENT_E_PIN, HIGH);
+      digitalWrite(SEGMENT_F_PIN, HIGH);
+      digitalWrite(SEGMENT_G_PIN, HIGH);
+      break;
+    case 9:
+      digitalWrite(SEGMENT_A_PIN, HIGH);
+      digitalWrite(SEGMENT_B_PIN, HIGH);
+      digitalWrite(SEGMENT_C_PIN, HIGH);
+      digitalWrite(SEGMENT_D_PIN, HIGH);
+      digitalWrite(SEGMENT_E_PIN, LOW);
+      digitalWrite(SEGMENT_F_PIN, HIGH);
+      digitalWrite(SEGMENT_G_PIN, HIGH);
+      break;
+    default:
+      digitalWrite(SEGMENT_A_PIN, LOW);
+      digitalWrite(SEGMENT_B_PIN, LOW);
+      digitalWrite(SEGMENT_C_PIN, LOW);
+      digitalWrite(SEGMENT_D_PIN, LOW);
+      digitalWrite(SEGMENT_E_PIN, LOW);
+      digitalWrite(SEGMENT_F_PIN, LOW);
+      digitalWrite(SEGMENT_G_PIN, LOW);
+  }
+}
+
 void setup() {
   pinMode(DIGIT_1_PIN, OUTPUT);
   pinMode(DIGIT_2_PIN, OUTPUT);
@@ -25,10 +189,10 @@
   pinMode(SEGMENT_F_PIN, OUTPUT);
   pinMode(SEGMENT_G_PIN, OUTPUT);

-  digitalWrite(DIGIT_1_PIN, HIGH);
-  digitalWrite(DIGIT_2_PIN, HIGH);
-  digitalWrite(DIGIT_3_PIN, HIGH);
-  digitalWrite(DIGIT_4_PIN, LOW);
+  analogWrite(DIGIT_1_PIN, DIGIT_OFF);
+  analogWrite(DIGIT_2_PIN, DIGIT_OFF);
+  analogWrite(DIGIT_3_PIN, DIGIT_OFF);
+  analogWrite(DIGIT_4_PIN, DIGIT_OFF);
   digitalWrite(SEGMENT_A_PIN, HIGH);
   digitalWrite(SEGMENT_B_PIN, HIGH);
   digitalWrite(SEGMENT_C_PIN, HIGH);
@@ -36,9 +200,19 @@
   digitalWrite(SEGMENT_E_PIN, HIGH);
   digitalWrite(SEGMENT_F_PIN, HIGH);
   digitalWrite(SEGMENT_G_PIN, HIGH);
+
+  digits[0] = MINUS;
+  digits[1] = 2;
+  digits[2] = 3;
+  digits[3] = DEGREE;
 }

 void loop() {
-  // put your main code here, to run repeatedly:
-
-}
+  activateDigit(currentDigitIndex);
+  drawDigit(digits[currentDigitIndex]);
+
+  currentDigitIndex++;
+  if (currentDigitIndex >= 4) currentDigitIndex = 0;
+
+  delayMicroseconds(500);
+}


Can't get STL port for AVR working...

Can't get STL port for AVR working...

--- Synthduino.ino
+++ Synthduino.ino
@@ -1,8 +1,5 @@
 #include "note.h"
 #include "pitches.h"
-//#include <pnew.cpp>
-#include <iterator>
-#include <vector>

 #define BASS 12


Changes magic ints to named variables

Changes magic ints to named variables

--- rfduino/Device0/Device0.ino
+++ rfduino/Device0/Device0.ino
@@ -2,6 +2,13 @@
 #include "OneButton.h"

 device_t role = DEVICE0;
+
+int BUTTON_A_SINGLE = 0;
+int BUTTON_B_SINGLE = 1;
+int BUTTON_A_DOUBLE = 2;
+int BUTTON_B_DOUBLE = 3;
+int BUTTON_A_LONG = 4;
+int BUTTON_B_LONG = 5;

 int gzllTimeout = 10000;

@@ -33,37 +40,37 @@

 void onClickA()
 {
-  sendToHost(0);
+  sendToHost(BUTTON_A_SINGLE);
   resetAndSleep();
 }

 void onClickB()
 {
-  sendToHost(1);
+  sendToHost(BUTTON_B_SINGLE);
   resetAndSleep();
 }

 void onDoubleClickA()
 {
-  sendToHost(2);
+  sendToHost(BUTTON_A_DOUBLE);
   resetAndSleep();
 }

 void onDoubleClickB()
 {
-  sendToHost(3);
+  sendToHost(BUTTON_B_DOUBLE);
   resetAndSleep();
 }

 void onLongPressA()
 {
-  sendToHost(4);
+  sendToHost(BUTTON_A_LONG);
   resetAndSleep();
 }

 void onLongPressB()
 {
-  sendToHost(5);
+  sendToHost(BUTTON_B_LONG);
   resetAndSleep();
 }

@@ -94,7 +101,7 @@
 {
   if(gzllRunning){
     RFduinoGZLL.end();
-    gzllRunning = false;
+    gzllRunning = false;
   }
 }

@@ -110,9 +117,9 @@
   if(gzllLastCommandTime != 0 && (millis() - gzllLastCommandTime) > gzllTimeout){
     stopGzll();
   }
-
+
   tick();
-
+
   if (shouldSleep) {
       // Hvis GZLL-stacken er paa, sov til timeout og sjekk s p nytt om stacken kan slaas av.
       if(gzllRunning) {
@@ -123,8 +130,8 @@
         RFduino_ULPDelay(INFINITE);
       }
   }
-
-  delay(10); // Kan ikke kalle tick for ofte...
+
+  delay(10); // Kan ikke kalle tick for ofte...
 }

 void RFduinoGZLL_onReceive(device_t device, int rssi, char *data, int len)


Fix bug that caused canbus setting to fail over binary link.

--- GVRET.ino
+++ GVRET.ino
@@ -490,7 +490,7 @@
 	static byte buff[20];
 	static int step = 0;
 	static STATE state = IDLE;
-	static int build_int;
+	static uint32_t build_int;
 	uint8_t temp8;
 	uint16_t temp16;
 	static bool markToggle = false;