Add files via upload

Add files via upload

more changes

--- arduino/tempLogger/tempLogger.ino
+++ arduino/tempLogger/tempLogger.ino
@@ -1,6 +1,6 @@
 /*
   This code logs the temperature from a DS18B20 temperature sensor
-  and prints the temperature along with a time stamp and unique UUID using a
+  and prints the temperature along with a time stamp and unique A2 using a
   DS3231 Clock and a SparkFun microSD Transflash Breakout
   It also reads and logs the voltage

@@ -9,7 +9,7 @@
    and http://tronixstuff.com/2014/12/01/tutorial-using-ds1307-and-ds3231-real-time-clock-modules-with-arduino/ using the clock
    and https://github.com/OSBSS/TRH/blob/master/TRH.ino main code body
    and https://github.com/jarzebski/Arduino-DS3231 library we use for clock interrupts
-   and https://github.com/sirleech/TrueRandom for UUID
+   and https://github.com/sirleech/TrueRandom for A2
    and https://startingelectronics.org/articles/arduino/measuring-voltage-with-arduino/ for voltage sensor
    and was modified to save the temperature, in fahrenheit, and time data to a microSD card

@@ -66,6 +66,7 @@
 int sum = 0;                    // sum of samples taken
 unsigned int sample_count = 0; // current sample number
 float voltage = 0.0;            // calculated voltage
+int volt_pin = A3;

 // Convert normal decimal numbers to binary coded decimal
 byte decToBcd(byte val)
@@ -114,7 +115,8 @@
   ds.select(addr);
   ds.write(0x44, 1); // start conversion, with parasite power on at the end

-  byte present = ds.reset();
+  //byte present = ds.reset();
+  ds.reset();
   ds.select(addr);
   ds.write(0xBE); // Read Scratchpad

@@ -302,7 +304,8 @@
     }
   dataFile.print(second);
   dataFile.print(",");
-  //dataFile.println(temp);
+  dataFile.print(temp);
+  dataFile.print(",");
   dataFile.close();

 #if DEBUG
@@ -328,43 +331,6 @@
   sleep_disable();
 }

-/*Generate and print UUID to disk
- * https://github.com/sirleech/TrueRandom
- */
-void print_UUID_To_Disk() {
-  File dataFile = SD.open(filename, FILE_WRITE);
-
-  // if the file is available, write to it:
-  if (dataFile) {
-    delay(50);
-    byte uuidNumber[16];
-    TrueRandom.uuid(uuidNumber);
-
-    for (int i=0; i<16; i++) {
-      if (i==4) dataFile.print("-");
-      if (i==6) dataFile.print("-");
-      if (i==8) dataFile.print("-");
-      if (i==10) dataFile.print("-");
-
-      int topDigit = uuidNumber[i] >> 4;
-      int bottomDigit = uuidNumber[i] & 0x0f;
-      // Print high hex digit
-#if DEBUG
-      Serial.print( "0123456789ABCDEF"[topDigit]);
-      Serial.print("0123456789ABCDEF"[bottomDigit]);
-#endif
-      dataFile.print( "0123456789ABCDEF"[topDigit] );
-      // Low hex digit
-      dataFile.print( "0123456789ABCDEF"[bottomDigit] );
-    }
-#if DEBUG
-    Serial.println();
-#endif
-
-    dataFile.close();
-  }
-}
-
 /*
  * Initialize the clock time, the alarm for the clock,
  * and the interrupt associated with it which is used
@@ -419,6 +385,12 @@

 }

+int freeRam ()
+{
+  extern int __heap_start, *__brkval;
+  int v;
+  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
+}

 //continually log data every timeToSleep (specified at the top) number of minutes.
 //go to sleep inbetween. The clock wakes the arduino up every minute to check if
@@ -457,11 +429,6 @@

    //update until we hit the specified number of minutes to run

-#if DEBUG
-  Serial.print("clock.isAlarm1() " + String(clock.isAlarm1(false)) + " && (timeCount < (timeToSleep - 1)) : ");
-  Serial.println(clock.isAlarm1(false) && (timeCount < (timeToSleep - 1)));
-#endif
-
  //check if the desired number of minutes to sleep has elapsed
    if(clock.isAlarm1(false) && (timeCount < (timeToSleep - 1))){
       timeCount++;
@@ -480,7 +447,7 @@
     //https://startingelectronics.org/articles/arduino/measuring-voltage-with-arduino/
     // take a number of analog samples and add them up
     while (sample_count < NUM_VOLTAGE_SAMPLES) {
-        sum += analogRead(A3);
+        sum += analogRead(volt_pin);
         /*REMOVE*/
 #if DEBUG_TO_SD
         write_Text_To_Disk("sum = "+String(sum)+"\n");
@@ -492,11 +459,11 @@
         delay(10);
     }
     // use 5.0 for a 5.0V ADC reference voltage
-    // 5.015V is the calibrated reference voltage
+    //5.015V is the calibrated reference voltage
     voltage = ((float)sum / (float)NUM_VOLTAGE_SAMPLES * 5) / 1024.0;
     sample_count = 0;
     sum = 0;
-    voltage *= 11;
+    voltage *= 11*0.646616541;
     // send voltage for display on Serial Monitor
     // voltage multiplied by 11 when using voltage divider that
     // divides by 11. 11.132 is the calibrated voltage divide
@@ -505,17 +472,24 @@
     Serial.print(voltage);
     Serial.println (" V");
 #endif
-
+
+#if DEBUG_TO_SD
+    write_Text_To_Disk(" "+String(voltage)+"\n");
+#endif
     //we finally hit the specified number of minutes to run, log & reset
     timeCount = 0;
     temperature = getTemp();
     delay(5);

-    //log uuid, temp, voltage
-    print_UUID_To_Disk();
-    write_Text_To_Disk(", ");
+    //temp, voltage
     append_Temp_To_Disk(temperature);
     write_Text_To_Disk(" "+String(voltage)+"\n");
+    freeRam();
+    //free memory
+//    write_Text_To_Disk(", "+String(freeRam()) + "\n");
+#if DEBUG_TO_SD
+    write_Text_To_Disk(" "+String(voltage)+"\n");
+#endif
     voltage = -5000;

 #if DEBUG
@@ -527,8 +501,7 @@

     //clear alarm flag and update time To sleep
     clock.clearAlarm1();
-
-  }
-
-}
-
+
+  }
+}
+


Add a startup message

Add a startup message

On branch parityAndStopBits
modified:   Examples/recover/recover.ino

--- Examples/recover/recover.ino
+++ Examples/recover/recover.ino
@@ -29,6 +29,7 @@
 void setup()
 {
   DEBUG_BEGIN(57600);
+  DEBUG_PRINTLN("Starting recovery in 3 seconds.");
   btSerial.cmdMode2Start(powerPin);

   // Provide some time for the user to start the serial monitor


using RCSwitch to test send/receive 433 between arduinos

--- ookDecoder.ino
+++ ookDecoder.ino
@@ -5,6 +5,14 @@
 // 2010-04-11 Jean-Claude Wippler <jcw@equi4.com>

 //Todo merge back from https://github.com/jcw/jeelib/tree/master/examples/RF12/ookRelay2
+
+//http://playground.arduino.cc/Code/HomeEasy
+
+#include <RCSwitch.h>
+
+RCSwitch mySwitch = RCSwitch();
+int incomingByte = 0;   // for incoming serial data
+

 #include "DecodeOOK.h"
 #include "CrestaDecoder.h"
@@ -88,6 +96,8 @@
    DDRE  &= ~_BV(PE5);
    PORTE &= ~_BV(PE5);
 #endif
+
+    mySwitch.enableTransmit(10);  // Using Pin #10
 }

 void loop () {
@@ -132,5 +142,10 @@
 //        if (fsx.nextPulse(p))
 //            reportSerial("FSX", fsx);
 //    }
+    if (Serial.available() > 0) {
+        // read the incoming byte:
+        incomingByte = Serial.read();
+        mySwitch.send(5393, 24);
+    }
 }


Trying to get STL working for AVR

Trying to get STL working for AVR

--- Synthduino.ino
+++ Synthduino.ino
@@ -1,5 +1,8 @@
 #include "note.h"
 #include "pitches.h"
+//#include <pnew.cpp>
+#include <iterator>
+#include <vector>

 #define BASS 12


Update main.ino

Update main.ino

--- main/main.ino
+++ main/main.ino
@@ -30,13 +30,14 @@
   Serial.begin(115200);
   inputsinit(); // set inputs
   outputsinit(); // set outputs
-  interruptsfunctionsinit(); // set interrupts
+//  interruptsfunctionsinit(); // set interrupts

 }

 void loop() {
   void getMidiIn();
+  void SetMidiOut();
 }

@@ -182,3 +183,188 @@
     }
   }
 }
+
+void setMidiOut(){
+
+  // read both inputs of Jog Wheel
+
+  int a = digitalRead(JogWheelPinA);
+  int b = digitalRead(JogWheelPinB);
+
+  if (a == b ) { // b is leading a (counter-clockwise)
+    valJogWheel--;
+    currentDirection = COUNTER_CLOCKWISE;
+  }
+  else { // a is leading b (clockwise)
+    valJogWheel++;
+    currentDirection = CLOCKWISE;
+  }
+
+  valJogWheel = valJogWheel % CPR; // track 0 to 400
+  if (valJogWheel >= JogWheelToggle) { //Prevent Intempestive Move or flickering
+    controlChange(MidiChannel, 63, 127); // Send CC For JogWheel Activity
+    mappedvalJogWheel = map(abs(valJogWheel), 0, JogWheelMaxval, 0, 127); //map Jog Wheel value from 0 to 127
+    JogWheelActive = 1;
+    if (currentDirection = CLOCKWISE) {
+      controlChange(MidiChannel, 61, mappedvalJogWheel); // Send CC For JogWheel FORWARD Direction
+    }
+    if (currentDirection = COUNTER_CLOCKWISE) {
+      controlChange(MidiChannel, 62, mappedvalJogWheel); // Send CC For JogWheel REWARD Direction
+    }
+    MidiUSB.flush(); // Be sure CC is Send
+    valJogWheel = 0;
+  }
+
+valSongSwitch = digitalRead(SongSwitch); // Read Analog Input
+ if (lastSongSwitch != valSongSwitch){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 40, valSongSwitch); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastSongSwitch = valSongSwitch;
+  }
+valPatternSwitch = digitalRead(PatternSwitch); // Read Analog Input
+ if (lastPatternSwitch != valPatternSwitch){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 41, valPatternSwitch); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastPatternSwitch = valPatternSwitch;
+  }
+valKitSwitch = digitalRead(KitSwitch); // Read Analog Input
+ if (lastKitSwitch != valKitSwitch){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 42, valKitSwitch); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastKitSwitch = valKitSwitch;
+  }
+valInsertSwitch = digitalRead(InsertSwitch); // Read Analog Input
+ if (lastInsertSwitch != valInsertSwitch){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 43, valInsertSwitch); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastInsertSwitch = valInsertSwitch;
+  }
+valDeleteSwitch = digitalRead(DeleteSwitch); // Read Analog Input
+ if (lastDeleteSwitch != valDeleteSwitch){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 44, valDeleteSwitch); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastDeleteSwitch = valDeleteSwitch;
+  }
+valMinusSwitch = digitalRead(MinusSwitch); // Read Analog Input
+ if (lastMinusSwitch != valMinusSwitch){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 45, valMinusSwitch); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastMinusSwitch = valMinusSwitch;
+  }
+valPlusSwitch = digitalRead(PlusSwitch); // Read Analog Input
+ if (lastPlusSwitch != valPlusSwitch){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 46, valPlusSwitch); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastPlusSwitch = valPlusSwitch;
+  }
+valTempoSwitch = digitalRead(TempoSwitch); // Read Analog Input
+ if (lastTempoSwitch != valTempoSwitch){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 47, valTempoSwitch); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastTempoSwitch = valTempoSwitch;
+  }
+valStopSwitch = digitalRead(StopSwitch); // Read Analog Input
+ if (lastStopSwitch != valStopSwitch){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 48, valStopSwitch); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastStopSwitch = valStopSwitch;
+  }
+valPlaySwitch = digitalRead(PlaySwitch); // Read Analog Input
+ if (lastPlaySwitch != valPlaySwitch){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 49, valPlaySwitch); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastPlaySwitch = valPlaySwitch;
+  }
+valRecSwitch = digitalRead(RecSwitch); // Read Analog Input
+ if (lastRecSwitch != valRecSwitch){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 50, valRecSwitch); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastRecSwitch = valRecSwitch;
+  }
+valBankPad = digitalRead(BankPad); // Read Analog Input
+ if (lastBankPad != valBankPad){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 51, valBankPad); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastBankPad = valBankPad;
+  }
+valCrashPad = digitalRead(CrashPad); // Read Analog Input
+ if (lastCrashPad != valCrashPad){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 52, valCrashPad); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastCrashPad = valCrashPad;
+  }
+valCupPad = digitalRead(CupPad); // Read Analog Input
+ if (lastCupPad != valCupPad){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 53, valCupPad); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastCupPad = valCupPad;
+  }
+
+  valRidePad = digitalRead(RidePad); // Read Analog Input Shift Function
+  valKickPad = digitalRead(KickPad);
+  valSnarePad = digitalRead(SnarePad);
+  valClosedHatPad = digitalRead(ClosedHatPad);
+  valOpenHatPad = digitalRead(OpenHatPad);
+
+  if (valRidePad != lastRidePad) {
+    // reset the debouncing timer
+    lastDebounceTime = millis();
+  }
+  if ((millis() - lastRidePadDebounceTime) > debouncePadDelay) { // Only send Midi CC if switch is pressed
+    if (valRidePad != RidePadState) {
+      RidePadState = valRidePad;
+      if (RidePadState == LOW && valKickPad == LOW) {
+        controlChange(MidiChannel, 64, 127); // Send CC
+        MidiUSB.flush(); // Be sure CC is Send
+        lastRidePad = valRidePad;
+      }
+      if (RidePadState == LOW && valSnarePad == LOW) {
+        controlChange(MidiChannel, 65, 127); // Send CC
+        MidiUSB.flush(); // Be sure CC is Send
+        lastRidePad = valRidePad;
+      }
+      if (RidePadState == LOW && valClosedHatPad == LOW) {
+        controlChange(MidiChannel, 66, 127); // Send CC
+        MidiUSB.flush(); // Be sure CC is Send
+        lastRidePad = valRidePad;
+      }
+      if (RidePadState == LOW && valOpenHatPad == LOW) {
+        controlChange(MidiChannel, 67, 127); // Send CC
+        MidiUSB.flush(); // Be sure CC is Send
+        lastRidePad = valRidePad;
+      }
+
+    }
+  }
+valFunctionPad = digitalRead(FunctionPad); // Read Analog Input
+ if (lastFunctionPad != valFunctionPad){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 55, valFunctionPad); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastFunctionPad = valFunctionPad;
+  }
+valKickPad = digitalRead(KickPad); // Read Analog Input
+ if (lastKickPad != valKickPad){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 56, valKickPad); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastKickPad = valKickPad;
+  }
+valSnarePad = digitalRead(SnarePad); // Read Analog Input
+ if (lastSnarePad != valSnarePad){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 57, valSnarePad); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastSnarePad = valSnarePad;
+  }
+valClosedHatPad = digitalRead(ClosedHatPad); // Read Analog Input
+ if (lastClosedHatPad != valClosedHatPad){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 58, valClosedHatPad); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastClosedHatPad = valClosedHatPad;
+  }
+valOpenHatPad = digitalRead(OpenHatPad); // Read Analog Input
+ if (lastOpenHatPad != valOpenHatPad){ // Only send Midi CC if changed is detected
+  controlChange(MidiChannel, 59, valOpenHatPad); // Send CC
+  MidiUSB.flush(); // Be sure CC is Send
+  lastOpenHatPad = valOpenHatPad;
+  }
+
+}


Reordering of includes

Reordering of includes

--- elfi/elfi.ino
+++ elfi/elfi.ino
@@ -73,17 +73,14 @@

 // INCLUDES ====================================================================
 // Cosa library ----------------------------------------------------------------
-#include "Cosa/Trace.hh"
-#include "Cosa/Watchdog.hh"
-#include "Cosa/OutputPin.hh"
-
+#include "Cosa/Driver/NEXA.hh"
 #include "Cosa/INET/DHCP.hh"
 #include "Cosa/INET/DNS.hh"
 #include "Cosa/INET/NTP.hh"
-
-#include "Cosa/Driver/NEXA.hh"
-
+#include "Cosa/OutputPin.hh"
 #include "Cosa/Socket/Driver/W5100.hh"
+#include "Cosa/Trace.hh"
+#include "Cosa/Watchdog.hh"

 // ElFi library ----------------------------------------------------------------
 #include "TimerActivity.h"


Update arduino/OpenROV/OpenROV.ino

Update arduino/OpenROV/OpenROV.ino

add sensor support for cape current - iout

--- arduino/OpenROV/OpenROV.ino
+++ arduino/OpenROV/OpenROV.ino
@@ -8,6 +8,7 @@
 Motors motors(9, 10, 11);
 Command cmd;
 Device vout("vout", 0, vout.analog, vout.in);
+Device iout("iout", 3, iout.analog, iout.in);
 Device light("light", 5, light.analog, light.out);
 Timer time;

@@ -61,9 +62,10 @@
     }
   }

-  // send voltage
+  // send voltage and current
   if (time.elapsed(1000)) {
     vout.send(vout.read());
+    iout.send(iout.read());
     Serial.print("time:");
     Serial.println(millis());
   }


Fixed typo on name of variable

Fixed typo on name of variable

--- arduino/OpenROV/OpenROV.ino
+++ arduino/OpenROV/OpenROV.ino
@@ -33,7 +33,7 @@
 int average = 0;                // the average
 int new_tilt = MIDPOINT;
 int new_p = MIDPOINT;
-int new_c = MIDPOINT;
+int new_s = MIDPOINT;
 int new_v = MIDPOINT;
 int tilt_val = MIDPOINT;
 int p = MIDPOINT;
@@ -96,12 +96,12 @@
     if (p>new_p) new_p += min(smoothingIncriment,p-new_p);
     if (v<new_v) new_v -= min(smoothingIncriment,new_v-v);
     if (v>new_v) new_v += min(smoothingIncriment,v-new_v);
-    if (s<new_c) new_c -= min(smoothingIncriment,new_c-s);
-    if (s>new_c) new_c += min(smoothingIncriment,s-new_c);
+    if (s<new_s) new_s -= min(smoothingIncriment,new_s-s);
+    if (s>new_s) new_s += min(smoothingIncriment,s-new_s);
     if (tilt_val<new_tilt) new_tilt -= min(smoothingIncriment,new_tilt-tilt_val);
     if (tilt_val>new_tilt) new_tilt += min(smoothingIncriment,tilt_val-new_tilt);
     tilt.writeMicroseconds(new_tilt);
-    motors.go(new_p, new_v, new_c);
+    motors.go(new_p, new_v, new_s);
   }

   if (time.elapsed (100)) {
@@ -136,7 +136,7 @@
     Serial.print(",");
     Serial.print(new_v);
     Serial.print(",");
-    Serial.print(new_c);
+    Serial.print(new_s);
     Serial.print(";");
     Serial.print("mtarg:");
     Serial.print(p);


-Changed pin definitions for preliminary register control to not conflict with  the ethernet and sd (SPI) modules

--- controller/src/preliminary_register_driver/preliminary_register_driver.ino
+++ controller/src/preliminary_register_driver/preliminary_register_driver.ino
@@ -1,9 +1,9 @@
 #include "TimerOne.h"

-#define SRCLR_PIN 13  //Active low
-#define SRCLK_PIN 12
-#define RCLK_PIN 11
-#define OE_PIN 10     //Active Low
+#define SRCLR_PIN 9  //Active low
+#define SRCLK_PIN 8
+#define RCLK_PIN 7
+#define OE_PIN 6     //Active Low

 #define VALVES_PER_VALVE_BANK 8
 #define NUM_VALVE_BANKS 2
@@ -12,8 +12,8 @@
 //TODO: Likely change this to come from the pattern file
 #define PATTERN_LENGTH 16

-#define SER1_PIN 8
-#define SER2_PIN 9
+#define SER1_PIN 2
+#define SER2_PIN 3

 int serial_pins[NUM_VALVE_BANKS] = {SER1_PIN, SER2_PIN};


delay between leds decrease by level

delay between leds decrease by level

--- saymon_says/saymon_says.ino
+++ saymon_says/saymon_says.ino
@@ -29,6 +29,7 @@
 const int statePlay = 1;
 const int stateEnd = 2;
 const int stateNewLevel = 3;
+const int statePressedOk = 4;

 int level;
 int state;
@@ -49,6 +50,11 @@
   state = stateNewLevel;

   randomSeed(analogRead(A5));
+
+  //initial set
+  for (int i = 0 ; i < level; i++) {
+    sequence[i] = redButton;
+  }

 }

@@ -78,39 +84,39 @@
       if (button == 2) sequence[i] = yellowButton;
       if (button == 3) sequence[i] = blueButton;
     }
-
+
     //play
     displayWrite("memorizza");
     for (int i = 0; i < level; i++) {
-    int button = sequence[i];
-      delay(300);
-      digitalWrite(button, HIGH);
+      int button = sequence[i];
       if (button == redButton) { tone(tonePin, NOTE_C4); digitalWrite(redLed, HIGH); }
       if (button == greenButton) { tone(tonePin, NOTE_D4); digitalWrite(greenLed, HIGH); }
       if (button == yellowButton) { tone(tonePin, NOTE_E4); digitalWrite(yellowLed, HIGH); }
       if (button == blueButton) { tone(tonePin, NOTE_F4); digitalWrite(blueLed, HIGH); }

-      delay(1000);
+      int maxMapLevel = 16;
+      int mapLevel = level;
+      if (mapLevel > maxMapLevel) {
+        mapLevel = maxMapLevel;
+      }
+      int delayMemorization = 500 + map(mapLevel, 1, maxMapLevel, 800, 0);
+
+      //Serial.println(delayMemorization);
+
+      delay(delayMemorization);
       noTone(tonePin);
       allLedOff();
+      delay(50); //to see two or more equal color in sequence

     }
     state = statePlay;
     displayWrite("ripeti");
     currentPlayingSeqIndex = 0;

-  }
+  }

-
-  /*
-  Serial.print(analogRead(redButton));
-  Serial.print(analogRead(greenButton));
-  Serial.print(analogRead(yellowButton));
-  Serial.println(analogRead(blueButton));
-  */
-
-    if (pressed(redButton) && (state == statePlay)) {
-     checkPressing(redLed, NOTE_C4, redButton);
+  if (pressed(redButton) && (state == statePlay)) {
+    checkPressing(redLed, NOTE_C4, redButton);
   } else if (pressed(greenButton) && (state == statePlay)) {
     checkPressing(greenLed, NOTE_D4, greenButton);
   } else if (pressed(yellowButton) && (state == statePlay)) {
@@ -122,9 +128,11 @@
 }

 void checkPressing(int led, unsigned int note, int button) {
-       digitalWrite(led, HIGH);
-       tone(tonePin, note);
+        digitalWrite(led, HIGH);
+         tone(tonePin, note);
+
        if (sequence[currentPlayingSeqIndex] == button) {
+
          displayWrite("OK !");
          currentPlayingSeqIndex ++;
          if (currentPlayingSeqIndex >= level) {
@@ -134,10 +142,10 @@
          displayWrite("sbagliato");
          state = stateEnd;
        }
-      delay(1000);
-      noTone(tonePin);
-      allLedOff();
-
+                delay(1000);
+          noTone(tonePin);
+          allLedOff();
+
 }

 boolean pressed(int button) {


corrected sketch for ds18b20 temperature sensor

--- ds18b20_temp_sensor/ds18b20_temp_sensor.ino
+++ ds18b20_temp_sensor/ds18b20_temp_sensor.ino
@@ -1,62 +1,78 @@
 #include <OneWire.h>

-// DS18S20 Temperature chip i/o
-OneWire ds(10);  // on pin 10
+// OneWire DS18S20, DS18B20, DS1822 Temperature Example
+//
+// http://www.pjrc.com/teensy/td_libs_OneWire.html
+//
+// The DallasTemperature library can do all this work for you!
+// http://milesburton.com/Dallas_Temperature_Control_Library
+
+OneWire  ds(10);  // on pin 10 (a 4.7K resistor is necessary)

 void setup(void) {
-  // initialize inputs/outputs
-  // start serial port
-  Serial.begin(9600);
+  Serial.begin(115200);
 }

 void loop(void) {
   byte i;
   byte present = 0;
+  byte type_s;
   byte data[12];
   byte addr[8];
-  int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;
+  float celsius, fahrenheit;
+
   if ( !ds.search(addr)) {
-      Serial.print("No more addresses.\n");
-      ds.reset_search();
+    Serial.println("No more addresses.");
+    Serial.println();
+    ds.reset_search();
+    delay(250);
+    return;
+  }
+
+  Serial.print("ROM =");
+  for( i = 0; i < 8; i++) {
+    Serial.write(' ');
+    Serial.print(addr[i], HEX);
+  }
+
+  if (OneWire::crc8(addr, 7) != addr[7]) {
+      Serial.println("CRC is not valid!");
       return;
   }
-
-  Serial.print("R=");
-  for( i = 0; i < 8; i++) {
-    Serial.print(addr[i], HEX);
-    Serial.print(" ");
-  }
-
-  if ( OneWire::crc8( addr, 7) != addr[7]) {
-      Serial.print("CRC is not valid!\n");
+  Serial.println();
+
+  // the first ROM byte indicates which chip
+  switch (addr[0]) {
+    case 0x10:
+      Serial.println("  Chip = DS18S20");  // or old DS1820
+      type_s = 1;
+      break;
+    case 0x28:
+      Serial.println("  Chip = DS18B20");
+      type_s = 0;
+      break;
+    case 0x22:
+      Serial.println("  Chip = DS1822");
+      type_s = 0;
+      break;
+    default:
+      Serial.println("Device is not a DS18x20 family device.");
       return;
-  }
-
-  if ( addr[0] == 0x10) {
-      Serial.print("Device is a DS18S20 family device.\n");
-  }
-  else if ( addr[0] == 0x28) {
-      Serial.print("Device is a DS18B20 family device.\n");
-  }
-  else {
-      Serial.print("Device family is not recognized: 0x");
-      Serial.println(addr[0],HEX);
-      return;
-  }
+  }

   ds.reset();
   ds.select(addr);
-  ds.write(0x44,1);         // start conversion, with parasite power on at the end
-
+  ds.write(0x44, 1);        // start conversion, with parasite power on at the end
+
   delay(1000);     // maybe 750ms is enough, maybe not
   // we might do a ds.depower() here, but the reset will take care of it.
-
+
   present = ds.reset();
   ds.select(addr);
   ds.write(0xBE);         // Read Scratchpad

-  Serial.print("P=");
-  Serial.print(present,HEX);
+  Serial.print("  Data = ");
+  Serial.print(present, HEX);
   Serial.print(" ");
   for ( i = 0; i < 9; i++) {           // we need 9 bytes
     data[i] = ds.read();
@@ -64,33 +80,33 @@
     Serial.print(" ");
   }
   Serial.print(" CRC=");
-  Serial.print( OneWire::crc8( data, 8), HEX);
-  LowByte = data[0];
-  HighByte = data[1];
-  TReading = (HighByte << 8) + LowByte;
-  SignBit = TReading & 0x8000;  // test most sig bit
-  if (SignBit) // negative
-  {
-    TReading = (TReading ^ 0xffff) + 1; // 2's comp
+  Serial.print(OneWire::crc8(data, 8), HEX);
+  Serial.println();
+
+  // Convert the data to actual temperature
+  // because the result is a 16 bit signed integer, it should
+  // be stored to an "int16_t" type, which is always 16 bits
+  // even when compiled on a 32 bit processor.
+  int16_t raw = (data[1] << 8) | data[0];
+  if (type_s) {
+    raw = raw << 3; // 9 bit resolution default
+    if (data[7] == 0x10) {
+      // "count remain" gives full 12 bit resolution
+      raw = (raw & 0xFFF0) + 12 - data[6];
+    }
+  } else {
+    byte cfg = (data[4] & 0x60);
+    // at lower res, the low bits are undefined, so let's zero them
+    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
+    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
+    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
+    //// default is 12 bit resolution, 750 ms conversion time
   }
-  Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25
-
-  Whole = Tc_100 / 100;  // separate off the whole and fractional portions
-  Fract = Tc_100 % 100;
-
-
-  if (SignBit) // If its negative
-  {
-     Serial.print("-");
-  }
-  Serial.print(Whole);
-  Serial.print(".");
-  if (Fract < 10)
-  {
-     Serial.print("0");
-  }
-  Serial.print(Fract);
-
-  Serial.print("\n");
-  Serial.println();
+  celsius = (float)raw / 16.0;
+  fahrenheit = celsius * 1.8 + 32.0;
+  Serial.print("  Temperature = ");
+  Serial.print(celsius);
+  Serial.print(" Celsius, ");
+  Serial.print(fahrenheit);
+  Serial.println(" Fahrenheit");
 }


Fix a bug where it was possible to get stuck

in middle of a macro loop

--- n64_controller_v3/n64_controller_v3.ino
+++ n64_controller_v3/n64_controller_v3.ino
@@ -330,7 +330,7 @@
           loopMacro = 0;
           timesToLoop = 0;
           loopCounter = 0;
-          isInputting = false;
+          //isInputting = false;
           macroIndex = serial_rx_buffer[0] - startingMacroIndex;
           /*
             Serial.print("Received ");
@@ -376,7 +376,7 @@
     if (macroInputsToRun != 0) {
       if (macroInputsToRun > currentMacroIndexRunning)
       {
-        if (timesToLoop >= loopCounter) {
+        if (loopCounter <= timesToLoop) {
           for (unsigned int currentInputIndex = 0; currentInputIndex < sizeof(serial_rx_buffer); currentInputIndex++) {
             current_macro_input[currentInputIndex] = macro_buffer[currentMacroIndexRunning][currentInputIndex];
             //Serial.println(macro_buffer[currentMacroIndexRunning][currentInputIndex]);
@@ -395,7 +395,7 @@
           if (timesToLoop <= 0) {
             //
           }
-          if (timesToLoop > 0 && timesToLoop >= loopCounter) {
+          if (timesToLoop > 0 && loopCounter <= timesToLoop) {
             loopCounter++;
           }
         }


Clean up code and remove jupyter integration

--- code/lissajous/lissajous.ino
+++ code/lissajous/lissajous.ino
@@ -27,31 +27,41 @@
   servox.attach(6);  // attaches the servo on pin 9 to the servo object
   servoy.attach(7);  // attaches the servo on pin 10 to the servo object
   pinMode(3, INPUT_PULLUP); // Starting button input
-  Serial.begin(9600);
+//  Serial.begin(9600);
+  randomSeed(analogRead(0));
+  servox.write(90);
+  servoy.write(90);
 }

 void loop() {
   // Wait for a button press.
   while (digitalRead(3) != 0) {
-    if (Serial.available() > 0 ) {
-      facter = Serial.parseFloat();
-      starter = Serial.parseFloat();
-      circle_size = Serial.parseFloat();
-      circle_speed = Serial.parseFloat();
-      circle_start = Serial.parseFloat();
-      min_x = Serial.parseFloat();
-      min_y = Serial.parseFloat();
-      scale = Serial.parseFloat();
-      Serial.print(facter);
-      Serial.println();
-    }
-    servox.write(90);
-    servoy.write(90);
+//    if (Serial.available() > 0 ) {
+//      facter = Serial.parseFloat();
+//      starter = Serial.parseFloat();
+//      circle_size = Serial.parseFloat();
+//      circle_speed = Serial.parseFloat();
+//      circle_start = Serial.parseFloat();
+//      min_x = Serial.parseFloat();
+//      min_y = Serial.parseFloat();
+//      scale = Serial.parseFloat();
+//      Serial.print(facter);
+//      Serial.println();
+
+    facter = random(3)/1.0 + 1.0 + random(301)/10000.0;
+    starter = random(315)/100.0;
+    circle_size = random(20, 100)/100.0;
+    circle_speed = random(4)/1.0 - 0.05 + random(101)/1000.0;
+    circle_start = random(315)/100.0;
+    min_x = 0.0;
+    min_y = 0.0;
+    scale = 1.5;
   }
-
+  servox.write(90);
+  servoy.write(90);
+  delay(5000);
   // Main loop, to 90% decay in amplitude of the movements.
-  first_loop = true;
-  decay = 60000;
+  decay = 60000.0;

   for(pos = int(decay*0.1); pos < decay; pos += 1)
   {
@@ -64,12 +74,6 @@
     servox.write(adjx);
     servoy.write(adjy);

-    // This gives us time to drop the pen
-    if (first_loop) {
-      first_loop = false;
-    }
-
     delay(1); // Just for consistent speed.
   }
-  delay(5000);
 }


We should validate GGA/RMC sentences coming in on NMEA before blindly trying to parse them.

--- mega/mega.ino
+++ mega/mega.ino
@@ -2110,12 +2110,15 @@
     #endif
     b_string = gps_read_buffer;
     gps_read_buffer = nmea_read_buffer;
-    parse_gps_buffer_as_gga();
+    if(validate_and_maybe_remediate_gps_buffer())
+    {
+      parse_gps_buffer_as_gga();
+      if(gps_valid)
+      {
+        nmea_gga_timestamp = millis();
+      }
+    }
     gps_read_buffer = b_string;
-    if(gps_valid)
-    {
-      nmea_gga_timestamp = millis();
-    }
   }

   else if(nmea_read_buffer.indexOf(F("RMC")) == 3)
@@ -2125,12 +2128,15 @@
     #endif
     b_string = gps_read_buffer;
     gps_read_buffer = nmea_read_buffer;
-    parse_gps_buffer_as_rmc();
+    if(validate_and_maybe_remediate_gps_buffer())
+    {
+      parse_gps_buffer_as_rmc();
+      if(gps_valid)
+      {
+        nmea_rmc_timestamp = millis();
+      }
+    }
     gps_read_buffer = b_string;
-    if(gps_valid)
-    {
-      nmea_rmc_timestamp = millis();
-    }
   }

   //


Inclui implementação código do Arduino referente às funcionalidades 2 e 3 sem usar interrupções.

--- arduino/casa_inteligente/casa_inteligente.ino
+++ arduino/casa_inteligente/casa_inteligente.ino
@@ -50,7 +50,6 @@
 #define TP_AR_TEMPERATURA "casa/ar/temperatura"
 #define TP_AR_STATUS "casa/ar/status"

-//float temperatura;
 int status_ar = LOW;

 DHT dht(PINO_SENSOR_TEMP, TIPO_SENSOR);
@@ -58,9 +57,32 @@

 // Configurações da funcionalidade 02 - Acionamento automático das luzes da garagem

-
-
-// Configurações da funcionalidade 03 - Alarme com utilização de sensor de movimento
+//Carrega a biblioteca do sensor ultrassonico
+#include <Ultrasonic.h>
+
+//Define os pinos para o trigger e echo
+#define PINO_TRIGGER 8
+#define PINO_ECHO 9
+#define PINO_LED_OCUPACAO 12
+// Distância que define se a garagem está ocupada
+#define DISTANCIA_OCUPADA 10
+#define TP_GARAGEM_STATUS "casa/garagem/status"
+
+int status_garagem = LOW;
+
+
+Ultrasonic ultrasonic(PINO_TRIGGER, PINO_ECHO);
+
+// Configurações da funcionalidade 03 - Alarme com utilização de sensor de movimento e buzzer
+
+#define PINO_BUZZER 10
+#define PINO_SENSOR_MOV 3
+#define PINO_LED_ALARME 7
+#define DELAY_SONORO 500
+#define FREQ_BUZZER 1500
+#define TP_ALARME_STATUS "casa/alarme/status"
+
+boolean alarme_disparado = false;

 void setup() {
@@ -68,10 +90,14 @@

   conectar_ethernet();

-//  conectar_mosquitto();
-
   // Setup da funcionalidade 01
   setup_ar();
+
+  // Setup da funcionalidade 02
+  setup_garagem();
+
+  // Setup da funcionalidade 03
+  setup_alarme();
 }

 void loop() {
@@ -80,8 +106,24 @@
     conectar_mosquitto();
   }
   client.loop();
+
   ler_temperatura();
-  Narcoleptic.delay(5000);
+
+  medir_distancia();
+
+  verificar_movimento();
+
+  if (alarme_disparado) {
+    //Ligando o buzzer com uma frequencia de 1500 hz.
+    tone(PINO_BUZZER, FREQ_BUZZER);
+    delay(DELAY_SONORO);
+
+    //Desligando o buzzer.
+    noTone(PINO_BUZZER);
+    delay(DELAY_SONORO);
+  }
+
+  delay(500);
 }

 // Metodo para manipular mensagens recebidas do broker
@@ -139,6 +181,60 @@
 }

+// Métodos da funcionalidade 02
+
+void setup_garagem() {
+  pinMode(PINO_LED_OCUPACAO, OUTPUT);
+}
+
+float medir_distancia() {
+  long tempo = ultrasonic.timing();
+  int distancia = ultrasonic.convert(tempo, Ultrasonic::CM);
+
+  if (distancia <= DISTANCIA_OCUPADA) {
+    informar_ocupacao(HIGH);
+  } else {
+    informar_ocupacao(LOW);
+  }
+}
+
+void informar_ocupacao(int status) {
+  if (status_garagem != status) {
+    digitalWrite(PINO_LED_OCUPACAO, status);
+    status_garagem = status;
+    Serial.println("mudei um status");
+    client.publish(TP_GARAGEM_STATUS, status == 0 ? "0" : "1");
+  }
+}
+
+
+// Métodos da funcionalidade 03
+
+
+void setup_alarme() {
+  pinMode(PINO_SENSOR_MOV, INPUT);
+  pinMode(PINO_LED_ALARME, OUTPUT);
+  pinMode(PINO_BUZZER, OUTPUT);
+}
+
+void acionar_alarme() {
+  if (!alarme_disparado) {
+    client.publish(TP_ALARME_STATUS, "1");
+    alarme_disparado = true;
+    digitalWrite(PINO_LED_ALARME, HIGH);
+  } else {
+    digitalWrite(PINO_LED_ALARME, LOW);
+  }
+}
+
+void verificar_movimento() {
+  Serial.println(digitalRead(PINO_SENSOR_MOV));
+  if (digitalRead(PINO_SENSOR_MOV) == HIGH) {
+    acionar_alarme();
+  }
+}
+
+
 // Métodos auxiliares

 void conectar_mosquitto() {


changed the pot ranges

changed the pot ranges

--- proj/ledvo_lounge_final/ledvo_lounge_final.ino
+++ proj/ledvo_lounge_final/ledvo_lounge_final.ino
@@ -213,7 +213,6 @@

     if(anim_switch) {
       reset_all();
-      FastLED.show();
       anim_switch = false;
     }


issue #7 testing input array

issue #7 testing input array

--- arduino_control/arduino_control.ino
+++ arduino_control/arduino_control.ino
@@ -265,44 +265,20 @@
 }

 //******************************
-// CURRENT DATA READ
+// POSITION DATA READ
 //******************************
-float currentDataRead()
-{
-  current_data = 0;
-  unsigned char len = 0;
-  unsigned char buf[8];
-
-  // clear the string:
-  sync();
-
-  if (CAN_MSGAVAIL == CAN.checkReceive())           // check if data coming
-  {
-    CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf
-
-    unsigned int canId = CAN.getCanId();
-
-    Serial.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[2];
-    current_data <<= 8;
-    current_data = current_data | buf[3];
-    // current_data <<= 8;
-    // current_data = current_data | buf[6];
-    // current_data <<= 8;
-    // current_data = current_data | buf[7];
+void positionDataRead(double buf)
+{
+    encoder_data = buf[4];
+    encoder_data <<= 8;
+    encoder_data = encoder_data | buf[5];
+
+    Serial.print("Encoder: ");
+    Serial.println(encoder_data);

     // Serial.println(current_data);

     return(current_data);
-  }
 }

 //****************
@@ -348,20 +324,10 @@
         // }
         // Serial.println();
         break;
+
+      // ID 321 message has information sent by the amplification board
       case 0x321:
-        // Serial.println("-----------------------------");
-        // Serial.print("AMPLIFICACAO: ");
-        // Serial.println(canId, HEX);
-
-        // for(int i = 0; i<len; i++)    // print the data
-        // {
-        //     Serial.print(buf[i], HEX);
-        //     Serial.print("\t");
-        // }
-        // Serial.println();
-        encoder_data = buf[4];
-        encoder_data <<= 8;
-        encoder_data = encoder_data | buf[5];
+        encoderDataRead();

         // // load cell information is read from buf[1], buf[2] and buf[3] and converted to decimal
         loadcell_data = buf[1];
@@ -374,11 +340,9 @@
 //        Serial.println(loadcell_data);

 //
-        Serial.print("Encoder: ");
-        Serial.println(encoder_data);
         break;
       }
-      return(encoder_data);
+      // return(encoder_data);
   }
 }

@@ -394,8 +358,9 @@
       break;
     case Operational:
       // amplificationBoardDataRead();
-//       currentDataRead();
-//    reads CAN networks
+      //       currentDataRead();
+
+    //    reads CAN BUS
     CANDataRead();


-added author

-added author

--- channelswitcher/channelswitcher.ino
+++ channelswitcher/channelswitcher.ino
@@ -1,3 +1,8 @@
+/*
+VTX Channel Switcher
+Author: Markus Wilhelm
+*/
+
 #include "BasicSerial3.h"

 // timeout in centi seconds after which servo signal will no longer evaluated and a restart is required


Made things a bit simpler

Made things a bit simpler

--- otto/otto.ino
+++ otto/otto.ino
@@ -47,43 +47,6 @@
             delay(DELAY);
         }

-        // rotate hip forward
-        for (i = 0; i < MOVE; ++i) {
-            leftHip.writeMicroseconds(LEFT_HIP_MIDDLE+i);
-            delay(DELAY);
-        }
-
-        for (i = 0; i < MOVE; ++i) {
-            rightAnkle.writeMicroseconds(RIGHT_ANKLE_MIDDLE - MOVE*FACTOR+i*FACTOR);
-            leftAnkle.writeMicroseconds(LEFT_ANKLE_MIDDLE - MOVE+i);
-            delay(DELAY);
-        }
-
-        for (i = 0; i < MOVE; ++i) {
-            rightAnkle.writeMicroseconds(RIGHT_ANKLE_MIDDLE+i);
-            leftAnkle.writeMicroseconds(LEFT_ANKLE_MIDDLE+i*FACTOR);
-            leftHip.writeMicroseconds(LEFT_HIP_MIDDLE+MOVE-i);
-            delay(DELAY);
-        }
-
-        for (i = 0; i < MOVE; ++i) {
-            rightHip.writeMicroseconds(RIGHT_HIP_MIDDLE-i);
-            leftHip.writeMicroseconds(LEFT_HIP_MIDDLE-i);
-            delay(DELAY);
-        }
-
-        for (i = 0; i < MOVE; ++i) {
-            rightAnkle.writeMicroseconds(RIGHT_ANKLE_MIDDLE+MOVE-i);
-            leftAnkle.writeMicroseconds(LEFT_ANKLE_MIDDLE+MOVE*FACTOR-i*FACTOR);
-            delay(DELAY);
-        }
-
-        for (i = 0; i < MOVE; ++i) {
-            rightAnkle.writeMicroseconds(RIGHT_ANKLE_MIDDLE-i*FACTOR);
-            leftAnkle.writeMicroseconds(LEFT_ANKLE_MIDDLE-i);
-            delay(DELAY);
-        }
-
         running = true;
     }

@@ -92,13 +55,6 @@

 void stepForward() {
     int i = 0;
-
-    // rotate to center
-    for (i = 0; i < MOVE; ++i) {
-        rightHip.writeMicroseconds(RIGHT_HIP_MIDDLE - MOVE + i);
-        leftHip.writeMicroseconds(LEFT_HIP_MIDDLE - MOVE + i);
-        delay(DELAY);
-    }

     // rotate left
     for (i = 0; i < MOVE; ++i) {
@@ -138,5 +94,12 @@
         leftAnkle.writeMicroseconds(LEFT_ANKLE_MIDDLE - i);
         delay(DELAY);
     }
+
+    // rotate to center
+    for (i = 0; i < MOVE; ++i) {
+        rightHip.writeMicroseconds(RIGHT_HIP_MIDDLE - MOVE + i);
+        leftHip.writeMicroseconds(LEFT_HIP_MIDDLE - MOVE + i);
+        delay(DELAY);
+    }
 }


Misc fixed.

Misc fixed.

* All params need to be accounted for with Phant.
* Don't forget to actually set lastUpdateTime. :)

--- water_heater_monitor/water_heater_monitor.ino
+++ water_heater_monitor/water_heater_monitor.ino
@@ -33,7 +33,9 @@

     data_index = 0;
     eagle_data[data_index] = '\0';
-    postToPhant();
+    if (postToPhant()) {
+      lastUpdateTime = now;
+    }
   }

   // Delays allow the ESP8266 to perform critical tasks
@@ -57,7 +59,9 @@
       unsigned long now = millis();

       if ((now > lastUpdateTime + 60000 || now < lastUpdateTime) && strncmp(eagle_data, "RUNTIME", 7) != 0 && strchr(eagle_data, ':') != NULL) {
-        postToPhant();
+        if (postToPhant()) {
+          lastUpdateTime = now;
+        }
       }

       // Reset the data
@@ -135,9 +139,17 @@
     phant.add("fault",   strtok_r(NULL, " ", &tokenptr));
   } else {
     phant.add("runtime", "0:00");
+    phant.add("coll_t",  "");
+    phant.add("stor_t",  "");
+    phant.add("diff_t",  "");
+    phant.add("hili_t",  "");
+    phant.add("aux_1",   "");
+    phant.add("aux_2",   "");
     phant.add("pump",    "OFF");
     phant.add("uplim",   "OFF");
+    phant.add("fault",   "");
   }
+
   phant.add("ambient_t", dht.readTemperature(true));

   // Now connect to data.sparkfun.com, and post our data:


unsuccessful hacking here

unsuccessful hacking here

--- src/sketch.ino
+++ src/sketch.ino
@@ -1,41 +1,39 @@
-#define LED_PIN 13
-#define BLINK_DELAY 75
-
 #include "serLCD.h"

 #define LCD_PIN 2
+#define LED_PIN 13
+#define BLINK_DELAY 75

 serLCD lcd(LCD_PIN);

 void setup() {
-  delay(1000);
+  delay(500);

+  Serial.begin(19200);
   lcd.clear();
-
-  delay(100);
-
   lcd.print("  MediBot 5000");
-
-  delay(1000);

   for (int i = 0; i < 4; i++) {
     blink();
   }

-  ledOn();
-
-  delay(1000);
-
-  ledOff();
-
   lcd.setCursor(2,1);
-  lcd.print("millis: ");
 }

+String vfo = "";
+char character;
+
 void loop() {
-  lcd.setCursor(2, 9);
-  lcd.print(millis());
-  delay(1000);
+  Serial.print("fa;");
+  delay(250);
+
+  while (Serial.available() > 0) {
+    character = Serial.read();
+    lcd.listen();
+    lcd.print(character);
+    lcd.print(':');
+  }
+
 }

 void ledOn() {


Moved PID_v1.h include out of "own libraries" since it isn't mine

--- ballbot.ino
+++ ballbot.ino
@@ -30,6 +30,7 @@
 #include <SPI.h>
 #include <EEPROM.h>
 #include <FrequencyTimer2.h>   // Built into teensy core
+#include <PID_v1.h>

 /* own libraries */
 #include <EEPROMAnything.h>    // see https://github.com/brianchen118/Team-PI-Lib/tree/master/EEPROMAnything
@@ -38,7 +39,6 @@
 #include <fastTrig.h>          // https://github.com/brianchen118/fastTrig
 #include <omnidrive.h>         // see https://github.com/brianchen118/omnidrive
 #include <sensorfusion.h>      // see https://github.com/brianchen118/sensorfusion
-#include <PID_v1.h>
 #include "balanceController.h"
 #include "locationCalculator.h"
 #include "macros.h"


code can now arm the APM and set various throttles

--- drone/WebServerESC/WebServerESC.ino
+++ drone/WebServerESC/WebServerESC.ino
@@ -7,7 +7,7 @@
 #include <Servo.h>
 #include <WiServer.h>

-byte thestart = 0;
+byte armed = 0;

 #define WIRELESS_MODE_INFRA	1
 #define WIRELESS_MODE_ADHOC	2
@@ -42,7 +42,35 @@

 // Webpage in flash memory
 const prog_char htmlHead[] PROGMEM = {"<meta http-equiv=""content-type"" content=""text/html; charset=utf-8"" /><title>OneButtonAlert Device</title>"};
-const prog_char htmlMotor[] PROGMEM = {"<select name=""OPERATION"" id=""OPERATION"" style=""font-size:50px""><option value=""OFF"">Turn ON</option><option value=""ON"">Turn OFF</option><option value=""90"">90</option></select>
<input type=submit value=SUBMIT style=""font-size:50px"">
</form>

"};
+const prog_char htmlMotor[] PROGMEM = {
+"<select name=""OPERATION"" id=""OPERATION"" style=""font-size:50px""><option value=""reset"">Reset Motors</option><option value=""arm"">Arm Motors</option><option value=""throttle25"">Throttle 25</option><option value=""throttle50"">Throttle 50</option><option value=""throttle75"">Throttle 75</option></select>
<input type=submit value=SUBMIT style=""font-size:50px"">
</form>

"};
+
+// time of last arming
+unsigned long lastArmTime = 0;
+
+// wifi connection state
+U8 state = 0;
+
+// These are the motors
+Servo throttleMotor;
+Servo pitchMotor;
+Servo yawMotor;
+Servo rollMotor;
+
+/*
+Servo angle : PWM range
+40 : 0    - 1230
+60 : 1231 - 1360
+70 : 1361 - 1490
+90 : 1491 - 1620
+100: 1621 - 1749
+120: 1750 +
+*/
+// speed is 0-100
+int servoAngleForSpeed(int speed)
+{
+    return map(speed, 0, 100, 40, 120);
+}

 // This is our page serving function that generates web pages
 boolean sendMyPage(char* URL)
@@ -54,68 +82,80 @@
         return true;
     }

-    if (strcmp (URL, "/?OPERATION=OFF") == 0) {
-        thestart = 1;
-        _webpageHelper();
-        move_to_start();
-        return (true);
-    }
-
-
-    if (strcmp (URL, "/?OPERATION=ON") == 0) {
-        thestart = 0;
-        _webpageHelper();
-        move_to_end();
-        return (true);
-    }
-
-
-    if (strcmp (URL, "/?OPERATION=90") == 0) {
-        thestart = 0;
+    if (strcmp (URL, "/?OPERATION=reset") == 0) {
+        resetMotors();
+        _webpageHelper();
+        return (true);
+    }
+
+    if (strcmp (URL, "/?OPERATION=arm") == 0) {
+        arm();
+        _webpageHelper();
+        return (true);
+    }
+
+    if (strcmp (URL, "/?OPERATION=throttle25") == 0) {
+        throttleMotor.write(servoAngleForSpeed(25));
+        _webpageHelper();
+        return (true);
+    }
+
+    if (strcmp (URL, "/?OPERATION=throttle50") == 0) {
+        throttleMotor.write(servoAngleForSpeed(50));
         _webpageHelper();
-        move_to_ninty();
-        return (true);
-    }
-
+        return (true);
+    }
+
+    if (strcmp (URL, "/?OPERATION=throttle75") == 0) {
+        throttleMotor.write(servoAngleForSpeed(75));
+        _webpageHelper();
+        return (true);
+    }
+
+
+
+    Serial.println("url not found");
     // URL not found
     return false;
 }

-int i = 0;     // Loop counter
-
-// This is our motor.
-Servo myMotor;
-
-void arm(){
-    // arm the speed controller, modify as necessary for your ESC
-    setSpeed(0);
-    delay(3000); //delay 1 second,  some speed controllers may need longer
-}
-
-void setSpeed(int speed){
-      // speed is from 0 to 100 where 0 is off and 100 is maximum speed
-      //the following maps speed values of 0-100 to angles from 0-180,
-     // some speed controllers may need different values, see the ESC instructions
-     int angle = map(speed, 0, 100, 0, 180);
-     myMotor.write(angle);
-}
-
-void setup() {
-    WiServer.enableVerboseMode(true);
-
-    // Put the motor to Arduino pin #9
-    myMotor.attach(8);
-    arm();
-    myMotor.write(70);
-    // Required for I/O from Serial monitor
+void resetMotors()
+{
+    throttleMotor.write(servoAngleForSpeed(0));
+    yawMotor.write(servoAngleForSpeed(50));
+    rollMotor.write(servoAngleForSpeed(50));
+    pitchMotor.write(servoAngleForSpeed(50));
+}
+
+void setup()
+{
+     // Required for I/O from Serial monitor
     Serial.begin(57600);
-     Serial.println("Starting WiFi");
-
+
+    Serial.println("Starting WiFi");
      // Initialize WiServer and have it use the sendMyPage function to serve pages
     WiServer.init(sendMyPage);
-}
-
-U8 state = 0;
+
+
+    rollMotor.attach(6);
+    yawMotor.attach(7);
+    throttleMotor.attach(8);
+    pitchMotor.attach(9);
+
+    WiServer.enableVerboseMode(true);
+
+    Serial.println("setting all channels at resting state");
+    resetMotors();
+    delay(5000);
+
+    arm();
+
+    /*
+    Serial.println("setting throttle to 25");
+    throttleMotor.write(servoAngleForSpeed(25));
+    */
+
+ }

 void loop()
 {
@@ -127,7 +167,7 @@

     if(!state) {
         WiServer.init(sendMyPage);
-    }
+    }

     // Run WiServer
     WiServer.server_task();
@@ -150,13 +190,13 @@
     WiServer.print (local_ip[3], DEC);
     WiServer.print ("
");

-    if (thestart == 0) {
-        WiServer.print("
<form> Engine Motor - OFF
");
+    if (armed) {
+        WiServer.print("
<form> Engine Motor - ON
");
         WiServer.print("<method=GET>");
         WiServer.print_P(htmlMotor);
     }
     else {
-        WiServer.print("
<form> Engine Motor - ON
");
+        WiServer.print("
<form> Engine Motor - OFF
");
         WiServer.print("<method=GET>");
         WiServer.print_P(htmlMotor);
     }
@@ -164,21 +204,20 @@
     WiServer.print ("
");
 }

-
-void move_to_start()
-{
-    myMotor.write(80);
-    //delay(500); // delay 1000ms, this allows the previous instruction to be finished.
-}
-
-
-void move_to_end()
-{
-    myMotor.write(70);
-}
-
-void move_to_ninty()
-{
-    myMotor.write(90);
-}
-
+void arm()
+{
+    unsigned long now = millis();
+
+    // don't try rearming if we already tried earlier, this will confusing the APM
+    if(now - lastArmTime < 6000) {
+         return;
+    }
+
+    Serial.println("arming");
+    throttleMotor.write(servoAngleForSpeed(0));
+    yawMotor.write(servoAngleForSpeed(130));
+    delay(5000);
+    resetMotors();
+    armed = 1;
+    lastArmTime = now;
+}


add analog float switch reporting

add analog float switch reporting

--- arduino/balcony_garden/balcony_garden.ino
+++ arduino/balcony_garden/balcony_garden.ino
@@ -4,12 +4,14 @@
 #include <Arduino.h>
 #include "cmd_protocol.h"
 #include "base_device.h"
+#include "analog_float_switch.h"
 #include "relay_switch.h"
 #include "dht22_sensor.h"
 #include "ds18b20_sensor.h"

 #define DELAY 500

+#define START_PIN_FLOAT_SWTCH   0 // pin 0: analog float switch
 #define START_PIN_RELAY_SWTCHS  2 // pin 2: main kill switch
                                   // pin 3: grow bed valve
                                   // pin 4: top left outlet
@@ -26,13 +28,15 @@
 #define NUM_H20_SNSRS     2
 #define NUM_FEED_VALVES   1

+#define FLOAT_SWTCH_NAME_PREFIX   "FloatSwitch"
 #define RELAY_SWTCH_NAME_PREFIX   "RelaySwitch"
 #define DHT22_SNSR_NAME_PREFIX    "DHT22Sensor"
 #define DSB18B20_SNSR_NAME_PREFIX "DS18B20Sensor"

-CRelay         g_relay_switches[NUM_RELAY_SWTCHS];
-CDht22Sensor   g_dht22_sensors[NUM_DHT22_SNSRS];
-CDs18b20Sensor g_ds18b20_sensor;  // these probes are all on 1 wire
+CAnalogFloatSwitch g_float_switch;
+CRelay             g_relay_switches[NUM_RELAY_SWTCHS];
+CDht22Sensor       g_dht22_sensors[NUM_DHT22_SNSRS];
+CDs18b20Sensor     g_ds18b20_sensor;  // these probes are all on 1 wire

 #define DBG 1 // turn on to get detailed debug info
 #if DBG == 0
@@ -45,6 +49,10 @@
 {
     Serial.begin(SERIAL_BAUD);
     delay(DELAY);
+
+    // initialize analog float switch object and pin
+    g_float_switch.set_name(FLOAT_SWTCH_NAME_PREFIX);
+    g_float_switch.set_pin(START_PIN_FLOAT_SWTCH);

     // initialize relay switch objects and pins
     for (unsigned int i = 0; i < NUM_RELAY_SWTCHS; i++)
@@ -98,7 +106,7 @@
                 }
                 break;
             case GET:
-                //report_water_sensor_states();
+                report_float_switch_states();
                 report_relay_switch_states();
                 report_dht22_sensor_states();
                 report_ds18b20_sensor_states();
@@ -109,6 +117,12 @@
         }
     }

+}
+
+// report float switch states
+void report_float_switch_states()
+{
+    Serial.println(g_float_switch.get_status_str());
 }

 // report relay switch states


use bit arithmetic to get bytes

use bit arithmetic to get bytes

--- arduino/personal_space/personal_space.ino
+++ arduino/personal_space/personal_space.ino
@@ -514,10 +514,15 @@
 }

 void send_data(){
-  uint8_t data[] = {'d', 'a', 't', 'a'};
-  uint8_t len = 4;
+  uint16_t data16[] = {68,97,116,97};
+  uint8_t data8[8];

-  uart_tx(data, len);
+  for (int i = 0; i < sizeof(data16); i++){
+    data8[i*2] = data16[i] & 0xFF;
+    data8[i*2 + 1] = (data16[i] & 0xFF00) >> 8;
+  }
+
+  uart_tx(data8, sizeof(data8));
 }

 bool stringComplete = false;  // whether the string is complete


Update text4Directions.ino

Update text4Directions.ino

--- examples/text4Directions/text4Directions.ino
+++ examples/text4Directions/text4Directions.ino
@@ -18,7 +18,7 @@
 */
 #include <stdint.h>
 #include <TouchScreen.h>
-#include <TFT.h>
+#include <TFT_T.h>

 #ifdef SEEEDUINO
   #define YP A2   // must be an analog pin, use "An" notation!


added bpm control

added bpm control

--- examples/Sequencer_example/Sequencer_example.ino
+++ examples/Sequencer_example/Sequencer_example.ino
@@ -11,7 +11,6 @@
 byte numSteps = 4;

 void setup(){
-  stepTime = 60000.f / bpm;
   pinMode(LED, OUTPUT);
   pinMode(13, OUTPUT);
 }
@@ -37,4 +36,7 @@
  }

  dur[0] = analogRead(0) / 1024.f * 100;
+ bpm = (analogRead(8) >> 3) + 30; // from 30 to 157 bpm
+ stepTime = 60000.f / bpm;
+
 }


the speed function requires two arguments.

--- ArduAutoCar/ArduAutoCar.ino
+++ ArduAutoCar/ArduAutoCar.ino
@@ -94,7 +94,7 @@
       radio.startListening();
     } else
   {
-    //speed(128); //If there is no contact with the controller, stop the car
+    //speed(128, false); //If there is no contact with the controller, stop the car
   }
 }


Improve Speed

Improve Speed

--- source/Arduino_32u4_Code/Arduino_32u4_Code.ino
+++ source/Arduino_32u4_Code/Arduino_32u4_Code.ino
@@ -77,7 +77,7 @@
     if(cmd == "Press"){
       keypressdone=1;
 //      String fullkeys = SOFTserial.readString();
-      String fullkeys = Serial1.readString();
+      String fullkeys = Serial1.readStringUntil('\n');
       int str_len = fullkeys.length()+1;
       char keyarray[str_len];
       fullkeys.toCharArray(keyarray, str_len);
@@ -109,7 +109,7 @@
     //If command equals "Print:X"
     else if(cmd == "Print") {
 //      String keycode = SOFTserial.readString();
-      String keycode = Serial1.readString();
+      String keycode = Serial1.readStringUntil('\n');
 //      if(debug==1) {
 //        Serial.print("Printing: "); //Debug line
 //        Serial.println(keycode); //Debug line
@@ -121,7 +121,7 @@
     //If command equals "PrintLine:X"
     else if(cmd == "PrintLine") {
 //      String keycode = SOFTserial.readString();
-      String keycode = Serial1.readString();
+      String keycode = Serial1.readStringUntil('\n');
 //      if(debug==1) {
 //        Serial.print("Printing Line: "); //Debug line
 //        Serial.println(keycode); //Debug line
@@ -137,7 +137,7 @@
 //mouse up
     //If command equals "MouseMoveUp:X"
     else if(cmd == "MouseMoveUp") {
-      String mousemove = Serial1.readString();
+      String mousemove = Serial1.readStringUntil('\n');
       int mousemoveamt = mousemove.toInt();
       delay(25);
       Mouse.begin();
@@ -149,7 +149,7 @@
 //mouse down
     //If command equals "MouseMoveDown:X"
     else if(cmd == "MouseMoveDown") {
-      String mousemove = Serial1.readString();
+      String mousemove = Serial1.readStringUntil('\n');
       int mousemoveamt = mousemove.toInt();
       delay(25);
       Mouse.begin();
@@ -161,7 +161,7 @@
 //mouse left
     //If command equals "MouseMoveLeft:X"
     else if(cmd == "MouseMoveLeft") {
-      String mousemove = Serial1.readString();
+      String mousemove = Serial1.readStringUntil('\n');
       int mousemoveamt = mousemove.toInt();
       delay(25);
       Mouse.begin();
@@ -173,7 +173,7 @@
 //mouse right
     //If command equals "MouseMoveRight:X"
     else if(cmd == "MouseMoveRight") {
-      String mousemove = Serial1.readString();
+      String mousemove = Serial1.readStringUntil('\n');
       int mousemoveamt = mousemove.toInt();
       delay(25);
       Mouse.begin();
@@ -185,21 +185,21 @@
 //mouse click command EX: MouseClickLEFT: MouseClickRIGHT: MouseClickMIDDLE:
     //If command equals "MouseClickX:"
     else if(cmd == "MouseClickRIGHT") {
-        String junk = Serial1.readString();
+        String junk = Serial1.readStringUntil('\n');
         delay(25);
         Mouse.begin();
         Mouse.click(MOUSE_RIGHT);
         Mouse.end();
       }
     else if(cmd == "MouseClickLEFT") {
-        String junk = Serial1.readString();
+        String junk = Serial1.readStringUntil('\n');
         delay(25);
         Mouse.begin();
         Mouse.click(MOUSE_LEFT);
         Mouse.end();
       }
       else if(cmd == "MouseClickMIDDLE") {
-        String junk = Serial1.readString();
+        String junk = Serial1.readStringUntil('\n');
         delay(25);
         Mouse.begin();
         Mouse.click(MOUSE_MIDDLE);


Code Clean-up + increase time out

Code Clean-up + increase time out

--- BiotechHardware/dcs/dcs_alpha4/dcs_alpha4.ino
+++ BiotechHardware/dcs/dcs_alpha4/dcs_alpha4.ino
@@ -7,8 +7,7 @@
 #include <Servo.h>

 const char server[] = "192.168.2.4";
-byte mac[] = {
-  0x90, 0xA2, 0xDA, 0x0E, 0xF5, 0xF8};
+byte mac[] = {0x90, 0xA2, 0xDA, 0x0E, 0xF5, 0xF8};
 IPAddress ip(192,168,1,5);

 EthernetClient client;
@@ -16,20 +15,13 @@
 const byte ROWS = 4;
 const byte COLS = 3;
 char keys[ROWS][COLS] = {
-  {
-    '1','2','3'    }
-  ,{
-    '4','5','6'    }
-  ,{
-    '7','8','9'    }
-  ,{
-    '*','0','#'    }
-};
-
-byte rowPins[ROWS] = {
-  2, 3, 4, 5};
-byte colPins[COLS] = {
-  6, 7, 8};
+{'1','2','3'},
+{'4','5','6'},
+{'7','8','9'},
+{'*','0','#'}};
+
+byte rowPins[ROWS] = {2, 3, 4, 5};
+byte colPins[COLS] = {6, 7, 8};

 Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS );
 LiquidCrystal_I2C lcd(0x27,20,4);
@@ -68,7 +60,7 @@
   Serial.println(Ethernet.localIP());

   W5100.setRetransmissionTime(0x07D0);
-  W5100.setRetransmissionCount(3);
+  W5100.setRetransmissionCount(10);

   lcd.init();
   lcd.backlight();
@@ -79,7 +71,6 @@

   check_server();

-  lcd_init();
   pinMode(sensor, INPUT);
   digitalWrite(sensor, HIGH);
   pinMode(push_btn, INPUT);
@@ -385,7 +376,4 @@

     device_condition = false;
   }
-}
-
-
-
+}


Minor cleanup.

Minor cleanup.

--- experimental/arduino101/science-journal-arduino/science-journal-arduino.ino
+++ experimental/arduino101/science-journal-arduino/science-journal-arduino.ino
@@ -58,29 +58,17 @@
   blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);
   valueCharacteristic.setEventHandler(BLESubscribed, bleNotificationSubscribeHandler);
   valueCharacteristic.setEventHandler(BLEUnsubscribed, bleNotificationUnsubscribeHandler);
-DEBUG_PRINTLN("Bluetooth device active, waiting for address...");
-    ble_client_get_factory_config(&_local_bda, _device_name);
-  DEBUG_PRINT("Type: ");
-  DEBUG_PRINTLN(_local_bda.type);
-  DEBUG_PRINT("Addr: ");
-  for (int i = 0; i <= BLE_ADDR_LEN; ++i) {
-    Serial.print(_local_bda.addr[i], HEX);
-  }
-    DEBUG_PRINTLN("");
-
+
+  ble_client_get_factory_config(&_local_bda, _device_name);
   String name = "Sci";
   name += String(_local_bda.addr[4], HEX);
   name += String(_local_bda.addr[5], HEX);
-
-
+  DEBUG_PRINT("Address is: ");
+  DEBUG_PRINTLN(name);
   blePeripheral.setLocalName(name.c_str());

   // advertise the service
   blePeripheral.begin();
-
-
-
-  DEBUG_PRINTLN("Bluetooth device active, waiting for connections...");
 }


Salt Lamp v1.3

Salt Lamp v1.3

--- sketch.ino
+++ sketch.ino
@@ -1,5 +1,5 @@

-// Neopixel Salt Lamp v1.2
+// Neopixel Salt Lamp v1.3
 // By Chris Barrett - Polaris Interplanetary - Special Projects Division
 // Supports two modes; All pixel colour fade, and 8 pixel RGB mixer. All modes are asynchronous, and compartmentalized into functions.
 // January 2016 - Shimmer has been overhauled. Cleaner, faster and more productive. NO MORE MID FADE FLICKER!


added mosfet switch and refined

added mosfet switch and refined

--- hacks/attiny85_voltage_meter/attiny85_voltage_meter.ino
+++ hacks/attiny85_voltage_meter/attiny85_voltage_meter.ino
@@ -3,6 +3,7 @@

 #define GREEN_PIN 3
 #define RED_PIN 4
+#define POWER_SWITCH_PIN 0
 #define SECONDS_TO_SLEEP 16 // Multiple of 8
 #define SECONDS_ON 3

@@ -39,6 +40,7 @@
 {
   pinMode(GREEN_PIN, OUTPUT);
   pinMode(RED_PIN, OUTPUT);
+  pinMode(POWER_SWITCH_PIN, OUTPUT);
   set_sleep_mode(SLEEP_MODE_PWR_DOWN);
 }

@@ -46,12 +48,14 @@
 {
   pinMode(GREEN_PIN, INPUT);  // saves som extra uA
   pinMode(RED_PIN, INPUT); // saves som extra uA
+  pinMode(POWER_SWITCH_PIN, INPUT); // saves som extra uA
   ADCSRA &= ~(1<<ADEN); //Disable ADC, saves ~230uA
   setup_watchdog(8); //Setup watchdog to go off after 8sec
   sleep_mode(); //Go to sleep!
   ADCSRA |= (1<<ADEN); //Enable ADC
   pinMode(GREEN_PIN, OUTPUT);  // saves som extra uA
   pinMode(RED_PIN, OUTPUT); // saves som extra uA
+  pinMode(POWER_SWITCH_PIN, OUTPUT); // saves som extra uA
 }

 //This runs each time the watch dog wakes us up from sleep
@@ -65,12 +69,14 @@
     vcc = readVcc();
     if (vcc >= 3900) {
       // Measured at vcc=3.7V, plenty of voltage
+      digitalWrite(POWER_SWITCH_PIN, HIGH);
       digitalWrite(GREEN_PIN, HIGH);
       digitalWrite(RED_PIN, LOW);
       delay(1000); // delay so we are not checking vcc all the time
       digitalWrite(GREEN_PIN, LOW);
     } else if (vcc <= 3400) {
       // Measured at vcc<=3.3V, voltage is gone, flash fast red pin 1s
+      // Don't turn on POWER_SWITCH_PIN, no voltage left
       digitalWrite(GREEN_PIN, LOW);
       for (int i=0; i<5; i++) {
         digitalWrite(RED_PIN, HIGH);
@@ -80,6 +86,7 @@
       }
     } else {
       // Not much voltage left, flash green pin 1s.
+      digitalWrite(POWER_SWITCH_PIN, HIGH);
       digitalWrite(RED_PIN, LOW);
       for (int i=0; i<5; i++) {
         digitalWrite(GREEN_PIN, HIGH);
@@ -88,6 +95,7 @@
         delay(100);
       }
     }
+
     delay(1000*SECONDS_ON-1000);

     for (int i=0; i<5; i++) {
@@ -95,7 +103,9 @@
         delay(100);
         digitalWrite(RED_PIN, LOW);
         delay(100);
-    }
+    }
+
+    digitalWrite(POWER_SWITCH_PIN, LOW);
   }

   enterSleep();


prepare for merge

prepare for merge

--- engine-room/engine_arduino/engine_arduino.ino
+++ engine-room/engine_arduino/engine_arduino.ino
@@ -88,9 +88,9 @@
   if (switch_pin == NO) {
     return SWITCH_WALL;
   } else if (digitalRead(switch_pin)) {
+    return SWITCH_OFF;
+  } else {
     return SWITCH_ON;
-  } else {
-    return SWITCH_OFF;
   }
 }

@@ -309,7 +309,7 @@
   }
   pinMode(LED_BUILTIN, OUTPUT);

-  pinMode(22, INPUT);
+  pinMode(22, INPUT_PULLUP);
   // Initial switch pins as INPUTs.
 //  for (int switch_index = 0; switch_index < GRIDSIZE * GRIDSIZE; switch_index++) {
 //    int pin = getSwitchPin(getRow(switch_index), getCol(switch_index));
@@ -333,39 +333,54 @@
 //  delay(100);
 //}

+void loop() {
+  if (USE_SERIAL) {
+    Serial.println("DEBUG");
+  }
+  for (int index = 0; index < GRIDSIZE * GRIDSIZE; index++) {
+    int value = getSwitchValue(getRow(index), getCol(index));
+    if (index % GRIDSIZE == 0) {
+      if (USE_SERIAL) {
+        Serial.println("");
+      }
+    }
+    if (value == SWITCH_WALL) {
+      if (USE_SERIAL) {
+        Serial.print("X");
+      }
+    } else {
+      if (USE_SERIAL) {
+        Serial.print(value);
+      }
+    }
+
+    if (USE_SERIAL) {
+      Serial.print(' ');
+    }
+  }
+
+  if (USE_SERIAL) {
+    Serial.print('\n');
+    Serial.print('\n');
+    Serial.flush();
+  }
+
+  delay(1000);
+}
+
 //void loop() {
-//  if (USE_SERIAL) {
-//    Serial.println("DEBUG");
-//  }
-//  for (int index = 0; index < GRIDSIZE * GRIDSIZE; index++) {
-//    int value = getSwitchValue(getRow(index), getCol(index));
-//    if (index % GRIDSIZE == 0) {
-//      if (USE_SERIAL) {
-//        Serial.println("");
-//      }
-//    }
-//    if (value == SWITCH_WALL) {
-//      if (USE_SERIAL) {
-//        Serial.print("X");
-//      }
-//    } else {
-//      if (USE_SERIAL) {
-//        Serial.print(value);
-//      }
-//    }
-//
-//    if (USE_SERIAL) {
-//      Serial.print(' ');
-//    }
-//  }
-//
-//  if (USE_SERIAL) {
-//    Serial.print('\n');
-//    Serial.print('\n');
-//    Serial.flush();
-//  }
-//
-//  delay(1000);
+//  for(uint16_t i = 0; i < STRIP_LENGTH; i++)
+//  {
+//    colors[i] = CYAN;
+//  }
+//  if (true) { //digitalRead(22)) {
+//    setColor(3, 3, GREEN);
+//  }
+//  else {
+//    setColor(3, 3, GREEN);
+//  }
+//  leds.write(colors, STRIP_LENGTH);
+//  delay(50);
 //}

 //void loop() {
@@ -394,20 +409,12 @@
 //  delay(10);
 //}

-void loop() {
-  bool victory = update();
-  leds.write(colors, STRIP_LENGTH);
-  delay(50);
-
 //void loop() {
-//  delay(10);
+//  bool victory = update();
+//  if (victory) {
+//    delay(500);
+//    setAllBlue();
+//  }
+//  delay(50);
+//  leds.write(colors, STRIP_LENGTH);
 //}
-//
-
-void loop() {
-  bool victory = update();
-  if (victory) {
-    delay(500);
-    setAllBlue();
-  }
-}


Forgot to send NAK on unsupported commands

--- serprog-due/serprog-due.ino
+++ serprog-due/serprog-due.ino
@@ -206,4 +206,5 @@
 {
   byte op = get_chr();
   if(cmd[op])cmd[op]();
+  else put_chr(S_NAK);
 }


Googleカレンダから赤外線リモコン制御対応

Googleカレンダから赤外線リモコン制御対応

--- 1_practice/esp32_27_goo_lcd3/esp32_27_goo_lcd3.ino
+++ 1_practice/esp32_27_goo_lcd3/esp32_27_goo_lcd3.ino
@@ -29,14 +29,23 @@
 #define PORT 1024                           // 受信ポート番号
 #define DEVICE "alarm_1,"                   // 子機デバイス名(5文字+"_"+ID+",")

-#define DEV_AC_ON  "" 						// ACリレーをONにするときのコマンド
-#define DEV_AC_OFF ""						// ACリレーをOFFにするときのコマンド
-
-/*	WiFiｺﾝｼｪﾙｼﾞｪ電源担当(ACリレー)を使用する場合は以下のように設定してください。
-	（IPアドレスは、WiFiｺﾝｼｪﾙｼﾞｪ電源担当のアドレスに書き換える）
-
-#define DEV_AC_ON  "192.168.0.155/?RELAY=1" // ACリレーをONにするときのコマンド
-#define DEV_AC_OFF "192.168.0.155/?RELAY=0" // ACリレーをOFFにするときのコマンド
+#define DEV_AC_ON  ""                       // ACリレーをONにするときのコマンド
+#define DEV_AC_OFF ""                       // ACリレーをOFFにするときのコマンド
+
+/*  WiFiｺﾝｼｪﾙｼﾞｪ電源担当(ACリレー)を使用する場合は以下のように設定してください。
+    （IPアドレスは、WiFiｺﾝｼｪﾙｼﾞｪ電源担当のアドレスに書き換える）
+#define DEV_AC_ON  "192.168.0.3/?RELAY=1"   // ACリレーをONにするときのコマンド
+#define DEV_AC_OFF "192.168.0.3/?RELAY=0"   // ACリレーをOFFにするときのコマンド
+*/
+
+#define DEV_IR ""                           // 赤外線リモコン送信機のIPアドレス
+#define IR_ON  "IR=104,AA,5A,CF,10,00,11,20,3F,18,B0,00,F4,B1"  // エアコンON
+#define IR_OFF "IR=104,AA,5A,CF,10,00,21,20,3F,18,B0,00,F4,81"  // エアコンOFF
+
+/*  WiFiｺﾝｼｪﾙｼﾞｪリモコン担当(赤外線リモコン)を使用する場合は以下のように設定して
+　　ください。
+    （IPアドレスは、WiFiｺﾝｼｪﾙｼﾞｪリモコン担当のアドレスに書き換える）
+#define DEV_IR "192.168.0.4/"               // 赤外線リモコン送信機のIPアドレス
 */

 LiquidCrystal lcd(17,26,13,14,15,16);       // CQ出版 IoT Express 用 LCD開始
@@ -184,14 +193,20 @@
                 int led = atoi(buf[i]+10) % 2;      // 「LED=」の数値を変数ledへ
                 digitalWrite(PIN_LED,led);          // LEDの点灯または消灯
             }
-            if(sec==0){								// 現在時刻の秒が0のとき
-				wifi_udp(buf[i]);            		// 予定を送信
-            	delay(1000);                 		// 音声完了待ち
-	            if(!strncmp(buf[i]+6,"AC=",3)){     // 予定の内容がAC制御の時
-	                int ac = atoi(buf[i]+9);   		// 「AC=」の数値を変数ledへ
-	                if(ac) httpGet(DEV_AC_ON);
-	                else httpGet(DEV_AC_OFF);
-	            }
+            if(sec==0){                             // 現在時刻の秒が0のとき
+                wifi_udp(buf[i]);                   // 予定を送信
+                chime=chimeBells(PIN_BUZZER,chime); // チャイム音
+				String s = buf[i];
+				if(s.indexOf("AC=") == 6){          // 予定の内容がAC制御の時
+                    int ac=s.substring(9).toInt();  // 「AC=」の数値を変数acへ
+                    if(ac) httpGet(DEV_AC_ON);      // ACリレーをONにする
+                    else httpGet(DEV_AC_OFF);       // ACリレーをOFFにする
+                }
+				if(s.indexOf("IR=") == 6){          // 予定の内容がAC制御の時
+                    int ir=s.substring(9).toInt();  // 「AC=」の数値を変数irへ
+                    if(ir) httpPost(DEV_IR,IR_ON);  // エアコンの電源をONにする
+                    else httpPost(DEV_IR,IR_OFF);   // エアコンの電源をOFFにする
+                }
             }
         }
     }


Finalised

Finalised

--- Timer1ShotLib/Timer1ShotLib/Timer1ShotLib.ino
+++ Timer1ShotLib/Timer1ShotLib/Timer1ShotLib.ino
@@ -1,23 +1,41 @@
+/************/
+/* INCLUDES */
+/************/
 #include <digitalWriteFast.h>
-
 //#include <TimerOne.h>
 #define	GPIO2_PREFER_SPEED	1
 #include <arduino2.h>

+/*************/
+/* CONSTANTS */
+/*************/
 #define RESOLUTION 65536
+#define BUFLEN 100
+#define MAXF 5
+#define MAXA 45

-int period = 2000; // 20 ms
+/********************/
+/* GLOBAL VARIABLES */
+/********************/
+int maxus = 2390; // 20 ms
+int mid = 1545;
+double deg2us = 845 / 90.0;
 long start = 0;
 unsigned int pwmPeriod;
 unsigned char clockSelectBits;
 char oldSREG;
-void resume();
+char buf[BUFLEN+1];
+float freq, amp;
+int pos;

+/*************/
+/* FUNCTIONS */
+/*************/
 void timerSetup(int duty) {
   TCCR1A = 0;                 // clear control register A
   TCCR1B = 0; //_BV(WGM13);        // set mode 8: phase and frequency correct pwm, stop the timer
   TCNT1 = 0x00;
-  long cycles = (F_CPU / 1000000) * period;                                      // the counter runs backwards after TOP, interrupt is at BOTTOM so divide microseconds by 2
+  long cycles = (F_CPU / 1000000) * maxus;                                      // the counter runs backwards after TOP, interrupt is at BOTTOM so divide microseconds by 2
   if(cycles < RESOLUTION)              clockSelectBits = _BV(CS10);              // no prescale, full xtal
   else if((cycles >>= 3) < RESOLUTION) clockSelectBits = _BV(CS11);              // prescale by /8
   else if((cycles >>= 3) < RESOLUTION) clockSelectBits = _BV(CS11) | _BV(CS10);  // prescale by /64
@@ -60,14 +78,20 @@
 					// and the first one is in the middle of a cycle
 }

+/*********/
+/* SETUP */
+/*********/
 void setup() {
   // put your setup code here, to run once:
   Serial.begin(38400);
   pinMode2(8, OUTPUT);
   timerSetup(512);
-  start = micros();
+  //start = micros();
 }

+/********/
+/* LOOP */
+/********/
 void loop() {
   // put your main code here, to run repeatedly:
   //long t1 = micros();
@@ -76,15 +100,75 @@
   //long t1 = micros();
   //cli();
   //TCNT1=16*1500;
-  long time = micros();
-  TCNT1 = round(16*(200*sin(2*PI*0.5*(time-start)/1000000.0) + 1500));
-  digitalWrite2(8, HIGH);
-  while(TCNT1>0);
-  digitalWrite2(8, LOW);
+  Serial.println("Enter frequency, amplitude");
+  pos = 16*mid;
+
+  while ( Serial.available() == 0 ) {
+       TCNT1 = pos;
+       digitalWrite2(8, HIGH);
+       while(TCNT1>0);
+       digitalWrite2(8, LOW);
+       delay(20);
+  }
+
+   int n = Serial.readBytesUntil(',',buf,BUFLEN);
+   buf[n] = '\0';
+   freq = atof(buf);
+   n = Serial.readBytes(buf,BUFLEN);
+   buf[n] = '\0';
+   amp = atof(buf);
+   if( !(freq > 0 && freq <= MAXF) )
+   {
+     Serial.print("Frequency must be between 0 and ");
+     Serial.println(MAXF);
+   }
+   else if( !(amp > 0 && amp <= MAXA) )
+   {
+     Serial.print("Amplitude must be between 0 and ");
+     Serial.println(MAXA);
+   }
+   else
+   {
+     Serial.print("Platform oscillating at ");
+     Serial.print(freq);
+     Serial.print("Hz, ");
+     Serial.print(amp);
+     Serial.println("Deg");
+
+     float ampus = amp*deg2us;
+     long start = micros();
+
+     while ( Serial.available() == 0 ) {
+       long time = micros();
+       pos = round(16*(ampus*sin(2*PI*freq*(time-start)/1000000.0) + mid));
+       TCNT1 = pos;
+       digitalWrite2(8, HIGH);
+       while(TCNT1>0);
+       digitalWrite2(8, LOW);
+       delay(20);
+     }
+
+     bool above = pos > 16*mid;
+
+     while ( ( above && pos > 16*mid ) || ( !above && pos < 16*mid ) ) {
+       long time = micros();
+       pos = round(16*(ampus*sin(2*PI*freq*(time-start)/1000000.0) + mid));
+       TCNT1 = pos;
+       digitalWrite2(8, HIGH);
+       while(TCNT1>0);
+       digitalWrite2(8, LOW);
+       delay(20);
+     }
+   }
+  //long time = micros();
+  //TCNT1 = round(16*(200*sin(2*PI*0.5*(time-start)/1000000.0) + 1500));
+  //digitalWrite2(8, HIGH);
+  //while(TCNT1>0);
+  //digitalWrite2(8, LOW);
   //long t2 = micros();
   //Serial.println(t2-time);
   //delay(20);
   //long t2 = micros();
   //Serial.println(t2-t1);
-  delay(20);
+  //delay(20);
 }


Control timer by button

Control timer by button

--- examples/Handlers/SimpleTimer/SimpleTimer.ino
+++ examples/Handlers/SimpleTimer/SimpleTimer.ino
@@ -6,25 +6,39 @@
 #include <SimpleTimer.h>

 // For this example you need to have SimpleTimer library:
-// https://github.com/jfturcot/SimpleTimer
+//   https://github.com/jfturcot/SimpleTimer
+// Visit this page for more information:
+//   http://playground.arduino.cc/Code/SimpleTimer

 // Auth token you get from App
 char auth[] = "00000000000000000000000000000000";

+#define LED_PIN 9
+
 SimpleTimer timer;
+int t1;

 void setup()
 {
   Serial.begin(115200);
   Blynk.begin(auth);
-  pinMode(9, OUTPUT);
-  timer.setInterval(500, repeatMe);
+  pinMode(LED_PIN, OUTPUT);
+  t1 = timer.setInterval(500, ledBlynk);
 }

-// a function to be executed periodically
-void repeatMe()
+BLYNK_ON_WRITE(1)
 {
-  digitalWrite(9, !digitalRead(9));
+  if (param[0].asInt()) {
+    timer.enable(t1);
+  } else {
+    timer.disable(t1);
+  }
+  Blynk.virtualWrite(5, millis()/1000);
+}
+
+void ledBlynk()
+{
+  digitalWrite(LED_PIN, !digitalRead(LED_PIN));
 }

 void loop()


Update UbidotsGetValue.ino

Update UbidotsGetValue.ino

--- examples/UbidotsGetValue/UbidotsGetValue.ino
+++ examples/UbidotsGetValue/UbidotsGetValue.ino
@@ -7,10 +7,10 @@
 //GPRS Shield is connected to the Software UART

 #define APN "Your_apn_of_your_SIM_here"
-#define USER "Your_username_here"  // if your apn doesnt have username just put ""
-#define PASS "Your_password_here"  // if your apn doesnt have password just put ""
-#define TOKEN "Your_token_here"  // Remplace it with your token
-#define ID "Your_id_here" // Remplace it with your variable ID
+#define USER "Your_username_here"  // If your apn doesnt have username just put ""
+#define PASS "Your_password_here"  // If your apn doesnt have password just put ""
+#define TOKEN "Your_token_here"  // Replace it with your Ubidots token
+#define ID "Your_id_here" // Replace it with your Ubidots' variable ID

 Ubidots client(TOKEN);

@@ -23,6 +23,6 @@
 void loop() {
   float value = client.getValue(ID);
   Serial.println(value);
-  delay(600);  // 600 milliseconds
+  delay(1000);
   Serial.println(value);
 }


Improve readability.

Improve readability.

--- examples/RF12/RF12demo/RF12demo.ino
+++ examples/RF12/RF12demo/RF12demo.ino
@@ -843,8 +843,9 @@
       case 'n': // Clear node entries in RAM & eeprom
         if ((stack[0] > 1) && (stack[0] < 31) && (value == 123) && (nodes[stack[0]] == 0)) {
           nodes[stack[0]] = 0xFF;                                           // Clear RAM entry
-          for (byte i = 0; i < (RF12_EEPROM_SIZE); ++i)
-            eeprom_write_byte(RF12_EEPROM_ADDR + (stack[0]*32) + i, 0xFF);  // Clear eeprom entry
+          for (byte i = 0; i < (RF12_EEPROM_SIZE); ++i) {
+            eeprom_write_byte(RF12_EEPROM_ADDR + (stack[0]*32) + i, 0xFF);  // Clear complete eeprom entry
+          }
         }
         else {
           Serial.println("\rInvalid");


convert all voltage values to floats

convert all voltage values to floats

--- main.ino
+++ main.ino
@@ -10,8 +10,8 @@
 int uv;
 int ir;
 int visible;
-int solarVoltage;
-int batteryVoltage;
+float solarVoltage;
+float batteryVoltage;
 bool daytime;

 typedef enum {
@@ -53,14 +53,14 @@
   RGB.color(0,0,0);

   // get solar and battery voltage
-  solarVoltage = analogRead(A1);
-  batteryVoltage = analogRead(A0);
+  solarVoltage = (float)analogRead(A1) / 2048.0 * 3.3;
+  batteryVoltage = (float)analogRead(A0) / 2048.0 * 3.3;

   // early exit - battery voltage is too LOW
-  if (batteryVoltage < 2200)
+  if (batteryVoltage < 3.55)
   {
-    // if at night time wait 20 minutes before trying again
-    if (solarVoltage < 2250)
+    // if solar voltage not sufficient to charge battery wait 20 minutes
+    if (solarVoltage < 3.72)
     {
       System.sleep(SLEEP_MODE_DEEP, 60*20);
     }
@@ -72,7 +72,7 @@
   }

   daytime = true;
-  if (solarVoltage < 1000)
+  if (solarVoltage < 3.0)
     daytime = false;

   delay(100);
@@ -125,16 +125,13 @@
         request.port = 80;
         request.path = URL;

-        float solar = (float)solarVoltage / 2048.0 * 3.3;
-        float battery = (float)batteryVoltage / 2048.0 * 3.3;
-
         request.body =  "field1=" + String((int)temperature, DEC)
                          + "&" + "field2=" + String((int)humidity, DEC) // Do not omit
                          + "&" + "field3=" + String(uv, DEC) // the &
                          + "&" + "field4=" + String(ir, DEC)
                          + "&" + "field5=" + String(visible, DEC)
-                         + "&" + "field6=" + String(solar, 2)
-                         + "&" + "field7=" + String(battery, 2);
+                         + "&" + "field6=" + String(solarVoltage, 2)
+                         + "&" + "field7=" + String(batteryVoltage, 2);
         http.post(request, response, headers);
         currentState = STATE_WIFI_COMPLETE;
       }
@@ -149,16 +146,6 @@
     if (daytime == false)
       reconnectIn = 15;

-    // did not connect to the Internet
-    if (!WiFi.ready())
-    {
-      if (batteryVoltage > 2250 && solarVoltage > 2400)
-      {
-        // strong battery and solar voltage - power back on in 3 minutes
-        reconnectIn = 3;
-      }
-      // else fall thru and test for day/night
-    }
     System.sleep(SLEEP_MODE_DEEP, reconnectIn*60);
   }
 }


refactored to remove main loop delay, and to put monitor actions into main loop, and to yield between monitor actions

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -93,7 +93,7 @@
 // data monitoring stuff ////////////////////////////////////////////////////
 const boolean SEND_DATA = true;  // turn off posting of data if required here
 const int MONITOR_POINTS = 60; // number of data points to store
-struct monitor_t {
+typedef struct {
   unsigned long timestamp;
   float waterCelsius;
   float airCelsius;
@@ -103,7 +103,7 @@
   long waterLevel1;
   long waterLevel2;
   long waterLevel3;
-};
+} monitor_t;
 monitor_t monitorData[MONITOR_POINTS];
 int monitorCursor = 0;
 int monitorSize = 0;
@@ -214,12 +214,34 @@
   dnsServer.processNextRequest();
   webServer.handleClient();

-  if(loopCounter == TICK_MONITOR) {
-    updateSensorData(monitorData);
-    // TODO yeild() here?
-    // TODO pump logic
-    delay(500); // TODO a better way?!
-  }
+  if(loopCounter == TICK_MONITOR) { // monitor levels, valve logic, push data
+    monitor_t* now = &monitorData[monitorCursor];
+    if(monitorSize < MONITOR_POINTS)
+      monitorSize++;
+    now->timestamp = millis();
+    if(GOT_TEMP_SENSOR) {
+      getTemperature(&now->waterCelsius);               yield();
+    }
+    if(GOT_HUMID_SENSOR) {
+      getHumidity(&now->airCelsius, &now->airHumid);    yield();
+    }
+    if(GOT_LIGHT_SENSOR) { getLight(&now->lux);         yield(); }
+    if(GOT_PH_SENSOR) { getPH(&now->pH);                yield(); }
+    if(GOT_LEVEL_SENSOR) {
+      getLevel(LEVEL_ECHO_PIN1, &now->waterLevel1);     yield();
+      getLevel(LEVEL_ECHO_PIN2, &now->waterLevel2);     yield();
+      getLevel(LEVEL_ECHO_PIN3, &now->waterLevel3);     yield();
+    }
+
+    doValveLogic(); yield(); // set pumps on and off etc.
+// TODO    doValveLogic(now, &flowState); yield(); // set pumps on and off etc.
+    if(SEND_DATA) { postSensorData(&monitorData[monitorCursor]); yield(); }
+
+    if(++monitorCursor == MONITOR_POINTS)
+      monitorCursor = 0;
+    // delay(500);
+  }
+
   if(loopCounter == TICK_WIFI_DEBUG) {
     Serial.print("SSID: "); Serial.print(apSSID);
     Serial.print("; IP address(es): local="); Serial.print(WiFi.localIP());
@@ -230,6 +252,13 @@
   }

   if(loopCounter++ == LOOP_ROLLOVER) loopCounter = 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// pump and valve cycle management stuff ////////////////////////////////////
+void doValveLogic() { // set pumps on and off etc.
+  /*
+  */
 }

 /////////////////////////////////////////////////////////////////////////////
@@ -565,7 +594,7 @@
 /////////////////////////////////////////////////////////////////////////////
 // sensor/actuator stuff ////////////////////////////////////////////////////
 void startPeripherals() {
-  Serial.println("startPeripherals");
+  Serial.println("\nstartPeripherals...");
   mySwitch.enableTransmit(15);   // RC transmitter is connected to Pin 15

   tempSensor.begin();     // start the onewire temperature sensor
@@ -623,42 +652,6 @@
     Serial.println("Found pH sensor");
   }
 }
-void updateSensorData(monitor_t *monitorData) {
-  // Serial.print("monitorCursor = "); Serial.print(monitorCursor);
-  // Serial.print(" monitorSize = ");  Serial.println(monitorSize);
-
-  monitor_t* now = &monitorData[monitorCursor];
-  if(monitorSize < MONITOR_POINTS)
-    monitorSize++;
-  now->timestamp = millis();
-  if(GOT_TEMP_SENSOR) {
-    getTemperature(&now->waterCelsius);
-    // TODO yeild();
-  }
-  if(GOT_HUMID_SENSOR) {
-    getHumidity(&now->airCelsius, &now->airHumid);
-    // TODO yeild();
-  }
-  if(GOT_LIGHT_SENSOR) {
-    getLight(&now->lux);
-    // TODO yeild();
-  }
-  if(GOT_PH_SENSOR) {
-    getPH(&now->pH);
-    // TODO yeild();
-  }
-  if(GOT_LEVEL_SENSOR) {
-    getLevel(LEVEL_ECHO_PIN1, &now->waterLevel1);
-    getLevel(LEVEL_ECHO_PIN2, &now->waterLevel2);
-    getLevel(LEVEL_ECHO_PIN3, &now->waterLevel3);
-    // TODO yeild();
-  }
-
-  if(SEND_DATA) postSensorData(&monitorData[monitorCursor]);
-
-  if(++monitorCursor == MONITOR_POINTS)
-    monitorCursor = 0;
-}
 void postSensorData(monitor_t *monitorData) {
   //Serial.println("\npostSensorData");


Add Humidity Graphing

Add Humidity Graphing


Migrated arduino code to use FastLED instead of the adafruit libraries, changes pylon display

--- src/arduino/Triangula_Main/Triangula_Main.ino
+++ src/arduino/Triangula_Main/Triangula_Main.ino
@@ -1,3 +1,7 @@
+
+#include <FastLED.h>
+#include <pixeltypes.h>
+

 // Comment this out to entirely disable the motor control functions. Handy when testing and you
 // really don't want the robot to vanish off into the distance mid-test.
@@ -8,8 +12,6 @@
    for each motor, these are converted to values in the range -128 to 127 and sent to the motor drivers.
    Also handles lighting and reporting of encoder values in response to a bulk data request.
 */
-#include <Adafruit_NeoPixel.h>
-#include "Triangula_NeoPixel.h"
 #include <Wire.h>
 #ifdef ENABLE_MOTOR_FUNCTIONS
 #include <Sabertooth.h>
@@ -22,11 +24,16 @@
 #define MOTOR_SPEED_SET 0x20
 #define SET_SOLID_COLOUR 0x21
 #define ENCODER_READ 0x22
+#define UPDATE_LED_GROUP 0x23

 // Register map array size in bytes
 #define REG_MAP_SIZE   6
 // Maximum length of a command
-#define MAX_SENT_BYTES 5
+#define MAX_SENT_BYTES 26
+
+// Number of neopixels
+#define NUM_LEDS 48
+#define LED_DATA_PIN 6

 // Track absolute encoder values, these are unsigned ints and can (and will) roll over. The difference()
 // function handles these cases properly. Note that these are volatile as they're updated on pin change
@@ -45,10 +52,10 @@
 #endif

 // Lights
-Triangula_NeoPixel pixels = Triangula_NeoPixel();
+CRGB leds[NUM_LEDS];

 void setup() {
-  pixels.begin();
+  FastLED.addLeds<NEOPIXEL, LED_DATA_PIN>(leds, NUM_LEDS);
   Serial.begin(9600);
   Wire.begin(SLAVE_ADDRESS);
   Wire.onRequest(requestEvent);
@@ -80,8 +87,8 @@
     ST[i].motor(0);
   }
 #endif
-  pixels.setSolidColour(170, 255, 60);
-  pixels.show();
+  setSolidColour(170, 255, 60);
+  FastLED.show();
 }

@@ -101,15 +108,16 @@
           }
           for (int i = 0; i < 3; i++) {
             ST[i].motor(((int)(receivedCommands[i + 1])) - 128);
+            setColoursForWheelSpeed(i, (int)(receivedCommands[i + 1]), HUE_PURPLE, HUE_ORANGE);
           }
-          setColours(registerMap, REG_MAP_SIZE, 8, 0);
+          FastLED.show();
         }
 #endif
         break;
       case SET_SOLID_COLOUR:
         if (checkCommand(3)) {
-          pixels.setSolidColour(receivedCommands[1], receivedCommands[2], receivedCommands[3]);
-          pixels.show();
+          setSolidColour(receivedCommands[1], receivedCommands[2], receivedCommands[3]);
+          FastLED.show();
         }
         break;
       case ENCODER_READ:
@@ -121,6 +129,15 @@
         encoderData[5] =  pos_a & 0xff;
         encoderIndex = 0;
         break;
+      case UPDATE_LED_GROUP:
+        if (checkCommand(26)) {
+          int pixelOffset = 0;
+          for (int pixel = receivedCommands[1]; pixel < (receivedCommands[1] + receivedCommands[2]); pixel++) {
+            int hue = receivedCommands[3 + pixelOffset * 3];
+            int sat = receivedCommands[4 + pixelOffset * 3];
+            int val = receivedCommands[5 + pixelOffset * 3];
+          }
+        }
       default:
 #ifdef ENABLE_MOTOR_FUNCTIONS
         // Unknown command, stop the motors.
@@ -128,8 +145,8 @@
           ST[i].motor(0);
         }
 #endif
-        pixels.setSolidColour(0, 255, 50);
-        pixels.show();
+        setSolidColour(0, 255, 50);
+        FastLED.show();
         break;
     }
   }
@@ -215,17 +232,37 @@
   encoder_c = c;
 }

-// Set colours based on the signal received from the Pi
-void setColours(byte hues[], int hueCount, int pixelsPerValue, int fromPixel) {
-  int pixel = fromPixel;
-  for (int i = 0; i < hueCount; i++) {
-    uint32_t colour_a = pixels.hsvToColour(hues[i], 255, 150);
-    uint32_t colour_b = pixels.hsvToColour(hues[(i + 1) % hueCount], 255, 150);
-    for (int j = 0; j < pixelsPerValue; j++) {
-      uint32_t colour = pixels.interpolate(colour_a, colour_b, ((float)j) / ((float)pixelsPerValue));
-      pixels.setPixelColor(pixel++, colour);
-    }
-  }
-  pixels.show();
-}
-
+void setSolidColour(int hue, int saturation, int value) {
+  for (int pixel = 0; pixel < NUM_LEDS; pixel++) {
+    leds[pixel] = CHSV(hue, saturation, value);
+  }
+}
+
+// Set pylon colours based on speed
+// wheelSpeed is 0-255, where 0 is full speed one way, 255 full speed the other
+// pylon is [0,1,2] depending on which wheel we're creating the lighting for
+void setColoursForWheelSpeed(int pylon, int wheelSpeed, int hue1, int hue2) {
+  if (wheelSpeed >= 128) {
+    int ledsLit = (wheelSpeed - 112) >> 4;
+    for (int n = 0; n < 8; n++) {
+      if (n <= ledsLit) {
+        leds[pylon * 8 + n] = CHSV(hue1, 200, 200);
+      }
+      else {
+        leds[pylon * 8 + n] = CHSV(0, 0, 0);
+      }
+    }
+  }
+  else {
+    int ledsLit = (143 - wheelSpeed) >> 4;
+    for (int n = 0; n < 8; n++) {
+      if ((8 - n) <= ledsLit) {
+        leds[pylon * 8 + n] = CHSV(hue2, 200, 200);
+      }
+      else {
+        leds[pylon * 8 + n] = CHSV(0, 0, 0);
+      }
+    }
+  }
+}
+


Remove Serial Setup

Remove Serial Setup

Fixed Parentheses and Commented Out Serial Setup

--- GatesPuzzle/GatesPuzzle.ino
+++ GatesPuzzle/GatesPuzzle.ino
@@ -58,7 +58,7 @@
 void loop(){

   //Get data from the serial port (If any Available)
-  if(Serial.available()){
+  /*if(Serial.available()){
     serialBytes = Serial.available();
     Serial.readBytes(serialIn, serialBytes);
     if((serialIn[1] == '|' && serialIn[3] == '|' && serialIn[5] == '|' && serialIn[7] == '|')){
@@ -74,7 +74,7 @@
       Serial.print("Path Setup: Failure\n")
     }

-  }
+  }*/

   //Grab all the Button Values
   for(i = 0; i < 10; i++){
@@ -103,7 +103,7 @@
 int checkPath(int n, int a, int b){
   return (
           //If We are using the AND Gate
-          ((n == 1 && (a == 1) && (b == 1))) ? 1 : 0) ||
+          ((n == 1 && ((a == 1) && (b == 1))) ? 1 : 0) ||
           //If we are using the OR Gate
           ((n == 2 && ((a == 1) || (b == 1))) ? 1 : 0) ||
           //If we are using NAND Gate
@@ -115,4 +115,4 @@
           //If we are using XNOR Gate
           ((n == 6 && !((a == 1) ^ (b == 1))) ? 1 : 0)
         );
-}+}


Update ChickenDoorController.ino

Update ChickenDoorController.ino

Format Debug statements

--- ChickenDoorController/ChickenDoorController.ino
+++ ChickenDoorController/ChickenDoorController.ino
@@ -80,43 +80,58 @@
 // the loop function runs over and over again until power down or reset
 void loop() {
 	delay(2000);
-	if (debug){
-		Serial.println();
-		Serial.println("LoopHead");
-	}
 	//Get the Date/Time from the RTC
 	now = rtc.now();
 	//Get Sunrise/Sunset for the current year/month/day as INT's that equate to minutes from midnight that he sunrise/sunset will occur (THE TRUE is passing in Daylight Savings Time!)
 	sunrise = colton.sunrise(now.year(), now.month(), now.day(), true);
 	sunset = colton.sunset(now.year(), now.month(), now.day(), true);
 	if (debug) {
-		Serial.println();
-		Serial.print(now.year());
-		Serial.print('/');
+    Serial.println("-- -- -- -- -- -- -- --");
+    Serial.print("Currently: ");
 		Serial.print(now.month());
 		Serial.print('/');
 		Serial.print(now.day());
+    Serial.print('/');
+    Serial.print(now.year());
 		Serial.print(" - ");
 		Serial.print(now.hour());
 		Serial.print(':');
 		Serial.print(now.minute());
 		Serial.print(':');
 		Serial.print(now.second());
+    Serial.println();
 	}

 	//Lets get add the "now" Minutes and "now" hours*60 to see how many minutes from midnight we are
 	currentMins = ((now.hour()) * 60) + (now.minute());
-	Serial.println(currentMins);
-
+	//Debug minutes from midnight for sunrise/now/sunset
+	if (debug) {
+  	Serial.println();
+  	Serial.print("Now:");
+    Serial.print(currentMins);
+    Serial.println();
+    Serial.print("Sunrise:");
+    Serial.print(sunrise);
+    Serial.println();
+    Serial.print("Sunset:");
+    Serial.print(sunset);
+    Serial.println();
+	}
 	//lets start comparisons, if the door should be up....
 	if (sunrise < currentMins && currentMins < sunset)
 	{
+    //Door Should Be Up
+    if (debug) {
 		Serial.println("Door should be up");
+    }
 	}

 	else
 	{
+    //Door should be Down
+    if (debug) {
 		Serial.println("Door should be down");
+    }
 	}

 	/* Loop ToDo:
@@ -135,15 +150,19 @@
 	/* This is just temporary switch debug code*/
 	if (DoorUp == LOW)
 	{
+    if (debug) {
 		Serial.println("Door Opened All The Way");
+    }
 		stopDoor();
 		digitalWrite(builtInLED, HIGH);
 	}
 	else
 	{
 		digitalWrite(builtInLED, LOW);
-		("Door Not Open all the way");
+		if (debug) {
+		    Serial.println("Door Not Open all the way");
+        }
 		raiseDoor();
 	}
-
+	//EndMainLoop
 }


Name arguments

Name arguments

--- arduino/MoonPhaseCalendar/MoonPhaseCalendar.ino
+++ arduino/MoonPhaseCalendar/MoonPhaseCalendar.ino
@@ -66,10 +66,13 @@

 void display_blank()
 {
+    using length = uint8_t;
+    using pos = uint8_t;
+
     uint8_t const segs_off   = 0;
     uint8_t const segments[] = { segs_off, segs_off, segs_off, segs_off };

-    display.setSegments( segments, 4, 0 );
+    display.setSegments( segments, length(4), pos(0) );
 }

 void display_number( int const x, Pause const pause_ms )


十字キーを押したときのシリアル出力を変更

十字キーを押したときのシリアル出力を変更

--- SFCBandBros/SFCBandBros.ino
+++ SFCBandBros/SFCBandBros.ino
@@ -15,10 +15,10 @@
 	if(input & SNES_B) Serial.print("B ");
 	if(input & SNES_X) Serial.print("X ");
 	if(input & SNES_Y) Serial.print("Y ");
-	if(input & SNES_UP) Serial.print("u ");
-	if(input & SNES_DOWN) Serial.print("d ");
-	if(input & SNES_LEFT) Serial.print("l ");
-	if(input & SNES_RIGHT) Serial.print("r ");
+	if(input & SNES_UP) Serial.print("^ ");
+	if(input & SNES_DOWN) Serial.print("v ");
+	if(input & SNES_LEFT) Serial.print("< ");
+	if(input & SNES_RIGHT) Serial.print("> ");
 	if(input & SNES_L) Serial.print("L ");
 	if(input & SNES_R) Serial.print("R ");
 	if(input & SNES_START) Serial.print("St ");


Cleaning the unused files.

Cleaning the unused files.

--- arduino/EEPROM/testWriteRead/testWriteRead.ino
+++ arduino/EEPROM/testWriteRead/testWriteRead.ino
@@ -1,38 +0,0 @@
-#include <Wire.h>
-
-#define chip 0x50
-
-void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data )
-{
-  Wire.beginTransmission(deviceaddress);
-  Wire.write(eeaddress);
-  Wire.write(data);
-  Wire.endTransmission();
-
-  delay(5);
-}
-
-byte readEEPROM(int deviceaddress, unsigned int eeaddress )
-{
-  byte rdata = 0xFF;
-  Wire.beginTransmission(deviceaddress);
-  Wire.write(eeaddress >> 8);
-  Wire.endTransmission();
-   Wire.requestFrom(deviceaddress,1);
-  if (Wire.available()) rdata = Wire.read();
-   return rdata;
-}
-
-void setup(void)
-{
-  Serial.begin(9600);
-  Wire.begin();
-
-  unsigned int address = 1;
-
-  writeEEPROM(0x50, address, 13);
-  delay(5);
-  Serial.print(readEEPROM(chip, address), DEC);
-}
-
-void loop(){}


More tweaks

More tweaks

--- fed-arduino/fed-arduino.ino
+++ fed-arduino/fed-arduino.ino
@@ -40,7 +40,7 @@
 File dataFile;

 const int MOTOR_STEPS_PER_REVOLUTION = 513;
-const int STEPS_TO_INCREMENT = 72; //24
+const int STEPS_TO_INCREMENT = 48; //24
 Adafruit_MotorShield gMotorShield = Adafruit_MotorShield();
 Adafruit_StepperMotor *motor1 = gMotorShield.getStepper(MOTOR_STEPS_PER_REVOLUTION,1);
 Adafruit_StepperMotor *motor2 = gMotorShield.getStepper(MOTOR_STEPS_PER_REVOLUTION,2);
@@ -70,8 +70,8 @@

   //motor shield stuff
   gMotorShield.begin();
-  motor1->setSpeed(30);
-  motor2->setSpeed(30);
+  motor1->setSpeed(15);
+  motor2->setSpeed(15);

   //SD card init stuff
   Wire.begin();
@@ -278,13 +278,13 @@
     power_twi_enable();
     if (motorNum == 0)
     {
-      motor1->step(STEPS_TO_INCREMENT/3,BACKWARD,DOUBLE);
+      motor1->step(STEPS_TO_INCREMENT/6,BACKWARD,DOUBLE);
       motor1->step(STEPS_TO_INCREMENT,FORWARD,DOUBLE);
       motor1->release();
     }
     else if (motorNum == 1)
     {
-      motor2->step(STEPS_TO_INCREMENT/3,BACKWARD,DOUBLE);
+      motor2->step(STEPS_TO_INCREMENT/6,BACKWARD,DOUBLE);
       motor2->step(STEPS_TO_INCREMENT,FORWARD,DOUBLE);
       motor2->release();
     }