We should return LACK_OK or a NACK will be send...

--- src/Full_decoder/Full_decoder.ino
+++ src/Full_decoder/Full_decoder.ino
@@ -235,12 +235,16 @@
         return LNCV_LACK_OK;
       } else if (lncvAddress == 1024) {
         lncvValue = freeRam();
+        return LNCV_LACK_OK;
       } else if (lncvAddress == 1025) {
         lncvValue = __bss_start;
+        return LNCV_LACK_OK;
       } else if (lncvAddress == 1026) {
         lncvValue = __bss_end;
+        return LNCV_LACK_OK;
       } else if (lncvAddress == 1027) {
         lncvValue = SP;
+        return LNCV_LACK_OK;
       } else if ((lncvAddress > 1027) && (lncvAddress < 1033)){
         LnBufStats* stats = LocoNet.getStats();
         switch (lncvAddress) {
@@ -259,6 +263,7 @@
           case 1032:
           lncvValue = stats->Collisions;
         }
+        return LNCV_LACK_OK;
       } else {
         // Invalid LNCV address, request a NAXK
         return LNCV_LACK_ERROR_UNSUPPORTED;


Implemented reading the voltage on one of the pins

--- src/Full_decoder/Full_decoder.ino
+++ src/Full_decoder/Full_decoder.ino
@@ -70,6 +70,8 @@
 byte dsdata[9];

 #define LOCONET_TX_PIN 5
+
+#define POWER_VOLTAGE_PIN A2

 extern int __bss_start, __bss_end;

@@ -103,6 +105,12 @@
   //// default is 12 bit resolution, 750 ms conversion time
   return raw; // To be devided by 16;
 }
+
+uint16_t readPowerVoltage() {
+  uint16_t adcValue = analogRead(POWER_VOLTAGE_PIN);
+  return adcValue * 15.3117207;
+}
+
 void reportSlot(uint16_t slot, uint16_t state) {
   DEBUG("Reporting slot ");
   DEBUG(slot);
@@ -235,6 +243,11 @@
   pca.begin();
   pca.setPWMFreq(70);

+#ifdef POWER_VOLTAGE_PIN
+  pinMode(POWER_VOLTAGE_PIN, INPUT);
+  Serial.print("Power voltage in mV: ");
+  Serial.println(readPowerVoltage());
+#endif
 }

 void loop() {
@@ -396,6 +409,9 @@
           lncvValue = stats->Collisions;
         }
         return LNCV_LACK_OK;
+      } else if (lncvAddress == 1034) {
+          lncvValue = readPowerVoltage();
+          return LNCV_LACK_OK;
       } else {
         // Invalid LNCV address, request a NAXK
         return LNCV_LACK_ERROR_UNSUPPORTED;


Use updateIMU directly, avoid comparing floats

--- src/main/main.ino
+++ src/main/main.ino
@@ -55,7 +55,7 @@
 	float accY = imu.a.y / gScale;
 	float accZ = imu.a.z / gScale;

-	ahrs.update(gyroX, gyroY, gyroZ, accX, accY, accZ, 0.0f, 0.0f, 0.0f);
+	ahrs.updateIMU(gyroX, gyroY, gyroZ, accX, accY, accZ);
 }

 char report[80];


Removing test motion code from last commit.

--- firmware/LaserBox/LaserBox.ino
+++ firmware/LaserBox/LaserBox.ino
@@ -42,7 +42,7 @@
   */
   // handle any debug events pending
   debugHandleEvents();
-/*
+
   char gestureType[6];  // fits RIGHT<null>, the longest string that can be returned
   byte *patternData;
   byte patternLength;
@@ -56,11 +56,6 @@
     patternRun(patternData, patternLength);
     free(patternData);
   }
-  */
-  if(digitalRead(50)) {
-    // motion!
-
-    fogPulse(8, 1, 500, 500);
-  }
+
   delay(250);
 }


some nicenesses with real stars, however, azimuth still gets error

--- arduino_st/arduino_st.ino
+++ arduino_st/arduino_st.ino
@@ -5,7 +5,7 @@
 #endif

 #define LCD_BACK_LIGHT_SENS_DEGREE (0.15) //sensevity of when to turn on backlight
-#define SENSOR_6050_FIFO_HZ 10 //my update to motion_api, should be defined prior include
+#define SENSOR_6050_FIFO_HZ 20 //my update to motion_api, should be defined prior include
 #define USE_LCD
 #define INTERRUPT_PIN 2  // use pin 2 on Arduino Uno & most boards
 #define READINGS_AMOUNT_AVR static_cast<uint8_t>((SENSOR_6050_FIFO_HZ) / 10 + 3) //how many reading to use to calc avr
@@ -20,6 +20,7 @@
 #ifdef USE_LCD
 #include "LiquidCrystal.h"
 LiquidCrystal lcd(4, 5, 10, 11, 12, 13);
+#define MAX_BRIGHTNESS 50
 #define backLightPin 3
 #endif

@@ -109,7 +110,7 @@
 {
 #ifdef USE_LCD
     pinMode(backLightPin, OUTPUT);
-    analogWrite(backLightPin, 200);
+    analogWrite(backLightPin, MAX_BRIGHTNESS);
     lcd.begin(16, 2);
     lcd.clear();
     lcd.print(F("Init,fifo: "));
@@ -202,12 +203,23 @@
                 mpu.getFIFOBytes(fifoBuffer, packetSize);
                 fifoCount -= packetSize;
                 mpu.dmpGetQuaternion(msg.message.value.vals.current_quat, fifoBuffer);
-                mpu.dmpGetQuaternion(&q, fifoBuffer); q.normalize();
-                mpu.dmpGetGravity(&gravity, &q); gravity.normalize();
+                mpu.dmpGetQuaternion(&q, fifoBuffer);
+                q.normalize();
+
+                mpu.dmpGetGravity(&gravity, &q);
+                gravity.normalize();

                 //https://www.reddit.com/r/Astronomy/comments/3udenf/quaternion_matrix_or_euler_angles_conversion_to/
-                el.push_back_lpf(removeRotRad<decltype(el0)>(atan(gravity.x / sqrt(sqrf(gravity.y) + sqrf(gravity.z)))));
-                az.push_back_lpf(getAz(-2.f * atan2(q.z, q.w)));
+                auto elt = removeRotRad<decltype(el0)>(atan(gravity.x / sqrt(sqrf(gravity.y) + sqrf(gravity.z))));
+                el.push_back(elt);
+
+                decltype(az0) azt;
+
+                // if (elt > radians(45))
+                azt = -2.f * atan2(q.z, q.w);
+                // else
+                // azt = atan2(2 * (q.x* q.y -  q.w * q.z), 2 * (q.w * q.w +  q.x * q.x) - 1);
+                az.push_back(getAz(azt));
             }
             while (fifoCount > 0);
         }
@@ -225,6 +237,7 @@
     static bool once = true;
     static elapsedMillis timeElapsed;
     static elapsedMillis light;
+    static elapsedMillis hadUsb;

     static my_helpers::Circular<decltype(az0) , READINGS_AMOUNT_AVR> az(0);
     static my_helpers::Circular<decltype(el0) , READINGS_AMOUNT_AVR> el(0);
@@ -233,50 +246,52 @@
     // if programming failed, don't try to do anything
     if (!dmpReady) return;

-    if (sensorDataReady)
+    while (sensorDataReady)
         readSensor(az, el);

     if (once)
     {
         //let it stabilize for 5seconds
-        if (timeElapsed > 2000 + 1000 * (100 / SENSOR_6050_FIFO_HZ ))
+        if (timeElapsed > 10000 + 1000 * (200 / SENSOR_6050_FIFO_HZ ))
         {
             //after pressing "reset" current position will be used as zero
             az0 = az;
             el0 = el;
-            once = false;
-            timeElapsed = 0;
             az.clear(az0);
             el.clear(el0);
+            timeElapsed = 0;
             light = 0;
+            hadUsb = 60000;
+            interrupts();
+            once = false;
         }
     }
     else
     {
+        interrupts();
         while (Serial.available() >= 3 + 9)
         {
-
+            interrupts();
             if (Serial.find(MESSAGE_HDR))
             {
                 //computer makes S/R request, and arduino just responds
                 Serial.readBytes(msg.buffer, 9);
                 {
-                    my_helpers::no_interrupts lock;
                     if (msg.message.Command == 'S') //set
                     {
                         float azm = 0;
                         float elm = 0;

                         ard_st::readAzEl(msg.message.value, &azm, &elm);
-
+                        my_helpers::no_interrupts dumb;
                         az0 = az - azm;
                         el0 = el - elm;
-                        az.push_back(azm);
-                        el.push_back(elm);
+                        az.clear(azm);
+                        el.clear(elm);
                         continue;
                     }
-                    if (msg.message.Command == 'R') //read, other part of message must be present but ignored
+                    if (msg.message.Command == 'R' && light > 250) //read, other part of message must be present but ignored
                     {
                         ard_st::packAzEl(msg.message.value, getAz(az - az0), el - el0);
                         Serial.write(msg.message.value.buffer, sizeof(msg.message.value.buffer));
@@ -285,38 +300,53 @@
                     }
                 }
             }
-        }
-
+            hadUsb = 0;
+            interrupts();
+        }
+
+        bool static aw_once = true;
         if (abs(az.lastDelta()) > lightSens || abs(el.lastDelta()) > lightSens)
         {
             light = 0;
 #ifdef USE_LCD
-            analogWrite(backLightPin, 100);
-#endif
-        }
-
-        if (light > 30000)
+            analogWrite(backLightPin, MAX_BRIGHTNESS);
+#endif
+            aw_once = true;
+        }
+        int lig = light;
+        interrupts(); //those asholes do not do sei() after checking timer!!
+
+        if (lig > 30000 && hadUsb > 60000)
         {
 #ifdef USE_LCD
             digitalWrite(backLightPin, LOW);
 #endif
-            set_sleep_mode(SLEEP_MODE_IDLE); //only idle seems works by interrupt from sensor
-            sleep_enable();
-            sleep_mode();
-            sleep_disable();
+            interrupts();
+            if (!sensorDataReady)
+            {
+                set_sleep_mode(SLEEP_MODE_IDLE); //only idle seems works by interrupt from sensor
+                sleep_enable();
+                sleep_mode();
+                sleep_disable();
+            }
         }
         else
         {
 #ifdef USE_LCD
-            if (light > 7000) analogWrite(backLightPin, 10);
-#endif
-
-            if (timeElapsed > 250)
+            if (lig > 7000 && aw_once)
+            {
+                analogWrite(backLightPin, 10);
+                aw_once = false;
+            }
+#endif
+
+            if (timeElapsed > 450)
             {
                 auto t = mpu.getTemperature() / 340. + +36.53; //celsius
                 printValues(getAz(az - az0), el - el0, t);
                 timeElapsed = 0;
             }
         }
+        interrupts();
     }
 }


remove trivial functions like servo, adc

They are developed on separate branches.

In fact there is one critical issue comes from Servo lib:
Servo::attach() enables a timer, it may affect many other
unrelated functions, such as SPIFFS.exist?
So remove it on master branch decidedly...

--- src/neurite.ino
+++ src/neurite.ino
@@ -43,7 +43,6 @@
 #include <Ticker.h>
 #include <ArduinoJson.h>
 #include "FS.h"
-#include <Servo.h>

 extern "C" {
 #include "osapi.h"
@@ -101,7 +100,6 @@
 #ifdef NEURITE_ENABLE_WIFIMULTI
 ESP8266WiFiMulti WiFiMulti;
 #endif
-Ticker ticker_worker;
 Ticker ticker_led;
 Ticker ticker_cmd;
 Ticker ticker_mon;
@@ -459,17 +457,6 @@
 	}
 }

-/* FIXME is this necessary? */
-static void ticker_worker_task(void)
-{
-#if 0
-	struct neurite_data_s *nd = &g_nd;
-	char tmp[64];
-	sprintf(tmp, "%s time: %d ms", nd->uid, millis());
-	mqtt_cli.publish(nd->cfg.topic_to, tmp);
-#endif
-}
-
 static void button_release_handler(struct neurite_data_s *nd, int dts)
 {
 	log_dbg("button pressed for %d ms\n\r", dts);
@@ -535,15 +522,6 @@
 	stop_ticker_mon(nd);
 	ticker_mon.attach_ms(100, ticker_monitor_task, nd);
 }
-inline void stop_ticker_worker(struct neurite_data_s *nd)
-{
-	ticker_worker.detach();
-}
-inline void start_ticker_worker(struct neurite_data_s *nd)
-{
-	stop_ticker_worker(nd);
-	ticker_worker.attach(1, ticker_worker_task);
-}
 inline void stop_ticker_but(struct neurite_data_s *nd)
 {
 	ticker_but.detach();
@@ -619,7 +597,6 @@
 	log_info("rebooting...\n\r");
 	stop_ticker_but(nd);
 	stop_ticker_mon(nd);
-	stop_ticker_worker(nd);
 	stop_ticker_led(nd);
 	stop_ticker_cmd(nd);
 	ESP.restart();
@@ -1098,7 +1075,6 @@
 			mqtt_cli.publish(nd->cfg.topic_to, (const char *)payload_buf);

 			start_ticker_led_breath(nd);
-			//start_ticker_worker(nd);
 			start_ticker_mon(nd);
 			CMD_SERIAL.println(FPSTR(STR_READY));
 			log_dbg("heap free: %d\n\r", ESP.getFreeHeap());
@@ -1202,7 +1178,6 @@
 #ifdef NEURITE_ENABLE_USER
 #define USER_LOOP_INTERVAL 1000

-Servo myservo;
 static bool b_user_loop_run = true;

 enum {
@@ -1220,19 +1195,6 @@
 void neurite_user_worker(void)
 {
 	/* add user stuff here */
-#if 0
-	struct neurite_data_s *nd = &g_nd;
-	static int adc_prev = 0;
-	int adc = analogRead(A0);
-	if (abs(adc - adc_prev) > 50) {
-		adc_prev = adc;
-		char buf[32];
-		__bzero(buf, sizeof(buf));
-		sprintf(buf, "adc: %d", analogRead(A0));
-		if (nd->mqtt_connected)
-			mqtt_cli.publish(nd->cfg.topic_to, (const char *)buf);
-	}
-#endif
 }

 void neurite_user_loop(void)
@@ -1261,7 +1223,6 @@
 void neurite_user_hold(void)
 {
 	log_dbg("\n\r");
-	myservo.detach();
 	update_user_state(USER_ST_0);
 }

@@ -1271,7 +1232,6 @@
 	log_dbg("\n\r");
 	pinMode(14, OUTPUT);
 	analogWrite(14, 1023);
-	myservo.attach(13);
 }

 /* called once on mqtt message received */
@@ -1321,13 +1281,6 @@
 			log_dbg("hit light, msg(value): %s(%d)\n\r", token, val);
 			analogWrite(14, val);
 		}
-	} else if (strcmp(token, "servo:") == 0) {
-		token = strtok(NULL, "\0");
-		if (token) {
-			int val = atoi(token);
-			log_dbg("hit servo, msg(value): %s(%d)\n\r", token, val);
-			myservo.write(val);
-		}
 	} else {
 	}
 	free(msg);


fixing misplaced ifdef

fixing misplaced ifdef

--- examples/CaroloCar/CaroloCar.ino
+++ examples/CaroloCar/CaroloCar.ino
@@ -209,8 +209,8 @@
 }

 void transmitSensorData() {
+  if (millis() - previousTransmission > COM_FREQ) {
 #ifdef DEBUG //if we are in debug mode, use plain text with netstrings
-  if (millis() - previousTransmission > COM_FREQ) {
     String out;
     out = "US1-";
     out += frontSonar.getDistance();
@@ -232,29 +232,29 @@
     out += gyro.getAngularDisplacement();
     Serial.println(encodedNetstring(out));
 #else //use protobuffer
-  Sensors message;
-  message.usFront = frontSonar.getDistance();
-  message.usRear = rearSonar.getDistance();
-  message.irFrontRight = middleFrontIR.getDistance();
-  message.irRearRight = middleRearIR.getDistance();
-  message.irBackLeft = rearLeftIR.getDistance();
-  message.irBackRight = rearRightIR.getDistance();
-  message.wheelFrontLeft = encoderLeft.getDistance();
-  message.wheelRearRight = encoderRight.getDistance();
-  pb_ostream_t outstream = pb_ostream_from_buffer(enc_buffer, sizeof(enc_buffer));
-  status = pb_encode(&outstream, Sensors_fields, &message);
-  message_length = outstream.bytes_written;
-  if (status) { //if valid send the protobytes
-    for (int i = 0; i < message_length; i++) {
-      if (enc_buffer[i] == flagEND || enc_buffer[i] == flagESC) {
-        Serial.write(flagESC);
-        Serial.write(enc_buffer[i]^varXOR);
-      } else {
-        Serial.write(enc_buffer[i]);
-      }
-    }
-    Serial.write(flagEND);
-  }
+    Sensors message;
+    message.usFront = frontSonar.getDistance();
+    message.usRear = rearSonar.getDistance();
+    message.irFrontRight = middleFrontIR.getDistance();
+    message.irRearRight = middleRearIR.getDistance();
+    message.irBackLeft = rearLeftIR.getDistance();
+    message.irBackRight = rearRightIR.getDistance();
+    message.wheelFrontLeft = encoderLeft.getDistance();
+    message.wheelRearRight = encoderRight.getDistance();
+    pb_ostream_t outstream = pb_ostream_from_buffer(enc_buffer, sizeof(enc_buffer));
+    status = pb_encode(&outstream, Sensors_fields, &message);
+    message_length = outstream.bytes_written;
+    if (status) { //if valid send the protobytes
+      for (int i = 0; i < message_length; i++) {
+        if (enc_buffer[i] == flagEND || enc_buffer[i] == flagESC) {
+          Serial.write(flagESC);
+          Serial.write(enc_buffer[i]^varXOR);
+        } else {
+          Serial.write(enc_buffer[i]);
+        }
+      }
+      Serial.write(flagEND);
+    }
 #endif
     previousTransmission = millis();
   }


Refactor PIR sketch

Refactor PIR sketch

--- ProofOfConceptNesh/PIRSketch.ino
+++ ProofOfConceptNesh/PIRSketch.ino
@@ -11,6 +11,8 @@
 const int  MKR1000_PINPIR1 = 14;               // choose the input pin (for PIR sensor)

+
+int calibrationTime = 30;       //the time we give the sensor to calibrate (10-60 secs according to the datasheet)
 int val = 0;                    // variable for reading the pin status
 long unsigned int lowIn;         //the time when the sensor outputs a low impulse
 long unsigned int pause = 5000;  //the amount of milliseconds the sensor has to be low before we assume all motion has stopped
@@ -44,12 +46,26 @@
    pinMode(MKR1000_LED, OUTPUT);

    pinMode(MKR1000_PINPIR1, INPUT);     // declare sensor as input
+

+  //give the sensor some time to calibrate
+  delay(50);
+  Serial.print("calibrating sensor ");
+    for(int i = 0; i < calibrationTime; i++){
+      Serial.print(".");
+      delay(1000);
+      }
+    Serial.println(" done");
+    Serial.println("SENSOR ACTIVE");
+    delay(50);
+
+    Serial.print("check for the presence of the shield");
   //check for the presence of the shield:
   if (WiFi.status() == WL_NO_SHIELD) {
     // don't continue:
     while (true);
   }
+   Serial.print("Good. this board supports Wifi!");

   // attempt to connect to Wifi network:
   while (status != WL_CONNECTED) {
@@ -158,8 +174,7 @@
 void loop(){
   val = digitalRead(MKR1000_PINPIR1);   // read input value
   if (val == HIGH) {                    // check if the input is HIGH
-    digitalWrite(MKR1000_LED, HIGH);    // turn LED ON
-    //delay(150);
+    digitalWrite(MKR1000_LED, HIGH);    // turn LED ON

     if (lockLow) {
          lockLow = false;               //makes sure we wait for a transition to LOW before any further output is made:
@@ -168,15 +183,14 @@
          Serial.print("motion detected at ");
          Serial.print(duration);
          Serial.println(" sec");
-
+         delay(50);
          azureHttpPost("{deviceId:NeshMKR100Dev1, motion:1,elapsed:"+ duration + "}");
     }

     takeLowTime = true;
   }
   else {
-      digitalWrite(MKR1000_LED, LOW);   // turn LED OFF
-      //delay(150);
+      digitalWrite(MKR1000_LED, LOW);   // turn LED OFF

        if(takeLowTime){
           lowIn = millis();             //save the time of the transition from high to LOW
@@ -191,7 +205,7 @@
            Serial.print("motion ended at ");      //output
            Serial.print(duration);
            Serial.println(" sec");
-
+           delay(50);
           azureHttpPost("{deviceId:NeshMKR100Dev1, motion:0,elapsed:"+ duration + "}");
     }
   }


added amps

added amps

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -1037,7 +1037,7 @@
   } else if(analogSensor == "analog_mains") {
     (*a) = (float) ( emon1.calcIrms(1480) / 10 /*fudge!*/ );
     dbg(analogDBG, "mains reading is ");
-    dbg(analogDBG, (*a)); dbg(analogDBG, "\n");
+    dbg(analogDBG, (*a)); dbg(analogDBG, "A\n");
   } else if(analogSensor == "analog_pressure") {
     int analogValue = analogRead(A0);


changed to start with Fan ON, but does not compile - missing AES256.h and maybe others

--- ExhaustNode/ExhaustNode.ino
+++ ExhaustNode/ExhaustNode.ino
@@ -59,7 +59,7 @@

 #include <SPI.h>

-#include "MakerspaceMQTT.h"
+#include "MakerSpaceMQTT.h"
 #include "Log.h"
 #include "LEDs.h"
 #include "OTA.h"
@@ -104,6 +104,11 @@
 void setup() {
   digitalWrite(RELAY, 0); // Stop the relay from fluttering during pinMode() change.
   pinMode(RELAY, OUTPUT);
+
+  {// Start with the exhaust fan ON, so you don't have to wait for WiFi to turn the fan on
+  machinestate = POWERED;
+  digitalWrite(RELAY, 1);
+  }

   pinMode(LED_GREEN, OUTPUT);
   pinMode(LED_ORANGE, OUTPUT);
@@ -362,7 +367,7 @@
     Log.print(">");

     Log.print(" Button="); Log.print(digitalRead(PUSHBUTTON)  ? "not-pressed" : "PRESSed");
-    Log.print(" Relay="); Log.print(digitalRead(RELAY)  ? "ON" : "off");
+    Log.print(" Relay="); Log.print(digitalRead(RELAY)  ? "ON" : "off"); //
     Log.println(".");

     last_debug = millis();


Call randomSeed before generating each byte in the mac address

--- sketches/Energino/Energino.ino
+++ sketches/Energino/Energino.ino
@@ -144,11 +144,11 @@
   settings.host = HOST;
   settings.port = PORT;
   strcpy (settings.apikey,KEY);
-  randomSeed(analogRead(0));
   settings.mac[0] = 0x90;
   settings.mac[1] = 0xA2;
   settings.mac[2] = 0xDA;
   for (int i = 3; i < 6; i++) {
+    randomSeed(analogRead(0));
     settings.mac[i] = random(0, 255);
   }
 #endif


stupid shit wont compile

stupid shit wont compile

other stuff says not in scope , makes no sense

--- examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino
+++ examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino
@@ -7,47 +7,52 @@
 #define TRIGGER_PIN 0
 const char* modes[] = { "NULL", "STA", "AP", "STA+AP" };

-#define OLED
-
-#include <Wire.h>
-#include <Adafruit_GFX.h>
-#include <Adafruit_SSD1306.h>
-#ifdef OLED
-
-#define SCREEN_WIDTH 128 // OLED display width, in pixels
-#define SCREEN_HEIGHT 32 // OLED display height, in pixels
-
-// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
-#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
-Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
-
-void init_oled(){
-  Wire.begin(SCL,SDA);  // begin(sda, scl) SWAP!
-  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
-  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
-    Serial.println(F("SSD1306 allocation failed"));
-  }
-
-  display.clearDisplay();
-  display.setTextSize(1);             // Normal 1:1 pixepl scale
-  display.setTextColor(WHITE);        // Draw white text
-  display.setCursor(0,0);             // Start at top-left corner
-  display.display();
-}
-#endif
+// // #define MYOLED
+
+// #include <Wire.h>
+// #include <Adafruit_GFX.h>
+// #include <Adafruit_SSD1306.h>
+// #ifdef MYOLED
+
+// #define SCREEN_WIDTH 128 // OLED display width, in pixels
+// #define SCREEN_HEIGHT 32 // OLED display height, in pixels
+
+// // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
+// #define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
+// Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
+
+// void init_oled(){
+//   Wire.begin(SCL,SDA);  // begin(sda, scl) SWAP!
+//   // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
+//   if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
+//     Serial.println(F("SSD1306 allocation failed"));
+//   }
+
+//   display.clearDisplay();
+//   display.setTextSize(1);             // Normal 1:1 pixepl scale
+//   display.setTextColor(WHITE);        // Draw white text
+//   display.setCursor(0,0);             // Start at top-left corner
+//   display.display();
+// }
+
+// void print_oled(String str,uint8_t size){
+//   display.clearDisplay();
+//   display.setTextSize(size);
+//   display.setTextColor(WHITE);
+//   display.setCursor(0,0);
+//   display.println(str);
+//   display.display();
+// }
+// #else
+//   void print_oled(String str,uint8_t size){
+//     (void)str;
+//     (void)size;
+//   }
+// #endif

 void print_oled(String str,uint8_t size){
-  #ifdef OLED
-  display.clearDisplay();
-  display.setTextSize(size);
-  display.setTextColor(WHITE);
-  display.setCursor(0,0);
-  display.println(str);
-  display.display();
-  #else
   (void)str;
   (void)size;
-  #endif
 }

 WiFiManager wm;


Update UbidotsSaveMultiValues.ino

Update UbidotsSaveMultiValues.ino

--- examples/UbidotsSaveMultiValues/UbidotsSaveMultiValues.ino
+++ examples/UbidotsSaveMultiValues/UbidotsSaveMultiValues.ino
@@ -10,15 +10,14 @@
  * Define Constants
  ****************************************/
 // Your GPRS credentials, if any
-#define APN               "Put_the_APN_here"
-#define USER              "Put_the_APN_user_here"
-#define PASS              "Put_the_APN_pwd_here"
-#define TOKEN             "Put_your_Ubidots_token_here"
-#define DEVICE_LABEL      "Put_your_device_API_label"
-#define VARIABLE_LABEL_1  "temperature"
-#define VARIABLE_LABEL_2  "humidity"
-#define VARIABLE_LABEL_3  "pressure"
-
+const char *APN  =           "Put_the_APN_here"
+const char *USER =           "Put_the_APN_user_here"
+const char *PASS =           "Put_the_APN_pwd_here"
+const char *TOKEN=           "Put_your_Ubidots_token_here"
+const char *DEVICE_LABEL=    "Put_your_device_API_label"
+const char *VARIABLE_LABEL_1="Put_your_variable_API_label_1"
+const char *VARIABLE_LABEL_2="Put_your_variable_API_label_2"
+const char *VARIABLE_LABEL_3="Put_your_variable_API_label_3"

 Ubidots client(TOKEN,APN,USER,PASS);


update.

update.

--- firmware/examples/coapserver.ino
+++ firmware/examples/coapserver.ino
@@ -80,3 +80,10 @@
     delay(1000);
     coap.loop();
 }
+
+/*
+if you change LED, req/res test with coap-client(libcoap), run following.
+coap-client -m get coap://(arduino ip addr)/light
+coap-client -e "1" -m put coap://(arduino ip addr)/light
+coap-client -e "0" -m put coap://(arduino ip addr)/light
+*/


faster frequency control

faster frequency control

--- Oscillator/Oscillator.ino
+++ Oscillator/Oscillator.ino
@@ -22,7 +22,8 @@
 //double dfreq;
 uint_fast16_t dfreq;
 // const double refclk=31372.549;  // =16MHz / 510
-const double refclk=31376.6;      // measured
+//const float refclk=31376.6;      // measured
+const float refclk=23529.412; // =12MHz / 510

 // variables used inside interrupt service declared as voilatile
 volatile uint_fast8_t icnt;              // var inside interrupt
@@ -50,7 +51,7 @@
 //  dfreq_copy = analogRead(0);

   while(1) {
-     if (c4ms > 250) {                 // timer / wait fou a full second
+     if (c4ms > 120) {                 // timer / wait fou a full second
       c4ms=0;
       dfreq = analogRead(0);
 //      dfreq=analogRead(0);             // read Poti on analog pin 0 to adjust output frequency from 0..1023 Hz


Added pins for LED indicators

Added pins for LED indicators

--- ReFilament/ReFilament.ino
+++ ReFilament/ReFilament.ino
@@ -1,7 +1,10 @@
 // Set up global variables
-const byte EXT_PIN = 9;
+const byte EXT_PIN = 11;
 const byte SPL_PIN = 10;
-const byte HTR_PIN = 11;
+const byte HTR_PIN = 9;
+const byte ENBL_PIN = 4;
+const byte HTR_LED = 7;
+const byte HOT_LED = 6;

 // Serial input parameter editing for PID
 boolean input_complete = false;
@@ -68,6 +71,7 @@
   pinMode(EXT_PIN, OUTPUT); // Extrusion Motor
   pinMode(SPL_PIN, OUTPUT); // Spooling Motor
   pinMode(HTR_PIN, OUTPUT); // Heater
+  pinMode(ENBL_PIN, OUTPUT); // Power Supply Enable
   pinMode(clockPin, INPUT);
   pinMode(dataPin, INPUT);

@@ -81,6 +85,9 @@
   digitalWrite(EXT_PIN, LOW);
   digitalWrite(SPL_PIN, LOW);
   digitalWrite(HTR_PIN, LOW);
+  digitalWrite(ENBL_PIN, LOW);
+  delay(6000);
+  digitalWrite(ENBL_PIN, HIGH);

   Serial.begin(9600);
   start_millis = millis();
@@ -101,7 +108,7 @@
   }

   analogWrite(SPL_PIN, 3);
-  analogWrite(EXT_PIN, 0);
+  analogWrite(EXT_PIN, 40);
   delay(10);

   printSerialData();


Correction on serial port.

Correction on serial port.

--- support/BotFirmata/BotFirmata.ino
+++ support/BotFirmata/BotFirmata.ino
@@ -611,7 +611,8 @@
   Firmata.attach(START_SYSEX, sysexCallback);
   Firmata.attach(SYSTEM_RESET, systemResetCallback);

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


Flush the output fully

Flush the output fully

--- camera_box/camera_box.ino
+++ camera_box/camera_box.ino
@@ -100,6 +100,7 @@

   Serial.println("}");

+  Serial.flush();
   delay(1000);

   while (1){


Fix indent

Fix indent

--- examples/Boards_USB_Serial/TI_Stellaris_LaunchPad/TI_Stellaris_LaunchPad.ino
+++ examples/Boards_USB_Serial/TI_Stellaris_LaunchPad/TI_Stellaris_LaunchPad.ino
@@ -69,7 +69,7 @@
 {
   // Debug console
   Serial1.begin(9600);
-
+
   // Blynk will work through Serial
   Serial.begin(9600);
   Blynk.begin(auth, Serial);


Print song number

Print song number

--- ableton-midi-foot-controller.ino
+++ ableton-midi-foot-controller.ino
@@ -584,6 +584,8 @@
     lcd.clear();
     if (song) {
       lcd.print(song);
+      lcd.setCursor(0, 1);
+      lcd.print(selectedSong + (bank * numberOfChannelButtons) + 1);
     }
   }


Output bank and song number

Output bank and song number

--- ableton-midi-foot-controller.ino
+++ ableton-midi-foot-controller.ino
@@ -613,7 +613,10 @@
     if (song) {
       lcd.print(song);
       lcd.setCursor(0, 1);
-      lcd.print(selectedSong + (bank * numberOfChannelButtons) + 1);
+      lcd.print(F("Bank: "));
+      lcd.print(bank + 1);
+      lcd.print(F(" Song: "));
+      lcd.print(selectedSong + 1);
     }
   }


Delete LeoShieldCT1234.ino

Delete LeoShieldCT1234.ino


Bring all state changes into one function

--- timer/timer.ino
+++ timer/timer.ino
@@ -60,12 +60,17 @@
 }

-void change_to_waiting_state() {
-  current_state = STATE_WAITING;
-}
-
-void change_to_mode_state() {
-  Serial.println("FIXME - code up change_to_mode_state");
+void change_to_state(int new_state) {
+  if (new_state == STATE_WAITING) {
+    current_state = STATE_WAITING;
+  } else if (new_state == STATE_RUNNING) {
+    current_state = STATE_RUNNING;
+  } else if (new_state == STATE_PULSING) {
+    current_state = STATE_PULSING;
+  } else if (new_state == STATE_MODE) {
+    Serial.println("FIXME - code up change_to_state(STATE_MODE)");
+    change_to_state(STATE_WAITING);
+  }
 }

 void waiting_state_loop (int button) {
@@ -74,7 +79,7 @@
   if (button == BUTTON_RESTART) {
     return start_countdown_timer();
   } else if ( button == BUTTON_MODE ) {
-    return change_to_mode_state();
+    return change_to_state(STATE_MODE);
   } else if ( button == BUTTON_PLUS ) {
     countdown_duration += ONE_MINUTE;
   } else if ( button == BUTTON_MINUS && countdown_duration >= ONE_MINUTE ) {
@@ -84,7 +89,7 @@

 void start_countdown_timer () {
   countdown_ends = millis() + countdown_duration + 300;
-  current_state = STATE_RUNNING;
+  change_to_state(STATE_RUNNING);
 }

 void running_state_loop (int button) {
@@ -98,15 +103,15 @@
   if ( button == BUTTON_RESTART ) {
     start_countdown_timer();
   } else if ( button == BUTTON_MODE ) {
-    change_to_waiting_state();
+    change_to_state(STATE_WAITING);
   } else if ( button == BUTTON_PLUS ) {
     countdown_ends += ONE_MINUTE;
-    current_state = STATE_RUNNING;
+    change_to_state(STATE_RUNNING);
   } else if ( button == BUTTON_MINUS ) {
     long time_remaining = countdown_ends - millis();
     if ( time_remaining > ONE_MINUTE ) {
       countdown_ends -= ONE_MINUTE;
-      current_state = STATE_RUNNING;
+      change_to_state(STATE_RUNNING);
     }
   }
 }


Added switch to notifications on new notification

--- Sakuya_TiLDA/Sakuya_TiLDA.ino
+++ Sakuya_TiLDA/Sakuya_TiLDA.ino
@@ -30,6 +30,8 @@

 void loop()
 {
+  bool new_notifications = false;
+
   // Process new messages from serial
   while(SERIAL.available())
   {
@@ -44,7 +46,8 @@
     switch(data[0])
     {
       case 'N':
-        process_notification_message(data);
+        if(process_notification_message(data))
+          new_notifications = true;
         break;

       case 'L':
@@ -62,6 +65,15 @@
   // Poll backlight timeout
   backlight_timeout(BACKLIGHT_IDLE_TIMEOUT_MS);

+  // Switch to notifications if there are new ones
+  if(new_notifications)
+  {
+    current_display_notif = notif_list_tail();
+    display = DISPLAY_NOTIFICATIONS;
+    enable_backlight();
+  }
+
+  // Make sure there are notifications before trying to display any
   if((display == DISPLAY_NOTIFICATIONS) && (!current_display_notif))
     display = DISPLAY_IDLE;


Delete DELUX_3D_printer_alert.ino

Delete DELUX_3D_printer_alert.ino

--- AnetA8alert_MLX90614-MQ2-Library/AnetA8alert_MLX90614-MQ2-Library/examples/DELUX_3D_printer_alert/DELUX_3D_printer_alert.ino
+++ AnetA8alert_MLX90614-MQ2-Library/AnetA8alert_MLX90614-MQ2-Library/examples/DELUX_3D_printer_alert/DELUX_3D_printer_alert.ino
@@ -1,137 +0,0 @@
-/*
-
-  This program is made as a help to avoid fire hasards for 3D printers and is used at your own risk.
-
-  Safty:
-  Printer Manufacturers strongly recommend that you do not leave a lit 3D printer unattended, and that is fitted
-  with a smoke detector in umeldbart vicinity. This project is intended to provide further assistance.
-
-  IR thermometer (GY-906), addresses the heatblocken so that it measures the temperature, while the smoke detector (MQ-2) measures possible. smoke.
-
-  How to:
-  Place the IR thermometer (GY-906) so it is pointing at the nozzel
-  Place the MQ-2 at a high on the printer
-  The relay is mountet, on the main, befor the Powersuply and is mountet, as Normaly Closed, so if the power is turned off, the printer does not start automatically again
-
-  Description:
-  As an additional precaution, it is recommended to add a "Heated Bed Power Expansion moduel" so the power to "Heat Bed" bypassing the controller card
-
-  Hookup:
-  MLX90614 Temp Sensor by I2C interface:         A4 (SDA), A5 (SCL) by Limor Fried/Ladyada for Adafruit Industries.
-  MQ-2 Smoke detector:                           A3
-  Relay                                          D10 Take care, your working with main power
-  AlertPin - speaker                             D9
-  AlertPin - piezoelectric speaker               D8
-  All okay - LED+ R220                           D7
-
-
-  by
-  Michel Sommer, OZ1SQT http://markussen-net.dk
-
-*/
-
-#include <Wire.h>
-#include <MLX90614.h>
-
-Adafruit_MLX90614 mlx = Adafruit_MLX90614();
-
-#define OK_PIN 7                 // LED, "all okay"
-#define ALERT_PIN 8              // Piezoelectric speaker, "Alert"
-#define AUDIO_PIN 9              // Speaker
-#define RELAY_PIN 10             // Relay
-#define SMOKE_PIN A3             // MQ2 smokesensor analogpin
-
-#define OK_TONE 250              // Tone, "all okay"
-#define LOW_TONE 500             // Tone, "low temp"
-#define ALERT_TONE 1000          // Tone, "high temp"
-
-#define THRESHOLD_LOW 160        // threshold level 160
-#define THRESHOLD_HIGH 310       // threshold level 310
-#define THRESHOLD_SMOKE_LOW 250  // threshold level 250 LOW
-#define THRESHOLD_SMOKE_HIGH 400 // threshold level 400 HIGH
-
-#define PulseTime 1              // Delay time in seconds
-
-float analogSMOKE = 0;
-float PrinterTemperature = 0;
-
-void setup() {
-  Serial.begin(9600);
-  pinMode(OK_PIN, OUTPUT);
-  pinMode(ALERT_PIN, OUTPUT);
-  pinMode(AUDIO_PIN, OUTPUT);
-  pinMode(RELAY_PIN, OUTPUT);
-  pinMode(SMOKE_PIN, INPUT);
-
-  mlx.begin();
-}
-
-void loop() {
-  PrinterTemperature = mlx.readObjectTempC();
-  analogSMOKE = analogRead(SMOKE_PIN);
-
-Serial.print("Object = ");
-Serial.print(PrinterTemperature);
-Serial.println(" C");
-// objekt temp
-
-Serial.print("Ambient = ");
-Serial.print(mlx.readAmbientTempC());
-Serial.println(" C");
-// omgivende temp
-
-    // High temp
-  if (PrinterTemperature >= THRESHOLD_HIGH) {
-    digitalWrite(OK_PIN, LOW);
-    digitalWrite(ALERT_PIN, HIGH);
-    digitalWrite(RELAY_PIN, HIGH);
-    tone(AUDIO_PIN, ALERT_TONE);
-  }
-
-    // Low temp
-  if (PrinterTemperature < THRESHOLD_LOW) {
-    tone(AUDIO_PIN, LOW_TONE);
-
-    digitalWrite(OK_PIN, HIGH);
-    delay(1000);
-    digitalWrite(OK_PIN, LOW);
-    delay(1000);
-  }
-
-  if (analogSMOKE > THRESHOLD_SMOKE_LOW) {
-
-    digitalWrite(ALERT_PIN, HIGH);
-    tone(AUDIO_PIN, ALERT_TONE);
-    delay(1000);
-    digitalWrite(ALERT_PIN, LOW);
-    noTone(AUDIO_PIN);
-    delay(1000);
-  }
-
-      // Smoke alert, AnalogIndput
-  if (analogSMOKE > THRESHOLD_SMOKE_HIGH) {
-    digitalWrite(OK_PIN, LOW);
-    digitalWrite(ALERT_PIN, HIGH);
-    digitalWrite(RELAY_PIN, HIGH);
-    tone(AUDIO_PIN, ALERT_TONE);
-  }
-
-    // High temp and smoke alert
-  if ((PrinterTemperature >= THRESHOLD_HIGH) && (analogSMOKE > THRESHOLD_SMOKE_HIGH)) {
-    digitalWrite(OK_PIN, LOW);
-    digitalWrite(ALERT_PIN, HIGH);
-    digitalWrite(RELAY_PIN, HIGH);
-    tone(AUDIO_PIN, ALERT_TONE);
-  }
-
-    // Idel
-  else {
-    digitalWrite(OK_PIN, HIGH);
-    digitalWrite(ALERT_PIN, LOW);
-    digitalWrite(RELAY_PIN, LOW);
-    noTone(AUDIO_PIN);
-  }
-
-  delay(PulseTime * 1000);
-
-}


Initial commit of the xbee cpp test

Initial commit of the xbee cpp test

--- Arduino/sketchbook/XbeeCppTest/XbeeCppTest.ino
+++ Arduino/sketchbook/XbeeCppTest/XbeeCppTest.ino
@@ -1,13 +1,30 @@
-#include <XBeeS6.h>
+#include <XbeeS6.h>
+
+//#include <XBeeS6.h>

 //#include "XbeeS6.h"
+#define BAUD_RATE 115200
+
+Tx64Packet tx_packet;

 void setup()
 {
+  Serial.begin(BAUD_RATE);
+  Serial.println("Starting the Receiver!");

+  tx_packet.set_Address(0x00000000C0A80064);
+  tx_packet.push_back(0x15);
+  tx_packet.push_back(0x16);
 }

 void loop()
 {
+  uint16_t length = tx_packet.packet_buf();

+  for(int i = 0; i < length; i++)
+  {
+    Serial.print(tx_buffer[i], HEX);
+    Serial.print(" ");
+  }
+  Serial.print('\n');
 }


Remove system time debugging.

Remove system time debugging.

--- teensy/n2k.ino
+++ teensy/n2k.ino
@@ -161,7 +161,6 @@
   //Serial.println(N2kMsg.PGN);

   switch (N2kMsg.PGN) {
-    case 126992UL: HandleSystemTime(N2kMsg); break;

     case 127250UL: HandleHeading(N2kMsg); break;
     case 127258UL: HandleVariation(N2kMsg); break;
@@ -345,20 +344,6 @@
     }
   }

-}
-
-void HandleSystemTime(const tN2kMsg &N2kMsg)
-{
-  unsigned char SID;
-  uint16_t SystemDate;
-  double SystemTime;
-  tN2kTimeSource TimeSource;
-
-  if ( ParseN2kPGN126992(N2kMsg, SID, SystemDate, SystemTime, TimeSource) )
-  {
-    Serial.print("COWABUNGA SystemDate="); Serial.println(SystemDate);
-    Serial.print("COWABUNGA SystemTime="); Serial.println(SystemTime);
-  }
 }

 void HandleEnvironment(const tN2kMsg &N2kMsg)


Radio-active glow animation

Radio-active glow animation

--- matrixscroller.ino
+++ matrixscroller.ino
@@ -7,6 +7,8 @@

 #define GLYPH_WIDTH     6
 #define GLYPH_HEIGHT    8
+
+static uint32_t frame[8];

 void setup(void)
 {
@@ -20,8 +22,6 @@
   /* and clear the display */
   lc.clearDisplay(0);
 }
-
-static uint32_t frame[8];

 // reverses bit order in a byte
 static uint8_t revbits(uint8_t b)
@@ -74,11 +74,51 @@
     }
 }

+static void draw_bitmap(const uint8_t *bitmap)
+{
+    int i;
+    for (i = 0; i < 8; i++) {
+        frame[i] = (uint32_t)bitmap[i] << 24;
+    }
+}
+
+static void alarm_cycle(void)
+{
+    static int phase = 0;
+    static const uint8_t radio[8] = {0x3C, 0x5A, 0x99, 0x99, 0xFF, 0xE7, 0x42, 0x3C};
+    static const uint8_t mask[8] =  {0x7C, 0xFE, 0x92, 0xFE, 0x7C, 0x38, 0x7C, 0x7C};
+    static const uint8_t skull[8] = {0x7C, 0xFE, 0xFE, 0x92, 0x92, 0x6C, 0x38, 0x38};
+
+    phase = (phase + 1) % 64;
+    if (phase < 32) {
+        draw_bitmap(radio);
+    } else {
+        draw_bitmap(mask);
+    }
+    update_display();
+
+    int level = phase % 32;
+    if (level < 16) {
+        lc.setIntensity(0, level);
+    } else {
+        lc.setIntensity(0, 31 - level);
+    }
+}
+
+
 void loop(void)
 {
-  static const char text[] = "Spoorlaan 5d   PIZZA   ";

   int i;
+  int j;
+
+#if 1
+    alarm_cycle();
+    delay(40);
+#else
+  static const char text[] = "  56 cpm  ";
+
+  lc.setIntensity(0, 4);
   for (i = 0; text[i] != 0; i++) {
     draw_char(text[i]);

@@ -86,7 +126,8 @@
     for (j = 0; j < GLYPH_WIDTH; j++) {
       scroll();
       update_display();
-      delay(25);
+      delay(40);
     }
   }
+#endif
 }


deleted repeated lines in sketch description

 "This example is written for a network using WPA encryption. For
 WEP or WPA, change the Wifi.begin() call accordingly."

--- libraries/WiFi/examples/WiFiWebClient/WiFiWebClient.ino
+++ libraries/WiFi/examples/WiFiWebClient/WiFiWebClient.ino
@@ -4,9 +4,6 @@

  This sketch connects to a website (http://www.google.com)
  using a WiFi shield.
-
- This example is written for a network using WPA encryption. For
- WEP or WPA, change the Wifi.begin() call accordingly.

  This example is written for a network using WPA encryption. For
  WEP or WPA, change the Wifi.begin() call accordingly.


Create microbit_Screen.ino

Create microbit_Screen.ino


Delete GettingStarted_KY-040_RotaryEncoder.ino.ino

--- RotaryEncoder/examples/GettingStarted_KY-040_RotaryEncoder/GettingStarted_KY-040_RotaryEncoder.ino/GettingStarted_KY-040_RotaryEncoder.ino.ino
+++ RotaryEncoder/examples/GettingStarted_KY-040_RotaryEncoder/GettingStarted_KY-040_RotaryEncoder.ino/GettingStarted_KY-040_RotaryEncoder.ino.ino
@@ -1,79 +0,0 @@
-//  GettingStarted KY-040 RotaryEncoder Demo
-//  Search string: "ky-040 rotary decoder encoder module for arduino"
-//
-//  Functions:
-//    Rotate CW:   count up         0..15, 0
-//    Rotate CCW:  count down       0, 15..0
-//    Push Button: reset counter to 0
-//
-//
-//  Wiring:
-//         KY-040                 Arduino AVR (UNO, Nano, etc.)
-//    +-------------+
-//    |             |--- CLK  >   o Pin 3
-//    |             |--- DAT  >   o Pin 2
-//    |   top view  |--- SW   >   o Pin A1
-//    |             |--- VCC  >   o 5.0V
-//    |             |--- GND  >   o GND
-//    +-------------+
-//
-//     No external RC- or R-parts are used. Debouncing will be supported by Rotary Encoder library 'RotaryEncoder.h'
-//
-//  Copyright (c) 2015 Thomas Walloschke (artkeller at gmx.de). All rights reserved.
-//
-//  Permission is hereby granted, free of charge, to any person obtaining a copy
-//  of this software and associated documentation files (the "Software"), to deal
-//  in the Software without restriction, including without limitation the rights
-//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-//  copies of the Software, and to permit persons to whom the Software is
-//  furnished to do so, subject to the following conditions:
-//
-//  The above copyright notice and this permission notice shall be included in
-//  all copies or substantial portions of the Software.
-//
-//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-//  THE SOFTWARE.
-
-// ***************************************************************
-
-#include <RotaryEncoder.h>
-
-#if ARDUINO >= 100
-#include "Arduino.h"
-#else
-#include "WProgram.h"
-#endif
-
-// Default Rotary Encoder Object
-RotaryEncoder rotaryEncoder = RotaryEncoder();  // CLK = pin 3, DAT = pin 2, SW = pin A1, CW = count up, CCW = count down
-
-// ***************************************************************
-
-void setup() {
-  Serial.begin(115200);
-  Serial.println(F("GettingStarted KY-040 RotaryEncoder Demo"));
-}
-
-// ***************************************************************
-
-void loop() {                                                   // apply Rotary Encoder methods
-
-  // Get Rotary Encoder status
-  rotaryEncoder.startDebouncer();                               // has to be inside loop to enable debouncer
-  rotaryEncoder.updateClearButton();                            // enable Button to clear recent encoder position if pushed, set to 0
-
-  // Print changes
-  if (rotaryEncoder.hasChanged()) {                             // verify if encoder position has changed
-    volatile byte encoderPos = rotaryEncoder.encodedPos() % 16; // update counter for the dial (values 0..15)
-    Serial.print(F("Position: "));
-    Serial.println(encoderPos, DEC);
-  }
-}
-
-// ***************************************************************
-


Delete K_Nearest_Boxes_Picture.ino

Delete K_Nearest_Boxes_Picture.ino

--- K_Nearest_Boxes_Picture/K_Nearest_Boxes_Picture.ino
+++ K_Nearest_Boxes_Picture/K_Nearest_Boxes_Picture.ino
@@ -1,174 +0,0 @@
-//Camera Sensor
-//Feature is r, g, b
-//Pre-known object of different colors
-#include <Arduino.h>
-
-#include "Object.h"
-
-// For connection to Python
-int incomingByte = 0;
-
-const int DISTANCE_SENSOR_MAX_DISTANCE = 50;
-
-//K Nearest Neighbors
-const int K = 3;
-
-const size_t NUM_OF_KNOWN_OBJECTS = 9;
-const size_t NUM_OF_OBJECT_TYPES = 3;
-String Known_Object_Types[3] = {"Small", "Medium", "Large"};
-
-// Takes the features from the current object and converts them to strings and integers
-// **
-void ObjectFeatureExtraction(Object &currObject) {
-  // Pass in an object (Pass by pointer)
-  int currDistance;
-
-  // Get Image from camera
-
-  // Send Image to Python for processing
-
-  // Get average r, g, b values back
-  if(Serial.available() > 0) {
-    currObject.red = Serial.read();
-    currObject.green = Serial.read();
-    currObject.blue = Serial.read();
-  }
-}
-
-//  Computes the euclidean distance between the known and the current object's rgb values
-float ComputeDistanceofColors(Object currObject, Object knownObject) {
-  float red = currObject.red - knownObject.red;
-  float green = currObject.green - knownObject.green;
-  float blue = currObject.blue - knownObject.blue;
-  float dist = pow(red, 2) + pow(green, 2) + pow(blue, 2);
-  dist = roundf(dist* 100.0) / 100.0;
-  return dist;
-}
-
-//  Computes the euclidean distance between the known and the current object's features
-float ComputeDistanceofObjects(Object currObject, Object knownObject) {
-  // Compute color distances
-  float ColorDistance = ComputeDistanceofColors(currObject, knownObject);
-  // Square all the the feature distances between the known and current object (necessary when there are more features)
-  float dist = pow(ColorDistance, 2);
-  // Take the square root of all the distances
-  dist = sqrt(dist);
-  // Nearest 100ths place
-  dist = roundf(dist * 100.0) / 100.0;
-
-  return dist;
-}
-
-// Finds the patterns from the current object and compares them to patterns from the given objects
-// **
-String ObjectPatternRecognition(Object currObject, Object knownObjects[]) {
-  Object kNearestObjects[K];
-
-  // For testing purposes
-  for(int i = 0; i < NUM_OF_KNOWN_OBJECTS; ++i) {
-    Serial.println(ComputeDistanceofObjects(currObject, knownObjects[i]));
-  }
-
-  // The first K Object differences are added to the kNearestObjects array
-  for(int i = 0; i < K; ++i) {
-    kNearestObjects[i].red = abs(knownObjects[i].red - currObject.red);
-    kNearestObjects[i].green = abs(knownObjects[i].green - currObject.green);
-    kNearestObjects[i].blue = abs(knownObjects[i].blue - currObject.blue);
-    kNearestObjects[i].type = knownObjects[i].type;
-  }
-
-  // Now, determine if each remaining object is among the K closest, and if so insert into array (thus dropping one obj)
-  for(int i = K; i < NUM_OF_KNOWN_OBJECTS; ++i) { // For each remaining known object
-
-    // Find the current max difference in the K nearest objects
-    float max_dist = 0;
-    int max_index = 0;
-    float temp_red = 0;
-    float temp_green = 0;
-    float temp_blue = 0;
-    float temp_dist = 0;
-
-    for(int j = 0; j < K; ++j) {
-      //temp_dist = ComputeDistanceofObjects(currObject, kNearestObjects[j]);
-      temp_dist = ComputeDistanceofObjects(currObject, knownObjects[j]);
-      if(temp_dist > max_dist) { // Update max
-        max_dist = temp_dist;
-        max_index = j;
-      }
-    }
-
-    // If the current known object's difference < the max difference in the current K nearest neighbors
-    temp_red = abs(knownObjects[i].red - currObject.red);
-    temp_green = abs(knownObjects[i].green - currObject.green);
-    temp_blue = abs(knownObjects[i].blue - currObject.blue);
-    temp_dist = ComputeDistanceofObjects(currObject, knownObjects[i]);
-
-    if(temp_dist < max_dist) {
-      // Replace the existing neighbor having max_dist, by the current known object, in the K nearest neighbors array
-      kNearestObjects[max_index].type = knownObjects[i].type;
-      kNearestObjects[max_index].red = temp_red;
-      kNearestObjects[max_index].green = temp_green;
-      kNearestObjects[max_index].blue = temp_blue;
-      max_dist = temp_dist;
-    }
-  }
-
-  int count = 0;
-  int max_count = 0;
-  String max_type;
-  // Find out which object type occurs the most
-  for(int i = 0; i < NUM_OF_OBJECT_TYPES; ++i) {
-    count = 0;
-    for(int j = 0; j < K; ++j) {
-      if(kNearestObjects[j].type == Known_Object_Types[i]) {
-        count++;
-      }
-    }
-    if(count > max_count) {
-      max_count = count;
-      max_type = Known_Object_Types[i];
-    }
-  }
-
-  return max_type;
-}
-
-// Prints the type of object that is being passed through the project
-// **
-void Actuation(String object) {
-  if(object != "") {
-    Serial.print("\t");
-    Serial.println(object);
-  }
-}
-
-void setup() {
-  Serial.begin(9600);
-}
-
-void loop() {
-  //Turns both LEDs off before each reading
-
-  //Should put feature extraction and pattern recognition in one multi-second for loop to
-    //give the box time to go through the sensors.
-
-  Object knownObjects[NUM_OF_KNOWN_OBJECTS] =
-                        {{"Orange", 222, 186, 43},
-                        {"Orange", 247, 174, 47},
-                        {"Orange", 233, 151, 9},
-                        {"Apple", 233, 61, 9},
-                        {"Apple", 215, 26, 26},
-                        {"Apple", 225, 20, 20}};
-
-  Object currObject;
-  String closestObject;
-
-  ObjectFeatureExtraction(currObject);
-
-  closestObject = ObjectPatternRecognition(currObject, knownObjects);
-
-  Actuation(closestObject);
-
-  delay(1000);
-}
-


Fixed include error and added an additional touch sensor for testing.

--- examples/Sandbox/CosaTouch/CosaTouch.ino
+++ examples/Sandbox/CosaTouch/CosaTouch.ino
@@ -33,7 +33,7 @@
 #include "Cosa/Touch.hh"
 #include "Cosa/RTC.hh"
 #include "Cosa/Watchdog.hh"
-#include "Cosa/IOStram.hh"
+#include "Cosa/IOStream.hh"
 #include "Cosa/IOStream/Driver/UART.hh"

 IOStream cout(&uart);
@@ -42,11 +42,12 @@
 private:
   uint16_t m_count;
 public:
-  Counter(Board::DigitalPin pin) : Touch(pin), m_count(0) {}
+  Counter(Board::DigitalPin pin, uint16_t init) : Touch(pin), m_count(init) {}
   virtual void on_key_down() { cout << PSTR("count = ") << ++m_count << endl; }
 };

-Counter key(Board::D3);
+Counter c1(Board::D3, 100);
+Counter c2(Board::D4, 0);

 void setup()
 {


Added a WS2812 LED Strip for the RPM. Softwar is also compatible with a Sparkfun Pro Micro now. The Sparkfun chip is only working with the new Host Application from the last commit.

--- Teensy/ACTCon/ACTCon.ino
+++ Teensy/ACTCon/ACTCon.ino
@@ -1,18 +1,18 @@
 /*
  * The MIT License (MIT)
- *
+ *
  * Copyright (c) 2015 Michael Drost
- *
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
  * in the Software without restriction, including without limitation the rights
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  * copies of the Software, and to permit persons to whom the Software is
  * furnished to do so, subject to the following conditions:
- *
+ *
  * The above copyright notice and this permission notice shall be included in all
  * copies or substantial portions of the Software.
- *
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,10 +22,21 @@
  * SOFTWARE.
  */

+#include <FastLED.h>
+
+#define LED_PIN     3
+
+// Information about the LED strip itself
+#define NUM_LEDS    34
+#define CHIPSET     WS2811
+#define COLOR_ORDER GRB
+CRGB leds[NUM_LEDS];
+#define BRIGHTNESS  32
+
 int percentage;
 int rpm;
 int rpmt;
-int maxrpm;
+long maxrpm;
 enum state_t
 {
   idle,
@@ -34,7 +45,7 @@
   recrpm,
   finrpm,
   fin
-}state;
+} state;
 const int ledPin = 13;
 const int FFPin = 12;
 void setup()
@@ -46,89 +57,109 @@
   digitalWrite(FFPin, HIGH);
   percentage = 0;
   rpm = 0;
-  rpmt=0;
+  rpmt = 0;
   maxrpm = 1000;
-  state=idle;
+  state = idle;
+
+  FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalSMD5050 );
+  FastLED.setBrightness( BRIGHTNESS );
 }

 void loop()
 {
-
-//check serial and receive messages
-  if(Serial.available())
+
+  //check serial and receive messages
+  if (Serial.available())
   {
-//receive
+    //receive
     byte incomingByte = Serial.read();
-//decode vibration level
-    if(state == rec && incomingByte >= '0' && incomingByte <= '9')
+    //decode vibration level
+    if (state == rec && incomingByte >= '0' && incomingByte <= '9')
     {
       percentage *= 10;
-      percentage += incomingByte -'0';
+      percentage += incomingByte - '0';
       Serial.print("Percentage Set to: ");
       Serial.println(percentage);
     }
-//decode rpm
-    if(state == recrpm && incomingByte >= '0' && incomingByte <= '9')
+    //decode rpm
+    if (state == recrpm && incomingByte >= '0' && incomingByte <= '9')
     {
       rpmt *= 10;
-      rpmt += incomingByte -'0';
+      rpmt += incomingByte - '0';
       Serial.print("rpm Set to: ");
       Serial.println(rpmt);
     }
-//find start and stop Bytes A R and stop E r
-    if(incomingByte == 'A')
+    //find start and stop Bytes A R and stop E r
+    if (incomingByte == 'A')
     {
       state = rec;
     }
-    if(incomingByte == 'R')
+    if (incomingByte == 'R')
     {
       rpmt = 0;
       state = recrpm;
     }
-    if(incomingByte == 'E' && state == rec)
+    if (incomingByte == 'E' && state == rec)
     {
-      state = fin;
+      state = fin;
     }
-    if(incomingByte == 'r' && state == recrpm)
+    if (incomingByte == 'r' && state == recrpm)
     {
-      state = idle;
+      state = idle;
       rpm = rpmt;
     }
   }
-//apply received values
-  if(state == fin)
+  //apply received values
+  if (state == fin)
   {
     state = idle;
-    if(percentage >100){percentage = 0; return;}
-    if(percentage > 50)
+    if (percentage > 100) {
+      percentage = 0;
+      return;
+    }
+    if (percentage > 50)
     {
-      digitalWrite(FFPin, LOW);
+      digitalWrite(FFPin, LOW);
     }
     else
     {
-      digitalWrite(FFPin, HIGH);
+      digitalWrite(FFPin, HIGH);
     }
     percentage = 0;
   }
-
-//find max rpm
-  if(rpm > maxrpm) maxrpm = rpm;
-//TODO: Filter downshifts --> driving fullspeed in the 6th gear and dunshifting rapidly brings engine to 15000 rpm which is definately not maxrpm
-
-//LED Controll for max rpm
-  if((rpm > (maxrpm*95/100)))
+
+  //find max rpm
+  if (rpm > maxrpm) maxrpm = rpm;
+  //TODO: Filter downshifts --> driving fullspeed in the 6th gear and dunshifting rapidly brings engine to 15000 rpm which is definately not maxrpm
+
+  //LED Controll for max rpm
+  if ((rpm > (maxrpm * 95 / 100)))
   {
-    if(((millis()/50) % 2)==0)
+    if (((millis() / 50) % 2) == 0)
       digitalWrite(ledPin, HIGH);
     else
       digitalWrite(ledPin, LOW);
   }
-  else if((rpm > (maxrpm*85/100)))
+  else if ((rpm > (maxrpm * 85 / 100)))
   {
     digitalWrite(ledPin, HIGH);
   }
   else
     digitalWrite(ledPin, LOW);
+
+
+  for (int i = 0; i < NUM_LEDS; ++i)
+  {
+    CRGB Color = CRGB::Green;
+    if (i >= 24) Color = CRGB::Yellow;
+    if (i >= 28) Color = CRGB::Red;
+    if ((((long)rpm) * NUM_LEDS / maxrpm) > i)
+      leds[i] = Color;
+    else
+      leds[i] = CRGB::Black;
+  }
+  FastLED.show();
 }

+


Update Beacon.ino

Update Beacon.ino

--- FastLED/Beacon.ino
+++ FastLED/Beacon.ino
@@ -1,34 +1,38 @@
-#include "captouch.h"
-#include "FastLED.h"
+// This #include statement was automatically added by the Particle IDE.
+#include <FastLED.h>
+FASTLED_USING_NAMESPACE;

-#define RING_PIN    3
-#define RING_LEDS    64
+//The FastLED variables
+#define RING_PIN    D1
+#define RING_LEDS    24
 CRGB ringLeds[RING_LEDS];
-
-#define STRIP_PIN    3
-#define STRIP_LEDS    64
+#define STRIP_PIN    D0
+#define STRIP_LEDS    15
 CRGB stripLeds[STRIP_LEDS];

-CRGB red = CHSV( 0, 0, 0);
-CRGB green  = CHSV( 85, 0, 0);
-CRGB blue  = CHSV( 150, 0, 0);
-CRGB beaconColor = CHSV( 0, 0, 0);
-CRGB baseColor = CHSV( 0, 0, 0);
+//The fastLED color declarations
+const int  colors = 3;
+CHSV red = CHSV(0, 0 , 0);
+CHSV green  = CHSV(85, 0 , 0);
+CHSV blue  = CHSV(171, 0 , 0);
+CHSV currentPalette[colors] =  {red, green, blue};

-uint8_t  colors = 3;
-uint32_t currentPalette =  [red,  green,  blue];
+CHSV beaconColor; //The color beacon sent
+CHSV baseColor;  //The beacon color received

-CapTouch::Event touchEvent;

+char beaconString[40]; //the string being published

 uint8_t brightness = 254; //Global brightness assignment
+int button = D3; //The push button pin

 void setup() {
+    pinMode(button, INPUT_PULLDOWN);
 	delay(3000); // 3 second delay for recovery
-	Particle.subscribe("LampUpdate", gotColorUpdate, MY_DEVICES);
-	Touch.setup();
+
+
   	FastLED.addLeds<NEOPIXEL, RING_PIN>(ringLeds, RING_LEDS);
 	FastLED.addLeds<NEOPIXEL, STRIP_PIN>(stripLeds, STRIP_LEDS);

@@ -38,55 +42,62 @@

 void loop()
-{
-	touchEvent = Touch.getEvent();
-  	if (touchEvent == CapTouch::TouchEvent) {
-		whileTouching();
-	}
-	update();
-	FastLED.show();
+{	if(digitalRead(button) == HIGH){
+        whileTouching();
+    }
 }

-void gotColorUpdate(const char *name, const char *data) {

-	String str = String(data);
-    char strBuffer[40] = "";
-    str.toCharArray(strBuffer, 40);
-    colorFromID = strtok(strBuffer, "~");
-    baseColor = atof(strtok(NULL, "~"));
+void whileTouching() {
+
+	unsigned int colorIndex = 0; //Integer used to select applied color
+	unsigned int satBright = 0; //The initial brightness and saturation of the lights
+	CHSV color = green; //The first color
+	fill_solid(stripLeds, STRIP_LEDS, CRGB::Black);
+	fill_solid(ringLeds, RING_LEDS, CRGB::Black);

-    // DEBUG
-    String sColorRecieved = String(baseColor);
-    Particle.publish("Color_Recieved", System.deviceID() + "~" + sColorRecieved);
+    while (digitalRead(button) == HIGH) {
+
+		if(satBright > 250){
+		    ringFill(color.hue);
+		    fill_solid(stripLeds, STRIP_LEDS, CRGB::Black);
+		    fill_solid(ringLeds, RING_LEDS, CRGB::Black);
+			satBright = 0;
+			colorIndex ++;
+			color = currentPalette[colorIndex % colors];
+
+			}
+
+		uint8_t pixelsLit = map(satBright,0,250,0,STRIP_LEDS);
+
+		for (int i = 0; i <= pixelsLit && i <= STRIP_LEDS;i++){
+			stripLeds[i] = color;
+			}
+
+
+		color.saturation = satBright;
+		color.value = satBright;
+		satBright += 15;
+		FastLED.show();
+		delay(60);
+		now = millis();
+	}
+	FastLED.show();
+	beaconColor = color;
+	fill_solid(stripLeds, STRIP_LEDS, CRGB::Black);
+	fill_solid(ringLeds, RING_LEDS, CRGB::Black);
+	sprintf(publishString, "%u:%u:%u",beaconColor.hue,beaconColor.saturation,beaconColor.value);
+    Spark.publish("Color: ",publishString);
+    lastTime = now;
+
 }

-void whileTouching() {
-	uint8_t colorIndex = 0;
-	uint8_t satBright = 20;
-	CRGB color = red;

-    	while (touchEvent != CapTouch::ReleaseEvent) {
+void ringFill(int colorHue){ //This function lights up the beacon when the colors are maxed

-		if(satBright >= 255){
-			satBright = 20;
-			colorIndex +=1;
-			color = currentPalette[colorIndex % colors];
-			}
-
-		uint8_t pixelsLit = map(satBright,0,255,0,STRIP_LEDS+1);
-
-		for int(i = 0; i <= pixelsLit && i <= STRIP_LEDS;i++){
-			stripLeds[i] = color;
-			}
-		if(pixelsLit > STRIP_LEDS){
-			fill_solid(&ringLeds, RING_LEDS, color); //at max capacity, light up the whole beacon
-			}
-		satBright += 5;
-		color.saturation = satBright;
-		color.brightness = satBright;
-	}
-	fastLED.show();
-	beaconColor = color;
-	String sColor = String(beaconColor);
-	Particle.publish("colorUpdate", System.deviceID() + "~" + sColor, 60, PRIVATE);
+    for(int i = 0; i <= 255; i++){
+        fill_solid(ringLeds, RING_LEDS, CHSV(colorHue,255,i));
+        FastLED.show();
+        delay(5);
+    }
 }


modified esc_calib code

modified esc_calib code

--- arduino/src/T-80AFLAME/esc_calib/esc_calib.ino
+++ arduino/src/T-80AFLAME/esc_calib/esc_calib.ino
@@ -189,9 +189,9 @@

   // map(channels[0], RC_MIN, RC_MAX, ESC_MIN, ESC_MAX)
   rcthr = channels[0];
-  rcroll = map(channels[1], RC_MIN, RC_MAX, -60, 60);
-  rcpit = map(channels[2], RC_MIN, RC_MAX, -60, 60);
-  rcyaw = map(channels[3], RC_MIN, RC_MAX, -300, 300);
+  rcroll = map(channels[1], RC_MIN, RC_MAX, -150, 150);
+  rcpit = map(channels[2], RC_MIN, RC_MAX, -150, 150);
+  rcyaw = map(channels[3], RC_MIN, RC_MAX, -500, 500);

   Serial.println("RC constrained values:");
   Serial.println(rcthr);


Return true in blink_led_handler.

Return true in blink_led_handler.

--- examples/BlinkLed/BlinkLed.ino
+++ examples/BlinkLed/BlinkLed.ino
@@ -102,6 +102,7 @@
       setLedEnabled(true);
     }
   }
+  return true;
 }

 boolean led_status_handler(TinyWebServer& web_server) {


Print "Yún" and not "Y�n"; "degrees C" to "ºC"

Hi, just got a Yún few days ago and noticed that when testing stuff, just cosmetic.

Thanks.

--- libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino
+++ libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino
@@ -102,11 +102,11 @@
       // convert the millivolts to temperature celsius:
       float temperature = (voltage - 500) / 10;
       // print the temperature:
-      client.print("Current time on the Yún: ");
+      client.print("Current time on the Y&uacuten: ");
       client.println(timeString);
       client.print("
Current temperature: ");
       client.print(temperature);
-      client.print(" degrees C");
+      client.print(" &degC");
       client.print("
This sketch has been running since ");
       client.print(startString);
       client.print("
Hits so far: ");


correction d'une coquille

correction d'une coquille

--- matrix-RGB/matrix-RGB.ino
+++ matrix-RGB/matrix-RGB.ino
@@ -113,8 +113,6 @@
     digitalWrite(BPin, b);
     digitalWrite(CPin, c);

-    delayMicroseconds(100);
-
     // on envoie les données
     // d'abord les lignes du bas de l'afficheur
     for (int j=0; j<32; j++) {


一つのファイルに統合

一つのファイルに統合

--- app/inTheDuck/LoverDuck.ino
+++ app/inTheDuck/LoverDuck.ino
@@ -46,4 +46,37 @@
   mySend("z"+(String)data[2]);
 }

+void comBegin(int speed){
+  if(isBT){
+    //passkey is 1234
+    BT.begin(speed);
+  }
+  else{
+    Serial.begin(speed);
+  }
+}

+void mySend(String s){
+  //add device ID
+  s=idString+s;
+  if(isBT){
+    BT.println(s);
+  }
+  else{
+    Serial.println(s);
+  }
+}
+
+boolean comAvailable(){
+  boolean value;
+  if(isBT){
+    value=BT.available();
+  }
+  else{
+    value=Serial.available();
+  }
+  return value;
+}
+
+
+


Update Infrared_Sensor.ino

Update Infrared_Sensor.ino

--- examples/Infrared_Sensor/Infrared_Sensor.ino
+++ examples/Infrared_Sensor/Infrared_Sensor.ino
@@ -9,9 +9,9 @@
 BIoTEthernetClient client;

 int ledPin = 13;
-int pirPin = 6;
+int irPin = 6;
 int val = 0;
-bool pirState = LOW;
+bool irState = LOW;

 void setup()
 {
@@ -26,7 +26,7 @@
     Serial.println("connected");

   pinMode (ledPin,OUTPUT);
-  pinMode (pirPin, INPUT);
+  pinMode (irPin, INPUT);
 }
 }
 void loop ()
@@ -35,7 +35,7 @@
       String message = client.readString();
   }

-  val = digitalRead(pirPin);
+  val = digitalRead(irPin);
   Serial.println(val);

 if (val == HIGH){


Fixed the problem in reading bytes from gps. The problem caused due to after calling the dynamic_array_Serial function, the main loop didn't request for the software serial which caused program to stop at that point and enter endless loop. Also, I added "while(src.available()<=0)" to wait for gps to fill the buffer.

--- Drones/Drones.ino
+++ Drones/Drones.ino
@@ -92,7 +92,7 @@

-char* dynamic_array_Serial(SoftwareSerial*,int);
+char* dynamic_array_Serial(SoftwareSerial*,int,char,char);
 //----------------------------Setup Code-----------------------------------------------//
 void setup() {
 	pinMode(MOTOR_1_PIN, OUTPUT);
@@ -112,11 +112,19 @@
 void loop() {
   // put your main code here, to run repeatedly:
   char* gpsbuffer;
+  gpsSerial.listen();
 // Initialize buffer for gps data
-  Serial.println("Try to communicate");
+/*  Serial.println("Try to communicate");
+  Serial.print("Buffer size: ");
   Serial.println(gpsSerial.available());
- 	if (gpsSerial.available() > 0&&gpsSerial.peek()=='$'){
-   gpsbuffer=dynamic_array_Serial(gpsSerial,100);
+  Serial.print("First byte in buffer: ");
+  Serial.println(gpsSerial.peek());
+  Serial.println(gpsSerial.available());*/
+  //Serial.println(gpsSerial.read());
+  //Serial.println("Waiting for buffer to be filled");
+ //	if (gpsSerial.available() > 0){
+   gpsbuffer=dynamic_array_Serial(gpsSerial,100,'$','*');
+   Serial.println("Succeed in loading buffer with data");
    Serial.println(array_length);
    //Serial.print(gpsbuffer[0]);
    /* while (!(gpsSerial.findUntil("$GPRMC,",'*'))){
@@ -133,23 +141,26 @@

     //gpsbuffer[i]=" ";
   }
- 	}
-  else{
+  Serial.println();
+ //	}
+ /* else{
     Serial.println("Fail to communicate!");
   }
-
+ */
   //Serial.println();
 //	For Testing only
   array_length=1;
-  delay(1000);
-  gpsSerial.flush();
+  //Serial.println("Flushing serial");
+  //gpsSerial.flush();
   free(gpsbuffer);
-  Serial.println("Flushing serial");
+  delay(1000);//Waiting for bytes to fill IO buffer

 }
-char* dynamic_array_Serial(SoftwareSerial src,int max_length){
+char* dynamic_array_Serial(SoftwareSerial src,int max_length,char start_char,char terminator){
   src.listen();
+  while(src.available()<=0);//Waiting for bytes to fill buffer
+  while(src.read()!=start_char);//Waiting for the start char
   extern int array_length;
   Serial.println("Successful");
   //Serial.println(array_length); Testing
@@ -166,7 +177,7 @@
   while(src.available()>0){//Cant go into this loop
     char temp=src.read();
     delay(20);
-    if(temp!='*'){
+    if(temp!=terminator){
       max_array[array_length-1]=temp;
       array_length++;
       //Serial.println(max_array[array_length-1]);


Cleanup output formatting; Missing new-line.

--- examples/Benchmarks/CosaBenchmarkPins/CosaBenchmarkPins.ino
+++ examples/Benchmarks/CosaBenchmarkPins/CosaBenchmarkPins.ino
@@ -435,7 +435,7 @@
     AnalogPin::sample(0);
   stop = RTC::micros();
   us = (stop - start) / 1000L;
-  INFO("Cosa(%ulX): %ul us per AnalogPin::sample()/n", base/us, us);
+  INFO("Cosa(%ulX): %ul us per AnalogPin::sample()\n", base/us, us);

   // Measure the time to perform 1,000 analog pin samples
   // Vary prescale division factor from 128 down to 2.
@@ -449,6 +449,7 @@
     INFO("Cosa(%ulX):prescale(%d): %ul us per analogPin.sample()",
 	 base/us, factor, us);
   }
+  trace.println();
 }

 void loop()


Delete MPU6050_raw.ino

Delete MPU6050_raw.ino

--- Examples/MPU6050_raw/MPU6050_raw.ino
+++ Examples/MPU6050_raw/MPU6050_raw.ino
@@ -1,155 +0,0 @@
-// I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class
-// 10/7/2011 by Jeff Rowberg <jeff@rowberg.net>
-// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
-//
-// Changelog:
-//      2013-05-08 - added multiple output formats
-//                 - added seamless Fastwire support
-//      2011-10-07 - initial release
-
-/* ============================================
-I2Cdev device library code is placed under the MIT license
-Copyright (c) 2011 Jeff Rowberg
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-===============================================
-*/
-
-// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
-// for both classes must be in the include path of your project
-#include "I2Cdev.h"
-#include "MPU6050.h"
-
-// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
-// is used in I2Cdev.h
-#if (I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE) && !defined (SPARK)
-    #include "Wire.h"
-#endif
-
-// class default I2C address is 0x68
-// specific I2C addresses may be passed as a parameter here
-// AD0 low = 0x68 (default for InvenSense evaluation board)
-// AD0 high = 0x69
-MPU6050 accelgyro;
-//MPU6050 accelgyro(0x69); // <-- use for AD0 high
-
-int16_t ax, ay, az;
-int16_t gx, gy, gz;
-
-
-
-// uncomment "OUTPUT_READABLE_ACCELGYRO" if you want to see a tab-separated
-// list of the accel X/Y/Z and then gyro X/Y/Z values in decimal. Easy to read,
-// not so easy to parse, and slow(er) over UART.
-#define OUTPUT_READABLE_ACCELGYRO
-
-// uncomment "OUTPUT_BINARY_ACCELGYRO" to send all 6 axes of data as 16-bit
-// binary, one right after the other. This is very fast (as fast as possible
-// without compression or data loss), and easy to parse, but impossible to read
-// for a human.
-//#define OUTPUT_BINARY_ACCELGYRO
-
-#if defined (SPARK)
-#define LED_PIN D7 // (Spark Core is D7)
-#else
-#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)
-#endif
-
-bool blinkState = false;
-
-void setup() {
-    // join I2C bus (I2Cdev library doesn't do this automatically)
-    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
-        Wire.begin();
-    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
-        Fastwire::setup(400, true);
-    #endif
-
-    // initialize serial communication
-    // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
-    // it's really up to you depending on your project)
-    Serial.begin(38400);
-
-    // initialize device
-    Serial.println("Initializing I2C devices...");
-    accelgyro.initialize();
-
-    // verify connection
-    Serial.println("Testing device connections...");
-    Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
-
-    // use the code below to change accel/gyro offset values
-    /*
-    Serial.println("Updating internal sensor offsets...");
-    // -76	-2359	1688	0	0	0
-    Serial.print(accelgyro.getXAccelOffset()); Serial.print("\t"); // -76
-    Serial.print(accelgyro.getYAccelOffset()); Serial.print("\t"); // -2359
-    Serial.print(accelgyro.getZAccelOffset()); Serial.print("\t"); // 1688
-    Serial.print(accelgyro.getXGyroOffset()); Serial.print("\t"); // 0
-    Serial.print(accelgyro.getYGyroOffset()); Serial.print("\t"); // 0
-    Serial.print(accelgyro.getZGyroOffset()); Serial.print("\t"); // 0
-    Serial.print("\n");
-    accelgyro.setXGyroOffset(220);
-    accelgyro.setYGyroOffset(76);
-    accelgyro.setZGyroOffset(-85);
-    Serial.print(accelgyro.getXAccelOffset()); Serial.print("\t"); // -76
-    Serial.print(accelgyro.getYAccelOffset()); Serial.print("\t"); // -2359
-    Serial.print(accelgyro.getZAccelOffset()); Serial.print("\t"); // 1688
-    Serial.print(accelgyro.getXGyroOffset()); Serial.print("\t"); // 0
-    Serial.print(accelgyro.getYGyroOffset()); Serial.print("\t"); // 0
-    Serial.print(accelgyro.getZGyroOffset()); Serial.print("\t"); // 0
-    Serial.print("\n");
-    */
-
-    // configure Arduino LED for
-    pinMode(LED_PIN, OUTPUT);
-}
-
-void loop() {
-    // read raw accel/gyro measurements from device
-    accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
-
-    // these methods (and a few others) are also available
-    //accelgyro.getAcceleration(&ax, &ay, &az);
-    //accelgyro.getRotation(&gx, &gy, &gz);
-
-    #ifdef OUTPUT_READABLE_ACCELGYRO
-        // display tab-separated accel/gyro x/y/z values
-        Serial.print("a/g:\t");
-        Serial.print(ax); Serial.print("\t");
-        Serial.print(ay); Serial.print("\t");
-        Serial.print(az); Serial.print("\t");
-        Serial.print(gx); Serial.print("\t");
-        Serial.print(gy); Serial.print("\t");
-        Serial.println(gz);
-    #endif
-
-    #ifdef OUTPUT_BINARY_ACCELGYRO
-        Serial.write((uint8_t)(ax >> 8)); Serial.write((uint8_t)(ax & 0xFF));
-        Serial.write((uint8_t)(ay >> 8)); Serial.write((uint8_t)(ay & 0xFF));
-        Serial.write((uint8_t)(az >> 8)); Serial.write((uint8_t)(az & 0xFF));
-        Serial.write((uint8_t)(gx >> 8)); Serial.write((uint8_t)(gx & 0xFF));
-        Serial.write((uint8_t)(gy >> 8)); Serial.write((uint8_t)(gy & 0xFF));
-        Serial.write((uint8_t)(gz >> 8)); Serial.write((uint8_t)(gz & 0xFF));
-    #endif
-
-    // blink LED to indicate activity
-    blinkState = !blinkState;
-    digitalWrite(LED_PIN, blinkState);
-}


bugfix

bugfix

--- WifiWeatherGuy.ino
+++ WifiWeatherGuy.ino
@@ -499,7 +499,7 @@
 	}

 	fetch(now, F("astronomy/conditions"), cbytes, last_fetch_conditions, cfg.conditions_interval, [] (JsonObject &root) {
-		if (update_conditions(root, conditions))
+		if (update_conditions(root, conditions) && (cfg.dimmable || fade == cfg.bright))
 			update_display(screen);
 	});


Update Timer_Interrupt_Notes.ino

Update Timer_Interrupt_Notes.ino

--- PulseSensorAmped_Arduino_1.5.0/Timer_Interrupt_Notes.ino
+++ PulseSensorAmped_Arduino_1.5.0/Timer_Interrupt_Notes.ino
@@ -147,11 +147,11 @@

       ISR(TIMER1_COMPA_vect)
   ******************************************************************************************
-  ADAFRUIT Gemma, ADAFRUIT Trinket (or any other board with ATtiny85 running at 8MHz)
+  ADAFRUIT Gemma, ADAFRUIT Trinket 8MHz, Digispark Pro 8MHz, (or any other board with ATtiny85 running at 8MHz)

     NOTE: Gemma does not do serial communication! Comment out or remove the Serial code in the Arduino sketch!

-    NOTE: You must use Software Serial with the Trinket!
+    NOTE: You must use Software Serial with the Trinket or Digispark!
           A the top of the main code page put these lines

             #define rxPin 3
@@ -181,11 +181,11 @@
       ISR(TIMER1_COMPA_vect)

   ******************************************************************************************
-  ADAFRUIT Trinket with 16MHz software setting (or any other board with ATtiny85 running at 16MHz)
+  ADAFRUIT Trinket with 16MHz software setting, Digispark Pro 16MHz, (or any other board with ATtiny85 running at 16MHz)

     NOTE: Use analog pin 2 for the Pulse Sensor purple wire.

-    NOTE: You must use Software Serial with the Trinket!
+    NOTE: You must use Software Serial with the Trinket or Digispark!
           A the top of the main code page put these lines

             #define rxPin 3


Schedule a channel upload after getting start from talkback

--- examples/04.FSM/SmartParkinglot/SmartParkinglot.ino
+++ examples/04.FSM/SmartParkinglot/SmartParkinglot.ino
@@ -13,19 +13,20 @@
 SoftwareSerial espSerial(2, 3);
 Esp8266<SoftwareSerial> esp(espSerial);

+Channel<SoftwareSerial> channel(esp, scheduler, "AAAAAAAAAAAAAAAA", [](HttpRequest& request){
+  request.addParameter("field1", String(shield.getTemperature()));
+  request.addParameter("field2", String(shield.getBrightness()));
+  request.addParameter("field3", String(parkinglot.getState()));
+  request.addParameter("field4", String(parkinglot.getCredit()));
+});
+
 Talkback<SoftwareSerial> talkback(esp, 9999, "AAAAAAAAAAAAAAAA", [](String command){
   if(command == "pay") {
     parkinglot.process(Parkinglot::pay);
   } else if(command == "start") {
     parkinglot.process(Parkinglot::start);
+    channel.scheduleUpload();
   }
-});
-
-Channel<SoftwareSerial> channel(esp, scheduler, "JE6VRA8PR16IVC7D", [](HttpRequest& request){
-  request.addParameter("field1", String(shield.getTemperature()));
-  request.addParameter("field2", String(shield.getBrightness()));
-  request.addParameter("field3", String(parkinglot.getState()));
-  request.addParameter("field4", String(parkinglot.getCredit()));
 });

 void setup(void)


update two temperatures

update two temperatures

--- examples/ECS_therm/ECS_therm.ino
+++ examples/ECS_therm/ECS_therm.ino
@@ -145,8 +145,8 @@
       else
       {
           //send to MQTT server
-          myMqtt->publishValue("temp", temp1, 1);
-		  myMqtt->publishValue("temp", temp2, 1);
+          myMqtt->publishValue("temp1", temp1, 1);
+		  myMqtt->publishValue("temp2", temp2, 1);
       }
   }


TALKED TO THE MC OFFICIALLY

TALKED TO THE MC OFFICIALLY

MC sends information in reverse byte order with RegID first
EX: 59 70 17 0 => 0x1770 (6000)
ID of MC CAN messages is 0x181 when it transmits
When only setting values the CAN message ID must be 0x201

--- MC_CAN/MC_CAN.ino
+++ MC_CAN/MC_CAN.ino
@@ -13,7 +13,10 @@
   #error "Teensy 3.6 with dual CAN bus is required to run this example"
 #endif

-static CAN_message_t msg;
+static CAN_message_t msgON;
+static CAN_message_t msgOFF;
+static CAN_message_t msgRD;
+
 static uint8_t hex[17] = "0123456789abcdef";

 class ExampleClass : public CANListener
@@ -50,38 +53,55 @@
   delay(1000);
   Serial.println(F("Hello Teensy 3.6 dual CAN Test With Objects."));

-  Can0.begin(1000000);
-  Can1.begin(1000000);
+  Can0.begin(500000);
+  Can1.begin(500000);

-  Can0.attachObj(&exampleClass);
+  Can1.attachObj(&exampleClass);
   exampleClass.attachGeneralHandler();

-  msg.ext = 0;
-  msg.id = 0x100;
-  msg.len = 8;
-  msg.buf[0] = 10;
-  msg.buf[1] = 20;
-  msg.buf[2] = 0;
-  msg.buf[3] = 100;
-  msg.buf[4] = 128;
-  msg.buf[5] = 64;
-  msg.buf[6] = 32;
-  msg.buf[7] = 16;
+  msgON.ext = 0;
+  msgON.id = 0x201;
+  msgON.len = 3;
+  msgON.buf[0] = 0xd1;
+  msgON.buf[1] = 100;
+  msgON.buf[2] = 100;
+
+  msgOFF.ext = 0;
+  msgOFF.id = 0x201;
+  msgOFF.len = 3;
+  msgOFF.buf[0] = 0xd1;
+  msgOFF.buf[1] = 0;
+  msgOFF.buf[2] = 0;
+
+  msgRD.ext = 0;        //no can extended IDs
+  msgRD.id = 0x201;     //id of MC
+  msgRD.len = 3;        //length of message (in bytes)
+  msgRD.buf[0] = 0x3d;  //Read command
+  msgRD.buf[1] = 0x59;  //Register to read from
+  msgRD.buf[2] = 0;     //blank
+
+  //NOTE: MC sends information in reverse byte order with RegID first
+  //      EX: 59 70 17 0 => 0x1770 (6000)
+  //ID of MC is 0x181 when it tx's
+
+
+
+
+  Serial.println(F("Type any character to start"));
+  while (!Serial.available()) {
+
+  }
+  Serial.println(F("Starting test"));
+  Can0.write(msgRD);
+
 }

 // -------------------------------------------------------------
 void loop(void)
 {
-  msg.buf[0]++;
-  Can1.write(msg);
-  msg.buf[0]++;
-  Can1.write(msg);
-  msg.buf[0]++;
-  Can1.write(msg);
-  msg.buf[0]++;
-  Can1.write(msg);
-  msg.buf[0]++;
-  Can1.write(msg);
-  delay(20);
+//  Can0.write(msgON);
+//  delay(500);
+//  Can0.write(msgOFF);
+//  delay(500);
 }


Updated BA2 1MEM example

Updated BA2 1MEM example

--- examples/BA2_TGA_Pro_1MEM/BA2_TGA_Pro_1MEM.ino
+++ examples/BA2_TGA_Pro_1MEM/BA2_TGA_Pro_1MEM.ino
@@ -8,9 +8,13 @@
  * This demo will provide an audio passthrough, as well as exercise the
  * MIDI interface.
  *
- * It will also perform a sweeo of the SPI MEM0 external RAM.
+ * It will also peform a sweep of SPI MEM0.
+ *
+ * NOTE: SPI MEM0 can be used by a Teensy 3.1/3.2/3.5/3.6.
+ * pins.
  *
  */
+//#include <i2c_t3.h>
 #include <Wire.h>
 #include <Audio.h>
 #include <MIDI.h>
@@ -19,7 +23,6 @@
 MIDI_CREATE_DEFAULT_INSTANCE();
 using namespace midi;

-
 using namespace BAGuitar;

 AudioInputI2S            i2sIn;
@@ -32,23 +35,25 @@
 BAAudioControlWM8731      codecControl;
 BAGpio                    gpio;  // access to User LED
 BASpiMemory               spiMem0(SpiDeviceId::SPI_DEVICE0);
-BASpiMemory               spiMem1(SpiDeviceId::SPI_DEVICE1);

 unsigned long t=0;

 // SPI stuff
 int spiAddress0 = 0;
-int spiData0 = 0xff;
+uint16_t spiData0 = 0xABCD;
 int spiErrorCount0 = 0;
-int spiAddress1 = 0;
-int spiData1 = 0xff;
-int spiErrorCount1 = 0;
-
+
+constexpr int mask0 = 0x5555;
+constexpr int mask1 = 0xaaaa;
+
+int maskPhase = 0;
+int loopPhase = 0;

 void setup() {

   MIDI.begin(MIDI_CHANNEL_OMNI);
   Serial.begin(57600);
+  while (!Serial) {}
   delay(5);

   // If the codec was already powered up (due to reboot) power itd own first
@@ -56,26 +61,53 @@
   delay(100);
   AudioMemory(24);

-  Serial.println("Enabling codec...\n");
+  Serial.println("Sketch: Enabling codec...\n");
   codecControl.enable();
   delay(100);
+
+  Serial.println("Enabling SPI");
+  spiMem0.begin();

 }

-void loop() {
+int calcData(int spiAddress, int loopPhase, int maskPhase)
+{
+  int data;
+
+  int phase = ((loopPhase << 1) + maskPhase) & 0x3;
+  switch(phase)
+  {
+    case 0 :
+    data = spiAddress ^ mask0;
+    break;
+    case 1:
+    data = spiAddress ^ mask1;
+    break;
+    case 2:
+    data = ~spiAddress ^ mask0;
+    break;
+    case 3:
+    data = ~spiAddress ^ mask1;
+
+  }
+  return (data & 0xffff);
+}
+
+void loop() {

   //////////////////////////////////////////////////////////////////
   // Write test data to the SPI Memory 0
   //////////////////////////////////////////////////////////////////
-  for (spiAddress0=0; spiAddress0 <= SPI_MAX_ADDR; spiAddress0++) {
+  maskPhase = 0;
+  for (spiAddress0=0; spiAddress0 <= SPI_MAX_ADDR; spiAddress0=spiAddress0+2) {
     if ((spiAddress0 % 32768) == 0) {
       //Serial.print("Writing to ");
       //Serial.println(spiAddress0, HEX);
     }

-    //mem0Write(spiAddress0, spiData0);
-    spiMem0.write(spiAddress0, spiData0);
-    spiData0 = (spiData0-1) & 0xff;
+    spiData0 = calcData(spiAddress0, loopPhase, maskPhase);
+    spiMem0.write16(spiAddress0, spiData0);
+    maskPhase = (maskPhase+1) % 2;
   }
   Serial.println("SPI0 writing DONE!");

@@ -84,31 +116,32 @@
   ///////////////////////////////////////////////////////////////////
   spiErrorCount0 = 0;
   spiAddress0 = 0;
-  spiData0 = 0xff;
-
-  for (spiAddress0=0; spiAddress0 <= SPI_MAX_ADDR; spiAddress0++) {
+  maskPhase = 0;
+
+  for (spiAddress0=0; spiAddress0 <= SPI_MAX_ADDR; spiAddress0=spiAddress0+2) {
     if ((spiAddress0 % 32768) == 0) {
-      //Serial.print("Reading ");
-      //Serial.print(spiAddress0, HEX);
-    }
-
-    //int data = mem0Read(spiAddress0);
-    int data = spiMem0.read(spiAddress0);
+//      Serial.print("Reading ");
+//      Serial.print(spiAddress0, HEX);
+    }
+
+    spiData0 = calcData(spiAddress0, loopPhase, maskPhase);
+    int data = spiMem0.read16(spiAddress0);
     if (data != spiData0) {
       spiErrorCount0++;
       Serial.println("");
       Serial.print("ERROR MEM0: (expected) (actual):");
       Serial.print(spiData0, HEX); Serial.print(":");
-      Serial.println(data, HEX);
+      Serial.print(data, HEX);
+
       delay(100);
     }
+    maskPhase = (maskPhase+1) % 2;

     if ((spiAddress0 % 32768) == 0) {
-      //Serial.print(", data = ");
-      //Serial.println(data, HEX);
-    }
-
-    spiData0 = (spiData0-1) & 0xff;
+//      Serial.print(", data = ");
+//      Serial.println(data, HEX);
+//      Serial.println(String(" loopPhase: ") + loopPhase + String(" maskPhase: ") + maskPhase);
+    }

     // Break out of test once the error count reaches 10
     if (spiErrorCount0 > 10) { break; }
@@ -116,7 +149,8 @@
   }

   if (spiErrorCount0 == 0) { Serial.println("SPI0 TEST PASSED!!!"); }
-
+
+  loopPhase = (loopPhase+1) % 2;

   ///////////////////////////////////////////////////////////////////////
   // MIDI TESTING


Update Beta_1-2-3-um.ino

Update Beta_1-2-3-um.ino


fixed firmware for blendmicro

fixed firmware for blendmicro

--- firmware/BLEFirmataSketch/BLEFirmataSketch.ino
+++ firmware/BLEFirmataSketch/BLEFirmataSketch.ino
@@ -6,6 +6,8 @@
  *    sketch by adding support for BLE.
  *
  */
+
+#define BLE_NAME "BlendMicro"

 #include <boards.h>
 #include <SPI.h>
@@ -577,21 +579,25 @@
   for (byte i=0; i < TOTAL_PINS; i++) {

     // skip pin 8, 9 for BLE Shield
-    if ((i == 8) || (i == 9))
+    //if ((i == 8) || (i == 9))
+    //  continue;
+
+    // skip pin 4, 6, 7 for BlendMicro BLE controll
+    if ((i == 4) || (i == 6) || (i == 7))
       continue;

     // skip SPI pins
     if ( (i==MOSI) || (i==MISO) || (i==SCK) || (i==SS) )
       continue;

-     // Default all to digital pins
-//    if (IS_PIN_ANALOG(i)) {
+    // Default all to digital pins
+    if (IS_PIN_ANALOG(i)) {
       // turns off pullup, configures everything
-//      setPinModeCallback(i, ANALOG);
-//    } else {
+      setPinModeCallback(i, ANALOG);
+    } else {
       // sets the output to 0, configures portConfigInputs
-      setPinModeCallback(i, OUTPUT);
-//    }
+      //setPinModeCallback(i, OUTPUT);
+    }
   }
   // by default, do not report any analog inputs
   analogInputsToReport = 0;
@@ -609,7 +615,7 @@

 void setup()
 {
-//  BleFirmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION);
+  BleFirmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION);

   BleFirmata.attach(ANALOG_MESSAGE, analogWriteCallback);
   BleFirmata.attach(DIGITAL_MESSAGE, digitalWriteCallback);
@@ -630,7 +636,7 @@
   //ble_set_pins(3, 2);

   // Set your BLE Shield name here, max. length 10
-  //ble_set_name("My Name");
+  ble_set_name(BLE_NAME);

   // Init. BLE and start BLE library.
   ble_begin();


Comments modified

Comments modified


Added IP getter

Added IP getter

Now printing the IP to the LCD. Well, probably. Need to test.

--- System/WiFi.ino
+++ System/WiFi.ino
@@ -49,3 +49,38 @@
     delay(100); // ToDo: Insert a DHCP timeout!
   }
 }
+
+bool displayConnectionDetails(void)
+{
+  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
+
+  lcd_clear();
+  lcd_cursor("0", "00");
+
+  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
+  {
+    lcd_print("Unable to retrieve the IP Address!");
+    return false;
+  }
+  else
+  {
+    lcd_print("IP: "); printIPdots(ipAddress);
+    lcd_cursor("1", "00");
+    lcd_print("GW: "); printIPdots(gateway);
+    lcd_cursor("2", "00");
+    lcd_print("DHCP: "); printIPdots(dhcpserv);
+    lcd_cursor("3", "00");
+    lcd_print("DNS: "); printIPdots(dnsserv);
+    return true;
+  }
+}
+
+void printIPdots(uint32_t ip) {
+  lcd_print((uint8_t)(ip >> 24));
+  lcd_print('.');
+  lcd_print((uint8_t)(ip >> 16));
+  lcd_print('.');
+  lcd_print((uint8_t)(ip >> 8));
+  lcd_print('.');
+  lcd_print((uint8_t)(ip));
+}


20150217.1142

--- cmdMULTIsens/src/sketch.ino
+++ cmdMULTIsens/src/sketch.ino
@@ -62,6 +62,7 @@
         Serial.println("D | d : DHT22 calculated Dewpoint");
         Serial.println("E | e : DHT22 calculated Dewpoint2");
         Serial.println("H | h : DHT22 humidity");
+        Serial.println("R | r : DHT22 all sensor data (S,H,D,E)")
         Serial.println("S | s : DHT22 temperature");
         Serial.println("T | t : TMP36 temperature");
         break;
@@ -81,6 +82,21 @@
       case 'h':
         // DHT22 humidity
         Value = dht.readHumidity();
+        Serial.print(Value);
+        break;
+      case 'R':
+      case 'r':
+        // All DHT22 data: Temperature, Humidity, DewPoint, DewPoint2
+        float t = dht.readTemperature();
+        Serial.print(t);
+        Serial.print(", ");
+        float h = dht.readHumidity();
+        Serial.print(h);
+        Serial.print(", ");
+        Value = dht.computeDewPoint(t, h);
+        Serial.print(Value);
+        Serial.print(", ");
+        Value = dht.computeDewPoint2(t, h);
         Serial.print(Value);
         break;
       case 'S':


option of interrupts in demo

option of interrupts in demo

--- library/examples/HardwareDemo/HardwareDemo.ino
+++ library/examples/HardwareDemo/HardwareDemo.ino
@@ -10,9 +10,13 @@
 #include <Adafruit_MCP23017.h>
 #include <Dilbert.h>

+/* #define USE_BUTTON_INTERRUPTS */
+
 Dilbert *badge;

+#ifdef USE_BUTTON_INTERRUPTS
 volatile bool gpio_interrupt;
+#endif

 void setup()
 {
@@ -40,9 +44,12 @@
   badge->neoPixels().setPixelColor(7, Adafruit_NeoPixel::Color(120, 120, 120));
   badge->neoPixels().show();

+#ifdef USE_BUTTON_INTERRUPTS
   /* Button interrupt setup */
   gpio_interrupt = false;
   attachInterrupt(Dilbert::MCP23017_INT_GPIO, handle_int, FALLING);
+#endif
+
   badge->buttons().setCallback(handle_buttons);
 }

@@ -74,18 +81,24 @@
   {
     delay(5);

+#ifdef USE_BUTTON_INTERRUPTS
     if (gpio_interrupt)
     {
       badge->buttons().poll();
       gpio_interrupt = false;
     }
+#else
+    badge->buttons().poll();
+#endif
   }
 }

+#ifdef USE_BUTTON_INTERRUPTS
 void handle_int()
 {
   gpio_interrupt = true;
 }
+#endif

 void handle_buttons(inputtype_t type, IInputDevice *device)
 {


Remove superfluous bus writes and resets, these were causing bad temperature readings on DS18B20 devices

--- firmware/examples/ReadTemp.ino
+++ firmware/examples/ReadTemp.ino
@@ -86,13 +86,7 @@

   present = ds.reset();
   ds.select(addr);
-  ds.write(0xB8,0);         // Recall Memory 0
-  ds.write(0x00,0);         // Recall Memory 0
-
-  present = ds.reset();
-  ds.select(addr);
   ds.write(0xBE, 0);         // Read Scratchpad 0
-  ds.write(0x00,0);         // Recall Memory 0

   Serial.print("  Data = ");
   Serial.print(present, HEX);
@@ -142,4 +136,4 @@
   Serial.print(" Celsius, ");
   Serial.print(fahrenheit);
   Serial.println(" Fahrenheit");
-}+}


Cleanup

Cleanup

--- examples/Export_Demo/myPlant_ESP8266/myPlant_ESP8266.ino
+++ examples/Export_Demo/myPlant_ESP8266/myPlant_ESP8266.ino
@@ -29,7 +29,6 @@
   delay(500);
   Serial.begin(115200);

-
   /**************************************************************
    *
    * Workflow to connect the device to WiFi network.
@@ -47,7 +46,6 @@
    * to connect. User can RESET the board and re-initiate provisioning
    *
    * Explore the Settings.h for parameters
-   * Read the documentation for more info: http://
    *
    **************************************************************/


Update Serial_for_EC_Calibration_m0.ino

Update Serial_for_EC_Calibration_m0.ino

--- OpenCTD_Feather_Adalogger/Support_Code/Serial_for_EC_Calibration_m0.ino
+++ OpenCTD_Feather_Adalogger/Support_Code/Serial_for_EC_Calibration_m0.ino
@@ -1,3 +1,5 @@
+//For use calibrating the Atlas EZO conductivity sensor and circuit.
+
 #include <SoftwareSerial.h>

 SoftwareSerial gtSerial(12, 13); // Arduino RX, Arduino TX


Update dac_fifo_dma.ino

Update dac_fifo_dma.ino

Some extensions and explanations

--- dac_fifo_dma.ino
+++ dac_fifo_dma.ino
@@ -15,9 +15,9 @@
 // but rather a ringbuffer. There is an index to the currently used entry.
 //
 // DMA transfers can be triggered by the FIFO index being at 0 and
-// the FIFO watermark. This code uses these triggers to transfer 4 entries
-// at a time. The lower half of the FIFO (entries 0 - 3) is updated when
-// the FIFO index reaches 4 (the watermark), the upper half (entries 4 - 7)
+// the FIFO watermark. This code uses these triggers to transfer 8 entries
+// at a time. The lower half of the FIFO (entries 0 - 7) is updated when
+// the FIFO index reaches 11 (maximum - 4) (= the watermark), the upper half (entries 8 - 15)
 // is updated when the FIFO index wraps to 0.
 //
 // The FIFO DMA destination is set up using the DMA modulo feature,
@@ -29,6 +29,8 @@

 #include <array>
 #include <DMAChannel.h>
+#define TRACE_VIEW 1
+

 const size_t buffer_alignment = 8;
 std::array<uint16_t, 512> buffer __attribute__ ((aligned (buffer_alignment))) DMAMEM;
@@ -37,11 +39,8 @@
 static_assert(buffer.size() % 8 == 0, "Buffer size must be multiple of DAC buffer.");

 void initBuffer() {
-    for(size_t i = 0; i < buffer.size(); i += 4) {
-        buffer[i+0] = 0;
-        buffer[i+1] = 1000;
-        buffer[i+2] = 2000;
-        buffer[i+3] = 3000;
+    for(size_t i = 0; i < buffer.size(); i ++) {
+        buffer[i] = (int16_t)(2047 * sinf(6.2831853 * i / buffer.size())) +2048;
     }
 }

@@ -58,36 +57,37 @@
     DAC0_C0 |= DAC_C0_DACRFS;     // use 3.3V VDDA as reference voltage
     DAC0_C0 |= DAC_C0_DACBWIEN;   // enable DMA trigger at watermark
     DAC0_C0 |= DAC_C0_DACBTIEN;   // enable DMA trigger at 0
-    DAC0_C1 = DAC_C1_DACBFWM(2) | // watermark for DMA trigger
-                                  // --> DMA triggered when DAC buffer index is 4
+    DAC0_C1 = DAC_C1_DACBFWM(3) | // watermark for DMA trigger
+                                  // --> DMA triggered when DAC buffer index is 4 words away from DACBFUP, that means at index 11 here
+                                  // which gives DMA still enough time to refill the ring buffer from index 0 to 7
               DAC_C1_DMAEN      | // enable DMA
               DAC_C1_DACBFEN;     // enable DAC buffer

-    DAC0_C2 = DAC_C2_DACBFUP(7);  // set buffer size to 8
+    DAC0_C2 = DAC_C2_DACBFUP(15);  // set buffer size to 16

     DAC0_SR &= ~(DAC_SR_DACBFWMF); // clear watermark flag
     DAC0_SR &= ~(DAC_SR_DACBFRTF); // clear top pos flag
     DAC0_SR &= ~(DAC_SR_DACBFRBF); // clear bottom pos flag

-    // Init DAC FIFO with the last 8 buffer elements. This makes setting up the circular
+    // Init DAC FIFO with the last 16 buffer elements. This makes setting up the circular
     // DMA transfer easier.
     using aliased_uint16 = uint16_t __attribute__((__may_alias__));
     using aliased_uint16_vptr = volatile aliased_uint16*;
-    for(size_t i = 0; i < 8; i++) {
-        ((aliased_uint16_vptr) &DAC0_DAT0L)[i] = buffer[buffer.size() - 8 + i];
+    for(size_t i = 0; i < 16; i++) {
+        ((aliased_uint16_vptr) &DAC0_DAT0L)[i] = buffer[buffer.size() - 16 + i];
     }

     // The modulo feature of the DMA controller is used. The destination
     // pointer wraps at +16 bytes.
-    dma.destinationCircular(((volatile uint16_t*) &DAC0_DAT0L), 16);
+    dma.destinationCircular(((volatile uint16_t*) &DAC0_DAT0L), 32);

     dma.TCD->SADDR = buffer.data();
     dma.TCD->SOFF = 2;
     dma.TCD->ATTR_SRC = 1;
-    dma.TCD->NBYTES = 8;
+    dma.TCD->NBYTES = 16;
     dma.TCD->SLAST = -buffer_byte_count;
-    dma.TCD->BITER = buffer_byte_count / 8;
-    dma.TCD->CITER = buffer_byte_count / 8;
+    dma.TCD->BITER = buffer_byte_count / 16;
+    dma.TCD->CITER = buffer_byte_count / 16;

     dma.triggerAtHardwareEvent(DMAMUX_SOURCE_DAC0);
     dma.enable();
@@ -108,9 +108,10 @@
     PDB0_MOD = mod;

     // The hardware doesn't do what the manual claims. The DAC trigger counter is
-    // not reset on PDB counter overflow. Things work correctly, if the PDB mod
-    // is used.
-    PDB0_DACINT0 = mod;                // trigger DAC once per PDB cycle
+    // not reset on PDB counter overflow. Things work correctly, if the PDB mod or
+    // ((PDBmod + 1) / n) -1 which subdivides the PDB cycle by n, are used.
+    // The missing reset on overflow allows even "uneven" divisions...
+    PDB0_DACINT0 = 0x1554;             // trigger DAC 12.00293 times per PDB cycle, just as an example
     PDB0_DACINTC0 = PDB_DACINTC_TOE;   // enable DAC interval trigger

     PDB0_SC |= PDB_SC_LDOK;            // sync buffered PDB registers
@@ -126,11 +127,14 @@
         unsigned dac_out_idx_curr = DAC0_C2 >> 4;
         unsigned dac_val = ((aliased_uint16_vptr) &DAC0_DAT0L)[dac_out_idx_curr];
         interrupts();
-        if(src_idx_prev == src_idx_curr && dac_out_idx_prev == dac_out_idx_curr) continue;
+        if(/*src_idx_prev == src_idx_curr &&*/ dac_out_idx_prev == dac_out_idx_curr) continue;
         src_idx_prev = src_idx_curr;
         dac_out_idx_prev = dac_out_idx_curr;
-        Serial.printf("DMA src idx: %4u   DMA dest idx: %4u   DAC out idx: %4u   DAC value: %4u\n",
+        if (!TRACE_VIEW)
+          Serial.printf("DMA src idx: %4u   DMA dest idx: %4u   DAC out idx: %4u   DAC value: %4u\n",
                       src_idx_curr, dest_idx, dac_out_idx_curr, dac_val);
+        else
+          Serial.println(dac_val); // This allows to see the waveform in the tracer
     }
 }


Added some tmphax in an attempt to get back to the performance of commit b786d3341751833b6a1cde4ed43cd75eb85907ff but it did not work.

--- examples/StepTest/StepTest.ino
+++ examples/StepTest/StepTest.ino
@@ -33,8 +33,11 @@
   }
   ledYellow(1);

-  stepper.init(amisSlaveSelect);
-  stepper.enableDriver();
+  //stepper.init(amisSlaveSelect);
+  //stepper.enableDriver();
+
+  SPIwriteParam(12, 10); // tmphax
+  SPIwriteParam(11, 1); // tmphax
 }

 void loop()
@@ -49,3 +52,117 @@
   // stepper motor.
   delay(1);
 }
+
+/************************ tmphax below *******************************/
+
+//Commands
+#define READ B000  //  CMD2=0
+#define WRITE B100  //  CMD2=1
+
+//Addresses of control registers
+#define WR 0x0
+#define CR0 0x1
+#define CR1 0x2
+#define CR2 0x3
+#define CR3 0x9
+
+//Addresses of status regusters
+#define SR0 0x4
+#define SR1 0x5
+#define SR2 0x6
+#define SR3 0x7
+#define SR4 0xA
+
+//Control register parameters
+#define DIRCTRL 1
+#define NXTP 2
+#define EMC 3
+#define SLAT 4
+#define SLAG 5
+#define PWMF 6
+#define PWMJ 7
+#define SM 8
+#define ESM 9
+#define SLP 10
+#define MOTEN 11
+#define CUR 12
+#define WDEN 13
+#define WDT 14
+
+
+void SPIwriteParam(int param, byte newData)
+{
+  //Before writing a single param we must read what is already at
+  //that address so we can preserve it.
+  byte prevData;
+
+  switch(param)
+  {
+    case DIRCTRL:
+    prevData = SPItransmit(READ, CR1, 0) & B01111111;
+    SPItransmit(WRITE, CR1, prevData | newData<<7);
+    break;
+    case NXTP:
+    prevData = SPItransmit(READ, CR1, 0) & B10111111;
+    SPItransmit(WRITE, CR1, prevData | newData<<6);
+    break;
+    case EMC:
+    prevData = SPItransmit(READ, CR1, 0) & B11111100;
+    SPItransmit(WRITE, CR1, prevData | newData<<0);
+    break;
+    case SLAT:
+    prevData = SPItransmit(READ, CR2, 0) & B11101111;
+    SPItransmit(WRITE, CR2, prevData | newData<<4);
+    break;
+    case SLAG:
+    prevData = SPItransmit(READ, CR2, 0) & B11011111;
+    SPItransmit(WRITE, CR2, prevData | newData<<5);
+    break;
+    case PWMF:
+    prevData = SPItransmit(READ, CR1, 0) & B11110111;
+    SPItransmit(WRITE, CR1, prevData | newData<<3);
+    break;
+    case PWMJ:
+    prevData = SPItransmit(READ, CR1, 0) & B11111011;
+    SPItransmit(WRITE, CR1, prevData | newData<<2);
+    break;
+    case SM:
+    prevData = SPItransmit(READ, CR0, 0) & B00011111;
+    SPItransmit(WRITE, CR0, prevData | newData<<5);
+    break;
+    case ESM:
+    prevData = SPItransmit(READ, CR3, 0) & B11111000;
+    SPItransmit(WRITE, CR3, prevData | newData<<0);
+    break;
+    case SLP:
+    prevData = SPItransmit(READ, CR2, 0) & B10111111;
+    SPItransmit(WRITE, CR2, prevData | newData<<6);
+    break;
+    case MOTEN:
+    prevData = SPItransmit(READ, CR2, 0) & B01111111;
+    SPItransmit(WRITE, CR2, prevData | newData<<7);
+    break;
+    case CUR:
+    prevData = SPItransmit(READ, CR0, 0) & B11100000;
+    SPItransmit(WRITE, CR0, prevData | newData<<0);
+    break;
+    case WDEN:
+    prevData = SPItransmit(READ, WR, 0) & B01111111;
+    SPItransmit(WRITE, WR, prevData | newData<<7);
+    break;
+    case WDT:
+    prevData = SPItransmit(READ, WR, 0) & B10000111;
+    SPItransmit(WRITE, WR, prevData | newData<<3);
+    break;
+  }
+}
+
+byte SPItransmit(int cmd, int adr, byte dataIn)
+{
+    digitalWrite(amisSlaveSelect, LOW);  //take the ss pin low to select the chip
+    SPI.transfer(cmd<<5 | adr);  //send command and address byte
+    byte dataOut = SPI.transfer(dataIn);  //send data byte for write and read data dyte for read
+    digitalWrite(amisSlaveSelect, HIGH); //take the ss pin high to de-select the chip
+    return dataOut;
+}
+


What the hell. long delay

What the hell. long delay

--- interduino/src/sketch.ino
+++ interduino/src/sketch.ino
@@ -16,7 +16,7 @@
 		int ledState = Serial.read();
 		if(ledState == 65){
 			digitalWrite(13, HIGH);
-			delay(7000);
+			delay(10000);
 			digitalWrite(13, LOW);
 		}
 //		if(ledState == 90){