reset WheelwriterControlNano.ino to original

--- software/WheelwriterControlNano/WheelwriterControlNano.ino
+++ software/WheelwriterControlNano/WheelwriterControlNano.ino
@@ -69,7 +69,6 @@
 void loop()
 {
       static int charCount = 0;
-      static int microspaceCount = 0;
       char buffer[70]; // 64 plus a few extra for some run-over commands (e.g., reverse)
       uint8_t readLength = 65;
       uint8_t bytesRead = 0;
@@ -95,15 +94,13 @@
           //Serial.println(bytesRead);
           //Serial.println(" bytes.");
           char command = buffer[0];
-          Serial.println(int(command));
+          //Serial.println(int(command));

           if (command == 0) { // text to print
             // look for next two bytesp
-            Serial.readBytes(buffer,3);
+            Serial.readBytes(buffer,2);
             bytesToPrint = buffer[0] + (buffer[1] << 8); // little-endian
-            int spacing = buffer[2];
-            microspaceCount += bytesToPrint * spacing / 2;
-            charCount = printAllChars(buffer,bytesToPrint,charCount, spacing);
+            charCount = printAllChars(buffer,bytesToPrint,charCount);
           }
           else if (command == 1) { // image to print
             //Serial.println("image");
@@ -128,14 +125,6 @@
           } else if (command == 7) {
             beepTypewriter();
             Serial.println("ok");
-          } else if (command == '\n') {
-                // read the number of spaces
-                Serial.readBytes(buffer,2);
-                int microspacesToPrint = buffer[0] + (buffer[1] << 8); // little-endian
-                //Serial.println("newline");
-                //Serial.println(microspacesToPrint);
-                send_return_microspaces(microspacesToPrint / 2);
-                microspaceCount = 0;
           }
           else {
             charCount = printOne(command,charCount);
@@ -223,7 +212,7 @@
     else if (charToPrint == 128 or charToPrint == 129) {
         paper_vert((charToPrint == 128 ? 0 : 1),8); // full line up/down
     }
-    else if (charToPrint == 133) { // micro-down, ctrl-d is 4
+    else if (charToPrint == 4) { // micro-down, ctrl-d is 4
         paper_vert(1,1);
     }
     else if (charToPrint == 21) { // micro-up, ctrl-u is 21
@@ -250,9 +239,7 @@
     }
     else {
         //Serial.println("about to print");
-        //send_letter(asciiTrans[charToPrint]);
-        send_letter_without_space(asciiTrans[charToPrint]);
-
+        send_letter(asciiTrans[charToPrint]);
         charCount++;
     }

@@ -267,7 +254,7 @@

 int printAllChars(char buffer[],
                   uint16_t bytesToPrint,
-                  int charCount, int spacing) {
+                  int charCount) {
     uint8_t readLength = 65;
     bool fastPrinting = false;
     uint16_t bytesPrinted = 0;
@@ -334,8 +321,7 @@
                     fastTextInit();
                     fastPrinting = true;
                 }
-                fastTextChars(buffer + bufferPos, 1, spacing);
-
+                fastTextChars(buffer + bufferPos, 1);
                 if (reverseText) {
                     charCount--;
                     if (charCount < 0) {
@@ -609,35 +595,6 @@
     //delay(LETTER_DELAY); // before next character
 }

-void send_letter_without_space(int letter) {
-    sendByte(0b100100001);
-    sendByte(0b000001011);
-    sendByte(0b100100001);
-    sendByte(0b000000011);
-    sendByte(letter);
-    if (underline) {
-      sendByte(0b000000000); // no space
-      sendByte(0b100100001);
-      sendByte(0b000001011);
-      sendByte(0b100100001);
-      sendByte(0b000000011);
-      sendByte(asciiTrans['_']);
-    }
-    if (bold) {
-      sendByte(0b000000001); // one microspace
-      sendByte(0b100100001);
-      sendByte(0b000001011);
-      sendByte(0b100100001);
-      sendByte(0b000000011);
-      sendByte(letter);
-      sendByte(0b000001001);
-    } else {
-      // not bold
-      sendByte(0b000000000); // spacing for one character
-    }
-    //delay(LETTER_DELAY); // before next character
-}
-
 void letterNoSpace(int letter) {
     sendByte(0b100100001);
     sendByte(0b000001011);
@@ -769,60 +726,6 @@
     //delay(CARRIAGE_WAIT_BASE + CARRIAGE_WAIT_MULTIPLIER * numChars);
 }

-void send_return_microspaces(int numSpaces) {
-    // calculations for further down
-    int byte1 = (numSpaces) >> 7;
-    int byte2 = ((numSpaces) & 0x7f) << 1;
-
-    sendByte(0b100100001);
-    sendByte(0b000001011);
-    sendByte(0b100100001);
-    sendByte(0b000001101);
-    sendByte(0b000000111);
-    sendByte(0b100100001);
-
-    /*if (numChars <= 23 || numChars >= 26) {*/
-        sendByte(0b000000110);
-
-        // We will send two bytes from a 10-bit number
-        // which is numChars * 5. The top three bits
-        // of the 10-bit number comprise the first byte,
-        // and the remaining 7 bits comprise the second
-        // byte, although the byte needs to be shifted
-        // left by one (not sure why)
-        // the numbers are calculated above for timing reasons
-        sendByte(byte1);
-        sendByte(byte2); // each char is worth 10
-        sendByte(0b100100001);
-        // right now, the platten is moving, maybe?
-
-    /*} else if (numChars <= 25) {
-        // not sure why this is so different
-        sendByte(0b000001101);
-        sendByte(0b000000111);
-        sendByte(0b100100001);
-        sendByte(0b000000110);
-        sendByte(0b000000000);
-        sendByte(numChars * 10);
-        sendByte(0b100100001);
-        // right now, the platten is moving, maybe?
-    }*/
-
-    sendByte(0b000000101);
-    sendByte(0b010010000);
-
-    /*
-    sendByte(0b100100001);
-
-
-    // send one more byte but don't wait explicitly for the response
-    // of 0b001010000
-    sendByteOnPin(0b000001011);*/
-
-    // wait for carriage
-    //delay(CARRIAGE_WAIT_BASE + CARRIAGE_WAIT_MULTIPLIER * numChars);
-}
-
 void correct_letter(int letter) {
     sendByte(0b100100001);
     sendByte(0b000001011);
@@ -936,7 +839,7 @@
     sendByte(0b010000000);
     sendByte(0b000000000);
 }
-void fastTextChars(char *s, int length, int spacing) {
+void fastTextChars(char *s, int length) {
     // letters start here
     for (int i=0; i < length; i++) {
         sendByte(0b100100001);
@@ -967,8 +870,7 @@
                 micro_backspace(0b1010); // full space back
             } else {
             // full space
-            //sendByte(0b000001010);
-            sendByte(spacing);
+            sendByte(0b000001010);
             }
         }
     }
@@ -1048,3 +950,4 @@
   */
 }

+


correction bug lecture capteur pression plaque chauffante. On fait différence des valeurs lues maintenant

--- arduino/plaques_de_cuisson_captors/plaques_de_cuisson_captors.ino
+++ arduino/plaques_de_cuisson_captors/plaques_de_cuisson_captors.ino
@@ -18,7 +18,8 @@

 /* Capteur de pression */
 const int panPin = A0;
-int panValue;
+int old_panValue = 200;
+int panValue = 200;
 bool isWeighted = false;

 /* Dernier état envoyé */
@@ -65,13 +66,16 @@
   }

   /* Weight */
-  panValue = analogRead(panPin);
-  /*Serial.print("poids : ");
-  Serial.println(panValue);*/
-  if(panValue > 0) {
+  old_panValue = panValue;
+  panValue = analogRead(panPin);
+  /*Serial.print("poids : ");*/
+  Serial.println(panValue);
+  if(panValue - old_panValue > 20) {
+    Serial.println("casserole sur le feu");
     isWeighted = true;
-  } else {
+  } else if (old_panValue - panValue > 20) {
     isWeighted = false;
+    Serial.println("casserole retiré");
   }

   /* Send information */


tested 1 mili period 	modified:   PWM_generation_expriment/PWM_generation_expriment.ino

--- PWM_generation_expriment/PWM_generation_expriment.ino
+++ PWM_generation_expriment/PWM_generation_expriment.ino
@@ -7,15 +7,20 @@

 void generate(unsigned pin, unsigned period, unsigned duty);

-void loop() {
-  generate(pwm,100,80);
+
+void loop()
+{
+  generate(pwm,1000,250);
 }
+
+
 void generate(unsigned pin, unsigned period, unsigned duty)
 {
   digitalWrite(pin, HIGH);
-  delay(duty);
+  //delay(duty);
+   delayMicroseconds(duty);

   digitalWrite(pin, LOW);
-  delay(period - duty);
+   delayMicroseconds(period - duty);
 }


Added PQ command

Added PQ command

to make use of Rob’s printCommandQ() function

--- software/firmware/LogoBotWifiScribbler/LogoBotWifiScribbler.ino
+++ software/firmware/LogoBotWifiScribbler/LogoBotWifiScribbler.ino
@@ -357,6 +357,8 @@
     writeText("LOGOBOT");
   } else if (c.startsWith("WT")) {
     writeText(c.substring(3));
+  } else if (c.startsWith("PQ")) {
+    printCommandQ();
   }
 }

@@ -991,4 +993,3 @@
 long sqr(long v) {
   return v*v;
 }
-


Update _02-mqtt-sw.ino

Update _02-mqtt-sw.ino

--- _02-mqtt-sw/_02-mqtt-sw.ino
+++ _02-mqtt-sw/_02-mqtt-sw.ino
@@ -112,12 +112,10 @@
   Serial.println(ssid);

   WiFi.mode(WIFI_STA);
+  WiFi.begin(ssid, password);

   #ifdef __IS_MY_HOME
-  WiFi.begin(ssid, password, channel, bssid);
   WiFi.config(IPAddress(192, 168, 10, 11), IPAddress(192, 168, 10, 1), IPAddress(255, 255, 255, 0));
-  #else
-  WiFi.begin(ssid, password);
   #endif


added 10ms delay

added 10ms delay

--- Teensy/Teensy.ino
+++ Teensy/Teensy.ino
@@ -35,7 +35,6 @@
 void serCommand(){
   LCD.write(0xFE);
 }
-

 float getLoad(int iters) {
   if (iters == 0) {
@@ -103,7 +102,9 @@
     }
   }

+
   Serial.print(millis());
   Serial.print(",");
   Serial.println(getLoad(0));
+  delay(10);
 }


Added timer feature.

Added timer feature.

--- BackEnd/BackEnd.ino
+++ BackEnd/BackEnd.ino
@@ -907,7 +907,10 @@

   // Run timer when a timer_on command has been received and a positive edge is detected
   if( g_aPins[_iOutPinNum].is_timer_on && g_aPins[_iOutPinNum].prev_value < DIGITAL_VOLTAGE_THRESHOLD && g_aPins[_iOutPinNum].value >= DIGITAL_VOLTAGE_THRESHOLD )
+  {
     g_aPins[_iOutPinNum].timer_running = true;
+    g_aPins[_iOutPinNum].timer_start_time = millis();
+  }

   // IF timer_is_on && Timer_Running
     // IF timer expired
@@ -929,6 +932,7 @@
     else // Timer expired
     {
       g_aPins[_iOutPinNum].timer_running = false;
+//      g_aPins[_iOutPinNum].timer_start_time = millis();
     }
   }

@@ -1421,8 +1425,10 @@
       if (poIsTimerOn)
       {
         g_aPins[i].is_timer_on = poIsTimerOn->valuebool;
+        /*
         if(g_aPins[i].is_timer_on)
           g_aPins[i].timer_start_time = millis();
+          */
       }

       aJsonObject *poTimerValue = aJson.getObjectItem(poPinVals, "timer_value");
@@ -1729,7 +1735,7 @@

   // Initialize HW and JSON protocol code
   //Serial.println("Initilize Hardware");
-//  initBoardState(); // Assure a state
+  initBoardState(); // Assure a state
   initBoardStateFromFile(BOARD_CONFIG_FILE_FULL_PATH); // Replace the state with the file, if available
   //delay(1000);


Recovering work lost when machine crashed.  Now it actaully makes noise.

--- switchbox.ino
+++ switchbox.ino
@@ -30,6 +30,8 @@

 boolean sw1_on = false;
 boolean sw2_on = false;
+
+uint16_t btn_tones[16];

 uint32_t Wheel(byte WheelPos) {
   WheelPos = 255 - WheelPos;
@@ -67,9 +69,6 @@
 uint16_t wipe_animation_delay = 25;
 uint16_t chase_animation_delay = 50;
 uint16_t rainbow_wheel_speed = 1;
-
-
-
 uint16_t red_blink_interval, grn_blink_interval, blu_blink_interval, blink_counter;

 void animation_init() {
@@ -201,6 +200,7 @@
     if ( ! *btn_dwn ) {
       btn_debounce_timer = millis();
       *btn_dwn = true;
+      tone(SPKR_PIN, btn_tones[btn_pin], 250);
       // write new random seed based on timing and current random number
       // randomSeed(random(1024)^(btn_debounce_timer&1023));
       return true;
@@ -209,6 +209,9 @@
     if ( *btn_dwn ) {
       btn_debounce_timer = millis();
       *btn_dwn = false;
+      if ( btn_pin == SW1_PIN || btn_pin == SW2_PIN ) {
+        tone(SPKR_PIN, btn_tones[btn_pin], 250);
+      }
       return true;
     }
   }
@@ -224,25 +227,31 @@
   pinMode(SW1_PIN,       INPUT);
   digitalWrite(SW1_PIN,   HIGH); // turn on internal pullup resistor
   sw1_on = (digitalRead(SW1_PIN) == 0)?true:false;
-  digitalWrite(SW1_PIN,   HIGH);
+  btn_tones[SW1_PIN] = NOTE_C2;

   pinMode(SW2_PIN,       INPUT);
   digitalWrite(SW2_PIN,   HIGH); // this one too
   sw2_on = (digitalRead(SW2_PIN) == 0)?true:false;
-  digitalWrite(SW2_PIN,   HIGH); // this one too
+  btn_tones[SW2_PIN] = NOTE_E2;

   pinMode(REDBTN_OUT,   OUTPUT);
   pinMode(REDBTN_IN,     INPUT);
   digitalWrite(REDBTN_IN, HIGH); // turn on internal pullup resistor
+  btn_tones[REDBTN_IN] = NOTE_C3;
+
   pinMode(GRNBTN_OUT,   OUTPUT);
   pinMode(GRNBTN_IN,     INPUT);
   digitalWrite(GRNBTN_IN, HIGH); // turn on internal pullup resistor
+  btn_tones[GRNBTN_IN] = NOTE_D3;
+
   pinMode(BLUBTN_OUT,   OUTPUT);
   pinMode(BLUBTN_IN,     INPUT);
   digitalWrite(BLUBTN_IN, HIGH); // turn on internal pullup resistor
+  btn_tones[BLUBTN_IN] = NOTE_F3;

   pinMode(BIGBTN_IN,     INPUT);
   digitalWrite(BIGBTN_IN, HIGH); // turn on internal pullup resistor
+  btn_tones[BIGBTN_IN] = NOTE_G3;

   pinMode(SPKR_PIN,     OUTPUT);


corrigido funcaoSegura, agora gera alarme

--- EMP-B-Due.ino
+++ EMP-B-Due.ino
@@ -364,7 +364,7 @@
   if (ativo(seguranca)){
     funcaoSimples(saida, nome, inicio, fim);
   } else {
-    alarme_ativo = VERDADEIRO;
+    bloqueioPorAlarme("Sensor da Mandíbula");
   }
 }


Fixed comment formatting that was inconsistent.

Signed-off-by: Braden Licastro <79d6010d7e15bbb3aa5be04af4e1cdfb0e9c5bfd@live.com>


Manage to create dynamic reading function for software serial. However, still got problem when read from gps. It seems that every time I read from it, I just miss the beginning chars ,"$GPRMC". Thus, when I read, my function always return false. To be solved.

--- Drones/Drones.ino
+++ Drones/Drones.ino
@@ -61,6 +61,7 @@
 int motor_2_output;
 int motor_3_output;
 int motor_4_output;
+int array_length=1;//To store array_length
 bool blinkState = false;
 bool dmpReady = false;
 uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU
@@ -91,8 +92,7 @@

-void parse_gps(char buffer[60]);
-
+char* dynamic_array_Serial(SoftwareSerial*,int);
 //----------------------------Setup Code-----------------------------------------------//
 void setup() {
 	pinMode(MOTOR_1_PIN, OUTPUT);
@@ -111,28 +111,91 @@
 //----------------------------Main Loop-----------------------------------------------//
 void loop() {
   // put your main code here, to run repeatedly:
-  char gpsbuffer[60];
+  char* gpsbuffer;
 // Initialize buffer for gps data
- 	if (gpsSerial.available() > 0){
-    while (!(gpsSerial.findUntil("$GPRMC,",'*'))){
+  Serial.println("Try to communicate");
+  Serial.println(gpsSerial.available());
+ 	if (gpsSerial.available() > 0&&gpsSerial.peek()=='$'){
+   gpsbuffer=dynamic_array_Serial(gpsSerial,100);
+   Serial.println(array_length);
+   //Serial.print(gpsbuffer[0]);
+   /* while (!(gpsSerial.findUntil("$GPRMC,",'*'))){
       gpsSerial.flush();
     }
     gpsSerial.readBytesUntil("*",gpsbuffer,60);// Problem, if it is N, the function will try to find enough bytes to fill the memory it is given

     }//Cannot read Bytes, just skip this if-clause, need to be solved
     //used findUntil method to skip other info
-  for(int i;i<60;i++){
+  */
+  //How to return length???
+  for(int i;i<array_length-1;i++){
   	Serial.print(gpsbuffer[i]);

     //gpsbuffer[i]=" ";
   }
-  Serial.println();
+ 	}
+  else{
+    Serial.println("Fail to communicate!");
+  }
+
+  //Serial.println();
 //	For Testing only
-
+  array_length=1;
   delay(1000);
   gpsSerial.flush();
   free(gpsbuffer);
+  Serial.println("Flushing serial");
+
+
 }
-void parse_gps(char buffer[60]){
-
+char* dynamic_array_Serial(SoftwareSerial src,int max_length){
+  src.listen();
+  extern int array_length;
+  Serial.println("Successful");
+  //Serial.println(array_length); Testing
+  if(src.available()>0){
+    Serial.println("Checking IO buffer");
+  //Serial.println(src.peek());
+    Serial.println("Initializing buffer");
+  char*  max_array=(char*)malloc(sizeof(char)*max_length);
+  for(int i=0;i<max_length;i++){
+    max_array[i]=NULL;
+  }
+  Serial.println("Start reading");
+  while(!(src.available()>0));//Waiting for bytes to fill the IO buffer
+  while(src.available()>0){//Cant go into this loop
+    char temp=src.read();
+    delay(20);
+    if(temp!='*'){
+      max_array[array_length-1]=temp;
+      array_length++;
+      //Serial.println(max_array[array_length-1]);
+    }
+    else{
+      Serial.print("Array length: ");
+      Serial.println(array_length);
+      char* result=(char*)malloc(sizeof(char)*array_length);
+      for(int i=0;i<max_length;i++){
+        if(max_array[i]==NULL){
+          free(max_array);//free memory
+          Serial.println("End listening");
+          //Serial.println(result[0]);
+          return result;
+        }
+        else{
+          result[i]=max_array[i];
+          //Serial.print(max_array[i]);
+          //Serial.print(":");
+          //Serial.println(result[i]);
+        }
+      }
+    }
+  }
+  }
+
+
+ else{
+    return NULL;
+  }
 }
+


Fix for old libc and removal of access to private fields.

--- Scripts/serialdemo_spad.ino
+++ Scripts/serialdemo_spad.ino
@@ -45,8 +45,8 @@
 {
   messenger.sendCmdStart(kDebug);
   messenger.sendCmdArg("UNKNOWN COMMAND");
-  messenger.sendCmdArg(messenger.lastCommandId);
-  messenger.sendCmdArg(messenger.commandBuffer);
+//  messenger.sendCmdArg(messenger.lastCommandId);
+//  messenger.sendCmdArg(messenger.commandBuffer);
   messenger.sendCmdEnd();
 }

@@ -56,7 +56,7 @@
 {
   char *szRequest = messenger.readStringArg();

-  if (stricmp(szRequest, "INIT") == 0) {
+  if (strcmp(szRequest, "INIT") == 0) {
     messenger.sendCmdStart(kRequest);
     messenger.sendCmdArg("SPAD");
     // Unique Device ID
@@ -67,14 +67,14 @@
     return;
   }

-  if (stricmp(szRequest, "PING") == 0) {
+  if (strcmp(szRequest, "PING") == 0) {
     messenger.sendCmdStart(kRequest);
     messenger.sendCmdArg("PONG");
     messenger.sendCmdArg(messenger.readInt32Arg());
     messenger.sendCmdEnd();
     return;
   }
-  if (stricmp(szRequest, "CONFIG") == 0) {
+  if (strcmp(szRequest, "CONFIG") == 0) {

     // Expose LED
     messenger.sendCmdStart(kCommand);


added active steering 	modified:   GolfCart_Control_3_/GolfCart_Control_3_.ino

--- GolfCart_Control_3_/GolfCart_Control_3_.ino
+++ GolfCart_Control_3_/GolfCart_Control_3_.ino
@@ -7,16 +7,21 @@
 #define STEER_RUN 	2000
 #define STEER_LUN       1000
 #define STEER_TIME 	800
-#define STEER_UNIT      0.1 // the model# / 360
-#define STEER_INTER_1   2 //pin 21
-#define STEER_INTER_2   3 //pin 20
+#define STEER_UNIT      0.36 // the model#  360/1000
+#define STEER_INTER_1   4 //pin 21
+#define STEER_PIN_1     19
+#define STEER_INTER_2   5 //pin 20
+#define STEER_PIN_2     18
 #define STEER_INTER_G   4 //pin 19
 #define STEER_PIN	9
+#define STEER_ACTIVE    true
+#define DEGREE_PREC     5
+#define DEGREE_DELTA    10

 #define BRAKE_UNIT 	1800
 #define BRAKE_TIME 	500
-#define BRAKE_ON_PIN    0 //pin 2
-#define BRAKE_OFF_PIN   1 //pin 3
+#define BRAKE_ON_PIN    30 //pin 2
+#define BRAKE_OFF_PIN   31 //pin 3
 #define BRAKE_PIN	8

 #define ACCEL_UNIT 	100
@@ -48,6 +53,7 @@
 int intbuf;
 int i = 0;
 int currentSpeed = 0;
+char buffer[6];

 // Mustnt conflict / collide with our message payload data. Fine if we use base64 library ^^ above
@@ -110,10 +116,42 @@

 void steerPulse()
 {
+#ifdef STEER_ACTIVE
+  if(steeringAngle >= (steerSetAngle - DEGREE_PREC/2) || steeringAngle <= (steerSetAngle + DEGREE_PREC/2))
+  {
+    stopSteering();
+  }
+  else if(steeringAngle > (steerSetAngle + DEGREE_PREC/2) && (steeringAngle - steerSetAngle) < DEGREE_DELTA)
+  {
+    steer.writeMicroseconds(1400 - ((steeringAngle - steerSetAngle)/DEGREE_DELTA)*400);
+  }
+  else if(steeringAngle < (steerSetAngle - DEGREE_PREC/2) && (steerSetAngle - steeringAngle) < DEGREE_DELTA)
+  {
+    steer.writeMicroseconds(1400 - ((steeringAngle - steerSetAngle)/DEGREE_DELTA)*400);
+  }
+  else if(steeringAngle < (steerSetAngle - DEGREE_PREC/2))
+  {
+    steer.writeMicroseconds(STEER_RUN);
+  }
+  else if(steeringAngle > (steerSetAngle + DEGREE_PREC/2))
+  {
+    steer.writeMicroseconds(STEER_LUN);
+  }
+#else
   if(steeringAngle >= steerSetAngle)
   {
     stopSteering();
   }
+#endif
+  //inter_1_state = digitalRead(18);
+  //inter_2_state = digitalRead(19);
+  //buffer[0] = '0'+digitalRead(30);
+  //buffer[1] = ' ';
+  //buffer[2] = '0'+digitalRead(31);
+  //buffer[3] = ' ';
+  //buffer[4] = '0'+digitalRead(32);
+  //buffer[5] = 0;
+  //cmdMessenger.sendCmd(kACK,buffer);
   setTime();
 }

@@ -128,7 +166,7 @@
 // turning and sets steeringAngle plus or minus the STEER_UNIT accordingly
 void steer_inter_1()
 {
-  inter_1_state = digitalRead(21);
+  inter_1_state = digitalRead(STEER_PIN_1);
   if (inter_2_state)
   {
     if(inter_1_state)
@@ -142,12 +180,14 @@
       steeringAngle = steeringAngle + STEER_UNIT;
     else
       steeringAngle = steeringAngle - STEER_UNIT;
-  }
+  }
+
+//  cmdMessenger.sendCmd(kACK,);
 }

 void steer_inter_2()
 {
-  inter_2_state = digitalRead(20);
+  inter_2_state = digitalRead(STEER_PIN_2);
   if (inter_1_state)
   {
     if(inter_2_state)
@@ -161,7 +201,8 @@
       steeringAngle = steeringAngle - STEER_UNIT;
     else
       steeringAngle = steeringAngle + STEER_UNIT;
-  }
+  }
+  //cmdMessenger.sendCmd(kACK,"The steer angle is: %d",steeringAngle);
 }

 void Steering()
@@ -281,6 +322,10 @@
     applyBrake();
 }

+//void brakePoll()
+//{
+
+
 void brakeState()
 {
   brake_state = !brake_state;
@@ -299,9 +344,9 @@
 void applyBrake()
 {
   if(brake_state)
+    brake.write(2000);
+  else
     brake.write(1000);
-  else
-    brake.write(2000);
 }

 /************************************************************/
@@ -337,12 +382,13 @@

   attachInterrupt(STEER_INTER_1, steer_inter_1, CHANGE);
   attachInterrupt(STEER_INTER_2, steer_inter_2, CHANGE);
-  attachInterrupt(STEER_INTER_G, steer_inter_180, RISING);
+//  attachInterrupt(STEER_INTER_G, steer_inter_180, RISING);
   steer.attach(STEER_PIN);
   steeringAngle = 0.0;

-  attachInterrupt(BRAKE_ON_PIN, brakeState, RISING);
-  attachInterrupt(BRAKE_OFF_PIN, brakeState, RISING);
+  //attachInterrupt(BRAKE_ON_PIN, brakeState, RISING);
+  //attachInterrupt(BRAKE_OFF_PIN, brakeState, RISING);
+
   brake.attach(BRAKE_PIN);

   steer.writeMicroseconds(1500);
@@ -359,15 +405,23 @@
   digitalWrite(RELAY_POWER,LOW);
   //digitalWrite(RELAY_RAM,LOW);
   digitalWrite(RELAY_DIRECTION,HIGH);
+
+//  applyBrake();
+//  delay(1000);
+//  stopBrake();
+//  brake_state = !brake_state;
+//  applyBrake();
+//  delay(1000);
+//  stopBrake();
 }

 void loop()
 {
   cmdMessenger.feedinSerialData();
   steerPulse();
-  brakePulse();
-}
-
-
-
-
+//  brakePulse();
+}
+
+
+
+


Added something

Added something

--- Motor_Controler.ino
+++ Motor_Controler.ino
@@ -1,5 +1,6 @@
 #define NO_PRINT 0
 #define PRINT_SPEED 1
+#define Something

 //mXeY - silnik X, pin enkodera Y
 #define m1e1 23


Add checkTelnet() for inbound

Add checkTelnet() for inbound

--- MicroView/WiFiModem-Menu/WiFiModem-Menu.ino
+++ MicroView/WiFiModem-Menu/WiFiModem-Menu.ino
@@ -6,8 +6,9 @@

 /* TODO
  *  set ip tcp-mode 0x10 to disable remote configuration
- *  wifly.setBroadcastInterval(0);
- *  wifly.setDeviceID("Wifi-Modem");
+ *  CheckTelnet() for inbound
+ *  ATH1 handling
+ *  +++ guard time for inboun
  *
  *
  *
@@ -29,7 +30,7 @@

 ;  // Keep this here to pacify the Arduino pre-processor

-#define VERSION "0.07b2"
+#define VERSION "0.07b3"

 // Configuration 0v3: Wifi Hardware, C64 Software.

@@ -880,7 +881,7 @@
     // Idle here until connected
     while (!wifly.isConnected())  {}
     C64Println(F("Incoming Connection"));
-    //CheckTelnet();
+    CheckTelnet();
     TerminalMode();
 }
 // ----------------------------------------------------------
@@ -1749,9 +1750,23 @@
                 break;

                 case 'H':
-                if (Modem_CommandBuffer[i+1] == '0')
-                  Modem_CommandBuffer[i++];
+                switch(Modem_CommandBuffer[i++])
+                {
+                    case '0':
+                    suppressOkError = true;
                     Modem_Disconnect();
+                    break;
+
+                    /*case '1':
+                    // Future
+                    break;*/
+
+                    default:
+                    i--;                        // User entered ATH
+                    suppressOkError = true;
+                    Modem_Disconnect();
+                    break;
+                }
                 break;

                 case 'Q':
@@ -2092,7 +2107,7 @@
     if (Modem_DCDFollowsRemoteCarrier)
         digitalWriteFast(C64_DCD, Modem_ToggleCarrier(true));

-    //CheckTelnet();
+    CheckTelnet();

     Modem_isConnected = true;
     Modem_isCommandMode = false;


Added at&w0, at&y0, more settings to EEPROM, modem recovery if locked out.

--- MicroView/WiFiModem-Menu/WiFiModem-Menu.ino
+++ MicroView/WiFiModem-Menu/WiFiModem-Menu.ino
@@ -6,7 +6,7 @@

 // Defining HAYES enables Hayes commands and disables the 1) and 2) menu options for telnet and incoming connections.
 // This is required to ensure the compiled code is <= 30,720 bytes
-//#define HAYES
+#define HAYES
 //#define ENABLE_C64_DCD
 #include <MicroView.h>
 #include <elapsedMillis.h>
@@ -56,14 +56,22 @@
 #define TIMEDOUT  -1
 boolean baudMismatch = (BAUD_RATE != WiFly_BAUD_RATE ? 1 : 0);
 #ifndef HAYES
-boolean Modem_flowControlEnabled = false;   // Should this be a menu option for non-Hayes mode?
+boolean Modem_flowControl = false;   // Should this be a menu option for non-Hayes mode?
 #endif

 // EEPROM Addresses
-#define ADDR_PETSCII       0
-#define ADDR_AUTOSTART     1
-#define ADDR_MODEM_ECHO    10
-#define ADDR_MODEM_FLOW    11
+#define ADDR_PETSCII            0
+#define ADDR_AUTOSTART          1
+#define ADDR_MODEM_ECHO         10
+#define ADDR_MODEM_FLOW         11
+#define ADDR_MODEM_VERBOSE      12
+#define ADDR_MODEM_QUIET        13
+#define ADDR_MODEM_S0_AUTOANS   14
+#define ADDR_MODEM_S2_ESCAPE    15
+#define ADDR_MODEM_DCD_INVERTED 16
+
+#define ADDR_RECOVERY           254
+#define ADDR_FIRST_TIME_CHECK   255

 // PETSCII state
@@ -92,14 +100,16 @@
 boolean Modem_isCommandMode = true;
 boolean Modem_isConnected = false;
 boolean Modem_isRinging = false;
-boolean Modem_EchoOn = EEPROM.read(ADDR_MODEM_ECHO);
-boolean Modem_flowControlEnabled = EEPROM.read(ADDR_MODEM_FLOW);
+boolean Modem_Echo = false;
+boolean Modem_flowControl = false;
 boolean Modem_VerboseResponses = true;
 boolean Modem_QuietMode = false;
 boolean Modem_isDcdInverted = false;

 boolean Modem_S0_AutoAnswer = false;
 char    Modem_S2_EscapeCharacter = '+';
+
+byte    Modem_Recovery = 0;

 #define COMMAND_BUFFER_SIZE  81
 char Modem_LastCommandBuffer[COMMAND_BUFFER_SIZE];
@@ -119,6 +129,31 @@
         uView.begin(); // begin of MicroView
         uView.setFontType(0);
         uView.clear(ALL); // erase hardware memory inside the OLED controller
+
+#ifdef HAYES
+        if (EEPROM.read(ADDR_FIRST_TIME_CHECK) != 222) {
+            // First time - reset to defaults
+            Modem_LoadDefaults();
+            Modem_Save_Settings(0);
+            EEPROM.write(ADDR_FIRST_TIME_CHECK, 222);
+            EEPROM.write(ADDR_RECOVERY, 0);
+        }
+        else
+        {
+            Modem_Load_Settings(0);
+        }
+
+        Modem_Recovery = EEPROM.read(ADDR_RECOVERY);
+        if (Modem_Recovery > 2)   // 2 = 3 times
+        {
+            Modem_LoadDefaults();
+            Modem_Save_Settings(0);
+            delay(1000);
+            EEPROM.write(ADDR_RECOVERY, 0);
+        }
+        Modem_Recovery++;
+        EEPROM.write(ADDR_RECOVERY, Modem_Recovery);
+#endif  // HAYES

         C64Serial.begin(BAUD_RATE);
         WifiSerial.begin(WiFly_BAUD_RATE);
@@ -158,8 +193,9 @@
 #ifdef ENABLE_C64_DCD
         digitalWriteFast(C64_DCD, true);    // true = no carrier
 #endif
+        EEPROM.write(ADDR_RECOVERY, 0);   // We made it to the menu so user is not trying to reset to defaults..
         HandleAutoStart();
-
+
         C64Println();
 #ifdef HAYES
         C64Println(F("Commodore Wi-Fi Modem Hayes"));
@@ -385,6 +421,14 @@

 // Pointer version.  Does not work with F("") or PSTR("").  Use with sprintf and sprintf_P
 void DisplayP(const char *message)
+{
+    uView.clear(PAGE); // erase the memory buffer, when next uView.display() is called, the OLED will be cleared.
+    uView.setCursor(0, 0);
+    uView.println(message);
+    uView.display();
+}
+
+void DisplayInt(int message)
 {
     uView.clear(PAGE); // erase the memory buffer, when next uView.display() is called, the OLED will be cleared.
     uView.setCursor(0, 0);
@@ -864,7 +908,7 @@

         if (changed)
         {
-            if (Modem_flowControlEnabled || BAUD_RATE >= MIN_FLOW_CONTROL_RATE || baudMismatch)
+            if (Modem_flowControl || BAUD_RATE >= MIN_FLOW_CONTROL_RATE || baudMismatch)
             {
                 sprintf_P(temp, PSTR("Wifi:%ld\n\nC64: %ld\n\nRTS: %ld"), rnxv_chars, c64_chars, c64_rts_count);
             }
@@ -880,7 +924,7 @@
 inline void DoFlowControl()
 {

-    if (Modem_flowControlEnabled || BAUD_RATE >= MIN_FLOW_CONTROL_RATE || baudMismatch)
+    if (Modem_flowControl || BAUD_RATE >= MIN_FLOW_CONTROL_RATE || baudMismatch)
     {
         // Check that C64 is ready to receive
         while (digitalReadFast(C64_RTS) == LOW)   // If not...  C64 RTS and CTS are inverted.
@@ -1158,7 +1202,8 @@

     Modem_EscapeCount = 0;

-    Modem_LoadDefaults();
+    //Modem_LoadDefaults();
+    Modem_Load_Settings(0);
     Modem_ResetCommandBuffer();

     C64Println();
@@ -1201,21 +1246,6 @@
     memset(Modem_CommandBuffer, 0, COMMAND_BUFFER_SIZE);
 }

-
-void Modem_LoadDefaults(void)
-{
-    Modem_isCommandMode = true;
-    Modem_isConnected = false;
-    Modem_isRinging = false;
-    Modem_SetEcho(true);
-    Modem_VerboseResponses = true;
-    Modem_QuietMode = false;
-    Modem_S0_AutoAnswer = false;
-    Modem_S2_EscapeCharacter = '+';
-    Modem_isDcdInverted = false;
-}
-
-
 int Modem_ToggleCarrier(boolean isHigh)
 {
     int result = 0; //_isDcdInverted ? (isHigh ? LOW : HIGH) : (isHigh ? HIGH : LOW);
@@ -1253,13 +1283,6 @@
     digitalWriteFast(C64_DTR, Modem_ToggleCarrier(false));
 }

-void Modem_SetEcho(boolean on)
-{
-    Modem_EchoOn = on;
-    EEPROM.write(ADDR_MODEM_ECHO, Modem_EchoOn);  // Save
-}
-
-
 // Validate and handle AT sequence  (A/ was handled already)
 void Modem_ProcessCommandBuffer()
 {
@@ -1300,7 +1323,8 @@

     if (strcmp(Modem_CommandBuffer, ("ATZ")) == 0)
     {
-        Modem_LoadDefaults();
+        //Modem_LoadDefaults();
+        Modem_Load_Settings(0);
         Modem_PrintOK();
     }
     else if (strcmp(Modem_CommandBuffer, ("ATI")) == 0)
@@ -1357,17 +1381,15 @@
     {
         if (strstr(Modem_CommandBuffer, ("E0")) != NULL)
         {
-            Modem_SetEcho(false);
-        }
-
+            Modem_Echo = false;
+        }
         if (strstr(Modem_CommandBuffer, ("E1")) != NULL)
         {
-            Modem_EchoOn = true;
-        }
-
+            Modem_Echo = true;
+        }
         if (strstr(Modem_CommandBuffer, ("E?")) != NULL)
         {
-            C64PrintIntln(EEPROM.read(ADDR_MODEM_ECHO));
+            C64PrintIntln(Modem_Echo);
         }

         if (strstr(Modem_CommandBuffer, ("Q0")) != NULL)
@@ -1375,22 +1397,28 @@
             Modem_VerboseResponses = false;
             Modem_QuietMode = false;
         }
-
         if (strstr(Modem_CommandBuffer, ("Q1")) != NULL)
         {
             Modem_QuietMode = true;
         }
+        if (strstr(Modem_CommandBuffer, ("Q?")) != NULL)
+        {
+            C64PrintIntln(Modem_QuietMode);
+        }

         if (strstr(Modem_CommandBuffer, ("V0")) != NULL)
         {
             Modem_VerboseResponses = false;
         }
-
         if (strstr(Modem_CommandBuffer, ("V1")) != NULL)
         {
             Modem_VerboseResponses = true;
         }
-
+        if (strstr(Modem_CommandBuffer, ("V?")) != NULL)
+        {
+            C64PrintIntln(Modem_VerboseResponses);
+        }
+
         if (strstr(Modem_CommandBuffer, ("X0")) != NULL)
         {
             // TODO
@@ -1399,20 +1427,36 @@
         {
             // TODO
         }
+        if (strstr(Modem_CommandBuffer, ("X?")) != NULL)
+        {
+            // TODO
+        }
+
         if (strstr(Modem_CommandBuffer, ("&K0")) != NULL)
         {
-            Modem_flowControlEnabled = false;
-            EEPROM.write(ADDR_MODEM_FLOW, 0);
+            Modem_flowControl = false;
+            //EEPROM.write(ADDR_MODEM_FLOW, 0);
         }
         if (strstr(Modem_CommandBuffer, ("&K1")) != NULL)
         {
-            Modem_flowControlEnabled = true;
-            EEPROM.write(ADDR_MODEM_FLOW, 1);
+            Modem_flowControl = true;
+            //EEPROM.write(ADDR_MODEM_FLOW, 1);
         }
         if (strstr(Modem_CommandBuffer, ("&K?")) != NULL)
         {
-            C64PrintIntln(EEPROM.read(ADDR_MODEM_FLOW));
-        }
+            C64PrintIntln(Modem_flowControl);
+        }
+
+        if (strstr(Modem_CommandBuffer, ("&W0")) != NULL)
+        {
+            Modem_Save_Settings(0);
+        }
+
+        if (strstr(Modem_CommandBuffer, ("Y0")) != NULL)
+        {
+            Modem_Load_Settings(0);
+        }
+
         if (strstr(Modem_CommandBuffer, ("DL")) != NULL)
         {
             Modem_Dialout("",1);
@@ -1537,14 +1581,14 @@
         // Command Mode -----------------------------------------------------------------------
         if (Modem_isCommandMode)
         {
-            if (Modem_flowControlEnabled)
+            if (Modem_flowControl)
                 digitalWriteFast(C64_CTS, LOW);
             //char inbound = toupper(_serial->read());
             char inbound = C64Serial.read();

-            if (Modem_EchoOn)
+            if (Modem_Echo)
             {
-                if (!Modem_flowControlEnabled)
+                if (!Modem_flowControl)
                     delay(100/(BAUD_RATE/2400));         // Slow down command mode to prevent garbage if flow control
                                                          // is disabled.  Doesn't work at 9600.  TODO:  Fix
                 C64Serial.write(inbound);
@@ -1570,7 +1614,7 @@
                     if (toupper(Modem_CommandBuffer[0]) == 'A' && (Modem_CommandBuffer[1] == '/'))
                     {
                         strcpy(Modem_CommandBuffer, Modem_LastCommandBuffer);
-                        if (Modem_flowControlEnabled)
+                        if (Modem_flowControl)
                             digitalWriteFast(C64_CTS, HIGH);
                         Modem_ProcessCommandBuffer();
                         Modem_ResetCommandBuffer();  // To prevent A matching with A/ again
@@ -1579,7 +1623,7 @@
             }
             else if (toupper(Modem_CommandBuffer[0]) == 'A' && toupper(Modem_CommandBuffer[1]) == 'T')
             {
-                if (Modem_flowControlEnabled)
+                if (Modem_flowControl)
                     digitalWriteFast(C64_CTS, HIGH);
                 Modem_ProcessCommandBuffer();
             }
@@ -1618,7 +1662,7 @@
         }
     }
     //digitalWrite(DCE_RTS, LOW);
-    if (Modem_flowControlEnabled)
+    if (Modem_flowControl)
         digitalWriteFast(C64_CTS, HIGH);
 }

@@ -1771,6 +1815,51 @@
 Serial.begin(115200);
 */

+#ifdef HAYES
+
+void Modem_LoadDefaults(void)
+{
+    Display(F("Setting defaults"));
+    Modem_isCommandMode = true;
+    Modem_isConnected = false;
+    Modem_isRinging = false;
+    Modem_Echo = true;
+    Modem_flowControl = false;
+    Modem_VerboseResponses = true;
+    Modem_QuietMode = false;
+    Modem_S0_AutoAnswer = false;
+    Modem_S2_EscapeCharacter = '+';
+    Modem_isDcdInverted = false;
+    delay(2000);
+}
+
+// Save settings to profile.  Future:  profile #1 using ADDR_MODEM_ECHO1 etc.
+void Modem_Save_Settings(byte profile_num)
+{
+    EEPROM.write(ADDR_MODEM_ECHO, Modem_Echo);
+    EEPROM.write(ADDR_MODEM_FLOW, Modem_flowControl);
+    EEPROM.write(ADDR_MODEM_VERBOSE, Modem_VerboseResponses);
+    EEPROM.write(ADDR_MODEM_QUIET, Modem_QuietMode);
+    EEPROM.write(ADDR_MODEM_S0_AUTOANS, Modem_S0_AutoAnswer);
+    EEPROM.write(ADDR_MODEM_S2_ESCAPE, Modem_S2_EscapeCharacter);
+    EEPROM.write(ADDR_MODEM_DCD_INVERTED, Modem_isDcdInverted);
+}
+
+void Modem_Load_Settings(byte profile_num)
+// Load settings from profile.  Future:  profile #1 using ADDR_MODEM_ECHO1 etc.
+{
+    Modem_Echo = EEPROM.read(ADDR_MODEM_ECHO);
+    Modem_flowControl = EEPROM.read(ADDR_MODEM_FLOW);
+    Modem_VerboseResponses = EEPROM.read(ADDR_MODEM_VERBOSE);
+    Modem_QuietMode = EEPROM.read(ADDR_MODEM_QUIET);
+    Modem_S0_AutoAnswer = EEPROM.read(ADDR_MODEM_S0_AUTOANS);
+    Modem_S2_EscapeCharacter = EEPROM.read(ADDR_MODEM_S2_ESCAPE);
+    Modem_isDcdInverted = EEPROM.read(ADDR_MODEM_DCD_INVERTED);
+}
+
+
+#endif  // HAYES
+

 int freeRam ()
 {


Use scroll callback array in ADSR function.

--- examples/adsr/adsr.ino
+++ examples/adsr/adsr.ino
@@ -55,14 +55,7 @@
 void switch_isr();

 void save_click_callback();
-void adsr_scroll_callback_0(int delta);
-void adsr_scroll_callback_1(int delta);
-void adsr_scroll_callback_2(int delta);
-void adsr_scroll_callback_3(int delta);
-void adsr_scroll_callback_4(int delta);
-void adsr_scroll_callback_5(int delta);
-void adsr_scroll_callback_6(int delta);
-void adsr_scroll_callback_7(int delta);
+void adsr_scroll_callback(uint8_t selected, int delta);

 class DU_ADSR_Function : public DUINO_Function {
  public:
@@ -84,14 +77,7 @@
       container_adsr_->attach_child(widgets_adsr_[i + 4], i + 4);
     }
     container_outer_->attach_child(container_adsr_, 1);
-    widgets_adsr_[0]->attach_scroll_callback(adsr_scroll_callback_0);
-    widgets_adsr_[1]->attach_scroll_callback(adsr_scroll_callback_1);
-    widgets_adsr_[2]->attach_scroll_callback(adsr_scroll_callback_2);
-    widgets_adsr_[3]->attach_scroll_callback(adsr_scroll_callback_3);
-    widgets_adsr_[4]->attach_scroll_callback(adsr_scroll_callback_4);
-    widgets_adsr_[5]->attach_scroll_callback(adsr_scroll_callback_5);
-    widgets_adsr_[6]->attach_scroll_callback(adsr_scroll_callback_6);
-    widgets_adsr_[7]->attach_scroll_callback(adsr_scroll_callback_7);
+    container_adsr_->attach_scroll_callback_array(adsr_scroll_callback);

     env = 0;
     gate_time = 0;
@@ -334,14 +320,7 @@
 }

 void save_click_callback() { function->widget_save_click_callback(); }
-void adsr_scroll_callback_0(int delta) { function->widget_adsr_scroll_callback(0, delta); }
-void adsr_scroll_callback_1(int delta) { function->widget_adsr_scroll_callback(1, delta); }
-void adsr_scroll_callback_2(int delta) { function->widget_adsr_scroll_callback(2, delta); }
-void adsr_scroll_callback_3(int delta) { function->widget_adsr_scroll_callback(3, delta); }
-void adsr_scroll_callback_4(int delta) { function->widget_adsr_scroll_callback(4, delta); }
-void adsr_scroll_callback_5(int delta) { function->widget_adsr_scroll_callback(5, delta); }
-void adsr_scroll_callback_6(int delta) { function->widget_adsr_scroll_callback(6, delta); }
-void adsr_scroll_callback_7(int delta) { function->widget_adsr_scroll_callback(7, delta); }
+void adsr_scroll_callback(uint8_t selected, int delta) { function->widget_adsr_scroll_callback(selected, delta); }

 void setup()
 {


Update MultipleSteppers.ino

Update MultipleSteppers.ino

--- examples/MultipleSteppers/MultipleSteppers.ino
+++ examples/MultipleSteppers/MultipleSteppers.ino
@@ -1,18 +1,16 @@
 /*==========================================================================
- * This sketch shows how to move more than one motor in sync.
+ * The sketch shows how to move more than one motor.
  *
- *
+ * If more than one motor is moved by one controller all motors will arrive at
+ * their targets at the same time. E.g., if the motors are part of a
+ * x/y transport system, the transport move on a straight diagonal line to the
+ * target coordinates.
  *
- * The target position is set to 1000 steps relative to the
- * current position. The move command of the controller
- * moves the motor to the target position.
- *
- * Default parameters are
- * Speed:          800 steps/s
- * Acceleration:  2500 steps/s^2
- *
- * (slow, but good to start with since they will work on any normal stepper)
+ * The sketch also shows examples how the motor properties are set up
  *
+ * A 1/16 microstep driver is assumed. You probably want to adjust speed,
+ * acceleration and distances if you are using a driver with another microstep
+ * resolution.
  ===========================================================================*/

 #include <StepControl.h>
@@ -33,7 +31,7 @@

   motor_2
     .SetMaxSpeed(50000)       // steps/s
-    .SetAcceleration(200000);  // steps/s^2
+    .SetAcceleration(200000); // steps/s^2

   motor_3
     .SetPullInSpeed(300)      // steps/s
@@ -43,7 +41,7 @@

 void loop()
 {
-  constexpr int spr = 3200;  // 16*200=3200 steps per revolution
+  constexpr int spr = 16*200;  // 3200 steps per revolution

   // lets shake
   for(int i = 0; i < 5; i++)


Fix printout.

Fix printout.

--- examples/Sandbox/CosaRegistry/CosaRegistry.ino
+++ examples/Sandbox/CosaRegistry/CosaRegistry.ino
@@ -227,7 +227,7 @@
   ASSERT(blob != NULL);
   uint16_t errs;
   ASSERT(reg.get_value<uint16_t>(blob, &errs));
-  trace << errs << endl;
+  trace << PSTR("errors = ") << errs << endl;
   errors += 42;
   ASSERT(reg.get_value<uint16_t>(blob, &errs));
   trace << PSTR("errors = ") << errs << endl;


eliminate delay in de-bounce - better

eliminate delay in de-bounce - better

--- Lifter/Lifter.ino
+++ Lifter/Lifter.ino
@@ -43,15 +43,15 @@
 const int cardThickness = 52;       // calculated 141 steps to lift a card. 608steps/turn
                                      // (20 turns per 86 cards, 141.3953 ...
 const int proxSense2 = 620;         // threshold for OPB606A riding on fan housing
-const int liftSenseTop = 820;        // above threshold nothing is close to face of OPB606A
+const int liftSenseTop = 740;        // above threshold nothing is close to face of OPB606A
 const long int hoverArmPos = 15;      // pick up postion after zeroing against armLimit
 const long int firstArmPos = 120;    // experimentally determined drop-off position
 const long int secondArmPos = 220;   // 2nd drop and max Arm travel
-const byte closeAng = 105;              // servo position: closest approach to card-stack
-const byte openAng = 165;              // servo postion:
-const byte bumpBinSteps = 36;        // for jiggle when grabTryCo17unt goes up.
+const byte closeAng = 115;              // servo position: closest approach to card-stack
+const byte openAng = 158;              // servo postion:
+const byte bumpBinSteps = 36;        // for jiggle when grabTryCount goes up.
 const byte servoPosition = 130;      // initial setup() safe servo position & middle return
-const byte extraServoBump = 12;      // travel either way a little further then settle back to low or high
+const byte extraServoBump = 22;      // travel either way a little further then settle back to low or high
 int newAnalog1 = 0;                 // hold value from the PROX_PIN sensor
 int newAnalog2 = 0;                 // hold value from the CARD_PIN sensor
 int oldAnalog1 = 0;                 // discover changes in the PROX_PIN sensor
@@ -148,10 +148,9 @@

     // arm starts off moving towards limit switch in setup(), hits it, moves to ready-to-load
     if ((armState == HIGH) && (stepperArm.targetPosition() < 0)){
-      delay(4);                                  // de-bounce the switch hopefully
+      delay(2);                                  // de-bounce the switch hopefully
       if (digitalState(LIMIT_ARM)) {
         stepperArm.setCurrentPosition(0);
-        delay(3);                             // deceleration allowance
         stepperArm.moveTo(firstArmPos);
         UPDATE = true;
         armState = LOW;


Check if queue is not empty

Check if queue is not empty

--- MagicMushroom.ino
+++ MagicMushroom.ino
@@ -160,7 +160,7 @@
   mqttClient.loop();
   webServer.handleClient();

-  if(debouncer.fell()) {
+  if(debouncer.fell() && sounds.size() > 0) {
     currentSoundIndex = currentSoundIndex % sounds.size();
     sounds[currentSoundIndex].toCharArray(convertBuffer, MAX_FILENAME_LENGTH);


Disabling keepalive code as requires modifying libraries

--- WhereDial.ino
+++ WhereDial.ino
@@ -358,7 +358,7 @@
           Serial.print(":keepAliveTimeoutStart=");
           Serial.println(keepAliveTimeoutStart);
           Serial.println("Sending keep alive");
-          if (!client.sendKeepAlive()) {
+          if (1/*||!client.sendKeepAlive()*/) {
             Serial.println("Keep alive failed");
             break;
           } else {


Fix and simplify SensorTag button example

--- libraries/CurieBLE/examples/central/sensortag_button/sensortag_button.ino
+++ libraries/CurieBLE/examples/central/sensortag_button/sensortag_button.ino
@@ -14,24 +14,6 @@
  */

 #include <CurieBLE.h>
-
-const int NUM_OF_SERVICE = 10;
-
-char *serviceUUIDArray[NUM_OF_SERVICE] =
-
-  // These are the various services that are included in the CC2650 Sensor Tag
-  // If you uncomment them you can see the various services
-{ //"f000aa00-0451-4000-b000-000000000000",
-  //    "f000aa20-0451-4000-b000-000000000000",
-  //    "f000aa40-0451-4000-b000-000000000000",
-  //    "f000aa70-0451-4000-b000-000000000000",
-  //    "f000aa80-0451-4000-b000-000000000000",
-  //    "f000aa64-0451-4000-b000-000000000000",
-  //    "f000ac00-0451-4000-b000-000000000000",
-  //    "f000ccc0-0451-4000-b000-000000000000",
-  //    "f000ffc0-0451-4000-b000-000000000000",
-  "0000ffe0-0000-1000-8000-00805f9b34fb"
-};

 void setup() {
   Serial.begin(9600);
@@ -77,10 +59,7 @@
     * Use a central app that can display the BT MAC address
     * ******************************************************
     */
-
-    if (peripheral.address() == "24:71:89:07:27:80")
-
-    {
+    if (peripheral.address() == "68:C9:0B:06:BC:81") {
       // stop scanning
       BLE.stopScan();

@@ -94,9 +73,6 @@

 void monitorSensorTagButtons(BLEDevice peripheral)
 {
-  static bool getAllServices = true;
-  static int serviceIndx = 0;
-
   // connect to the peripheral
   Serial.println("Connecting ...");
   if (peripheral.connect()) {
@@ -106,34 +82,18 @@
     return;
   }

-  if (getAllServices) {
-    // discover peripheral attributes
-    Serial.println("Discovering attributes ...");
-    if (peripheral.discoverAttributes()) {
-      Serial.println("Attributes discovered");
-    } else {
-      getAllServices = false;
-      Serial.println("Attribute discovery failed.");
-      peripheral.disconnect();
-      return;
-    }
+  // discover peripheral attributes
+  Serial.println("Discovering attributes of service 0xffe0 ...");
+  if (peripheral.discoverAttributesByService("ffe0")) {
+    Serial.println("Attributes discovered");
   } else {
-    int tmp = serviceIndx;
-    Serial.print("Discovering Service: ");
-    Serial.println(serviceUUIDArray[tmp]);
-    if (++serviceIndx >= NUM_OF_SERVICE)
-      serviceIndx = 0;
-    if (peripheral.discoverAttributesByService(serviceUUIDArray[tmp]) == false) {
-      Serial.println("Can't find the Service.");
-      peripheral.disconnect();
-      return;
-    } else {
-      Serial.println("Service discovered.");
-    }
+    Serial.println("Attribute discovery failed.");
+    peripheral.disconnect();
+    return;
   }

   // retrieve the simple key characteristic
-  BLECharacteristic simpleKeyCharacteristic = peripheral.characteristic("0000ffe1-0000-1000-8000-00805f9b34fb");
+  BLECharacteristic simpleKeyCharacteristic = peripheral.characteristic("ffe1");

   // subscribe to the simple key characteristic
   Serial.println("Subscribing to simple key characteristic ...");
@@ -174,6 +134,7 @@
     }
   }

+  Serial.println("SensorTag disconnected!");
 }


Cambios y arreglos importantes

Cambios y arreglos importantes

Cambiada indentacion de dos espacios, a una tabulacion
Codigo arreglado para que compile:
* Añadida definicion de algunas funciones
* Re-acomodado codigo

Removido codigo innecesario
Mas correcciones de indentacion
Añadidos algunos comentarios

--- examples/Otto_smooth_criminal/Otto_smooth_criminal.ino
+++ examples/Otto_smooth_criminal/Otto_smooth_criminal.ino
@@ -6,34 +6,41 @@
 //--           Juan Gonzalez (obijuan): juan.gonzalez@bq.com
 //-----------------------------------------------------------------
 #include <Servo.h>
+//BUILT-IN
 #include <Oscillator.h>
+//IMPORT FROM PROJECT
 #include <EEPROM.h>
+//BUILT-IN; https://www.arduino.cc/en/Reference/EEPROM

 #define N_SERVOS 4
-//-- First step: Configure the pins where the servos are attached
+//-- Primer paso: Configurar los pines en los que estan conectados los servos
 /*
-         ---------------
-        |     O   O     |
-        |---------------|
-YR 3==> |               | <== YL 2
-         ---------------
-            ||     ||
-            ||     ||
-RR 5==>   -----   ------  <== RL 4
-         |-----   ------|
+				 ---------------
+				|     O   O     |
+				|---------------|
+		YR 3==> |               | <== YL 2
+				 ---------------
+					||     ||
+					||     ||
+		RR 5==>   -----  ------  <== RL 4
+				 |-----  ------|
 */
+
+#define PIN_RR 5
+#define PIN_RL 4
+#define PIN_YR 3
+#define PIN_YL 2
+
+
+// Activar para tomar datos de calibracion de la memoria interna (?)
 #define EEPROM_TRIM false
-// Activate to take callibration data from internal memory
+
+//ni idea..
 #define TRIM_RR 7
 #define TRIM_RL 4
 #define TRIM_YR  4
 #define TRIM_YL -7
 //OTTO.setTrims(-7,-4,-4,7);
-
-#define PIN_RR 5
-#define PIN_RL 4
-#define PIN_YR 3
-#define PIN_YL 2

 #define INTERVALTIME 10.0

@@ -56,42 +63,45 @@
 void swing(int steps, int T=1000);
 void upDown(int steps, int T=1000);
 void flapping(int steps, int T=1000);
+void dance();
+void primera_parte();
+void segunda_parte();

 void setup()
 {
-  Serial.begin(19200);
-
-  servo[0].attach(PIN_RR);
-  servo[1].attach(PIN_RL);
-  servo[2].attach(PIN_YR);
-  servo[3].attach(PIN_YL);
-
-  //EEPROM.write(0,TRIM_RR);
-  //EEPROM.write(1,TRIM_RL);
-  //EEPROM.write(2,TRIM_YR);
-  //EEPROM.write(3,TRIM_YL);
-
-  int trim;
-
-  if(EEPROM_TRIM){
-    for(int x=0;x<4;x++){
-      trim=EEPROM.read(x);
-      if(trim>128)trim=trim-256;
-      Serial.print("TRIM ");
-      Serial.print(x);
-      Serial.print(" en ");
-      Serial.println(trim);
-      servo[x].SetTrim(trim);
-    }
-  }
-  else{
-    servo[0].SetTrim(TRIM_RR);
-    servo[1].SetTrim(TRIM_RL);
-    servo[2].SetTrim(TRIM_YR);
-    servo[3].SetTrim(TRIM_YL);
-  }
-
-  for(int i=0;i<4;i++) servo[i].SetPosition(90);
+	Serial.begin(19200);
+
+	servo[0].attach(PIN_RR);
+	servo[1].attach(PIN_RL);
+	servo[2].attach(PIN_YR);
+	servo[3].attach(PIN_YL);
+
+	//EEPROM.write(0,TRIM_RR);
+	//EEPROM.write(1,TRIM_RL);
+	//EEPROM.write(2,TRIM_YR);
+	//EEPROM.write(3,TRIM_YL);
+
+	int trim;
+
+	if(EEPROM_TRIM){
+		for(int x=0;x<4;x++){
+			trim=EEPROM.read(x);
+			if(trim>128)trim=trim-256;
+			Serial.print("TRIM ");
+			Serial.print(x);
+			Serial.print(" en ");
+			Serial.println(trim);
+			servo[x].SetTrim(trim);
+		}
+	}
+	else{
+		servo[0].SetTrim(TRIM_RR);
+		servo[1].SetTrim(TRIM_RL);
+		servo[2].SetTrim(TRIM_YR);
+		servo[3].SetTrim(TRIM_YL);
+	}
+
+	for(int i=0;i<4;i++) servo[i].SetPosition(90);
 }

 // TEMPO: 121 BPM
@@ -100,77 +110,68 @@

 void loop()
 {
- // if(Serial.available()){
-  //  char init = Serial.read();
-   // if (init=='X'){
-   //   delay(4000); //3000 - 4500
-
-dance();
-
-
-//for(int i=0;i<4;i++) servo[i].SetPosition(90);
-
-
-          for(int i=0;i<4;i++) servo[i].SetPosition(90);
-   // }
- // }
+
+	dance();
+	//Reiniciar la posicion de los servos
+	for(int i=0;i<4;i++) servo[i].SetPosition(90);
+
 }

 void dance(){
-  primera_parte();
-  segunda_parte();
-  moonWalkLeft(4,t*2);
-  moonWalkRight(4,t*2);
-  moonWalkLeft(4,t*2);
-  moonWalkRight(4,t*2);
-  primera_parte();
-  crusaito(1,t*8);
-  crusaito(1,t*7);
-
-  for (int i=0; i<16; i++){
-    flapping(1,t/4);
-    delay(3*t/4);
-  }
+	primera_parte();
+	segunda_parte();
+	moonWalkLeft(4,t*2);
+	moonWalkRight(4,t*2);
+	moonWalkLeft(4,t*2);
+	moonWalkRight(4,t*2);
+	primera_parte();
+	crusaito(1,t*8);
+	crusaito(1,t*7);
+
+	for (int i=0; i<16; i++){
+		flapping(1,t/4);
+		delay(3*t/4);
+	}

-  moonWalkRight(4,t*2);
-  moonWalkLeft(4,t*2);
-  moonWalkRight(4,t*2);
-  moonWalkLeft(4,t*2);
-
-  drunk(t*4);
-  drunk(t*4);
-  drunk(t*4);
-  drunk(t*4);
-  kickLeft(t);
-  kickRight(t);
-  drunk(t*8);
-  drunk(t*4);
-  drunk(t/2);
-  delay(t*4);
-
-  drunk(t/2);
-
-  delay(t*4);
-  walk(2,t*2);
-  backyard(2,t*2);
-  goingUp(t*2);
-  goingUp(t*1);
-  noGravity(t*2);
-  crusaito(1,t*2);
-  crusaito(1,t*8);
-  crusaito(1,t*2);
-  crusaito(1,t*8);
-  crusaito(1,t*2);
-  crusaito(1,t*3);
-
-  delay(t);
-  primera_parte();
-    for (int i=0; i<32; i++){
-    flapping(1,t/2);
-    delay(t/2);
-  }
-
-  for(int i=0;i<4;i++) servo[i].SetPosition(90);
+	moonWalkRight(4,t*2);
+	moonWalkLeft(4,t*2);
+	moonWalkRight(4,t*2);
+	moonWalkLeft(4,t*2);
+
+	drunk(t*4);
+	drunk(t*4);
+	drunk(t*4);
+	drunk(t*4);
+	kickLeft(t);
+	kickRight(t);
+	drunk(t*8);
+	drunk(t*4);
+	drunk(t/2);
+	delay(t*4);
+
+	drunk(t/2);
+
+	delay(t*4);
+	walk(2,t*2);
+	backyard(2,t*2);
+	goingUp(t*2);
+	goingUp(t*1);
+	noGravity(t*2);
+	crusaito(1,t*2);
+	crusaito(1,t*8);
+	crusaito(1,t*2);
+	crusaito(1,t*8);
+	crusaito(1,t*2);
+	crusaito(1,t*3);
+
+	delay(t);
+	primera_parte();
+		for (int i=0; i<32; i++){
+		flapping(1,t/2);
+		delay(t/2);
+	}
+
+	for(int i=0;i<4;i++) servo[i].SetPosition(90);
 }

@@ -181,18 +182,18 @@
 ////////////////////////////////////////////////////////////////////////////////////////

 void oscillate(int A[N_SERVOS], int O[N_SERVOS], int T, double phase_diff[N_SERVOS]){
-  for (int i=0; i<4; i++) {
-    servo[i].SetO(O[i]);
-    servo[i].SetA(A[i]);
-    servo[i].SetT(T);
-    servo[i].SetPh(phase_diff[i]);
-  }
-  double ref=millis();
-   for (double x=ref; x<T+ref; x=millis()){
-     for (int i=0; i<4; i++){
-        servo[i].refresh();
-     }
-  }
+	for (int i=0; i<4; i++) {
+		servo[i].SetO(O[i]);
+		servo[i].SetA(A[i]);
+		servo[i].SetT(T);
+		servo[i].SetPh(phase_diff[i]);
+	}
+	double ref=millis();
+	 for (double x=ref; x<T+ref; x=millis()){
+		 for (int i=0; i<4; i++){
+				servo[i].refresh();
+		 }
+	}
 }

 unsigned long final_time;
@@ -203,29 +204,29 @@
 int oldPosition[]={90,90,90,90};

 void moveNServos(int time, int  newPosition[]){
-  for(int i=0;i<N_SERVOS;i++)	increment[i] = ((newPosition[i])-oldPosition[i])/(time/INTERVALTIME);
-
-  final_time =  millis() + time;
-
-  iteration = 1;
-  while(millis() < final_time){ //Javi del futuro cambia esto
-      interval_time = millis()+INTERVALTIME;
-
-      oneTime=0;
-      while(millis()<interval_time){
-          if(oneTime<1){
-              for(int i=0;i<N_SERVOS;i++){
-                  servo[i].SetPosition(oldPosition[i] + (iteration * increment[i]));
-              }
-              iteration++;
-              oneTime++;
-          }
-      }
-  }
-
-  for(int i=0;i<N_SERVOS;i++){
-    oldPosition[i] = newPosition[i];
-  }
+	for(int i=0;i<N_SERVOS;i++)	increment[i] = ((newPosition[i])-oldPosition[i])/(time/INTERVALTIME);
+
+	final_time =  millis() + time;
+
+	iteration = 1;
+	while(millis() < final_time){ //Javi del futuro cambia esto  //Javi se olvido de cambiarlo lol
+			interval_time = millis()+INTERVALTIME;
+
+			oneTime=0;
+			while(millis()<interval_time){
+					if(oneTime<1){
+							for(int i=0;i<N_SERVOS;i++){
+									servo[i].SetPosition(oldPosition[i] + (iteration * increment[i]));
+							}
+							iteration++;
+							oneTime++;
+					}
+			}
+	}
+
+	for(int i=0;i<N_SERVOS;i++){
+		oldPosition[i] = newPosition[i];
+	}
 }

@@ -234,313 +235,313 @@
 //////////////////////////////////////////////////////////////////////////////

 void goingUp(int tempo){
-
-      pause=millis();
-      for(int i=0;i<4;i++) servo[i].SetPosition(90);
-      delay(tempo);
-      servo[0].SetPosition(80);
-      servo[1].SetPosition(100);
-      delay(tempo);
-      servo[0].SetPosition(70);
-      servo[1].SetPosition(110);
-      delay(tempo);
-      servo[0].SetPosition(60);
-      servo[1].SetPosition(120);
-      delay(tempo);
-      servo[0].SetPosition(50);
-      servo[1].SetPosition(130);
-      delay(tempo);
-      servo[0].SetPosition(40);
-      servo[1].SetPosition(140);
-      delay(tempo);
-      servo[0].SetPosition(30);
-      servo[1].SetPosition(150);
-      delay(tempo);
-      servo[0].SetPosition(20);
-      servo[1].SetPosition(160);
-      delay(tempo);
-
-      while(millis()<pause+8*t);
+
+			pause=millis();
+			for(int i=0;i<4;i++) servo[i].SetPosition(90);
+			delay(tempo);
+			servo[0].SetPosition(80);
+			servo[1].SetPosition(100);
+			delay(tempo);
+			servo[0].SetPosition(70);
+			servo[1].SetPosition(110);
+			delay(tempo);
+			servo[0].SetPosition(60);
+			servo[1].SetPosition(120);
+			delay(tempo);
+			servo[0].SetPosition(50);
+			servo[1].SetPosition(130);
+			delay(tempo);
+			servo[0].SetPosition(40);
+			servo[1].SetPosition(140);
+			delay(tempo);
+			servo[0].SetPosition(30);
+			servo[1].SetPosition(150);
+			delay(tempo);
+			servo[0].SetPosition(20);
+			servo[1].SetPosition(160);
+			delay(tempo);
+
+			while(millis()<pause+8*t);
+
+}
+
+void lateral_fuerte(boolean side, int tempo){
+
+	for(int i=0;i<4;i++) servo[i].SetPosition(90);
+	if (side) servo[0].SetPosition(40);
+	else servo[1].SetPosition(140);
+	delay(tempo/2);
+	servo[0].SetPosition(90);
+	servo[1].SetPosition(90);
+	delay(tempo/2);

 }

 void primera_parte(){
-
-  int move1[4] = {60,120,90,90};
-  int move2[4] = {90,90,90,90};
-  int move3[4] = {40,140,90,90};
-
-  for(int x=0; x<3; x++){
-    for(int i=0; i<3; i++){
-      lateral_fuerte(1,t/2);
-      lateral_fuerte(0,t/4);
-      lateral_fuerte(1,t/4);
-      delay(t);
-    }
-
-    pause=millis();
-    for(int i=0;i<4;i++) servo[i].SetPosition(90);
-    moveNServos(t*0.4,move1);
-    moveNServos(t*0.4,move2);
-    while(millis()<(pause+t*2));
-  }
-
-  for(int i=0; i<2; i++){
-    lateral_fuerte(1,t/2);
-    lateral_fuerte(0,t/4);
-    lateral_fuerte(1,t/4);
-    delay(t);
-  }
-
-  pause=millis();
-  for(int i=0;i<4;i++) servo[i].SetPosition(90);
-  crusaito(1,t*1.4);
-  moveNServos(t*1,move3);
-  for(int i=0;i<4;i++) servo[i].SetPosition(90);
-  while(millis()<(pause+t*4));
+
+	int move1[4] = {60,120,90,90};
+	int move2[4] = {90,90,90,90};
+	int move3[4] = {40,140,90,90};
+
+	for(int x=0; x<3; x++){
+		for(int i=0; i<3; i++){
+			lateral_fuerte(1,t/2);
+			lateral_fuerte(0,t/4);
+			lateral_fuerte(1,t/4);
+			delay(t);
+		}
+
+		pause=millis();
+		for(int i=0;i<4;i++) servo[i].SetPosition(90);
+		moveNServos(t*0.4,move1);
+		moveNServos(t*0.4,move2);
+		while(millis()<(pause+t*2));
+	}
+
+	for(int i=0; i<2; i++){
+		lateral_fuerte(1,t/2);
+		lateral_fuerte(0,t/4);
+		lateral_fuerte(1,t/4);
+		delay(t);
+	}
+
+	pause=millis();
+	for(int i=0;i<4;i++) servo[i].SetPosition(90);
+	crusaito(1,t*1.4);
+	moveNServos(t*1,move3);
+	for(int i=0;i<4;i++) servo[i].SetPosition(90);
+	while(millis()<(pause+t*4));
 }

 void segunda_parte(){
-
-  int move1[4] = {90,90,80,100};
-  int move2[4] = {90,90,100,80};
-  int move3[4] = {90,90,80,100};
-  int move4[4] = {90,90,100,80};
-
-  int move5[4] = {40,140,80,100};
-  int move6[4] = {40,140,100,80};
-  int move7[4] = {90,90,80,100};
-  int move8[4] = {90,90,100,80};
-
-  int move9[4] = {40,140,80,100};
-  int move10[4] = {40,140,100,80};
-  int move11[4] = {90,90,80,100};
-  int move12[4] = {90,90,100,80};
-
-  for(int x=0; x<7; x++){
-    for(int i=0; i<3; i++){
-      pause=millis();
-      moveNServos(t*0.15,move1);
-      moveNServos(t*0.15,move2);
-      moveNServos(t*0.15,move3);
-      moveNServos(t*0.15,move4);
-      while(millis()<(pause+t));
-    }
-    pause=millis();
-    moveNServos(t*0.15,move5);
-    moveNServos(t*0.15,move6);
-    moveNServos(t*0.15,move7);
-    moveNServos(t*0.15,move8);
-    while(millis()<(pause+t));
-  }
+
+	int move1[4] = {90,90,80,100};
+	int move2[4] = {90,90,100,80};
+	int move3[4] = {90,90,80,100};
+	int move4[4] = {90,90,100,80};
+
+	int move5[4] = {40,140,80,100};
+	int move6[4] = {40,140,100,80};
+	int move7[4] = {90,90,80,100};
+	int move8[4] = {90,90,100,80};
+
+	int move9[4] = {40,140,80,100};
+	int move10[4] = {40,140,100,80};
+	int move11[4] = {90,90,80,100};
+	int move12[4] = {90,90,100,80};
+
+	for(int x=0; x<7; x++){
+		for(int i=0; i<3; i++){
+			pause=millis();
+			moveNServos(t*0.15,move1);
+			moveNServos(t*0.15,move2);
+			moveNServos(t*0.15,move3);
+			moveNServos(t*0.15,move4);
+			while(millis()<(pause+t));
+		}
+		pause=millis();
+		moveNServos(t*0.15,move5);
+		moveNServos(t*0.15,move6);
+		moveNServos(t*0.15,move7);
+		moveNServos(t*0.15,move8);
+		while(millis()<(pause+t));
+	}

-  for(int i=0; i<3; i++){
-    pause=millis();
-    moveNServos(t*0.15,move9);
-    moveNServos(t*0.15,move10);
-    moveNServos(t*0.15,move11);
-    moveNServos(t*0.15,move12);
-    while(millis()<(pause+t));
-  }
-}
-
-void lateral_fuerte(boolean side, int tempo){
-
-  for(int i=0;i<4;i++) servo[i].SetPosition(90);
-  if (side) servo[0].SetPosition(40);
-  else servo[1].SetPosition(140);
-  delay(tempo/2);
-  servo[0].SetPosition(90);
-  servo[1].SetPosition(90);
-  delay(tempo/2);
-
+	for(int i=0; i<3; i++){
+		pause=millis();
+		moveNServos(t*0.15,move9);
+		moveNServos(t*0.15,move10);
+		moveNServos(t*0.15,move11);
+		moveNServos(t*0.15,move12);
+		while(millis()<(pause+t));
+	}
 }

 void drunk (int tempo){
-
-  pause=millis();
-
-  int move1[] = {60,70,90,90};
-  int move2[] = {110,120,90,90};
-  int move3[] = {60,70,90,90};
-  int move4[] = {110,120,90,90};
-
-  moveNServos(tempo*0.235,move1);
-  moveNServos(tempo*0.235,move2);
-  moveNServos(tempo*0.235,move3);
-  moveNServos(tempo*0.235,move4);
-  while(millis()<(pause+tempo));
+
+	pause=millis();
+
+	int move1[] = {60,70,90,90};
+	int move2[] = {110,120,90,90};
+	int move3[] = {60,70,90,90};
+	int move4[] = {110,120,90,90};
+
+	moveNServos(tempo*0.235,move1);
+	moveNServos(tempo*0.235,move2);
+	moveNServos(tempo*0.235,move3);
+	moveNServos(tempo*0.235,move4);
+	while(millis()<(pause+tempo));

 }

 void noGravity(int tempo){
-
-  int move1[4] = {120,140,90,90};
-  int move2[4] = {140,140,90,90};
-  int move3[4] = {120,140,90,90};
-  int move4[4] = {90,90,90,90};
-
-
-  for(int i=0;i<4;i++) servo[i].SetPosition(90);
-  for(int i=0;i<N_SERVOS;i++) oldPosition[i]=90;
-  moveNServos(tempo*2,move1);
-  moveNServos(tempo*2,move2);
-  delay(tempo*2);
-  moveNServos(tempo*2,move3);
-  moveNServos(tempo*2,move4);
+
+	int move1[4] = {120,140,90,90};
+	int move2[4] = {140,140,90,90};
+	int move3[4] = {120,140,90,90};
+	int move4[4] = {90,90,90,90};
+
+
+	for(int i=0;i<4;i++) servo[i].SetPosition(90);
+	for(int i=0;i<N_SERVOS;i++) oldPosition[i]=90;
+	moveNServos(tempo*2,move1);
+	moveNServos(tempo*2,move2);
+	delay(tempo*2);
+	moveNServos(tempo*2,move3);
+	moveNServos(tempo*2,move4);

 }

 void kickLeft(int tempo){
-  for(int i=0;i<4;i++) servo[i].SetPosition(90);
-  delay(tempo);
-  servo[0].SetPosition(50); //pie derecho
-  servo[1].SetPosition(70); //pie izquiero
-  delay(tempo);
-  servo[0].SetPosition(80); //pie derecho
-  servo[1].SetPosition(70); //pie izquiero
-  delay(tempo/4);
-  servo[0].SetPosition(30); //pie derecho
-  servo[1].SetPosition(70); //pie izquiero
-  delay(tempo/4);
-  servo[0].SetPosition(80); //pie derecho
-  servo[1].SetPosition(70); //pie izquiero
-  delay(tempo/4);
-  servo[0].SetPosition(30); //pie derecho
-  servo[1].SetPosition(70); //pie izquiero
-  delay(tempo/4);
-  servo[0].SetPosition(80); //pie derecho
-  servo[1].SetPosition(70); //pie izquiero
-  delay(tempo);
+	for(int i=0;i<4;i++) servo[i].SetPosition(90);
+	delay(tempo);
+	servo[0].SetPosition(50); //pie derecho
+	servo[1].SetPosition(70); //pie izquiero
+	delay(tempo);
+	servo[0].SetPosition(80); //pie derecho
+	servo[1].SetPosition(70); //pie izquiero
+	delay(tempo/4);
+	servo[0].SetPosition(30); //pie derecho
+	servo[1].SetPosition(70); //pie izquiero
+	delay(tempo/4);
+	servo[0].SetPosition(80); //pie derecho
+	servo[1].SetPosition(70); //pie izquiero
+	delay(tempo/4);
+	servo[0].SetPosition(30); //pie derecho
+	servo[1].SetPosition(70); //pie izquiero
+	delay(tempo/4);
+	servo[0].SetPosition(80); //pie derecho
+	servo[1].SetPosition(70); //pie izquiero
+	delay(tempo);
 }

 void kickRight(int tempo){
 for(int i=0;i<4;i++) servo[i].SetPosition(90);
-  delay(tempo);
-  servo[0].SetPosition(110); //pie derecho
-  servo[1].SetPosition(130); //pie izquiero
-  delay(tempo);
-  servo[0].SetPosition(110); //pie derecho
-  servo[1].SetPosition(100); //pie izquiero
-  delay(tempo/4);
-  servo[0].SetPosition(110); //pie derecho
-  servo[1].SetPosition(150); //pie izquiero
-  delay(tempo/4);
-  servo[0].SetPosition(110); //pie derecho
-  servo[1].SetPosition(80); //pie izquiero
-  delay(tempo/4);
-  servo[0].SetPosition(110); //pie derecho
-  servo[1].SetPosition(150); //pie izquiero
-  delay(tempo/4);
-  servo[0].SetPosition(110); //pie derecho
-  servo[1].SetPosition(100); //pie izquiero
-  delay(tempo);
+	delay(tempo);
+	servo[0].SetPosition(110); //pie derecho
+	servo[1].SetPosition(130); //pie izquiero
+	delay(tempo);
+	servo[0].SetPosition(110); //pie derecho
+	servo[1].SetPosition(100); //pie izquiero
+	delay(tempo/4);
+	servo[0].SetPosition(110); //pie derecho
+	servo[1].SetPosition(150); //pie izquiero
+	delay(tempo/4);
+	servo[0].SetPosition(110); //pie derecho
+	servo[1].SetPosition(80); //pie izquiero
+	delay(tempo/4);
+	servo[0].SetPosition(110); //pie derecho
+	servo[1].SetPosition(150); //pie izquiero
+	delay(tempo/4);
+	servo[0].SetPosition(110); //pie derecho
+	servo[1].SetPosition(100); //pie izquiero
+	delay(tempo);
 }

 void walk(int steps, int T){
-    int A[4]= {15, 15, 30, 30};
-    int O[4] = {0, 0, 0, 0};
-    double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(90), DEG2RAD(90)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+		int A[4]= {15, 15, 30, 30};
+		int O[4] = {0, 0, 0, 0};
+		double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(90), DEG2RAD(90)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
 }

 void run(int steps, int T){
-    int A[4]= {10, 10, 10, 10};
-    int O[4] = {0, 0, 0, 0};
-    double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(90), DEG2RAD(90)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+		int A[4]= {10, 10, 10, 10};
+		int O[4] = {0, 0, 0, 0};
+		double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(90), DEG2RAD(90)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
 }

 void backyard(int steps, int T){
-    int A[4]= {15, 15, 30, 30};
-    int O[4] = {0, 0, 0, 0};
-    double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(-90), DEG2RAD(-90)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+		int A[4]= {15, 15, 30, 30};
+		int O[4] = {0, 0, 0, 0};
+		double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(-90), DEG2RAD(-90)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
 }

 void backyardSlow(int steps, int T){
-    int A[4]= {15, 15, 30, 30};
-    int O[4] = {0, 0, 0, 0};
-    double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(-90), DEG2RAD(-90)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+		int A[4]= {15, 15, 30, 30};
+		int O[4] = {0, 0, 0, 0};
+		double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(-90), DEG2RAD(-90)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
 }

 void turnLeft(int steps, int T){
-    int A[4]= {20, 20, 10, 30};
-    int O[4] = {0, 0, 0, 0};
-    double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(90), DEG2RAD(90)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+		int A[4]= {20, 20, 10, 30};
+		int O[4] = {0, 0, 0, 0};
+		double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(90), DEG2RAD(90)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
 }

 void turnRight(int steps, int T){
-    int A[4]= {20, 20, 30, 10};
-    int O[4] = {0, 0, 0, 0};
-    double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(90), DEG2RAD(90)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+		int A[4]= {20, 20, 30, 10};
+		int O[4] = {0, 0, 0, 0};
+		double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(90), DEG2RAD(90)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
 }

 void moonWalkRight(int steps, int T){
-    int A[4]= {25, 25, 0, 0};
-    int O[4] = {-15 ,15, 0, 0};
-    double phase_diff[4] = {DEG2RAD(0), DEG2RAD(180 + 120), DEG2RAD(90), DEG2RAD(90)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+		int A[4]= {25, 25, 0, 0};
+		int O[4] = {-15 ,15, 0, 0};
+		double phase_diff[4] = {DEG2RAD(0), DEG2RAD(180 + 120), DEG2RAD(90), DEG2RAD(90)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
 }

 void moonWalkLeft(int steps, int T){
-    int A[4]= {25, 25, 0, 0};
-    int O[4] = {-15, 15, 0, 0};
-    double phase_diff[4] = {DEG2RAD(0), DEG2RAD(180 - 120), DEG2RAD(90), DEG2RAD(90)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+		int A[4]= {25, 25, 0, 0};
+		int O[4] = {-15, 15, 0, 0};
+		double phase_diff[4] = {DEG2RAD(0), DEG2RAD(180 - 120), DEG2RAD(90), DEG2RAD(90)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
 }

 void crusaito(int steps, int T){
-    int A[4]= {25, 25, 30, 30};
-    int O[4] = {- 15, 15, 0, 0};
-    double phase_diff[4] = {DEG2RAD(0), DEG2RAD(180 + 120), DEG2RAD(90), DEG2RAD(90)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+		int A[4]= {25, 25, 30, 30};
+		int O[4] = {- 15, 15, 0, 0};
+		double phase_diff[4] = {DEG2RAD(0), DEG2RAD(180 + 120), DEG2RAD(90), DEG2RAD(90)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
 }

 void swing(int steps, int T){
-    int A[4]= {25, 25, 0, 0};
-    int O[4] = {-15, 15, 0, 0};
-    double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(90), DEG2RAD(90)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+		int A[4]= {25, 25, 0, 0};
+		int O[4] = {-15, 15, 0, 0};
+		double phase_diff[4] = {DEG2RAD(0), DEG2RAD(0), DEG2RAD(90), DEG2RAD(90)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
 }

 void upDown(int steps, int T){
-    int A[4]= {25, 25, 0, 0};
-    int O[4] = {-15, 15, 0, 0};
-    double phase_diff[4] = {DEG2RAD(180), DEG2RAD(0), DEG2RAD(270), DEG2RAD(270)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+		int A[4]= {25, 25, 0, 0};
+		int O[4] = {-15, 15, 0, 0};
+		double phase_diff[4] = {DEG2RAD(180), DEG2RAD(0), DEG2RAD(270), DEG2RAD(270)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
 }

 void flapping(int steps, int T){
-    int A[4]= {15, 15, 8, 8};
-    int O[4] = {-A[0], A[1], 0, 0};
-    double phase_diff[4] = {DEG2RAD(0), DEG2RAD(180), DEG2RAD(90), DEG2RAD(-90)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+		int A[4]= {15, 15, 8, 8};
+		int O[4] = {-A[0], A[1], 0, 0};
+		double phase_diff[4] = {DEG2RAD(0), DEG2RAD(180), DEG2RAD(90), DEG2RAD(-90)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
 }

 void test(int steps, int T){
-    int A[4]= {15, 15, 8, 8};
-    int O[4] = {-A[0] + 10, A[1] - 10, 0, 0};
-    double phase_diff[4] = {DEG2RAD(0), DEG2RAD(180), DEG2RAD(90), DEG2RAD(-90)};
-
-    for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
-}
+		int A[4]= {15, 15, 8, 8};
+		int O[4] = {-A[0] + 10, A[1] - 10, 0, 0};
+		double phase_diff[4] = {DEG2RAD(0), DEG2RAD(180), DEG2RAD(90), DEG2RAD(-90)};
+
+		for(int i=0;i<steps;i++)oscillate(A,O, T, phase_diff);
+}


Increase initial delay

Increase initial delay

--- Node/Node.ino
+++ Node/Node.ino
@@ -42,7 +42,7 @@

   Serial.begin(9600);

-  delay(1000);
+  delay(3000);
   Serial.println("Starting up");

   Wire.begin();


code debug and request improvements

code debug and request improvements

--- src-arduino/arduair-mega-wifi-shield-DS1307-allSensors/arduair-mega-wifi-shield-DS1307-allSensors.ino
+++ src-arduino/arduair-mega-wifi-shield-DS1307-allSensors/arduair-mega-wifi-shield-DS1307-allSensors.ino
@@ -1,4 +1,4 @@
-  /******************************************************************************
+/******************************************************************************
 Arduair project
 Fabian Gutierrez @ Universidad Pontificia Bolivariana
 https://github.com/fega/arduair
@@ -35,18 +35,21 @@
 #include <SFE_BMP180.h>//Sparkfun BMP180 pressure Sensor Library
 #include <SparkFunTSL2561.h>//light sensor library SparkFun TSL2561 Breakout
 #include <WiFi.h>      //wifi shield Library
-#define DEVMODE true
+#define DEVMODE true  //uncomment to get Serial ouput
 //Default configuration
 #define RED_LED_PIN 2
 #define GREEN_LED_PIN 3
+#define YELLOW_LED_PIN 13
 #define DS1307_ADDRESS 0x68 //clock ADRESS
+#define WIFIPIN 4
 #define DHTPIN 5
-#define DHTTYPE DHT22  //dht type
-#define WIFIPIN 4
-#define SDPIN 10
 #define SHINYEI_P1 8
 #define SHINYEI_P2 9
-#define CO  1 //
+#define SDPIN 10
+#define CONFIGPIN 23
+#define DHTTYPE DHT22  //dht type
+
+#define CO  1 //Ze sensors serials
 #define NO2 2
 #define SO2 3

@@ -60,7 +63,7 @@
 //Wifi and device config
 char ssid[20]; //  your network SSID (name)
 char pass[20];    // your network password (use for WPA, or use as key for WEP)
-char server[20];
+char server[25];
 char device[20];
 char password[20];
 bool wifi = true;
@@ -76,23 +79,25 @@
  * Arduair configuration initialization
  */
 void setup() {
-
   digitalWrite(GREEN_LED_PIN,HIGH); // Setup Light On
+  pinMode(CONFIGPIN,INPUT);//check config button
+  int config = digitalRead(CONFIGPIN);
+
+  #if defined(DEVMODE)
+    Serial.begin(9600);
+    if (digitalRead(CONFIGPIN)==HIGH) Serial.println("CONFIG PIN: HIGH");
+  #endif
+
   getDate(DS1307_ADDRESS);
   sdBegin();
-  #if defined(DEVMODE)
-  Serial.begin(9600);
   arduairSetup();
-  #endif
-  Serial1.begin(9600); //ZE CO-sensor
-  Serial2.begin(9600); //ZE NO2-sensor
-  Serial3.begin(9600); //ZE SO2-sensor
+  if (wifi){wifiBegin();}
+  if (config==HIGH) requestConfig();
+
   Wire.begin();
   dht.begin();
   bmp.begin();
   light.begin();
-
-  if (wifi){wifiBegin();}
   winsenBegin();
   digitalWrite(GREEN_LED_PIN,LOW); // Setup Light Off
 }
@@ -134,6 +139,8 @@
  if (client.connect(server, 80)) {
    #if defined(DEVMODE)
    Serial.println("connecting...");
+   Serial.print("GET "); Serial.print("/"); Serial.print(device); Serial.print("/"); Serial.print(password);
+   Serial.print(monthDay); Serial.print(month);Serial.print(year); Serial.print(hour);Serial.print(minute);
    #endif
    //String getRequest ="GET"+"hola"+" "
    // send the HTTP GET request:
@@ -162,8 +169,29 @@
    #if defined(DEVMODE)
    Serial.println("Request done");
    #endif
- }
- }
+ }else{
+  #if defined(DEVMODE)
+  Serial.println("Conecction fail");
+   #endif
+ }
+ #if defined(DEVMODE)
+ int timeout = millis() + 20000;
+  while (client.available() == 0) {
+   if (timeout - millis() < 0) {
+     #if defined(DEVMODE)
+     Serial.println("client Timeout !");
+     #endif
+     client.stop();
+     warn();
+     log("client Timeout !");
+   }
+ }
+ while(client.available()) {
+   String response=client.readStringUntil('}');
+     Serial.println(response);
+ }
+ #endif
+}
 /**
  * Writes the data in the SD.
  * This function act in the following form: first, inactive the wifi-shield
@@ -172,14 +200,10 @@
  */
 void tableWrite(){
   //write data in SD
-  digitalWrite(WIFIPIN,HIGH); //inactive wifi-shield
-  digitalWrite(SDPIN,LOW); //active SD
-
   myFile = SD.open("DATA.txt", FILE_WRITE); //open SD data.txt file

   if (myFile){
     //write ISO date ex: 1994-11-05T08:15:30-05:00
-
     // myFile.print(year);myFile.print("-");
     // myFile.print(month);myFile.print("-");
     // myFile.print(monthDay);myFile.print("T");
@@ -209,8 +233,6 @@
     myFile.println(" ");
     myFile.close();
   }
-  digitalWrite(WIFIPIN,LOW); //active wifishield
-  digitalWrite(SDPIN,HIGH); //inactive SD

 }
 /**
@@ -237,8 +259,6 @@
   #if defined(DEVMODE)
   Serial.println("Started  PM read");
   #endif
-
-

   unsigned long triggerOnP10, triggerOffP10, pulseLengthP10, durationP10;
   boolean P10 = HIGH, triggerP10 = false;
@@ -299,10 +319,9 @@
   pm25 = concSmall;

   #if defined(DEVMODE)
-  Serial.println("Ended  PM read");
-  Serial.print("PM 10: ");
+  Serial.print("  PM 10: ");
   Serial.println(pm10);
-  Serial.print("PM 2.5: ");
+  Serial.print("  PM 2.5: ");
   Serial.println(pm25);
   #endif
 }
@@ -436,6 +455,16 @@
   monthDay = bcdToDec(Wire.read());
   month = bcdToDec(Wire.read());
   year = bcdToDec(Wire.read());
+
+  #if defined(DEVMODE)
+    Serial.print(year);    Serial.print("-");
+    Serial.print(month);   Serial.print("-");
+    Serial.print(monthDay);Serial.print("T");
+    Serial.print(hour);    Serial.print(":");
+    Serial.print(minute);  Serial.print(":");
+    Serial.print(second);
+    Serial.print("+5:00,   ");
+  #endif
 }
 /**
  * SD card begin function
@@ -459,13 +488,13 @@
   h = humidityRead();
   t = temperatureRead();
   #if defined(DEVMODE)
-  Serial.print("p: ");
+  Serial.print("  p: ");
   Serial.println(p);
-  Serial.print("l: ");
+  Serial.print("  l: ");
   Serial.println(l);
-  Serial.print("h: ");
+  Serial.print("  h: ");
   Serial.println(h);
-  Serial.print("t: ");
+  Serial.print("  t: ");
   Serial.println(t);
   #endif
 }
@@ -474,8 +503,9 @@
  */
 void arduairSetup(){
  #if defined(DEVMODE)
- Serial.println("Applying Settings...");
+ Serial.println("start arduairSetup...");
  #endif
+
  char character;
  String settingName;
  String settingValue;
@@ -499,10 +529,9 @@
       if(character == ']'){

       #if defined(DEVMODE)
-      //Debuuging Printing
-      Serial.print("Name:");
-      Serial.println(settingName);
-      Serial.print("Value :");
+      Serial.print("  ");
+      Serial.print(settingName);
+      Serial.print(": ");
       Serial.println(settingValue);
       #endif

@@ -536,19 +565,21 @@
 */
 void applySetting(String settingName, String settingValue) {
   if (settingName=="network"){
-    settingValue.toCharArray(ssid,20);
+    settingValue.toCharArray(ssid,20);
   }
   if (settingName=="networkpass"){
     settingValue.toCharArray(pass,20);
   }
   if (settingName=="server"){
-    settingValue.toCharArray(server,20);
-  }
-  if (settingName="device"){
+    settingValue.toCharArray(server,25);
+    Serial.println(server);
+  }
+  if (settingName=="device"){
     settingValue.toCharArray(device,20);
   }
   if (settingName=="password"){
     settingValue.toCharArray(password,20);
+    Serial.println(password);
   }
   if (settingName=="wifi"){
     wifi==toBoolean(settingValue);
@@ -605,8 +636,6 @@
  * This function begins wifi connection
  */
 void wifiBegin(){
-    digitalWrite(WIFIPIN,HIGH); //active wifishield
-    digitalWrite(SDPIN,LOW); //inactive SD
     // check for the presence of the shield:
     if (WiFi.status() == WL_NO_SHIELD) {
     #if defined(DEVMODE)
@@ -643,7 +672,10 @@
  */
 void winsenBegin(){
   #if defined(DEVMODE)
-  Serial.println("disabling sensors");
+  //Serial.println("disabling sensors");
+  Serial1.begin(9600); //ZE CO-sensor
+  Serial2.begin(9600); //ZE NO2-sensor
+  Serial3.begin(9600); //ZE SO2-sensor
   #endif
   byte message[] = {0xFF,0x01, 0x78, 0x04, 0x00, 0x00, 0x00, 0x00, 0x83};//TODO: change bye array to "manual form"
   Serial1.write(message,sizeof(message));
@@ -667,10 +699,8 @@
  */
 void winsenRead(int cont){
   #if defined(DEVMODE)
-  Serial.println("Winsen Sensor Reading");
-  #endif
-
-
+  //Serial.println("Winsen Sensor Reading");
+  #endif

   byte message[] = {0xFF,0x01, 0x78, 0x03, 0x00, 0x00, 0x00, 0x00, 0x84};
   unsigned long sampletime_ms = 30000;
@@ -691,7 +721,7 @@
           ppm = measure[2]*256+measure[3];
           co=ppm;
           #if defined(DEVMODE)
-          Serial.print("[CO]: ");
+          Serial.print("  [CO]:  ");
           Serial.println(ppm);
           #endif

@@ -714,7 +744,7 @@
           no2=ppm;

           #if defined(DEVMODE)
-          Serial.print("[NO2]: ");
+          Serial.print("  [NO2]: ");
           Serial.println(ppm);
           #endif
         }else{
@@ -736,7 +766,7 @@
         so2=ppm;

         #if defined(DEVMODE)
-        Serial.print("[SO2]: ");
+        Serial.print("  [SO2]: ");
         Serial.println(ppm);
         #endif
       }else{
@@ -785,14 +815,72 @@
   }
  }
 /**
+ * request config file from server and update it
+ */
+void requestConfig(){
+  String config;
+  #if defined(DEVMODE)
+  Serial.println("Resquesting Config file");
+  #endif
+  client.stop();
+  Serial.println(device);
+  Serial.println(password);
+  Serial.println(server);
+  if (client.connect(server, 80)) {
+    client.print("GET ");
+    client.print("/"); client.print(device);
+    client.print("/"); client.print(password);
+    client.print("/");
+    //http GET end
+    client.print(" HTTP/1.1");
+    client.println("");
+    client.println("");
+    //server
+    client.print("Host: ");client.print(server);
+    client.println("User-Agent: Arduair");
+       client.println("Connection: close");
+    #if defined(DEVMODE)
+    Serial.println("Request done");
+    #endif
+  } else {
+    #if defined(DEVMODE)
+    Serial.println("connection failed");
+    #endif
+    warn();
+  }
+  int timeout = millis() + 20000;
+  while (client.available() == 0) {
+   if (timeout - millis() < 0) {
+     #if defined(DEVMODE)
+     Serial.println("client Timeout !");
+     #endif
+     client.stop();
+     warn();
+     log("client Timeout !");
+   }
+ }
+ while(client.available()) {
+   config=client.readStringUntil('\r');
+   #if defined(DEVMODE)
+     Serial.println(config);
+   #endif
+ }
+ //write config
+  SD.remove("CONFIG.txt");
+  myFile = SD.open("CONFIG.txt", FILE_WRITE); //open SD data.txt file
+  if (myFile){
+    myFile.print(config);
+    myFile.close();
+  }
+  arduairSetup();
+}
+/**
  * Log function, it writes a message in a log file.
  * @param message Message to be
  */
 void log(String message){
-  digitalWrite(WIFIPIN,HIGH); //inactive wifi-shield
-  digitalWrite(SDPIN,LOW); //active SD
-
-
+
+  myFile = SD.open("LOG.txt", FILE_WRITE); //open SD data.txt file
   if (myFile){
     //write ISO date ex: 1994-11-05T08:15:30-05:00
     myFile.print(year);myFile.print("-");
@@ -808,9 +896,6 @@
     myFile.println(" ");
     myFile.close();
   }
-  digitalWrite(WIFIPIN,LOW); //active wifishield
-  digitalWrite(SDPIN,HIGH); //inactive SD
-
 }
 /**
  * turn the warning light on


Entropy is now 4 bytes and use only three colors at startup

--- firmware/node/node.ino
+++ firmware/node/node.ino
@@ -6,7 +6,7 @@
 #include <avr/pgmspace.h>
 #include "parse.h"

-const uint8_t NAX_NODES = 120;
+const uint8_t MAX_NODES = 120;
 const uint8_t NUM_PIXELS = 4;
 const uint8_t OUT_PIN = 2;
 const uint8_t US_PER_TICK = 25;
@@ -203,9 +203,9 @@
     uint8_t   *data;

     target = packet[0];
-    if (target > NAX_NODES + 1)
-    {
-        uint8_t cls = target - (NAX_NODES + 1), i;
+    if (target > MAX_NODES + 1)
+    {
+        uint8_t cls = target - (MAX_NODES + 1), i;

         for(i = 0; i < NUM_CLASSES; i++)
             if (g_classes[i] == cls)
@@ -301,12 +301,9 @@
             {
                 color_t col;

-                g_random_seed = data[0];
+                g_random_seed = *(int32_t *)data;
                 randomSeed(g_random_seed);
-
-                col.c[0] = col.c[2] = 0;
-                col.c[1] = 180;
-                show_color(&col);
+                show_color(NULL);
             }
             break;

@@ -320,14 +317,9 @@

         case PACKET_POSITION:
         {
-            color_t col;
             g_pos[0] = *(uint16_t *)data;
             g_pos[1] = *(uint16_t *)(&data[2]);
             g_pos[2] = *(uint16_t *)(&data[4]);
-
-            col.c[0] = col.c[1] = 0;
-            col.c[2] = 180;
-            show_color(&col);
             break;
         }
         case PACKET_CLASSES:
@@ -535,6 +527,7 @@
 void setup()
 {
     uint32_t timer_cal;
+    color_t col;

     Serial.begin(38400);
     Serial.println("hue-chandelier board!");
@@ -548,7 +541,24 @@
     {
         g_ticks_per_sec = timer_cal;
         Serial.print("calibrated ");
-    }
+        col.c[0] = 0;
+        col.c[1] = 128;
+        col.c[2] = 0;
+    }
+    else
+    {
+        col.c[0] = 0;
+        col.c[1] = 0;
+        col.c[2] = 128;
+    }
+    if (g_node_id == 0 || g_node_id >= MAX_NODES)
+    {
+        col.c[0] = 128;
+        col.c[1] = 0;
+        col.c[2] = 0;
+    }
+    show_color(&col);
+
     Serial.println("node " + String(g_node_id) + " ready. ");

     g_ticks_per_frame = g_ticks_per_sec * g_delay / 1000;


Change the yellow to be more orange

Change the yellow to be more orange


Updating main comment

Updating main comment

--- WallClock.ino
+++ WallClock.ino
@@ -1,18 +1,16 @@
 /*
- * TwoLeds – this example demonstrates using RotaryEncoder with a button.
+ * WallClock
  *
- * Dependencies for the library:
- * http://www.pjrc.com/teensy/td_libs_Encoder.html
+ * 7-Segment Display for current time, based on the RTC chip.
  *
- * Dependencies for the example:
+ * Rotary encoder is used to set the time.
  *
- * RotaryEncoderWithButton library
- * SimpleTimer library
+ * Press and hold to enter configuration menu, then click to advance
+ * to the next.
  *
- *  Created on: Aug 9, 2014
- *      Author: Konstantin Gredeskoul
+ * (c) 2014 All rights reserved.  Please see LICENSE.
  *
- *  (c) 2014 All rights reserved.  Please see LICENSE.
+ * Author: Konstantin Gredeskoul <kigster@gmail.com>
  */

 #include <RotaryEncoderWithButton.h>


Updatet ble_HID_template_HID_HRM

Updatet ble_HID_template_HID_HRM

--- libraries/BLE/examples/ble_HID_template_HID_HRM/ble_HID_template_HID_HRM.ino
+++ libraries/BLE/examples/ble_HID_template_HID_HRM/ble_HID_template_HID_HRM.ino
@@ -310,37 +310,48 @@

             case ACI_DEVICE_STANDBY:
               Serial.println(F("Evt Device Started: Standby"));
-              //Manage the bond in EEPROM of the AVR
+              if (aci_evt->params.device_started.hw_error)
               {
-                uint8_t eeprom_status = 0;
-                eeprom_status = EEPROM.read(0);
-                if (eeprom_status != 0x00)
-                {
-                  Serial.println(F("Previous Bond present. Restoring"));
-                  //We must have lost power and restarted and must restore the bonding infromation using the ACI Write Dynamic Data
-                  if (ACI_STATUS_TRANSACTION_COMPLETE == bond_data_restore(&aci_state, eeprom_status, &bonded_first_time))
-                  {
-                    Serial.println(F("Bond restored successfully"));
-                  }
-                  else
-                  {
-                    Serial.println(F("Bond restore failed"));
-                  }
-                }
-              }
-
-              // Start bonding as all HID devices need to be bonded to be usable
-              if (ACI_BOND_STATUS_SUCCESS != aci_state.bonded)
-              {
-                lib_aci_connect(180/* in seconds */, 0x0050 /* advertising interval 50ms*/);
-                Serial.println(F("Advertising started : Waiting to be connected and bonded"));
+                delay(20); //Magic number used to make sure the HW error event is handled correctly.
               }
               else
-              {
-                //connect to an already bonded device
-                //Use lib_aci_direct_connect for faster re-connections
-                lib_aci_connect(10/* in seconds */, 0x0020 /* advertising interval 20ms*/);
-                Serial.println(F("Already bonded : Advertising started : Waiting to be connected"));
+              {
+                //Manage the bond in EEPROM of the AVR
+                {
+                  uint8_t eeprom_status = 0;
+                  eeprom_status = EEPROM.read(0);
+                  if (eeprom_status != 0x00)
+                  {
+                    Serial.println(F("Previous Bond present. Restoring"));
+                    Serial.println(F("Using existing bond stored in EEPROM."));
+                    Serial.println(F("   To delete the bond stored in EEPROM, connect Pin 6 to 3.3v and Reset."));
+                    Serial.println(F("   Make sure that the bond on the phone/PC is deleted as well."));
+                    //We must have lost power and restarted and must restore the bonding infromation using the ACI Write Dynamic Data
+                    if (ACI_STATUS_TRANSACTION_COMPLETE == bond_data_restore(&aci_state, eeprom_status, &bonded_first_time))
+                    {
+                      Serial.println(F("Bond restored successfully"));
+                    }
+                    else
+                    {
+                      Serial.println(F("Bond restore failed. Delete the bond and try again."));
+                    }
+                  }
+                }
+
+                // Start bonding as all proximity devices need to be bonded to be usable
+                if (ACI_BOND_STATUS_SUCCESS != aci_state.bonded)
+                {
+                  lib_aci_bond(180/* in seconds */, 0x0050 /* advertising interval 50ms*/);
+                  Serial.println(F("No Bond present in EEPROM."));
+                  Serial.println(F("Advertising started : Waiting to be connected and bonded"));
+                }
+                else
+                {
+                    //connect to an already bonded device
+                    //Use lib_aci_direct_connect for faster re-connections with PC, not recommended to use with iOS/OS X
+                    lib_aci_connect(100/* in seconds */, 0x0020 /* advertising interval 20ms*/);
+                    Serial.println(F("Already bonded : Advertising started : Waiting to be connected"));
+                }
               }
               break;
           }
@@ -357,15 +368,14 @@
           //TRANSACTION_CONTINUE and TRANSACTION_COMPLETE
           //all other ACI commands will have status code of ACI_STATUS_SCUCCESS for a successful command

-          Serial.print(F("ACI Status of ACI Evt Cmd Rsp 0x"));
-          Serial.println(aci_evt->params.cmd_rsp.cmd_status, HEX);
-          Serial.print(F("ACI Command 0x"));
-          Serial.println(aci_evt->params.cmd_rsp.cmd_opcode, HEX);
-          Serial.println(F("Evt Cmd respone: Error. Arduino is in an while(1); loop"));
-          while (1);
+          Serial.print(F("ACI Command "));
+          Serial.println(aci_evt->params.cmd_rsp.cmd_opcode, HEX);
+          Serial.print(F("Evt Cmd respone: Status "));
+          Serial.println(aci_evt->params.cmd_rsp.cmd_status, HEX);
         }
         if (ACI_CMD_GET_DEVICE_VERSION == aci_evt->params.cmd_rsp.cmd_opcode)
         {
+          //Store the version and configuration information of the nRF8001 in the Hardware Revision String Characteristic
           lib_aci_set_local_data(&aci_state, PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET,
                                  (uint8_t *)&(aci_evt->params.cmd_rsp.params.get_device_version),
                                  sizeof(aci_evt_cmd_rsp_params_get_device_version_t));
@@ -493,6 +503,54 @@
           }
         }
         Serial.println(F(""));
+        break;
+
+      case ACI_EVT_HW_ERROR:
+        Serial.print(F("HW error: "));
+        Serial.println(aci_evt->params.hw_error.line_num, DEC);
+
+        for(uint8_t counter = 0; counter <= (aci_evt->len - 3); counter++)
+        {
+        Serial.write(aci_evt->params.hw_error.file_name[counter]); //uint8_t file_name[20];
+        }
+        Serial.println();
+
+                //Manage the bond in EEPROM of the AVR
+                {
+                  uint8_t eeprom_status = 0;
+                  eeprom_status = EEPROM.read(0);
+                  if (eeprom_status != 0x00)
+                  {
+                    Serial.println(F("Previous Bond present. Restoring"));
+                    Serial.println(F("Using existing bond stored in EEPROM."));
+                    Serial.println(F("   To delete the bond stored in EEPROM, connect Pin 6 to 3.3v and Reset."));
+                    Serial.println(F("   Make sure that the bond on the phone/PC is deleted as well."));
+                    //We must have lost power and restarted and must restore the bonding infromation using the ACI Write Dynamic Data
+                    if (ACI_STATUS_TRANSACTION_COMPLETE == bond_data_restore(&aci_state, eeprom_status, &bonded_first_time))
+                    {
+                      Serial.println(F("Bond restored successfully"));
+                    }
+                    else
+                    {
+                      Serial.println(F("Bond restore failed. Delete the bond and try again."));
+                    }
+                  }
+                }
+
+                // Start bonding as all proximity devices need to be bonded to be usable
+                if (ACI_BOND_STATUS_SUCCESS != aci_state.bonded)
+                {
+                  lib_aci_bond(180/* in seconds */, 0x0050 /* advertising interval 50ms*/);
+                  Serial.println(F("No Bond present in EEPROM."));
+                  Serial.println(F("Advertising started : Waiting to be connected and bonded"));
+                }
+                else
+                {
+                    //connect to an already bonded device
+                    //Use lib_aci_direct_connect for faster re-connections with PC, not recommended to use with iOS/OS X
+                    lib_aci_connect(100/* in seconds */, 0x0020 /* advertising interval 20ms*/);
+                    Serial.println(F("Already bonded : Advertising started : Waiting to be connected"));
+                }
         break;
     }
   }


Playing around.

Playing around.

--- Tests/FSM/FSM.ino
+++ Tests/FSM/FSM.ino
@@ -11,7 +11,7 @@
 const int BUTTON_PIN = 8;
 const int SPEAKER_PIN = 7; // Status speaker, resistor?
 const int ULTRA_SOUND_PIN = 6;
-const int GALV_PIN = 10;
+const int GALV_PIN = A1;

 // Constants for servo
 Servo servoRight;
@@ -118,8 +118,6 @@

   } else if (currentState == 3) {
-    irDistLeft = irDistance(IR_LED_PIN_LEFT, IR_REC_PIN_LEFT);         // Measure distance
-    irDistRight = irDistance(IR_LED_PIN_RIGHT, IR_REC_PIN_RIGHT);

   //Serial.print(irDistLeft);
   //Serial.print("  ");
@@ -128,10 +126,13 @@
   if (foundCylinder) {
     stopMovement();
   } else {
+  irDistLeft = irDistance(IR_LED_PIN_LEFT, IR_REC_PIN_LEFT);         // Measure distance
+  irDistRight = irDistance(IR_LED_PIN_RIGHT, IR_REC_PIN_RIGHT);
   galvReading = digitalRead(GALV_PIN);
   if (galvReading == HIGH) {
     foundCylinder = true;
-    //Serial.println("Galv!");
+    stopMovement();
+    Serial.println("Galv!");
   } else if (irDistLeft < 0.8) {
     turnLeft();
   } else if (irDistRight < 0.8) {