9600 for example

9600 for example

--- examples/ReadTag/ReadTag.ino
+++ examples/ReadTag/ReadTag.ino
@@ -5,7 +5,7 @@
 NfcAdapter nfc = NfcAdapter();

 void setup(void) {
-    Serial.begin(115200);
+    Serial.begin(9600);
     Serial.println("NDEF Reader");
     nfc.begin();
 }


Saving ram with shorter strings; added ping

--- battlestation/arduino/arduino.ino
+++ battlestation/arduino/arduino.ino
@@ -68,7 +68,7 @@
     if (c == '\n') {
       exec_cmd();
     } else {
-      Serial.println("command too long");
+      Serial.println  ("command too long");
     }

     // Done executing or buffer is full before newline
@@ -79,53 +79,57 @@
 }

 void exec_cmd() {
+  boolean ok = false;
   char * tok = NULL;
   const char * cmd_name = strtok_r(cmd, " ", &tok);
-  if (strcmp(cmd, "strip") == 0) {
-    exec_strip(tok);
-  } else if (strcmp(cmd, "flash") == 0) {
-    exec_flash(tok);
-  } else if (strcmp(cmd, "help") == 0) {
-    Serial.println("strip <strip_num> <team_num> <leds> <team_num> <leds> <team_num> <leds>");
-    Serial.println("flash <strip_num>");
-    Serial.println("help");
+  if (cmd_name[0] == 's') {
+    ok = exec_score(tok);
+  } else if (cmd_name[0] == 'f') {
+    ok = exec_flash(tok);
+  } else if (cmd_name[0] == 'p') {
+    // the "ok" is the result
+    ok = true;
+  } else if (cmd_name[0] == 'h') {
+    Serial.println("f(lash) s");
+    Serial.println("h(elp)");
+    Serial.println("s(core) s t # t # t #");
+    Serial.println("p(ing)");
+    ok = true;
+  }
+
+  if (ok) {
+    Serial.println("ok");
   } else {
-    Serial.print("unknown command: ");
-    Serial.println(cmd);
-  }
+    Serial.println("err");
+  }
 }

-void usage(const char * usage) {
-  Serial.print("usage: ");
-  Serial.println(usage);
-}
-
-void exec_flash(char * tok) {
+boolean exec_flash(char * tok) {
   // Read strip number
   char * arg = strtok_r(NULL, " ", &tok);
   if (arg == NULL) {
-    Serial.println("strip number is required");
-    return;
+    Serial.println("strip required");
+    return false;
   }
   int strip = atoi(arg);
   if (strip > 3) {
-    Serial.println("strip number is one of 0,1,2,3");
-    return;
+    Serial.println("strip is 0,1,2,3");
+    return false;
   }
-  flash(*score_strips[strip], Adafruit_NeoPixel::Color(255, 255, 0), 10, 100);
+  flash(*score_strips[strip], Adafruit_NeoPixel::Color(255, 255, 0), 5, 80);
 }

-void exec_strip(char * tok) {
+boolean exec_score(char * tok) {
   // Read strip number
   char * arg = strtok_r(NULL, " ", &tok);
   if (arg == NULL) {
-    Serial.println("strip number is required");
-    return;
+    Serial.println("strip required");
+    return false;
   }
   int strip = atoi(arg);
   if (strip > 3) {
-    Serial.println("strip number is one of 0,1,2,3");
-    return;
+    Serial.println("strip is 0,1,2,3");
+    return false;
   }

   byte led = 0;
@@ -134,20 +138,20 @@
     // Read the team
     arg = strtok_r(NULL, " ", &tok);
     if (arg == NULL) {
-      Serial.println("team number is required");
-      return;
+      Serial.println("team required");
+      return false;
     }
     int team = atoi(arg);
     if (team > 2) {
-      Serial.println("team number is one of 0,1,2");
-      return;
+      Serial.println("team is 0,1,2");
+      return false;
     }

     // Read the LED count
     arg = strtok_r(NULL, " ", &tok);
     if (arg == NULL) {
-      Serial.println("led count is required");
-      return;
+      Serial.println("led # required");
+      return false;
     }
     int team_leds = atoi(arg);

@@ -163,6 +167,7 @@
     score_strips[strip]->setPixelColor(l, 0, 0, 0);
   }
   score_strips[strip]->show();
+  return true;
 }

 void flash(Adafruit_NeoPixel & strip, uint32_t color, byte times, unsigned long delay_ms) {


Delete sensorflare-pwm.ino

Delete sensorflare-pwm.ino

--- examples/sensorflare-pwm.ino
+++ examples/sensorflare-pwm.ino
@@ -1,17 +0,0 @@
-//Include the SensorFlare library
-#include "sensorflare.h"
-
-//Initialize objects from the library
-//One object of the class "PWMOut" is initialized for
-//every PWM output that will be remote control
-SensorFlare::PWMOut pwm(A0);
-
-void setup() {
-// Call the begin() functions for every object of the classes "DigitalOut" and
-//"PWMout" to be wired up correct and available.
-    pwm.begin();
-}
-
-void loop() {
-
-}


Add dependency information

Add dependency information

Thanks for the suggestion @hinrg in #4

--- bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino
+++ bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino
@@ -7,6 +7,19 @@
   |______/  | _| `.__| \______/  |__|  |__|    /__/     \__\ \______/      |__|      \______/  |__|  |__| /__/     \__\  |__|     |__|  \______/  |__| \__|

   Thanks much to @corbanmailloux for providing a great framework for implementing flash/fade with HomeAssistant https://github.com/corbanmailloux/esp-mqtt-rgb-led
+
+  To use this code you will need the following dependancies:
+
+  - Support for the ESP8266 boards.
+        - You can add it to the board manager by going to File -> Preference and pasting http://arduino.esp8266.com/stable/package_esp8266com_index.json into the Additional Board Managers URL field.
+        - Next, download the ESP8266 dependancies by going to Tools -> Board -> Board Manager and searching for ESP8266 and installing it.
+
+  - You will also need to download the follow libraries by going to Sketch -> Include Libraries -> Manage Libraries
+      - DHT sensor library
+      - Adfruit unified sensor
+      - PubSubClient
+      - ArduinoJSON
+
 */


Send a continuous status.

Send a continuous status.

--- arduino/serial_server/serial_server.ino
+++ arduino/serial_server/serial_server.ino
@@ -9,23 +9,40 @@
 String inputString = "";         // a string to hold incoming data
 boolean stringComplete = false;  // whether the string is complete

+String statusString = "";         // a string to hold outgoing data
+
 void setup(){
   //delay(100); //wait for bus to stabalise
   // serial
   Serial.begin(9600);
   // reserve 200 bytes for the inputString:
   inputString.reserve(200);
+  statusString.reserve(200);
 }

 void loop(){
+  static unsigned long send_time = millis();
+
   // print the string when a newline arrives:
   if (stringComplete) {
-    flash(200);
     Serial.println(inputString);
     // clear the string:
     inputString = "";
     stringComplete = false;
   }
+
+  if (millis() - send_time >= 10)
+  {
+    send_time = millis();
+    send_status();
+  }
+}
+
+// Send back our status down the serial link. Called by the main loop.
+void send_status(){
+    flash(1);
+    statusString = "hello";
+    Serial.println(statusString);
 }

 /*
@@ -54,3 +71,4 @@
     delay(msecs);
     digitalWrite(led_pin, LOW);
 }
+


firmware add dynamic average, bound margin argorithm

--- firmware/verification/VWC/SEN0193_3_Calibrate/SEN0193_3_Calibrate.ino
+++ firmware/verification/VWC/SEN0193_3_Calibrate/SEN0193_3_Calibrate.ino
@@ -2,7 +2,7 @@
  *  Features:
  *    load/save VWC boundry value at EEPROM address 0 ( size = 2* int )
  *    Press button to start/stop calibrate mode.
- *    Calibrating with LED on
+ *    Calibrating with LED blinking
  *
  *  Connection:
  *    Button : D2, default high
@@ -15,9 +15,10 @@
  *
  *  Calibrate procedure:
  *    Power On
- *    Press Button - see LED on
- *    In any sequence in the Air and Water. Suggest have 10 seconds in each state
- *    Press Button - see LED off
+ *    Press Button - see LED blink (about per-second)
+ *    In any sequence in the Air and Water. Suggest have 30 seconds in each state
+ *    When air and water tested, LED blink fast
+ *    Press Button - see LED off, setting will be save only when blink fast
  *
  *  Detail:
  *    Without calibrate, the default value is DEF_TOP, DEF_DOWN
@@ -35,6 +36,8 @@
 #define DEF_TOP 520
 #define DEF_DOWN 261
 #define VWC_CNT 3
+#define SYN_AVG_CNT 3 // Get dynamic average from SYN_AVG_CNT sensing
+#define BOUND_MARGIN 10
 struct ADC_Bound {
   int v_top; // value sense at air
   int v_down; // value sense at water
@@ -42,9 +45,13 @@
 ADC_Bound bound[VWC_CNT];
 int pin_vwc[VWC_CNT] = {A3,A4,A5};
 int mode =0; //mode 0: normal mode , mode 1: calibrate mode
-int count=0; // lopp count
+int count=0; // lopp count
+int bound_change[VWC_CNT*2]; // 0: not changed, 1: changed
+int led_state = 0; //0: LED off, 1:LED on
+float dyn_avg[VWC_CNT];

 void save_setting(){
+  Serial.println("Save setting!");
   for(int i=0;i<VWC_CNT;i++){
     EEPROM.put(0+i*sizeof(ADC_Bound), bound[i]);
   }
@@ -60,8 +67,15 @@
   }
 }

+void update_avg(int i,int value){
+  if(dyn_avg[i]==0){
+    dyn_avg[i]=value;
+  }else{
+    dyn_avg[i] = (dyn_avg[i] * (SYN_AVG_CNT-1) + value )/SYN_AVG_CNT;
+  }
+}
 void setup() {
-  Serial.begin(115200);
+  Serial.begin(9600);
   pinMode(PIN_BUTTON,INPUT);
   for(int i=0;i<VWC_CNT;i++){
     pinMode(pin_vwc[i],INPUT);
@@ -82,9 +96,16 @@

   for(int i=0;i<VWC_CNT;i++){
     val[i] = analogRead(pin_vwc[i]); //connect sensor to Analog 0
+    update_avg(i,val[i]);
     if( mode == 1 ){
-      if(val[i]> bound[i].v_top) bound[i].v_top = val[i];
-      if(val[i]< bound[i].v_down ) bound[i].v_down = val[i];
+      if(dyn_avg[i]> bound[i].v_top - BOUND_MARGIN) {
+        bound[i].v_top = round(dyn_avg[i]);
+        bound_change[i*2+0] =1;
+      }
+      if(dyn_avg[i]< bound[i].v_down + BOUND_MARGIN ) {
+        bound[i].v_down = round(dyn_avg[i]);
+        bound_change[i*2+ 1] =1;
+      }
     }

     vwc[i] = 1.0-((float(val[i])-bound[i].v_down)/(bound[i].v_top-bound[i].v_down));
@@ -92,12 +113,24 @@
   Serial.print(val[i]); Serial.print(",");
   Serial.print(vwc[i]*100); Serial.print(",");
   Serial.print(bound[i].v_down); Serial.print(",");
-  Serial.print(bound[i].v_top);
+  Serial.print(bound[i].v_top); Serial.print(" ");
   if(i != VWC_CNT-1 ) Serial.print(",");
   }
   Serial.println("");

 }
+int calibrate_complete_check(){
+  int change_cnt =0;
+  for(int i=0;i<VWC_CNT*2;i++){
+    if(bound_change[i]==1){
+      change_cnt++;
+    }
+  }
+  if(change_cnt==6) return 1;
+  else return 0;
+}
+
+
 void mode_check_and_run(){
   int btn_state;
   //detect if btn click
@@ -107,13 +140,16 @@
     if( mode == 0 ){ // cal complete
       Serial.println("Calibrate Complete!");
       digitalWrite(PIN_LED,0);
-      save_setting();
+      if(calibrate_complete_check()) save_setting();
+      else load_setting();
     }else{ //mode = 1 , cal start
       Serial.println("Calibrate Start!");
       digitalWrite(PIN_LED,1);
       for(int i=0;i<VWC_CNT;i++){
         bound[i].v_top = CALINIT_TOP;
         bound[i].v_down = CALINIT_DOWN;
+        bound_change[i*2+0] = 0;
+        bound_change[i*2+1] = 0;
       }
     }
     delay(500); // to avoid single click with multiple action
@@ -126,10 +162,21 @@
 //

 void loop() {
+  int toggle_set;
   mode_check_and_run();
   if(count % 20 == 0 ){
     sensing();
   }
+  if( mode == 1 ){
+    toggle_set = 10; // estimate on/off per second
+    if(calibrate_complete_check()){
+      toggle_set = 3; // about 3 time faster
+    }
+    if(count % toggle_set == 0 ){
+      led_state = 1 - led_state;
+      digitalWrite(PIN_LED,led_state);
+    }
+  }
   count++;
   delay(50);
 }


updated motor numbers

updated motor numbers

at makers faire

--- edward.ino
+++ edward.ino
@@ -18,7 +18,7 @@
   // cannot be initialized in constructor because the constructor
   // is called before the arduino functions work
   // ping, head motor, l motor, r motor, l turn, r turn, move time, l zero, r zero
-  Edward.start(7, 9, 3, 11, 730, 750, 2250);
+  Edward.start(7, 9, 3, 11, 675, 830, 2250);
   Edward.stop();
   Edward.Neck.write(90);
   debug("Press any key to start");


Implemented dynamic IP assignment (DHCP) in HTTP driver for Arduino Mega board

Jira issue: WP-595

--- webinos/platform/arduino/arduino_mega/api/sensors_actuators_driver/sensors_actuators_driver.ino
+++ webinos/platform/arduino/arduino_mega/api/sensors_actuators_driver/sensors_actuators_driver.ino
@@ -43,7 +43,7 @@

 IOElement * elements[MAX_NUM_ELEMENTS];

-byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
+byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xAC };
 byte* pzp_ip;
 byte* board_ip;
 IPAddress BOARD_IP(DFLT_BOARD_IP);
@@ -66,16 +66,15 @@
     client.println("\",\"port\":\"80\"} HTTP/1.0");
 }

-String getInfoFromSD(boolean check_for_elements){
+void getInfoFromSD(boolean check_for_elements){
     boolean first_element = true;
     boolean ignore = false;
-    String req;

     // see if the card is present and can be initialized:
     if (!sd_ready && !SD.begin(chipSelect)) {
         Serial.println("Card failed, or not present");
         // don't do anything more:
-        return "";
+        return;
     }
     else{
         Serial.println("card initialized.");
@@ -88,6 +87,10 @@
     if (configFile) {
         String s;
         char c;
+
+        if(check_for_elements && !client.connected())
+            client = server.available();
+
         while (configFile.available()) {
             c = configFile.read();
             if(c == '#' ){
@@ -113,11 +116,10 @@
                         buf[i] = tmp.charAt(i);
                     buf[tmp.length()-1] = '\0';
                     board_id = buf;
-                    req = board_id;
-                }
-                else if(s.startsWith("BRDIPAD")){  // BOARD IP ADDRESS
-                    board_ip = strIp2byteVect(s.substring(7));
-                }
+                }
+//                else if(s.startsWith("BRDIPAD")){  // BOARD IP ADDRESS
+//                    board_ip = strIp2byteVect(s.substring(7));
+//                }
 //                else if(s.startsWith("BRDPORT")){  // BOARD PORT
 //                    board_port = s.substring(7).toInt();
 //                }
@@ -134,10 +136,12 @@
                     int tp_pos = 0;
                     if(first_element){
                         first_element=false;
-                        req += "[";
+//                        req += "[";
+                        client.print("[");
                     }
                     else{
-                        req += ",";
+//                        req += ",";
+                        client.print(",");
                     }
                     for(int i=0; i<tmp.length(); i++){
                         if(tmp.charAt(i) == ':' || tmp.charAt(i) == '\n'){
@@ -145,11 +149,17 @@

                             if(counter == 0){  // ELEMENT ID
                                 elements[num_elements] = new IOElement();
-                                req += "{\"id\":\"";
-                                req += board_id;
-                                req += "_";
-                                req += field;
-                                req += "\", \"element\":{";
+//                                req += "{\"id\":\"";
+//                                req += board_id;
+//                                req += "_";
+//                                req += field;
+//                                req += "\", \"element\":{";
+                                client.print("{\"id\":\"");
+                                client.print(board_id);
+                                client.print("_");
+                                client.print(field);
+                                client.print("\", \"element\":{");
+
                                 int len = strlen(board_id) + 1 + field.length() +1 ;  // BOARD_ID + _ + id + \0
                                 char * buf = (char*) malloc(sizeof(char)*(len));
                                 strcpy(buf,board_id);
@@ -162,9 +172,12 @@
                                 elements[num_elements]->rate = DFLT_ELEMENT_RATE;
                             }
                             else if(counter == 1){  // ELEMENT SA
-                                req += "\"sa\":\"";
-                                req += field;
-                                req += "\",";
+//                                req += "\"sa\":\"";
+//                                req += field;
+//                                req += "\",";
+                                client.print("\"sa\":\"");
+                                client.print(field);
+                                client.print("\",");
                                 elements[num_elements]->sa = !field.equals("0");
                             }
                             else if(counter == 2){  // ELEMENT AD
@@ -174,39 +187,60 @@
                                 elements[num_elements]->pin = field.toInt();
                             }
                             else if(counter == 4){  // ELEMENT MAXIMUMRANGE
-                                req += "\"maximumRange\":\"";
-                                req += field;
-                                req += "\",";
+//                                req += "\"maximumRange\":\"";
+//                                req += field;
+//                                req += "\",";
+                                client.print("\"maximumRange\":\"");
+                                client.print(field);
+                                client.print("\",");
                             }
                             else if(counter == 5){  // ELEMENT MINDELAY
-                                req += "\"minDelay\":\"";
-                                req += field;
-                                req += "\",";
+//                                req += "\"minDelay\":\"";
+//                                req += field;
+//                                req += "\",";
+                                client.print("\"minDelay\":\"");
+                                client.print(field);
+                                client.print("\",");
                             }
                             else if(counter == 6){  // ELEMENT POWER
-                                req += "\"power\":\"";
-                                req += field;
-                                req += "\",";
+//                                req += "\"power\":\"";
+//                                req += field;
+//                                req += "\",";
+                                client.print("\"power\":\"");
+                                client.print(field);
+                                client.print("\",");
                             }
                             else if(counter == 7){  // ELEMENT RESOLUTION
-                                req += "\"resolution\":\"";
-                                req += field;
-                                req += "\",";
+//                                req += "\"resolution\":\"";
+//                                req += field;
+//                                req += "\",";
+                                client.print("\"resolution\":\"");
+                                client.print(field);
+                                client.print("\",");
                             }
                             else if(counter == 8){  // ELEMENT TYPE
-                                req += "\"type\":\"";
-                                req += field;
-                                req += "\",";
+//                                req += "\"type\":\"";
+//                                req += field;
+//                                req += "\",";
+                                client.print("\"type\":\"");
+                                client.print(field);
+                                client.print("\",");
                             }
                             else if(counter == 9){  // ELEMENT VENDOR
-                                req +="\"vendor\":\"";
-                                req += field;
-                                req += "\",";
+//                                req +="\"vendor\":\"";
+//                                req += field;
+//                                req += "\",";
+                                client.print("\"vendor\":\"");
+                                client.print(field);
+                                client.print("\",");
                             }
                             else if(counter == 10){  // ELEMENT VERSION
-                                req +="\"version\":\"";
-                                req += field;
-                                req += "\"}}";
+//                                req +="\"version\":\"";
+//                                req += field;
+//                                req += "\"}}";
+                                client.print("\"version\":\"");
+                                client.print(field);
+                                client.print("\"}}");
                             }
                             counter++;
                             tp_pos = i+1;
@@ -215,33 +249,18 @@
                     }
                     num_elements++;
                 }
-                s = "";
+                s = "";
             }
         }
         if(check_for_elements){
-            req += "]";
+//            req += "]";
+              client.print("]");
         }
         configFile.close();
     }
     else {
         Serial.println("error opening configuration file");
     }
-    return req;
-}
-
-
-void setup(){
-    Serial.begin(9600);
-
-    getInfoFromSD(false);
-
-    if(board_ip != NULL)
-        Ethernet.begin(mac, board_ip);
-    else
-        Ethernet.begin(mac, BOARD_IP);
-
-    Serial.print("My IP address: ");
-    Serial.println(Ethernet.localIP());
 }

 int getValueFromSensor(bool ad, int pin){
@@ -262,12 +281,16 @@
         if(val == elements[id_ele]->lastValue)
             senddata = false;
     }
+
+    if(client.connected())
+      client.stop();
+
     if (senddata && client.connect(pzp_ip, pzp_port)) {
-        // Serial.println(val);
-        // Serial.println(elements[id_ele]->lastValue);
-        // Serial.print("Send data id : ");
-        // Serial.println(id_ele);
-        // Serial.println(elements[id_ele]->rate);
+//        Serial.println(val);
+//        Serial.println(elements[id_ele]->lastValue);
+//        Serial.print("Send data id : ");
+//        Serial.println(id_ele);
+//        Serial.println(elements[id_ele]->rate);
         client.print("POST /sensor?id=");
         client.print(elements[id_ele]->id);
         client.print("&data=");
@@ -278,6 +301,33 @@
         elements[id_ele]->lastConnectionTime = millis();
     }
     elements[id_ele]->lastValue = val;
+}
+
+void setup(){
+    Serial.begin(9600);
+
+    getInfoFromSD(false);
+
+    /*
+    if(board_ip != NULL)
+        Ethernet.begin(mac, board_ip);
+    else
+        Ethernet.begin(mac, BOARD_IP);
+    */
+
+    Serial.println("Trying to get an IP address using DHCP");
+    if (Ethernet.begin(mac) == 0) {
+        Serial.println("Failed to configure Ethernet using DHCP");
+
+        // initialize the ethernet device not using DHCP:
+        if(board_ip != NULL)
+            Ethernet.begin(mac, board_ip);
+        else
+            Ethernet.begin(mac, BOARD_IP);
+    }
+
+    Serial.print("My IP address: ");
+    Serial.println(Ethernet.localIP());
 }

 void loop(){
@@ -375,7 +425,8 @@
                             client.print("{\"bid\":\"");
                             client.print(board_id);
                             client.print("\",\"cmd\":\"ele\",\"elements\":");
-                            client.print(getInfoFromSD(true));
+                            getInfoFromSD(true);
+                            //client.print(getInfoFromSD(true));
                             client.println("}");
                             elements_ready = true;
                         }
@@ -400,8 +451,11 @@
                             if(strcmp(cmd,"str")==0){
                                 client.print("{\"cmd\":\"str\",");
                                 for(int i=0; i<num_elements; i++){
-                                    if(strcmp(elements[i]->id, eid) == 0)
+                                    if(strcmp(elements[i]->id, eid) == 0){
+                                        Serial.print("starting ");
+                                        Serial.println(elements[i]->id);
                                         elements[i]->active = true;
+                                    }
                                 }
                             }
                             else{


Time-date modification

Time-date modification

* Time-date printing optimization
* Time-date setup fix

--- meteo_lcd/meteo_lcd.ino
+++ meteo_lcd/meteo_lcd.ino
@@ -79,6 +79,14 @@

 // Real-time clock
 DS3231 rtc;
+
+
+// Time format
+// 01234567890123456789
+// 00:00:00  31.12.2017
+char time_format[21] = "17:34:59  31.12.2017";
+void print_time_string(unsigned row, bool full_update = false);
+

 // Error value
 const int32_t err_val = 200000;
@@ -405,8 +413,8 @@
                 lcd.setCursor(6, line);
                 break;
             case 3:
-                if (val < 0)  val = 31; // this allows to set 31.02 as a date
-                if (val > 31) val = 0;
+                if (val < 1)  val = 31; // this allows to set 31.02 as a date
+                if (val > 31) val = 1;
                 rtc.setDate(val);
                 lcd.setCursor(10, line);
                 if (val < 10)
@@ -415,8 +423,8 @@
                 lcd.setCursor(10, line);
                 break;
             case 4:
-                if (val < 0)  val = 12;
-                if (val > 12) val = 0;
+                if (val < 1)  val = 12;
+                if (val > 12) val = 1;
                 rtc.setDate(val);
                 lcd.setCursor(13, line);
                 if (val < 10)
@@ -441,17 +449,25 @@

     lcd.noCursor();
     lcd.noBlink();
+
+    // Full time update
+    print_time_string(3 /* 4th row */, true);
 }

 ////////////////////////////////////////////////////////////////////////////////
 //                PRINT TIME

-/* returns time-date string via param from rtc.
- * rtc should be at least 21 bytes long.
+/*
+ * Prints time-date string in global char time_format[]
+ * Does an update/printing only when needed
  */
-void print_time_string(unsigned row)
-{
+void print_time_string(unsigned row, bool full_update)
+{
+    /*
+     * 01234567890123456789
+     * 17:34:59  31.12.2017
+     */

     static byte last_second;
     if (last_second == rtc.getSecond()) {
@@ -463,66 +479,55 @@

     //print_clock(); // Optional

-    bool tmp1 = false;
-    bool tmp2 = false;
-
-    char str[21];
     byte ret;
-
-    /*
-     * 01234567890123456789
-     * 17:34:59  31.12.2017
-     */
+    bool tmp1, tmp2;
+
+    // second
+    ret = last_second;
+    time_format[6] = ret / 10 + ('0');
+    time_format[7] = ret % 10 + ('0');
+
+    if (ret != 0 && !full_update)
+	goto end;
+
+    // minute
+    ret = rtc.getMinute();
+    time_format[3] = ret / 10 + ('0');
+    time_format[4] = ret % 10 + ('0');
+
+    if (ret != 0 && !full_update)
+	goto end;

     // hour
     ret = rtc.getHour(tmp1, tmp2);
-    str[0] = ret / 10 + ('0');
-    str[1] = ret % 10 + ('0');
-
-    str[2] = ':';
-
-    // minute
-    ret = rtc.getMinute();
-    str[3] = ret / 10 + ('0');
-    str[4] = ret % 10 + ('0');
-
-    str[5] = ':';
-
-    // second
-    ret = last_second;
-    str[6] = ret / 10 + ('0');
-    str[7] = ret % 10 + ('0');
-
-    str[8] = ' ';
-    str[9] = ' ';
+    time_format[0] = ret / 10 + ('0');
+    time_format[1] = ret % 10 + ('0');
+
+    if (ret != 0 && !full_update)
+	goto end;
+
+    // Update all date string - very little optimization gain

     // day
     ret = rtc.getDate();
-    str[10] = ret / 10 + ('0');
-    str[11] = ret % 10 + ('0');
-
-    str[12] = '.';
+    time_format[10] = ret / 10 + ('0');
+    time_format[11] = ret % 10 + ('0');

     // month
     ret = rtc.getMonth(tmp1);
-    str[13] = ret / 10 + ('0');
-    str[14] = ret % 10 + ('0');
-
-    str[15] = '.';
+    time_format[13] = ret / 10 + ('0');
+    time_format[14] = ret % 10 + ('0');

     // year - only last two digits
     ret = rtc.getYear();
-    str[16] = '2';
-    str[17] = '0';
-    str[18] = ret / 10 + ('0');
-    str[19] = ret % 10 + ('0');
-
-    // end of string
-    str[20] = '\0';
-
-    LOGLN(str);
+
+    time_format[18] = ret / 10 + ('0');
+    time_format[19] = ret % 10 + ('0');
+
+end:
+    LOGLN(time_format);
     lcd.setCursor(0, row);
-    lcd.print(str);
+    lcd.print(time_format);
 }

 ////////////////////////////////////////////////////////////////////////////////
@@ -793,6 +798,9 @@

     // Draw template - Labels and units.
     draw_template();
+
+    // Full time update
+    print_time_string(3 /* 4th row */, true);
     LOGLN("Setup end");
 }

@@ -801,8 +809,8 @@

 void loop ()
 {
-    static byte iter;
-    iter = iter + 1;
+    static unsigned long lastTime;
+    unsigned long timeNow = millis();
     LOGLN("Loop");

     if (enter_time_setup())
@@ -812,16 +820,16 @@
     backlight_buttons();

     // Update meteo data
-    if (!iter) {
+    if (timeNow - lastTime > 1000) {
+        lastTime = timeNow;
+        digitalWrite(DEBUG_LED, HIGH);
         float temp_in, humid_in, temp_out, humid_out;
         int32_t pressure;

         read_meteo_data(temp_in, humid_in, temp_out, humid_out, pressure);
         fill_data(temp_in, temp_out, humid_in, humid_out, pressure);
-    }
-
-    // Clock icon - optional. Only if show_dew_point is disabled
-    //print_clock();
+        digitalWrite(DEBUG_LED, LOW);
+    }

     // Update the displayed time
     print_time_string(3 /* 4th row */);


Update AppManager.ino

Update AppManager.ino

--- library/examples/AppManager/AppManager.ino
+++ library/examples/AppManager/AppManager.ino
@@ -22,6 +22,7 @@

 #include "ProfileApp.h"
 #include "StarsApp.h"
+#include "DilbertApp.h"

 /* #define USE_BUTTON_INTERRUPTS */

@@ -45,6 +46,8 @@
   appManager.addApp(new ProfileApp());
   appManager.addApp(new ButtonTestApp());
   appManager.addApp(new StarsApp());
+  appManager.addApp(new DilbertApp());
+
   /* Small delay before app manager start (which turns on backlight) */
   delay(100);


working led with cleaned code

working led with cleaned code

--- esp8266_tmp/test_sketch/test_sketch.ino
+++ esp8266_tmp/test_sketch/test_sketch.ino
@@ -27,18 +27,18 @@
   // ici on va juste repondre avec un "hello !"
   server.on("/bonjour", [](){
     server.send(200, "text/plain", "hello !");
-    Serial.print("hello !");
+    Serial.println("hello !");
   });
   pinMode(2, OUTPUT);
   server.on("/2/on", [](){
     digitalWrite(2,HIGH);
     server.send(200, "text/plain", "LED 2 turned on !");
-    Serial.print("LED 2 turned on !");
+    Serial.println("LED 2 turned on !");
   });
   server.on("/2/off", [](){
     digitalWrite(2,LOW);
     server.send(200, "text/plain", "LED 2 turned off !");
-    Serial.print("LED 2 turned off !");
+    Serial.println("LED 2 turned off !");
   });
   server.begin();
 }


subscribe to 6

subscribe to 6

--- _04-lcd-dust/a-01-esp01-i2c/a-01-esp01-i2c.ino
+++ _04-lcd-dust/a-01-esp01-i2c/a-01-esp01-i2c.ino
@@ -565,7 +565,7 @@
     }

     client.loop();
-    for (int i = 0; i < 5; ++i)
+    for (int i = 0; i < 6; ++i)
     {
       client.subscribe(subs_simple_all[i]);
       client.loop();


Disabled Debug Constant

Disabled Debug Constant

--- systemdalarmefull.ino
+++ systemdalarmefull.ino
@@ -5,7 +5,7 @@

 int stateInPacket = 0; //to move in their bit pattern
 int sysdalarmValue = 2; //to tell IFTTT if system is armed or not
-bool DEBUG = TRUE;
+bool DEBUG = FALSE;

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


ミリ秒とμ秒の誤りを修正

ミリ秒とμ秒の誤りを修正

--- 1_practice/esp32_27_goo_lcd2/esp32_27_goo_lcd2.ino
+++ 1_practice/esp32_27_goo_lcd2/esp32_27_goo_lcd2.ino
@@ -124,9 +124,8 @@
     time2txt(date,TIME+time/1000);          // 時刻を文字配列変数dateへ代入
     if(time%21600000ul<100){                // 6時間に1回の処理
         wifi_ntp();                         // wifi_ntpを実行
-        return;
     }
-    if(time%(SLEEP_P)<100){                 // SLEEP_P間隔の処理
+    if(time%(SLEEP_P/1000)<100){            // SLEEP_P間隔の処理
         wifi_google();                      // Googleカレンダから予定を取得する
         buf_i=0;                            // 表示用の予定番号をリセット
     }


debug output

debug output

--- Stroller_interruptHandling_1/Stroller_interruptHandling_1.ino
+++ Stroller_interruptHandling_1/Stroller_interruptHandling_1.ino
@@ -7,12 +7,14 @@

 #include <avr/sleep.h>
 #include <avr/power.h>
+/*
+* a single revoluion of the wheel has this distance in mm (89,5 cm)
+ */
+#define distance 895
 /*
- *
+ * if true, print serial output
  */
-
-#define distance 895
-
+int debug = 1;

 long distanceToDate=0;
 int pinOut = 13;
@@ -144,16 +146,20 @@
   if (hadRound==1) {
     distanceToDate=distanceToDate+distance;
     digitalWrite(pinOut,HIGH);
-//    Serial.print("Distance is now: ");
-//    Serial.print(distanceToDate);
-//    Serial.print(" at  ");
-//    Serial.println(millis());
+    if (debug==HIGH) {
+      Serial.print("Distance is now: ");
+      Serial.print(distanceToDate);
+      Serial.print(" at  ");
+      Serial.println(millis());
+    }
     hadRound=0;
     delay(100);
   }
    digitalWrite(pinOut,LOW);
-//  Serial.print(millis());
-//  Serial.println("going back to sleep");
-//  delay(50);
+   if (debug==HIGH) {
+    Serial.print(millis());
+    Serial.println("going back to sleep");
+    delay(50);
+   }
   enterSleep();
 }


Fixed problem with arduino names of vars

--- Arduino-code/two-sensors-test/two-sensors-test.ino
+++ Arduino-code/two-sensors-test/two-sensors-test.ino
@@ -1,30 +1,31 @@
 /*
 Pines of the first sensor.
 */
-#define S1-echo 7
-#define S1-trig 8
+#define S1echo 7
+#define S1trig 8

 /*
 Pines of the second sensor.
 */
-#define S2-echo 10
-#define S2-trig 11
+#define S2echo 10
+#define S2trig 11

 long duration, distance;
 void setup() {
   /*
   Setup of the echo & trig of everysensor.
   */
-  pinMode(S1-echo, INPUT);
-  pinMode(S2-echo, INPUT);
+  pinMode(S1echo, INPUT);
+  //pinMode(S2echo, INPUT);

-  pinMode(S1-trig, OUTPUT);
-  pinMode(S2-trig, OUTPUT);
+  pinMode(S1trig, OUTPUT);
+  //pinMode(S2trig, OUTPUT);

 }

 void loop() {
-  estimateDistance(S1-trig, S1-echo);
+  printReadings("Testing",0);
+  estimateDistance(S1trig, S1echo);
   delayMicroseconds(1000);
 }


Added an example with preprogrammed analog values

--- examples/AnalogKeysExample/AnalogKeysExample.ino
+++ examples/AnalogKeysExample/AnalogKeysExample.ino
@@ -27,7 +27,9 @@
 #define INPUTPIN 0

 char* keys [] = {"NONE", "LEFT", "RIGHT", "UP", "DOWN", "SELECT"};
-int analogValues [KEYSLENGTH] = {};
+int analogValues [KEYSLENGTH] = {}; // If you know the values of the keys you can already pass them, that way you don't have to calibrate
+// Example with preprogrammed analog values:
+// int analogValues [] = {675, 314, 0, 85, 475};

 AnalogKeys analogKeys(&lcd, INPUTPIN, keys, KEYSLENGTH, analogValues);


Cleanup delay handling.

Cleanup delay handling.

--- examples/Sandbox/CosaLowPower/CosaLowPower.ino
+++ examples/Sandbox/CosaLowPower/CosaLowPower.ino
@@ -108,9 +108,11 @@
 #ifdef USE_WATCHDOG_DELAY
   // 1,5 mA, 64 ms blink
   Watchdog::begin();
+  delay = Watchdog::delay;
   while (wakeup.is_low()) {
     led.toggle();
-    Watchdog::delay(64);
+    // Watchdog::delay(64);
+    delay(64);
   }
   led.off();
   Watchdog::end();
@@ -118,7 +120,8 @@
   // 15 mA, 16 ms blink
   while (wakeup.is_low()) {
     led.toggle();
-    for (uint8_t i = 0; i < 4; i++) DELAY(16000U);
+    // for (uint8_t i = 0; i < 4; i++) DELAY(16000U);
+    delay(64);
   }
   led.off();
 #endif


Pre pull

Pre pull

--- Arduino/sketchbook/XbeeServerGnd/XbeeServerGnd.ino
+++ Arduino/sketchbook/XbeeServerGnd/XbeeServerGnd.ino
@@ -42,7 +42,8 @@
   Serial.print(("Starting time: "));
   Serial.println(start_time);

-  tx_packet.set_Address(0x00000000C0A80164);
+  tx_packet.set_Address(0x00000000C0A80164);
+  //tx_packet.set_Address(0x00000000C0A80165);

   tx_buffer1 = get_buffer();

@@ -222,4 +223,4 @@

 }

-
+


Fixed app freeze when sending command without card present

--- frontdesk/frontdesk.ino
+++ frontdesk/frontdesk.ino
@@ -103,10 +103,11 @@

 	while (Serial.available()) {
 		if (state == 0 || state == 1) {
-			Serial.write(ERROR_CHAR);
 			while (Serial.available()) {
 				Serial.read();
 			}
+			Serial.write(ERROR_CHAR);
+			Serial.write(END_CHAR);
 		}
 		else {
 			characterRead[i] = Serial.read();
@@ -165,7 +166,7 @@
 		}

 		Serial.write(END_CHAR);
-		state = 0;
+		playUnderground();
 	}
 }


software debounce

software debounce

--- Arduino/wheel-read-write/wheel-read-write.ino
+++ Arduino/wheel-read-write/wheel-read-write.ino
@@ -10,8 +10,11 @@
 int previousMillis1 = 0;
 int previousMillis2 = 0;

-const int stepsPerRevelation = 20;
-const int distanceInMMPerRevelation = 220;
+// Debouncer
+unsigned long EncoderLockDuration = 15000; // in microseconds
+
+unsigned long PreviousScan1 = 0;
+unsigned long PreviousScan2 = 0;

 // Motor 1 - Left
@@ -103,6 +106,14 @@

 void EncoderRotationCount1()
 {
+    unsigned long currentMicros = micros();
+    if (currentMicros - PreviousScan1 <= EncoderLockDuration)
+    {
+        return;
+    }
+
+    PreviousScan1 = currentMicros;
+
     if(motorDirectionIsForward1)
     {
         interrupt1Count++;
@@ -115,6 +126,14 @@

 void EncoderRotationCount2()
 {
+    unsigned long currentMicros = micros();
+    if (currentMicros - PreviousScan2 <= EncoderLockDuration)
+    {
+        return;
+    }
+
+    PreviousScan2 = currentMicros;
+
     if(motorDirectionIsForward2)
     {
         interrupt2Count++;


Forgot onData()

Forgot onData()

--- examples/02_Quick_start_anto/02_Quick_start_anto.ino
+++ examples/02_Quick_start_anto/02_Quick_start_anto.ino
@@ -48,6 +48,7 @@
   pinMode(D2,OUTPUT);
   pinMode(D3,OUTPUT);

+  anto.mqtt.onData(messageReceived);
   anto.mqtt.sub("LED1");
   anto.mqtt.sub("LED2");
   anto.mqtt.sub("LED3");


Fixed incorrectly named variable.

Fixed incorrectly named variable.

Thanks to Mark for the bug report.

--- Chapter_4/Lesson_4.3/Exercises/Solution_2.ino
+++ Chapter_4/Lesson_4.3/Exercises/Solution_2.ino
@@ -44,7 +44,7 @@
 // motor 0 is our right motor, motor 1 is our left motor.
 void setSpeed(int motor, int speed) {
 	if ( motor == 0 ) {
-		if ( motorspeed < 0 ) {
+		if ( speed < 0 ) {
 			digitalWrite(rightMotorDirection, LOW);
 			analogWrite(rightMotorSpeed, abs(speed));
 		} else {
@@ -52,7 +52,7 @@
 			analogWrite(rightMotorSpeed, speed);
 		}
 	} else {
-		if ( motorspeed < 0 ) {
+		if ( speed < 0 ) {
 			digitalWrite(leftMotorDirection, HIGH);
 			analogWrite(leftMotorSpeed, abs(speed));
 		} else {


Updated SensorsTeste

Updated SensorsTeste

--- NoFollow/Testes/SensorsTeste/SensorsTeste.ino
+++ NoFollow/Testes/SensorsTeste/SensorsTeste.ino
@@ -1,19 +1,23 @@
-#define PIN_MUX_S0 6
+#define PIN_MUX_S0 A1
 #define PIN_MUX_S1 12
 #define PIN_MUX_S2 7
 #define PIN_MUX_S3 4
-#define PIN_MUX_AN 5
+#define PIN_MUX_AN A5
 #define PIN_MUX_ENABLE 16
 int values[16];
-int SENSOR_MIN;
-int SENSOR_MAX;
+int SENSOR_MIN = 100;
+int SENSOR_MAX = 500;
+int ini = 8;
+int fim = 16;
 static int S[] = {PIN_MUX_S0, PIN_MUX_S1, PIN_MUX_S2, PIN_MUX_S3};

 void readValues(){
-    for(uint8_t i = 8; i < 16; i++){
+    for(uint8_t i = ini; i < fim; i++){
       for(int n = 0; n < 4; n++){
-        digitalWrite(S[n], i & (0x1 << n));
+        digitalWrite(S[n], !!(i & (0x1 << n)));
+      //  Serial.print(!!(i & (0x1 << n)));
       }
+      //Serial.print("\t");
       values[i] = analogRead(PIN_MUX_AN);
     }
   }
@@ -24,9 +28,14 @@
 float getPosition(){
   float weighted_sum = 0;
   float sum = 0;
-  for(int i = 0; i < 9; i++){
-    float value = map(getValue(i), SENSOR_MIN, SENSOR_MAX, 0, 1);
-    weighted_sum = weighted_sum + value  * (i + 1);
+  for(int i = ini; i < fim; i++){
+    float value = (getValue(i) - 0.0) * (-1.0) / (SENSOR_MAX - SENSOR_MIN) + 1.0;
+    value = fmin(fmax(0.0, value), 1.0);
+    Serial.print(i);
+    Serial.print(" : ");
+    Serial.print(value);
+    Serial.print(" ");
+    weighted_sum = weighted_sum + value  * (i -7);
     sum = sum + value;
   }
   float position = ((weighted_sum / sum) - 4.5) / 3.5;
@@ -60,14 +69,14 @@
   pinMode(PIN_MUX_S2, OUTPUT);
   pinMode(PIN_MUX_S3, OUTPUT);
   pinMode(PIN_MUX_AN, INPUT);
-  calibrateSensor();
+  //calibrateSensor();

 }

 void loop() {
   digitalWrite(PIN_MUX_ENABLE, HIGH);
+  digitalWrite(PIN_MUX_S0, HIGH);
   readValues();
-  Serial.print("Position = ");
   Serial.print(getPosition());
   Serial.println();
   delay(100);


fix Arduino 1.0 incompatibility

fix Arduino 1.0 incompatibility

--- examples/RF12/packetBuf/packetBuf.ino
+++ examples/RF12/packetBuf/packetBuf.ino
@@ -18,8 +18,18 @@
     byte length() { return fill; }
     void reset() { fill = 0; }

+#if ARDUINO < 100
     virtual void write(uint8_t ch)
         { if (fill < sizeof buf) buf[fill++] = ch; }
+#else
+    virtual size_t write(uint8_t ch) {
+        if (fill < sizeof buf) {
+            buf[fill++] = ch;
+            return 1;
+        }
+        return 0;
+    }
+#endif

 private:
     byte fill, buf[RF12_MAXDATA];


moving back to 57600

moving back to 57600

still need to update the WiFlySetup sketch

--- examples/RoseBot/RoseBotFirmata/RoseBotFirmata.ino
+++ examples/RoseBot/RoseBotFirmata/RoseBotFirmata.ino
@@ -989,7 +989,7 @@
   /* calculate number of loops per ping */
   numLoops = INTER_PING_INTERVAL / samplingInterval ;

-  Firmata.begin(115200);
+  Firmata.begin(57600);
   systemResetCallback();  // reset to default config
 }


Rename payload callback and its parameter

Make it clear what the function does.
'client' was named ambiguously. Make it 'payload_stream', just like when reading a large Publish message.

--- examples/mqtt_publish_large/mqtt_publish_large.ino
+++ examples/mqtt_publish_large/mqtt_publish_large.ino
@@ -25,14 +25,14 @@
   Serial.println();
 }

-bool message(Client& client) {
+bool write_payload(Client& payload_stream) {
   char buf[64];
   memset(buf, 32, 64);
   for (int l = 0; l < 1024; l++) {
     int len = sprintf(buf, "%d", l);
     buf[len] = 32;
     buf[63] = '\n';
-    uint32_t sent = client.write((const uint8_t*)buf, 64);
+    uint32_t sent = payload_stream.write((const uint8_t*)buf, 64);
     if (sent < 64)
       return false;
   }
@@ -55,7 +55,7 @@
   if (WiFi.status() == WL_CONNECTED) {
     if (!client.connected()) {
       if (client.connect("arduinoClient")) {
-	client.publish("outTopic", message, 65536);
+	client.publish("outTopic", write_payload, 65536);
       }
     }


Update VCNL4010-tester.ino

Update VCNL4010-tester.ino

--- firmware/examples/VCNL4010-tester.ino
+++ firmware/examples/VCNL4010-tester.ino
@@ -1,6 +1,6 @@
 // This #include statement was automatically added by the Particle IDE.
 #include "application.h"
-#include "ParticleVCNL4010/VCNL4010.h"
+#include "vcnl4010.h"

 vcnl4010 vcnl;

@@ -20,4 +20,4 @@
    Serial.print("Ambient: "); Serial.println(vcnl.readAmbient());
    Serial.print("Proimity: "); Serial.println(vcnl.readProximity());
    delay(1000);
-}+}


Changed MidMenu steering wheel argument to be passed in listener since does not working ...

--- MID/MID.ino
+++ MID/MID.ino
@@ -147,7 +147,6 @@
 //
 // Display driver
 #include "lib/Lcd16x2.h"
-
 //
 // Define Welcome screen
 static void playWelcomeScreen();


Do not detach servo, saves power

Do not detach servo, saves power

--- tracker/tracker.ino
+++ tracker/tracker.ino
@@ -73,10 +73,10 @@
 #define PIN_PERIF_POWER 7 // PD7
 #define PIN_WAKEUP 2 // INT0

-#define PIN_LDR_LEFT  0 // PC0
-#define PIN_LDR_RIGHT 1 // PC1
-#define THRESHOLD_LDR_HORZ 50
-#define MOVE_INTERVAL_MILLIS 60
+#define PIN_LDR_LEFT  1 // PC0
+#define PIN_LDR_RIGHT 0 // PC1
+#define THRESHOLD_LDR_HORZ 5
+#define MOVE_INTERVAL_MILLIS 30

 #define SERVO_INCREMENT 5 // How much to move each loop
 #define SERVO_PIN_HORZ 9 // PB1
@@ -148,6 +148,7 @@
     vw_setup(2000);      // Bits per sec
     vw_set_tx_pin(PIN_TX);

+    servo_horz.attach(SERVO_PIN_HORZ, SERVO_HORZ_MIN, SERVO_HORZ_MAX);
     servoOn();
     servo_horz.writeMicroseconds(servo_horz_pos);

@@ -167,7 +168,7 @@

         // INT0 pin LOW = sleep
         if (!digitalRead(PIN_WAKEUP)) {
-          goToSleep(SLEEP_FLAG_DARK);
+          //goToSleep(SLEEP_FLAG_DARK);
           //TODO connect LDR to INT0
         }

@@ -176,13 +177,16 @@
     // Transmit after interval
     if (now - tx_last >= tx_interval) {
         tx_last = now;
+
+        byte wake_up = digitalRead(PIN_WAKEUP);

         // Send a transmission
         // int = 5 bytes in transmision string
         // long int = 10 bytes in transmision string
         // byte = 3 bytes in transmision string
         char msg[25]; // string to send
-        sprintf(msg, "%d,%u,%u,%lu", msgId, ldr_val_left, ldr_val_right, readVcc());
+        sprintf(msg, "S,%d,%d,%u,%u,%lu", msgId, wake_up, ldr_val_left, ldr_val_right, readVcc());
+        Serial.println(msg);
         vw_send((uint8_t *)msg, strlen(msg));
         vw_wait_tx(); // Wait until the whole message is gone
         ++msgId;
@@ -190,19 +194,8 @@
         ++awake_tx_count;
         if (awake_tx_count > AWAKE_TX_MAX) {
           awake_tx_count = 0;
-
-          // Turn off the servo
-          servoOff();
-
-          digitalWrite(LED_DEBUG, LOW);
-
           // Watchdog will wake us up in 8 seconds time.
           goToSleep(SLEEP_FLAG_IDLE);
-
-          digitalWrite(LED_DEBUG, HIGH);
-
-          // Turn on the servo (todo: leave servo off for much longer)
-          servoOn();
         }

     }
@@ -223,10 +216,12 @@
         if (servo_horz_pos < SERVO_HORZ_MIN) servo_horz_pos = SERVO_HORZ_MIN;
       }

+      /*
       Serial.print("  H > ");
       Serial.print(diff_horz);
       Serial.print("-");
       Serial.println(servo_horz_pos);
+      */

       // move a bit each loop until target is reached.
       servo_horz.writeMicroseconds(servo_horz_pos);
@@ -240,11 +235,11 @@
     ldr_val_left = analogRead(PIN_LDR_LEFT);
     ldr_val_right = analogRead(PIN_LDR_RIGHT);

-
+    /*
     Serial.print(ldr_val_left);
     Serial.print(':');
     Serial.println(ldr_val_right);
-
+    */

     int diff = ldr_val_left - ldr_val_right;
     if (abs(diff) > THRESHOLD_LDR_HORZ) {
@@ -259,7 +254,7 @@
  */
 void servoOn()
 {
-  servo_horz.attach(SERVO_PIN_HORZ, SERVO_HORZ_MIN, SERVO_HORZ_MAX);
+  //servo_horz.attach(SERVO_PIN_HORZ, SERVO_HORZ_MIN, SERVO_HORZ_MAX);
   digitalWrite(SERVO_PIN_HORZ_POWER, LOW); // low = 0n (PNP)
 }

@@ -268,7 +263,7 @@
  */
 void servoOff()
 {
-  servo_horz.detach();
+  //servo_horz.detach();
   digitalWrite(SERVO_PIN_HORZ_POWER, HIGH); // low = 0n (PNP)
 }

@@ -301,6 +296,11 @@
 void goToSleep(byte flag)
 {
   sleep_flag = flag;
+
+  digitalWrite(LED_DEBUG, LOW);
+
+  // Turn off the servo
+  servoOff();

   // Power down the periferals
   digitalWrite(PIN_PERIF_POWER, HIGH);
@@ -343,8 +343,13 @@

   ADCSRA = (1 << ADEN); // ADC back on

+  digitalWrite(LED_DEBUG, HIGH);
+
   // Power up the periferals
   digitalWrite(PIN_PERIF_POWER, LOW); // (PNP)
+
+  // Turn on the servo (todo: leave servo off for much longer)
+  servoOn();

 }


Use nullptr instead of NULL

Use nullptr instead of NULL

--- ESP8266HueEmulator/ESP8266HueEmulator.ino
+++ ESP8266HueEmulator/ESP8266HueEmulator.ino
@@ -344,10 +344,10 @@
   static char copy[128]; // Length defines the maximum length of the c_string we can process
   int i;
   strcpy(copy, str); // Since strtok consumes the first arg, make a copy
-  for (i = 1, act = copy; i <= index; i++, act = NULL) {
+  for (i = 1, act = copy; i <= index; i++, act = nullptr) {
     //Serial.print(".");
     sub = strtok_r(act, delim, &ptr);
-    if (sub == NULL) break;
+    if (!sub) break;
   }
   return sub;
 }


Water activated switch support code was added.


Connected to Google [NickNet]

Connected to Google [NickNet]

--- software/_proto_ESPTesting/ESPNano/ESPNano.ino
+++ software/_proto_ESPTesting/ESPNano/ESPNano.ino
@@ -1,8 +1,8 @@
 #include <SoftwareSerial.h>

-#define SSID    "OSU_Access"
-#define PASS    ""
-#define DST_IP  "220.181.111.85"
+#define SSID    "NickNet"
+#define PASS    "27304600"
+#define DST_IP  "173.194.33.136" //Google.com

 SoftwareSerial dbgSerial(11, 10); //Rx, Tx

@@ -30,6 +30,9 @@
 	if(Serial.find("OK")){
 		dbgSerial.println("[Module Responded OK]");
 	}
+	/* else {
+		testFailed();
+	} */

 	delay(500);

@@ -39,7 +42,11 @@
 	if(Serial.find("OK")){
 		dbgSerial.println("[Module Responded OK]");
 	}
+	else {
+		testFailed();
+	}

+	dbgSerial.println("[Attempting to connect to WiFi]");
 	bool connected = false;
 	for (int i = 0; i < 5; i++){
 		if(connectWiFi()){
@@ -48,7 +55,8 @@
 		}
 	}
 	if(!connected){
-		dbgSerial.print("[### Failed to connect to WiFi ###]");
+		dbgSerial.println("[### Failed to connect to WiFi ###]");
+		testFailed();
 	}

 	delay(5000);
@@ -59,22 +67,58 @@
 	if(Serial.find("OK")){
 		dbgSerial.println("[Module Responded OK]");
 	}
+
+	dbgSerial.println("[Requesting IP]");
+	Serial.print("AT+CIFSR\015\012");
+	for(int i = 0; i < 500; ++i){
+		if(Serial.available()){
+			dbgSerial.print((char) Serial.read());
+		}
+		delay(1);
+	}
 }

 void loop(){
-	/*
-	if(Serial.available()){
-		dbgSerial.print((char) Serial.read());
-	}
-	*/

-
+
+  String cmd = "AT+CIPSTART=\"TCP\",\"";
+  cmd += DST_IP;
+  cmd += "\",80";
+  Serial.println(cmd);
+  dbgSerial.println(cmd);
+  if (Serial.find("Error")) return;
+  cmd = "GET / HTTP/1.0\r\n\r\n";
+  Serial.print("AT+CIPSEND=");
+  Serial.println(cmd.length());
+  if (Serial.find(">"))
+  {
+    dbgSerial.print(">");
+  } else
+  {
+    Serial.println("AT+CIPCLOSE");
+    dbgSerial.println("connect timeout");
+    delay(1000);
+    return;
+  }
+  Serial.print(cmd);
+  delay(2000);
+  //Serial.find("+IPD");
+  while (Serial.available())
+  {
+    char c = Serial.read();
+    dbgSerial.write(c);
+    if (c == '\r') dbgSerial.print('\n');
+  }
+  dbgSerial.println("====");
+  delay(1000);

 	//dbgSerial.println("[Prompting for available networks]");
 	//Serial.print("AT+CWLAP\015\012");

+
+	//Command prompt to send commands to ESP module
 	while(1){
 		if(Serial.available()){
 			dbgSerial.print((char) Serial.read());
@@ -107,9 +151,13 @@
 		return true;
 	}
 	else {
-		dbgSerial.println("[### Failed to connect to Wifi ###]");
+		dbgSerial.println("[# Failed to connect to Wifi #]\n");
 		return false;
 	}

 }

+void testFailed(){
+	dbgSerial.println("[### Previous Test Failed ###]");
+	while(1);
+}


Remove old code

Remove old code

--- Arduino/can_bus_writer/can_bus_writer.ino
+++ Arduino/can_bus_writer/can_bus_writer.ino
@@ -39,54 +39,14 @@

           msgID = 0x349;
           int data2[] = { 0x76, 0x0F, 0xBE, 0x1A, 0x00 };
-          send_message(msgID, data2, 5);
+          //send_message(msgID, data2, 5);

           msgID = 0x0C0;
           int data3[] = { 0xF4, 0xFF };
-          send_message(msgID, data3, 2);
+          //send_message(msgID, data3, 2);

-
-
-
         Serial.println("Sent");
-
         delay(100);
-}
-
-//void send_key_in()
-//{
-//          tCAN message;
-//
-//        message.id = 0x130; //formatted in HEX
-//        message.header.rtr = 0;
-//        message.header.length = 5; //formatted in DEC
-//        message.data[0] = 0x45;
-//        message.data[1] = 0x42;
-//        message.data[2] = 0x69;
-//        message.data[3] = 0x8F;
-//        message.data[4] = 0xFE;
-//
-//        mcp2515_bit_modify(CANCTRL, (1<<REQOP2)|(1<<REQOP1)|(1<<REQOP0), 0);
-//        mcp2515_send_message(&message);
-//        send_message(0x130, [0x45, 0x42, 0x69, 0x8F, 0xFE])
-//}
-
-void send_fuel_value()
-{
-          tCAN message;
-
-        message.id = 0x1A1; //formatted in HEX
-        message.header.rtr = 0;
-        message.header.length = 5; //formatted in DEC
-        message.data[0] = 0xBE;
-        message.data[1] = 0xDE;
-        message.data[2] = 0x12;
-        message.data[3] = 0x04;
-        message.data[4] = 0x91;
-        //BE DE 12 04 91
-
-        mcp2515_bit_modify(CANCTRL, (1<<REQOP2)|(1<<REQOP1)|(1<<REQOP0), 0);
-        mcp2515_send_message(&message);
 }

 void send_message(int messageID, int data[], int len)


use analog pin as input

use analog pin as input

--- mouseScroll/mouseScroll.ino
+++ mouseScroll/mouseScroll.ino
@@ -13,8 +13,8 @@
  * Pin 5 is the mouse data pin, pin 6 is the clock pin
  * Feel free to use whatever pins are convenient.
  */
-#define MDATA 5
-#define MCLK 6
+#define MDATA A0
+#define MCLK A1

 /*
  * according to some code I saw, these functions will
@@ -38,10 +38,10 @@
   char i;
   char parity = 1;

-    Serial.print("Sending ");
-    Serial.print(data, HEX);
-    Serial.print(" to mouse\n");
-    Serial.print("RTS\n");
+//    Serial.print("Sending ");
+//    Serial.print(data, HEX);
+//    Serial.print(" to mouse\n");
+//    Serial.print("RTS\n");
   /* put pins in output mode */
   gohi(MDATA);
   gohi(MCLK);
@@ -87,13 +87,12 @@
   delayMicroseconds(50);
   while (digitalRead(MCLK) == HIGH)
     ;
-  Serial.print("Switch mode1");
+
+  gohi(MDATA);

   /* wait for mouse to switch modes */
   while ((digitalRead(MCLK) == LOW) || (digitalRead(MDATA) == LOW))
     ;
-
-  Serial.print("Switch mode2");

   /* put a hold on the incoming data. */
   golo(MCLK);
@@ -152,33 +151,33 @@

   gohi(MCLK);
   gohi(MDATA);
-    Serial.println("Sending reset to mouse\n");
+//    Serial.println("Sending reset to mouse\n");
   mouse_write(0xff);
-    Serial.println("mouse_write");
+//    Serial.println("mouse_write");
   mouse_read();  /* ack byte */
-    Serial.print("Read ack byte1\n");
+//    Serial.print("Read ack byte1\n");
   mouse_read();  /* blank */
   mouse_read();  /* blank */
-    Serial.print("Setting sample rate 200\n");
+//    Serial.print("Setting sample rate 200\n");
   mouse_write(0xf3);  /* Set rate command */
   mouse_read();  /* ack */
   mouse_write(0xC8);  /* Set rate command */
   mouse_read();  /* ack */
-    Serial.print("Setting sample rate 100\n");
+//    Serial.print("Setting sample rate 100\n");
   mouse_write(0xf3);  /* Set rate command */
   mouse_read();  /* ack */
   mouse_write(0x64);  /* Set rate command */
   mouse_read();  /* ack */
-    Serial.print("Setting sample rate 80\n");
+//    Serial.print("Setting sample rate 80\n");
   mouse_write(0xf3);  /* Set rate command */
   mouse_read();  /* ack */
   mouse_write(0x50);  /* Set rate command */
   mouse_read();  /* ack */
-    Serial.print("Read device type\n");
+//    Serial.print("Read device type\n");
   mouse_write(0xf2);  /* Set rate command */
   mouse_read();  /* ack */
   mouse_read();  /* mouse id, if this value is 0x00 mouse is standard, if it is 0x03 mouse is Intellimouse */
-    Serial.print("Setting wheel\n");
+//    Serial.print("Setting wheel\n");
   mouse_write(0xe8);  /* Set wheel resolution */
   mouse_read();  /* ack */
   mouse_write(0x03);  /* 8 counts per mm */
@@ -192,10 +191,10 @@
   mouse_write(0xf4);  /* Enable device */
   mouse_read();  /* ack */

-    Serial.print("Sending remote mode code\n");
+//    Serial.print("Sending remote mode code\n");
   mouse_write(0xf0);  /* remote mode */
   mouse_read();  /* ack */
-    Serial.print("Read ack byte2\n");
+//    Serial.print("Read ack byte2\n");
   delayMicroseconds(100);
 }

@@ -222,8 +221,6 @@
   char mx;
   char my;
   char mz;
-
-  Serial.println("Trying to get the data");

   /* get a reading from the mouse */
   mouse_write(0xeb);  /* give me data! */


Modified connection flag and placement of sensor println.

--- workspace/serialWithoutDistortion/serialWithoutDistortion.ino
+++ workspace/serialWithoutDistortion/serialWithoutDistortion.ino
@@ -1,7 +1,7 @@
 String msg;
 void setup() {
   // put your setup code here, to run once:
-  Serial.begin(115200z);
+  Serial.begin(115200);
   Serial.setTimeout(100);
 }

@@ -12,7 +12,7 @@
     char ping = Serial.read();
     if (ping == '2')
     {
-      Serial.println('0');
+      Serial.println('2');
     }else if(ping == '*')
     {
       msg = Serial.readStringUntil('$');


it moves

it moves

--- XBee_rob_function_2.0/xBee_2.0/xBee_2.0.ino
+++ XBee_rob_function_2.0/xBee_2.0/xBee_2.0.ino
@@ -13,6 +13,48 @@

 #include <Dynamixel_Serial.h>
 #include <readxBee.h>
+#include <SoftwareSerial.h>
+
+#define SERVO_ControlPin 0x02       // Control pin of buffer chip, NOTE: this does not matter becasue we are not using a half to full control buffer.
+#define SERVO_SET_Baudrate 57600    // Baud rate speed which the Dynamixel will be set too (57600)
+#define LED13 0x0D
+#define CW_LIMIT_ANGLE 0x001        // lowest clockwise angle is 1, as when set to 0 it set servo to wheel mode
+#define CCW_LIMIT_ANGLE 0xFFF       // Highest anit-clockwise angle is 0XFFF, as when set to 0 it set servo to wheel mode
+#define OPEN 'o'
+#define CLOSE 'c'
+
+SoftwareSerial mySerial(10, 11);    // RX, TX
+
+void setup() {
+  Serial.begin(115200);
+  Serial1.begin(115200);
+  Serial.flush();                                       // Clear the serial buffer of garbage data before running the code.
+  mySerial.begin(SERVO_SET_Baudrate);                   // We now need to set Ardiuno to the new Baudrate speed 115200
+  Serial.begin(SERVO_SET_Baudrate);                                  // Start serial communication on baudrate 57600
+  Dynamixel.begin(mySerial);                            // Calling mySerial function which sets 10 pin as the 2nd RX serial pin, and sets pin 11 as the 2nd TX serial pin
+  Dynamixel.setDirectionPin(SERVO_ControlPin);          // Optional. Set direction control pin which controls if the program writes or reads
+
+  //Turn on hold for the servos, so they stay in place
+  Dynamixel.setHoldingTorque(0x01, true);               //Set on hold turque for each servo
+  Dynamixel.setHoldingTorque(0x02, true);
+  Dynamixel.setHoldingTorque(0x03, true);
+  Dynamixel.setHoldingTorque(0x04, true);
+  Dynamixel.setHoldingTorque(0x05, true);
+
+  //Set profile acceleration
+  Dynamixel.setProfileAcceleration(0x01, 10);           //Set profile acc for each servo
+  Dynamixel.setProfileAcceleration(0x02, 10);
+  Dynamixel.setProfileAcceleration(0x03, 10);
+  Dynamixel.setProfileAcceleration(0x04, 300);
+  Dynamixel.setProfileAcceleration(0x05, 300);
+
+  //Set profile velocity
+  Dynamixel.setProfileVelocity(0x01, 100);              //Set profile vel for each servo
+  Dynamixel.setProfileVelocity(0x02, 100);
+  Dynamixel.setProfileVelocity(0x03, 100);
+  Dynamixel.setProfileVelocity(0x04, 200);
+  Dynamixel.setProfileVelocity(0x05, 200);
+ }

 int x, y, z, emg1, emg2;
 int infoPk[24];
@@ -23,6 +65,22 @@
             byte jelly = Serial1.read();
             infoPk[i] = jelly;
           }
+
+
+  if(emg1>100){
+    Dynamixel.performMovement(2148, 2048, 2048, CLOSE);   //"Initial" position
+    delay(1500);
+    Dynamixel.performMovement(2148, 1850, 3250, OPEN);     //Ready position
+    delay(2000);
+    Dynamixel.performMovement(1600, 2800, 3200, OPEN);      //Move to sponge.
+    Dynamixel.gripper(CLOSE);                               //Grab
+    Dynamixel.performMovement(2148, 1850, 3250, CLOSE);     //Detour
+    Dynamixel.performMovement(2650, 2800, 3200, CLOSE);     //Move to destination
+    delay(500);
+    Dynamixel.gripper(OPEN);                                //Release
+  delay(500);
+  }
+
   for(int a = 13; a < 24; a++) {
     y = infoPk[15] + (infoPk[14] << 8);
     z = infoPk[13] + (infoPk[12] << 8);
@@ -36,13 +94,11 @@
     Serial.print(" EMG Ch.1 = ") && Serial.print(emg1);
     Serial.print(" EMG Ch.2 = ") && Serial.print(emg2);
     Serial.println();
+
   }
  }
-}
-void setup() {
-  Serial.begin(115200);
-  Serial1.begin(115200);
-}
+ }
+

 void loop() {
   actualName();


Cleaned up code for testing RTC and SD

Cleaned up code for testing RTC and SD

--- Sensors/Sensor-Main.ino
+++ Sensors/Sensor-Main.ino
@@ -2,7 +2,7 @@
 #include <SD.h>
 #include "Wire.h"

-//Definations
+//Definitions
 #define DS1307_ADDRESS 0x86;//Need to get updated I2C Address
 byte zero = 0x00; //Needed as a workaround for issue #537 RTC Support
 File testFile;
@@ -21,7 +21,7 @@
 }

 void loop(){
-	//This is testing writing to a file on the sdcard
+	/*This is testing writing to a file on the sdcard
 	testFile = SD.open("test.txt", FILE_WRITE);

 	if (testFile) {
@@ -34,8 +34,9 @@
     	// if the file didn't open, print an error:
     	Serial.println("error opening test.txt");
   	}
-
-  	//This is for testing the RTC
+	*/
+  	/*
+  	//This is for testing the RTC and printing to serial
   	Wire.beginTransmission(DS1307_ADDRESS);
  	Wire.write(zero); //Workaround
    	Wire.endTransmission();
@@ -62,4 +63,5 @@
   	Serial.print(minute);
   	Serial.print(":");
   	Serial.print(second);
+  	*/
 }


Dst fix

Dst fix

--- NeoPixelNightLight/NeoPixelNightLight.ino
+++ NeoPixelNightLight/NeoPixelNightLight.ino
@@ -90,7 +90,7 @@
 bool pressed = false;
 bool changingModes = false;

-// helper to get time for testing if no UTC available
+// helper to get time for testing if no RTC available
 DateTime getCurrent()
 {
   DateTime ret;
@@ -99,14 +99,14 @@
   else
     ret = compileTime.unixtime() + millis() / 50; // speed up time! use 1000 for close to real time

-  // need to sprint forward? 2am, second Sunday in March
-  if ( ret.month() == 2 && ret.dayOfTheWeek() == 0 && ret.hour() == 2 && (ret.day() % 7) == 1 )
+  // need to spring forward? 2am, second Sunday in March
+  if ( ret.month() == 3 && ret.dayOfTheWeek() == 0 && ret.hour() == 2 && (ret.day() / 7) == 1 && inDst == 0)
   {
     inDst = 1;
     ret = ret + TimeSpan(0,1,0,0);
     rtc.adjust(ret);
   }
-  else if ( ret.month() == 11 && ret.dayOfTheWeek() == 0 && ret.hour() == 2 && (ret.day() % 7) == 0 && inDst == 1 )
+  else if ( ret.month() == 11 && ret.dayOfTheWeek() == 0 && ret.hour() == 2 && (ret.day() / 7) == 0 && inDst == 1 )
   {
     // need to fall back first Sunday in November 2am back to 1am
     inDst = 0;
@@ -187,7 +187,7 @@
   }
   //Adjust for weeks
   targetDate += (NthWeek-1)*7;
-  return new DateTime ( year, month, targetDate, hour, min );
+  return DateTime ( year, month, targetDate, hour, min );
 }

 void setDst( DateTime current )
@@ -202,6 +202,14 @@
        inDst = 0;
   Serial.print("Setting DST to ");
   Serial.println(inDst);
+  char buffer[100];
+  sprintf(buffer, "Current  is %d/%d/%d %d:%d", (int)current.month(), (int)current.day(), (int)current.year(), (int)current.hour(), (int)current.minute() );
+  Serial.println(buffer);
+  sprintf(buffer, "StartDst is %d/%d/%d %d:%d", (int)startDst.month(), (int)startDst.day(), (int)startDst.year(), (int)startDst.hour(), (int)startDst.minute() );
+  Serial.println(buffer);
+  sprintf(buffer, "EndDst   is %d/%d/%d %d:%d", (int)endDst.month(), (int)endDst.day(), (int)endDst.year(), (int)endDst.hour(), (int)endDst.minute() );
+  Serial.println(buffer);
+
 }

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


TODO-851: make secondary radio panic explicit

--- V0p2_Main/V0p2_Main.ino
+++ V0p2_Main/V0p2_Main.ino
@@ -329,7 +329,7 @@
   DEBUG_SERIAL_PRINTLN_FLASHSTRING("R2");
 #endif
   // Check that the radio is correctly connected; panic if not...
-  if(!SecondaryRadio.configure(1, &SecondaryRadioConfig) || !SecondaryRadio.begin()) { panic(); }
+  if(!SecondaryRadio.configure(1, &SecondaryRadioConfig) || !SecondaryRadio.begin()) { panic(F("r2")); }
   // Assume no RX nor filtering on secondary radio.
 #endif // ENABLE_RADIO_SECONDARY_MODULE


Update BLE_server_encrypted.ino

Update BLE_server_encrypted.ino

--- cpp_utils/tests/BLETests/Arduino/security/BLE_server/BLE_server_encrypted/BLE_server_encrypted.ino
+++ cpp_utils/tests/BLETests/Arduino/security/BLE_server/BLE_server_encrypted/BLE_server_encrypted.ino
@@ -17,7 +17,7 @@
   Serial.begin(115200);
   Serial.println("Starting BLE work!");

-  BLEDevice::init("MyESP32");
+  BLEDevice::init("ESP32");
   /*
    * Here we have implemented simplest security. This kind security does not provide authentication
    */
@@ -40,4 +40,4 @@
 void loop() {
   // put your main code here, to run repeatedly:
   delay(2000);
-}+}


Adjust max sensor distance to something more suitable

--- examples/sensors/ultrasounds/HCSR04/HCSR04.ino
+++ examples/sensors/ultrasounds/HCSR04/HCSR04.ino
@@ -2,7 +2,8 @@

 const int TRIGGER_PIN = 6; //D6
 const int ECHO_PIN = 7; //D7
-SR04 front(TRIGGER_PIN, ECHO_PIN, 10);
+const unsigned int MAX_DISTANCE = 100;
+SR04 front(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

 void setup() {


Make TLC compile-time optional

Make TLC compile-time optional

--- src/Full_decoder/Full_decoder.ino
+++ src/Full_decoder/Full_decoder.ino
@@ -27,6 +27,7 @@
 uint8_t pins_conf = 0;

 /* TLC5947 Support*/
+#if TLC_SUPPORT
 #include "Adafruit_TLC5947.h"

 // How many boards do you have chained?
@@ -38,6 +39,7 @@
 #define oe  -1  // set to -1 to not use the enable pin (its optional)

 Adafruit_TLC5947 tlc = Adafruit_TLC5947(NUM_TLC5974, clock, data, latch);
+#endif // TLC_SUPPORT

 /* PCA9685 Support */

@@ -158,10 +160,12 @@
         confpins[slot] = new DualAction(slot, pin, address, pos1, pos2, speed, pin_config);
         confpins[slot]->restore_state(eeprom_read_word((uint16_t*)&(_CV.conf[slot].servo.state)));
         break;
+#if TLC_SUPPORT
       case 101: // TLC5947 PWM LED Controller.
         pin_config = ((eeprom_read_word((uint16_t*)&(_CV.conf[slot].output.options)) & 0x01) == 0x01);
         confpins[slot] = new TLC5947pin(&tlc, slot, pin, address, pin_config, pin, 1000);
         break;
+#endif // TLC_SUPPORT
       case 102: // PCA9686
         pos1  = eeprom_read_word((uint16_t*)&(_CV.conf[slot].servo.pos1));
         pos2  = eeprom_read_word((uint16_t*)&(_CV.conf[slot].servo.pos2));
@@ -201,7 +205,9 @@
   for (i = 0; i < pins_conf; i++) {
     configureSlot(i);
   }
+#if TLC_SUPPORT
   tlc.begin();
+#endif //TLC_SUPPORT

   if (!ds.search(addr)) {
     ds.reset_search();


Cleanup receiver code

Cleanup receiver code

Small cleanup update. Changed tabs to spaces and improved formatting
slightly.

--- src/Argo2_Receiver/Argo2_Receiver.ino
+++ src/Argo2_Receiver/Argo2_Receiver.ino
@@ -2,7 +2,7 @@
  *
  * Tomas Manterola
  *
- * Adafruit Feather M0 Adalogger Program for interface with RFM96W receiver.
+ * Adafruit Feather M0 Adalogger Program for interface with a RFM96W receiver.
  * Receives and transmits data from and to capsule.
  * GroundStation program must be used on computer connected to the microcontroller.
  */
@@ -15,7 +15,6 @@
 // Indicator LEDs
 #define RX_LED 8
 #define TX_LED 13
-

 // RFM96W Chip Select and Interrupt pins
 #define RFM_CS 17
@@ -30,123 +29,125 @@

 void setup() {
-	// Start serial communication with computer
-	Serial.begin(9600);
-
-	// Configure LEDs to OUTPUT
-	pinMode(RX_LED, OUTPUT);
-	pinMode(TX_LED, OUTPUT);
-
-	// Wait until computer catches up connecting to Serial
-	delay(5000);
-
-	// Initialize RFM96W - if there's an error retry
-	while (!rf95.init()) {
-		Serial.println("RFM96W Initialization Failed!");
-		delay(1000);
-	}
-
-	//Configure RFM96W
-	configureRFM96W();
-
-	// Set RFM96W to receiver mode so that it can receive messages
-	rf95.setModeRx();
+
+    // Start serial communication with computer
+    Serial.begin(9600);
+
+    // Configure LEDs to OUTPUT
+    pinMode(RX_LED, OUTPUT);
+    pinMode(TX_LED, OUTPUT);
+
+    // Wait until computer catches up connecting to Serial
+    delay(5000);
+
+    // Initialize RFM96W - if there's an error retry
+    while (!rf95.init()) {
+        Serial.println("RFM96W Initialization Failed!");
+        delay(1000);
+    }
+
+    //Configure RFM96W
+    configureRFM96W();
+
+    // Set RFM96W to receiver mode so that it can receive messages
+    rf95.setModeRx();
 }

 void loop() {
-	// Check for messages from capsule and send to Ground Station ([MSG];[RSSI])
-	if (rf95.available()) {
-		uint8_t data[RH_RF95_MAX_MESSAGE_LEN];
-		uint8_t len = sizeof(data);
-
-		// Receive data and check for errors ('rf95.recv(data, &len)' returns 0 if error occurs)
-		if (rf95.recv(data, &len)) {
-			// Turn on RX_LED
-			digitalWrite(RX_LED, HIGH);
-
-			// Send data
-			Serial.print((char*)data);
-
-			// Add RSSI to message
-			Serial.print(";");
-			Serial.println(rf95.lastRssi(), DEC);
-
-			// Turn off RX_LED
-			delay(100);
-			digitalWrite(RX_LED, LOW);
-
-		} else {
-			Serial.println("Error receiving message!");
-		}
-	}
-
-	// Send any messages from Ground Station to capsule ([TX_POWER];[MSG])
-	if (Serial.available()) {
-		// Read TX Power and message to be transmitted from Serial and save these in 'tx_power' and 'msg' respectively
-		tx_power = Serial.readStringUntil(';').toInt();
-		Serial.readStringUntil('\n').toCharArray((char*)msg, sizeof(msg));
-
-		// Calculate and append checksum
-		char checksum_str[8];
-		snprintf(checksum_str, sizeof(checksum_str), "*%04X", crc16(msg, strlen((char*)msg)));
-		strcat((char*)msg, checksum_str);
-
-		// Send data
-		sendData(msg);
-	}
+
+    // Check for messages from capsule and send to Ground Station ([MSG];[RSSI])
+    if (rf95.available()) {
+        uint8_t data[RH_RF95_MAX_MESSAGE_LEN];
+        uint8_t len = sizeof(data);
+
+        // Receive data and check for errors ('rf95.recv(data, &len)' returns 0 if error occurs)
+        if (rf95.recv(data, &len)) {
+            // Turn on RX_LED
+            digitalWrite(RX_LED, HIGH);
+
+            // Send data
+            Serial.print((char*)data);
+
+            // Add RSSI to message
+            Serial.print(";");
+            Serial.println(rf95.lastRssi(), DEC);
+
+            // Turn off RX_LED
+            delay(100);
+            digitalWrite(RX_LED, LOW);
+
+        } else {
+            Serial.println("Error receiving message!");
+        }
+    }
+
+    // Send any messages from Ground Station to capsule ([TX_POWER];[MSG])
+    if (Serial.available()) {
+        // Read TX Power and message to be transmitted from Serial and save these in 'tx_power' and 'msg' respectively
+        tx_power = Serial.readStringUntil(';').toInt();
+        Serial.readStringUntil('\n').toCharArray((char*)msg, sizeof(msg));
+
+        // Calculate and append checksum
+        char checksum_str[8];
+        snprintf(checksum_str, sizeof(checksum_str), "*%04X", crc16(msg, strlen((char*)msg)));
+        strcat((char*)msg, checksum_str);
+
+        // Send data
+        sendData(msg);
+    }
 }

-// 	RFM96W Transceiver Configuration (Registers: 0x1D, 0x1E, 0x26)
+//  RFM96W Transceiver Configuration (Registers: 0x1D, 0x1E, 0x26)
 //
-// 	Bandwith (BW): 125 kHz 			= 7
-// 	Coding Rate (CR): 4/8 			= 4
-// 	Mode: Explicit					= 0
-// 	Spreading Factor (SF): 4096		= 12
-// 	LowDataRateOptimization: ON 	= 1
+//  Bandwith (BW): 125 kHz          = 7
+//  Coding Rate (CR): 4/8           = 4
+//  Mode: Explicit                  = 0
+//  Spreading Factor (SF): 4096     = 12
+//  LowDataRateOptimization: ON     = 1
 //
-//	Preamble Length 				= 8
-//	Frequency						= 434.000 MHz
+//  Preamble Length                 = 8
+//  Frequency                       = 434.000 MHz

 void configureRFM96W() {
-	const RH_RF95::ModemConfig cfg = {
-		// Register 0x1D:
-		// BW   	  CR        Mode
-		(7 << 4) | (4 << 1) | (0 << 0),
-
-		// Register 0x1E:
-		//  SF
-		(12 << 4),
-
-		// Register 0x26:
-		// Low Data Rate Optimization
-		(1 << 3)
-	};
-	rf95.setModemRegisters(&cfg);
-
-	rf95.setPreambleLength(8);
-	rf95.setFrequency(434.000);
+    const RH_RF95::ModemConfig cfg = {
+        // Register 0x1D:
+        // BW         CR        Mode
+        (7 << 4) | (4 << 1) | (0 << 0),
+
+        // Register 0x1E:
+        //  SF
+        (12 << 4),
+
+        // Register 0x26:
+        // Low Data Rate Optimization
+        (1 << 3)
+    };
+    rf95.setModemRegisters(&cfg);
+
+    rf95.setPreambleLength(8);
+    rf95.setFrequency(434.000);
 }

 // Send data using RFM96W LoRa Transceiver
 // Uses 'tx_power' to set transmission power
 void sendData(uint8_t msg[]) {
-	// Set TX Power to value received from GroundStation
-	rf95.setTxPower(tx_power);
-
-	// Send message and turn on TX_LED
-	// Length doesn't include null-character (string terminator), so add 1
-	rf95.send(msg, strlen((char*)msg) + 1);
-	digitalWrite(TX_LED, HIGH);
-
-	// Wait until packet is completely sent and turn off TX_LED
-	rf95.waitPacketSent();
-	digitalWrite(TX_LED, LOW);
-
-	// Set RFM96W back to receiver mode so that it can receive any new messages
-	rf95.setModeRx();
+    // Set TX Power to value received from GroundStation
+    rf95.setTxPower(tx_power);
+
+    // Send message and turn on TX_LED
+    // Length doesn't include null-character (string terminator), so add 1
+    rf95.send(msg, strlen((char*)msg) + 1);
+    digitalWrite(TX_LED, HIGH);
+
+    // Wait until packet is completely sent and turn off TX_LED
+    rf95.waitPacketSent();
+    digitalWrite(TX_LED, LOW);
+
+    // Set RFM96W back to receiver mode so that it can receive any new messages
+    rf95.setModeRx();
 }


TW-50: made messages scroll on bottom of screen always leaving time and date visible.

--- tinywatch.ino
+++ tinywatch.ino
@@ -10,15 +10,18 @@
 #define BLE_RDY 2
 #define BLE_RST 9

-const int SCREEN_WIDTH = 48;
-
+const int SCREEN_HEIGHT = 48;
+const int SCREEN_WIDTH = 96;
+const int MSG_X_START = -200;
 //Determines which version of TinyScreen we are using.
 TinyScreen display = TinyScreen(TinyScreenPlus);
 //Buffer used for drawing.
 RenderBuffer<uint16_t, 20> buffer;
+char* msg = "";
 int rBackground = 0;
 int gBackground = 0;
 int bBackground = 0;
+int msgX = -100;
 char isTimeSet = 0;
 //Temp sleep
 char isSleep = 0;
@@ -73,6 +76,7 @@
   } else if (!central || !central.connected()) {
     buffer.drawText("Searching...", 15, 8, buffer.rgb(255, 255, 255), &liberationSans_8ptFontInfo);
   }
+  renderMessage();

   //temp sleep
   isSleep ? display.off() : display.on();
@@ -86,11 +90,13 @@
 }

 void blePeripheralConnectHandler(BLECentral& central) {
-  messageWithSecondDelay("Connected...");
+  msg = "Connected...";
+  msgX = MSG_X_START;
 }

 void blePeripheralDisconnectHandler(BLECentral& central) {
-  messageWithSecondDelay("Disconnected...");
+  msg = "Disconnected...";
+  msgX = MSG_X_START;
 }

 void setTimeHandler(BLECentral& central, BLECharacteristic& characteristic) {
@@ -98,10 +104,8 @@
   isTimeSet = 1;
 }

-void messageWithSecondDelay(String msg) {
-  buffer.drawText(stringBuffer.start().put(msg.c_str()).get(), 15, 8, buffer.rgb(255, 255, 255), &liberationSans_8ptFontInfo);
-  refreshScreen();
-  delay(1000);
+int centerX(){
+  return SCREEN_WIDTH/2;
 }

 void refreshScreen() {
@@ -111,16 +115,26 @@

 void renderTime() {
   char* timeString = stringBuffer.start().put(hour() < 10 ? "0" : "").putDec(hour()).put(":").put(minute() < 10 ? "0" : "").putDec(minute()).put(":").put(second() < 10 ? "0" : "").putDec(second()).get();
-  buffer.drawText(timeString, 22, 16, buffer.rgb(255, 255, 255), &liberationSans_12ptFontInfo);
+  buffer.drawText(timeString, centerX() - 36, 16, buffer.rgb(255, 255, 255), &liberationSans_16ptFontInfo);
 }

 void renderDate() {
   char* dateString = stringBuffer.start().putDec(month()).put("-").putDec(day()).put("-").putDec(year()).get();
-  buffer.drawText(dateString, 26, 34, buffer.rgb(255, 255, 255), &liberationSans_8ptFontInfo);
+  buffer.drawText(dateString, centerX() - 24, 34, buffer.rgb(255, 255, 255), &liberationSans_10ptFontInfo);
 }

 void renderBackground() {
   buffer.drawRect(0, 0, 96, 64)->filledRect(buffer.rgb(rBackground, gBackground, bBackground));
+}
+
+void renderMessage(){
+  if(msg != "" && msgX < (SCREEN_WIDTH + abs(MSG_X_START))){
+    buffer.drawText(msg, msgX, 48, buffer.rgb(255, 255, 255), &liberationSans_8ptFontInfo);
+    msgX++;
+  } else{
+    msg = "";
+    msgX = MSG_X_START;
+  }
 }

 //TODO: Method to render orientation.


fixed arduino firmware to disable torque when serial_node.py is killed.

--- jsk_2016_01_baxter_apc/firmware/gripper_front_manager_right.ino
+++ jsk_2016_01_baxter_apc/firmware/gripper_front_manager_right.ino
@@ -116,8 +116,12 @@
 void loop() {
     float temp_act = 0.0, press_act = 0.0;
     unsigned long int press_cal, temp_cal;
-
-    if (millis() > publisher_timer) {
+
+    if (!nh.connected()) {
+        servo_torque_msg.data = false;
+        servo_angle_msg.data = 0;
+        myservo.detach();
+    } else if (millis() > publisher_timer) {
         readData();
         temp_cal = calibration_T(temp_raw);
         press_cal = calibration_P(pres_raw);


OutputExpander experimenting.

OutputExpander experimenting.

--- Mpe/Plugs/OutputExpander/OutputExpander.ino
+++ Mpe/Plugs/OutputExpander/OutputExpander.ino
@@ -14,7 +14,7 @@
 int outputEnable = 0;

 // Testing on 5 pins (MSB, so starting at
-int maxPins = 8;
+int maxPins = 9;

 void shift(int q)
 {
@@ -32,16 +32,30 @@
   pinMode(clockPin, OUTPUT);
   pinMode(dataPin, OUTPUT);
 }
-
+int x = 0;
 void loop()
-{
+{/*
   for (int pinNumber = 0; pinNumber <= maxPins; pinNumber++)
   {
     shift(pinNumber);
 #if SERIAL
     Serial.println(pinNumber);
 #endif
-    delay(80);
+    delay(120);
   }
   delay(800);
+*/
+//delay(100);
+  delay(x);
+  digitalWrite(latchPin, LOW);
+
+
+  shiftOut(dataPin, clockPin, MSBFIRST, 0b11001100);
+
+  delay(10);
+  digitalWrite(latchPin, HIGH);
+
+
+  x += 10;
+  if (x==0xf) x = 0;
 }


Correct typo in example, az was printed instead of ax

--- libraries/CurieImu/examples/RawImuDataSerial/RawImuDataSerial.ino
+++ libraries/CurieImu/examples/RawImuDataSerial/RawImuDataSerial.ino
@@ -137,7 +137,7 @@

   // display tab-separated accel/gyro x/y/z values
   Serial.print("a/g:\t");
-  Serial.print(az);
+  Serial.print(ax);
   Serial.print("\t");
   Serial.print(ay);
   Serial.print("\t");


fix variable

fix variable

--- testing/arduino/omniwheel4_EncoderC.ino
+++ testing/arduino/omniwheel4_EncoderC.ino
@@ -178,9 +178,9 @@

         for(uint8_t i = 0; i < sizeof(SpeedMapping_Motor3); ++i) {
             Serial.println("----------");
-            Serial.println(SpeedMapping_Motor1[i].value);
-            Serial.println(SpeedMapping_Motor2[i].value);
-            Serial.println(SpeedMapping_Motor3[i].value);
+            Serial.println(SpeedMapping_Motor1[i].RPM);
+            Serial.println(SpeedMapping_Motor2[i].RPM);
+            Serial.println(SpeedMapping_Motor3[i].RPM);
         }
     }
 }


Added LCD display and changed data acquistion loop.

The changes in the data acquisition loop should be temporary and/or
reviewed to make sure they are ok.

--- oktopus-autopilote/oktopus-autopilote.ino
+++ oktopus-autopilote/oktopus-autopilote.ino
@@ -8,47 +8,109 @@
 #include "GPS.h"
 #include "Gyroscope.h"
 #include "Moisture.h"
+#include "RudderServo.h"
 #include "Temperature.h"
+#include <LiquidCrystal.h>

+void cycleDataOnLCD();
+int averageDataSamples(int dataSamples[], int numberOfSamples);
+
+LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
 GPS gps;
 Gyroscope gyroscope;
 Moisture moistureSensor;
+RudderServo rudderServo;
 Temperature temperatureSensor;

-float heading = 0.00;
+int heading[15];
 NMEAData gpsData;
 String moisture = "Unknown";
 short temperature = 0;
+int angle = 0;

 void setup() {
   Serial.begin(115200);
   gps.enable();
+  gyroscope.enable();
   moistureSensor.enable();
+  rudderServo.enable();
   temperatureSensor.enable();
-  gyroscope.enable();
+  lcd.begin(16, 2);
+  lcd.clear();
+  lcd.setCursor(0, 0);
+  lcd.print("Oktopus");
+  lcd.setCursor(0, 1);
+  lcd.print("autopilot");
+
 }

-uint32_t timer = millis();
+uint32_t timer1 = millis();
+uint32_t timer2 = millis();
+uint8_t count = 0;

 void loop() {
-
+
   gpsData = gps.getData();

   // if millis() or timer wraps around, we'll just reset it
-  if (timer > millis())  timer = millis();
+  if (timer1 > millis())  timer1 = millis();
+  if (timer2 > millis())  timer2 = millis();

-  if (millis() - timer > 2000) {
+
+  if (millis() - timer1 > 100) {
+    timer1 = millis(); // reset the time
+    heading[count] = gyroscope.getData();
+    if (count < 14) {
+      count++;
+    } else {
+      count = 0;
+    }
+  }
+  if (millis() - timer2 > 2500) {
+    gps.printData(gpsData);
+    rudderServo.setAngle(-40);
+    delay(500);
+    rudderServo.setAngle(0);
+    delay(500);
+    rudderServo.setAngle(40);
+    delay(500);
+  }
+  if (millis() - timer2 > 5000) {
+      timer2 = millis(); // reset the time

-    timer = millis(); // reset the time
-
-    heading = gyroscope.getData();
-    moisture = moistureSensor.getData();
-    temperature = temperatureSensor.getData();
-
-    gps.printData(gpsData);
-    gyroscope.printData(heading);
-    moistureSensor.printData(moisture);
-    temperatureSensor.printData(temperature);
+      angle = rudderServo.getData();
+      moisture = moistureSensor.getData();
+      temperature = temperatureSensor.getData();
+
+      gyroscope.printData(averageDataSamples(heading, 15));
+      moistureSensor.printData(moisture);
+      rudderServo.printData(angle);
+      temperatureSensor.printData(temperature);
+      cycleDataOnLCD();
   }
 }

+void cycleDataOnLCD() {
+  lcd.clear();
+  lcd.setCursor(0, 0);
+  lcd.print("GYR:");
+  lcd.print(averageDataSamples(heading, 15));
+  lcd.print(" HUM:");
+  lcd.print(moisture);
+  lcd.setCursor(0, 1);
+  lcd.print("ANG:");
+  lcd.print(angle);
+  lcd.print(" TMP: ");
+  lcd.print(temperature);
+}
+
+int averageDataSamples(int dataSamples[], int numberOfSamples){
+  int average = 0;
+  int sum = 0;
+  for (int i = 0; i < numberOfSamples; i++) {
+    sum = sum + dataSamples[i];
+  }
+  average = sum/numberOfSamples;
+  return average;
+}
+


add tool

add tool

--- arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/OPM_for_Arduino/test_manager/test_manager.ino
+++ arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/OPM_for_Arduino/test_manager/test_manager.ino
@@ -12,16 +12,27 @@

 #define NONE      -1

+#define FIST_MAni
+#define se
+
 void setup()
 {
-  Manipulator manipulator;
-  manipulator.addworld(WORLD,position, orientation)
+  // Manipulator manipulator;
+  addManipulator();
+  addworld(manipulator, WORLD,position, orientation);
+  addComponent();
+  addTool();
+
   manipulator.addComponent(WORLD, NONE, BASE, mass, inertia_tensor, relative_position, relative_orientation, axis_of_rotation);
   manipulator.addComponent(WORLD, NONE, BASE, mass, inertia_tensor, relative_position, relative_orientation, axis_of_rotation);
   manipulator.addComponent(WORLD, NONE, BASE, mass, inertia_tensor, relative_position, relative_orientation, axis_of_rotation);
   manipulator.addComponent(WORLD, NONE, BASE, mass, inertia_tensor, relative_position, relative_orientation, axis_of_rotation);
   manipulator.addComponent(WORLD, NONE, BASE, mass, inertia_tensor, relative_position, relative_orientation, axis_of_rotation);

+  getManipulator(manipulator);
+
+  OMLinkKinematics OMLinkKinematics;
+  connectForward(OMLinkKinematics.forward(First_manipulator));
 }

 void loop()


Fix Pin Switching to use written value

Fix Pin Switching to use written value

--- src/arduino101/science-journal-arduino/science-journal-arduino.ino
+++ src/arduino101/science-journal-arduino/science-journal-arduino.ino
@@ -62,7 +62,7 @@
 void bleConfigChangeHandler(BLECentral& central, BLECharacteristic& characteristic) {
   // config characteristic event handler
   DEBUG_PRINTLN("config change event");
-  handle( (uint8_t*) config, 20);
+  handle( (uint8_t*) characteristic.value(), characteristic.valueLength());
   DEBUG_PRINT("Pin: ");
   DEBUG_PRINTLN(pin);
 }


test 3

test 3

--- _43-PietteTech_DHT-8266/_43-PietteTech_DHT-8266.ino
+++ _43-PietteTech_DHT-8266/_43-PietteTech_DHT-8266.ino
@@ -186,10 +186,9 @@
           if ( acquireresult == 0 ) {
             t = DHT.getCelsius();
             h = DHT.getHumidity();
-
-            bDHTstarted = false;
-            DHTnextSampleTime = millis() + DHT_SAMPLE_INTERVAL;
           }
+          bDHTstarted = false;
+          DHTnextSampleTime = millis() + DHT_SAMPLE_INTERVAL;
         }
       }


Modify: fix steering control.

Modify: fix steering control.

--- arduino/Steer_control_and_RC/Steer_control_and_RC.ino
+++ arduino/Steer_control_and_RC/Steer_control_and_RC.ino
@@ -6,6 +6,11 @@
   memcpy(bytes_temp, (unsigned char*) (&float_variable), 4);
 }

+float receiver_scaler(float input, float max_value) {
+  float result = (input - 1500) / 400 * max_value;
+  result = (input > max_value) ? max_value : ((input < -max_value) ? -max_value : input);
+  return result;
+}
 // the cs pin of the version after v1.1 is default to D9
 // v0.9b and v1.0 is default D10
 const int SPI_CS_PIN = 9;
@@ -49,31 +54,59 @@
 }

 void loop() {
+  ///receive steering can msg
+  unsigned char len = 0;
+  unsigned char buf[5];
+  unsigned char first_byte = 0x0000;
+  unsigned char second_byte = 0x0000;
+
+  int steer_angle = 0x0000;
+
+  if (CAN_MSGAVAIL == CAN.checkReceive())           // check if data coming
+  {
+    CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf
+
+    unsigned int canId = CAN.getCanId();
+
+    Serial.println("-----------------------------");
+    Serial.print("Get data from ID: ");
+    Serial.println(canId, HEX);
+
+    for (int i = 0; i < len; i++) // print the data
+    {
+      Serial.print(buf[i], HEX);
+      Serial.print("\t");
+    }
+    first_byte = buf[1];
+    second_byte = buf[0];
+    steer_current = (first_byte << 8) | second_byte;
+
+    Serial.print("angle_hex = ");
+    Serial.print(steer_current, HEX);
+    Serial.print("  angle = ");
+    Serial.println(steer_current, DEC);
+
+    Serial.println();
+  }
+
   //  CAN.sendMsgBuf(0x01, 0, 8, rotate);
   ch1 = pulseIn(6, HIGH, 25000); // each channel
   ch2 = pulseIn(5, HIGH, 25000); // each channel
-  float voltage = (ch1 - 1550) / 300 * 19;
-  voltage = (voltage > 19) ? 19 : ((voltage < 0) ? 0 : voltage);
-  float steering_target = (ch2 - 1500) / 400 * 750;
-  steering_target = (steering_target > 750) ? 750 : ((steering_target < -750) ? -750 : steering_target );
-  //  if (Serial.available() > 0) {
-  //    float_value = Serial.parseFloat();
-  //  }
+
+  float voltage = receiver_scaler(ch1, 19);
+  float steering_target = receiver_scaler(ch2, 750);
+
   myPID.SetTunings(kp, ki, kd)
   myPID.Compute();

-  float2Bytes(motor_1_back, voltage);
-  unsigned char* total_rotate = (unsigned char*)malloc(8 * sizeof(char)); // array to hold the result
-  memcpy(total_rotate,     motor_1_front, 4 * sizeof(unsigned char)); // copy 4 floats from x to total[0]...total[3]
-  memcpy(total_rotate + 4, motor_1_back, 4 * sizeof(unsigned char)); // copy 4 floats from y to total[4]...total[7]
+
   //steering motor Sendmsg
   float2Bytes(motor_2_back, steering_voltage);
   unsigned char* total_rotate = (unsigned char*)malloc(8 * sizeof(char)); // array to hold the result
   memcpy(total_rotate,     motor_2_front, 4 * sizeof(unsigned char)); // copy 4 floats from x to total[0]...total[3]
   memcpy(total_rotate + 4, motor_2_back, 4 * sizeof(unsigned char)); // copy 4 floats from y to total[4]...total[7]

-  CAN.sendMsgBuf(0x01, 0, 8, total_rotate);
-
+//  CAN.sendMsgBuf(0x01, 0, 8, total_rotate);
   for (int i = 0; i < 8; i++) {
     Serial.print(total_rotate[i], HEX);
     Serial.print('\t');
@@ -82,6 +115,8 @@

   free(total_rotate);
   delay(10);
+
+
 }

 // END FILE


ciritical bugsfix, caused a very annoying crash!

--- BuggyTracker/BuggyTracker.ino
+++ BuggyTracker/BuggyTracker.ino
@@ -91,11 +91,11 @@
     Serial.println("printing distance");
   #endif
   if (ble_connected()) {
-              char output[25];
-            // length of output should be: 5 fixed, 10 time, 10 distance;
+              char output[26];
+            // length of output should be: 5 fixed, 10 time, 10 distance, but must be one longer?!?
          sprintf(output,"D:%10lu:%10lu\n\n",time,curDistance);

-          ble_write_bytes((unsigned char *)output,25);
+          ble_write_bytes((unsigned char *)output,26);
   }
 }


Quick comment updates

Quick comment updates

--- SoMoV4/SoMoV4_Test/SoMoV4_Test.ino
+++ SoMoV4/SoMoV4_Test/SoMoV4_Test.ino
@@ -205,7 +205,7 @@
   return temp*127;
 }

-#define MAG_CENTER  0        // Assume same for x, y, and z
+#define MAG_CENTER 0        // Assume same for x, y, and z
 #define MAG_RANGE  32000
 #define MAG_MAX    (MAG_CENTER+MAG_RANGE)
 #define MAG_MIN    (MAG_CENTER-MAG_RANGE)
@@ -234,7 +234,7 @@
 }

-// Scale one of the inputs to return distance from center (0=centered, 1=min or max)
+// Scale one of the inputs to return distance from center (0.0=centered, 1.0=min or max, may exceed 1.0)
 float ScaleAbs(long in, long center, long range)
 {
   // Get the absolute distance from center


Fix Hand Module Tranceiver

Fix Hand Module Tranceiver

--- Software/HandModule/HandModule.ino
+++ Software/HandModule/HandModule.ino
@@ -29,8 +29,8 @@
  */

 #include <SPI.h>
+#include <RF24.h>
 #include <printf.h>
-#include <RF24.h>

 class Motor
 {
@@ -126,6 +126,7 @@
   radio.setAutoAck(1);
   radio.openReadingPipe(1, address);
   radio.startListening();
+  radio.printDetails();
   Serial.println("Radio is listening...");

   // Initializing Motor
@@ -140,8 +141,8 @@
 {
   if (radio.available())
   {
-    while(radio.available());
-    {
+    while (radio.available())
+    {
       radio.read(&data, 1);

       Serial.print("Data received: ");
@@ -149,12 +150,13 @@
       parseCommand(data);
     }
   }
+
+  // Run Motor Timeout Controller
+  for (int i = 0; i < MOTOR_COUNT; i++)
+  {
+    motor[i].timeoutControl();
+  }

-  // Run Motor Timeout Controller
-  for (int i = 0; i < MOTOR_COUNT; i++)
-  {
-    motor[i].timeoutControl();
-  }
 }

 /**
@@ -167,7 +169,7 @@
   byte command = message & 0xF0;
   byte channel = message & 0x0F;

-  if (channel > 9)
+  if (channel > MOTOR_COUNT - 1)
     return;

    switch(command)
@@ -208,3 +210,4 @@
     motor[i].turnOff();
   }
 }
+


fixed compilation error

fixed compilation error

--- ASC_Alexa_Sprinkler_Controller/ASC_Alexa_Sprinkler_Controller.ino
+++ ASC_Alexa_Sprinkler_Controller/ASC_Alexa_Sprinkler_Controller.ino
@@ -93,7 +93,7 @@
   mcp.pinMode(5, OUTPUT);
   mcp.pinMode(6, OUTPUT);
   mcp.pinMode(7, OUTPUT);
-  mcp.pinMode(8, OUTPUT);
+  //mcp.pinMode(8, OUTPUT); GPB0 test

 // ensure that each pin defaults to HIGH (relay off)
 // these cheap blue relay modules use active low logic.
@@ -105,7 +105,7 @@
   mcp.digitalWrite(5, HIGH); //K6
   mcp.digitalWrite(6, HIGH); //K7
   mcp.digitalWrite(7, HIGH); //K8
-  //mcp.digitalWrite(8, HIGH); MCP23017 GPB0 test
+  //mcp.digitalWrite(8, LOW); // GPB0 test

 //Webpage Heading
   webPage += "
ASC - Alexa Sprinkler Controller
";
@@ -169,8 +169,11 @@
   if (mdns.begin("esp8266", WiFi.localIP()))
     Serial.println("MDNS responder started");

-    server.on("/", [](){
-    server.send(200, "text
+  server.on("/", [](){
+    server.send(200, "text/html", webPage);
+  });
+
+
   //RELAY 1 ------------------------------------
     server.on("/relay1On", [](){
     server.send(200, "text/html", webPage);


added better description for the initR command

Text is taken from the ada fruit examples.


Working version of multi-pin ttl pulse

Working version of multi-pin ttl pulse

--- flea3_multi_pin_trigger/flea3_multi_pin_trigger.ino
+++ flea3_multi_pin_trigger/flea3_multi_pin_trigger.ino
@@ -1,12 +1,17 @@
+// TTL pulse to Arduino Mega 2560 pins 0,2,3
+// Unlike the Uno, the Mega ports map differently.
+// Arduino pins 0,2,3 map to PORTE 0,4,5
+
+//set Port E pins 0-7 as OUTPUT
 void setup()
 {
-  DDRB = B11111111;
+  DDRE = B11111111;
 }

 void loop()
 {
-  PORTB = B11100000;
+  PORTE = B00110001; //Set pins 0,4,5 as HIGH
   delayMicroseconds(3333);
-  PORTB = B00000000;
+  PORTE = B00000000; //Set pins 0,4,5 as LOW
   delayMicroseconds(3333);
 }


added open/close top functions

added open/close top functions

--- RobotControl/RobotControl.ino
+++ RobotControl/RobotControl.ino
@@ -1,115 +1,42 @@
 #include <MeetAndroid.h>
 #include <Servo.h>
+
+MeetAndroid meetAndroid;
 Servo myservo;

-#define LEFTSIDE_NEG   2
-#define LEFTSIDE_POS   3
-#define RIGHTSIDE_NEG  6
-#define RIGHTSIDE_POS  7
 #define TRIGGER_PIN    8
 #define ECHO_PIN       12

-MeetAndroid meetAndroid;
+void setup(){
+  myservo.attach(11);
+  int pos = myservo.read();
+
+  //set servo at to 180 degrees to begin with
+  while (pos != 180) {
+    myservo.write(pos);
+    delay(15);
+    pos++;
+}
+
+Serial.begin(9600);

-void setup(){
- /* myservo.attach(11);
-  int pos = myservo.read();
-  //set servo at to 180 degrees to begin with
-//  while (pos != 180) {
-//    myservo.write(pos);
-//    delay(15);
-//    pos++;
-}*/
-
-
-
- Serial.begin(9600);
-
- meetAndroid.registerFunction(forward, 'w');
- meetAndroid.registerFunction(backward, 's');
- meetAndroid.registerFunction(leftTurn, 'a');
- meetAndroid.registerFunction(rightTurn, 'd');
- meetAndroid.registerFunction(stopIt, 'x');
+meetAndroid.registerFunction(openTop, 'w');
+meetAndroid.registerFunction(closeTop, 'x');
+}

-
-  pinMode(LEFTSIDE_NEG, OUTPUT);
-  pinMode(LEFTSIDE_POS, OUTPUT);
-  pinMode(RIGHTSIDE_NEG, OUTPUT);
-  pinMode(RIGHTSIDE_POS, OUTPUT);
+void loop(){
+  meetAndroid.receive();

 }

-
-void loop(){
-  //meetAndroid.receive();
-
-  //while (getSonar() > 30) {
-    forward2();
-  //}
-
-  //while (getSonar() < 30) {
-    //rightTurn2();
-    //delay(50);
-  //}
-
-
-  delay(100);
-
+void openTop(byte flag, byte numOfValues) {
+  //130
+  myservo.write(meetAndroid.getInt());
 }

-void forward(byte flag, byte numOfValues)
-{
-  analogWrite(LEFTSIDE_POS, meetAndroid.getInt());
-  analogWrite(RIGHTSIDE_POS,meetAndroid.getInt());
-  analogWrite(LEFTSIDE_NEG,0);
-  analogWrite(LEFTSIDE_NEG,0);
-}
-
-void forward2()
-{
-  analogWrite(LEFTSIDE_POS, 255);
-  analogWrite(RIGHTSIDE_POS, 255);
-  analogWrite(LEFTSIDE_NEG,255);
-  analogWrite(LEFTSIDE_NEG,255);
-}
-
-void backward(byte flag, byte numOfValues)
-{
-  analogWrite(LEFTSIDE_POS,0);
-  analogWrite(RIGHTSIDE_POS,0);
-  analogWrite(LEFTSIDE_NEG,meetAndroid.getInt());
-  analogWrite(LEFTSIDE_NEG,meetAndroid.getInt());
-}
-
-
-void stopIt(byte flag, byte numOfValues)
-{
-  analogWrite(LEFTSIDE_POS,meetAndroid.getInt());
-  analogWrite(RIGHTSIDE_POS,meetAndroid.getInt());
-  analogWrite(LEFTSIDE_NEG,meetAndroid.getInt());
-  analogWrite(RIGHTSIDE_NEG,meetAndroid.getInt());
-}
-
-void leftTurn(byte flag, byte numOfValues){
-  analogWrite(LEFTSIDE_POS,0);
-  analogWrite(LEFTSIDE_NEG,meetAndroid.getInt());
-  analogWrite(RIGHTSIDE_POS,meetAndroid.getInt());
-  analogWrite(RIGHTSIDE_NEG,0);
-  Serial.print(meetAndroid.getInt());
-}
-
-void rightTurn(byte flag, byte numOfValues){
-   analogWrite(LEFTSIDE_POS,meetAndroid.getInt());
-   analogWrite(LEFTSIDE_NEG,0);
-   analogWrite(RIGHTSIDE_POS,0);
-   analogWrite(RIGHTSIDE_NEG,meetAndroid.getInt());
-}
-
-void rightTurn2(){
-   analogWrite(LEFTSIDE_POS, 255);
-   analogWrite(LEFTSIDE_NEG,0);
-   analogWrite(RIGHTSIDE_POS,0);
-   analogWrite(RIGHTSIDE_NEG, 255);
+void closeTop(byte flag, byte numOfValues) {
+  //180
+  myservo.write(meetAndroid.getInt());
 }

 int getSonar(){
@@ -122,5 +49,3 @@
 }

-
-


delete comment

delete comment

--- 5.Canny/5.canny_arduino_raspi_uart_security/arduino-raspi_uart_security_system_for_pen/arduino-raspi_uart_security_system_for_pen.ino
+++ 5.Canny/5.canny_arduino_raspi_uart_security/arduino-raspi_uart_security_system_for_pen/arduino-raspi_uart_security_system_for_pen.ino
@@ -3,7 +3,6 @@
 void setup() {
     Serial.begin(9600);
     pinMode(photoPin, INPUT);
- //  pinMode(8, OUTPUT);
     pinMode(5, INPUT);
     pinMode(13, OUTPUT);


Found a bug in the function that send the JSON string to the client. Fixed, but we haven't confirmed if the UI gets the string with the right format.

--- ServerSketch/ServerSketch.ino
+++ ServerSketch/ServerSketch.ino
@@ -500,13 +500,15 @@

     updateBoardState();
     aJsonObject *msg = getJsonBoardState();
+//    Serial.println("HERE0");
     //p = (char *)(aJson.print(msg));
     char * pTempPointer = aJson.print(msg);
+ //   Serial.println("HERE1");
     p = (unsigned char *)pTempPointer;
     //    Serial.println("");
-
+ //   Serial.println("HERE2");
     aJson.print(msg, &serial_stream);
-    Serial.println("");
+ //   Serial.println("HERE3");
     aJson.deleteItem(msg);

     /*
@@ -534,8 +536,8 @@
     //Serial.println(n);

     n = libwebsocket_write(wsi, p, n, LWS_WRITE_TEXT);
-
-    aJson.deleteItem(msg);
+//    Serial.println("HERE4");
+ //   aJson.deleteItem(msg);
   }

   g_luiCounter++;
@@ -823,28 +825,30 @@
     // Populate the pin's type
     if( g_aPins[i].is_analog )
     {
-      aJson.addItemToObject(apoPin[i],"is_analog", aJson.createTrue() );
+      aJson.addItemToObject(apoPin[i],"is_analog", aJson.createItem("true") );
     }
     else
     {
-      aJson.addItemToObject(apoPin[i],"is_analog", aJson.createFalse() );
+      aJson.addItemToObject(apoPin[i],"is_analog", aJson.createItem("false") );
     }

     // Populate the pin's direction
     if( g_aPins[i].is_input )
     {
-      aJson.addItemToObject(apoPin[i],"is_input", aJson.createTrue() );
+      aJson.addItemToObject(apoPin[i],"is_input", aJson.createItem("true") );
     }
     else
     {
-      aJson.addItemToObject(apoPin[i],"is_input", aJson.createFalse() );
+      aJson.addItemToObject(apoPin[i],"is_input", aJson.createItem("false") );
     }

     // Populate pin's value
-    aJson.addItemToObject(apoPin[i],"value", aJson.createItem( g_aPins[i].value ) );
+    char buff[20];
+    snprintf(buff, sizeof(buff),"%f", g_aPins[i].value);
+    aJson.addItemToObject(apoPin[i],"value", aJson.createItem( buff ) );

     // TO DO - Add pin connections array
-    aJson.addItemToObject(apoPin[i],"connections", aJson.createIntArray(iaPinConnects,0) );
+   // aJson.addItemToObject(apoPin[i],"connections", aJson.createIntArray(iaPinConnects,0) );
     /*
      int analogValues[6];
      for (int i = 0; i < 6; i++) {
@@ -971,8 +975,8 @@
 void processMessage(char *_acMsg)
 {

-  Serial.print("Incoming message: ");
-  Serial.println(_acMsg);
+//  Serial.print("Incoming message: "); // debug
+//  Serial.println(_acMsg);

   aJsonObject *poMsg = aJson.parse(_acMsg);

@@ -1042,7 +1046,6 @@
        */

       char sPinState[128];
-      Serial.println("Pin Data: ");
       //       aJsonObject *poPinVals = aJson.getObjectItem(_pJsonPins, pinstr);

       aJsonObject *poLabel = aJson.getObjectItem(poPinVals, "label");
@@ -1090,26 +1093,11 @@
         g_aPins[i].value = atof(poValue->valuestring);
       }

-      /*
-       //        g_aPins[i].is_analog = poLabel->valuebool;
-       // g_aPins[i].label[PIN_LABEL_SIZE] =
-
-       aJsonObject *poIsAnalog = aJson.getObjectItem(poPinVals, "is_analog");
-       if (poPinVals)
-       g_aPins[i].is_analog = poIsAnalog->valuebool;
-       */
-
-      // g_aPins[i].is_input =
-
-
-      // g_aPins[i].value =
-
       // Print pin value after assigment
+//            Serial.println("Pin Data: ");
       //      char sPinState[128];
-      snprintf(sPinState, sizeof(sPinState), "%s,%i,%i,%f", g_aPins[i].label, g_aPins[i].is_analog, g_aPins[i].is_input, g_aPins[i].value);
-      //snprintf(sPinState, sizeof(sPinState), "%s,%i,%i,%f", g_aPins[i].label, poIsAnalog->valuebool, g_aPins[i].is_input, g_aPins[i].value);
-      //Serial.println("Pin Data: ");
-      Serial.println(sPinState);
+  //    snprintf(sPinState, sizeof(sPinState), "%s,%i,%i,%f", g_aPins[i].label, g_aPins[i].is_analog, g_aPins[i].is_input, g_aPins[i].value);
+  //    Serial.println(sPinState);

     }