Still investigating on how to get HUI SysEx

--- arduinoBCF/arduinoBCF.ino
+++ arduinoBCF/arduinoBCF.ino
@@ -1,21 +1,14 @@
 #include <SPI.h>
 #include <Wire.h>
+
 #include <Adafruit_GFX.h>
 #include <Adafruit_SSD1306.h>
-
+#include <MIDI.h>
+
+//Oled related
 #define OLED_RESET 4
-
-
-#include <MIDI.h>
-
-MIDI_CREATE_DEFAULT_INSTANCE();
-
-Adafruit_SSD1306 display(OLED_RESET);
-
-
-#define LOGO16_GLCD_HEIGHT 16
-#define LOGO16_GLCD_WIDTH  16
-
+#define LOGO16_GLCD_HEIGHT 16
+#define LOGO16_GLCD_WIDTH  16
 // character dimensions (for aligning text)
 #define CH_WID 6
 #define CH_HEI 8
@@ -25,6 +18,10 @@
 #define DP_WID_MID 64
 #define DP_HEI_MID 16

+Adafruit_SSD1306 display(OLED_RESET);
+
+MIDI_CREATE_DEFAULT_INSTANCE();
+#define   MIDI_NAMESPACE   midi

 static const unsigned char PROGMEM logo16_glcd_bmp[] =
 { B00000000, B11000000,
@@ -42,144 +39,222 @@
   B00111111, B11110000,
   B01111100, B11110000,
   B01110000, B01110000,
-  B00000000, B00110000 };
+  B00000000, B00110000
+};

 #if (SSD1306_LCDHEIGHT != 32)
 #error("Height incorrect, please fix Adafruit_SSD1306.h!");
 #endif

-
-
+//MIDI buffer
+byte buffer[10];
+
+
+/**
+   Board Setup
+*/
 void setup() {

   MIDI.begin(MIDI_CHANNEL_OMNI);
-
-  // As of the MIDI Library v3.1, the lib uses C style function
-  // pointers to create a callback system for handling input events.
-  //MIDI.setHandleNoteOn(HandleNoteOn);
-  MIDI.setHandleControlChange(HandleCC);
+
+  // MIDI callback system for handling input events.
+  //MIDI.setHandleNoteOn(HandleNoteOn);
+  //MIDI.setHandleControlChange(HandleCC);
   //MIDI.setHandleNoteOff(HandleNoteOff);
-
-
-
-  // put your setup code here, to run once:
+  //MIDI.setHandleSystemExclusive(HandleSysEx);
+
   Serial.begin(9600);

   // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
-  // init done
-
+
   // Show image buffer on the display hardware.
   // Since the buffer is intialized with an Adafruit splashscreen
   // internally, this will display the splashscreen.
   display.display();
   delay(1);
-
-   // Clear the buffer.
-   display.clearDisplay();
-
-//line1
+  display.clearDisplay();
+
+  // Loading message
   display.setTextColor(WHITE);
-  displayMainText("Kick");
+  display.setCursor(0, 0);
+  display.setTextSize(2);
+  display.println("BCF 2000");
+  display.setTextSize(1);
+  display.print("Init: ");
+  for (int16_t i = 0; i < 100; i += 1) {
+    display.drawLine(display.getCursorX() + i, display.getCursorY(), display.getCursorX() + i, display.getCursorY() + CH_HEI, WHITE);
+    display.display();
+    delay(1);
+  }
+  display.print("OK!");
+  display.display();
+  delay(100);
+  display.clearDisplay();
+  display.drawPixel(10, 10, WHITE);
+  display.display();
+}
+
+const byte * toto;
+
+
+enum MidiType{
+  InvalidType           = 0x00,
+  NoteOff               = 0x80,
+  NoteOn                = 0x90,
+  AfterTouchPoly        = 0xA0,
+  ControlChange         = 0xB0,
+  ProgramChange         = 0xC0,
+  AfterTouchChannel     = 0xD0,
+  PitchBend             = 0xE0,
+  SystemExclusive       = 0xF0,
+  TimeCodeQuarterFrame  = 0xF1,   // 241
+  SongPosition          = 0xF2,
+  SongSelect            = 0xF3,
+  TuneRequest           = 0xF6,
+  Clock                 = 0xF8,
+  Start                 = 0xFA,
+  Continue              = 0xFB,
+  Stop                  = 0xFC,
+  ActiveSensing         = 0xFE,
+  SystemReset           = 0xFF,
+};
+
+
+/**
+   MAIN loop, mostly reading MIDI messages
+*/
+void loop() {
+
+
+
+  //PING Mackie HUI protocol on DAW
+  // note on, key 0, velocity 0
+  //MIDI.sendNoteOn(0,0,1);
+

-//line2
-  //display.setCursor(0,10);
+  // Reading MIDI messages, // not handling them via Callback
+  MIDI.read();
+  display.clearDisplay();
+  display.setCursor(0, 0);
+  display.display();
+  switch (MIDI.getType()) {
+    case 0xB0:
+      display.print("CC");
+     break;
+    case 0xF0:
+      display.setCursor(0, CH_HEI*2); //display IT on 3rd line
+      display.print("SysEx");
+     break;
+    case 0x80:
+      display.print("NoteOff");
+     break;
+    case 0x90:
+      display.print("NoteOn");
+     break;
+    case 0xFE:
+      display.print("ActiveSensing");
+     break;
+    case 0xC0:
+      display.print("PC");
+     break;
+    case 0xA0:
+      display.print("AfterTouchPoly");
+     break;
+    case 0xD0:
+      display.print("AfterTouchChannel");
+     break;
+    case 0xFC:
+      display.print("Stop");
+     break;
+    case 0xFF:
+      display.print("SystemReset");
+     break;
+    case 0xE0:
+      display.print("PitchBend");
+     break;
+    default:
+      display.setCursor(0, CH_HEI);
+      display.print(MIDI.getType());
+      break;
+  }

-  //displayParameter("volume","42dB");
-    display.setTextSize(1);
-
-   display.clearDisplay();
-
-   display.setCursor(0,0);
-   display.print("note On  :");
-   display.setCursor(0,CH_HEI);
-   display.print("note Off :");
-   display.setCursor(0,CH_HEI*2);
-   display.print("CC       :");
-
-
-
-
-
-
-  display.display();
-  delay(1);
-}
-
-void loop() {
-  // put your main code here, to run repeatedly:
-  MIDI.read();
-
-  /*
-    display.clearDisplay();
-     displayMainText("Kick");
-     displayParameter("volume","");
-
-  for(int16_t i=0; i<100; i+=1) {
-     display.drawLine(display.getCursorX()+i, display.getCursorY(), display.getCursorX()+i, display.getCursorY()+CH_HEI, WHITE);
-     display.display();
-     delay(1);
+  display.display();
+  //display.print(MIDI.getSysExArrayLength());
+
+
+   /*
+  for (int16_t i = 0; i < MIDI.getSysExArrayLength(); i += 1) {
+    display.print(toto[i]);
   }
-
-*/
-}
-
-
-//Display Kick / Snare / bass etc
-void displayMainText(const char * text){
-   display.setCursor(0,0);
-   display.setTextSize(3);
-   centerText(text);
-}
-
-void centerText(const char * text){
-  display.setCursor(DP_WID_MID - (3 * CH_WID * 2),display.getCursorY());
-  display.println(text);
-}
-
-void displayParameter(const char * param,const char * value){
-  //display.setCursor(DP_WID_MID - (3 * CH_WID * 2),display.getCursorY());
-  display.setTextSize(1);
-  display.print(param);
-  display.print(": ");
-  display.print(value);
-}
-
-
-/*
-void HandleNoteOn(byte channel, byte pitch, byte velocity)
-{
-  // Do something here with your data!
-   display.setCursor(7 * CH_WID ,0);
-   display.print("      ");
-   display.setCursor(7 * CH_WID ,0);
-   display.print(pitch);
-   //display.display();
-
-}
-
-void HandleNoteOff(byte channel, byte pitch, byte velocity)
+  */
+  display.display();
+
+}
+
+
+
+/**
+   MIDI CC
+*/
+void HandleCC(byte channel, byte pitch, byte velocity)
 {
   // Do something here with your data!
-   display.setCursor(7 * CH_WID ,CH_HEI);
-   display.print("      ");
-   display.setCursor(7 * CH_WID ,CH_HEI);
-   display.print(pitch);
-   //display.display();
-
-}*/
-
-void HandleCC(byte channel, byte pitch, byte velocity)
-{
-  // Do something here with your data!
-   display.clearDisplay();
-   display.setCursor(0,0);
-   display.setTextSize(3);
-   display.println(pitch);
-   display.setTextSize(1);
-   display.println(velocity);
-   display.display();
-
-
-}
-
+  display.clearDisplay();
+  display.setCursor(0, 0);
+  display.println("MIDI CC");
+  display.print(channel);
+  display.print(":");
+  display.print(pitch);
+  display.print(":");
+  display.println(velocity);
+  display.display();
+
+  /*
+     if(channel == 0xa0){
+        display.clearDisplay();
+        display.setCursor(0,0);
+        display.setTextSize(3);
+        display.println("woot");
+
+        display.setTextSize(1);
+        if(pitch == 0){
+             display.print("L :");
+             display.print(velocity);
+        }
+        else{
+             display.print("R : ");
+             display.print(velocity);
+
+        }
+
+
+        display.display();
+     }
+  */
+}
+
+
+/**
+   MIDI SysEx
+*/
+void HandleSysEx(byte *array, unsigned size) {
+
+  display.clearDisplay();
+  display.setCursor(0, 0);
+  display.println("SysEx");
+  display.print(array[0]);
+  display.display();
+
+
+}
+
+
+
+
+
+
+
+
+
+


typo...

typo...

--- examples/Paint/Paint.ino
+++ examples/Paint/Paint.ino
@@ -26,7 +26,7 @@

 void setup()
 {
-  Serial.begine(19200);
+  Serial.begin(19200);
   display.connect(&Serial, 19200);
   display.sendHandshake(); //get infos
   display.clearScreen();


Fix example.

Fix example.

--- examples/basic/basic.ino
+++ examples/basic/basic.ino
@@ -3,6 +3,7 @@
 LongPushSwitch longPushSwitch =  LongPushSwitch(2, 1000, shortPushFunc, longPushFunc, FALLING);

 void setup() {
+  Serial.begin(115200);
   pinMode(2, INPUT_PULLUP);
 }


Capacitive Button now more reliable.

Capacitive Button now more reliable.

All I did was change the lower bound in aniProfileButton() from 20 to 40. 50 Might be even better, but might
rick accidental triggers. It is significantly more reliable from this change. After further testing I might
change this to 50.

--- TinkerTie.ino
+++ TinkerTie.ino
@@ -42,7 +42,7 @@
   static long state_prev = capSensor.capacitiveSensor(30);
   long state_curr = capSensor.capacitiveSensor(30);

-  if ((state_curr <= 20) && (state_prev >= 50)) { //on short button release
+  if ((state_curr <= 40) && (state_prev >= 50)) { //on short button release
     nextAnimationProfile();
   }
   state_prev = state_curr;


cleaned up code

cleaned up code

--- Oscillator/Oscillator.ino
+++ Oscillator/Oscillator.ino
@@ -1,32 +1,35 @@
 /*
- *
- * DDS Sine Generator mit ATMEGS 168
- * Timer2 generates the  31250 KHz Clock Interrupt
- *
- * KHM 2009 /  Martin Nawrath
- * Kunsthochschule fuer Medien Koeln
- * Academy of Media Arts Cologne
+KidModular - OSCILLATOR
+by Tiago Angelo (aka p1nho)

- */
+Built with:
+Arduino 1.0.5 (on Arduino MEGA2560)
+Stripped out version of UTFT Library v.2.82 (12 Jul 2016) by Henning Karlsen
+Audio ouput using Direct Digital Synthesis method from an example by Martin Nawrath
+*/

+/************************************ INCLUDED LIBS & HEADERS ***********************************************/
 #include "avr/pgmspace.h"
+#include "Wavetables.h"
 #include <UTFT.h>
-#include "Wavetables.h"

+/************************************ DEFINITIONS ***********************************************************/
+// Audio
 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
 #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
+// MEGA=pin10 UNO=pin11
+#define AUDIOPIN 10

+/************************************ CLASS OBJECTS *********************************************************/
+// LCD
 UTFT myGLCD(CTE32HR,38,39,40,41);

-int ledPin = 13;                 // LED pin 7
-int testPin = 7;
-int t2Pin = 6;
+/************************************ VARIABLES *************************************************************/
+// Audio
 byte bb;
-
 double dfreq;
 // const double refclk=31372.549;  // =16MHz / 510
 const double refclk=31376.6;      // measured
-
 // variables used inside interrupt service declared as voilatile
 volatile byte icnt;              // var inside interrupt
 volatile byte icnt1;             // var inside interrupt
@@ -34,35 +37,29 @@
 volatile unsigned long phaccu;   // pahse accumulator
 volatile unsigned long tword_m;  // dds tuning word m

+/************************************ SETUP *****************************************************************/
 void setup()
 {
-  // Setup the LCD
+  // LCD setup - uses delay() and therefore must go before any interrupts
   myGLCD.InitLCD();

-  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
-//  Serial.begin(115200);        // connect to the serial port
-//  Serial.println("DDS Test");
-
-  pinMode(6, OUTPUT);      // sets the digital pin as output
-  pinMode(7, OUTPUT);      // sets the digital pin as output
-  // pin10 on ArduinoMEGA
-  pinMode(10, OUTPUT);     // pin11= PWM  output / frequency output
-
+  // Audio setup
+  pinMode(AUDIOPIN, OUTPUT); // output / frequency output
   Setup_timer2();
-
   // disable interrupts to avoid timing distortion
   cbi (TIMSK0,TOIE0);              // disable Timer0 !!! delay() is now not available
   sbi (TIMSK2,TOIE2);              // enable Timer2 Interrupt
-
   dfreq=1000.0;                    // initial output frequency = 1000.o Hz
   tword_m=pow(2,32)*dfreq/refclk;  // calulate DDS new tuning word
-
-
 }
+
+/************************************ LOOP ******************************************************************/
 void loop()
 {
+  // LCD
   myGLCD.fillScr(VGA_RED);

+  // Audio
   while(1) {
      if (c4ms > 250) {                 // timer / wait fou a full second
       c4ms=0;
@@ -71,18 +68,11 @@
       cbi (TIMSK2,TOIE2);              // disble Timer2 Interrupt
       tword_m=pow(2,32)*dfreq/refclk;  // calulate DDS new tuning word
       sbi (TIMSK2,TOIE2);              // enable Timer2 Interrupt
+    }
+  }
+ }

-//      Serial.print(dfreq);
-//      Serial.print("  ");
-//      Serial.println(tword_m);
-    }
-
-//   sbi(PORTD,6); // Test / set PORTD,7 high to observe timing with a scope
-//   cbi(PORTD,6); // Test /reset PORTD,7 high to observe timing with a scope
-  }
-
- }
-//******************************************************************
+/************************************ AUDIO FUNCTIONS *******************************************************/
 // timer2 setup
 // set prscaler to 1, PWM mode to phase correct PWM,  16000000/510 = 31372.55 Hz clock
 void Setup_timer2() {
@@ -101,14 +91,11 @@
   cbi (TCCR2B, WGM22);
 }

-//******************************************************************
 // Timer2 Interrupt Service at 31372,550 KHz = 32uSec
 // this is the timebase REFCLOCK for the DDS generator
 // FOUT = (M (REFCLK)) / (2 exp 32)
 // runtime : 8 microseconds ( inclusive push and pop)
 ISR(TIMER2_OVF_vect) {
-
-//  sbi(PORTD,7);          // Test / set PORTD,7 high to observe timing with a oscope

   phaccu=phaccu+tword_m; // soft DDS, phase accu with 32 bits
   icnt=phaccu >> 24;     // use upper 8 bits for phase accu as frequency information
@@ -119,6 +106,4 @@
     c4ms++;
     icnt1=0;
    }
-
-// cbi(PORTD,7);            // reset PORTD,7
 }


Updating timeout and disabling fona before trying to reenable

--- rede-firmware.ino
+++ rede-firmware.ino
@@ -321,6 +321,7 @@
     Serial.println(strlen(buffer));

     if (!fona_enabled) {
+      disable_fona();
       fona_enabled = enable_fona();
     }

@@ -341,7 +342,7 @@
       if (send_http_post(http_post_url, id, buffer)) {
         break;
       }
-      delay(1000);
+      delay(5000);
     }
     if (i >= NUM_RETRIES) {
       Serial.println(F("HTTP POST Failed"));


Disabled debug as default and minor init fixes

--- rover/rover.ino
+++ rover/rover.ino
@@ -7,7 +7,8 @@
 #define MAX_POWER  400
 #define MIN_POWER -400

-const static boolean DEBUG = true;
+// Command interpreter logic
+const static boolean DEBUG = false;

 // Accessory descriptor. It's how Arduino identifies itself in Android.
 char accessoryName[] = "UDOO Silkworm jeep";
@@ -30,8 +31,9 @@
 void setup() {
   cpu_irq_enable();
   Serial.begin(115200);
+  delay(1000);
   Serial.println("All power to the engines!");
-  delay(2000);
+  delay(1000);

   motor.init();
   stopEngine();
@@ -137,6 +139,7 @@
   if (v <= MAX_POWER && v >= MIN_POWER) {
     return v;
   } else {
+    Serial.println("DANGER: too much V!");
     return 0;
   }
 }


Coba GSM

Coba GSM

--- examples/GSM-ServiceData/GSM-ServiceData.ino
+++ examples/GSM-ServiceData/GSM-ServiceData.ino
@@ -10,6 +10,9 @@
 SoftwareSerial SSerial(10, 11);
 DTE dte(SSerial, PINPOWER, DEBUG);
 GSM gsm(dte);
+
+char buffer[5], a;
+int x = 0, p;

 void setup(void) {
   Serial.begin(9600);
@@ -32,10 +35,24 @@
   }

   if (Serial.available() > 0) {
-    char buffer[20];
-    unsigned char x = Serial.readBytes(buffer, 20);
-    buffer[x] = '\0';
-    gsm.sendServiceData(buffer);
+    a = Serial.read();
+    if ((a != '\n') && (x < 6)) {
+      buffer[x] = a;
+      Serial.print(buffer[x]);
+      x++;
+    }
+    if (a == '\n') {
+      buffer[x - 1] = '\0';
+      p = strlen(buffer);
+      char temp[p];
+      strcpy(temp, buffer);
+
+      Serial.println();
+      // Serial.print(p);
+      gsm.sendServiceData(temp);
+      x = 0;
+      // while(x<6) {buffer[x]='null'; x++;}
+    }
   }

   if (Urc.serviceDataIndication.updated) {


Modify samples to use Arduboy2 library

Modify samples to use Arduboy2 library

--- examples/Sample2-Complex/Sample2-Complex.ino
+++ examples/Sample2-Complex/Sample2-Complex.ino
@@ -1,11 +1,11 @@
-#include <Arduboy.h>
+#include <Arduboy2.h>
 #include <ArdVoice.h>
 #include "voices.h"
 #include "bitmaps.h"

 #define ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0]))

-Arduboy arduboy;
+Arduboy2 arduboy;
 ArdVoice ardvoice;
 #define ARDBITMAP_SBUF arduboy.getBuffer()
 #include <ArdBitmap.h>


Reducing memory usage on T84

Reducing memory usage on T84

--- examples/RF12/RF12demo/RF12demo.ino
+++ examples/RF12/RF12demo/RF12demo.ino
@@ -1,4 +1,4 @@
-/// @dir RF12demo
+F/// @dir RF12demo
 /// Configure some values in EEPROM for easy config of the RF12 later on.
 // 2009-05-06 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

@@ -17,6 +17,14 @@
 #include <util/parity.h>

 #define DEBUG 1
+
+/// Save a few bytes of flash by declaring const if used more than once.
+const char INVALID1[] PROGMEM = "\rInvalid\n";
+const char COMMA[] PROGMEM = ",";
+const char SPACE[] PROGMEM = " ";
+const char INITFAIL[] PROGMEM = "config save failed\n";
+const char VERSION[] PROGMEM = "\n[RF12demo.11]";
+///

 // ATtiny's only support outbound serial @ 38400 baud, and no DataFlash logging

@@ -224,15 +232,13 @@
     eeprom_write_byte(RF12_EEPROM_ADDR + i, b);
   }
   if (!rf12_config())
-    showString(PSTR("config save failed\n"));
+     showString(INITFAIL);
 }

 static byte bandToFreq (byte band) {
    return band == 4 ? RF12_433MHZ : band == 8 ? RF12_868MHZ : band == 9 ? RF12_915MHZ : 0;
 }

-#if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__)
-#else
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // OOK transmit code

@@ -270,7 +276,8 @@
     delay(10);
   }
 }
-
+#if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__)
+#else
 static void kakuSend(char addr, byte device, byte on) {
   int cmd = 0x600 | ((device - 1) << 4) | ((addr - 1) & 0xF);
   if (on)
@@ -465,9 +472,9 @@
   df_flush();
   showString(PSTR("DF S "));
   Serial.print(dfLastPage);
-  showString(PSTR(" "));
+  showString(SPACE);
   Serial.print(dfBuf.seqnum);
-  showString(PSTR(" "));
+  showString(SPACE);
   Serial.println(dfBuf.timestamp);

   // erase next block if we just saved data into a fresh block
@@ -531,7 +538,7 @@

     showString(PSTR("DF I "));
     Serial.print(dfLastPage);
-    showString(PSTR(" "));
+    showString(SPACE);
     Serial.println(dfBuf.seqnum);

     // df_wipe();
@@ -558,9 +565,9 @@
     Serial.print(page);
     showString(PSTR(" : "));
     Serial.print(curr.seqnum);
-    showString(PSTR(" "));
+    showString(SPACE);
     Serial.print(curr.timestamp);
-    showString(PSTR(" "));
+    showString(SPACE);
     Serial.println(curr.crc);
   }
 }
@@ -589,7 +596,7 @@
   word page = scanForMarker(seqnum, asof);
   showString(PSTR("r: page "));
   Serial.print(page);
-  showString(PSTR(" "));
+  showString(SPACE);
   Serial.println(dfLastPage);
   discardInput();
   word savedSeqnum = dfBuf.seqnum;
@@ -607,7 +614,7 @@
     if (crc != 0) {
       showString(PSTR("DF C? "));
       Serial.print(page);
-      showString(PSTR(" "));
+      showString(SPACE);
       Serial.println(crc);
       continue;
     }
@@ -618,13 +625,13 @@
         break;
       showString(PSTR("R "));
       Serial.print(dfBuf.seqnum);
-      showString(PSTR(" "));
+      showString(SPACE);
       Serial.print(dfBuf.timestamp + dfBuf.data[i++]);
-      showString(PSTR(" "));
+      showString(SPACE);
       Serial.print((int) dfBuf.data[i++]);
       byte n = dfBuf.data[i++];
       while (n-- > 0) {
-        showString(PSTR(" "));
+        showString(SPACE);
         Serial.print((int) dfBuf.data[i++]);
       }
       Serial.println();
@@ -632,18 +639,18 @@
     // at end of each page, report a "DF R" marker, to allow re-starting
     showString(PSTR("DF R "));
     Serial.print(page);
-    showString(PSTR(" "));
+    showString(SPACE);
     Serial.print(dfBuf.seqnum);
-    showString(PSTR(" "));
+    showString(SPACE);
     Serial.println(dfBuf.timestamp);
   }
   dfFill = 0; // ram buffer is no longer valid
   dfBuf.seqnum = savedSeqnum + 1; // so next replay will start at a new value
   showString(PSTR("DF E "));
   Serial.print(dfLastPage);
-  showString(PSTR(" "));
+  showString(SPACE);
   Serial.print(dfBuf.seqnum);
-  showString(PSTR(" "));
+  showString(SPACE);
   Serial.println(millis());
 }

@@ -697,10 +704,6 @@
 ;
 #endif

-/// Save a few bytes of flash by declaring const if used more than once.
-const char INVALID1[] PROGMEM = "\rInvalid\n";
-const char COMMA[] PROGMEM = ",";
-///
 static void showString (PGM_P s) {
   for (;;) {
     char c = pgm_read_byte(s++);
@@ -830,12 +833,6 @@
         dest = value;
         memcpy(testbuf, stack, top);
         break;
-#if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__)
-#else
-      case 'l': // turn activity LED on or off
-        if (value) activityLed(1);
-        else activityLed(0);
-        break;
       case 'f': // send FS20 command: <hchi>,<hclo>,<addr>,<cmd>f
         rf12_initialize(0, RF12_868MHZ, 0);
         activityLed(1);
@@ -843,6 +840,12 @@
         activityLed(0);
         rf12_config(0);
         break;
+#if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__)
+#else
+      case 'l': // turn activity LED on or off
+        if (value) activityLed(1);
+        else activityLed(0);
+        break;
       case 'k': // send KAKU command: <addr>,<dev>,<on>k
         rf12_initialize(0, RF12_433MHZ, 0);
         activityLed(1);
@@ -889,6 +892,8 @@
       case 'v': //display the interpreter version
         displayVersion(1);
         break;
+#if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__)
+#else
       case 'j':
         if (stack[0] <= MAX_NODES) {
           const uint8_t *ee_entry = RF12_EEPROM_ADDR + (stack[0] * 32);
@@ -933,12 +938,13 @@
           if (rf12_config())
             initialize();
           else
-            showString(PSTR("Initialize failed\n"));
+            showString(INITFAIL);
         }
         else {
           showString(INVALID1);
         }
       break;
+#endif
       case 'n': // Clear node entries in RAM & eeprom
         if ((stack[0] > 0) && (stack[0] <= MAX_NODES) && (value == 123) && (nodes[stack[0]] == 0)) {
           nodes[stack[0]] = 0xFF;                                           // Clear RAM entry
@@ -1002,7 +1008,7 @@
         }
       else
         {
-          showString(PSTR(" "));
+          showString(SPACE);
           Serial.print((char) data[i]);
         }
     }
@@ -1010,7 +1016,7 @@
 }

 void displayVersion(uint8_t newline ) {
-  showString(PSTR("\n[RF12demo.11]"));
+  showString(VERSION);
   if(newline!=0) {
 #if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__)
     showString(PSTR(" T "));
@@ -1119,11 +1125,11 @@
       showString(PSTR(" G"));
       showByte(rf12_grp);
     }
-    showString(PSTR(" "));
+    showString(SPACE);
     showByte(rf12_hdr);
     for (byte i = 0; i < n; ++i) {
       if (!useHex)
-        showString(PSTR(" "));
+        showString(SPACE);
       showByte(rf12_data[i]);
     }
     Serial.println();


Refactor Arduino SW

Refactor Arduino SW

--- ArduinoSW/Laser-harp/Laser-harp.ino
+++ ArduinoSW/Laser-harp/Laser-harp.ino
@@ -1,146 +1,47 @@
-String inputString = "";         // a string to hold incoming data
-boolean stringComplete = false;
+boolean laserReaderAction = false;
+
+static const byte NUMBER_OF_LASERS = 26;
+
+static int sensorList[NUMBER_OF_LASERS];
+static int laserList[NUMBER_OF_LASERS];
+boolean statesOfLasers[NUMBER_OF_LASERS];

-// První oktáva
-int laser01 = 21;
-int laser02 = 22;
-int laser03 = 23;
-int laser04 = 24;
-int laser05 = 25;
-int laser06 = 26;
-int laser07 = 27;
-int laser08 = 28;
+void setup() {

-// Druhá oktáva
-int laser09 = 29;
-int laser10 = 30;
-int laser11 = 31;
-int laser12 = 32;
-int laser13 = 33;
-int laser14 = 34;
-int laser15 = 35;
-int laser16 = 36;
+  for(int i = 0; i <= NUMBER_OF_LASERS; i++)
+  {
+    sensorList[i] = i + 2;
+    pinMode(sensorList[i], INPUT);
+
+    laserList[i] = i + 28;
+    pinMode(laserList[i], OUTPUT);
+    digitalWrite(laserList[i], HIGH);

-// Třetí oktáva
-int laser17 = 37;
-int laser18 = 38;
-int laser19 = 39;
-int laser20 = 40;
-int laser21 = 41;
-int laser22 = 42;
-int laser23 = 43;
-int laser24 = 44;
+    statesOfLasers[i] = false;
+  }

-int oktava1[8];
-int oktava2[8];
-int oktava3[8];
-
-
-void setup() {
-  // initialize serial:
-  Serial.begin(9600);
-  inputString.reserve(200);
-
-  pinMode(laser01, INPUT);
-  pinMode(laser02, INPUT);
-  pinMode(laser03, INPUT);
-  pinMode(laser04, INPUT);
-  pinMode(laser05, INPUT);
-  pinMode(laser06, INPUT);
-  pinMode(laser07, INPUT);
-  pinMode(laser08, INPUT);
-
-  pinMode(laser09, INPUT);
-  pinMode(laser10, INPUT);
-  pinMode(laser11, INPUT);
-  pinMode(laser12, INPUT);
-  pinMode(laser13, INPUT);
-  pinMode(laser14, INPUT);
-  pinMode(laser15, INPUT);
-  pinMode(laser16, INPUT);
-
-  pinMode(laser17, INPUT);
-  pinMode(laser18, INPUT);
-  pinMode(laser19, INPUT);
-  pinMode(laser20, INPUT);
-  pinMode(laser21, INPUT);
-  pinMode(laser22, INPUT);
-  pinMode(laser23, INPUT);
-  pinMode(laser24, INPUT);
+  Serial.begin(9600);
 }

 void loop() {

-oktava1[0] = digitalRead(laser01);
-oktava1[1] = digitalRead(laser02);
-oktava1[2] = digitalRead(laser03);
-oktava1[3] = digitalRead(laser04);
-oktava1[4] = digitalRead(laser05);
-oktava1[5] = digitalRead(laser06);
-oktava1[6] = digitalRead(laser07);
-oktava1[7] = digitalRead(laser08);
-
-sendOktava(oktava1);
-
-oktava2[0] = digitalRead(laser09);
-oktava2[1] = digitalRead(laser10);
-oktava2[2] = digitalRead(laser11);
-oktava2[3] = digitalRead(laser12);
-oktava2[4] = digitalRead(laser13);
-oktava2[5] = digitalRead(laser14);
-oktava2[6] = digitalRead(laser15);
-oktava2[7] = digitalRead(laser16);
-
-sendOktava(oktava2);
-
-oktava3[0] = digitalRead(laser17);
-oktava3[1] = digitalRead(laser18);
-oktava3[2] = digitalRead(laser19);
-oktava3[3] = digitalRead(laser20);
-oktava3[4] = digitalRead(laser21);
-oktava3[5] = digitalRead(laser22);
-oktava3[6] = digitalRead(laser23);
-oktava3[7] = digitalRead(laser24);
-
-sendOktava(oktava3);
-
-delay(1000);
-
-
-
-serialEvent(); //call the function
-  // print the string when a newline arrives:
-  if (stringComplete) {
-    inputString.trim();
-    Serial.println(inputString);
-
-    // clear the string:
-    inputString = "";
-    stringComplete = false;
+  for(int i = 0 ; i < NUMBER_OF_LASERS; i++){
+    pinMode(sensorList[i], INPUT);
+    Serial.println(sensorList[i]);
+  }
+  delay(10000);
+
+  if(laserReaderAction){
+     LaserReader();
   }
 }

+static void LaserReader(){

-void sendOktava(int* oktava) {
-  for (int x=0; x<8; x++) {
-    Serial.print(oktava[x]);
+  for (int i = 0; i < NUMBER_OF_LASERS; i++) {
+    statesOfLasers[i] = sensorList[i] != HIGH;
   }
-  Serial.println();
+
 }
-
-void serialEvent() {
-  while (Serial.available()) {
-    // get the new byte:
-    char inChar = (char)Serial.read();
-    // add it to the inputString:
-    inputString += inChar;
-    // if the incoming character is a newline, set a flag
-    // so the main loop can do something about it:
-    if (inChar == '\n') {
-      stringComplete = true;
-    }
-  }
-}
-


Renamed storageGetPattern to storageGetFileContents as there's nothing pattern-specific about it.

--- firmware/LaserBox/Storage.ino
+++ firmware/LaserBox/Storage.ino
@@ -9,25 +9,25 @@
   }
 }

-// read all pattern data from a specific pattern file, return the length of it
+// read all data from a specific file, return the length of it
 // returns a pointer which must be freed when done with it!
-// TODO: DRY this with storageGetRandomPattern
-int *storageGetPattern(char *patternFilename, byte **patternData) {
-  File patternFile;
-  byte patternLength;
+// TODO: DRY this with storageGetRandomPattern?
+int *storageGetFileContents(char *fileName, byte **fileData) {
+  File theFile;
+  byte fileLength;

-  patternFile = SD.open(patternFilename);
-  patternLength = patternFile.available();
-  *patternData = malloc(patternLength); // TODO: should read from the file bit by bit as we parse, ideally
-  if(patternData == NULL) {
-    debugMessage("Failed to allocate memory for pattern.");
-    patternFile.close();
+  theFile = SD.open(fileName);
+  fileLength = theFile.available();
+  *fileData = malloc(fileLength); // TODO: should read from the file bit by bit as we parse, ideally
+  if(fileData == NULL) {
+    debugMessage("Failed to allocate memory for file.");
+    theFile.close();
     return 0;
   }
-  patternFile.read(*patternData, patternLength);
-  patternFile.close();
+  theFile.read(*fileData, fileLength);
+  theFile.close();

-  return patternLength;
+  return fileLength;
 }

 // read all pattern data from a random file of a provided type, return the length of it


slight tweak to throttle values.

slight tweak to throttle values.

--- teensy_rc_control/teensy_rc_control.ino
+++ teensy_rc_control/teensy_rc_control.ino
@@ -156,10 +156,10 @@
     }
     // TODO REMOVEME
     if (fsValues[6] < 1300) {
-      if (sendThrottle > 1540) sendThrottle = 1540;
+      if (sendThrottle > 1548) sendThrottle = 1548;
       if (sendThrottle < 1430) sendThrottle = 1430;
     } else if (fsValues[6] < 1700) {
-      if (sendThrottle > 1580) sendThrottle = 1580;
+      if (sendThrottle > 1570) sendThrottle = 1570;
       if (sendThrottle < 1430) sendThrottle = 1430;
     }
     carSteer.writeMicroseconds(map_polarity(sendSteer, STEER_INVERT));


add new message to detect end of initialization

--- Arduino/chorus-rf-laptimer/chorus-rf-laptimer.ino
+++ Arduino/chorus-rf-laptimer/chorus-rf-laptimer.ino
@@ -105,6 +105,7 @@
 #define RESPONSE_CALIBR_STATE   'i'
 #define RESPONSE_MONITOR_STATE  'V'
 #define RESPONSE_LAP0_STATE     'F'
+#define RESPONSE_END_SEQUENCE   'X'

 // send item byte constants
 // Must correspond to sequence of numbers used in "send data" switch statement
@@ -113,16 +114,17 @@
 #define SEND_RACE_STATE     1
 #define SEND_MIN_LAP_TIME   2
 #define SEND_THRESHOLD      3
-#define SEND_CURRENT_RSSI   4
-#define SEND_ALL_LAPTIMES   5
-#define SEND_SOUND_STATE    6
-#define SEND_BAND           7
-#define SEND_CALIBR_STATE   8
-#define SEND_MONITOR_STATE  9
-#define SEND_LAP0_STATE     10
+#define SEND_ALL_LAPTIMES   4
+#define SEND_SOUND_STATE    5
+#define SEND_BAND           6
+#define SEND_CALIBR_STATE   7
+#define SEND_MONITOR_STATE  8
+#define SEND_LAP0_STATE     9
+#define SEND_END_SEQUENCE   10
 // following itmes don't participate in "send all itmes" response
 #define SEND_LAST_LAPTIMES  100
 #define SEND_CALIBR_TIME    101
+#define SEND_CURRENT_RSSI   102
 // special item that sends all subsequent items from 0 (see above)
 #define SEND_ALL_DEVICE_STATE 255

@@ -294,12 +296,7 @@
                     onItemSent();
                 }
                 break;
-            case 4: // SEND_CURRENT_RSSI
-                if (sendIntToSerial(RESPONSE_CURRENT_RSSI, rssi)) {
-                    onItemSent();
-                }
-                break;
-            case 5: // SEND_ALL_LAPTIMES
+            case 4: // SEND_ALL_LAPTIMES
                 if (sendLapTimesIndex < newLapIndex) {
                     if (sendLaptimeToSerial(RESPONSE_LAPTIME, sendLapTimesIndex, lapTimes[sendLapTimesIndex])) {
                         sendLapTimesIndex++;
@@ -309,37 +306,39 @@
                     onItemSent();
                 }
                 break;
-            case 6: // SEND_SOUND_STATE
+            case 5: // SEND_SOUND_STATE
                 if (send4BitsToSerial(RESPONSE_SOUND_STATE, isSoundEnabled)) {
                     onItemSent();
                 }
                 break;
-            case 7: // SEND_BAND
+            case 6: // SEND_BAND
                 if (send4BitsToSerial(RESPONSE_BAND, bandIndex)) {
                     onItemSent();
                 }
                 break;
-            case 8: // SEND_CALIBR_STATE
+            case 7: // SEND_CALIBR_STATE
                 if (send4BitsToSerial(RESPONSE_CALIBR_STATE, isCalibrated)) {
                     onItemSent();
                 }
                 break;
-            case 9: // SEND_MONITOR_STATE
+            case 8: // SEND_MONITOR_STATE
                 if (send4BitsToSerial(RESPONSE_MONITOR_STATE, rssiMonitor)) {
                     onItemSent();
                 }
                 break;
-            case 10: // SEND_LAP0_STATE
+            case 9: // SEND_LAP0_STATE
                 if (send4BitsToSerial(RESPONSE_LAP0_STATE, shouldSkipFirstLap)) {
                     onItemSent();
                 }
                 break;
-
             // Below is a termination case, to notify that data for CONTROL_DATA_REQUEST is over.
             // Must be the last item in the sequence!
-            case 11:
-                isSendingData = 0;
-                shouldSendSingleItem = 1;
+            case 10: // SEND_END_SEQUENCE
+                if (send4BitsToSerial(RESPONSE_END_SEQUENCE, 1)) {
+                    onItemSent();
+                    isSendingData = 0;
+                    shouldSendSingleItem = 1;
+                }
                 break;

             //--------------------------------------------------------------------------------------
@@ -360,6 +359,11 @@
                 break;
             case 101: // SEND_CALIBR_TIME
                 if (sendLongToSerial(RESPONSE_CALIBR_TIME, calibrationMilliseconds)) {
+                    onItemSent();
+                }
+                break;
+            case 102: // SEND_CURRENT_RSSI
+                if (sendIntToSerial(RESPONSE_CURRENT_RSSI, rssi)) {
                     onItemSent();
                 }
                 break;


minor tweaks for maintainability

minor tweaks for maintainability

--- garden.ino
+++ garden.ino
@@ -9,23 +9,20 @@
 #define ZONE2 D4
 #define ZONE3 D5
 #define ZONE4 D6
+#define NUM_ZONES 4

 // ************************* VARIABLES *************************

 unsigned long last_cloud_time_sync = millis();
-int num_of_zones = 4;
-byte zone_state_array[num_of_zones] = {0,0,0,0};
-byte zones[num_of_zones] = {ZONE1, ZONE2, ZONE3, ZONE4};
+byte zone_state_array[NUM_ZONES] = {0,0,0,0};
+byte zones[NUM_ZONES] = {ZONE1, ZONE2, ZONE3, ZONE4};
 byte test_timer = 20;	// seconds for "relay test heartbeat timer"

 void setup() {

-	// set time zone to PST (daylight -6, std -7) on each boot
-	set_time_zone(-7);
-
 	// pin setup and initialization
-	for (int i = 0; i < num_of_zones; i++){
+	for (int i = 0; i < NUM_ZONES; i++){
 		pinMode(zones[i], OUTPUT);
 		digitalWrite(zones[i], LOW);
 	}
@@ -51,9 +48,6 @@

 void run_zone_for_duration(char zone_number, int duration){
 	// turn on zone for duration
-
-	// set timer and run
-	//change_zone_valve(zone_number, true);
 }

 bool change_zone_valve(int zone_number, bool on_or_off){
@@ -61,6 +55,9 @@
 	String status;

 	if (on_or_off){
+        // turn other zones off
+        zones_all_off("");
+
 		status = "on";
         digitalWrite(zones[zone_number-1], HIGH);
 	} else {
@@ -73,35 +70,11 @@
 	return on_or_off;
 }

-int zones_all_off(){
+int zones_all_off(String command){
 	// turn all zones off

 	Particle.publish("striide.garden.all_off");
-    for (int i = 0; i < num_of_zones; i++){
+    for (int i = 0; i < NUM_ZONES; i++){
 		digitalWrite(zones[i], LOW);
 	}
-}
-
-// ************************* TIME FUNCTIONS *************************
-
-void set_time_zone(float offset){
-	// set the current time zone
-	Time.zone(offset);
-}
-
-bool check_sync_timer(){
-	// check if 24 hours have passed
-	if (millis() - last_cloud_time_sync > ONE_DAY_MILLIS) {
-		return true;
-	} else {
-		return false;
-	}
-}
-
-void sync_time_with_cloud(){
-	// update current time on microprocessor
-// 	Particle.syncTime();
-	last_cloud_time_sync = millis();
-
-	Particle.publish("striide.garden.runzone");
-}
+}


Led update frequency is now 20Hz.

Led update frequency is now 20Hz.

--- aquacontrol32.ino
+++ aquacontrol32.ino
@@ -13,7 +13,7 @@
 #define COUNTRY_CODE_ISO_3166 "nl"  //https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

 //update frequency for LEDS in Hz
-#define UPDATE_FREQ_HZ        10
+#define UPDATE_FREQ_HZ        20

 // number of bit precission for LEDC timer
 #define LEDC_NUMBER_OF_BIT    16


removing setpixel call

removing setpixel call

--- firmware/beer/beersensor.ino
+++ firmware/beer/beersensor.ino
@@ -184,7 +184,7 @@
   currentSecond = Time.second();
   if(currentSecond != previousSecond)
   {
-      setPixels(instantPulseCount);
+      // setPixels(instantPulseCount);
       instantPulseCount = 0;
       previousSecond = currentSecond;
   }


change alarm implementation

change alarm implementation

--- src/elm_clk.ino
+++ src/elm_clk.ino
@@ -52,7 +52,7 @@

 #define SHOW_TIME_DURATION    7000
 #define SHOW_TEMP_DURATION    3000
-#define ALARM_CLEAR_DURATION 61000
+#define ALARM_CLEAR_DURATION 60001
 // ---------------------- //
 //  Common definitions
 // ---------------------- //
@@ -65,17 +65,18 @@
 byte fsmState       = 0;
 byte activeDigit    = 0;
 byte digitValues[N] = {0,0,0,0};
-byte alarmTriggeredToday = 0;
 int  tempInCelsius  = 0;
 unsigned long updateInterval    = 100;
 unsigned long lastTempRead      = 0;
 unsigned long lastClockRead     = 0;
 unsigned long lastShowTimeStart = 0;
 unsigned long lastShowTempStart = 0;
+unsigned long lastAlarmTrigger  = 0;
 unsigned long lastAlarmCleared  = 0;

-SevenSegController display(DIGIT0_PIN, DIGIT1_PIN, DIGIT2_PIN, DIGIT3_PIN, COLON_PIN, DEGREE_PIN, LATCH_PIN, DATA_PIN, CLOCK_PIN);
+SevenSegController display(DIGIT0_PIN, DIGIT1_PIN, DIGIT2_PIN, DIGIT3_PIN,
+	COLON_PIN, DEGREE_PIN, LATCH_PIN, DATA_PIN, CLOCK_PIN);
 OneButton buttonA(BUTTON_A_PIN, true);
 OneButton buttonB(BUTTON_B_PIN, true);
 OneWire oneWire(ONE_WIRE_BUS);
@@ -87,7 +88,8 @@
 // -------------------------------------- //
 void printDigits(int digits, char separator)
 {
-  // utility function for digital clock display: prints preceding separator and leading 0
+  // Utility function for digital clock display: prints preceding
+  // separator and leading 0
   Serial.print(separator);
   if(digits < 10)
     Serial.print('0');
@@ -153,7 +155,6 @@

 void setRtcAlarm(byte hour, byte minute)
 {
-	alarmTriggeredToday = 0;
 	tmElements_t hourSetting;
 	hourSetting.Hour = hour;
 	RTC.setAlarm(ALARM_0, makeTime(hourSetting));
@@ -165,6 +166,8 @@
 	// save alarm setting to parts of SRAM, easier retrieval
 	RTC.sramWrite(ALARM_H_ADDR, hour);
 	RTC.sramWrite(ALARM_M_ADDR, minute);
+
+	lastAlarmTrigger = 0;
 }

 // Debug statements, print new alarm / status to serial port.
@@ -275,9 +278,16 @@
 void playSong()
 {
 	display.disableDisplay();
-	int melody[] = {1319, 0, 1319, 0, 1319, 0, 1319, 0, 1976, 0, 1976, 0, 1976, 0, 1976, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1976, 0, 1976, 0, 1976, 0, 1976, 0, 2349, 0, 2349, 0, 2349, 0, 2349, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0};
-
-	int noteDurations[] = {63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42};
+	int melody[] = {1319, 0, 1319, 0, 1319, 0, 1319, 0, 1976, 0, 1976, 0, 1976,
+	 0, 1976, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1976, 0, 1976, 0, 1976, 0,
+	 1976, 0, 2349, 0, 2349, 0, 2349, 0, 2349, 0, 1760, 0, 1760, 0, 1760, 0,
+	  1760, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0, 1760, 0,
+	   1760, 0};
+
+	int noteDurations[] = {63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63,
+	 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42,
+	  63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42,
+	   63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42, 63, 42};

 	// iterate over the notes of the melody:
 	for (int thisNote = 0; thisNote < 64; thisNote++)
@@ -466,11 +476,12 @@

 	// If alarm condition is detected, modify FSM state accordingly
 	// When an alarm is triggered, the alarm pin is pulled low.
-	if (!digitalRead(ALARM_PIN) && !alarmTriggeredToday)
+	//if (RTC.alarm(ALARM_0) && RTC.alarm(ALARM_1) && !alarmTriggeredToday)
+	if (RTC.alarm(ALARM_0) && RTC.alarm(ALARM_1) && (millis()-lastAlarmTrigger) > ALARM_CLEAR_DURATION)
 	{
 		oldFsmState = fsmState;
 		fsmState    = SHOW_ALARM_MODE;
-		alarmTriggeredToday = 1;
+		lastAlarmTrigger = millis();
 	}

@@ -530,11 +541,6 @@

 			oldFsmState = fsmState;

-			if (alarmTriggeredToday && ((millis() - lastAlarmCleared) > ALARM_CLEAR_DURATION))
-			{
-				alarmTriggeredToday = 0;
-			}
-
 			if ((millis() - lastClockRead) > updateInterval)
 			{
 				updateTime();


Update RovMain.ino

Update RovMain.ino

minPW값 100으로 조정


Increase clock speed

Increase clock speed

--- Arduino/noise_multiplier/noise_multiplier.ino
+++ Arduino/noise_multiplier/noise_multiplier.ino
@@ -32,9 +32,9 @@
            | bit (CS11);                  // Start timer, prescaler of 8

   // Initialize OCR1A = 300 (pulse_width = 150us), OCR1B, and ICR1
-  ICR1 = 45;
-  OCR1B = 22;
-  OCR1A = 22;
+  ICR1 = 15;
+  OCR1B = 7;
+  OCR1A = 7;

   // enable timer compare interrupt
   TIMSK1 |= (1 << OCIE1A);


Lower case seems easier to read, but to avoid conflicts with the struct I renamed the struct values. I left the dark pixels upper case as that seemed to enhance the clarity

--- projects/arduino/led_matrix_256/led_matrix_256.ino
+++ projects/arduino/led_matrix_256/led_matrix_256.ino
@@ -17,74 +17,74 @@
 //int sensorValue = 0;  // variable to store the value coming from the sensor

 struct COLOR {
-  byte r;
-  byte g;
-  byte b;
+  byte red;
+  byte green;
+  byte blue;
 };

 #define D {0x00, 0x00, 0x00}
-#define B {0x00, 0x00, 0xFF}
-#define G {0x00, 0xFF, 0x00}
-#define R {0xFF, 0x00, 0x00}
-#define P {0xFF, 0x00, 0xFF}
-#define Y {0xFF, 0xFF, 0x00}
-#define A {0x00, 0xFF, 0xFF}
-#define W {0xFF, 0xFF, 0xFF}
+#define b {0x00, 0x00, 0xFF}
+#define g {0x00, 0xFF, 0x00}
+#define r {0xFF, 0x00, 0x00}
+#define p {0xFF, 0x00, 0xFF}
+#define y {0xFF, 0xFF, 0x00}
+#define a {0x00, 0xFF, 0xFF}
+#define w {0xFF, 0xFF, 0xFF}

 const PROGMEM COLOR frames[][NUM_OF_PIXELS] = { {
-        D,D,W,W,D,D,D,D,D,D,D,D,D,D,D,D,
-        D,D,D,D,D,D,D,D,D,D,D,W,D,W,D,D,
-        D,D,D,W,D,W,D,D,D,D,D,D,D,D,D,D,
-        D,D,D,D,D,D,D,D,D,W,D,D,D,D,D,D,
-        D,D,D,D,D,D,W,W,W,W,W,D,D,D,D,D,
-        D,D,D,D,D,W,W,W,W,W,D,D,D,D,D,D,
-        D,D,D,D,D,R,R,R,G,R,R,R,D,D,D,D,
-        D,D,D,R,R,R,R,G,R,R,R,R,D,D,D,D,
-        D,D,D,R,R,R,R,G,G,G,R,R,R,R,D,D,
-        D,D,R,R,R,R,G,G,G,R,R,R,R,D,D,D,
-        D,D,D,R,R,R,G,G,G,G,G,R,R,R,D,D,
-        D,D,R,R,G,G,G,G,G,G,G,R,R,D,D,D,
-        D,D,D,R,G,G,G,G,G,G,G,G,G,R,D,D,
-        D,D,D,R,R,R,R,Y,R,R,R,R,D,D,D,D,
-        D,D,D,D,D,R,R,R,Y,R,R,R,D,D,D,D,
-        D,D,D,D,D,R,R,Y,R,R,D,D,D,D,D,D
+        D,D,w,w,D,D,D,D,D,D,D,D,D,D,D,D,
+        D,D,D,D,D,D,D,D,D,D,D,w,D,w,D,D,
+        D,D,D,w,D,w,D,D,D,D,D,D,D,D,D,D,
+        D,D,D,D,D,D,D,D,D,w,D,D,D,D,D,D,
+        D,D,D,D,D,D,w,w,w,w,w,D,D,D,D,D,
+        D,D,D,D,D,w,w,w,w,w,D,D,D,D,D,D,
+        D,D,D,D,D,r,r,r,g,r,r,r,D,D,D,D,
+        D,D,D,r,r,r,r,g,r,r,r,r,D,D,D,D,
+        D,D,D,r,r,r,r,g,g,g,r,r,r,r,D,D,
+        D,D,r,r,r,r,g,g,g,r,r,r,r,D,D,D,
+        D,D,D,r,r,r,g,g,g,g,g,r,r,r,D,D,
+        D,D,r,r,g,g,g,g,g,g,g,r,r,D,D,D,
+        D,D,D,r,g,g,g,g,g,g,g,g,g,r,D,D,
+        D,D,D,r,r,r,r,y,r,r,r,r,D,D,D,D,
+        D,D,D,D,D,r,r,r,y,r,r,r,D,D,D,D,
+        D,D,D,D,D,r,r,y,r,r,D,D,D,D,D,D
     },

-    {   D,D,D,D,D,D,D,D,R,D,D,D,D,D,D,D,
-        D,D,D,D,D,D,D,R,D,D,D,D,D,D,D,D,
-        D,D,D,D,D,D,D,R,W,R,D,D,D,D,D,D,
-        D,D,D,D,D,R,R,W,R,R,D,D,D,D,D,D,
-        D,D,D,D,D,D,D,R,R,R,D,D,D,D,D,D,
-        D,D,D,D,D,D,D,Y,D,D,D,D,D,D,D,D,
-        D,D,D,D,D,D,D,D,Y,D,D,D,D,D,D,D,
-        D,D,D,D,W,W,W,W,W,W,W,D,D,D,D,D,
-        D,D,D,D,D,W,W,W,W,W,W,W,D,D,D,D,
-        D,D,D,D,W,W,W,W,W,W,W,D,D,D,D,D,
-        D,D,D,D,D,W,W,W,W,W,W,W,D,D,Y,D,
-        Y,D,Y,D,W,W,W,W,W,W,W,D,D,D,D,D,
-        Y,Y,Y,D,D,W,W,W,W,W,W,W,D,D,Y,D,
-        D,Y,Y,Y,W,W,W,W,W,W,W,Y,Y,Y,Y,D,
-        D,D,D,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,D,D,
-        D,D,D,Y,Y,Y,Y,Y,Y,Y,Y,Y,D,D,D,D
+    {   D,D,D,D,D,D,D,D,r,D,D,D,D,D,D,D,
+        D,D,D,D,D,D,D,r,D,D,D,D,D,D,D,D,
+        D,D,D,D,D,D,D,r,w,r,D,D,D,D,D,D,
+        D,D,D,D,D,r,r,w,r,r,D,D,D,D,D,D,
+        D,D,D,D,D,D,D,r,r,r,D,D,D,D,D,D,
+        D,D,D,D,D,D,D,y,D,D,D,D,D,D,D,D,
+        D,D,D,D,D,D,D,D,y,D,D,D,D,D,D,D,
+        D,D,D,D,w,w,w,w,w,w,w,D,D,D,D,D,
+        D,D,D,D,D,w,w,w,w,w,w,w,D,D,D,D,
+        D,D,D,D,w,w,w,w,w,w,w,D,D,D,D,D,
+        D,D,D,D,D,w,w,w,w,w,w,w,D,D,y,D,
+        y,D,y,D,w,w,w,w,w,w,w,D,D,D,D,D,
+        y,y,y,D,D,w,w,w,w,w,w,w,D,D,y,D,
+        D,y,y,y,w,w,w,w,w,w,w,y,y,y,y,D,
+        D,D,D,y,y,y,y,y,y,y,y,y,y,y,D,D,
+        D,D,D,y,y,y,y,y,y,y,y,y,D,D,D,D
     },

-    {   D,D,D,D,D,D,D,G,G,D,D,D,D,D,D,D,
-        D,D,D,D,D,D,D,G,G,D,D,D,D,D,D,D,
-        D,D,D,D,D,D,B,G,G,G,D,D,D,D,D,D,
-        D,D,D,D,D,D,G,G,B,R,D,D,D,D,D,D,
-        D,D,D,D,D,G,G,G,B,G,B,D,D,D,D,D,
-        D,D,D,D,D,G,B,G,G,G,B,D,D,D,D,D,
-        D,D,D,D,G,G,B,G,G,G,B,B,D,D,D,D,
-        D,D,D,D,G,R,G,B,B,G,G,G,D,D,D,D,
-        D,D,D,G,B,G,G,G,G,B,B,G,G,D,D,D,
-        D,D,D,G,B,P,G,G,G,B,B,G,G,D,D,D,
-        D,D,B,G,P,G,G,B,G,G,G,G,B,B,D,D,
-        D,D,G,G,Y,G,B,B,G,R,G,B,B,G,D,D,
-        D,G,G,G,G,B,B,G,G,G,B,B,G,G,G,D,
-        D,D,D,D,D,D,Y,Y,Y,Y,D,D,D,D,D,D,
-        D,D,D,D,D,D,Y,Y,Y,Y,D,D,D,D,D,D,
-        D,D,D,D,D,D,Y,Y,Y,Y,D,D,D,D,D,D
+    {   D,D,D,D,D,D,D,g,g,D,D,D,D,D,D,D,
+        D,D,D,D,D,D,D,g,g,D,D,D,D,D,D,D,
+        D,D,D,D,D,D,b,g,g,g,D,D,D,D,D,D,
+        D,D,D,D,D,D,g,g,b,r,D,D,D,D,D,D,
+        D,D,D,D,D,g,g,g,b,g,b,D,D,D,D,D,
+        D,D,D,D,D,g,b,g,g,g,b,D,D,D,D,D,
+        D,D,D,D,g,g,b,g,g,g,b,b,D,D,D,D,
+        D,D,D,D,g,r,g,b,b,g,g,g,D,D,D,D,
+        D,D,D,g,b,g,g,g,g,b,b,g,g,D,D,D,
+        D,D,D,g,b,p,g,g,g,b,b,g,g,D,D,D,
+        D,D,b,g,p,g,g,b,g,g,g,g,b,b,D,D,
+        D,D,g,g,y,g,b,b,g,r,g,b,b,g,D,D,
+        D,g,g,g,g,b,b,g,g,g,b,b,g,g,g,D,
+        D,D,D,D,D,D,y,y,y,y,D,D,D,D,D,D,
+        D,D,D,D,D,D,y,y,y,y,D,D,D,D,D,D,
+        D,D,D,D,D,D,y,y,y,y,D,D,D,D,D,D
     }
 };

@@ -122,7 +122,7 @@
     // Setup every pixels
     for(uint8_t i = 0; i < strip.numPixels(); i++) {
         pixel = frames[frameNumber][i];
-        strip.setPixelColor(i, pixel.r, pixel.g, pixel.b);
+        strip.setPixelColor(i, pixel.red, pixel.green, pixel.blue);
     }

     // Render the frame


Signed-off-by: jboehm1 <boehm.jean@gmail.com>

--- arduino/serial/serial.ino
+++ arduino/serial/serial.ino
@@ -23,6 +23,7 @@

         //VOLTMETRE
 int batteryLevel;
+char batteryLevel_char;
 float voltage;
 int mesure_voltage;
   //R1=97.9 kOhms
@@ -36,12 +37,12 @@
 void setup() {
   Serial.begin(9600);
   voltmetre();
-  Serial.print("Voltage = ");Serial.print(voltage);Serial.println(" V ");Serial.println();
+  //Serial.print("Voltage = ");Serial.print(mesure_voltage);Serial.println(" V ");Serial.println();

   if (voltage<6.5)
   {
-    Serial.println("CRITICAL ERROR : BATTERY TOO LOW !");
+    Serial.print((char)150); //valeur arbitraire
     while(1);
   }

@@ -49,8 +50,8 @@
     servo[j].attach(brocheServo[j], 800, 2100);     //Necessité de reduire la largeur de la PWM pour la restreindre (course des premiers servos~140)
   }
   for (int j=2 ; j<nbrServos ; j++){
-    servo[j].attach(brocheServo[j], 550, 2450);  //Pour servo poignet1 : 650,2400?
-    //Par défaut : 500,2500, par sécurité j'enlève 50us pour pas arriver en butée mécanique
+    servo[j].attach(brocheServo[j], 600, 2400);  //Pour servo poignet1 : 650,2400?
+    //Par défaut : 500,2500, par sécurité j'enlève 50us voire 100us pour pas arriver en butée mécanique
   }

   for (int k=0; k<nbrServos; k++){
@@ -62,7 +63,7 @@
 }

 void loop() {
-  if (periode>16000000){
+  if (periode>1600){
     voltmetre();
     periode=0;
     //Serial.println("loop");
@@ -114,9 +115,11 @@
     voltage = mesure_voltage / (255/5);
     voltage = voltage * 0.50229;
     batteryLevel=(voltage-6.6)*100/2.4;
-    if(batteryLevel > 0) Serial.println(batteryLevel);
+    batteryLevel_char=batteryLevel;
+    if(batteryLevel > 0) Serial.print(batteryLevel_char);
     //Serial.print(voltage);
     //Serial.println(" V ");
+    //Serial.println(batteryLevel);
     //else Serial.println("error");
 }

@@ -145,3 +148,25 @@
 void stillLED(){
   analogWrite(pinLED,250);
 }
+
+
+/*************** softPWM  ***************/
+void softPWM(int pin, int dutyCycle/* Percentage */) {
+  currentMicros = micros(); //Time elapsed since the start of the start of the programm
+  if (currentMicros - previousMicros <= dutyCycle*period/100) {
+    digitalWrite(pin,HIGH);
+    Serial.println("ON");
+  }
+  else {
+    if ( currentMicros - previousMicros <= period) {
+      digitalWrite(pin, LOW);
+      Serial.println("OFF");
+    }
+    else {
+      digitalWrite(pin, HIGH);
+      Serial.println("ON");
+      previousMicros = currentMicros;
+    }
+  }
+}
+


delay to make sure lcd is working

delay to make sure lcd is working

--- CapTouchPaint/CapTouchPaint.ino
+++ CapTouchPaint/CapTouchPaint.ino
@@ -116,7 +116,7 @@
   Wire.begin(I2C_MASTER, 0, 0, I2C_PINS_18_19, I2C_PULLUP_EXT, I2C_RATE_800);
   Serial.begin(115200);
   Serial.println(F("Cap Touch Paint!"));
-
+  delay(1000);
   tft.begin();
   tft.setRotation(3);
   tft.fillScreen(BLACK);


fixed float formating

fixed float formating

--- SpaceAPI/SpaceAPI.ino
+++ SpaceAPI/SpaceAPI.ino
@@ -41,7 +41,9 @@

   if (DEBUG) return;

-  snprintf(sendBuffer, sizeof sendBuffer, "key=%s&temp=%d \0", TOKEN, (int)temp);
+  char floatBuffer[5];
+  dtostrf(temp, 4, 2, floatBuffer);
+  snprintf(sendBuffer, sizeof sendBuffer, "key=%s&temp=%s \0", TOKEN, floatBuffer);
   ether.httpPost(endpoint, api, NULL, sendBuffer, NULL);

 //  Serial.println("[>] Done sending temperature!");
@@ -150,7 +152,7 @@
       Serial.print("[!] Temp updated: ");
       Serial.println(newTemp);
       updateTemperature(newTemp);
-      //oldTemp = newTemp;
+      oldTemp = newTemp;
     } else Serial.println("[*] Nothing to do.");

   }


Comment out some things that currently aren't working

--- Event_Printer/Event_Printer.ino
+++ Event_Printer/Event_Printer.ino
@@ -205,10 +205,11 @@
 void print_status()
 {
   String text = "";
-
+  /*
   text += "Throttle: ";
   text += motorcycle_state.throttle_position;
   text += "%        \n";
+  */

   text += "Heated Grips: ";
   if ( motorcycle_state.heated_grips == K25_Heated_Grips_State_off ) text += "OFF";
@@ -257,12 +258,13 @@
   else if ( motorcycle_state.abs_system == K25_ABS_State_on ) text += "ON";
   else text += "Unknown";
   text += "       \n";
-
+/*
   text += "ALS: ";
   if ( motorcycle_state.als == K25_ALS_State_dark ) text += "DARK";
   else if ( motorcycle_state.als == K25_ALS_State_light ) text += "LIGHT";
   else text += "Unknown";
   text += "       \n";
+*/

 #if PRINT_STATUS_TO_SERIAL_CONSOLE
   Serial.println(text);


Some quick code cleanups.

Some quick code cleanups.

--- octotemp/code/OctoTemp/OctoTemp/OctoTemp.ino
+++ octotemp/code/OctoTemp/OctoTemp/OctoTemp.ino
@@ -5,7 +5,8 @@
 #define SCLPIN 12

 // TODO(z2amiller):  Set up interrupts to call back when the temperature
-//                   on one of the pins gets too hot.
+//                   on one of the pins gets too hot.  Needs to be added to
+//                   an options class passed to the ADC library.
 #define ADC_INT 14

 #define ADC_ADDR 0x37
@@ -14,13 +15,13 @@
 class TI128D818 {
  public:
   TI128D818();
-  TI128D818(uint8_t add_addr);
-  bool init(uint8_t adc_mode = 0);
-  float temp(uint8_t channel = 0);
+  TI128D818(const uint8_t add_addr);
+  bool init(const uint8_t adc_mode = 0);
+  float temp(const uint8_t channel = 0);
  private:
-  uint8_t read8(uint8_t addr);
-  uint16_t read16(uint8_t addr);
-  void write8(uint8_t addr, uint8_t data);
+  uint8_t read8(const uint8_t addr);
+  uint16_t read16(const uint8_t addr);
+  void write8(const uint8_t addr, const uint8_t data);
   void pollUntilReady();
   uint8_t adc_addr_;
 };
@@ -29,27 +30,22 @@
   adc_addr_ = ADC_ADDR;
 }

-TI128D818::TI128D818(uint8_t adc_addr) {
+TI128D818::TI128D818(const uint8_t adc_addr) {
     adc_addr_ = adc_addr;
 }

 // TODO(z2amiller):  Have a maximum allowed elapsed time?
 // TODO(z2amiller):  Can't dump to serial in a library.  #ifdef debug?
 void TI128D818::pollUntilReady() {
-  bool ok = false;
   int delay_time = 33;
-  while (!ok) {
+  while (true) {
     delay(delay_time);
-    Serial.print("Polling ADC for ready state..");
-    int r = read8(0x0C);
+    const int r = read8(0x0C);
     if (r && 0x02) {
-      Serial.print(" not OK yet, state = ");
-      Serial.println(r);
       delay_time *= 1.4;
-    } else {
-      ok = true;
-      Serial.println(" Ready!");
+      continue;
     }
+    break;
   }
 }

@@ -57,7 +53,7 @@
 // TODO(z2amiller):  Have the TI128D818 library only return the raw
 //                   temperature value, this temperature conversion
 //                   is very application specific.
-float TI128D818::temp(uint8_t channel) {
+float TI128D818::temp(const uint8_t channel) {
   uint16_t t = read16(channel);
   // This is a 12 bit ADC; bit shift this 16 bit value to get the
   // 12 bits we are interested in.
@@ -78,7 +74,7 @@
 // TODO(z2amiller):  Provide a configuration class that encapsulates
 //                   all of the ADC configuration options.
 //                   (pins, modes, etc).
-bool TI128D818::init(uint8_t adc_mode) {
+bool TI128D818::init(const uint8_t adc_mode) {
   Wire.begin(SDAPIN, SCLPIN);
   write8(0x00, 0x00); // disable all.
   pollUntilReady();
@@ -88,38 +84,33 @@
   return true;
 }

-void TI128D818::write8(uint8_t addr, uint8_t data) {
+void TI128D818::write8(const uint8_t addr, const uint8_t data) {
   Wire.beginTransmission(adc_addr_);
   Wire.write(addr);
   Wire.write(data);
   Wire.endTransmission();
 }

-uint8_t TI128D818::read8(uint8_t addr) {
+uint8_t TI128D818::read8(const uint8_t addr) {
   Wire.beginTransmission(adc_addr_);
   Wire.write(addr);
   Wire.endTransmission();
   Wire.beginTransmission(adc_addr_);
   Wire.requestFrom(adc_addr_, (uint8_t)1);
-  uint8_t ret;
-  ret = Wire.read();
+  const uint8_t ret = Wire.read();
   Wire.endTransmission();
   return ret;
 }

-uint16_t TI128D818::read16(uint8_t addr) {
+uint16_t TI128D818::read16(const uint8_t addr) {
   Wire.beginTransmission(adc_addr_);
   Wire.write(addr);
   Wire.endTransmission();
   Wire.beginTransmission(adc_addr_);
   Wire.requestFrom(adc_addr_, (uint8_t)2);
-  uint16_t ret;
-  ret = Wire.read();
+  uint16_t ret = Wire.read();
   ret <<= 8;
   ret |= Wire.read();
-  Serial.print(" (raw read ");
-  Serial.print(ret);
-  Serial.print(") ");
   Wire.endTransmission();
   return ret;
 }
@@ -145,7 +136,5 @@
   Serial.print("  ch 3 = ");
   Serial.print(adc.temp(0x23));
   Serial.println("");
-  Serial.println("");
   delay(5000);
 }
-


replace ArduinoOTA with HTTPUpdateServer

--- WifiWeatherGuy.ino
+++ WifiWeatherGuy.ino
@@ -5,8 +5,9 @@
 #include <FS.h>
 #include <ESP8266WiFi.h>
 #include <ESP8266mDNS.h>
-#include <ArduinoOTA.h>
 #include <ESP8266WebServer.h>
+#include <ESP8266HTTPUpdateServer.h>
+
 #include "Configuration.h"
 #include "display.h"

@@ -24,6 +25,7 @@

 MDNSResponder mdns;
 ESP8266WebServer server(80);
+ESP8266HTTPUpdateServer httpUpdater;

 Print &out = Serial;
 #define DEBUG
@@ -134,33 +136,7 @@
     mdns.addService("http", "tcp", 80);
   } else
     out.println("Error starting MDNS");
-
-  ArduinoOTA.setHostname(cfg.hostname);
-  ArduinoOTA.onStart([]() {
-#ifdef DEBUG
-    Serial.println("Start");
-#endif
-  });
-  ArduinoOTA.onEnd([]() {
-#ifdef DEBUG
-    Serial.println("\nEnd");
-#endif
-  });
-  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
-#ifdef DEBUG
-    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
-#endif
-  });
-  ArduinoOTA.onError([](ota_error_t error) {
-    Serial.printf("Error[%u]: ", error);
-    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
-    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
-    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
-    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
-    else if (error == OTA_END_ERROR) Serial.println("End Failed");
-  });
-  ArduinoOTA.begin();
-
+
   last_fetch_conditions = -cfg.conditions_interval;
   last_fetch_forecasts = -cfg.forecasts_interval;

@@ -178,6 +154,7 @@
   server.serveStatic("/config", SPIFFS, "/config.json");
   server.serveStatic("/js/transparency.min.js", SPIFFS, "/transparency.min.js");

+  httpUpdater.setup(&server);
   server.begin();
 }

@@ -436,7 +413,6 @@

   static int screen = 0;

-  ArduinoOTA.handle();
   server.handleClient();
   mdns.update();


Break up setup() function

Break up setup() function

--- src/rx5808-pro-diversity/rx5808-pro-diversity.ino
+++ src/rx5808-pro-diversity/rx5808-pro-diversity.ino
@@ -100,95 +100,97 @@
 bool settings_beeps = true;
 bool settings_orderby_channel = true;

-// SETUP ----------------------------------------------------------------------------
+// === Setup ===================================================================
+
 void setup()
 {
-    // IO INIT
-    // initialize digital pin 13 LED as an output.
-    pinMode(PIN_LED, OUTPUT); // status pin for TV mode errors
+    setupIo();
+
+    // Enable buzzer and LED for duration of setup process.
     digitalWrite(PIN_LED, HIGH);
-    // buzzer
-    pinMode(PIN_BUZZER, OUTPUT); // Feedback buzzer (active buzzer, not passive piezo)
     digitalWrite(PIN_BUZZER, HIGH);
-    // minimum control pins
+
+    setReceiver(useReceiverA);
+    setupSettings();
+
+    // Init Display
+    if (drawScreen.begin(call_sign) > 0) {
+        haltWithError();
+    }
+
+    #ifdef USE_IR_EMITTER
+        // Used to Transmit IR Payloads
+        Serial.begin(9600);
+    #endif
+
+    // Setup complete.
+    digitalWrite(PIN_LED, LOW);
+    digitalWrite(PIN_BUZZER, LOW);
+}
+
+void setupIo() {
+    pinMode(PIN_LED, OUTPUT);
+    pinMode(PIN_BUZZER, OUTPUT);
+
     pinMode(PIN_BUTTON_UP, INPUT);
+    pinMode(PIN_BUTTON_MODE, INPUT);
     digitalWrite(PIN_BUTTON_UP, INPUT_PULLUP);
-    pinMode(PIN_BUTTON_MODE, INPUT);
     digitalWrite(PIN_BUTTON_MODE, INPUT_PULLUP);
-    // optional control
+
     pinMode(PIN_BUTTON_DOWN, INPUT);
+    pinMode(PIN_BUTTON_SAVE, INPUT);
     digitalWrite(PIN_BUTTON_DOWN, INPUT_PULLUP);
-    pinMode(PIN_BUTTON_SAVE, INPUT);
     digitalWrite(PIN_BUTTON_SAVE, INPUT_PULLUP);
-    //Receiver Setup
+
     pinMode(PIN_LED_A,OUTPUT);
-#ifdef USE_DIVERSITY
-    pinMode(PIN_LED_B,OUTPUT);
-#endif
-    setReceiver(useReceiverA);
-    // SPI pins for RX control
-    pinMode (PIN_SPI_SLAVE_SELECT, OUTPUT);
-    pinMode (PIN_SPI_DATA, OUTPUT);
-	pinMode (PIN_SPI_CLOCK, OUTPUT);
-
+    #ifdef USE_DIVERSITY
+        pinMode(PIN_LED_B,OUTPUT);
+    #endif
+
+    pinMode(PIN_SPI_SLAVE_SELECT, OUTPUT);
+    pinMode(PIN_SPI_DATA, OUTPUT);
+	pinMode(PIN_SPI_CLOCK, OUTPUT);
+}
+
+void setupSettings() {
     EepromSettings.load();

-    // read last setting from eeprom
+    // Set channel ASAP for fast boot times.
+    channelIndex = EepromSettings.channel;
+    setChannelModule(channelIndex);
+    last_channel_index = channelIndex;
+
     state = EepromSettings.defaultState;
-    channelIndex = EepromSettings.channel;
-
-    // set the channel as soon as we can
-    // faster boot up times :)
-    setChannelModule(channelIndex);
-    last_channel_index=channelIndex;
-
     settings_beeps = EepromSettings.beepEnabled;
     settings_orderby_channel = EepromSettings.orderByChannel;
-
-    // load saved call sign
     memcpy(call_sign, EepromSettings.callSign, sizeof(call_sign));

     rssi_min_a = EepromSettings.rssiAMin;
     rssi_max_a = EepromSettings.rssiAMax;
-#ifdef USE_DIVERSITY
-    diversity_mode = EepromSettings.diversityMode;
-    rssi_min_b = EepromSettings.rssiBMin;
-    rssi_max_b = EepromSettings.rssiBMax;
-#endif
-    force_menu_redraw=1;
-
-    // Init Display
-    if (drawScreen.begin(call_sign) > 0) {
-        // on Error flicker LED
-        while (true) { // stay in ERROR for ever
-            digitalWrite(PIN_LED, !digitalRead(PIN_LED));
-            delay(100);
-        }
-    }
-
-#ifdef USE_IR_EMITTER
-    // Used to Transmit IR Payloads
-    Serial.begin(9600);
-#endif
-
-#ifdef USE_DIVERSITY
-    // make sure we use receiver Auto when diveristy is unplugged.
-    if(!isDiversity()) {
-        diversity_mode = useReceiverAuto;
-    }
-#endif
-#ifdef USE_VOLTAGE_MONITORING
+    #ifdef USE_DIVERSITY
+        diversity_mode = EepromSettings.diversityMode;
+        rssi_min_b = EepromSettings.rssiBMin;
+        rssi_max_b = EepromSettings.rssiBMax;
+    #endif
+
+    #ifdef USE_DIVERSITY
+        // make sure we use receiver Auto when diveristy is unplugged.
+        if(!isDiversity()) {
+            diversity_mode = useReceiverAuto;
+        }
+    #endif
+
+    #ifdef USE_VOLTAGE_MONITORING
         vbat_scale = EepromSettings.vbatScale;
         warning_voltage = EepromSettings.vbatWarning;
         critical_voltage = EepromSettings.vbatCritical;
-#endif
-    // Setup Done - Turn Status LED off.
-    digitalWrite(PIN_LED, LOW);
-
-}
-
-
-// LOOP ----------------------------------------------------------------------------
+    #endif
+
+    force_menu_redraw = 1;
+}
+
+// === Main Loop ===============================================================
+
 void loop()
 {
     /*******************/
@@ -1351,3 +1353,11 @@
     digitalWrite(PIN_BUZZER, !value);
 }
 #endif
+
+void haltWithError() {
+    while (true) {
+        digitalWrite(PIN_LED, !digitalRead(PIN_LED));
+        digitalWrite(PIN_BUZZER, !digitalRead(PIN_BUZZER));
+        delay(100);
+    }
+}


Latest changes and a boatload of one off functions.

--- SacredDoorway/SacredDoorway.ino
+++ SacredDoorway/SacredDoorway.ino
@@ -1,4 +1,5 @@
 #include <Adafruit_NeoPixel.h>
+#include <Timer.h>

 /*
  * The 'strip' is composed of 419 (it should have been 420, but it's the last led so who cares)
@@ -37,15 +38,247 @@
 // Parameter 2 = Arduino pin number (most are valid)
 // Parameter 3 = pixel type flags, add together as needed:
 Adafruit_NeoPixel strip = Adafruit_NeoPixel(419, PIN, NEO_GRB + NEO_KHZ800);
+uint8_t brightness = 1;
+
+int sheets[] = {
+    0,
+    30,
+    60,
+    90,
+    120,
+    150,
+    180,
+    210
+};

 void setup() {
   strip.begin();
-  strip.setBrightness(255); // Not really necessary, seems that the default of the library is max brightness
+  strip.setBrightness(brightness); // Not really necessary, seems that the default of the library is max brightness
   strip.show(); // Initialize all pixels to 'off'
 }

 void loop() {
-  rainbow2(1);
+  fadeIn();
+
+  //nSheetSetColor(5, 255, 0, 0);
+
+  fadeSheetTo(3, 0, 0, 0, 0, 0, 255);
+  fadeSheetTo(6, 0, 0, 0, 0, 0, 255);
+  fadeSheetTo(6, 0, 0, 255, 0, 127, 255);
+  fadeSheetTo(6, 0, 127, 255, 0, 255, 255);
+  fadeSheetTo(5, 0, 0, 0, 255, 0, 0);
+  AllColorSpiral(strip.Color(255, 0, 50));
+  fadeSheetTo(5, 255, 0, 50, 255, 171, 0);
+  fadeSheetTo(2, 255, 0, 50, 0, 0, 255);
+  fadeSheetTo(1, 255, 0, 50, 50, 255, 0);
+  //rainbow(1);
+
+  //AllBlackSpiral();
+
+  AllWhite();
+
+  AllBlackSpiral(20);
+
+  //fadeOut();
+
+  for (int i = 0; i < 5; i++) {
+    AllSheetRainbowPulse(10);
+  }
+  AllBlackSpiral(1);
+  //AllWhite();
+  //fadeOut();
+
+
+
+}
+
+void nSheetSetColor(int n, uint16_t r, uint16_t g, uint16_t b) {
+  for (int i = sheets[n - 1]; i < sheets[n]; i++) {
+    strip.setPixelColor(i, r, g, b);
+    strip.setPixelColor(419 - i, r, g, b);
+  }
+}
+
+void AllSheetRainbowPulse (uint8_t wait) {
+  uint8_t i, j;
+
+  for(j = 0 ; j < 255; j++) {
+    for(i = 0; i < 30; i++) {
+      strip.setPixelColor(i, Wheel(j));
+      strip.setPixelColor(419 - i, Wheel(j));
+    }
+
+    for(i = 30; i < 60; i++) {
+      strip.setPixelColor(i, Wheel((j+10)));
+      strip.setPixelColor(419 - i, Wheel((j+10)));
+    }
+
+    for(i = 60; i < 90; i++) {
+      strip.setPixelColor(i, Wheel((j+20)));
+      strip.setPixelColor(419 - i, Wheel((j+20)));
+    }
+
+    for(i = 90; i < 120; i++) {
+      strip.setPixelColor(i, Wheel((j+30)));
+      strip.setPixelColor(419 - i, Wheel((j+30)));
+    }
+
+    for(i = 120; i < 150; i++) {
+      strip.setPixelColor(i, Wheel((j+40)));
+      strip.setPixelColor(419 - i, Wheel((j+40)));
+    }
+
+    for(i = 150; i < 180; i++) {
+      strip.setPixelColor(i, Wheel((j+50)));
+      strip.setPixelColor(419 - i, Wheel((j+50)));
+    }
+
+    for(i = 180; i < 210; i++) {
+      strip.setPixelColor(i, Wheel((j+60)));
+      strip.setPixelColor(419 - i, Wheel((j+60)));
+    }
+
+    fadeIn();
+    strip.show();
+
+    delay(wait);
+  }
+}
+
+void AllWhite() {
+  uint16_t pixel;
+  for (pixel = 0; pixel < 210; pixel++) {
+    strip.setPixelColor(pixel, 255, 255, 255);
+    strip.setPixelColor(419 - pixel, 255, 255, 255);
+
+    strip.show();
+    delay(1);
+  }
+}
+
+void AllBlack() {
+  uint16_t pixel, brightness;
+  for (pixel = 0; pixel < 210; pixel++) {
+    strip.setPixelColor(pixel, 0, 0, 0);
+    strip.setPixelColor(419 - pixel, 0, 0, 0);
+
+    strip.show();
+  }
+}
+
+void AllColorSpiral (uint32_t color) {
+  uint16_t i;
+  for (i = 0; i < 30; i++) {
+    strip.setPixelColor(i, color);
+    strip.setPixelColor(391 + i, color);
+
+    strip.setPixelColor(210 - i, color);
+    strip.setPixelColor(211 + i, color);
+
+    strip.setPixelColor(59 - i, color);
+    strip.setPixelColor(361 + i, color);
+
+    strip.setPixelColor(89 - i, color);
+    strip.setPixelColor(331 + i, color);
+
+    strip.setPixelColor(119 - i, color);
+    strip.setPixelColor(301 + i, color);
+
+    strip.setPixelColor(149 - i, color);
+    strip.setPixelColor(271 + i, color);
+
+    strip.setPixelColor(179 - i, color);
+    strip.setPixelColor(241 + i, color);
+
+    strip.show();
+    delay(10);
+  }
+}
+
+void SheetColorSpiral (uint32_t color) {
+  /*
+  for (uint8_t i = sheets[n - 1]; i < sheets[n]; i++) {
+    strip.setPixelColor(i, color);
+    strip.setPixelColor(419 - i, color);
+  }
+  */
+
+  for (int i = 0; i < 30; i++) {
+    strip.setPixelColor(i, color);
+    strip.setPixelColor(391 + i, color);
+
+    strip.setPixelColor(210 - i, color);
+    strip.setPixelColor(211 + i, color);
+
+    strip.setPixelColor(59 - i, color);
+    strip.setPixelColor(361 + i, color);
+
+    strip.setPixelColor(89 - i, color);
+    strip.setPixelColor(331 + i, color);
+
+    strip.setPixelColor(119 - i, color);
+    strip.setPixelColor(301 + i, color);
+
+    strip.setPixelColor(149 - i, color);
+    strip.setPixelColor(271 + i, color);
+
+    strip.setPixelColor(179 - i, color);
+    strip.setPixelColor(241 + i, color);
+
+    strip.show();
+    delay(10);
+  }
+}
+
+void AllBlackSpiral (uint8_t wait) {
+  uint16_t i;
+  for (i = 0; i < 30; i++) {
+    strip.setPixelColor(i, 0);
+    strip.setPixelColor(391 + i, 0);
+
+    strip.setPixelColor(210 - i, 0);
+    strip.setPixelColor(211 + i, 0);
+
+    strip.setPixelColor(59 - i, 0);
+    strip.setPixelColor(361 + i, 0);
+
+    strip.setPixelColor(89 - i, 0);
+    strip.setPixelColor(331 + i, 0);
+
+    strip.setPixelColor(119 - i, 0);
+    strip.setPixelColor(301 + i, 0);
+
+    strip.setPixelColor(149 - i, 0);
+    strip.setPixelColor(271 + i, 0);
+
+    strip.setPixelColor(179 - i, 0);
+    strip.setPixelColor(241 + i, 0);
+
+    strip.show();
+    delay(wait);
+  }
+}
+
+void fadeIn () {
+  if (brightness == 1) {
+    for (int i = 1; i < 256; i++) {
+      strip.setBrightness(i);
+      strip.show();
+    }
+  }
+
+  brightness = 255;
+}
+
+void fadeOut () {
+  if (brightness == 255) {
+    for (int i = 255; i > 0; i--) {
+      strip.setBrightness(i);
+      strip.show();
+    }
+  }
+
+  brightness = 1;
 }

 /**
@@ -58,47 +291,12 @@
     for(i=0; i<strip.numPixels(); i++) {
       strip.setPixelColor(i, Wheel((i+j) & 255));
     }
-    strip.show();
+
+    //fadeIn();
+
+    //strip.show();
     delay(wait);
   }
-}
-
-void rainbow1(uint8_t wait) {
-  uint16_t i, j;
-
-  for(j=0; j<256; j++) {
-    for(i=0; i < 29; i++) {
-      strip.setPixelColor(i, Wheel((i+j) & 255));
-      strip.setPixelColor(419 - i, Wheel((i+j) & 255));
-    }
-    strip.show();
-    delay(wait);
-  }
-}
-
-void rainbow2(uint8_t wait) {
-  uint16_t i, j;
-
-  for(j=0; j<256; j++) {
-    for(i=150; i < 179; i++) {
-      strip.setPixelColor(i, Wheel((i+j) & 255));
-      strip.setPixelColor(419 - i, Wheel((i+j) & 255));
-    }
-    strip.show();
-    //delay(wait);
-  }
-
-  brighttron();
-}
-
-void brighttron(){
-  for (int i = 60; i <= 89; i++)
-  {
-    strip.setPixelColor(i, 255, 255, 255);
-    strip.setPixelColor(419 - i, 255, 255, 255);
-  }
-
-  strip.show();
 }

 /**
@@ -149,3 +347,21 @@
   }
 }

+void fadeSheetTo (int sheet, int sr, int sg, int sb,
+             int er, int eg, int eb) {
+  int r_diff = er - sr;
+  int g_diff = eg - sg;
+  int b_diff = eb - sb;
+  int steps = 256;
+
+  for (int i = 0; i < steps; i++) {
+    nSheetSetColor(
+      sheet,
+      sr + i * r_diff / steps,
+      sg + i * g_diff / steps,
+      sb + i * b_diff / steps
+    );
+
+    strip.show();
+  }
+}


ANother GATT test

ANother GATT test

--- Peripheral/Test_Sensor1/Test_Sensor1.ino
+++ Peripheral/Test_Sensor1/Test_Sensor1.ino
@@ -14,13 +14,13 @@

 //###BLE Characteristics###
 BLEPeripheral blePeripheral;       // BLE Peripheral Device (the board you're programming)
-BLEService batteryService("180F"); // BLE "Battery service"
+BLEService cyclingPowerService("1818"); // BLE "Battery service"

 // BLE Battery Level Characteristic
-BLEUnsignedCharCharacteristic batteryLevel("2A19",  // standard 16-bit characteristic UUID
-    BLERead | BLENotify);     // remote clients will be able to get notifications if this characteristic changes
+BLEUnsignedCharCharacteristic sensorLocation("2A5D",  // standard 16-bit characteristic UUID
+    BLERead);     // remote clients will be able to get notifications if this characteristic changes

-int value = 50;
+int value = 1;

 void setup()
 {
@@ -31,11 +31,11 @@
      This name will appear in advertising packets
      and can be used by remote devices to identify this BLE device
      The name can be changed but maybe be truncated based on space left in advertisement packet */
-  blePeripheral.setLocalName("TestSensor1");
-  blePeripheral.setAdvertisedServiceUuid(batteryService.uuid());  // add the service UUID
-  blePeripheral.addAttribute(batteryService);   // Add the BLE Battery service
-  blePeripheral.addAttribute(batteryLevel); // add the battery level characteristic
-  batteryLevel.setValue(value);   // initial value for this characteristic
+  blePeripheral.setLocalName("TestSensor2");
+  blePeripheral.setAdvertisedServiceUuid(cyclingPowerService.uuid());  // add the service UUID
+  blePeripheral.addAttribute(cyclingPowerService);   // Add the BLE Battery service
+  blePeripheral.addAttribute(sensorLocation); // add the battery level characteristic
+  sensorLocation.setValue(value);   // initial value for this characteristic
   Serial.println("Configured BLE");
   /* Now activate the BLE device.  It will start continuously transmitting BLE
      advertising packets and will be visible to remote BLE central devices
@@ -59,11 +59,7 @@
     // turn on the LED to indicate the connection:
     digitalWrite(13, HIGH);
     while (central.connected()) {
-      if (value == 100) {
-        value = 0;
-      } else {
-        value = value + 1;
-      }
+      Serial.println("Value: " + value);
       delay(500);
     }
     Serial.print("Disconnected from central: ");


Id from mac address

Id from mac address

--- src/nest.ino
+++ src/nest.ino
@@ -27,6 +27,8 @@

 EthernetUDP udp;

+uint8_t mac[6] = {0x02, 0x05, 0x02, 0x04, 0x09, 0x05};
+
 void setup() {
   Serial.begin(9600);
   if (manager.init()) {
@@ -36,7 +38,6 @@
       Serial.println(F("RF init failed"));
   }

-  uint8_t mac[6] = {0x02, 0x05, 0x02, 0x04, 0x09, 0x05};
   Ethernet.begin(mac);
 }

@@ -55,20 +56,14 @@

 void sendMessage(uint8_t from,uint8_t *message) {
   int success = udp.beginPacket("api.skydome.io", 5506);
-  Serial.print(F("beginPacket: "));
-  Serial.println(message[0]);
-  Serial.println(message[1]);
-  Serial.println(message[2]);
-  Serial.println(message[3]);
-  Serial.println(message[4]);
   Serial.println(success ? F("success") : F("failed"));

-  success = udp.write(0x01);
-  success = udp.write(0x02);
-  success = udp.write(0x06);
-  success = udp.write(0x02);
-  success = udp.write(0x04);
-  success = udp.write(0x05);
+  success = udp.write(mac[0]);
+  success = udp.write(mac[1]);
+  success = udp.write(mac[2]);
+  success = udp.write(mac[3]);
+  success = udp.write(mac[4]);
+  success = udp.write(mac[5]);
   success = udp.write(message[0]);
   success = udp.write(message[1]);
   success = udp.write(message[2]);


serial only for debug mode

serial only for debug mode

--- gamecubecontroller.ino
+++ gamecubecontroller.ino
@@ -75,7 +75,12 @@
 volatile HIDBuffer_t fb { featureBuffer, HID_BUFFER_SIZE(FEATURE_DATA_SIZE,1), HID_JOYSTICK_REPORT_ID };

 void setup() {
-  USBHID.begin(reportDescription,sizeof(reportDescription),0x1EAF,0x0024);
+#ifdef SERIAL_DEBUG
+  USBHID.setSerial(1);
+#else
+  USBHID.setSerial(0);
+#endif
+  USBHID.begin(reportDescription,sizeof(reportDescription));
   USBHID.setBuffers(HID_REPORT_TYPE_FEATURE, &fb, 1);
   for (int i=0; i<numIndicators; i++)
     pinMode(indicatorLEDs[i], OUTPUT);
@@ -83,7 +88,6 @@
   pinMode(upButton, INPUT_PULLDOWN);

 #ifdef SERIAL_DEBUG
-  Serial.begin(115200);
   displayNumber(3);
   delay(4000);
   Serial.println("gamecube controller adapter");


use serial port for debugging

use serial port for debugging

--- status.ino
+++ status.ino
@@ -3,7 +3,6 @@
 #define OFF 0
 #define GREEN 1
 #define RED 2
-

 SparkButton strip = SparkButton();

@@ -18,6 +17,7 @@
         desired[i] = OFF;
     }
     Spark.function("update", handleUpdate);
+    Serial.begin(9600);
 }

 void loop() {


Use LED iso PIN to avoid confusion

Use LED iso PIN to avoid confusion

--- btnLed/src/sketch.ino
+++ btnLed/src/sketch.ino
@@ -9,14 +9,14 @@
 */

 #define pushbuttonPIN 2
-#define onoffPIN 3
+#define onoffLED 3

 volatile int flag = LOW;
 unsigned long timestamp = 0;

 void setup()
 {
-  pinMode(onoffPIN, OUTPUT);       // An LED to signal on or off state
+  pinMode(onoffLED, OUTPUT);       // An LED to signal on or off state
   attachInterrupt(0, interrupt, HIGH); // Interrupt when button is pressed
 }

@@ -33,5 +33,5 @@

 void loop()
 {
-  digitalWrite(onoffPIN, flag);
+  digitalWrite(onoffLED, flag);
 }


Added some time capabilities

Added some time capabilities

--- Arduino/sketchbook/XbeeCppTest/XbeeCppTest.ino
+++ Arduino/sketchbook/XbeeCppTest/XbeeCppTest.ino
@@ -28,16 +28,19 @@
 const int led_on = HIGH;
 const int led_off = LOW;

-time_t start_time;
+volatile time_t start_time;
 time_t current_time;
 void setup()
 {
+  start_time = now();
   pinMode(led_pin, OUTPUT);
 	digitalWrite(led_pin, led_off);
 	digitalWrite(reset_pin, HIGH);
 	pinMode(reset_pin, OUTPUT);
   Serial.begin(BAUD_RATE);
   Serial.println("Starting the Receiver!");
+  Serial.print("Starting time: ");
+  Serial.println(start_time);

   tx_packet.set_Address(0x00000000C0A80165);
   //tx_packet.set_Address(0x00000000FFFFFFFF);
@@ -94,6 +97,7 @@
     delay(2000);
   uint16_t length = tx_packet.prepare2send();
   uint16_t i;
+
   for(i = 0; i < length; i++)
   {
     //Uart.print(tx_buffer1[i], BYTE);
@@ -140,6 +144,9 @@
  if (Uart.available()) {
 		c = Uart.read();
 //		Serial.write(c);
+                 current_time = now();
+                Serial.print("current time: ");
+                Serial.println(current_time);
                 if(c == 0x7E) Serial.println();
                 Serial.print(c, HEX);
                 Serial.print(" ");


ota compatible verison number

ota compatible verison number

--- homie-dht.ino
+++ homie-dht.ino
@@ -50,7 +50,7 @@
   Serial.begin(115200);
   Serial << endl << endl;

-  Homie_setFirmware("HomieDht", "0.2");
+  Homie_setFirmware("HomieDht", "0.0.2");
   Homie_setBrand("HomieDht"); // before Homie.setup()
   Homie.setSetupFunction(setupHandler).setLoopFunction(loopHandler).onEvent(onHomieEvent);
   Homie.disableLedFeedback();


fixed sonar list, and set starting positions for servos to stop or center

--- CS26410.ino
+++ CS26410.ino
@@ -33,15 +33,19 @@
 Servo Turret;
 SharpIR IRRangeFinder(SharpIr, 25, 93, 20150);
 NewPing sonar1(Ping1, Ping1, 200);
-NewPing sonar1(Ping2, Ping2, 200);
-NewPing sonar1(Ping3, Ping3, 200);
-NewPing sonar1(Ping4, Ping4, 200);
+NewPing sonar2(Ping2, Ping2, 200);
+NewPing sonar3(Ping3, Ping3, 200);
+NewPing sonar4(Ping4, Ping4, 200);

 void setup() {

   Driveleft.attach(Dleft);
+  Driveleft.write(DleftStop);
   Driveright.attach(Dright);
+  Driveright.write(DrightStop);
   Turret.attach(turret);
+  Turret.write(TurretCenter);
+

   pinMode(LDRLeft, INPUT);
   pinMode(LDRCenter, INPUT);


Add ifdef for calibration (could be a serial message as well...)


Changed button example to pin 11 - uno compatible

--- examples/button/button.ino
+++ examples/button/button.ino
@@ -27,10 +27,10 @@
 {
   //Serial.begin(9600);delay(1000);Serial.println( "start" );
   // Initialize the machines
-  led1.begin( 3 ).blink( 200 ).fade( 5 ).state( led1.START );
-  led2.begin( 4 ).blink( 100 ).pause( 1000 ).fade( 5 ).state( led2.START );
-  led3.begin( 5 ).blink( 100 ).pause( 200 ).fade( 5 ).repeat( 10 ).state( led3.START );
-  btn.begin( 14, btn_change );
+  led1.begin( 3 ).blink( 20 ).fade( 5 ).state( led1.START );
+  led2.begin( 4 ).blink( 10 ).pause( 1000 ).fade( 5 ).state( led2.START );
+  led3.begin( 5 ).blink( 10 ).pause( 200 ).fade( 5 ).state( led3.START );
+  btn.begin( 11, btn_change );

   // Add the initialized machines to the factory
   factory.add( led1 );


Formating gps input, try to reject all information except GPRMC

--- Drones/Drones.ino
+++ Drones/Drones.ino
@@ -1,3 +1,29 @@
+//----------------------------License-----------------------------------------------//
+/*
+MIT License
+
+Copyright (c) 2016 Weili An
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+//-----------------------------Code----------------------------------------------//
 //Core library
 #include <MPU6050_6Axis_MotionApps20.h>
 #include <I2Cdev.h>
@@ -9,7 +35,7 @@
 #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
     #include "Wire.h"
 #endif
-//Specify the I2C address of MPU6050, default I2C adress is 0x68
+//Specify the I2C address of MPU6050, default I2C adress is 0x60
 MPU6050 mpu;
 //uncomment the following define in order to get the data you want
 //#define OUTPUT_READABLE_QUATERNION
@@ -17,6 +43,7 @@
 #define OUTPUT_READABLE_YAWPITCHROLL
 //Uncomment "OUTPUT_READABLE_REALACCEL" if you want to see acceleration components with gravity removed.
 #define OUTPUT_READABLE_REALACCEL
+//Define pins
 #define INTERRUPT_PIN 2
 #define LED_PIN 12
 #define MOTOR_1_PIN 3
@@ -25,6 +52,7 @@
 #define MOTOR_4_PIN 9
 #define SOFT_SERIAL_TX 11
 #define SOFT_SERIAL_RX 12
+//Define varibles
 int throttle_stick = 0;
 int yaw_stick = 0;
 int pitch_stick = 0;
@@ -63,7 +91,9 @@

-void parse_gps(char buffer[70]);
+void parse_gps(char buffer[60]);
+
+//----------------------------Setup Code-----------------------------------------------//
 void setup() {
 	pinMode(MOTOR_1_PIN, OUTPUT);
 	pinMode(MOTOR_2_PIN, OUTPUT);
@@ -78,24 +108,31 @@
 	// Begin both serials
 }

+//----------------------------Main Loop-----------------------------------------------//
 void loop() {
   // put your main code here, to run repeatedly:
-  char gpsbuffer[70];
+  char gpsbuffer[60];
 // Initialize buffer for gps data
  	if (gpsSerial.available() > 0){
-    if(gpsSerial.read()=='$'){
-  	gpsSerial.readBytesUntil("*",gpsbuffer,70);
+    while (!(gpsSerial.findUntil("$GPRMC,",'*'))){
+      gpsSerial.flush();
     }
-    }
-  for(int i;i<70;i++){
+    gpsSerial.readBytesUntil("*",gpsbuffer,60);// Problem, if it is N, the function will try to find enough bytes to fill the memory it is given
+
+    }//Cannot read Bytes, just skip this if-clause, need to be solved
+    //used findUntil method to skip other info
+  for(int i;i<60;i++){
   	Serial.print(gpsbuffer[i]);
-   //gpsbuffer[i]=" ";
+
+    //gpsbuffer[i]=" ";
   }
   Serial.println();
 //	For Testing only

   delay(1000);
+  gpsSerial.flush();
+  free(gpsbuffer);
 }
-void parse_gps(char buffer[70]){
+void parse_gps(char buffer[60]){

 }


Whitespace

Whitespace

--- examples/button/spark.ino
+++ examples/button/spark.ino
@@ -2,11 +2,11 @@
 int buttonState = 0;         // variable for reading the pushbutton status

 void setup() {
-    Spark.function("laststate", laststate);
+	Spark.function("laststate", laststate);
 }

 void loop() {
- 	pinMode(buttonPin, INPUT_PULLDOWN);
+	pinMode(buttonPin, INPUT_PULLDOWN);
 	buttonState = digitalRead(buttonPin);
 	delay(250);
 }


Typo fix

Typo fix


debug via serial interface

debug via serial interface

--- Flasher.ino
+++ Flasher.ino
@@ -24,19 +24,34 @@
 	By author's name

   $Id$
+
+  Port manipulation: for the Arduino Nano we have:
+  - PB0 .. PB5 = D8 .. D13
+  - PC0 .. PC5 = A0 .. A5
+  - PD0 .. PD7 = D0 .. D7
+  See also:
+	https://www.arduino.cc/en/Reference/PortManipulation

-	https://www.arduino.cc/en/Reference/PortManipulation
   https://www.arduino.cc/en/Hacking/Atmega168Hardware

 */

+// http://arduiniana.org/libraries/streaming/
+#include <Streaming.h>

 #include "EEprom.h"
+
+// UART baud rate
+#define UART_BAUD_RATE  9600

 EEprom eeprom;

 /**  */
 void setup() {
+
+  /* Initialize serial output at UART_BAUD_RATE bps */
+  Serial.begin(UART_BAUD_RATE);
+  Serial << F("Starting ...") << endl;
 }

 uint8_t addr = 0x01;
@@ -44,6 +59,11 @@
 /**  */
 void loop() {

+  Serial.print("0x");
+  if ( addr < 0x0f )
+    Serial.print("0");
+  Serial.println(addr, HEX);
+
   eeprom.setAddressLSB(addr);

   delay(2000);
@@ -59,6 +79,7 @@
 #endif

   addr <<= 1;
+  //addr += 1;

   if ( !addr ) addr = 0x01;
 }


v5.0 Add theme

v5.0 Add theme

--- PictureViewer.ino
+++ PictureViewer.ino
@@ -13,10 +13,11 @@
 int pastMode = HIGH;
 int pastTest = HIGH;
 bool SD_OK = false;
+String themeField;

 // The setup (runs once at start up)
 void setup(void) {
-  File root, entry;
+  File root, entry, themeName;

   pinMode(TEST_PIN, INPUT);
   pinMode(MODE_PIN, INPUT);
@@ -54,6 +55,15 @@
     entry.close();
   }
   root.close();
+
+  // Get and store the pictures theme
+  if ((themeName = SD.open("theme.txt", FILE_READ)) != NULL) {
+    while (themeName.available()) {
+      uint8_t tempByte = read8(themeName); // Reads one byte
+      themeField += (char)tempByte; // Store byte for displayFileName
+    }
+    themeName.close();
+  } // if ((themeName = SD.open("theme.txt", FILE_READ)) != NULL)

   // Print # of files and mode
   Serial.print("Number of files = ");
@@ -263,9 +273,15 @@
   return (true);
 }  // bmpDraw

-// These read 16- and 32-bit types from the SD card file.
+// These read 16-,32-bit and 8- types from the SD card file.
 // BMP data is stored little-endian, Arduino is little-endian too.
 // May need to reverse subscript order if porting elsewhere.
+
+uint8_t read8(File f) {
+  uint8_t result;
+  ((uint8_t *)&result)[0] = f.read();
+  return result;
+}

 uint16_t read16(File f) {
   uint16_t result;
@@ -326,7 +342,7 @@
   delay(10000);
 }

-// Displays the file name
+// Displays the file name among other things
 void displayFileName(char *fileName, bool fileFound, int bmpWidth, int bmpHeight) {
   static long lastRandomNumber;
   long randomColor;
@@ -374,6 +390,8 @@
     tft.setCursor(50, 0);
     tft.println("Test");
   }
+  tft.setCursor(0, 15);
+  tft.println(themeField);
   tft.setCursor(0, 50);
   tft.setTextSize(2);
   tft.println("File Name:");


New switch pin numbers (engine room)

New switch pin numbers (engine room)


two servos 😃

two servos 😃

--- singleServo/sketch_jun11a/sketch_jun11a.ino
+++ singleServo/sketch_jun11a/sketch_jun11a.ino
@@ -1,21 +0,0 @@
-// Connect and move a single servo
-// Chloe Chen
-// 11 June 2016
-
-#include <Servo.h>
-
-Servo servo0;
-
-void setup() {
-  servo0.attach(2);
-  servo0.write(180);
-
-}
-
-void loop() {
-  delay(1000);
-  servo0.write(90);
-  delay(1000);
-  servo0.write(180);
-  delay(1000);
-}


implementado segurança do datador e solda vertical, resolves #10

--- EMP-B-Due.ino
+++ EMP-B-Due.ino
@@ -72,7 +72,7 @@
 const unsigned long fim_refrigeracao = 1450; // Tempo de saída da função Refrigeração
 // DATADOR
 const unsigned long inicio_datador = 0; // Tempo de entrada da função Datador
-const unsigned long fim_datador = 400; // Tempo de saída da função Datador
+const unsigned long fim_datador = 700; // Tempo de saída da função Datador
 // SOLDAS VERTICAL E HORIZONTAL
 const unsigned long inicio_soldas = 0; // Tempo de entrada da função Soldas Horizontal e Vertical
 const unsigned long fim_soldas = 400; // Tempo de saída da função Soldas Horizontal e Vertical
@@ -226,7 +226,7 @@
     leFotocelula();
     funcaoSimples(mandibula, NomeMandibula, ti_mandibula, tf_mandibula);
     funcaoSegura(faca, NomeFaca, ti_faca, tf_faca, sensor_mandibula);
-    funcaoSimples(refrigeracao, NomeRefrigeracao, ti_refrigeracao, tf_refrigeracao);
+    funcaoBloqueante(refrigeracao, NomeRefrigeracao, ti_refrigeracao, tf_refrigeracao);
     funcaoComLiberacao(datador, NomeDatador, ti_datador, tf_datador, datador_ligado);
     funcaoSimples(soldas, NomeSoldas, ti_soldas, tf_soldas);
   }
@@ -371,14 +371,32 @@
   }
 }

+// void funcaoSegura(const byte saida, String nome, unsigned long inicio, unsigned long fim, byte seguranca, boolean alarmar){
+//   if (ativo(seguranca)){
+//     funcaoSimples(saida, nome, inicio, fim);
+//   } else {
+//     if (alarmar){
+//       bloqueioPorAlarme("Sensor da Mandíbula");
+//     } else {
+//       if (ligado(mandibula) && ativo(sensor_mandibula)){
+//         desligaFuncao(saida, nome);
+//       }
+//     }
+//   }
+// }
+
+void funcaoBloqueante(const byte saida, String nome, unsigned long inicio, unsigned long fim){
+  if (ligado(mandibula) && ativo(sensor_mandibula)){
+    desligaFuncao(saida, nome);
+  } else {
+    funcaoSimples(saida, nome, inicio, fim);
+  }
+}
+
 void funcaoComLiberacao(const byte saida, String nome, unsigned long inicio, unsigned long fim, byte liberacao){
-  inicio += inicio_ciclo;
-  fim += inicio_ciclo;
-  if (desligado(saida) && liberacao){
-    if (tempo_atual >= inicio && tempo_atual < fim) {
-      ligaFuncao(saida, nome);
-    }
-  } else if (tempo_atual >= fim) {
+  if (liberacao){
+    funcaoBloqueante(saida, nome, inicio, fim);
+  } else {
     desligaFuncao(saida, nome);
   }
 }
@@ -399,6 +417,7 @@
   if (fotocelula_liberada && !fotocelula_cortou){
     if (ativo(fotocelula)){
       fotocelula_cortou = VERDADEIRO;
+      escreveSerial("Fotocelula fez o corte.");
       reiniciaSaidas();
     }
   }


add missing include

add missing include

--- arduino/examples/ESP32IOBoard/ESP32IOBoard.ino
+++ arduino/examples/ESP32IOBoard/ESP32IOBoard.ino
@@ -41,7 +41,8 @@
 #include <OpenMRN.h>
 #include <openlcb/TcpDefs.hxx>

-#include "openlcb/MultiConfiguredConsumer.hxx"
+#include <openlcb/MultiConfiguredConsumer.hxx>
+#include <utils/GpioInitializer.hxx>

 // Pick an operating mode below, if you select USE_WIFI it will expose
 // this node on WIFI if you select USE_CAN, this node will be available


get precipitation int

get precipitation int

--- weather-clock.ino
+++ weather-clock.ino
@@ -104,9 +104,10 @@

     int temp = response.substring(startTemp, endTemp).toInt();

-    int startPrecip = endTemp;
-    int endPrecip = ;
+    int startPrecip = endTemp + 2;
+    int endPrecip = startPrecip + 3;

+    int precip = response.substring(startPrecip, endPrecip).toInt();

     // assignLedColor(temperature, percentPrecip)
   }


update DETAIL_TIMING

update DETAIL_TIMING

--- TICC/TICC.ino
+++ TICC/TICC.ino
@@ -30,8 +30,7 @@

 #ifdef DETAIL_TIMING
   int32_t start_micros;
-  int32_t calc_micros;
-  int32_t total_micros;
+  int32_t end_micros;
 #endif

 volatile int64_t PICcount;
@@ -245,10 +244,6 @@
          channels[i].totalize++;                  // increment number of events
          channels[i].ready_next();                // Re-arm for next measurement, clear TDC INTB

-       #ifdef DETAIL_TIMING
-         //calc_micros = micros() - start_micros;
-       #endif
-
       // if poll character is not null, only output if we've received that character via serial
       // NOTE: this may provide random results if measuring timestamp from both channels!
       if ( (channels[i].totalize > 2) &&             // throw away first readings
@@ -317,9 +312,9 @@
        if (i == 0) {CLR_LED_A;CLR_EXT_LED_A;};
        if (i == 1) {CLR_LED_B;CLR_EXT_LED_B;};

-      #ifdef DETAIL_TIMING
-        total_micros = micros() - start_micros;
-        Serial.println(total_micros);
+      #ifdef DETAIL_TIMING
+        end_micros = micros() - start_micros;
+        Serial.println(end_micros);
       #endif

       } // if INTB


Very simple Logo capable robot

Very simple Logo capable robot

This proof of concept was enjoyed for over 2 hours by  30 kids aging from 7 to 14 using 2 MRK-1's tethered to laptops via USB cable so that the simple commands could be sent to the robot in real time.

--- LogoBot/LogoBot.ino
+++ LogoBot/LogoBot.ino
@@ -1,5 +1,6 @@
 /********************************************************************
   Code to allow the MRK-1 sumo robot to be operated using simple Logo commands
+

   This code was built off of the Lesson 8, Competitive Sumo Robot
   http://github.com/SumoRobotLeague/MRK-1/
@@ -18,6 +19,7 @@
 /************************/
 // LED pin
 #define led 7
+#define LED 7

 // IR Sensor pins
 #define leftSensor  A1
@@ -42,15 +44,21 @@
 /** Global Variables and Configuration Settings **/
 /*************************************************/
 // Competition configuration settings
-int moveSpeed = 200;  //speed can vary from 0, stopped, to 255, full speed
-int moveTime = 200;  //duration in ms of movement in command such as forward
+int moveSpeed = 255;  //speed can vary from 0, stopped, to 255, full speed
+int moveTime = 1000;  //duration in ms of movement in command such as forward

 // Create our motor object
 Motor motor;

+// Strings and boolean for receiving Logo commands via serial communication
+String inputString = "";         // a string to hold incoming data
+boolean stringComplete = false;  // whether the string is complete
+

 void setup() {
 	Serial.begin(9600);
+  inputString.reserve(600);
+  inputString = "";

 	// pin setup
 	pinMode(button, INPUT_PULLUP);
@@ -70,15 +78,90 @@

 	// Motor setup
 	motor.setupRight(rightMotorSpeed, rightMotorDirection);
+  Serial.println("Setup Right Motor");
 	motor.setupLeft(leftMotorSpeed, leftMotorDirection);
-
+  Serial.println("Setup Left Motor");
 	Serial.println("Robot powered up. Awaiting Logo commands via serial communication");
 }

 void loop() {
-
-}
-
+   serialEvent(); //call the function
+  // print the string when a newline arrives:
+  if (stringComplete) {
+
+    //Serial.println(inputString);
+    executeCommand(inputString);
+
+    // clear the string:
+    inputString = "";
+    stringComplete = false;
+  }
+}
+
+//captures the command sent via serial
+void serialEvent() {
+  //Serial.println("Starting aggregation of serial characters");
+  while (Serial.available()) {
+    // get the new byte:
+    char inChar = (char)Serial.read();
+    // add it to the inputString:
+
+    // if the incoming character is a newline, set a flag
+    // so the main loop can do something about it:
+    if (inChar == '\n' || inChar == ' ') {
+      stringComplete = true;
+    } else {
+      inputString += inChar;
+      Serial.print("adding character: ");
+      Serial.println(inChar);
+    }
+  }
+}
+
+//TO DO - add the ability to parse out numbers following commands
+//this version simply matches the command with the function and execute it
+void executeCommand(String command){
+  //command.toLowerCase();
+  Serial.println(command);
+  if (command == "forward" || command == "fd"){
+    FD(moveTime);
+    Serial.println("Moving forward");
+  } else {
+    if (command == "backward" || command == "bd"){
+      BD(moveTime);
+      Serial.println("Moving backward");
+    } else {
+      if (command == "right" || command == "rt"){
+        RT(moveTime);
+        Serial.println("Right Turn");
+      } else {
+        if (command == "left" || command == "lt"){
+          LT(moveTime);
+          Serial.println("Left Turn");
+        } else {
+          if (command == "toot"){
+            toot();
+            Serial.println("Toot");
+          } else {
+            if (command == "light_on"){
+              light_on();
+              Serial.println("Lights On");
+            } else {
+              if (command == "light_off"){
+                light_off();
+                Serial.println("Lights Off");
+              } else {
+                Serial.print("Unable to execute:_");
+                Serial.println(command);
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+
+}

 /***************************************************************/
 /**      Commands from Logo's TORTIS project,                 **/
@@ -86,27 +169,45 @@
 /***************************************************************/

 // forward, aka FD
-void FD(int amt){{
-
+void FD(int amt){
+  motor.left(moveSpeed);
+  motor.right(moveSpeed);
+  delay(amt);
+  motor.left(0);
+  motor.right(0);
 }

 // backward, aka BD
 void BD(int amt){
-
+  motor.left(-moveSpeed);
+  motor.right(-moveSpeed);
+  delay(amt);
+  motor.left(0);
+  motor.right(0);
 }

 // turn left, aka LT
 void LT(int amt){
-
+  motor.left(-moveSpeed);
+  motor.right(moveSpeed);
+  delay(amt);
+  motor.left(0);
+  motor.right(0);
 }

 // turn right, aka RT
 void RT(int amt){
-
+  motor.left(moveSpeed);
+  motor.right(-moveSpeed);
+  delay(amt);
+  motor.left(0);
+  motor.right(0);
 }

 void toot(){
-
+  NT(NOTE_G3, 400);
+  delay(100);
+  NT(NOTE_G3, 400);
 }

 void pen_up(){
@@ -118,11 +219,11 @@
 }

 void light_on(){
-
+  digitalWrite(LED, HIGH);
 }

 void light_off(){
-
+  digitalWrite(LED, LOW);
 }

 // play a Note, not an authentic Logo command, just fun to use.


removed extra blank line

removed extra blank line


more switch

more switch

--- interduino/src/sketch.ino
+++ interduino/src/sketch.ino
@@ -4,7 +4,7 @@
 void setup()
 {
 	Serial.begin(9600);
-	pinMode(4, OUTPUT);
+	pinMode(10, OUTPUT);

 }

@@ -15,12 +15,12 @@
 	if(Serial.available()){
 		int ledState = Serial.read();
 		if(ledState == 65){
-			digitalWrite(4, HIGH);
+			digitalWrite(10, HIGH);
 			delay(10000);
-			digitalWrite(4, LOW);
+			digitalWrite(10, LOW);
 		}
 //		if(ledState == 90){
-//			digitalWrite(4, LOW);
+//			digitalWrite(10, LOW);
 //		}
 	}
 }