moved SimpleServer to a new repo

moved SimpleServer to a new repo

--- drone/SimpleServer/SimpleServer.ino
+++ drone/SimpleServer/SimpleServer.ino
@@ -1,90 +0,0 @@
-/*
- * A simple sketch that uses WiServer to serve a web page
- */
-
-#include <WiShield.h>
-#include <WiServer.h>
-
-#define WIRELESS_MODE_INFRA	1
-#define WIRELESS_MODE_ADHOC	2
-// #define DEBUG 1
-
-// Wireless configuration parameters ----------------------------------------
-unsigned char local_ip[] = {192,168,16,110};	// IP address of WiShield
-unsigned char gateway_ip[] = {192,168,16,254};	// router or gateway IP address
-unsigned char subnet_mask[] = {255,255,255,0};	// subnet mask for the local network
-const prog_char ssid[] PROGMEM = {"MP01"};		// max 32 bytes
-
-unsigned char security_type = 0;	// 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
-
-// WPA/WPA2 passphrase
-const prog_char security_passphrase[] PROGMEM = {"abc"};	// max 64 characters
-
-// WEP 128-bit keys
-// sample HEX keys
-prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,	// Key 0
-				  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	// Key 1
-				  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	// Key 2
-				  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00	// Key 3
-				};
-
-// setup the wireless mode
-// infrastructure - connect to AP
-// adhoc - connect to another WiFi device
-unsigned char wireless_mode = WIRELESS_MODE_INFRA;
-
-unsigned char ssid_len;
-unsigned char security_passphrase_len;
-// End of wireless configuration parameters ----------------------------------------
-
-
-// This is our page serving function that generates web pages
-boolean sendMyPage(char* URL)
-{
-
-    // Check if the requested URL matches "/"
-    if (strcmp(URL, "/") == 0) {
-        // Use WiServer's print and println functions to write out the page content
-        WiServer.print("<html>");
-        WiServer.print("Hello World!");
-        WiServer.print("</html>");
-
-        // URL was recognized
-        return true;
-    }
-    // URL not found
-    return false;
-}
-
-
-void setup()
-{
-  WiServer.enableVerboseMode(true);
-
-  // Enable Serial output and ask WiServer to generate log messages (optional)
-  Serial.begin(57600);
-
-  // Initialize WiServer and have it use the sendMyPage function to serve pages
-  WiServer.init(sendMyPage);
-}
-
-U8 state = 0;
-
-void loop(){
-  // Run WiServer
-
-  U8 newState = WiServer.getConnectionState();
-
-  if(newState != state) {
-    state = newState;
-  }
-
-  if(!state) {
-    WiServer.init(sendMyPage);
-  }
-
-  WiServer.server_task();
-
-  delay(10);
-}
-


updated LCD display

updated LCD display

--- mwsLCD/mwsLCD.ino
+++ mwsLCD/mwsLCD.ino
@@ -566,15 +566,14 @@
   lcd.clear();
   lcd.print("Rain Daily (mm)");
   lcd.setCursor(0, 2);
-  lcd.print(raindailymm);
+  lcd.print(dailyrainin);
   delay(2000);

   lcd.clear();
   lcd.print("Rain Hourly (mm)");
   lcd.setCursor(0, 2);
-  lcd.print(rainhourmm);
-  delay(2000);
-
+  lcd.print(rainin);
+  delay(2000);

   //Serial.print(",rain5mmm=");
   Serial.print(",");
@@ -582,15 +581,42 @@
   //Serial.print(",rainindicate=");
   Serial.print(",");
   Serial.print(Rainindi, 1);
+
+  lcd.clear();
+  lcd.print("Rain 5min (mm)");
+  lcd.setCursor(0, 2);
+  lcd.print(rainin_5m);
+  delay(2000);
+
   //Serial.print(",pressure=");
   Serial.print(",");
   Serial.print(pressure, 2);
+
+  lcd.clear();
+  lcd.print("Pressure (hPa)");
+  lcd.setCursor(0, 2);
+  lcd.print(pressure);
+  delay(2000);
+
   //Serial.print(",batt_lvl=");
   Serial.print(",");
   Serial.print(batt_lvl, 2);
+
+  lcd.clear();
+  lcd.print("Battery Level");
+  lcd.setCursor(0, 2);
+  lcd.print(batt_lvl);
+  delay(2000);
+
   //Serial.print(",light_lvl=");
   Serial.print(",");
   Serial.print(light_lvl, 2);

-}
-
+  lcd.clear();
+  lcd.print("Sunlight");
+  lcd.setCursor(0, 2);
+  lcd.print(light_lvl);
+  delay(2000);
+
+}
+


--- esp8266_160528_MPL115A2.ino
+++ esp8266_160528_MPL115A2.ino
@@ -3,6 +3,8 @@
 #include "esp8266_160602_udpTxToLogger.h"

 /*
+ * v0.8 2016 Jun. 26
+ *   - tweak delay in loop() to have approximately 1 second in total
  * v0.7 2016 Jun. 26
  *   - esp8266_160602_udpTxToLogger > increase connection retry from 3 to 6
  *   - esp8266_160602_udpTxToLogger > modify WiFi_setup() to avoid watchdog reset problem
@@ -139,7 +141,13 @@
   alt = calcAltitude(prs, kAltitudeCorrection);
   Serial.print(", Altitude=");
   Serial.print(alt);
+#if 0 // for debug of loop() timing (1 second loop)
+  int msec = millis() % 1000;
+  Serial.print(",");
+  Serial.print(msec);
+#endif
   Serial.println();
+
 }

 void UdpTxAltitude(float prs)
@@ -189,6 +197,7 @@
   }

   s_count++;
-  delay(1000); // msec
-}
-
+
+  delay(591); // msec // for approximately 1 second loop
+}
+


Strings to PROGMEM

Strings to PROGMEM

--- examples/RF12/RF12tune/RF12tune.ino
+++ examples/RF12/RF12tune/RF12tune.ino
@@ -12,7 +12,7 @@
 #define RETRY_LIMIT 9  // maximum number of times to retry
 #define RADIO_SYNC_MODE 2

-char importedConfig[] =
+const char importedConfig[] PROGMEM =
 ///
 /// Highlight the string below and paste in the value obtained from the RF12Demo "0j" command.
    "89D1066D49206939206732303920403836382E32323530204D487A0000006893";  //   0 I i9 g209 @868.2250 MHz
@@ -74,19 +74,19 @@
 void setup() {
   delay(5000);  // Startup delay to debounce disconnection
   Serial.begin(SERIAL_BAUD);
-  Serial.println("\n[RF12tune.0]");
+  showString(PSTR("\n[RF12tune.0] \n\r"));

   for (byte i = 0; i < (RF12_EEPROM_SIZE * 2); i+=2 ) {
-    w = ChkHex(importedConfig[i]);
+    w = ChkHex(getString (importedConfig, i));
     if (w) h = (w << 4);         // Move into high nibble
-    w = ChkHex(importedConfig[(i+1)]);
+    w = ChkHex(getString (importedConfig, i+1));
     if (w) h = h + (w & 0x0F);   // Add in low nibble
     showNibble(h >> 4);
     showNibble(h);
-    eeprom_write_byte((RF12_EEPROM_ADDR) + (i / 2), h);
+//    eeprom_write_byte((RF12_EEPROM_ADDR) + (i / 2), h);
     ((byte*) &config)[(i/2)] = h;
   }
- Serial.println();
+  showString(PSTR("\n\r"));

     frequency = (config.ee_frequency_hi << 8) + config.ee_frequency_lo;              // Loose flag nibble to get frequency high order
 }
@@ -96,7 +96,8 @@
     frequency = eeprom_read_byte(RF12_EEPROM_ADDR + 2);
     frequency = ((frequency & 0x0F)  << 8) + (eeprom_read_byte(RF12_EEPROM_ADDR + 3));              // Loose flag nibble to get frequency high order
     if (rf12_config()) {
-      Serial.print("Config Initialized ");
+//      Serial.print("Config Initialized ");
+      showString(PSTR("Config Initialized "));
       Serial.println(frequency);
       delay(50);
     }
@@ -109,25 +110,27 @@
    if (good){
      if (scan > upHigh) upHigh = scan;
      if (scan < upLow) upLow = scan;
-//     Serial.print("\n");
-//     Serial.print(good);
      delay(50);
    }
       else {
-        Serial.print("No Ack ");
+//        Serial.print("No Ack ");
+        showString(PSTR("No Ack "));
         Serial.print(scan);
-        Serial.print("\r");
+        showString(PSTR("\r"));
+//        Serial.print("\r");
         delay(50);
       }
   }
   if ((upHigh == 0) || (upLow == 0xFFFF)) return;  // If nobody answers then restart loop
-Serial.print("Scan up complete ");
-Serial.print(upLow);
-Serial.print("-");
-Serial.println(upHigh);
-delay(100);
-  downLow = 0xFFFF;
-  downHigh = 0;
+//    Serial.print("Scan up complete ");
+    showString(PSTR("Scan up complete "));
+    Serial.print(upLow);
+//    Serial.print("-");
+    showString(PSTR("-"));
+    Serial.println(upHigh);
+    delay(100);
+    downLow = 0xFFFF;
+    downHigh = 0;
   for (scan = (frequency + 50); scan > (frequency - 50); --scan)
   {
    rf12_control(0xA000 + scan);
@@ -135,28 +138,31 @@
    if (good){
      if (scan > downHigh) downHigh = scan;
      if (scan < downLow) downLow = scan;
-//     Serial.print("\n");
-//     Serial.print(good);
      delay(50);
    }
       else {
-        Serial.print("No Ack ");
+//        Serial.print("No Ack ");
+        showString(PSTR("No Ack "));
         Serial.print(scan);
-        Serial.print("\r");
+        showString(PSTR("\r"));
+//        Serial.print("\r");
         delay(50);
       }
   }
   if ((downHigh == 0) || (downLow == 0xFFFF)) return;  // If nobody answers then restart loop
-Serial.print("Scan down complete ");
-Serial.print(downLow);
-Serial.print("-");
-Serial.println(downHigh);
+  showString(PSTR("Scan down complete "));
+//  Serial.print("Scan down complete ");
+  Serial.print(downLow);
+//  Serial.print("-");
+    showString(PSTR("-"));
+  Serial.println(downHigh);

  frequency = ( ((upLow + downLow) / 2) + ((((upHigh + downHigh) / 2) - ((upLow + downLow)/ 2)) / 2)   );
- Serial.print("Centre frequency offset is ");
- Serial.println(frequency);
- delay(50);
+// Serial.print("Centre frequency offset is ");
+  showString(PSTR("Centre frequency offset is "));
+  Serial.println(frequency);
+  delay(50);
  config.ee_frequency_hi = frequency >> 8;
  config.ee_frequency_lo = frequency & 0x00FF;

@@ -170,7 +176,8 @@
     eeprom_write_byte(RF12_EEPROM_ADDR + i, b);
   }
   if (!rf12_config()) {
-    Serial.println("config save failed");
+    showString(PSTR("config save failed"));
+//    Serial.println("config save failed");
   }
   else {
     delay(50);
@@ -179,6 +186,20 @@
   while(1) // Nothing more
   {
      delay(32767);
+  }
+}
+static byte getString (PGM_P s, byte i) {
+    char c = pgm_read_byte(s + i);
+    return c;
+}
+static void showString (PGM_P s) {
+  for (;;) {
+    char c = pgm_read_byte(s++);
+    if (c == 0)
+      break;
+    if (c == '\n')
+      Serial.print('\r');
+    Serial.print(c);
   }
 }

@@ -211,9 +232,11 @@
 static char ChkHex(char c) {
   if ((c > 64) && (c < 71)) return (c + 9);    // "A" to "F"
   if ((c > 47) && (c < 58)) return c;          // "0" to "9"
-  Serial.print("\nError in importedConfig string '");
+    showString(PSTR("\nError in importedConfig string '"));
+//  Serial.print("\nError in importedConfig string '");
   Serial.print(c);
-  Serial.println("'");
+  showString(PSTR("'\n\r"));
+//  Serial.println("'");
   return 0;
 }
 /// showNibble code below pinched from RF12Demo 2013-09-22


backup

backup

--- tetrisdoor.ino
+++ tetrisdoor.ino
@@ -1 +1,333 @@
-init
+#include "application.h"
+#include "neopixel/neopixel.h"
+#include "MQTT/MQTT.h"
+
+#include "application.h"
+
+#define PIXEL_PIN      D0
+#define PIXEL_TYPE     WS2811
+
+#define matrixx        10
+#define matrixy         5
+#define fallspeedorg  800
+
+int pos[2]                   = { 5, 1};
+int bricks[7][4][2]          = { {{0, 1}, {-1, 0}, {0, 0}, {1, 0}}, {{-1, 1}, {-1, 0}, {0, 0}, {1, 0}}, {{1, 1}, {-1, 0}, {0, 0}, {1, 0}}, {{-1, 0}, {0, 0}, {0, 1}, {1, 1}}, {{-1, 1}, {0, 1}, {0, 0}, {1, 0}}, {{1, 0}, {1, 1}, {0, 1}, {0, 0}}, {{-1, 0}, {0, 0}, {1, 0}, {2, 0}}};
+int colors[7][3]             = { {255, 0, 0}, {100, 255, 0}, {0, 0, 255}, {255, 255, 0}, {0, 255, 255}, {255, 100, 0}, {255, 255, 255}};
+int matrix[matrixx][matrixy] = { 0};
+int leds[matrixx * matrixy]  = { 0};
+int current[4][2]            = { {1, 1}, {-1, 0}, {0, 0}, {1, 0} };
+int currentcach[4][2]        = { 0};
+int currentnum               = 1;
+int truepos[2]               = { 0,0};
+int fallspeed                = fallspeedorg;
+int fallcount                = 0;
+int moveable                 = 0;
+int fullrow                  = 0;
+int rowtodelete              = 0;
+int gameover                 = 0;
+int mode                     = 0;
+int currentColor[3]          = {0};
+
+Adafruit_NeoPixel strip = Adafruit_NeoPixel((matrixx * matrixy), PIXEL_PIN, PIXEL_TYPE);
+
+void callback(char* topic, byte* payload, unsigned int length);
+
+MQTT client("ansinas", 1883, callback);
+
+void callback(char* topic, byte* payload, unsigned int length) {
+    char p[length + 1];
+    memcpy(p, payload, length);
+    p[length] = NULL;
+    String message(p);
+
+    if (message.equals("LEFT")){
+        left();
+    }
+
+    if (message.equals("RIGHT")){
+        right();
+    }
+
+    if (message.equals("DOWN")){
+        down();
+    }
+
+    if (message.equals("ROTATE")){
+        rotate();
+    }
+
+}
+
+void setup() {
+
+    strip.begin();
+
+    for(int i = 0; i < strip.numPixels(); i++){
+        strip.setPixelColor(i, strip.Color(1, 0, 0));
+    }
+
+    strip.show();
+
+    client.connect("tetrisdoor");
+
+    if (client.isConnected()) {
+        client.publish("tetrisdoor","start");
+        client.subscribe("tetrisdoor");
+    }
+
+}
+
+void checkend(){
+
+  gameover = 0;
+
+  for(int x = 0; x < matrixx; x++){
+
+    if(matrix[x][1] != 0){
+      gameover = 1;
+    }
+
+  }
+
+  if(gameover == 1){
+
+    pos[0] = 5;
+    pos[1] = 1;
+
+    for(int x = 0; x < matrixx; x++){
+
+      for(int y = 0; y < matrixy; y++){
+        matrix[x][y] = 0;
+      }
+
+    }
+
+    add(random(7));
+
+    // ????????????????????????????????
+    for(int x = 0; x < matrixx; x++){
+
+      for(int y = 0; y< matrixy; y++){
+        matrix[x][y] = 0;
+      }
+
+    }
+    // ?????????????????????????????????
+
+  }
+
+}
+
+void checkrows(){
+
+  for(int y = 0; y < matrixy; y++){
+    fullrow = 1;
+
+    for(int x = 0; x < matrixx; x++){
+
+      if(matrix[x][y] == 0){
+        fullrow = 0;
+      }
+
+    }
+
+    if(fullrow == 1){
+
+      for(int row = y; row > 0; row--){
+
+        for(int x = 0; x < matrixx; x++){
+          matrix[x][row] = matrix[x][row-1];
+        }
+
+      }
+
+    }
+
+  }
+
+}
+
+void down(){
+  moveable = 1;
+  for(int e = 0; e < 4; e++){
+
+    if(matrix[current[e][0]+pos[0]][current[e][1]+pos[1]+1] != 0){
+      moveable = 0;
+    }
+
+    if(current[e][1]+pos[1]+1 == 35){
+      moveable = 0;
+    }
+
+  }
+
+  if(moveable == 1){
+    pos[1]++;
+  }else{
+    add(random(7));
+  }
+}
+
+void right(){
+  moveable = 1;
+
+  for(int e = 0; e < 4; e++){
+
+    if(matrix[current[e][0]+pos[0]+1][current[e][1]+pos[1]] != 0){
+      moveable = 0;
+    }
+
+    if(current[e][0]+pos[0]+1 == matrixx){
+      moveable = 0;
+    }
+
+  }
+
+  if(moveable == 1){
+    pos[0]++;
+  }
+}
+
+void left(){
+  moveable = 1;
+
+  for(int e = 0; e < 4; e++){
+
+    if(matrix[current[e][0]+pos[0]-1][current[e][1]+pos[1]] != 0){
+      moveable = 0;
+    }
+
+    if(current[e][0]+pos[0]-1 == -1){
+      moveable = 0;
+    }
+
+  }
+
+  if(moveable == 1){
+    pos[0]--;
+  }
+
+}
+
+void rotate(){
+
+  for(int e = 0; e < 4; e++){
+    currentcach[e][0] = current[e][0];
+    currentcach[e][1] = current[e][1];
+  }
+
+  for(int e = 0; e < 4; e++){
+    current[e][1] =  currentcach[e][0];
+    current[e][0] = -currentcach[e][1];
+  }
+
+  moveable = 1;
+
+  for(int e = 0; e < 4; e++){
+
+    if(matrix[current[e][0]+pos[0]][current[e][1]+pos[1]] != 0){
+      moveable = 0;
+    }
+
+    if(current[e][0]+pos[0] < 0){
+      moveable = 0;
+    }
+
+    if(current[e][0]+pos[0] > 9){
+      moveable = 0;
+    }
+
+  }
+
+  if(moveable == 0){
+
+    for(int e = 0; e < 4; e++){
+      current[e][0] = currentcach[e][0];
+      current[e][1] = currentcach[e][1];
+    }
+
+  }
+
+}
+
+void add(int b){
+
+  for(int e = 0; e < 4; e++){
+    matrix[current[e][0]+pos[0]][current[e][1]+pos[1]] = currentnum + 1;
+    current[e][0] = bricks[b][e][0];
+    current[e][1] = bricks[b][e][1];
+  }
+
+  currentnum = b;
+  pos[0] = 5;
+  pos[1] = 1;
+
+}
+
+void show(){
+
+  for(int i = 0; i < strip.numPixels(); i++){
+    strip.setPixelColor(i, strip.Color(0, 0, 0));
+  }
+
+  for(int x = 0; x < matrixx; x++){
+
+    for(int y = 0; y < matrixy; y ++){
+
+      if(matrix[x][y] != 0){
+
+        if(x%2 == 1){
+          strip.setPixelColor((x*matrixy)+y,             strip.Color( colors[matrix[x][y]-1][0], colors[matrix[x][y]-1][1], colors[matrix[x][y]-1][2]) );
+        }else{
+          strip.setPixelColor((x*matrixy)+(matrixy-y-1), strip.Color( colors[matrix[x][y]-1][0], colors[matrix[x][y]-1][1], colors[matrix[x][y]-1][2]) );
+        }
+
+      }
+
+    }
+
+  }
+
+  for(int e = 0; e < 4; e++){
+    truepos[0] = current[e][0]+pos[0];
+    truepos[1] = current[e][1]+pos[1];
+
+    if(truepos[0]%2 == 1){
+      strip.setPixelColor((truepos[0]*matrixy)+truepos[1],             strip.Color(colors[currentnum][0], colors[currentnum][1], colors[currentnum][2]) );
+    }else{
+      strip.setPixelColor((truepos[0]*matrixy)+(matrixy-truepos[1]-1), strip.Color(colors[currentnum][0], colors[currentnum][1], colors[currentnum][2]) );
+    }
+
+  }
+
+  strip.show();
+}
+
+void loop() {
+
+    if (client.isConnected()){
+        client.loop();
+    }
+
+    if(mode == 0){
+
+          for(int i = 0; i < strip.numPixels(); i++){
+            strip.setPixelColor(i, strip.Color(currentColor[0], currentColor[1], currentColor[2]));
+          }
+
+    }
+
+    if(mode == 1){
+        if(fallcount == fallspeed){
+            fallcount = 0;
+            down();
+        }
+
+        fallcount++;
+        checkrows();
+        checkend();
+        show();
+        delay(100);
+    }
+}


ssl fingerprint changed

ssl fingerprint changed

--- nodemcu_dht11.ino
+++ nodemcu_dht11.ino
@@ -75,7 +75,7 @@
     http.begin(corlysisUrl);
     //HTTPS variant - check ssh public key fingerprint
     //sprintf(corlysisUrl, "https://corlysis.com:8086/write?db=%s&u=token&p=%s", dbName, dbPassword);
-    //http.begin(corlysisUrl, "92:23:13:0D:59:68:58:83:E6:82:98:EB:18:D7:68:B5:C8:90:0D:03");
+    //http.begin(corlysisUrl, "FF:2D:E9:25:75:39:D1:A0:5C:99:02:34:EF:81:73:0F:3F:3E:2D:0D");

     http.addHeader("Content-Type", "application/x-www-form-urlencoded");
     int httpCode = http.POST(payloadStr);


magnet work

magnet work

--- Mumi/DoorUnlock/Magnet/Magnet.ino
+++ Mumi/DoorUnlock/Magnet/Magnet.ino
@@ -0,0 +1,29 @@
+static uint8_t totalUp=0; //-- Total time the selenoid has actived in seconds
+void setup()
+{
+	//-- Both output
+	DDRC = DDRC | (1<<7);
+	DDRB = DDRB | (1<<7);
+	//-- input Pullup
+	PORTD = PORTD | (1<<6);
+}
+void loop()
+{
+	if (totalUp>120)
+		while(1); //-- Lock it to avoid selenoid burn. Restart the system by repowering it
+
+	if ( (PIND&(1<<6)) == 0)//-- PIN12 uno is LOW
+	{
+		PORTC = PORTC & ~(1<<7); //-- Fire up relay to activate selenoid
+		PORTB = PORTB & ~(1<<7);
+		delay(20000);
+		totalUp += 20;
+		PORTC = PORTC | (1<<7); //-- revert & close relay connections
+		PORTB = PORTB | (1<<7);
+	}
+	else
+	{
+		PORTC = PORTC | (1<<7); //-- close relay connections
+		PORTB = PORTB | (1<<7);
+	}
+}


Working opcodes

Working opcodes

--- SDPArduinoCode/SDPArduinoCode.ino
+++ SDPArduinoCode/SDPArduinoCode.ino
@@ -1,6 +1,7 @@
 #include "SDPArduino.h"
 #include <Wire.h>
 #include <stdlib.h>
+#define STOP 0

 void setup(){

@@ -17,100 +18,119 @@
    helloWorld();
 }

+
+int getNumFromChar(char c){
+  int r = (int)c - (int)'0';
+  return r;
+}
+
 int getSig(String c){
-  int res;
-  char letter[2];
-  letter[0] = c[0];
-  letter[1] = '\0';
-  res = atoi(letter);
-  return res;
+  int r = getNumFromChar(c[0]);
+  return r;
 }

 int getOpcode(String c){
-  int res;
-  char letter[2];
-  letter[0] = c[1];
-  letter[1] = '\0';
-  res = atoi(letter);
-  return res;
+  int r = getNumFromChar(c[1]);
+  return r;
 }

-int getArg1(String c){
-  int res;
-  char letter[2];
-  letter[0] = c[2];
-  letter[1] = '\0';
-  res = atoi(letter);
-  return res;
+int getArg(String c){
+  int r1 = getNumFromChar(c[2]);
+  int r2 = getNumFromChar(c[3]);
+  int r3 = getNumFromChar(c[4]);
+  return ((r1*100)+(r2*10)+r3);
+}int r = (int)c - (int)'0';
+
+int check_checksum(String c, int opcode, int arg){
+  int checksum = getNumFromChar(c[5]);
+  int checksum_recalculated = (opcode + arg) % 10;
+
+  if(checksum == checksum_recalculated){
+    return 1;
+  }
+  else {
+    return 0;
+  }
+
 }

-int getArg2(String c){
-  int res;
+
+
+void moveRobotForward(int power){
+
+  //motorStop(0); // this might be useful, in the case the robot is already in a turning move

-  char letter[2];
-  letter[0] = c[3];
-  letter[1] = '\0';
-  int a = atoi(letter)*100;
-  res = a;
+  motorForward(1,power);
+  motorForward(2,power);
+
+  // need to create a reply message to let the PC acknowledge the accepted request and execution
+  Serial.println("Robot forward");
+
+}
+
+void moveRobotBackward(int power){
+
+  //motorStop(0); // again might be useful if the robot is in a turning move
+
+  // stop the motors first incase they are moving forward (to prevent mechinical failure)
+  motorStop(1);
+  motorStop(2);
+
+  // set motors to move backwards
+  motorBackward(1, power);
+  motorBackward(2,power);
+
+  // send reply message
+  Serial.println("Robot back");
+
+}
+
+void rotateRobotLeft(int power){
+
+  motorAllStop(); // use this for now, can change later on
+
+  // set motors for left rotation
+  motorForward(2,power);
+  motorForward(0,power);
+
+  // send reply message
+  Serial.println("Robot left");
+
+}
+
+void rotateRobotRight(int power){
+
+  motorAllStop(); // use this for now, can change later
+
+  // set motors for right rotation
+  motorForward(1, power);
+  motorBackward(0, power);
+
+  // send reply message
+  Serial.println("Robot right");
+
+}
+
+void stopRobot(){
+
+  motorAllStop();
+
+  // send reply message
+  Serial.println("Robot stopped");
+
+}
+
+void robotGrab(){
+
+  motorForward(5, 100);
+  delay(500);
+  motorAllStop();
+  Serial.println("Robot Grab");

-  letter[0] = c[4];
-  letter[1] = '\0';
-  int b = atoi(letter)*10;
-  res = res + b;
-
-
-  letter[0] = c[5];
-  letter[1] = '\0';
-  int d = atoi(letter);
-  res = res + d;
-
-  return res;
 }

-int check_checksum(String c){
-  int res = 1;
-  int w,x,y,z;
-
-  char letter1[2];
-  char letter2[2];
-  char letter3[2];
-  char letter4[2];
-  char letter5[2];
-
-  letter1[1] = '\0';
-  letter2[1] = '\0';
-  letter3[1] = '\0';
-  letter4[1] = '\0';
-  letter5[1] = '\0';
-
-  letter1[0] = c[2];
-  w = atoi(letter1);
-
-  letter1[0] = c[3];
-  x = atoi(letter1);
-
-  letter2[0] = c[4];
-  y = atoi(letter2);
-
-  letter3[0] = c[5];
-  z = atoi(letter3);
-
-//  char c;
-//  (int)c - (int)'0'
-
-  letter5[0] = c[6];
-  int test2 = atoi(letter5);
-
-
-  int test = (w+x+y+z)%10;
-  if(test2 != test){
-    res = 0;
-  }
-  return res;
-
-}

 void loop(){
@@ -122,42 +142,54 @@
     String c = Serial.readString();

     // inital test to see if message is recieved (delete afterwards)
+    //
     Serial.println(c);

-    // if checksum is correct continue decoding message and execute
-    if(check_checksum){

+      // need to check if signuture is our teams first!
+      // avoids unessacary computation on the arduino if it is not a message for out team.
       int sig = getSig(c);
-      int opcode = getOpcode(c);
-      int arg1 = getArg1(c);
-      int arg2 = getArg2(c);
+      if(sig != 0){ return; }
+
+        int opcode = getOpcode(c);
+        int arg = getArg(c);
+        int check = check_checksum(c, opcode, arg);
+
+        // if checksum is correct continue decoding message and execute
+        if(check == 1){

-      switch (opcode){
+          switch (opcode){
+
+            case STOP:  stopRobot();
+            break;
+
+            case 1:  moveRobotForward(arg);
+            break;

-        case 0:  motorForward(arg1,arg2);
-        break;
+            case 2:  moveRobotBackward(arg);
+            break;

-        case 1:  motorBackward(arg1,arg2);
-        break;
+            case 3:  rotateRobotLeft(arg);
+            break;
+
+            case 4:  rotateRobotRight(arg);
+            break;
+
+            case 5: robotGrab();
+            break;

-        case 2:  motorStop(arg1);
-        break;
+            default: Serial.println("ERR");
+            break;

-        case 3:  motorAllStop();
-        break;
-
-        default: Serial.println("Error in code this should not happen");
-        break;
-
-      }
-
-    }
-
-  }
+          } // switch
+      } // if checksum
+      else{
+        // checksum is not correct, sig is therefore message was corrupted
+        // reply: incorrect message (re-send)
+        Serial.println("CORR");
+      }
+    // } // if sig == 0 (if this fails, message is not for out team)
+  } // if serial.avalaible
+} // loop body

-
-
-
-}
-


Show panorama FOV when stopped instead of while moving.

#defined constants for rpm
add battery status to more screens
expanded some over-shortened text (2x no longer cared about)

--- pano-controller.ino
+++ pano-controller.ino
@@ -61,6 +61,8 @@
 #define MPU_INT 7

 // Stepper motors and drivers
+#define HORIZ_RPM 30
+#define VERT_RPM HORIZ_RPM*3
 #define MOTOR_STEPS 200
 #define VERT_DIR 5
 #define VERT_STEP 6
@@ -112,6 +114,7 @@
  */
 void displayBatteryStatus(void){
     int battmV = readBattery();
+    display.setCursor((17-battmV/10000)*6, 0);
     display.print(battmV/1000);
     display.print('.');
     display.print((battmV % 1000)/100);
@@ -173,6 +176,7 @@
     display.println(F(" photos"));
     displayPanoSize();
     displayProgress();
+    displayBatteryStatus();
     display.display();
 }

@@ -223,9 +227,9 @@
         if (pos_x == 0){
             if (HID::isEventRight(event)) pos_x = pano.horiz_gear_ratio;
             if (HID::isEventLeft(event)) pos_x = -pano.horiz_gear_ratio;
-            horiz_motor.setRPM(10);
+            horiz_motor.setRPM(HORIZ_RPM/3);
         } else {
-            horiz_motor.setRPM(30*abs(pos_x)/joystick.range);
+            horiz_motor.setRPM(HORIZ_RPM*abs(pos_x)/joystick.range);
             pos_x = pos_x/abs(pos_x);
         }

@@ -233,9 +237,9 @@
         if (pos_y == 0){
             if (HID::isEventUp(event)) pos_y = pano.vert_gear_ratio;
             if (HID::isEventDown(event)) pos_y = -pano.vert_gear_ratio;
-            vert_motor.setRPM(30);
+            vert_motor.setRPM(VERT_RPM/3);
         } else {
-            vert_motor.setRPM(90*abs(pos_y)/joystick.range);
+            vert_motor.setRPM(VERT_RPM*abs(pos_y)/joystick.range);
             pos_y = pos_y/abs(pos_y);
         }

@@ -249,28 +253,30 @@
             vert_motor.rotate(pos_y);
         }

-        if (vert && h >= 0 && v >= 0){
+        if (vert && !pos_x && !pos_y){
             pano.setFOV(h / pano.horiz_gear_ratio + camera.getHorizFOV(),
                         v / pano.vert_gear_ratio + camera.getVertFOV());
             pano.computeGrid();
-            if (pano.getVertShots()+pano.getHorizShots() != when_to_display){
-                display.setCursor(0,8*6);
-                display.print("          ");
-                display.setCursor(0,8*6);
-                displayPanoSize();
-                display.display();
-                when_to_display = pano.getVertShots() + pano.getHorizShots();
-            }
+            display.setCursor(0,8*6);
+            display.print(F("          "));
+            display.setCursor(0,8*6);
+            displayPanoSize();
+            display.print(pano.horiz_fov);
+            display.print("x");
+            display.print(pano.vert_fov);
+            display.print(" ");
+            displayBatteryStatus();
+            display.display();
         }
     }
     if (horiz){
         *horiz = h / pano.horiz_gear_ratio + camera.getHorizFOV();
-        horiz_motor.setRPM(40);
+        horiz_motor.setRPM(HORIZ_RPM);
         horiz_motor.rotate(-h);
     }
     if (vert){
         *vert = v / pano.vert_gear_ratio + camera.getVertFOV();
-        vert_motor.setRPM(120);
+        vert_motor.setRPM(VERT_RPM);
         vert_motor.rotate(v);
     }
     return (HID::isEventOk(event));
@@ -293,7 +299,6 @@
     while (!running){
         event = joystick.read() | remote.read();
         if (!event){
-            display.setCursor(17*6, 0);
             displayBatteryStatus();
             display.display();
             if (millis() - last_event > DISPLAY_SLEEP){
@@ -314,7 +319,6 @@
         display.clearDisplay();
         display.setCursor(0,0);
         menu.render(display, DISPLAY_ROWS);
-        display.setCursor(17*6, 0);
         displayBatteryStatus();
         display.display();
         delay(100);
@@ -405,21 +409,21 @@
 }

 /*
- * This is a callback invoked by selecting "Start"
+ * Menu callback invoked by selecting "Start"
  */
 int onStart(int __){
     setPanoParams();

     // set panorama FOV
-    if (!positionCamera("Top Left", NULL, NULL) ||
-        !positionCamera("Bot Right", &horiz, &vert)){
+    if (!positionCamera("Set Top Left", NULL, NULL) ||
+        !positionCamera("Set Bottom Right", &horiz, &vert)){
         return false;
     }

     pano.setFOV(horiz, vert);
     running = true;
     menu.sync();
-    if (!positionCamera("Adj start", NULL, NULL)){
+    if (!positionCamera("Adjust start pos\nSet exposure & focus", NULL, NULL)){
         return false;
     }
     executePano();
@@ -427,8 +431,7 @@
 }

 /*
- * This is a callback invoked by selecting "Repeat"
- * FIXME: does not work when previous was a 360 pano
+ * Menu callback invoked by selecting "Repeat"
  */
 int onRepeat(int __){
     setPanoParams();
@@ -436,7 +439,7 @@
     pano.setFOV(horiz, vert);
     running = true;
     menu.sync();
-    if (!positionCamera("Adj start", NULL, NULL)){
+    if (!positionCamera("Adjust start pos\nSet exposure & focus", NULL, NULL)){
         return false;
     }
     executePano();
@@ -444,22 +447,22 @@
 }

 /*
- * This is a callback invoked by selecting "Repeat"
+ * Menu callback invoked by selecting "Repeat"
  */
 int on360(int __){
     setPanoParams();

     // set panorama FOV
     horiz = 360;
-    if (!positionCamera("Top", NULL, NULL) ||
-        !positionCamera("Bottom", NULL, &vert)){
+    if (!positionCamera("Set Top", NULL, NULL) ||
+        !positionCamera("Set Bottom", NULL, &vert)){
         return false;
     }

     pano.setFOV(horiz, vert);
     running = true;
     menu.sync();
-    if (!positionCamera("Adj start", NULL, NULL)){
+    if (!positionCamera("Adjust start pos\nSet exposure & focus", NULL, NULL)){
         return false;
     }
     executePano();
@@ -467,7 +470,7 @@
 }

 /*
- * Menu callback for display pano info
+ * Menu callback for displaying last pano info
  */
 int onPanoInfo(int __){
     setPanoParams();


use free RAM

use free RAM

--- tests/BlynkFootprintTest/BlynkFootprintTest.ino
+++ tests/BlynkFootprintTest/BlynkFootprintTest.ino
@@ -72,7 +72,7 @@

 BLYNK_READ(V4)
 {
-  Blynk.virtualWrite(V4, test);
+  Blynk.virtualWrite(V4, BlynkFreeRam());
 }

 #endif /* ENABLE_HANDLERS */


Edited and tested using serial monitor

Edited and tested using serial monitor

--- VendingMachineRFID.ino
+++ VendingMachineRFID.ino
@@ -6,14 +6,12 @@
 #define SS_PIN 10
 #define RST_PIN A0

+#define transmission_attempts 10
+
 #include <SPI.h>
 #include <MFRC522.h> // MFRC522 library by Miguel Balboa (circuitito.com, Jan, 2012) & Søren Thing Andersen (access.thing.dk, fall of 2013)
 #include "EEPROMAnything.h"
 #include "VendingMachineRFID.h"
-
-/* Hack to fix sizeof(card_uid_t) sometimes becoming 5 (?) */
-// #define CARD_UID_SIZE 4
-// Caused by Stream.parseInt();

 MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
 uint32_t lastCardScan; // Debounce RFID reads
@@ -32,7 +30,7 @@
 uint8_t recieve_error;
 uint16_t rfid_recieve(){
   char parseBuffer[10];
-  uint8_t recieveAttemptsRemaining = 11;
+  uint8_t recieveAttemptsRemaining = transmission_attempts;
   uint16_t number = 0;
   while(recieveAttemptsRemaining-- > 0){
     if(Serial.readBytes(parseBuffer, sizeof(parseBuffer)) == sizeof(parseBuffer)){
@@ -51,7 +49,6 @@
       Serial.write(recieveAttemptsRemaining+48);
   }
   recieve_error = 1; // timed out
-//number = 0;
   // Let other party know we do not need a retransmission
   Serial.write(0);
   return number;
@@ -63,7 +60,7 @@
   uint8_t first_half   = number >> 8;   // >>>> >>>> 0001 0110
   uint8_t sencond_half = number & mask; // ____ ____ 0100 0111
   char waiting_for_ok = 1;
-  uint8_t transmitAttemptsRemaining = 10;
+  uint8_t transmitAttemptsRemaining = transmission_attempts;
   while(waiting_for_ok && transmitAttemptsRemaining-- > 0){
     // Flush incoming buffer
     while(Serial.available()){Serial.read();}
@@ -71,7 +68,8 @@
       Serial.write(sencond_half);
       Serial.write(first_half);
     }
-    Serial.readBytes(&waiting_for_ok,1);
+    if(Serial.readBytes(&waiting_for_ok,1) == 0) // No bytes recieved
+      waiting_for_ok = 1; // Overwrite waiting_for_ok - necessary?
   }
   return waiting_for_ok;
 }
@@ -192,7 +190,7 @@
         // Card found! (Known card OR found free spot for new card)
         // Attempt to add credits to card
         if(updateAndVerify(addr,card)){
-          Serial.print("C");
+          //Serial.print("C");
           // OK Beep
         } else{
           // Reset credits on vending machine
@@ -249,3 +247,4 @@
   }
   return 65535; // Error value
 }
+


This doesn't work yet because WifiManager is blocking

--- iDONT.ino
+++ iDONT.ino
@@ -19,7 +19,7 @@

 void loop()
 {
-  //main_state_machine(&mainState, &ledState, &wifiManager);
+  main_state_machine(&mainState, &ledState, &wifiManager);
   led_state_machine(&ledState);
   yield();
 }


removed stuff

removed stuff

--- research/DCF-RTC/DCF-RTC.ino
+++ research/DCF-RTC/DCF-RTC.ino
@@ -83,11 +83,6 @@
 void setup() {
   Serial.begin(9600);
   Wire.begin();
-
-  tmElements_t tm;
-  if (RTC.read(tm)) {
-    Serial.println("Time: ");
-  }

   Serial.println("Setting system clock from RTC module");
   setSyncProvider(RTC.get);


Poc Ultrason

Poc Ultrason

--- pug.ino
+++ pug.ino
@@ -5,6 +5,9 @@

 #define leftMotorPin1 9
 #define leftMotorPin2 10
+
+#define ultraTrig 14
+#define ultraEcho 15

 #define starterServoPin 18

@@ -24,6 +27,23 @@
   digitalWrite(rightMotorPin1, LOW);
   digitalWrite(rightMotorPin2, HIGH);
 }
+
+boolean ultraCheck(){
+  /* Utilisation du capteur Ultrason HC-SR04 */
+
+long lecture_echo;
+long cm;
+
+  digitalWrite(ultraTrig, HIGH);
+  delayMicroseconds(10);
+  digitalWrite(ultraTrig, LOW);
+  lecture_echo = pulseIn(ultraEcho, HIGH);
+  cm = lecture_echo / 58;
+  Serial.print("Distancem : ");
+  Serial.print(cm);
+  Serial.println("cm");
+  delay(10);
+  }

 void stopRight() {
   digitalWrite(rightMotorPin1, LOW);
@@ -129,12 +149,17 @@

 void setup() {
   // Motor Right
-  pinMode(9, OUTPUT);
-  pinMode(10, OUTPUT);
+  pinMode(leftMotorPin1, OUTPUT);
+  pinMode(leftMotorPin2, OUTPUT);

   // Motor Left
-  pinMode(11, OUTPUT);
-  pinMode(12, OUTPUT);
+  pinMode(rightMotorPin1, OUTPUT);
+  pinMode(rightMotorPin2, OUTPUT);
+
+  // Ultrason
+  pinMode(ultraTrig, OUTPUT);
+  digitalWrite(ultraTrig, LOW);
+  pinMode(ultraEcho, INPUT);

   // Serial
   Serial.begin(9600);
@@ -144,6 +169,7 @@

 void loop() {
   // TODO Script to win here ;)
+  ultraCheck();
 }

 // Serial


Some fixes

Some fixes

--- apollo/apolloClient/apolloClient.ino
+++ apollo/apolloClient/apolloClient.ino
@@ -222,37 +222,15 @@

       // Wait for http reponse and remove header
       Serial.println(F("waiting for data"));
-  while(!client.available()) {
-    delay(1); //wait for data
-  }
+  while(client.connected()) {
+    while(client.available()) {
+      if (checkBytes(crnl, byteStream)) {
+        goto end;
+      }
+    }
+  }
+  end:
   Serial.println(F("done waiting for data"));
-  if (client.available()) { //connected or data available
-
-  // New waiting thing
-  Serial.println(F("calling checkBytes"));
-  checkBytes(crnl, byteStream);
-/*
-    char a = client.read();
-    Serial.print(a);
-    if (a == '\r') {
-      char b = client.read();
-      Serial.print(b);
-      if (b == '\n') {
-        char c = client.read();
-        Serial.print(c);
-        if (c == '\r') {
-           char d = client.read();
-           Serial.print(d);
-           if (d == '\n') {
-               break;
-           }
-         }
-       }
-     }
-*/
-
-
-  }
   }
   else {
     Serial.println(F("connection failed")); //error message if no client connect


Make particle variables doubles, not floats

--- temperature-relay.ino
+++ temperature-relay.ino
@@ -45,9 +45,9 @@
 int led1 = D7;
 int powertail = D5;

-float temperature;
-float minuteAverage;
-float outdoorTemp;
+double temperature;
+double minuteAverage;
+double outdoorTemp;
 double tempOnThreshold = 60.0;
 double tempOffThreshold = 65.0;
 int power = 0;
@@ -233,7 +233,7 @@
   if (tempStr != NULL) {
     f_temp = tempStr.toFloat();
     if (f_temp !=0) {
-      outdoorTemp = f_temp;
+      outdoorTemp = (double)f_temp;
       publishTemp("outdoor_temp", "Outdoor Temp: ", outdoorTemp);
     }
   }
@@ -266,8 +266,8 @@
     if(sensors.count() > 0) {
       sensors.read();

-      minuteAverage = sensors.minute_average;
-      temperature = sensors.temp;
+      minuteAverage = (double)sensors.minute_average;
+      temperature = (double)sensors.temp;

       Serial.print("Temp: ");
       Serial.println(temperature);


Delete Vlastny_Model-RBA.ino

Delete Vlastny_Model-RBA.ino

--- ATTINY85/Vlastny_Model-RBA/Vlastny_Model-RBA.ino
+++ ATTINY85/Vlastny_Model-RBA/Vlastny_Model-RBA.ino
@@ -1,12 +0,0 @@
-#include "Attiny85_IO.h"
-Attiny attiny;
-void setup() {
-
-
-}
-
-void loop()
-{
-  if (attiny.LightSensor(1,"digital")==1){attiny.motor ("A", 1, "digital");}
-  else {attiny.motor("A", 0, "digital");}
-}


ACCEPT番号を送信するように変更

ACCEPT番号を送信するように変更

--- 2_example/example29_dash/example29_dash.ino
+++ 2_example/example29_dash/example29_dash.ino
@@ -133,10 +133,11 @@
     digitalWrite(PIN_EN,HIGH);              // センサ用の電源をONに
     udp.beginPacket(SENDTO, PORT);          // UDP送信先を設定
     udp.print(DEVICE);                      // デバイス名を送信
+    udp.print(i+1);                         // ACCEPT番号を送信
     for(i=0;i<6;i++){
         udp.print(',');
         if(mac[i]<0x10) udp.print(0);
-        udp.print(mac[i],HEX);
+        udp.print(mac[i],HEX);              // MACアドレスを送信
     }
     udp.println();
     udp.endPacket();                        // UDP送信の終了(実際に送信する)


Some tweaks, e.g. to work with hardware serial buffers moved up to 128 bytes. Start of initial gold master burn testing for both models.

--- device.ino
+++ device.ino
@@ -85,11 +85,11 @@
 #define   WIFI_NOT_CELL
 #define WIFI_DEBUG_ON
 //#define GPRS_DEBUG_ON
-#define GPS_DEBUG_ON
+//#define GPS_DEBUG_ON
 //#define PUMP_DEBUG_ON
 //#define EXECUTION_PATH_DEBUG_ON
 #define NMEA_DEBUG_ON
-#define DEBUG_MEMORY_ON
+//#define DEBUG_MEMORY_ON
 //#define STRESS_MEMORY_ON
 //#define BYPASS_AES_ON
 //#define BARO_DEBUG_ON
@@ -448,8 +448,10 @@

   //Serial3.println("$PMTK314,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28");	// Every 2 seconds
   //Serial3.println("$PMTK314,0,3,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*2A");		// GGA every 1 second, RMC every 3
-  Serial3.println("$PMTK314,0,3,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29");		// GGA every 2 second, RMC every 3
+  //Serial3.println("$PMTK314,0,3,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29");		// GGA every 2 second, RMC every 3
   //Serial3.println("$PMTK314,0,5,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*2E");		// GGA every 3 second, RMC every 5
+  Serial3.println("$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28");		// GGA & RMC every second
+  //Serial3.println("$PMTK314,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29");		// GGA every 3 second, RMC every 2
 }

@@ -2725,8 +2727,7 @@
     #endif
     return;
   }
-
-
+
   if(wifi_communication_state == idle)
   {
     if(latest_message_to_send.length() > 0)
@@ -3633,9 +3634,9 @@

 void parse_nmea_sentence()
 {
-
-//  Serial.print("NMEA: ");
-//  Serial.println(nmea_read_buffer);
+    #ifdef NMEA_DEBUG_ON
+    debug_info("NMEA buf:" + nmea_read_buffer);
+    #endif

   int commas[8] = {-1, -1, -1, -1, -1, -1, -1 , -1};

@@ -3946,6 +3947,7 @@
   {
     previous_console_timestamp = current_timestamp;
     report_state(true);
+    zero_nmea_values();
     #ifdef DEBUG_MEMORY_ON
     print_free_memory();
     #endif


fix a typo

fix a typo

--- rttygps/rttygps.ino
+++ rttygps/rttygps.ino
@@ -189,7 +189,7 @@
         msg += delim;
         msg += longitude;
         msg += delim;
-        msg += altitude
+        msg += altitude;
         msg += delim;
         msg += time;
         msg += nl;


Set color temperature

Set color temperature

The "white" was too purple. This makes the white more on the blue side, but at
least that looks like a cool color temp LED light than purple which is kind of
misleading.

--- arduino/blinkytape_orb.ino
+++ arduino/blinkytape_orb.ino
@@ -7,6 +7,7 @@
 // hardware
 #define NUM_LEDS 12
 #define LED_CORRECTION TypicalSMD5050
+#define COLOR_TEMPERATURE OvercastSky

 #define DATA_PIN 13
 #define BUTTON_IN 10
@@ -109,6 +110,7 @@

   FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
   FastLED.setCorrection(LED_CORRECTION);
+  FastLED.setTemperature(COLOR_TEMPERATURE);

   val = PULSE_MAX_VAL;


added ABORT serial command

added ABORT serial command

--- arduino/controller/controller.ino
+++ arduino/controller/controller.ino
@@ -17,7 +17,7 @@
 #define BAUDRATE 115200
 #define FLOAT_PRECISION_DIGITS 9
 #define FLOAT_DELTA 1e-20
-#define MAXCOMMANDS 12
+#define MAXCOMMANDS 14

 //Voltage sensing
 #define ADC_CHANNEL_VOLTAGE 0
@@ -42,8 +42,9 @@
 #define V_MIN (-V_REF/2.0 + DELTA_V)
 #define V_MAX ( V_REF/2.0 - DELTA_V)

-//SerialCommand parser
+//SerialCommand parsers
 SerialCommand SCmd(MAXCOMMANDS);
+SerialCommand SweepSCmd(2);

 //Sample Timer
 Timer SampleTimer;
@@ -93,8 +94,13 @@
   SCmd.addCommand("VSWEEP.RAMP",   setSweepRampCommand);
   SCmd.addCommand("VSWEEP.SAMPLE", setSweepSampleRateCommand);
   SCmd.addCommand("VSWEEP.CYCLES", setSweepCyclesCommand);
+
+  SCmd.addCommand("ABORT!", nullCommand);

   SCmd.setDefaultHandler(unrecognizedCommand);
+  //add commands that are only valid during an active sweep
+  SweepSCmd.addCommand("ABORT!", sweepAbortCommand);
+
   Serial.print(F("#<INIT>\n"));
   //start up the SPI bus
   SPI.begin();
@@ -276,6 +282,7 @@

 float _sweep_voltage_step;
 volatile float _sweep_control_voltage;
+volatile bool  _sweep_abort = false;

 //default parameters for the sweep
 float _sweep_v_start =  0;
@@ -284,13 +291,17 @@
 float _sweep_samp_rate = SAMPRATE_DEFAULT; //samples per second
 float _sweep_cycles  =  1;

+
+void sweepAbortCommand(){
+    Serial.print(F("#<ABORT />\n"));
+    _sweep_abort = true;
+}
+
 void sweepTickISR(){
   //Serial.print(F("Tick!\n"));
   _sweep_control_voltage += _sweep_voltage_step;
-  noInterrupts();           // disable all interrupts
   //change output voltage
   control_DAC.setVoltageOutput(_sweep_control_voltage + V_VGND); //shift to center-rail
-  interrupts();           // enable interrupts
 }

 void sweepSampleCallback(){
@@ -395,14 +406,20 @@
   int i;
   for(i=0; i < _sweep_cycles; i++){
       while (_sweep_control_voltage <= _sweep_v_end){
+        SweepSCmd.readSerial(); //process serial commands
+        if (_sweep_abort == true) goto END_SWEEP;
         SampleTimer.update();
       }
       _sweep_voltage_step = -1.0*_sweep_voltage_step;
       while (_sweep_control_voltage >= _sweep_v_start){
+        SweepSCmd.readSerial(); //process serial commands
+        if (_sweep_abort == true) goto END_SWEEP;
         SampleTimer.update();
       }
       _sweep_voltage_step = -1.0*_sweep_voltage_step;
   }
+END_SWEEP:
+  _sweep_abort = false;
   SampleTimer.stop(sampleEvent);
   Serial.print(F("#</CSV_DATA>\n"));
   Serial.print(F("#</VSWEEP>\n"));


Added Markov Speed Back

Added Markov Speed Back

--- Pan_Tilt_laser/Pan_Tilt_laser.ino
+++ Pan_Tilt_laser/Pan_Tilt_laser.ino
@@ -77,7 +77,7 @@

   delay(50);
-  //changeVal = getMarkovSpeed(changeVal);
+  changeVal = getMarkovSpeed(changeVal);

   panTiltX.angle = getDeltaPosition(&panTiltX, changeVal, probVal) + panTiltX.angle;

@@ -97,7 +97,7 @@
   else if(random(100001) < 10){
     laser.fire(0);
     panTilt.detach();
-    delay(60 * 1000 * random(5, 30));
+    delay(60000 * random(5, 30));
     panTilt.begin();
   }


Changes on readGPS.

Changes on readGPS.

--- scadacar_sketch/scadacar_sketch.ino
+++ scadacar_sketch/scadacar_sketch.ino
@@ -8,6 +8,8 @@

 #include <TinyGPS++.h>
 #include <SoftwareSerial.h>
+
+boolean debug = true;

 // Bluetooth Serial parameters:
 SoftwareSerial bt(5,4);
@@ -104,16 +106,18 @@
   delay(1000);
 }

-void sendMessage(String message)
-{
+void sendMessage(String msg)
+{
+  if(debug == true) {Serial.print("sending Bluetooth message: "); Serial.println(msg);}
   bt.flush();
   // Serial.print("Sending message: ");
   //Serial.println(message);
-  bt.println(message);
+  bt.println(msg);
 }

 void readMaster()
 {
+  if(debug == true) {Serial.println("reading Master Bluetooth...");}
   if (bt.available() > 0) {
     String msg; // string to store entire command line
     while (bt.available()) {
@@ -122,12 +126,15 @@
     Serial.println(msg);
     delay(50);
     checkIncommingCmd( msg.toInt() );
+  } else {
+    if(debug == true) {Serial.println("nothing from Master Bluetooth.");}
   }
   bt.flush();
 }

 void readOBD()
 {
+  if(debug == true) {Serial.println("reading OBD Bluetooth...");}
   if (obd.available() > 0) {
     String msg; // string to store entire command line
     delay(1000); // wait 1 sec to give time enough for the serial to receive all the stream
@@ -136,26 +143,32 @@
     }
     Serial.println(msg);
     delay(50);
-  } else {
-    sendMessage("No data from OBD2.");
+    sendMessage(msg);
+    } else {
+      if(debug == true) {Serial.println("nothing from OBD Bluetooth.");}
+      sendMessage("No data from OBD2.");
   }
   obd.flush();
 }

 void readGPS()
 {
+  if(debug == true) {Serial.println("reading GPS...");}
   // This sketch displays information every time a new sentence is correctly encoded.
-  while (ss.available() > 0) {
-    delay(1000); // wait 1 sec to give time enough for the serial to receive all the stream
-    if (gps.encode(ss.read())) {
+  if (ss.available() > 0) {
+    //delay(1000); // wait 1 sec to give time enough for the serial to receive all the stream
+    while (gps.encode(ss.read())) {
       displayInfo();
     }
+  } else {
+    if(debug == true) {Serial.println("nothing from GPS.");}
   }
   ss.flush();

   if (millis() > 5000 && gps.charsProcessed() < 10)
   {
-    Serial.println(F("No GPS detected: check wiring."));
+    if(debug == true) {Serial.println("No GPS detected: check wiring.");}
+    //Serial.println(F("No GPS detected: check wiring."));
     // while(true);
   }
 }
@@ -198,18 +211,23 @@
 {
   switch (cmd) {
     case 0:
+      if(debug == true) {Serial.println("Requesting PID_RPM");}
       send_OBD_cmd(PID_RPM);
       break;
     case 1:
+      if(debug == true) {Serial.println("Requesting PID_SPEED");}
       send_OBD_cmd(PID_SPEED);
       break;
     case 2:
+      if(debug == true) {Serial.println("Requesting PID_FUEL_LEVEL");}
       send_OBD_cmd(PID_FUEL_LEVEL);
       break;
     case 3:
+      if(debug == true) {Serial.println("Requesting PID_DISTANCE");}
       send_OBD_cmd(PID_DISTANCE);
       break;
     case 4:
+      if(debug == true) {Serial.println("Requesting PID_THROTTLE");}
       send_OBD_cmd(PID_THROTTLE);
       break;
   }


EDIT: Cleaning up code

EDIT: Cleaning up code

--- serialmovements/serialmovements.ino
+++ serialmovements/serialmovements.ino
@@ -3,32 +3,37 @@
 Servo arm1;
 Servo arm2;
 Servo legs;
+Servo head;

 int pos = 0;
 int pos2 = 0;
 int legPos;
 int legPos1;
+int index;
+const int numActions = 3;
 unsigned long startTime;
 unsigned long endTime;
-String command1;
-int duration1;
-String command2;
-int duration2;
+String input;
+String commands[numActions];
+String durations[numActions];

 void setup () {
   // start serial communication.
   Serial.begin (9600);

+  head.attach(12);
   arm1.attach(9);
   arm2.attach(11);
   legs.attach(10);
+
 }

 void loop () {
     arm1.write(170);
     arm2.write(0);
     legs.write(135);
+    head.write(65);

   while(Serial.available()>0) {
     input = Serial.readString();
@@ -46,21 +51,25 @@
       if (commands[i] == "sword"){
         startTime = millis();
         Serial.print("wagao");
-        while (millis() < startTime + duration*1000) {
+        while (millis() < startTime + durations[i].toInt()*1000) {
           swordFight(arm1,arm2,legs);
         }
-      command = "";
-    }
-
-      } else if (commands[i] == "walk") {
+      commands[i] = "";
+       } else if (commands[i] == "walk") {
           startTime = millis();
           Serial.print("wagao");
-          while (millis() < startTime + duration*1000) {
+          while (millis() < startTime + durations[i].toInt()*1000) {
            walk(arm1,arm2,legs);
           }
-          command = "";
-        } else if (commands[i] == "bow") {
-
+          commands[i] = "";
+      } else if (commands[i] == "bow") {
+          startTime = millis();
+          Serial.print("wagao");
+          while (millis() < startTime + durations[i].toInt()*1000) {
+           bow(head);
+           head.write(65);    //return to upright position
+          }
+          commands[i] = "";
       }
     }

@@ -85,7 +94,7 @@
 //    command = "";
 //  }
 //
-//}
+}

 void walk(Servo servo1, Servo servo2, Servo servo3) {
@@ -121,14 +130,10 @@
       servo1.write(pos);
       servo2.write(pos-90);
       servo3.write(140);
-//      servo2.write(legPos);
       legPos -= 1;

       delay(15);
-      servo2.write(legPos);
-
-
-
+      servo2.write(legPos);
   }
     for (pos = 145; pos >= 125; pos -= 1) { // goes from 180 degrees to 0 degrees
       servo1.write(pos);              // tell servo to go to position in variable 'pos'
@@ -137,10 +142,21 @@
       servo3.write(130);
       legPos1 += 1;
       servo2.write(legPos1);
-      delay(15);                       // waits 15ms for the servo to reach the position
-
+      delay(15);                       // waits 15ms for the servo to reach the position
   }

+}
+
+void bow(Servo servo1){
+  for (pos = 0; pos <= 65; pos += 1) { // goes from 0 degrees to 180 degrees
+    // in steps of 1 degree
+    servo1.write(pos);              // tell servo to go to position in variable 'pos'
+    delay(15);                       // waits 15ms for the servo to reach the position
+  }
+  for (pos = 65; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
+    servo1.write(pos);              // tell servo to go to position in variable 'pos'
+    delay(15);                       // waits 15ms for the servo to reach the position
+  }
 }

 void rest(Servo servo1, Servo servo2, Servo servo3) {


Update Modbus-Energy-Monitor-Arduino.ino

--- Modbus-Energy-Monitor-Arduino/Modbus-Energy-Monitor-Arduino.ino
+++ Modbus-Energy-Monitor-Arduino/Modbus-Energy-Monitor-Arduino.ino
@@ -30,12 +30,12 @@
 #define MB_BAUDRATE       2400          // b 2400
 #define MB_BYTEFORMAT     SERIAL_8N2    // Prty n
 #define TxEnablePin       17
-#define TIMEOUT           200
+#define TIMEOUT           100

 #define ID_1  1                       // id 001  modbus id of the energy monitor
 #define REFRESH_INTERVAL  5000        // refresh time, 5 SECONDS
-#define WRITE_INTERVAL 60000UL        // values send to serial port, 1 minute ( 60 * 1000)
+#define WRITE_INTERVAL 20000UL        // values send to serial port, 1 minute ( 60 * 1000)
 #define KWH_2_WS 36000000

 // Direcciones registros de datos solo lectura. Valores tipo float.
@@ -87,6 +87,7 @@
 void setup() {
   SERIAL_BEGIN(9600);
   MBserial.begin(MB_BAUDRATE, MB_BYTEFORMAT, TIMEOUT, REFRESH_INTERVAL);
+  delay(95);
   SERIAL_PRINTLN("time(s), maxVolt(V), minVolt(V), maxCurr(A) minCurr(A), maxPower(W), minPower(W), maxApPower(VA), minApPower(VA), maxFreq(Hz), minFreq(Hz), AvgPower (W), Energy(Kwh)");

   firstData = false;
@@ -145,29 +146,29 @@

     SERIAL_PRINT(currentMillis / 1000);
     SERIAL_PRINT(",");
-    SERIAL_PRINT(maxVoltage / VOL_FAC);
+    SERIAL_PRINT(maxVoltage / VOL_FAC, 1);
     SERIAL_PRINT(",");
-    SERIAL_PRINT(minVoltage / VOL_FAC);
+    SERIAL_PRINT(minVoltage /VOL_FAC, 1);
     SERIAL_PRINT(",");
-    SERIAL_PRINT(maxCurrent /CUR_FAC);
+    SERIAL_PRINT(maxCurrent /CUR_FAC, 2);
     SERIAL_PRINT(",");
-    SERIAL_PRINT(minCurrent / CUR_FAC);
+    SERIAL_PRINT(minCurrent / CUR_FAC, 2);
     SERIAL_PRINT(",");
-    SERIAL_PRINT(maxPower / POW_FAC);
+    SERIAL_PRINT(maxPower / POW_FAC, 2);
     SERIAL_PRINT(",");
-    SERIAL_PRINT(minPower /POW_FAC);
+    SERIAL_PRINT(minPower / POW_FAC, 2);
     SERIAL_PRINT(",");
-    SERIAL_PRINT(maxApower / POW_FAC);
+    SERIAL_PRINT(maxApower / POW_FAC, 2);
     SERIAL_PRINT(",");
-    SERIAL_PRINT(minApower /POW_FAC);
+    SERIAL_PRINT(minApower /POW_FAC, 2);
     SERIAL_PRINT(",");
-    SERIAL_PRINT(maxFreq / FRE_FAC);
+    SERIAL_PRINT(maxFreq / FRE_FAC, 2);
     SERIAL_PRINT(",");
-    SERIAL_PRINT(minFreq /FRE_FAC);
+    SERIAL_PRINT(minFreq / FRE_FAC, 2);
     SERIAL_PRINT(",");
-    SERIAL_PRINT(avgPower /ENE_FAC);
+    SERIAL_PRINT(avgPower / ENE_FAC, 2);
     SERIAL_PRINT(",");
-    SERIAL_PRINTLN(energy / ENE_FAC);
+    SERIAL_PRINTLN(energy /ENE_FAC, 2);

   }
 }


Send extra data to serial port

Send extra data to serial port

--- Sensors/GpsDataToSerial/GpsDataToSerial.ino
+++ Sensors/GpsDataToSerial/GpsDataToSerial.ino
@@ -85,15 +85,25 @@
           String sLat = getValue(value,',',2);
           if(sLat == "")
             sLat = "0";
+          String sLatd = getValue(value,',',3);
+
           String sLong = getValue(value,',',4);
           if(sLong == "")
             sLong = "0";
+          String sLongd = getValue(value,',',5);
+
+          String sAlt = getValue(value,',',9);
+          if(sAlt == "")
+            sAlt = "0";

-          String geo = "{\"latitude\":\"" + sLat + "\",\"longitude\":\"" + sLong + "\",\"altitude\":\"0\"}";
+          String geo = "{\"latitude\":\"" + sLat + "\",\"latd\":\"" + sLatd + "\",\"longitude\":\"" + sLong + "\",\"longd\":\"" + sLongd + "\",\"altitude\":\"" + sAlt + "\"}";

           Serial.println("#");
+          delay(50);
           Serial.println(geo);
+          delay(50);
           Serial.println("#");
+          delay(50);
         }
       }
     }


Moved break outside of scope

Moved break outside of scope

    * examples/ArduinoUnoNano-downlink/ArduinoUnoNano-downlink.ino:

--- examples/ArduinoUnoNano-downlink/ArduinoUnoNano-downlink.ino
+++ examples/ArduinoUnoNano-downlink/ArduinoUnoNano-downlink.ino
@@ -132,8 +132,8 @@
       case TX_SUCCESS:
         {
           Serial.println("TX successful and acknowledged");
-          break;
         }
+        break;
       case TX_WITH_RX:
         {
           String received = myLora.getRx();


fix code

fix code

--- little-switches/arduino/3_setup-rel/3_setup-rel.ino
+++ little-switches/arduino/3_setup-rel/3_setup-rel.ino
@@ -59,65 +59,57 @@
     // check for some of the special keys
     if (c == '1') {
       digitalWrite(2,HIGH);
-      t1 = millis();
+      delay(tempo);
+      digitalWrite(4,LOW);
+      Serial.println(c);
+
     }
     else if (c == '2') {
       digitalWrite(4,HIGH);
-      t2 = millis();
+      delay(tempo);
+      digitalWrite(4,LOW);
+      Serial.println(c);
     }
     else if (c == '3') {
       digitalWrite(5,HIGH);
-      t3 = millis();
+      delay(tempo);
+      digitalWrite(5,LOW);
+      Serial.println(c);
     }
     else if (c == '4') {
       digitalWrite(6,HIGH);
-      t4 = millis();
+      delay(tempo);
+      digitalWrite(6,LOW);
+      Serial.println(c);
     }
     else if (c == '5') {
       digitalWrite(7,HIGH);
-      t5 = millis();
+      delay(tempo);
+      digitalWrite(7,LOW);
+      Serial.println(c);
     }
     else if (c == '6') {
       digitalWrite(8,HIGH);
-      t6 = millis();
+      delay(tempo);
+      digitalWrite(8,LOW);
+      Serial.println(c);
     }
     else if (c == '7') {
       digitalWrite(A0,HIGH);
-      t7 = millis();
+      delay(tempo);
+      digitalWrite(A0,LOW);
+      Serial.println(c);
     }
     else if (c == '8') {
       digitalWrite(A1,HIGH);
-      t8 = millis();
+      delay(tempo);
+      digitalWrite(A1,LOW);
+      Serial.println(c);
     }
     else {
       Serial.print(c);
     }
   }

-  else {
-    if ((millis() - t1) > tempo) {
-      digitalWrite(2,LOW);
-    }
-    if ((millis() - t2) > tempo) {
-      digitalWrite(4,LOW);
-    }
-    if ((millis() - t3) > tempo) {
-      digitalWrite(5,LOW);
-    }
-    if ((millis() - t4) > tempo) {
-      digitalWrite(6,LOW);
-    }
-    if ((millis() - t5) > tempo) {
-      digitalWrite(7,LOW);
-    }
-    if ((millis() - t6) > tempo) {
-      digitalWrite(8,LOW);
-    }
-    if ((millis() - t7) > tempo) {
-      digitalWrite(A0,LOW);
-    }
-    if ((millis() - t8) > tempo) {
-      digitalWrite(A1,LOW);
-    }
-  }
+
 }


Move clock signal setup into its own function

--- Arduino/noise_multiplier/noise_multiplier.ino
+++ Arduino/noise_multiplier/noise_multiplier.ino
@@ -19,7 +19,19 @@
   // Setting DDB1 and DDB2
   DDRB |= bit (DDB1) | bit (DDB2);

-  // stop timer 1
+  setupClockSignals();
+
+  enableInterrupts();
+
+  Serial.begin(230400);
+  Serial.println("Starting...");
+
+  //Set D pins to input
+  DDRD = 0x00;
+}
+
+void setupClockSignals() {
+    // stop timer 1
   TCCR1A = 0;
   TCCR1B = 0;

@@ -35,20 +47,13 @@
   ICR1 = 15;
   OCR1B = 7;
   OCR1A = 7;
+}

-  // enable timer compare interrupt
+void enableInterrupts(){
+    // enable timer compare interrupt
   TIMSK1 |= (1 << OCIE1A);
-
   sei();
-
-  Serial.begin(230400);
-  Serial.println("Starting...");
-
-  //Set D pins to input
-  DDRD = 0x00;
-
-}
-
+}

 ISR(TIMER1_COMPA_vect) {
   static byte currentByte = 0x00;


make cooler pattern

make cooler pattern

--- arduino/LEDDisplay/LEDDisplay.ino
+++ arduino/LEDDisplay/LEDDisplay.ino
@@ -1,42 +1,46 @@
-int rows = 7;
-int cols = 7;
-int incr1 = 10;
+const int rows = 7;
+const int cols = 7;
+int coordMap[rows][cols];
+int coords[rows*cols][3];
 boolean lightOn = true;
-int startingBrightness = 0;
+int step = 0;
+int currentColor[3];
+int layer1[1] = {24};
+int layer2[8] = {18,23,32,17,31,16,25,30};
+int layer3[16] = {8,9,10,11,12,19,22,33,15,26,29,36,37,38,39,40};
+int layer4[24] = {0,1,2,3,4,5,6,42,43,44,45,46,47,48,7,20,21,34,35,13,14,27,28,41};
+int currWheelPos = 0;
+
 void setup() {
   Serial.begin(115200);
   pinMode(13, OUTPUT);
+
+  for (int i=0; i<rows*cols; i++) {
+    coords[i][0] = 0;
+    coords[i][1] = 0;
+    coords[i][2] = 0;
+    int col = i / rows;
+    int row = i % rows;
+    if (col % 2 == 0) {
+      row = rows - row - 1;
+    }
+    coordMap[col][row] = i;
+  }
 }

 void loop() {
-  int incr2 = 10;
-  int currentBrightness = startingBrightness;
-  String lightArray = "[";
-  for (int i=0; i<rows*cols; i++) {
-    String val = String(currentBrightness);
-    lightArray += "["+val+",0,0]";
-    if (i+1 < rows*cols) {
-      lightArray += ",";
-    }
-    currentBrightness += incr2;
-    if (currentBrightness > 255) {
-      incr2 = -10;
-      currentBrightness = 255;
-    } else if (currentBrightness < 0) {
-      incr2 = 10;
-      currentBrightness = 0;
-    }
+  for (int layer=0; layer<4; layer++) {
+    int brightness = layer - step;
+
   }
-  lightArray += "]";
-  startingBrightness += incr1;
-  if (startingBrightness > 255) {
-    incr1 = -10;
-    startingBrightness = 255;
-  } else if (startingBrightness < 0) {
-    incr1 = 10;
-    startingBrightness = 0;
+
+  step++;
+  if (step > 3) {
+    step = 0;
   }
-  Serial.println(lightArray);
+
+  setLightVals();
+
   if (lightOn) {
     digitalWrite(13, HIGH);
   } else {
@@ -45,3 +49,74 @@
   lightOn = !lightOn;
   delay(30);
 }
+
+void setLightVals() {
+  int prev[3];
+  prev[0] = coords[layer3[0]][0];
+  prev[1] = coords[layer3[0]][1];
+  prev[2] = coords[layer3[0]][2];
+  for (int i=0; i<24; i++) {
+    coords[layer4[i]][0] = prev[0];
+    coords[layer4[i]][1] = prev[1];
+    coords[layer4[i]][2] = prev[2];
+  }
+  prev[0] = coords[layer2[0]][0];
+  prev[1] = coords[layer2[0]][1];
+  prev[2] = coords[layer2[0]][2];
+  for (int i=0; i<16; i++) {
+    coords[layer3[i]][0] = prev[0];
+    coords[layer3[i]][1] = prev[1];
+    coords[layer3[i]][2] = prev[2];
+  }
+  prev[0] = coords[layer1[0]][0];
+  prev[1] = coords[layer1[0]][1];
+  prev[2] = coords[layer1[0]][2];
+  for (int i=0; i<8; i++) {
+    coords[layer2[i]][0] = prev[0];
+    coords[layer2[i]][1] = prev[1];
+    coords[layer2[i]][2] = prev[2];
+  }
+  setWheelColor(currWheelPos);
+  coords[layer1[0]][0] = currentColor[0];
+  coords[layer1[0]][1] = currentColor[1];
+  coords[layer1[0]][2] = currentColor[2];
+
+  String lightArray = "[";
+  for (int i=0; i<rows*cols; i++) {
+    String r = String(coords[i][0]);
+    String g = String(coords[i][1]);
+    String b = String(coords[i][2]);
+    lightArray += "["+r+","+g+","+b+"]";
+    if (i+1 < rows*cols) {
+      lightArray += ",";
+    }
+  }
+  lightArray += "]";
+  currWheelPos += 10;
+  if (currWheelPos > 255) {
+    currWheelPos -= 255;
+  }
+
+  Serial.println(lightArray);
+}
+
+// Input a value 0 to 255 to get a color value.
+// The colours are a transition r - g - b - back to r.
+void setWheelColor(byte wheelPos) {
+  wheelPos = 255 - wheelPos;
+  if(wheelPos < 85) {
+    currentColor[0] = 255 - wheelPos * 3;
+    currentColor[1] = 0;
+    currentColor[2] = wheelPos * 3;
+  } else if(wheelPos < 170) {
+    wheelPos -= 85;
+    currentColor[0] = 0;
+    currentColor[1] = wheelPos * 3;
+    currentColor[2] = 255 - wheelPos * 3;
+  } else {
+    wheelPos -= 170;
+    currentColor[0] = wheelPos * 3;
+    currentColor[1] = 255 - wheelPos * 3;
+    currentColor[2] = 0;
+  }
+}


added gsm modem code and custom micro_delay function

--- code/arduino/main/aws_sketch/aws_sketch.ino
+++ code/arduino/main/aws_sketch/aws_sketch.ino
@@ -22,8 +22,6 @@
 #include <DS1307RTC.h>
 #include <AWS.h>

-
-
 #define DHT22_PIN 6
 #define AWS_NO_SERIAL 1

@@ -31,6 +29,11 @@
 Adafruit_BMP085 bmp;
 DHT22 myDHT22(DHT22_PIN);

+
+#if !defined(AWS_NO_GSM)
+#include <SoftwareSerial.h>
+SoftwareSerial gsmSerial(4,5);
+#endif

 #if !defined(AWS_NO_LCD)
 #include <LiquidCrystal.h>
@@ -74,17 +77,13 @@
     // sync interval is default 5 minutes

     rtc_code = init_rtc(__TIME__,__DATE__);
-    for(int i = 0 ; i < 200 ; i++) {
-      delayMicroseconds(1000);
-    }
+    micro_delay(20);

     if(rtc_code == AWS_RTC_ERROR_NONE) {
         setSyncProvider(RTC.get);
         if(timeStatus()!= timeSet) {
             // wait a bit
-            for(int i = 0 ; i < 4000 ; i++) {
-                delayMicroseconds(1000);
-            }
+            micro_delay(400);
         }

         // try again
@@ -98,13 +97,20 @@
     attachInterrupt(0,isr_pin2,RISING);
     last_irq_time = 0 ;

-    Alarm.timerRepeat(2,pat_watchdog);
-    Alarm.timerRepeat(60,update_display);
-    Alarm.alarmRepeat(8,30,0, send_bulletin);
-
 #if !defined(AWS_NO_SERIAL)
     Serial.begin(9600);
 #endif
+
+#if !defined(AWS_NO_GSM)
+    gsmSerial.println("AT+CMGF=1");
+    micro_delay(20);
+    gsmSerial.println("AT+CSMS=1");
+    micro_delay(20);
+    gsmSerial.println("AT+CNMI=2,2,0,0");
+    micro_delay(20);
+#endif
+
+    Alarm.alarmRepeat(8,30,0, send_bulletin);

 }

@@ -118,16 +124,20 @@
     }
 }

+// param n is to ensure n*10 ms delay
+void micro_delay(int n) {
+    for(int i = 0 ; i < n ; i++) {
+        delayMicroseconds(10000);
+        // pat watchdog every 100*10 ms
+        if((i > 100) && (i %100 == 0 ))
+            wdt_reset();
+    }
+}
+
 void update_display() {

     // DHT22 pin needs 2 seconds
-    for(int i = 0 ; i < 250 ; i++) {
-        delayMicroseconds(10000);
-        if(i % 100 == 0 ) {
-            wdt_reset();
-        }
-    }
-
+    micro_delay(250);
     dht22_code = myDHT22.readData();

     if(dht22_code == DHT_ERROR_NONE) {
@@ -168,12 +178,39 @@
         rain_counter_reset = false ;
     }

-    // @todo send SMS
-
-}
-
-void pat_watchdog() {
+#if !defined(AWS_NO_GSM)
+    gsmSerial.print("\r");
+    micro_delay(20);
+    gsmSerial.print("AT+CMGF=1\r");
+    micro_delay(20);
+    gsmSerial.print("AT+CMGS=\"+918553518338\"\r");
+    micro_delay(20);
+    // pat watchdog
     wdt_reset();
+
+    gsmSerial.print("Yuktix H");
+    if(dht22_code !=  DHT_ERROR_NONE) {
+        gsmSerial.println("ERR");
+        gsmSerial.print(dht22_code);
+
+    } else {
+        gsmSerial.println(humidity);
+        gsmSerial.print(" T");
+        gsmSerial.print(dht22_temp);
+    }
+
+    gsmSerial.print(" P");
+    gsmSerial.print(pressure);
+    gsmSerial.print(" R");
+    gsmSerial.print(total_rain);
+    gsmSerial.println();
+    gsmSerial.write(0x1A);
+    micro_delay(100);
+    // pat watchdog
+    wdt_reset();
+
+#endif
+
 }

 void calculate_rain() {
@@ -229,7 +266,7 @@
     Serial.print(" P");
     Serial.print(pressure);
     Serial.print(" R");
-    Serial.print(rain_counter);
+    Serial.print(total_rain);

 }
 #endif
@@ -267,10 +304,14 @@
     p1 = round(pressure/10.0);
     lcd.print(p1);
     lcd.print(" R");
-    lcd.print(rain_counter);
+    lcd.print(total_rain);
 }
 #endif

 void loop() {

-}
+    update_display();
+    wdt_reset();
+    // refresh in 30 seconds
+    micro_delay(2750);
+}


AutoRecover: Made it use getDirection and setDirection.

--- examples/AutoRecover/AutoRecover.ino
+++ examples/AutoRecover/AutoRecover.ino
@@ -2,10 +2,13 @@
 from various errors that can occur when using the AMIS-30543,
 including an interruption of the motor power supply.

-Before using this example, be sure to change the parameter to
-setCurrentMilliamps to an appropriate current limit for your
-system.  Also, see this library's documentation for information
-about how to connect the driver:
+It also shows how to change the motor direction using SPI.  The
+DIR pin is not used and does not need to be connected.
+
+Before using this example, be sure to change the
+setCurrentMilliamps line to have an appropriate current limit for
+your system.  Also, see this library's documentation for
+information about how to connect the driver:

     http://pololu.github.io/amis-30543-arduino/
 */
@@ -48,7 +51,12 @@
     return;
   }

-  if ((millis() & 1023) >= 774)
+  uint16_t m = millis();
+
+  // We will switch directions after each pause.
+  bool desiredDirection = m >> 10 & 1;
+
+  if ((m & 1023) >= 774)
   {
     // Pause for 250 ms once per second.
   }
@@ -60,7 +68,13 @@
     {
       lastStepTime = micros();

-      // The NXT minimum high pulse width is 2 microseconds.
+      // Send the SPI command to change the direction, but only
+      // if it is needed.
+      if (desiredDirection != stepper.getDirection())
+      {
+        stepper.setDirection(desiredDirection);
+      }
+
       digitalWrite(amisStepPin, HIGH);
       delayMicroseconds(3);
       digitalWrite(amisStepPin, LOW);


LCD使用の初期値をOFF（使わない）へ変更

LCD使用の初期値をOFF（使わない）へ変更

--- 2_example/example31_demo/example31_demo.ino
+++ 2_example/example31_demo/example31_demo.ino
@@ -11,7 +11,7 @@
 #include <WiFiUdp.h>                        // UDP通信を行うライブラリ
 #define PIN_LED 2                           // GPIO 2(24番ピン)にLEDを接続
 #define PIN_SW 0                            // GPIO 0(25番ピン)にスイッチを接続
-#define LCD_EN 1                            // 液晶の接続有=1,無=0
+#define LCD_EN 0                            // 液晶の接続有=1,無=0
 #define WIFI_AP_MODE 1                      // Wi-Fi APモード ※「0」でSTAモード
 #define SSID "1234ABCD"                     // 無線LANアクセスポイントのSSID
 #define PASS "password"                     // パスワード


changed ino name

changed ino name

--- ArduDiffDriveRobot.ino
+++ ArduDiffDriveRobot.ino
@@ -1,105 +0,0 @@
-
-#include "ADDRPinout.h"
-
-#include <PinChangeInt.h>
-#include "Motor.h"
-#include "DiskEncoder.h"
-#include "DifferentialDriver.h"
-#include "Robot.h"
-#include "ADDRSupervisor.h"
-
-#define ENC_HIGH_DELAY 10
-
-volatile long lastRiseTimeL = 0;
-volatile long lastRiseTimeR = 0;
-
-bool start = true;
-bool atGoal = false;
-
-ADDRSupervisor *supervisor = new ADDRSupervisor();
-
-void updateLeftEncoderCountInterrupt()
-{
-	if(lastRiseTimeL + ENC_HIGH_DELAY < millis())
-	{
-		if(digitalRead(L_MOTOR_DIR) == HIGH)
-			supervisor->incrementEncoderCount(0);
-		else
-			supervisor->decrementEncoderCount(0);
-		lastRiseTimeL = millis();
-	}
-}
-
-void updateRightEncoderCountInterrupt()
-{
-	if(lastRiseTimeR + ENC_HIGH_DELAY < millis())
-	{
-
-		if(digitalRead(R_MOTOR_DIR) == HIGH)
-			supervisor->incrementEncoderCount(1);
-		else
-			supervisor->decrementEncoderCount(1);
-
-
-		lastRiseTimeR = millis();
-	}
-}
-
-void setup() {
-
-
-	Serial.begin(9600);
-	/*
-		65mm diameter
-		99.25mm base length
-	*/
-
-	Robot *robot = new Robot(130, 60);
-
-	Motor *leftMotor =  new Motor(L_MOTOR_PWM, L_MOTOR_DIR);
-	Motor *rightMotor = new Motor(R_MOTOR_PWM, R_MOTOR_DIR);
-	//rightMotor->setBeta( 0.90 );
-
-	robot->setMotors(leftMotor, rightMotor);
-
-	UltraSonicSensor A = UltraSonicSensor(SONIC_0);
-	UltraSonicSensor B = UltraSonicSensor(SONIC_1);
-	UltraSonicSensor C = UltraSonicSensor(SONIC_2);
-	UltraSonicSensor D = UltraSonicSensor(SONIC_3);
-	UltraSonicSensor E = UltraSonicSensor(SONIC_4);
-	UltraSonicSensor sensors[] = {A, B, C, D, E};
-
-	robot->setDistanceSensors(sensors);
-
-
-	DiskEncoder* leftEncoder =  new DiskEncoder(L_ENCODER, 16);
-	DiskEncoder* rightEncoder = new DiskEncoder(R_ENCODER, 16);
-	PCintPort::attachInterrupt(L_ENCODER, &updateLeftEncoderCountInterrupt, RISING);
-	PCintPort::attachInterrupt(R_ENCODER, &updateRightEncoderCountInterrupt, RISING);
-
-	robot->setDiskEncoders(leftEncoder, rightEncoder);
-
-	Serial.println("Starting ADDR-1");
-
-	DifferentialDriver *driver = new DifferentialDriver(0.0325, 0.09925);
-	robot->setDifferentialDriver(driver);
-
-	supervisor->setRobot(robot);
-
-}
-
-void loop() {
-
-
-	if(Serial.available() > 0)
-	{
-		char input = Serial.read();
-		if(input == 'g') start = true;
-	}
-
-	if(start && !atGoal)
-	{
-		atGoal = supervisor->updateBehavior();
-	}
-
-}


installed all 8 stepper motors

installed all 8 stepper motors

--- loom.ino
+++ loom.ino
@@ -14,7 +14,7 @@
     - 1 Teensy 3.5 microprocessor, with 512KB flash, 192KB RAM, 4KB EEPROM, and 40 I/O pins

    The software allow you to graphically configure the treadle tie-ups and the treadle sequence,
-   and then weave by throwing the shuttle and then pusshing the single foot pedeal to get the
+   and then weave by throwing the shuttle and just pushing the single foot pedeal to get the
    next configuration of the shafts.  The warping, though, must still be done manually!

    ------------------------------------------------------------------------------------------------------


ping.ino test update

ping.ino test update

--- sketchTests/ping/ping.ino
+++ sketchTests/ping/ping.ino
@@ -1,6 +1,6 @@
 #include <SPI.h>
 #include <RH_RF69.h>
-
+#include <Adafruit_BMP085.h>

 #define RF69_FREQ 915.0
 #define RFM69_INT     3
@@ -11,8 +11,9 @@

 RH_RF69 rf69(RFM69_CS, RFM69_INT);

+Adafruit_BMP085 bmp;
+
 void setup() {
-  // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println("Starting...");
   pinMode(RFM69_RST, OUTPUT);
@@ -21,7 +22,6 @@
   Serial.println("RFM69 RX Test!");
   Serial.println();

-  // manual reset
   digitalWrite(RFM69_RST, HIGH);
   delay(10);
   digitalWrite(RFM69_RST, LOW);
@@ -36,23 +36,30 @@
   if (!rf69.setFrequency(RF69_FREQ)) {
     Serial.println("Set Frequency Initialization Failed!");
   }
+
+  rf69.setTxPower(20, true);

-  // If you are using a high power RF69 eg RFM69HW, you *must* set a Tx power with the
-  // ishighpowermodule flag set like this:
-  rf69.setTxPower(20, true);  // range from 14-20 for power, 2nd arg must be true for 69HCW
-
-  // The encryption key has to be the same as the one in the server
   uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
   rf69.setEncryptionKey(key);

   Serial.print("RFM69 radio @");  Serial.print((int)RF69_FREQ);  Serial.println(" MHz");
+
+  if (!bmp.begin())
+  {
+    Serial.println("BMP180 Init Failed");
+  }
 }

 void loop() {
-  // put your main code here, to run repeatedly:
-  char radiopacket[20] = "Hello World #";
-  Serial.print("Sending "); Serial.println(radiopacket);
-  rf69.send((uint8_t *)radiopacket, strlen(radiopacket));
+  float temp = bmp.readTemperature();
+
+  String payload = String(temp) + ",0,0";
+  uint8_t data[payload.length()];
+  payload.getBytes(data, payload.length());
+  rf69.send(data, sizeof(data));
   rf69.waitPacketSent();
+
+  Serial.println(payload);
+
   delay(5000);
 }


Update Keypad.ino

Update Keypad.ino

--- ComboKeypad/Keypad.ino
+++ ComboKeypad/Keypad.ino
@@ -108,7 +108,7 @@
   }
 }

-}//Function Loop end
+}/*----(Function Loop end)----*/

 //////////////////////////////////////////////////////

@@ -149,7 +149,7 @@
       digitalWrite(wrongLight, 0);   //Turns the "Red" light off
        count = 0;  //Sets the counter to 0

-}//Function Reset end
+}/*----(Function Reset end)----*/

 //Function Debug, Prints the count, and what has been pressed
 void debug(){


bug minore

bug minore

--- Arduino/node/node.ino
+++ Arduino/node/node.ino
@@ -40,7 +40,7 @@
   if (DHT.read(DHT11_PIN) == DHTLIB_OK) {
     Serial.println("DHT11 read");
     byte hygro = map(analogRead(HYGRO), 0, 1023, 100, 0);
-    String data = (String)NODE_ID + "," + (String)DHT.temperature + "," + (String)DHT.humidity + "," + (String)hygro;
+    String data = (String)NODE_ID + "," + (String)DHT.temperature + "," + (String)hygro + "," + (String)DHT.humidity;
     Serial.println(data);
     uint8_t buffer[RH_NRF24_MAX_MESSAGE_LEN];
     data.toCharArray(buffer, data.length() + 1);


oops, naming

oops, naming

--- CocaCola/CocaCola.ino
+++ CocaCola/CocaCola.ino
@@ -80,7 +80,7 @@
 }

 void blinkLetters(int times) {
-    for (int x = 0; x < repeat; x++) {
+    for (int x = 0; x < times; x++) {
         lettersAllOff();
         delay(blinky);


Adding low power measurements for Arduino Lilypad.

--- examples/Sandbox/CosaLowPower/CosaLowPower.ino
+++ examples/Sandbox/CosaLowPower/CosaLowPower.ino
@@ -34,6 +34,10 @@
  *    a. Connected to VCC/GND, 32 uA
  *    b. Connected to RAW/GND, 840 uA
  *
+ * Arduino Lilypad, 8 Mhz, no modifications
+ * 1. Powered via FTDI USB/TTY adapter 5 V, 18 uA
+ * 2. Powered with LiPo 3,7 V, 16 uA
+ *
  * This file is part of the Arduino Che Cosa project.
  */


implemented 2 modes: oscillate & shake

implemented 2 modes: oscillate & shake

--- servo-turning-sine-wave/servo-turning-sine-wave.ino
+++ servo-turning-sine-wave/servo-turning-sine-wave.ino
@@ -18,13 +18,16 @@
 const int GENTLE_DELAY = 30;

 // milliseconds to wait between servo movement: when servo is shaking back & forth
-const int SHAKE_DELAY = 7;
+const int SHAKE_DELAY = 10;

 // maximum servo movement per iteration
 const int ANGLE_INCREMENT = 3;

 // milliseconds to wait at one end point before reversing rotation
 const int TURN_AROUND_DELAY = 10;
+
+// number of degrees to shake servo on each side of center
+const int SHAKE_OFFSET_ANGLE = 25;

 //
 // GLOBALS
@@ -50,25 +53,38 @@

 void loop()
 {
-  // oscillateGently();
+  // randomly determine which behavior
+  switch (random(2)) {
+    case 0:
+      currAngle = oscillateGently(currAngle, random(5, 10));
+      break;

-  currAngle = shakeServo(currAngle, random(5));
-  delay(3000);
+    case 1:
+      currAngle = shakeServo(currAngle, random(4));
+      break;
+  }
+
+  // wait 5 seconds until next loop
+  delay(5000);
 }

-void oscillateGently()
+int oscillateGently(int angle, int numOscillations)
 {
-  delay(TURN_AROUND_DELAY);
-  //  Serial.println("------------------------------------------------------------");
+  for (int ii = 0; ii < numOscillations ; ii += 1) {
+    delay(TURN_AROUND_DELAY);
+    //  Serial.println("------------------------------------------------------------");
+
+    digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
+    angle = turnServo(myservo, angle, random(angle, RIGHT_LIMIT - SHAKE_OFFSET_ANGLE) + 1, GENTLE_DELAY);
+
+    delay(TURN_AROUND_DELAY);
+    //  Serial.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+
+    digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
+    angle = turnServo(myservo, angle, random(SHAKE_OFFSET_ANGLE, angle), GENTLE_DELAY);
+  }

-  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
-  currAngle = turnServo(myservo, currAngle, RIGHT_LIMIT, GENTLE_DELAY);
-
-  delay(TURN_AROUND_DELAY);
-  //  Serial.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
-
-  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
-  currAngle = turnServo(myservo, currAngle, LEFT_LIMIT, GENTLE_DELAY);
+  return angle;
 }

 int turnServo(Servo servo, int startAngle, int endAngle, int delayTime)
@@ -116,10 +132,8 @@
 //
 int shakeServo(int startAngle, int numShakes)
 {
-  const int offCenter = 25;
-
-  int rightEnd = startAngle + offCenter;
-  int leftEnd = startAngle - offCenter;
+  int rightEnd = startAngle + SHAKE_OFFSET_ANGLE;
+  int leftEnd = startAngle - SHAKE_OFFSET_ANGLE;

   turnServo(myservo, startAngle, rightEnd, SHAKE_DELAY);
   turnServo(myservo, rightEnd, leftEnd, SHAKE_DELAY);


adding comment

adding comment

--- examples/sensors/infrareds/GP2D120/GP2D120.ino
+++ examples/sensors/infrareds/GP2D120/GP2D120.ino
@@ -2,7 +2,7 @@
 #include <Wire.h>

 GP2D120 sideFrontIR; //measure distances between 5 and 25 centimeters
-const int SIDE_FRONT_PIN = A0;
+const int SIDE_FRONT_PIN = A0; //you can use only analog enabled pins

 void setup() {
   sideFrontIR.attach(SIDE_FRONT_PIN);


[FW] Some more code cleanup.

[FW] Some more code cleanup.

--- firmware/MultiRomVC4000_2/MultiRomVC4000_2.ino
+++ firmware/MultiRomVC4000_2/MultiRomVC4000_2.ino
@@ -133,61 +133,61 @@
 0x0c, 0x14, 0x12, 0x10, 0x0f, 0x0c, 0x14, 0x12, 0x10, 0x0f, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00
 };

-#define CLOCK 4    //SRCLK
-#define LATCH 3    //RCLK
-#define DATA  5    //SER
-
-#define WR    2
-#define OEDATA    A1  //_G DATA BUS
-#define OEADDRESS A0  //_G ADDRESS BUS
-
-#define OEVCBUS 6
-
-#define CE1SRAM 7
-#define CE2SRAM 8
-
-#define LED 13
+#define CLOCK     4   // SRCLK
+#define LATCH     3   // RCLK
+#define DATA      5   // SER
+
+#define WR        2
+#define OEDATA    A1  // _G DATA BUS
+#define OEADDRESS A0  // _G ADDRESS BUS
+
+#define OEVCBUS   6
+
+#define CE1SRAM   7
+#define CE2SRAM   8
+
+#define LED       13

 void setup() {
- pinMode(CLOCK,OUTPUT);
- pinMode(LATCH,OUTPUT);
- pinMode(DATA,OUTPUT);
- pinMode(WR,OUTPUT);
- pinMode(OEDATA,OUTPUT);
- pinMode(OEADDRESS,OUTPUT);
- pinMode(OEVCBUS,OUTPUT);
- pinMode(LED,OUTPUT);
-
- disableVCBus();
- enableSRAM();
-
- Serial.begin(9600);
- delay(100);
-
- Serial.println("writing data");
- enableSRAM();
- for (int i=0;i<ROMSIZE;i++) {
-    write2RAM(i,pgm_read_byte(romImage+i));
- }
- disableSRAM();
-
- Serial.println("done");
- Serial.println("enable bus to VC4000");
- enableVCBus();
+  pinMode(CLOCK, OUTPUT);
+  pinMode(LATCH, OUTPUT);
+  pinMode(DATA, OUTPUT);
+  pinMode(WR, OUTPUT);
+  pinMode(OEDATA, OUTPUT);
+  pinMode(OEADDRESS, OUTPUT);
+  pinMode(OEVCBUS, OUTPUT);
+  pinMode(LED, OUTPUT);
+
+  disableVCBus();
+  enableSRAM();
+
+  Serial.begin(9600);
+  delay(100);
+
+  Serial.println("writing data");
+  enableSRAM();
+  for (int i = 0; i < ROMSIZE; i++) {
+    write2RAM(i, pgm_read_byte(romImage + i));
+  }
+  disableSRAM();
+
+  Serial.println("done");
+  Serial.println("enable bus to VC4000");
+  enableVCBus();
 }

 void loop() {
-  digitalWrite(LED,HIGH);
+  digitalWrite(LED, HIGH);
   delay(300);
-  digitalWrite(LED,LOW);
+  digitalWrite(LED, LOW);
   delay(300);
 }

 void enableSRAM() {
- pinMode(CE1SRAM,OUTPUT);
- pinMode(CE2SRAM,OUTPUT);
- digitalWrite(CE1SRAM,LOW);
- digitalWrite(CE2SRAM,HIGH);
+  pinMode(CE1SRAM, OUTPUT);
+  pinMode(CE2SRAM, OUTPUT);
+  digitalWrite(CE1SRAM, LOW);
+  digitalWrite(CE2SRAM, HIGH);
 }

 void disableSRAM() {
@@ -195,12 +195,11 @@
   // Switching them to INPUT mode while in HIGH state will
   // activate the internal pullup resistors to VCC (which is a
   // bad idea!).
- digitalWrite(CE1SRAM,LOW);
- digitalWrite(CE2SRAM,LOW);
- pinMode(CE1SRAM,INPUT);
- pinMode(CE2SRAM,INPUT);
-}
-
+  digitalWrite(CE1SRAM, LOW);
+  digitalWrite(CE2SRAM, LOW);
+  pinMode(CE1SRAM, INPUT);
+  pinMode(CE2SRAM, INPUT);
+}

 void disableVCBus() {
   digitalWrite(WR, HIGH);
@@ -217,23 +216,23 @@
 }

 void write2RAM(unsigned int address, byte data) {
-  digitalWrite(OEDATA,LOW);
-  digitalWrite(OEADDRESS,LOW);
-  digitalWrite(WR,HIGH);
-  shiftout(address,data);
-  digitalWrite(WR,LOW);
-  digitalWrite(WR,HIGH);
+  digitalWrite(OEDATA, LOW);
+  digitalWrite(OEADDRESS, LOW);
+  digitalWrite(WR, HIGH);
+  shiftout(address, data);
+  digitalWrite(WR, LOW);
+  digitalWrite(WR, HIGH);
 }

 void shiftout(unsigned int address, byte data) {
   byte lowbyte = address & 0xff;
   byte highbyte = address >> 8;

-  digitalWrite(LATCH,LOW);
-  shiftOut(DATA,CLOCK,MSBFIRST,data);
-  shiftOut(DATA,CLOCK,MSBFIRST,highbyte);
-  shiftOut(DATA,CLOCK,MSBFIRST,lowbyte);
-  digitalWrite(LATCH,HIGH);
+  digitalWrite(LATCH, LOW);
+  shiftOut(DATA, CLOCK, MSBFIRST, data);
+  shiftOut(DATA, CLOCK, MSBFIRST, highbyte);
+  shiftOut(DATA, CLOCK, MSBFIRST, lowbyte);
+  digitalWrite(LATCH, HIGH);
   delay(1);
-  digitalWrite(LATCH,LOW);
-}
+  digitalWrite(LATCH, LOW);
+}


make things compile again

make things compile again

--- LDR2Ethernet/LDR2Ethernet.ino
+++ LDR2Ethernet/LDR2Ethernet.ino
@@ -5,17 +5,17 @@
 const byte
   chipSelect = 8,
   frameHeader = 54,
-  LDRInterruptPin 0,
+  LDRInterruptPin = 0,
   ver = 1,
   ldrpin = 2;

 // ethernet interface mac address, must be unique on the LAN
-const byte etherMac[6] = {0x74, 0x69, 0x69, 0x2D, 0x31, 0x06};
-
-const char http_OK[] PROGMEM = "HTTP/1.0 200 OK\r\n"
-const char http_NOK[] PROGMEM = "HTTP/1.0 404 NOT FOUND\r\n"
-const char http_JSON[] PROGMEM = "Content-Type: application/json\r\n"
-const char http_HTML[] PROGMEM = "Content-Type: text/html\r\n"
+const byte etherMac[6] = {0x74, 0x69, 0x69, 0x2D, 0x31, 0x08};
+
+const char http_OK[] PROGMEM = "HTTP/1.0 200 OK\r\n";
+const char http_NOK[] PROGMEM = "HTTP/1.0 404 NOT FOUND\r\n";
+const char http_JSON[] PROGMEM = "Content-Type: application/json\r\n";
+const char http_HTML[] PROGMEM = "Content-Type: text/html\r\n";
 const char http_NOCACHE[] PROGMEM = "Pragma: no-cache\r\n\r\n";

 // offset addresses for the IP, MAC in the eeprom
@@ -54,13 +54,15 @@
   readIP(etherIP);
   bool online = false;
   if (etherIP[0] == 0 || etherIP[0] == 255){
-    Serial.println("Setting up DHCP");
-    if (!ether.dhcpSetup()){
-      Serial.println( "DHCP failed");
-    } else {
-      Serial.print("Online at DHCP:");
-      ether.printIp("IP: ", ether.myip);
-      online = true;
+    while(!online){
+      Serial.println("Setting up DHCP");
+      if (!ether.dhcpSetup()){
+        Serial.println( "DHCP failed");
+      } else {
+        Serial.print("Online at DHCP:");
+        ether.printIp("IP: ", ether.myip);
+        online = true;
+      }
     }
   }
   if(!online){


Fixed incorrect constant for Trigger PIN.

--- VernierLaserTracker/VernierLaserTracker.ino
+++ VernierLaserTracker/VernierLaserTracker.ino
@@ -1,4 +1,4 @@
-/*VernierLaserTracker  (v 2013.11)
+/*VernierLaserTracker  (v 2014.4)
 Monitors the position of an object using a Vernier Motion Detector
 and then aims a laser pointer mounted on a servo motor at the object.

@@ -15,7 +15,7 @@
 const int SpeedOfSound = 344; //in m/s
 double Distance;// in centimeters
 int val = 0;
-const int TriggerPin = 4; //trigger pin
+const int TriggerPin = 3; //trigger pin
 const int EchoPin = 2;// echo pin
 int Range=100; //distance in cm from Laser Pointer/Servo motor to Motion Detector
 void setup()
@@ -69,7 +69,7 @@
   Serial.println(Degrees);
   ServoSetting =Degrees;
   myservo.write(ServoSetting); // sets the servo position according to the scaled value
-  delay(50); //delay a second
+  delay(50); //delay a bit
 }


Level mode status bugfix

Level mode status bugfix

--- KISS_OSD/Protocol.ino
+++ KISS_OSD/Protocol.ino
@@ -291,7 +291,7 @@
         #endif

         current_armed = serialBuf[16 + STARTCOUNT];
-        if(serialBuf[65 + STARTCOUNT] > 0) current_armed = serialBuf[65 + STARTCOUNT];
+        if(serialBuf[65 + STARTCOUNT] > 1) current_armed = serialBuf[65 + STARTCOUNT];
         if (current_armed < 0) return false;

         ArmDisarmEvents();


style

style

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -340,7 +340,7 @@
 void handle_actuate() {
   Serial.println("serving page at /actuate");
   String toSend = pageTop;
-  toSend += ": setting actuator";
+  toSend += ": Setting Actuator";
   toSend += pageTop2;

   boolean newState = false;


Some small optimisations

Some small optimisations

--- MatrixEffect/MatrixEffect.ino
+++ MatrixEffect/MatrixEffect.ino
@@ -73,28 +73,24 @@
   for(uint8_t x=0; x<COLS; ++x){
     //first row -> turn off the off pixels after propagation of colour
     if(!onPixels[0][x]){
-      new_colors[xy2i(x,0)][_G] = 0;
-      new_colors[xy2i(x,0)][_R] = 0;
-      new_colors[xy2i(x,0)][_B] = 0;
+      new_colors[xy2i(x,0)] = CRGB::Black;
     }
   }
 }

 void setup(){
+  // Delay in case the LEDs draw a lot of current and kill the power supply
   delay(1000);
+  // Let the controller know we're using WS2801 leds, and give a pointer to the current colour array
   LEDS.addLeds<WS2801, RGB>(leds, NUM_LEDS);
-  LEDS.setBrightness(64);
+  // Limit the brightness somewhat (scale is 0-255)
+  LEDS.setBrightness(127);

+  // Initialise the leds to black (off)
   for(uint8_t i=0; i<NUM_LEDS; ++i){
     leds[i] = CRGB::Black;
   }
   LEDS.show();
-
-  // Initialise pixel seeds on first row
-  for(uint8_t x=0; x<COLS; ++x){
-    onPixels[0][x] = (random(0,10)>5);
-  }
-  sendColors();
 }

 unsigned long lastLoopTime = 0;


central board updated

central board updated

--- arduino/central_board/src/cboard.ino
+++ arduino/central_board/src/cboard.ino
@@ -14,12 +14,12 @@

 /* #################  1Wire                                                   */
-
-#define TEMP_PUBLISH_DELAY 20000
+// ar =[]; "1021715B020800AF".split(//).each_slice(2) { |e| ar+= [e.join] }; ar.map{ |e| "0x" + e }.join(', ')
+#define TEMP_PUBLISH_DELAY 40000
 uint32_t last_temp_read = 0;

-#define TEMPERATURE_PRECISION  9
-#define TEMP_MAX_FLOAT_LENGTH  5
+#define TEMPERATURE_PRECISION   9
+#define TEMP_MAX_FLOAT_LENGTH   5
 #define TEMP_SENSOR_NAME_LENGTH 3

 const uint8_t one_wire_pin_1 = 22;
@@ -42,15 +42,17 @@
 // DeviceAddress  room_low = { 0x10, 0x13, 0xB0, 0x5B, 0x02, 0x08, 0x00, 0xC3 },
 //               room_high = { 0x10, 0x57, 0x87, 0x5B, 0x02, 0x08, 0x00, 0xBF };

-TempSensor room_low  = { room_temp, { 0x10, 0x13, 0xB0, 0x5B, 0x02, 0x08, 0x00, 0xC3 }, "RL" };
+TempSensor room_low  = { room_temp, { 0x10, 0x13, 0xB0, 0x5B, 0x02, 0x08, 0x00, 0xC3 }, "RL" }; // !!! name can't be longer than TEMP_SENSOR_NAME_LENGTH - 1
 TempSensor room_high = { room_temp, { 0x10, 0x57, 0x87, 0x5B, 0x02, 0x08, 0x00, 0xBF }, "RH" };

-DeviceAddress  out1, out2;
-
-TempSensor temp_sensors[] = { room_low, room_high };
-
-// DeviceAddress  out1 = { 0x10, 0x13, 0xB0, 0x5B, 0x02, 0x08, 0x00, 0xC3 },
-//                out2 = { 0x10, 0x57, 0x87, 0x5B, 0x02, 0x08, 0x00, 0xBF };
+TempSensor out_1  = { outside_temp, { 0x10, 0x21, 0x71, 0x5B, 0x02, 0x08, 0x00, 0xAF }, "O1" };
+TempSensor out_2  = { outside_temp, { 0x10, 0x2E, 0xA4, 0x5B, 0x02, 0x08, 0x00, 0x07 }, "O2" };
+TempSensor chulan = { outside_temp, { 0x10, 0xB8, 0x9D, 0x5B, 0x02, 0x08, 0x00, 0x73 }, "CH" };
+
+// DeviceAddress  out1, out2, out3;
+
+TempSensor temp_sensors[] = { room_low, room_high, out_1, out_2, chulan };
+

 void setupTempSensors() {
   room_temp.begin();
@@ -65,8 +67,19 @@
   // if (!room_temp.getAddress(room_high, 1)) aSerial.l(Level::v).println("Unable to find address for Device 1");
   // printAddress(room_high);

-  room_temp.setResolution(room_low.address,  TEMPERATURE_PRECISION);
-  room_temp.setResolution(room_high.address, TEMPERATURE_PRECISION);
+  // if (!outside_temp.getAddress(out1, 0)) aSerial.l(Level::v).println("Unable to find address for Device 0");
+  // printAddress(out1);
+
+  // if (!outside_temp.getAddress(out2, 1)) aSerial.l(Level::v).println("Unable to find address for Device 1");
+  // printAddress(out2);
+
+  // if (!outside_temp.getAddress(out3, 2)) aSerial.l(Level::v).println("Unable to find address for Device 2");
+  // printAddress(out3);
+
+  for (int i=0; i<SIZE(temp_sensors); i++) {
+    temp_sensors[i].bus.setResolution( temp_sensors[i].address,  TEMPERATURE_PRECISION);
+  }
+
 }

 // function to print a device address
@@ -76,6 +89,7 @@
     if (deviceAddress[i] < 16) aSerial.l(Level::v).p("0");
     aSerial.l(Level::v).p(deviceAddress[i], HEX);
   }
+  aSerial.l(Level::v).pln("");
 }

 // function to print the temperature for a device
@@ -83,23 +97,16 @@
   return bus.getTempC(deviceAddress);
 }

-// // function to print a device's resolution
-// void printResolution(DeviceAddress deviceAddress)
-// {
-//   Serial.print("Resolution: ");
-//   Serial.print(sensors.getResolution(deviceAddress));
-//   Serial.println();
-// }
-
-// // main function to print information about a device
-// void printData(DeviceAddress deviceAddress)
-// {
-//   Serial.print("Device Address: ");
-//   printAddress(deviceAddress);
-//   Serial.print(" ");
-//   printTemperature(deviceAddress);
-//   Serial.println();
-// }
+void tempSensorsLoop() {
+  if(millis() - last_temp_read > TEMP_PUBLISH_DELAY) {
+    room_temp.requestTemperatures();
+    outside_temp.requestTemperatures();
+
+    publishTempSensors();
+
+    last_temp_read = millis();
+  }
+}

 /* #################  Ethernet                                                */
@@ -188,7 +195,7 @@
 void publishTemp(int16_t temp_index) {
   aSerial.l(Level::vvvv).p("publishTemp: ");

-  char topic_plus_sensor_name[ strlen(MQTT_TEMP_TOPIC "XX") ] = "";
+  char topic_plus_sensor_name[ strlen(MQTT_TEMP_TOPIC) + TEMP_SENSOR_NAME_LENGTH ] = "";
   char float_to_char_buffer[TEMP_MAX_FLOAT_LENGTH] = ""; // eg 25.9

   TempSensor t_sensor = temp_sensors[temp_index];
@@ -210,6 +217,12 @@

   client.publish(topic_plus_sensor_name, float_to_char_buffer);
   delay(20);
+}
+
+void publishTempSensors() {
+  for (int i=0; i<SIZE(temp_sensors); i++) {
+    publishTemp( i );
+  }
 }

 bool equalsToPinsTopic(char* recieved_topic) {
@@ -319,7 +332,7 @@
 void setup(void) {
   Serial.begin(9600);
   aSerial.setPrinter(Serial);
-  aSerial.setFilter(Level::vvvv);
+  aSerial.setFilter(Level::vvv);

   aSerial.l(Level::v).pln("Setup ...");

@@ -338,17 +351,5 @@

 void loop() {
   mqttLoop();
-
-  if(millis() - last_temp_read > TEMP_PUBLISH_DELAY) {
-    room_temp.requestTemperatures();
-
-    float temp = getTemperature(room_temp, room_low.address);
-
-    if( temp == DEVICE_DISCONNECTED_C ) aSerial.l(Level::v).p("ERROR: Temp sensor error").pln(temp);
-
-    publishTemp(0);
-
-    aSerial.l(Level::v).p(room_low.name).pln(temp);
-    last_temp_read = millis();
-  }
-}
+  tempSensorsLoop();
+}


stairs: serial speed is a constant

stairs: serial speed is a constant

--- stairs/src/main.ino
+++ stairs/src/main.ino
@@ -11,6 +11,8 @@

 #define LIGHT_ON "ON"
 #define LIGHT_OFF "OFF"
+
+#define SERIAL_SPEED 115200

 // Digital IO pin where the LED strip is connected.
 // Pin 4 is GPIO 2.
@@ -241,7 +243,7 @@

 // Initial setup, called once on boot.
 void setup() {
-    Serial.begin(115200);
+    Serial.begin(SERIAL_SPEED);

     FastLED.addLeds<NEOPIXEL, PIN_LED>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);


changed pin number back to 13

changed pin number back to 13

--- examples/Demo/Demo.ino
+++ examples/Demo/Demo.ino
@@ -1,6 +1,5 @@
 #include <IRremote.h>
 #include <IRremoteTools.h>
-#include <Svante.h>
 /*
 *  Demo for TinkerKitIRremote
 *  Make sure you are using TinkerKit remote,
@@ -17,7 +16,7 @@
 *  etc etc
 *
 */
-const int RECV_PIN = DP0;  //Define the receiver pin
+const int RECV_PIN = 13;  //Define the receiver pin
 const unsigned long TIMER_MAX=200;  //Timeout for when no repeat frame is received

 boolean pressed=false;


Tmeter: add ZXCT1009 current sense monitor.

--- microcontrollers/arduino-mega2560/mega-tmeter/mega-tmeter.ino
+++ microcontrollers/arduino-mega2560/mega-tmeter/mega-tmeter.ino
@@ -4,11 +4,13 @@
 unsigned gate_output = 0;       // control voltage to the Gate pin of transistor
 unsigned gate_input;            // measured voltage of the Gate pin
 unsigned drain_input;           // measured voltage of the Drain pin
+unsigned drain_current_input;   // measured current of the Drain pin
 unsigned power5_input;          // measured voltage of +5V power source
 unsigned power15_input;         // measured voltage of +15V power source

 unsigned gate_mv;               // millivolts at the Gate pin
 unsigned drain_mv;              // millivolts at the Drain pin
+unsigned long drain_uamp;       // microamperes at the Drain pin
 unsigned power5_mv;             // +5V power source in millivolts
 unsigned power15_mv;            // +15V power source in millivolts

@@ -33,6 +35,7 @@
 #define DRAIN_MULT      (((33 + 10) / 10.0) * CALIBRATE_DRAIN)      // resistors 33k and 10k
 #define POWER5_MULT     (((10 + 10) / 10.0) * CALIBRATE_POWER5)     // resistors 10k and 10k
 #define POWER15_MULT    (((33 + 10) / 10.0) * CALIBRATE_POWER15)    // resistors 33k and 10k
+#define DR_CURRENT_MULT (100000.0 / 220 / 51)                       // resistors 51 and 220

 /*
  * Read a character from the serial port.
@@ -74,6 +77,15 @@
 }

 /*
+ * Print milliamperes.
+ */
+void print_uamp(int uamp)
+{
+    Serial.print(uamp / 1000.0, 2);
+    Serial.write("mA");
+}
+
+/*
  * Measure gate voltage.
  * Repeat until the value is stable for 3 attempts.
  */
@@ -104,7 +116,7 @@
  * Measure drain voltage.
  * Repeat until the value is stable for 3 attempts.
  */
-void measure_drain()
+void measure_drain_voltage()
 {
     delay(1);
     drain_input = analogRead(A1);
@@ -123,6 +135,29 @@

         // The result is stable.
         drain_mv = drain_input * ((5000.0 / 1024) * DRAIN_MULT);
+        return;
+    }
+}
+
+void measure_drain_current()
+{
+    delay(1);
+    drain_current_input = analogRead(A4);
+    for (;;) {
+        unsigned attempt1 = drain_current_input;
+        delay(1);
+        drain_current_input = analogRead(A4);
+        if (attempt1 != drain_current_input)
+            continue;
+
+        unsigned attempt2 = drain_current_input;
+        delay(1);
+        drain_current_input = analogRead(A4);
+        if (attempt2 != drain_current_input)
+            continue;
+
+        // The result is stable.
+        drain_uamp = drain_current_input * ((5000.0 / 1024) * DR_CURRENT_MULT);
         return;
     }
 }
@@ -202,7 +237,7 @@
     Serial.print(gate_input);
     Serial.write(")");

-    Serial.write("\r\nDrain input: ");
+    Serial.write("\r\nDrain voltage: ");
     if (power15_mv > 5000) {
         print_mv(drain_mv);
         Serial.write(" (");
@@ -211,6 +246,12 @@
     } else {
         Serial.write("No power!");
     }
+
+    Serial.write("\r\nDrain current: ");
+    print_uamp(drain_uamp);
+    Serial.write(" (");
+    Serial.print(drain_current_input);
+    Serial.write(")");

     Serial.write("\r\n  Power +5V: ");
     print_mv(power5_mv);
@@ -256,7 +297,7 @@
         Serial.write(" ");
         Serial.print(((int)gate_mv - 5000) / 1000.0, 3);
         Serial.write("  ");
-        Serial.print((power15_mv - drain_mv) / 220.0, 3);
+        Serial.print(drain_uamp / 1000.0, 3);
         Serial.write("\r\n");

         // Stop when last three values are same.
@@ -331,15 +372,17 @@
     // Configure pins.
     // D2 - gate output
     // A0 - gate input
-    // A1 - drain input with divisor 1:4.3
+    // A1 - drain voltage input with divisor 1:4.3
     // A2 - +5V input with divisor 1:2
     // A3 - +15V input with divisor 1:4.3
+    // A4 - drain current input via ZXCT1009 current sense monitor
     //
     pinMode(gate_output_pin, OUTPUT);
     pinMode(A0, INPUT);
     pinMode(A1, INPUT);
     pinMode(A2, INPUT);
     pinMode(A3, INPUT);
+    pinMode(A4, INPUT);

     // Configure timer 3 prescale factor as 1:1.
     // Set bits CS32,CS31,CS30 to 0b001.


Changed pulse time to 50ms to get better performance at micro:bit end

--- arduino/pulse_stretcher/pulse_stretcher.ino
+++ arduino/pulse_stretcher/pulse_stretcher.ino
@@ -5,9 +5,9 @@
  * thus using it as an input device.
  */

-#define TRIGGER   3 // PB3
+#define TRIGGER   0 // PB0
 #define HOLD      4 // PB4
-#define ONTIME_MS 20
+#define ONTIME_MS 50

 void setup()
 {


added new parallel test

added new parallel test

--- proj/parallel_out_test_2/parallel_out_test_2.ino
+++ proj/parallel_out_test_2/parallel_out_test_2.ino
@@ -46,11 +46,27 @@
 void loop() {

-  for (uint8_t ss = 0; ss < NUM_STRIPS; ss++) {
-    fill_solid(&(leds[ss*NUM_LED]), NUM_LED, CHSV(2*ss*16, 255, 200));
+//  for (uint8_t ss = 0; ss < NUM_STRIPS; ss++) {
+//    fill_solid(&(leds[ss*NUM_LED]), NUM_LED, CHSV(2*ss*16, 192, 255));
+//  }
+
+  static uint8_t hue = 0;
+  for (int i = 0; i < NUM_STRIPS; i++) {
+    for (int j = 0; j < NUM_LED; j++) {
+      leds[(i * NUM_LED) + j] = CHSV((32 * i) + hue + j, 192, 255);
+    }
   }
+
+  // Set the first n leds on each strip to show which strip it is
+  for (int i = 0; i < NUM_STRIPS; i++) {
+    for (int j = 0; j <= i; j++) {
+      leds[(i * NUM_LED) + j] = CRGB::Red;
+    }
+  }
+
+  hue++;

   //LEDS.setBrightness(32);
   LEDS.show();
-  LEDS.delay(100);
+  LEDS.delay(10);
 }


fine tuning volume control

fine tuning volume control

--- arduino_signal/arduino_signal.ino
+++ arduino_signal/arduino_signal.ino
@@ -38,29 +38,29 @@
       case 121:
       Serial.write('3');
       SendVolUpCode();
+      delay(5);
+      SendVolUpCode();
       delay(3);
       SendVolUpCode();
-      delay(2);
+      delay(3);
       SendVolUpCode();
-      delay(2);
+      delay(3);
       SendVolUpCode();
-      delay(2);
-      SendVolUpCode();
-      delay(2);
+      delay(3);
       SendVolUpCode();
       break;
       case 122:
       Serial.write('4');
       SendVolDownCode();
+      delay(5);
+      SendVolDownCode();
       delay(3);
       SendVolDownCode();
-      delay(2);
+      delay(3);
       SendVolDownCode();
-      delay(2);
+      delay(3);
       SendVolDownCode();
-      delay(2);
-      SendVolDownCode();
-      delay(2);
+      delay(3);
       SendVolDownCode();
       break;
       case 123:


Update buggy.ino

Update buggy.ino

minor changes

--- esp_mikroe_buggy/buggy.ino
+++ esp_mikroe_buggy/buggy.ino
@@ -46,9 +46,9 @@
  */
 void moveBuggy(int direction, int throttle)
 {
-  int movingForwart = (throttle > 0);
+  int movingForward = (throttle > 0);

-  if(!movingForwart)
+  if(!movingForward)
     throttle = - throttle; // we should go in reverse -> flip the sign
   if(throttle < THROTTLE_THRESHOLD)
   {
@@ -71,7 +71,7 @@
   Serial.println(m + direction + " t " + throttle + "\nL " + leftPWM + " R " + rightPWM);

   // Move
-  if(movingForwart)
+  if(movingForward)
   {
     analogWrite(D1, 0);
     analogWrite(D2, leftPWM);