Use DallasTemperature.h

Use DallasTemperature.h

--- incuino/incuino.ino
+++ incuino/incuino.ino
@@ -19,6 +19,7 @@
 #include <Thread.h>
 #include <ThreadController.h>
 #include <TimerOne.h>
+#include <DallasTemperature.h>

 #define RELAY_PIN 8   // Connect Digital Pin 8 on Arduino to ? on Relay Module
 #define SENSOR_PIN 10
@@ -36,6 +37,7 @@
 double _kp = 70.0, _ki = 0.6, _kd = 0.6; // Initial tuning parameters
 PID _pid(&_input, &_output, &_setpoint, _kp, _ki, _kd, DIRECT);
 OneWire _ow(SENSOR_PIN);  // on pin 10 (a 4.7K resistor is necessary)
+DallasTemperature _sensors(&_ow); //Tell Dallas Temperature Library to use oneWire Library

 class Logger {

@@ -77,42 +79,8 @@
 Logger Log = Logger();

 float getTemp() {
-  byte i;
-  byte present = 0;
-  byte data[12];
-  byte addr[8];
-  unsigned long startTime;
-
-  _ow.reset_search();
-  if ( !_ow.search(addr)) {
-    _ow.reset_search();
-    startTime = millis();
-    while (millis() - startTime < 3000);
-    return ERROR_NO_MORE_ADDRESSES;
-  }
-  if (OneWire::crc8(addr, 7) != addr[7]) {
-    return ERROR_CRC_IS_NOT_VALID;
-  }
-  // the first ROM byte indicates which chip
-  int type_s = getChipType(addr[0]);
-  if (!_ow.reset()) {
-    return ERROR_FAILED_TO_RESET;
-  }
-  _ow.select(addr);
-  _ow.write(0x44, 1);        // start conversion, with parasite power on at the end
-  startTime = millis();
-  while (millis() - startTime < 1000); // maybe 750ms is enough, maybe not
-  // we might do a _ow.depower() here, but the reset will take care of it.
-  present = _ow.reset();
-  if (!present) {
-    Log.info("Failed to reset");
-  }
-  _ow.select(addr);
-  _ow.write(0xBE);         // Read Scratchpad
-  for ( i = 0; i < 9; i++) {           // we need 9 bytes
-    data[i] = _ow.read();
-  }
-  return convertTemp(data, type_s);
+  _sensors.requestTemperatures();
+  return _sensors.getTempCByIndex(0);
 }

 class SensorThread: public Thread {
@@ -132,14 +100,17 @@
   _controller.run();
 }

-SensorThread tempSensor = SensorThread();
+SensorThread _tempSensor = SensorThread();

 void setup(void) {
+  delay(1000);
   Serial.begin(9600);
+  delay(1000);
+  _sensors.begin();
   pinMode(RELAY_PIN, OUTPUT);
-  tempSensor.pin = SENSOR_PIN;
-  tempSensor.setInterval(10000);
-  _controller.add(&tempSensor);
+  _tempSensor.pin = SENSOR_PIN;
+  _tempSensor.setInterval(10000);
+  _controller.add(&_tempSensor);
   Timer1.initialize(10000000);
   Timer1.attachInterrupt(timerCallback);
   Timer1.start();
@@ -149,58 +120,8 @@
   _pid.SetMode(AUTOMATIC); //turn the PID on
 }

-int getChipType(int addr) {
-  switch (addr) {
-    case 0x10:
-      Log.debug("Chip = DS18S20");  // or old DS1820
-      return 1;
-      break;
-    case 0x28:
-      Log.debug("Chip = DS18B20");
-      return 0;
-      break;
-    case 0x22:
-      Log.debug("Chip = DS1822");
-      return 0;
-      break;
-    default:
-      Log.debug("Device is not a DS18x20 family device.");
-      return -1;
-  }
-}
-
-float convertTemp(byte data[12], int type_s) {
-  // Convert the data to actual temperature
-  // because the result is a 16 bit signed integer, it should
-  // be stored to an "int16_t" type, which is always 16 bits
-  // even when compiled on a 32 bit processor.
-  int16_t raw = (data[1] << 8) | data[0];
-  if (type_s) {
-    raw = raw << 3; // 9 bit resolution default
-    if (data[7] == 0x10) {
-      // "count remain" gives full 12 bit resolution
-      raw = (raw & 0xFFF0) + 12 - data[6];
-    }
-  }
-  else {
-    byte cfg = (data[4] & 0x60);
-    // at lower res, the low bits are undefined, so let's zero them
-    if (cfg == 0x00) {
-      raw = raw & ~7;  // 9 bit resolution, 93.75 ms
-    }
-    else if (cfg == 0x20) {
-      raw = raw & ~3; // 10 bit res, 187.5 ms
-    }
-    else if (cfg == 0x40) {
-      raw = raw & ~1; // 11 bit res, 375 ms}
-      //// default is 12 bit resolution, 750 ms conversion time
-    }
-  }
-  return (float) raw / 16.0;
-}
-
 void loop(void) {
-  float tempOrErrow = tempSensor.value;
+  float tempOrErrow = _tempSensor.value;
   if (tempOrErrow <= ERROR_RESPONSE) {
     Log.errorF("Code: ", tempOrErrow);
     return;


Fixed possible deadlock

Fixed possible deadlock

--- zamek.ino
+++ zamek.ino
@@ -94,7 +94,7 @@
 		bool	button	= digitalRead(pinButtonSwitch);
 		bool	door	= digitalRead(pinReedSwitch);

-		if(previousButtonState == pressed and button == released and door == close)
+		if(previousButtonState == pressed and button == released and isDoorLocked)
 			unlockDoor();
 		previousButtonState=button;


Change MOTOR_PIN to pin 10--pin 9 was destroyed

--- dremelfuge.ino
+++ dremelfuge.ino
@@ -29,7 +29,7 @@

 namespace {

-  const uint8_t MOTOR_PIN = 9;  // connected to base of transistor
+  const uint8_t MOTOR_PIN = 10;  // connected to base of transistor
   const uint8_t POT_PIN = A5;

   // White PushButton
@@ -169,6 +169,7 @@
 } // namespace

 // Application-specific function: Time and Instructions are the only dynamic UI
+
 inline void changeUI(PGM_P timeStr, PGM_P instructionStr) {

   // "Set time:" <=> "Finished in:"
@@ -393,4 +394,4 @@

   } // switch(mode)

-} // void loop()+} // void loop()


refactor

refactor

--- RGB_matrix.ino
+++ RGB_matrix.ino
@@ -27,47 +27,39 @@
     digitalWrite(13, LOW);
 }

-const int MODE0=0;
-const int MODE1=1;
-const int MODE2=2;
+const int MODE0=0,MODE1=1,MODE2=2;

-int buttonState=1;
 void loop() {
-    static int next_mode = MODE0;
-    if(next_mode==MODE0)      next_mode = start1();
-    else if(next_mode==MODE1) next_mode = music1();
-    else if(next_mode==MODE2) next_mode = music2();
+    static int mode = MODE0;
+
+    if(!digitalRead(9)) mode=(++mode)%3;
+
+    if(mode==MODE0)      start1();
+    else if(mode==MODE1) music1();
+    else if(mode==MODE2) music2();
+
+    delay(500);
 }

-int start1(){
-    delay(500);
-    buttonState=digitalRead(9);
-    if (buttonState ==LOW ) return MODE1;
-    else{
-        analogReference(INTERNAL);
-        int x=analogRead(5);
-        if(x<260){tone(8, 100,100);}
-        else if(x<280){tone(8, 600,100);}
-        else if(x<300){tone(8, 1100,100);}
-        else if(x<320){tone(8, 1600,100);}
-        else if(x<340){tone(8, 2100,100);}
-        else if(x<360){tone(8, 2600,100);}
-        else if(x<380){tone(8, 3100,100);}
-        else if(x<400){tone(8, 3600,100);}
-        else if(x<420){tone(8, 4100,100);}
-        else if(x<440){tone(8, 4600,100);}
-        else{tone(8, 5100,100);}
-        delay(1000);
-    }
-    return MODE0;
+void start1(){
+    analogReference(INTERNAL);
+    int x=analogRead(5);
+    if(x<260) tone(8, 100,100);
+    else if(x<280) tone(8,  600,100);
+    else if(x<300) tone(8, 1100,100);
+    else if(x<320) tone(8, 1600,100);
+    else if(x<340) tone(8, 2100,100);
+    else if(x<360) tone(8, 2600,100);
+    else if(x<380) tone(8, 3100,100);
+    else if(x<400) tone(8, 3600,100);
+    else if(x<420) tone(8, 4100,100);
+    else if(x<440) tone(8, 4600,100);
+    else tone(8, 5100,100);
+    delay(1000);
 }

-int music1(){
-    delay(500);
-    buttonState=1;
-    for (int thisNote = 0; thisNote < 82; thisNote++) {
-       buttonState=digitalRead(9);
-       if (buttonState ==LOW ) return MODE2;
+void music1(){
+    for (int thisNote = 0; thisNote < 82; thisNote++) {
        if(thisNote == 0){
             digitalWrite(5,LOW);
             digitalWrite(6,LOW);
@@ -158,12 +150,9 @@
         int pause = duration * 1.5; //音符の間で時間をあける
         delay(pause);
     }
-    return MODE1;
 }

-int music2(){
-    delay(500);
-    buttonState=1;
+void music2(){
     digitalWrite(0, LOW);
     digitalWrite(1, LOW);
     digitalWrite(2, LOW);
@@ -175,8 +164,6 @@
     digitalWrite(13, LOW);

     for (int thisNote = 0; thisNote < 68; thisNote++) {
-        buttonState=digitalRead(9);
-        if (buttonState ==LOW ) return MODE0;
         digitalWrite(5,HIGH);
         digitalWrite(6,HIGH);
         digitalWrite(7,HIGH);
@@ -190,5 +177,4 @@

         delay(pause);
     }
-    return MODE2;
 }


Add slew rate limiter functionality.

Add slew rate limiter functionality.

--- examples/seq/seq.ino
+++ examples/seq/seq.ino
@@ -22,6 +22,7 @@

 #include <du-ino_function.h>
 #include <du-ino_interface.h>
+#include <du-ino_dsp.h>
 #include <TimerOne.h>
 #include <avr/pgmspace.h>
 #include <util/atomic.h>
@@ -62,7 +63,7 @@
   bool stage_slew[8];
   uint8_t stage_count;
   bool diradd_mode;
-  uint8_t slew_rate;
+  float slew_hz;
   uint16_t gate_ms;
   unsigned long clock_period;
   bool clock_ext;
@@ -72,6 +73,8 @@

 volatile uint8_t stage, step;
 volatile bool gate, clock_gate, retrigger, reverse;
+
+DUINO_Filter * slew_filter;

 void clock_isr();
 void reset_isr();
@@ -85,7 +88,6 @@
     // TODO: attach GT3 to hardware clock isr that sets clock to EXT
     gt_attach_interrupt(GT3, clock_isr, CHANGE);
     gt_attach_interrupt(GT4, reset_isr, RISING);
-
   }

   virtual void loop()
@@ -149,7 +151,8 @@
     }

     // set pitch CV state
-    cv_out(CO1, seq_values.stage_cv[cached_stage]);
+    float slew_cv = slew_filter->filter(seq_values.stage_cv[cached_stage]);
+    cv_out(CO1, seq_values.stage_slew[cached_stage] ? slew_cv : seq_values.stage_cv[cached_stage]);

     // set gate and clock states
     gt_out(GT5, gate);
@@ -264,7 +267,8 @@
     {
       params.vals.slew_rate = 8;
     }
-    seq_values.slew_rate = params.vals.slew_rate;
+    seq_values.slew_hz = slew_hz(params.vals.slew_rate);
+    slew_filter->set_frequency(seq_values.slew_hz);

     if(params.vals.clock_bpm < 0 || params.vals.clock_bpm > 99)
     {
@@ -403,7 +407,8 @@
               {
                 params.vals.slew_rate = 16;
               }
-              seq_values.slew_rate = params.vals.slew_rate;
+              seq_values.slew_hz = slew_hz(params.vals.slew_rate);
+              slew_filter->set_frequency(seq_values.slew_hz);
               display->fill_rect(60, 13, 16, 5, DUINO_SSD1306::White);
               display_slew_rate(60, 13, params.vals.slew_rate, DUINO_SSD1306::Black);
               break;
@@ -591,6 +596,18 @@
     return 3000000 / (unsigned long)bpm;
   }

+  float slew_hz(uint8_t slew_rate)
+  {
+    if(slew_rate)
+    {
+      return (float)(17 - slew_rate) / 4.0;
+    }
+    else
+    {
+      return 65536.0;
+    }
+  }
+
   void display_slew_rate(int16_t x, int16_t y, uint8_t rate, DUINO_SSD1306::SSD1306Color color)
   {
     display->draw_vline(x + rate - 1, y, 5, color);
@@ -781,6 +798,8 @@
   stage = step = 0;
   gate = clock_gate = retrigger = false;

+  slew_filter = new DUINO_Filter(DUINO_Filter::LowPass, 1.0, 0.0);
+
   function = new DU_SEQ_Function();
   interface = new DU_SEQ_Interface();


fix url mentioned in script

fix url mentioned in script

--- playground/StereoLightTrigger/StereoLightTrigger.ino
+++ playground/StereoLightTrigger/StereoLightTrigger.ino
@@ -3,7 +3,7 @@
   StereoLightTrigger
   Demonstrates an interrupt-driven method for an Arduino to respond to LDR light threshold triggers.

-  For info and circuit diagrams see https://github.com/tardate/LittleArduinoProjects/tree/master/lpayground/StereoLightTrigger
+  For info and circuit diagrams see https://github.com/tardate/LittleArduinoProjects/tree/master/playground/StereoLightTrigger

  */


added D2 and D3 to react on RisingEdge

added D2 and D3 to react on RisingEdge

--- Buttons/Buttons.ino
+++ Buttons/Buttons.ino
@@ -1,17 +1,36 @@
 #include <Bounce.h>

+Bounce button2 = Bounce(2, 10); //D2
+Bounce button3 = Bounce(3, 10); //D3
 Bounce button4 = Bounce(4, 10); //D4
 Bounce button5 = Bounce(5, 10); //D5

 void setup() {
+  pinMode(2, INPUT_PULLUP);
+  pinMode(3, INPUT_PULLUP);
   pinMode(4, INPUT_PULLUP);
   pinMode(5, INPUT_PULLUP);
   pinMode(6, OUTPUT);
   digitalWrite(6, HIGH);
 }
 void loop() {
+  button2.update();
+  button3.update();
   button4.update();
   button5.update();
+
+  if (button2.risingEdge()) {
+    Keyboard.set_key1(KEY_P);
+    Keyboard.send_now();
+    Keyboard.set_key1(0);
+    Keyboard.send_now();
+  }
+  if (button3.risingEdge()) {
+    Keyboard.set_key1(KEY_O);
+    Keyboard.send_now();
+    Keyboard.set_key1(0);
+    Keyboard.send_now();
+  }

   if (button4.fallingEdge()) {
     Keyboard.set_key1(KEY_P);


Corrected RESTful buffer sizes

Corrected RESTful buffer sizes

--- freezer_monitor_v0_5/freezer_monitor_v0_5.ino
+++ freezer_monitor_v0_5/freezer_monitor_v0_5.ino
@@ -71,8 +71,8 @@
 SensorData sensorData;
 SensorThresholds sensorThresholds;

-char content[64];
-char buffer[128];
+char content[128];
+char buffer[64];

 /******************************************************************************


Fixed the calculation of the servo number

--- arduino_practice_target.ino
+++ arduino_practice_target.ino
@@ -35,7 +35,7 @@
 		Target* targets[targetsPerLane];

 		for (int t=0; t<targetsPerLane; t++){
-			servoNum = l * t % SERVOPERBOARD;
+			servoNum = (l * targetsPerLane + t) % SERVOPERBOARD;

 			if (servoNum == 0) {
 				pwm = Adafruit_PWMServoDriver(boardAddr++);
@@ -72,4 +72,4 @@
 	}

 	delete *lanes;
-}
+}


Moved Solenoid code to CoinSorter

Moved Solenoid code to CoinSorter

--- multi_point_solenoid/multi_point_solenoid.ino
+++ multi_point_solenoid/multi_point_solenoid.ino
@@ -1,64 +0,0 @@
-#include <Adafruit_NeoPixel.h>
-#ifdef __AVR__
-#include <avr/power.h>
-#endif
-
-#define SOLENOID_PIN       2
-#define LED_PIN            6
-
-// How many NeoPixels are attached to the Arduino?
-#define NUMPIXELS      18
-
-Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, LED_PIN, NEO_GRB + NEO_KHZ800);
-
-int delayval = 65; // delay for half a second
-
-void setup() {
-  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
-#if defined (__AVR_ATtiny85__)
-  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
-#endif
-  // End of trinket special code
-  Serial.begin(9600);
-  pinMode(SOLENOID_PIN, OUTPUT);
-  digitalWrite(SOLENOID_PIN, HIGH);
-  pixels.begin(); // This initializes the NeoPixel library.
-}
-
-void loop() {
-
-  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
-  int on_pixel;
-  int off_pixel;
-  int num_pixels_on = 2;
-  //This leaves 2 pixels on at all times:
-  for(int i=0;i < NUMPIXELS;i++){
-    on_pixel = i;
-    off_pixel = i - num_pixels_on;
-    if (on_pixel <  0){
-      on_pixel += NUMPIXELS;
-    }
-    if (off_pixel < 0){
-      off_pixel += NUMPIXELS;
-    }
-    if (on_pixel > NUMPIXELS){
-      on_pixel -= NUMPIXELS;
-    }
-    if (off_pixel > NUMPIXELS){
-      off_pixel -= NUMPIXELS;
-    }
-    pixels.setPixelColor(on_pixel, pixels.Color(255,255,255));
-    pixels.show();
-    pixels.setPixelColor(off_pixel, pixels.Color(0,0,0));
-    pixels.show();
-
-    if (Serial.available() > 0) {
-      int input = Serial.parseInt();
-      digitalWrite(SOLENOID_PIN, LOW);
-    }
-    if (Serial.read() == '\n') {};
-    delay(delayval);
-    digitalWrite(SOLENOID_PIN, HIGH);
-  }
-}
-


v1.6.1 - better screen and Serial handling

--- DigitalVFO.ino
+++ DigitalVFO.ino
@@ -38,16 +38,18 @@
 #define DEBUG_INT     (1 << 6)  // interrupts
 #define DEBUG_DISP    (1 << 7)  // display
 #define DEBUG_BATT    (1 << 8)  // battery
+#define DEBUG_MISC    (1 << 9)  // usually just debugging

 // DEBUG word for debugging program - bitmask values
-#define DEBUG         (DEBUG_BATT + DEBUG_ACT)
+#define DEBUG         (DEBUG_MISC + DEBUG_EVENT)
+//#define DEBUG         (DEBUG_BATT + DEBUG_ACT)
 //#define DEBUG         0
 //#define DEBUG         0xff

 // Digital VFO program name & version
 const char *ProgramName = "DigitalVFO";
 const char *Version = "1.6";
-const char *MinorVersion = ".0";
+const char *MinorVersion = ".1";
 const char *Callsign = "ac3dn";

 // display constants - below is for ubiquitous small HD44780 16x2 display
@@ -223,10 +225,6 @@

 //-----
-// VFO modes.  Online or standby.
-//-----
-
-//-----
 // Miscellaneous.
 //-----

@@ -325,7 +323,7 @@
 /* restart the Teensy, without invoking bootloader. */
 void restart(void)
 {
-  Serial.print(F("Restarting ..."));
+  Serial.print("Restarting ...");
   delay(500);
   WRITE_RESTART(0x5FA0004);
 }
@@ -333,7 +331,7 @@
 /* reboot the Teensy, invoking bootloader. */
 void reboot(void)
 {
-  Serial.print(F("Rebooting ..."));
+  Serial.print("Rebooting ...");
   delay(500);
   _reboot_Teensyduino_();
 }
@@ -346,6 +344,8 @@

 void initialize_eeprom()
 {
+  Serial.print("Erasing EVERYTHING in EEPROM!\n");
+  delay(3000);
   EEPROM.put(EepromFreq, DefaultFrequency);
   EEPROM.put(EepromSelDigit, DefaultSelDigit);
   EEPROM.put(EepromVfoClockOffset, DefaultVfoClockOffset);
@@ -390,7 +390,7 @@
   char *ptr = buf;

   // print error on console (maybe)
-  Serial.printf(F("message=%s\nTeensy is paused!\n"), msg);
+  Serial.printf("message=%s\nTeensy is paused!\n", msg);

   // truncate/pad message to NumRows * NumCols chars
   for (int i = 0; i < NumCols*NumRows; ++i)
@@ -433,23 +433,25 @@
 void decode_debug_levels(int debug)
 {
   if (debug & DEBUG_DDS)
-    Serial.print(F("    DEBUG_DDS\tbit is set\n"));
+    Serial.printf("    DEBUG_DDS\tbit is set: %06x\n", DEBUG_DDS);
   if (debug & DEBUG_FREQ)
-    Serial.print(F("    DEBUG_FREQ\tbit is set\n"));
+    Serial.printf("    DEBUG_FREQ\tbit is set: %06x\n", DEBUG_FREQ);
   if (debug & DEBUG_MENU)
-    Serial.print(F("    DEBUG_MENU\tbit is set\n"));
+    Serial.printf("    DEBUG_MENU\tbit is set: %06x\n", DEBUG_MENU);
   if (debug & DEBUG_EVENT)
-    Serial.print(F("    DEBUG_EVENT\tbit is set\n"));
+    Serial.printf("    DEBUG_EVENT\tbit is set: %06x\n", DEBUG_EVENT);
   if (debug & DEBUG_ACT)
-    Serial.print(F("    DEBUG_ACT\tbit is set\n"));
+    Serial.printf("    DEBUG_ACT\tbit is set: %06x\n", DEBUG_ACT);
   if (debug & DEBUG_RE)
-    Serial.print(F("    DEBUG_RE\tbit is set\n"));
+    Serial.printf("    DEBUG_RE\tbit is set: %06x\n", DEBUG_RE);
   if (debug & DEBUG_INT)
-    Serial.print(F("    DEBUG_INT\tbit is set\n"));
+    Serial.printf("    DEBUG_INT\tbit is set: %06x\n", DEBUG_INT);
   if (debug & DEBUG_DISP)
-    Serial.print(F("    DEBUG_DISP\tbit is set\n"));
+    Serial.printf("    DEBUG_DISP\tbit is set: %06x\n", DEBUG_DISP);
   if (debug & DEBUG_BATT)
-    Serial.print(F("    DEBUG_BATT\tbit is set\n"));
+    Serial.printf("    DEBUG_BATT\tbit is set: %06x\n", DEBUG_BATT);
+  if (debug & DEBUG_MISC)
+    Serial.printf("    DEBUG_MISC\tbit is set: %06x\n", DEBUG_MISC);
 }

 //----------------------------------------
@@ -509,6 +511,19 @@
   }
   lcd.clear();
   delay(100);
+  analogWrite(mc_Brightness, LcdBrightness);
+}
+
+void fade_out(void)
+{
+  // do a fade out, clear screen then normal brightness
+  for (int i = LcdBrightness; i; --i)
+  {
+    analogWrite(mc_Brightness, i);
+    delay(10);
+  }
+  lcd.clear();
+  delay(300);
   analogWrite(mc_Brightness, LcdBrightness);
 }

@@ -652,9 +667,7 @@

 #if (DEBUG & DEBUG_BATT)
   if (++batt_report_count > 0)
-  {
-    Serial.printf(F("volts: %.2fv, "), AverageVoltage);
-  }
+    Serial.printf("volts: %.2fv, ", AverageVoltage);
 #endif

   // figure out which battery symbol to use
@@ -663,9 +676,7 @@
     BatterySymbol = battnone;
 #if (DEBUG & DEBUG_BATT)
     if (batt_report_count > 0)
-    {
-      Serial.printf(F("no battery\n"));
-    }
+      Serial.printf("no battery\n");
 #endif
   }
   else if (AverageVoltage < MinVoltage)
@@ -673,9 +684,7 @@
     BatterySymbol = battunder;
 #if (DEBUG & DEBUG_BATT)
     if (batt_report_count > 0)
-    {
-      Serial.printf(F("battery under voltage\n"));
-    }
+      Serial.printf("battery under voltage\n");
 #endif
   }
   else if (AverageVoltage > OverVoltage)
@@ -683,9 +692,7 @@
     BatterySymbol = battover;
 #if (DEBUG & DEBUG_BATT)
     if (batt_report_count > 0)
-    {
-      Serial.printf(F("OVER VOLTAGE\n"));
-    }
+      Serial.printf("OVER VOLTAGE\n");
 #endif
   }
   else
@@ -695,17 +702,13 @@
     BatterySymbol = batt_syms[batt_bucket + 1];
 #if (DEBUG & DEBUG_BATT)
     if (batt_report_count > 0)
-    {
-      Serial.printf(F("batt_bucket=%d\n"), batt_bucket+1);
-    }
+      Serial.printf("batt_bucket=%d\n", batt_bucket+1);
 #endif
   }

 #if (DEBUG & DEBUG_BATT)
   if (batt_report_count > 0)
-  {
     batt_report_count = -ReportVoltageDelay;
-  }
 #endif
 }

@@ -733,19 +736,19 @@

 const char * xcmd_help(char *answer, char *cmd)
 {
-  strcpy(answer, (char *) F("\n-----------Interactive Commands-----------------\n"));
-  strcat(answer, (char *) F("H;           send help text to console\n"));
-  strcat(answer, (char *) F("BH;          boot hard, reload software via USB\n"));
-  strcat(answer, (char *) F("BS;          boot soft, restart program\n"));
-  strcat(answer, (char *) F("DE;          dump EEPROM\n"));
-  strcat(answer, (char *) F("ID;          get device identifier string\n"));
-  strcat(answer, (char *) F("MO;          set VFO mode to 'online'\n"));
-  strcat(answer, (char *) F("MS;          set VFO mode to 'standby'\n"));
-  strcat(answer, (char *) F("MG;          get VFO mode\n"));
-  strcat(answer, (char *) F("FSnnnnnnnn;  set frequency to 'nnnnnnnn'\n"));
-  strcat(answer, (char *) F("FG;          get frequency\n"));
-  strcat(answer, (char *) F("VG;          get battery voltage\n"));
-  strcat(answer, (char *) F("------------------------------------------------\n"));
+  strcpy(answer, (char *) "\n-----------Interactive Commands-----------------\n");
+  strcat(answer, (char *) "H;           send help text to console\n");
+  strcat(answer, (char *) "BH;          boot hard, reload software via USB\n");
+  strcat(answer, (char *) "BS;          boot soft, restart program\n");
+  strcat(answer, (char *) "DE;          dump EEPROM\n");
+  strcat(answer, (char *) "ID;          get device identifier string\n");
+  strcat(answer, (char *) "MO;          set VFO mode to 'online'\n");
+  strcat(answer, (char *) "MS;          set VFO mode to 'standby'\n");
+  strcat(answer, (char *) "MG;          get VFO mode\n");
+  strcat(answer, (char *) "FSnnnnnnnn;  set frequency to 'nnnnnnnn'\n");
+  strcat(answer, (char *) "FG;          get frequency\n");
+  strcat(answer, (char *) "VG;          get battery voltage\n");
+  strcat(answer, (char *) "------------------------------------------------\n");
   return answer;
 }

@@ -1011,10 +1014,10 @@

 void dump_menuitem(struct MenuItem *menuitem)
 {
-  Serial.printf(F("  menuitem address=%08x\n"), menuitem);
-  Serial.printf(F("  title=%s\n"), menuitem->title);
-  Serial.printf(F("  menu=%08x\n"), menuitem->menu);
-  Serial.printf(F("  action=%08x\n"), menuitem->action);
+  Serial.printf("  menuitem address=%08x\n", menuitem);
+  Serial.printf("  title=%s\n", menuitem->title);
+  Serial.printf("  menu=%08x\n", menuitem->menu);
+  Serial.printf("  action=%08x\n", menuitem->action);
 }

 //----------------------------------------
@@ -1023,17 +1026,17 @@

 void dump_menu(const char *msg, struct Menu *menu)
 {
-  Serial.printf(F("----------------- Menu --------------------\n"));
-  Serial.printf(F("%s\n"), msg);
-  Serial.printf(F("menu address=%08x\n"), menu);
-  Serial.printf(F("  title=%s\n"), menu->title);
-  Serial.printf(F("  num_items=%d\n"), menu->num_items);
-  Serial.printf(F("  items address=%08x\n"), menu->items);
+  Serial.printf("----------------- Menu --------------------\n");
+  Serial.printf("%s\n", msg);
+  Serial.printf("menu address=%08x\n", menu);
+  Serial.printf("  title=%s\n", menu->title);
+  Serial.printf("  num_items=%d\n", menu->num_items);
+  Serial.printf("  items address=%08x\n", menu->items);

   for (int i = 0; i < menu->num_items; ++i)
     dump_menuitem(menu->items[i]);

-  Serial.printf(F("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"));
+  Serial.printf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
 }
 #endif

@@ -1106,38 +1109,38 @@
       // get next event and handle it
       byte event = event_pop();
 #if (DEBUG & DEBUG_MENU)
-      Serial.printf(F("menu_show loop: event=%s\n"), event2display(event));
+      Serial.printf("menu_show loop: event=%s\n", event2display(event));
 #endif

       switch (event)
       {
         case vfo_RLeft:
 #if (DEBUG & DEBUG_MENU)
-          Serial.printf(F("menu_show: vfo_RLeft\n"));
+          Serial.printf("menu_show: vfo_RLeft\n");
 #endif
           if (--item_num < 0)
             item_num = 0;
           break;
         case vfo_RRight:
 #if (DEBUG & DEBUG_MENU)
-          Serial.printf(F("menu_show: vfo_RRight\n"));
+          Serial.printf("menu_show: vfo_RRight\n");
 #endif
           if (++item_num >= menu->num_items)
             item_num = menu->num_items - 1;
           break;
         case vfo_DnRLeft:
 #if (DEBUG & DEBUG_MENU)
-          Serial.printf(F("menu_show: vfo_DnRLeft (ignored)\n"));
+          Serial.printf("menu_show: vfo_DnRLeft (ignored)\n");
 #endif
           break;
         case vfo_DnRRight:
 #if (DEBUG & DEBUG_MENU)
-          Serial.printf(F("menu_show: vfo_DnRRight (ignored)\n"));
+          Serial.printf("menu_show: vfo_DnRRight (ignored)\n");
 #endif
           break;
         case vfo_Click:
 #if (DEBUG & DEBUG_MENU)
-          Serial.printf(F("menu_show: vfo_Click\n"));
+          Serial.printf("menu_show: vfo_Click\n");
 #endif
           if (menu->items[item_num]->action != NULL)
           {
@@ -1152,18 +1155,18 @@
           }
           menu_draw(menu);    // redraw the menu header, item redrawn below
 #if (DEBUG & DEBUG_MENU)
-          Serial.printf(F("menu_show: end of vfo_Click handling\n"));
+          Serial.printf("menu_show: end of vfo_Click handling\n");
 #endif
           break;
         case vfo_HoldClick:
 #if (DEBUG & DEBUG_MENU)
-          Serial.printf(F("menu_show: vfo_HoldClick, exit menu\n"));
+          Serial.printf("menu_show: vfo_HoldClick, exit menu\n");
 #endif
           event_flush();
           return;             // back to the parent menu or main screen
         default:
 #if (DEBUG & DEBUG_MENU)
-          Serial.printf(F("menu_show: unrecognized event %d\n"), event);
+          Serial.printf("menu_show: unrecognized event %d\n", event);
 #endif
           break;
       }
@@ -1181,13 +1184,13 @@

 void display_flash(void)
 {
-  lcd.noDisplay();
-  delay(150);
-  lcd.display();
-  delay(150);
-  lcd.noDisplay();
-  delay(150);
-  lcd.display();
+    for (int x = 0; x < 4; ++x)
+  {
+    lcd.noDisplay();
+    delay(50);
+    lcd.display();
+    delay(50);
+  }
 }

@@ -1216,7 +1219,7 @@
 void event_push(VFOEvent event)
 {
 #if (DEBUG & DEBUG_EVENT)
-  Serial.printf(F("event_push: pushing %s\n"), event2display(event));
+  Serial.printf("event_push: pushing %s\n", event2display(event));
 #endif

   // put new event into next empty slot
@@ -1264,7 +1267,7 @@
   interrupts();

 #if (DEBUG & DEBUG_EVENT)
-  Serial.printf(F("event_pop: popping %s\n"), event2display(event));
+  Serial.printf("event_pop: popping %s\n", event2display(event));
 #endif

   return event;
@@ -1317,21 +1320,21 @@
   // Must protect from RE code fiddling with queue
   noInterrupts();

-  Serial.printf(F("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"));
-  Serial.printf(F("Queue: %s\n"), msg);
+  Serial.printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
+  Serial.printf("Queue: %s\n", msg);
   for (int i = 0; i < EventQueueLength; ++i)
   {
     VFOEvent event = event_queue[i];

-    Serial.printf(F("  %d -> %s\n"), i, event2display(event));
+    Serial.printf("  %d -> %s\n", i, event2display(event));
   }
   if (event_pending() == 0)
-    Serial.printf(F("Queue length=0 (or %d)\n"), EventQueueLength);
+    Serial.printf("Queue length=0 (or %d)\n", EventQueueLength);
   else
-    Serial.printf(F("Queue length=%d\n"), event_pending());
-  Serial.printf(F("queue_aft=%d"), queue_aft);
-  Serial.printf(F(", queue_fore=%d\n"), queue_fore);
-  Serial.printf(F("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"));
+    Serial.printf("Queue length=%d\n", event_pending());
+  Serial.printf("queue_aft=%d", queue_aft);
+  Serial.printf(", queue_fore=%d\n", queue_fore);
+  Serial.printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");

   interrupts();
 }
@@ -1389,7 +1392,7 @@
   int index = num_digits - sel_col - 1;

 #if (DEBUG & DEBUG_DISPLAY)
-  Serial.printf(F("display_sel_value: value=%ld, sel_col=%d, num_digits=%d, col=%d, row=%d"),
+  Serial.printf("display_sel_value: value=%ld, sel_col=%d, num_digits=%d, col=%d, row=%d",
                    value, sel_col, num_digits, col, row);
 #endif

@@ -1456,7 +1459,7 @@
   char prefix = '+';

 #if (DEBUG & DEBUG_ACT)
-  Serial.printf(F("display_sel_offset: value=%d, sel_col=%d, num_digits=%d, col=%d, row=%d\n"),
+  Serial.printf("display_sel_offset: value=%d, sel_col=%d, num_digits=%d, col=%d, row=%d\n",
                 value, sel_col, num_digits, col, row);
 #endif

@@ -1567,13 +1570,13 @@
   // sample the pin value
   re_down = digitalRead(re_pinPush);
 #if (DEBUG & DEBUG_INT)
-    Serial.printf(F("pinPush_isr: re_down=0x%02X\n"), re_down);
+    Serial.printf("pinPush_isr: re_down=0x%02X\n", re_down);
 #endif

   if (re_down)
   {
 #if (DEBUG & DEBUG_INT)
-    Serial.printf(F("pinPush_isr: button DOWN\n"));
+    Serial.printf("pinPush_isr: button DOWN\n");
 #endif

     // button pushed down
@@ -1583,7 +1586,7 @@
   else
   {
 #if (DEBUG & DEBUG_INT)
-    Serial.printf(F("pinPush_isr: button UP\n"));
+    Serial.printf("pinPush_isr: button UP\n");
 #endif

     // button released, check if rotation, UP event if not
@@ -1639,7 +1642,7 @@
   byte pin_B = digitalRead(re_pinB);

 #if (DEBUG & DEBUG_INT)
-    Serial.printf(F("pinA_isr: pin_A=0x%02X, pin_B=0x%02X\n"), pin_A, pin_B);
+    Serial.printf("pinA_isr: pin_A=0x%02X, pin_B=0x%02X\n", pin_A, pin_B);
 #endif

   if (pin_A && pin_B && aFlag)
@@ -1676,7 +1679,7 @@
   byte pin_B = digitalRead(re_pinB);

 #if (DEBUG & DEBUG_INT)
-    Serial.printf(F("pinB_isr: pin_A=0x%02X, pin_B=0x%02X\n"), pin_A, pin_B);
+    Serial.printf("pinB_isr: pin_A=0x%02X, pin_B=0x%02X\n", pin_A, pin_B);
 #endif

   if (pin_A && pin_B && bFlag)
@@ -1774,7 +1777,7 @@
 // Print all EEPROM saved data to console.
 //----------------------------------------

-#define DELAY_MS 20  // not sure why we need a delay to print reliably
+#define DELAY_MS 100  // not sure why we need a delay to print reliably

 void dump_eeprom(void)
 {
@@ -1796,36 +1799,29 @@
   EEPROM.get(EepromDClickTime, dclick);
   EEPROM.get(EepromVoltsCalibrate, volt_calib);

-  Serial.printf(F("=================================================\n"));
+  Serial.printf("=================================================\n");
+  Serial.printf("dump_eeprom:\n");
+  Serial.printf("offset size  value\n");
+  Serial.printf("------ ----  -----\n");
+  Serial.printf("   %3d  (%d)  VfoFrequency=%ld\n", EepromFreq, sizeof(Frequency), freq);
+  Serial.printf("   %3d  (%d)  EepromSelDigit=%d\n", EepromSelDigit, sizeof(SelOffset), offset);
+  Serial.printf("   %3d  (%d)  VfoClockOffset=%d\n", EepromVfoClockOffset, sizeof(VfoClockOffset), clkoffset);
+  Serial.printf("   %3d  (%d)  LcdContrast=%d\n", EepromContrast, sizeof(LcdContrast), contrast);
+  Serial.printf("   %3d  (%d)  LcdBrightness=%d\n", EepromBrightness, sizeof(LcdBrightness), brightness);
+  Serial.printf("   %3d  (%d)  ReHoldClickTime=%dmsec\n", EepromHoldClickTime, sizeof(ReHoldClickTime), hold);
+  Serial.printf("   %3d  (%d)  ReDClickTime=%dmsec\n", EepromDClickTime, sizeof(ReDClickTime), dclick);
+  Serial.printf("   %3d  (%d)  VoltsCalibrate=%d\n", EepromVoltsCalibrate, sizeof(VoltsCalibrate), volt_calib);
+
   delay(DELAY_MS);
-  Serial.printf(F("dump_eeprom:\n"));
-  delay(DELAY_MS);
-  Serial.printf(F("   %2d (%d)  VfoFrequency=%ld\n"), EepromFreq, sizeof(Frequency), freq);
-  delay(DELAY_MS);
-  Serial.printf(F("   %2d (%d)  EepromSelDigit=%d\n"), EepromSelDigit, sizeof(SelOffset), offset);
-  delay(DELAY_MS);
-  Serial.printf(F("   %2d (%d)  VfoClockOffset=%d\n"), EepromVfoClockOffset, sizeof(VfoClockOffset), clkoffset);
-  delay(DELAY_MS);
-  Serial.printf(F("   %2d (%d)  LcdContrast=%d\n"), EepromContrast, sizeof(LcdContrast), contrast);
-  delay(DELAY_MS);
-  Serial.printf(F("   %2d (%d)  LcdBrightness=%d\n"), EepromBrightness, sizeof(LcdBrightness), brightness);
-  delay(DELAY_MS);
-  Serial.printf(F("   %2d (%d)  ReHoldClickTime=%dmsec\n"), EepromHoldClickTime, sizeof(ReHoldClickTime), hold);
-  delay(DELAY_MS);
-  Serial.printf(F("   %2d (%d)  ReDClickTime=%dmsec\n"), EepromDClickTime, sizeof(ReDClickTime), dclick);
-  delay(DELAY_MS);
-  Serial.printf(F("   %2d (%d)  VoltsCalibrate=%d\n"), EepromVoltsCalibrate, sizeof(VoltsCalibrate), volt_calib);
-  delay(DELAY_MS);

   for (int i = 0; i < NumSaveSlots; ++i)
   {
     get_slot(i, freq, offset);
-    Serial.printf(F("Slot %d: freq=%ld, seldig=%d\n"), i, freq, offset);
+    Serial.printf("Slot %d: freq=%ld, seldig=%d\n", i, freq, offset);
     delay(DELAY_MS);
   }

-  Serial.printf(F("=================================================\n"));
-  delay(DELAY_MS);
+  Serial.printf("=================================================\n");
 }

 //##############################################################################
@@ -1874,7 +1870,7 @@
 void dds_update(Frequency frequency)
 {
 //#if (DEBUG & DEBUG_DDS)
-//  Serial.printf(F("dds_update: frequency=%ld\n"), frequency);
+//  Serial.printf("dds_update: frequency=%ld\n", frequency);
 //#endif

   // if not online, do nothing
@@ -1885,7 +1881,7 @@
   ULONG data = (frequency * 4294967296) / (180000000 - VfoClockOffset);

 #if (DEBUG & DEBUG_DDS)
-  Serial.printf(F("dds_update: ONLINE: frequency=%ld, VfoClockOffset=%d, data=%ld\n"),
+  Serial.printf("dds_update: ONLINE: frequency=%ld, VfoClockOffset=%d, data=%ld\n",
                 frequency, VfoClockOffset, data);
 #endif

@@ -1906,7 +1902,7 @@
 void dds_standby(void)
 {
 #if (DEBUG & DEBUG_DDS)
-  Serial.printf(F("DDS into standby mode.\n"));
+  Serial.printf("DDS into standby mode.\n");
 #endif
   dds_update(0L);
 }
@@ -1918,7 +1914,7 @@
 void dds_online(void)
 {
 #if (DEBUG & DEBUG_FREQ)
-  Serial.printf(F("DDS into online mode, frequency=%dHz.\n"), VfoFrequency);
+  Serial.printf("DDS into online mode, frequency=%dHz.\n", VfoFrequency);
 #endif
   dds_update(VfoFrequency);
 }
@@ -1959,7 +1955,6 @@
   Serial.begin(19200);

 #if INIT_EEPROM != 0
-  Serial.print(F("Erasing EVERYTHING in EEPROM!\n"));
   initialize_eeprom();  // WARNING! Destroys the EEPROM stored values
 #endif

@@ -1983,8 +1978,11 @@

   // get state back from EEPROM, set display brightness/contrast
   restore_from_eeprom();
-  analogWrite(mc_Brightness, 0);    // display off while initializing
+  analogWrite(mc_Brightness, LcdBrightness);    // display off while initializing
   analogWrite(mc_Contrast, LcdContrast);
+
+  // show program name and version number
+  show_credits(false);

   // create underlined space for frequency display
   lcd.createChar(SpaceChar, sel_digits[SpaceIndex]);
@@ -2009,9 +2007,9 @@
     ReHoldClickTime = DefaultHoldClickTime;
     ReDClickTime = DefaultDClickTime;

-    Serial.printf(F("Resetting brightness to %d, contrast to %d and hold/dclick times\n"),
+    Serial.printf("Resetting brightness to %d, contrast to %d and hold/dclick times\n",
                   LcdBrightness, LcdContrast);
-    Serial.print(F("Click the RE button to continue..."));
+    Serial.print("Click the RE button to continue...");

     // show user we were reset
     lcd.clear();
@@ -2029,26 +2027,6 @@
     lcd.clear();
     delay(500);
   }
-
-  Serial.printf(F("%s %s%s (%s)\n"), ProgramName, Version, MinorVersion, Callsign);
-
-#if (DEBUG != 0)
-  Serial.printf(F("DEBUG is defined as %06X:\n"), DEBUG);
-  decode_debug_levels(DEBUG);
-//#else
-//  Serial.println(F("DEBUG is not turned on."));
-#endif
-
-  // dump EEPROM values
-#if (DEBUG != 0)
-  dump_eeprom();
-#endif
-
-  Serial.printf(F("Preparing screen ... "));
-
-  // show program name and version number
-  analogWrite(mc_Brightness, LcdBrightness);    // display ON for banner
-  banner();

   // eat any events that may have been generated
   event_flush();
@@ -2056,9 +2034,20 @@
   // measure voltage once, put into AverageVoltage
   AverageVoltage = get_volts();

+  fade_out();
+
+  Serial.printf("%s %s%s (%s)\n", ProgramName, Version, MinorVersion, Callsign);
+
+  // if *any* DEBUG turned on, explain state
+#if (DEBUG != 0)
+  Serial.printf("DEBUG is defined as %06X:\n", DEBUG);
+  decode_debug_levels(DEBUG);
+  dump_eeprom();
+#endif
+
   // show the main screen and continue in loop()
   show_main_screen();
-  Serial.print(F("Ready!\n"));
+  Serial.print("Ready!\n");
 }

 //----------------------------------------
@@ -2069,16 +2058,11 @@
 void show_main_screen(void)
 {
   lcd.clear();
-  lcd.setCursor(0, 0);
-//  lcd.print("Vfo:");
   display_sel_value(VfoFrequency, VfoSelectDigit, NumFreqChars, NumCols - NumFreqChars - 2, 0);
   lcd.print("Hz");

   lcd.setCursor(0, 1);
-  lcd.write(BlankRow);
-  lcd.setCursor(0, 1);
   lcd.write(mode2display(VfoMode));
-
 }

 //----------------------------------------
@@ -2429,7 +2413,7 @@
       LcdBrightness = index * 16 - 1;
       analogWrite(mc_Brightness, LcdBrightness);
 #if (DEBUG & DEBUG_ACT)
-      Serial.printf(F("brightness_action: brightness set to %d\n"), LcdBrightness);
+      Serial.printf("brightness_action: brightness set to %d\n", LcdBrightness);
 #endif

       // show brightness value in row 1
@@ -2510,7 +2494,7 @@
       LcdContrast = index * 16;
       analogWrite(mc_Contrast, LcdContrast);
 #if (DEBUG & DEBUG_ACT)
-      Serial.printf(F("contrast_action: contrast set to %d\n"), LcdContrast);
+      Serial.printf("contrast_action: contrast set to %d\n", LcdContrast);
 #endif

       // show brightness value in row 1
@@ -2582,7 +2566,7 @@
           if (holdtime < MinHoldClickTime)
             holdtime = MinHoldClickTime;
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("holdclick_action: vfo_RLeft, after holdtime=%d\n"), holdtime);
+          Serial.printf("holdclick_action: vfo_RLeft, after holdtime=%d\n", holdtime);
 #endif
           break;
         case vfo_RRight:
@@ -2590,7 +2574,7 @@
           if (holdtime > MaxHoldClickTime)
             holdtime = MaxHoldClickTime;
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("holdclick_action: vfo_RRight, after holdtime=%d\n"), holdtime);
+          Serial.printf("holdclick_action: vfo_RRight, after holdtime=%d\n", holdtime);
 #endif
           break;
         case vfo_Click:
@@ -2650,7 +2634,7 @@
           if (dctime < MinDClickTime)
             dctime = MinDClickTime;
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("doubleclick_action: vfo_RLeft, after dctime=%d\n"), dctime);
+          Serial.printf("doubleclick_action: vfo_RLeft, after dctime=%d\n", dctime);
 #endif
           break;
         case vfo_RRight:
@@ -2658,7 +2642,7 @@
           if (dctime > MaxDClickTime)
             dctime = MaxDClickTime;
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("doubleclick_action: vfo_RRight, after dctime=%d\n"), dctime);
+          Serial.printf("doubleclick_action: vfo_RRight, after dctime=%d\n", dctime);
 #endif
           break;
         case vfo_Click:
@@ -2729,7 +2713,7 @@
           if (VfoClockOffset < MinClockOffset)
             VfoClockOffset = MinClockOffset;
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("calibrate_freq_action: vfo_RLeft, after VfoClockOffset=%d\n"),
+          Serial.printf("calibrate_freq_action: vfo_RLeft, after VfoClockOffset=%d\n",
                         VfoClockOffset);
 #endif
           break;
@@ -2738,31 +2722,31 @@
           if (VfoClockOffset > MaxClockOffset)
             VfoClockOffset = MaxClockOffset;
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("calibrate_freq_action: vfo_RRight, after VfoClockOffset=%d\n"),
+          Serial.printf("calibrate_freq_action: vfo_RRight, after VfoClockOffset=%d\n",
                         VfoClockOffset);
 #endif
           break;
         case vfo_DnRLeft:
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("calibrate_freq_action: vfo_DnRLeft\n"));
+          Serial.printf("calibrate_freq_action: vfo_DnRLeft\n");
 #endif
           ++seldig;
           if (seldig >= MaxOffsetDigits)
             seldig = MaxOffsetDigits - 1;
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("calibrate_freq_action: vfo_DnRLeft, after seldig=%d\n"),
+          Serial.printf("calibrate_freq_action: vfo_DnRLeft, after seldig=%d\n",
                         seldig);
 #endif
           break;
         case vfo_DnRRight:
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("calibrate_freq_action: vfo_DnRLeft\n"));
+          Serial.printf("calibrate_freq_action: vfo_DnRLeft\n");
 #endif
           --seldig;
           if (seldig < 0)
             seldig = 0;
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("calibrate_freq_action: vfo_DnRRight, after seldig=%d\n"),
+          Serial.printf("calibrate_freq_action: vfo_DnRRight, after seldig=%d\n",
                         seldig);
 #endif
           break;
@@ -2836,7 +2820,7 @@
           if (VoltsCalibrate < MinVoltsCalibrate)
             VoltsCalibrate = MinVoltsCalibrate;
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("volts_calibrate_action: vfo_RLeft, after VoltsCalibrate=%d\n"),
+          Serial.printf("volts_calibrate_action: vfo_RLeft, after VoltsCalibrate=%d\n",
                         VoltsCalibrate);
 #endif
           break;
@@ -2845,31 +2829,31 @@
           if (VoltsCalibrate > MaxVoltsCalibrate)
             VoltsCalibrate = MaxVoltsCalibrate;
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("volts_calibrate_action: vfo_RRight, after VoltsCalibrate=%d\n"),
+          Serial.printf("volts_calibrate_action: vfo_RRight, after VoltsCalibrate=%d\n",
                         VoltsCalibrate);
 #endif
           break;
         case vfo_DnRLeft:
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("volts_calibrate_action: vfo_DnRLeft\n"));
+          Serial.printf("volts_calibrate_action: vfo_DnRLeft\n");
 #endif
           ++seldig;
           if (seldig >= MaxOffsetDigits)
             seldig = MaxOffsetDigits - 1;
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("volts_calibrate_action: vfo_DnRLeft, after seldig=%d\n"),
+          Serial.printf("volts_calibrate_action: vfo_DnRLeft, after seldig=%d\n",
                         seldig);
 #endif
           break;
         case vfo_DnRRight:
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("volts_calibrate_action: vfo_DnRLeft\n"));
+          Serial.printf("volts_calibrate_action: vfo_DnRLeft\n");
 #endif
           --seldig;
           if (seldig < 0)
             seldig = 0;
 #if (DEBUG & DEBUG_ACT)
-          Serial.printf(F("volts_calibrate_action: vfo_DnRRight, after seldig=%d\n"),
+          Serial.printf("volts_calibrate_action: vfo_DnRRight, after seldig=%d\n",
                         seldig);
 #endif
           break;
@@ -2977,7 +2961,7 @@
       char answer[512];    // place to construct answer strings

       CommandBuffer[CommandIndex] = '\0';
-      Serial.printf(F("%s\n"), do_external_cmd(answer, CommandBuffer, CommandIndex-1));
+      Serial.printf("%s\n", do_external_cmd(answer, CommandBuffer, CommandIndex-1));
       CommandIndex = 0;
     }
   }
@@ -2995,7 +2979,7 @@
     VFOEvent event = event_pop();

 #if (DEBUG & DEBUG_EVENT)
-    Serial.printf(F("handle_RE_events: event=%s\n"), event2display(event));
+    Serial.printf("handle_RE_events: event=%s\n", event2display(event));
 #endif

     switch (event)


Do not interfere with uboot.

Do not interfere with uboot.

--- support/BotFirmata/BotFirmata.ino
+++ support/BotFirmata/BotFirmata.ino
@@ -609,6 +609,15 @@

 void setup()
 {
+  Serial1.begin(57600);
+
+  do {
+    while (Serial1.available() > 0) {
+      Serial1.read();
+    }
+    delay(1000);
+  } while (Serial1.available() > 0);
+
   Firmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION);

   Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
@@ -619,7 +628,6 @@
   Firmata.attach(START_SYSEX, sysexCallback);
   Firmata.attach(SYSTEM_RESET, systemResetCallback);

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


Signed-off-by: alitai <assaf.litai@gmail.com>

--- GS3_Transformer.ino
+++ GS3_Transformer.ino
@@ -1,8 +1,10 @@
-#define CURRENT_VERSION "V0.32"
+#define CURRENT_VERSION "V0.33"

 /*
-	"GS3 mod EP Transformer" by assafl
+	GS/3 "Chimera"
 	Electronic "Paddle" and profile replay control application for La Marzocco GS/3 AV
+
+	https://github.com/alitai/GS3-Transformer

 	This software and associated Arduino based hardware converts a GS/3 into a powerful pressure
 	profiling machine. Furthermore it can mimic (hence "Chimera") all sorts of machines, such as
@@ -54,6 +56,9 @@
 		Removed Motor Current
 		Condensed Dashboard view
 		Enlarged graph view
+
+	v0.33
+		Added support for Otto Controls HTWF Hall Effect control paddle with center indent aligned to FLB threshold (PI until center indent, main pull beyond it)

 */


- added another set of deglitching variables, so swTrigger can safely be re-armed - probably only useful for swTrigger, not required otherwise

--- GeheimTuer.ino
+++ GeheimTuer.ino
@@ -218,6 +218,7 @@
 unsigned long ledMillis = 0;

 bool swFront, swBack, swTrigger, motorDiagA, motorDiagB; // debounced inputs
+bool swFrontDeglitch, swBackDeglitch, swTriggerDeglitch, motorDiagADeglitch, motorDiagBDeglitch; // TODO: quick hack. document
 uint16_t swFrontDebounce, swBackDebounce, swTriggerDebounce, motorDiagADebounce, motorDiagBDebounce; // debounce shift registers

@@ -253,9 +254,9 @@
   LED.sync();

   // initialize debounce registers, assume steady state
-  swFrontDebounce = (swFront = digitalRead(switchFront)) * 0xFFFF;
-  swBackDebounce = (swBack = digitalRead(switchBack)) * 0xFFFF;
-  swTriggerDebounce = (swTrigger = digitalRead(switchTrigger)) * 0xFFFF;
+  swFrontDebounce = (swFront = swFrontDeglitch = digitalRead(switchFront)) * 0xFFFF;
+  swBackDebounce = (swBack = swBackDeglitch = digitalRead(switchBack)) * 0xFFFF;
+  swTriggerDebounce = (swTrigger = swTriggerDeglitch = digitalRead(switchTrigger)) * 0xFFFF;

   Serial.print(F("Door status: "));

@@ -278,8 +279,8 @@
     motorEnable();

     // diag pull-ups should have brought the lines up by now
-    motorDiagADebounce = (motorDiagA = digitalRead(motorDiagAPin)) * 0xFFFF;
-    motorDiagBDebounce = (motorDiagB = digitalRead(motorDiagBPin)) * 0xFFFF;
+    motorDiagADebounce = (motorDiagA = motorDiagADeglitch = digitalRead(motorDiagAPin)) * 0xFFFF;
+    motorDiagBDebounce = (motorDiagB = motorDiagBDeglitch = digitalRead(motorDiagBPin)) * 0xFFFF;

     if (doorState != doorBlocked) {
       motorBrake();
@@ -320,8 +321,8 @@

   // fast debounce driver error signals to filter short glitches
-  debounce(motorDiagAPin, &motorDiagA, &motorDiagADebounce);
-  debounce(motorDiagBPin, &motorDiagB, &motorDiagBDebounce);
+  debounce(motorDiagAPin, &motorDiagA, &motorDiagADeglitch, &motorDiagADebounce);
+  debounce(motorDiagBPin, &motorDiagB, &motorDiagBDeglitch, &motorDiagBDebounce);

   // The WAM is overheating!
   if ((motorDiagA == LOW || motorDiagB == LOW) && doorState != doorError) {
@@ -336,9 +337,9 @@
   if (debounceMillis >= debounceInterval) {
     debounceMillis = 0;

-    debounce(switchTrigger, &swTrigger, &swTriggerDebounce);
-    debounce(switchFront, &swFront, &swFrontDebounce);
-    debounce(switchBack, &swBack, &swBackDebounce);
+    debounce(switchTrigger, &swTrigger, &swTriggerDeglitch, &swTriggerDebounce);
+    debounce(switchFront, &swFront, &swFrontDeglitch, &swFrontDebounce);
+    debounce(switchBack, &swBack, &swBackDeglitch, &swBackDebounce);
   }

@@ -384,9 +385,7 @@
         } else {
           debug(currentMillis, F("Button switch triggered - opening door\r\n"));
           initDrive(backward, accelProfileHigh);
-// TODO: think again. re-arming swTrigger disables deglitching
-// any short HIGH pulse resets swTrigger to LOW
-swTrigger = HIGH;
+          swTrigger = HIGH; // re-arm swTrigger
         }
         setLeds2(white, black, 3, ledBackward);
         doorState = doorOpening;
@@ -400,7 +399,7 @@
         motorFree();
         setLeds1(red, ledSolid);
         doorState = doorBlocked;
-swTrigger = HIGH;
+        swTrigger = HIGH;
         break;
       }

@@ -428,7 +427,7 @@
         debug(currentMillis, F("Total ms: "));
         Serial.println(driveTotalMillis);
         openMillis = 0;
-        setLeds1(green, ledFade);
+        setLeds1(green, ledSolid);
         doorState = doorOpen;
         break;
       }
@@ -451,7 +450,7 @@
         debug(currentMillis, F("Button switch triggered - door blocked\r\n"));
         setLeds1(red, ledSolid);
         doorState = doorBlocked;
-swTrigger = HIGH;
+        swTrigger = HIGH;
         break;
       }

@@ -526,7 +525,7 @@
           doorState = doorOpening;
         }
         setLeds2(white, black, 3, ledMode);
-swTrigger = HIGH;
+        swTrigger = HIGH;
       }
       break;

@@ -635,20 +634,21 @@
 }

 //__attribute__((always_inline))
-inline void debounce(const int swPin, bool *const swVal, uint16_t *const swDebounce) {
+inline void debounce(const int swPin, bool *const swVal, bool *const swDeglitch, uint16_t *const swDebounce) {
   // similiar to what digitalRead() does, assumes that swPin has no timer output assigned
   // this still leads to several indirect lookups per sample. direct PINx access might be faster
-  debounce(portInputRegister(digitalPinToPort(swPin)), digitalPinToBitMask(swPin), swVal, swDebounce);
+  debounce(portInputRegister(digitalPinToPort(swPin)), digitalPinToBitMask(swPin), swVal, swDeglitch, swDebounce);
 }

 //__attribute__((always_inline))
-inline void debounce(const volatile uint8_t *const port, const uint8_t pinMask, bool *const swVal, uint16_t *const swDebounce) {
+inline void debounce(const volatile uint8_t *const port, const uint8_t pinMask, bool *const swVal, bool *const swDeglitch, uint16_t *const swDebounce) {
   // NB: interference near multiples of 1/interval could cause spurious edges
   *swDebounce = ((*swDebounce << 1) | ((*port & pinMask)?(1):(0))) & 0x1FFF; // 13-bit debounce
-  if (*swDebounce == 0x1000) { // edge HIGH -> 12xLOW
-    *swVal = LOW;
-  } else if (*swDebounce == 0x0FFF) { // edge LOW -> 12xHIGH
-    *swVal = HIGH;
+
+  if (*swDebounce == 0x1000 && *swDeglitch == HIGH) { // edge HIGH -> 12xLOW
+    *swVal = *swDeglitch = LOW;
+  } else if (*swDebounce == 0x0FFF && *swDeglitch == LOW) { // edge LOW -> 12xHIGH
+    *swVal = *swDeglitch = HIGH;
   }
 }


Changed long to int

Changed long to int

Also removed redundant 'signed' keywords

--- proj/SpeedLight/SpeedLight.ino
+++ proj/SpeedLight/SpeedLight.ino
@@ -10,11 +10,11 @@
 #define errorThreshold 20
 #define cpr 200 // Cycles per revolution of encoder disk

-long targetSpeed = 40; // Target angulary velocity / setpoint in degrees per second
+int targetSpeed = 40; // Target angulary velocity / setpoint in degrees per second

-volatile signed long encoder0Pos = 0; // Delta of encoder position since last loop iteration
-signed long oldTime = 0; // Time in ms from last loop iteration
-signed long dps = 0; // Angular velocity in degrees per second
+volatile long encoder0Pos = 0; // Delta of encoder position since last loop iteration
+long oldTime = 0; // Time in ms from last loop iteration
+int dps = 0; // Angular velocity in degrees per second

 void setup() {
   pinMode(encoder0PinA, INPUT);


rewriting instructions in comments

rewriting instructions in comments

--- arduino/WiFi-Car_WEMOS-aRest/WiFi-Car_WEMOS-aRest.ino
+++ arduino/WiFi-Car_WEMOS-aRest/WiFi-Car_WEMOS-aRest.ino
@@ -1,25 +1,31 @@
-//                         2nd Thess Code Festival Workshop
-//
-// author: Paschaleris Triantafyllos
-//         https://paschaleris.gr
+//                         2nd Thess Code Festival Workshop     ~     Saturday 14th October
+//
+// author:      Paschaleris Triantafyllos
+//              https://paschaleris.gr
+//
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // From the folder "files needed\Arduino libraries" of this repository copy the folders:
 //    "Adafruit_SSD1306_WEMOS"
 //    "Adafruit_GFX_Library"
 //
-// paste them inside:  C:\Program Files (x86)\Arduino\libraries\
+// paste them inside:  "C:\Program Files (x86)\Arduino\libraries\"
 //
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Link to add additional boards (File > Preferences): http://arduino.esp8266.com/stable/package_esp8266com_index.json
-// Then open Boards Manager from Tools > Board > Board Manager and search and install "esp8266".
-//                                       then search and install "aREST"
-//
-// Before Upload CHECK in tools for the CORRECT PORT and:
+// Go to File > Preferences and in the field Additional Boards Manager URLs paste this link: http://arduino.esp8266.com/stable/package_esp8266com_index.json
+// Then go to Tools > Board > Board Manager and search and install "esp8266" (it may take a few minutes)
+//                                         then search and install "aREST"
+//
+//        !!! IMPORTANT !!!
+// Before Upload to Wemos CHECK in Tools for the CORRECT PORT (usually "COM 3" or 4) and verify your settings:
 //   Board: "WeMos D1 R2 & mini"
 //   CPU Frequency: "80MHz"
 //   Flash Size: "4M (3M SPIFFS)"
 //   Upload Speed: "921600"
+//
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//         Now, let's do some magic!
+//  ⊂(◉‿◉)つ
+//

 // Import required libraries
 #include "ESP8266WiFi.h"


change temp sensor to use the more stable dsb18b20

--- short-circuit-limiter/short-circuit-limiter.ino
+++ short-circuit-limiter/short-circuit-limiter.ino
@@ -1,4 +1,6 @@
 #include <U8g2lib.h>
+#include <OneWire.h>
+#include <DallasTemperature.h>
 #include "CTSensor.h"

 #define CURRENT_ENABLE_THRESHOLD 0.2
@@ -15,7 +17,7 @@

 #define PIN_LED 26
 #define PIN_CT A0
-#define PIN_TEMP A11
+#define PIN_TEMP 2
 #define PIN_BUZZER 4

 #define PIN_BUTTON_UP 25
@@ -51,6 +53,13 @@
 STATE currentState = STATE_MCB_TRIPPED;
 STATE nextState = STATE_WINDOW_BEFORE;

+// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
+OneWire oneWire(PIN_TEMP);
+
+// Pass our oneWire reference to Dallas Temperature.
+DallasTemperature dallasTemp(&oneWire);
+
+
 U8G2_UC1701_MINI12864_F_4W_SW_SPI u8g2(U8G2_R2, 21, 20, 19, 22);
 CTSensor clamp(PIN_CT, CT_CALIBRATION_VALUE);

@@ -67,7 +76,6 @@

   pinMode(PIN_RELAY_LIMITER, OUTPUT);
   pinMode(PIN_RELAY_MCB, OUTPUT);
-  pinMode(PIN_TEMP, INPUT);

   pinMode(PIN_BUTTON_UP, INPUT);
   pinMode(PIN_BUTTON_ENTER, INPUT);
@@ -78,6 +86,7 @@
   changeMCBRelayState(false);

   u8g2.begin();
+  dallasTemp.begin();

   unsigned long initialTime = millis();
   unsigned long timeElapsedSinceStart;
@@ -504,26 +513,10 @@

 //Obtained from https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor
 float getTemperature(){
-
-  long total = 0;
-
-  //First value is usually off
-  analogRead(PIN_TEMP);
-
-  for(int i = 0; i < TEMP_READS_SET; i++){
-    total += analogRead(PIN_TEMP);
-  }
-
-  int reading = total / TEMP_READS_SET;
-
-  // converting that reading to voltage, for 3.3v arduino use 3.3
-  float voltage = reading * 5.0;
-  voltage /= 1024.0;
-
-  // now print out the temperature
-  float temperatureC = (voltage - 0.5) * 100 ;
-
-  return temperatureC;
+  //There is only one sensor on the bus so just use the first one
+  dallasTemp.requestTemperaturesByIndex(0);
+  float temperature = dallasTemp.getTempCByIndex(0);
+  return temperature;
 }

 bool isAtLeastOneButtonPressed(){


Minor fix to prevent UI hang caused by new Arduino Tones library

--- examples/ReflowWizard/Tones.ino
+++ examples/ReflowWizard/Tones.ino
@@ -99,7 +99,7 @@
 const int tuneStartup[] PROGMEM = {NOTE_C5,8,NOTE_G4,8,-1};
 const int tuneButtonPressed[] PROGMEM = {NOTE_F5,500,-1};
 const int tuneInvalidPress[] PROGMEM = {NOTE_B2,10,-1};
-const int tuneReflowDone[] PROGMEM = {NOTE_C5,4,NOTE_G4,8,NOTE_G4,8, NOTE_A4,4,NOTE_G4,4,0,4,NOTE_B4,4,NOTE_C5,4,-1};
+const int tuneReflowDone[] PROGMEM = {NOTE_C5,4,NOTE_G4,8,NOTE_G4,8, NOTE_A4,4,NOTE_G4,4,1,4,NOTE_B4,4,NOTE_C5,4,-1};
 const int tuneRemoveBoards[] PROGMEM = {NOTE_C5,4,NOTE_B4,4,NOTE_E4,2,-1};
 const int tuneScreenshotBusy[] PROGMEM = {NOTE_C8,1000,-1};
 const int tuneScreenshotDone[] PROGMEM = {NOTE_D2,10,NOTE_D4,10,NOTE_D6,6,-1};
@@ -124,4 +124,4 @@
   }
   noTone(BUZZER_PIN);
 }
-
+


Added all basic commands including movement testing

--- rover/rover.ino
+++ rover/rover.ino
@@ -54,25 +54,39 @@
   if (adk.isReady()) {
       adk.read(&bytesRead, BUFFSIZE, buffer);
     if (bytesRead > 0) {
-      jeepCommandInterpreter(buffer[0], buffer[1]);
+      jeepCommandInterpreter(buffer[0] - 48, buffer[1] - 48);
     }
   }
 }

-void jeepCommandInterpreter(uint8_t command, uint8_t speed) {
-  switch(command) {
+void jeepCommandInterpreter(uint8_t commandMovement, uint8_t commandSpeed) {
+  int vPower = speedToPower(commandSpeed);
+  Serial.print("Required power: ");Serial.println(vPower);
+
+  switch(commandMovement) {
     case 0:
-      goForward(speed);
+      Serial.println("Received command: 0 -> move forward");
+      goForward(vPower);
       break;
     case 1:
-      goBackward(speed);
+      Serial.println("Received command: 1 -> move backward");
+      goBackward(vPower);
       break;
     case 2:
-      goLeft(speed);
+      Serial.println("Received command: 2 -> turn left");
+      turnLeft(vPower);
       break;
     case 3:
-      goRight(speed);
-      break;
+      Serial.println("Received command: 3 -> turn right");
+      turnRight(vPower);
+      break;
+    case 4:
+      Serial.println("Received command: 4 -> turn back");
+      turnBack(vPower);
+      break;
+    case 5:
+      Serial.println("Received command: 5 -> testing all movements");
+      testAllMovements(vPower);
     default:
       Serial.println("Command not available");
       break;
@@ -80,25 +94,51 @@
 }

 // Main movement command
-void goForward(uint8_t speed) {
-}
-
-void goBackward(uint8_t speed) {
-  turnBack();
-  goForward(speed);
-}
-
-void goLeft(uint8_t speed) {
-  turnLeft();
-  goForward(speed);
-}
-
-void goRight(uint8_t speed) {
-  turnRight();
-  goForward(speed);
-}
-
-// Helper movement
+void goForward(int vPower) {
+  motor.setM1Speed(vPower);
+  motor.setM2Speed(vPower);
+
+  delay(1000);
+  stopEngine();
+}
+void goBackward(int vPower) {
+  motor.setM1Speed(-vPower);
+  motor.setM2Speed(-vPower);
+
+  delay(1000);
+  stopEngine();
+}
+
+void turnLeft(int vPower) {
+  motor.setM1Speed(-vPower);
+  motor.setM2Speed(vPower);
+
+  delay(500);
+  stopEngine();
+}
+
+void turnRight(int vPower) {
+  motor.setM1Speed(vPower);
+  motor.setM2Speed(-vPower);
+
+  delay(500);
+  stopEngine();
+}
+
+void turnBack(int vPower) {
+  motor.setM1Speed(vPower);
+  motor.setM2Speed(-vPower);
+
+  delay(1000);
+  stopEngine();
+}
+
+void stopEngine() {
+  motor.setM1Speed(0);
+  motor.setM2Speed(0);
+}
+
+// Movement helpers
 int speedToPower(uint8_t speed) {
   int v;
   switch(speed) {
@@ -118,20 +158,6 @@

   // Return a safe motor power
   return motorProtection(v);
-}
-
-void turnLeft() {
-}
-
-void turnRight() {
-}
-
-void turnBack() {
-}
-
-void stopEngine() {
-  motor.setM1Speed(0);
-  motor.setM2Speed(0);
 }

 // Emergency checks


COH-71: WIP

COH-71: WIP

--- COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
+++ COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
@@ -1280,6 +1280,31 @@
       }
 #endif

+
+#if defined(ENABLE_FHT8VSIMPLE)
+  // Try for double TX for more robust conversation with valve?
+  const bool doubleTXForFTH8V = false;
+  // FHT8V is highest priority and runs first.
+  // ---------- HALF SECOND #0 -----------
+  bool useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_First(doubleTXForFTH8V); // Time for extra TX before UI.
+  if(useExtraFHT8VTXSlots)
+    {
+    // Time for extra TX before other actions, but don't bother if minimising power in frost mode.
+    // ---------- HALF SECOND #1 -----------
+    useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_Next(doubleTXForFTH8V);
+    }
+  if(useExtraFHT8VTXSlots)
+    {
+    // ---------- HALF SECOND #2 -----------
+    useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_Next(doubleTXForFTH8V);
+    }
+  if(useExtraFHT8VTXSlots)
+    {
+    // ---------- HALF SECOND #3 -----------
+    useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_Next(doubleTXForFTH8V);
+    }
+#endif
+
   // Command-Line Interface (CLI) polling, if still active.
   if(isCLIActive())
     {
@@ -1303,10 +1328,5 @@
 #endif
     TIME_LSD = OTV0P2BASE::getSecondsLT(); // Prepare to sleep until start of next full minor cycle.
     }
-
-// FIXME FIXME FIXME
-// Put back all FHT8V 0.5s interval stuff!
-
-
-  }
-
+  }
+


delete needless ino file

delete needless ino file

--- examples/indentedCodeESPArd.ino
+++ examples/indentedCodeESPArd.ino
@@ -1,63 +0,0 @@
-// Created by Rıza Arda Kırmızıoğlu and Berk Özdilek.
-/*
-This is an example of IvenCloudESP library in which you can activate your device,
-create data objects, send data to Iven Product Cloud and handle tasks.
-For further explanations about functions in library, hardware setup and REQUIRED manual
-settings of ESP8266 check blog: http://blog.iven.io
-*/
-
-#include <IvenCloudESP.h>
-
-// Analog read pin for LDR voltage value.
-#define lightPin 0
-
-// Software serial digital pins for Arduino to communicate with ESP8266
-#define arduino_rx_esp_tx 2
-#define arduino_tx_esp_rx 3
-
-// Sensor voltage value (between 0-1023 for 5v and 0-675 for 3.3v)
-int sensorValue = 0;
-
-//
-bool available;
-bool isActive = false;
-
-IvenCloudESP client(arduino_rx_esp_tx, arduino_tx_esp_rx, 9600, true);
-
-void setup() {
-  // put your setup code here, to run once:
-  Serial.begin(9600);
-  pinMode(lightPin, INPUT);
-}
-
-void loop() {
-  // put your main code here, to run repeatedly:
-  if (!isActive) {
-
-  	// Activates device, has API-KEY and returns IvenResponse object.
-    IvenResponse i = client.activateDevice("secret_key", "device_uid");
-
-    Serial.println(i.status);
-    if (i.status == 200)
-      isActive = true;
-      Serial.println("api-key is taken");
-  } else {
-  	// Creates IvenData object
-    IvenData data;
-
-    sensorValue = analogRead(lightPin);
-    if (sensorValue < 400)
-      available = true;
-    else available = false;
-
-    // Creates json object for the body of the HTTP POST request.
-    data.add("available", available);
-
-    // Posts data to Iven Product Cloud
-    IvenResponse p = client.sendData(data);
-
-    Serial.println(p.status);
-    Serial.println(p.ivenCode);
-    Serial.println(p.task);
-  }
-}


cleaned up wifi_prin_IP sketch, ready to use as template

--- sketch_wifi_print_IP/sketch_wifi_print_IP.ino
+++ sketch_wifi_print_IP/sketch_wifi_print_IP.ino
@@ -31,7 +31,7 @@
   if (wifi.joinAP(WIFI_SSID, WIFI_PASSWORD)) {
     SerialUSB.print("Join AP success\r\n");
     SerialUSB.print("IP: ");
-    SerialUSB.println(wifi.getLocalIP().c_str());
+    SerialUSB.println(getIP(true)); // short version of output, cached
   } else {
     SerialUSB.println("Join AP error");
   }
@@ -45,8 +45,34 @@
   SerialUSB.println("--");
   SerialUSB.println(counter);
   SerialUSB.print("IP: ");
-  SerialUSB.println(wifi.getLocalIP().c_str());
+  SerialUSB.println(getIP(true)); // short version of output, cached

   delay(5000);
 }

+/* get local IP address. The wifi library gives a strig result like this:
+ *
+ *  +CIFSR:APIP,"xxx.xxx.xxx.xxx"
+ *  +CIFSR:APMAC,"xx:xx:xx:xx:xx:xx"
+ *  +CIFSR:STAIP,"xxx.xxx.xxx.xxx"
+ *  +CIFSR:STAMAC,"xx:xx:xx:xx:xx:xx"
+ *
+ * we need to cut out the value from the STAIP line (Station IP)
+ *
+ */
+
+String getIP(bool cache) {
+  static String ip = "";
+  if (ip.length() && cache) {
+     return ip;
+  }
+  String pattern = "STAIP,\"";
+  String answer = wifi.getLocalIP().c_str();
+  int starti = answer.indexOf(pattern) + pattern.length();
+  ip = answer.substring(starti, answer.length() -1);
+  int stopi = ip.indexOf("\"");
+  ip = ip.substring(0,stopi);
+  return ip;
+}
+
+


Affinage des affichages des résultats. Quelques details a terminer.

--- calibrateur.ino
+++ calibrateur.ino
@@ -49,9 +49,9 @@
 #define TEMPOSLEEP 1000
 //en ms le temps d'etre sur que le servo ait bougé
 //d'un increment quand on fait les mesure à la roue codeuse
-#define PINVOIEB 3 //la pin surlaquelle est branché la voie B de la roue codeuse
+#define PINVOIEB 3 //la pin sur laquelle est branché la voie B de la roue codeuse
 #define ERREURCOMPTAGE 6 //la tolérance de comptage avant que l'on estime que le servo est arrivé au bout
-#define NBRCYCLE_AR 10 //nbre de cycle d'aller et retour pour la fin des mesure de caractérisation et nbr de cycle pour la mesure des PWMIN et PWMMAX
+#define NBRCYCLE_AR 4 //nbre de cycle d'aller et retour pour la fin des mesure de caractérisation et nbr de cycle pour la mesure des PWMIN et PWMMAX
 #define TEMPO_STAT 40 // tempo pour laisser le servo avancer lors des mesures
                        // statistique à la fin de la calibration ATTENTION 100ms semble etre trop court!!!!
 #define DEP_MINI_STAT 5  //correspond au déplacement minimum en nombre d'impulsion que doit faire le servo pour
@@ -443,17 +443,17 @@
                             Serial.println(tempsMesureVitesse);
                             // Mesure de min vers max
                             leServo.setObjectif(leServo.getMax());
-                            sleep(TEMPOSLEEP);
+                            //sleep(TEMPOSLEEP); inutile maintenant car on s'arrette quand compteur suffisament incrémenté'
                             Serial.print("cmpt="); Serial.println(compteur);
                             while (abs(compteur)<abs(amplitude)-DEP_MINI_STAT)
                                 {
-                                    Serial.print("yop");
+                                   /*  Serial.print("yop");
                                     Serial.print(" cmpt=");
-                                    Serial.println(compteur);
+                                    Serial.println(compteur); */
                                     sleep(TEMPO_STAT);
                                 }

-                            resultatTempsMax[i]=millis()-tempsMesureVitesse-\
+                            resultatTempsMax[i]=millis()-tempsMesureVitesse;//-\
                                                     TEMPO_STAT;
                             Serial.print(F("Cycle ")); Serial.print(i);
                             Serial.print(F(" temps= ")); Serial.println(resultatTempsMax[i]);
@@ -465,19 +465,19 @@
                              Serial.print("tempsMesureVitesse=");
                             Serial.println(tempsMesureVitesse);
                             leServo.setObjectif(leServo.getMin());
-                            sleep(TEMPOSLEEP);
+                            //sleep(TEMPOSLEEP);
                             Serial.print("cmpt="); Serial.println(compteur);
                             while (abs(compteur)<abs(amplitude)-DEP_MINI_STAT)
                                 {

-                                    Serial.print("yup ");
+                                    /*Serial.print("yup ");
                                     Serial.print("cmpt=");
-                                    Serial.println(compteur);
+                                    Serial.println(compteur);*/
                                     sleep(TEMPO_STAT);
                                 }

-                            resultatTempsMin[i]=millis()-tempsMesureVitesse-TEMPO_STAT;
+                            resultatTempsMin[i]=millis()-tempsMesureVitesse;//-TEMPO_STAT;
                             Serial.print(F("Cycle "));
                             Serial.print(i);
                             Serial.print(F(" temps= "));
@@ -508,21 +508,19 @@

                 case DISPRESULT:

-
-                    Serial.print(F(" Dans le sens croissant pwm "));
-                    //Serial.print(moyenne(NBRCYCLE_AR,resultatAmplitudeMax));
-                    //Serial.print(F(" impulsions (Ecart type : "));
-                    //Serial.print(ecartType(NBRCYCLE_AR,resultatAmplitudeMax));
-                    Serial.print(F(") l'amplitude est atteintes en un temps moyen de : "));
+                    leServo.setObjectif(leServo.getMilieu());
+                    Serial.print(F(" Dans le sens croissant pwm, "));
+
+                    Serial.print(F("l'amplitude retenue est atteintes en un temps moyen de : "));
                     Serial.print(moyenne(NBRCYCLE_AR,resultatTempsMax));
                     Serial.print(F(" ms (ecart type : "));
                     Serial.print(ecartType(NBRCYCLE_AR,resultatTempsMax));
                     Serial.println(F(" ms)"));
-                    Serial.print(F(" Dans le sens decroissant pwm  : "));
+                    Serial.print(F(" Dans le sens decroissant pwm, "));
                     //Serial.print(moyenne(NBRCYCLE_AR,resultatAmplitude));
                     //Serial.print(F("impulsions (Ecart type : "));
                     //Serial.print(ecartType(NBRCYCLE_AR,resultatAmplitude));
-                    Serial.print(F(") l'amplitude est atteintes en un temps moyen de : "));
+                    Serial.print(F("l'amplitude retenue est atteintes en un temps moyen de : "));
                     Serial.print(moyenne(NBRCYCLE_AR,resultatTempsMin));
                     Serial.print(F(" ms (ecart type : "));
                     Serial.print(ecartType(NBRCYCLE_AR,resultatTempsMin));


Adds OLED output to indicate making of a new batlog

--- batlog.ino
+++ batlog.ino
@@ -13,6 +13,7 @@
   BatLog.eeaddr = 1;

   if (EEPROM[0] != cookie) {
+    oled.drawString("Making new batlog", 0, 0, FONT_SIZE, COLOR_RED);
     EEPROM[0] = cookie;
     // filled the log with 0xFF so we know later when the log stops.
     for (uint16_t addr = 1; addr < 1024; ++addr) {


Read whole string in Arduino before start processing

--- AndroidThings/arduino/arduino.ino
+++ AndroidThings/arduino/arduino.ino
@@ -19,6 +19,7 @@
 uint32_t colorOff = pixels.Color(0,0,0);

 String readString;
+String wholeString;
 char c;
 boolean matrix[LEDS_COUNT];
 int r = 0;
@@ -34,57 +35,59 @@
 void loop() {
   while (Serial.available()) {
     delay(1);
-    c = Serial.read();
+    wholeString = Serial.readString();
+    parseString(wholeString);
+  }
+}
+
+void parseString(String input) {
+  for(int i=0; i<input.length(); i++){
+    c = input[i];
     if (c == LED_SEPARATOR) {
-      break;
+      if (readString.length() > 0) {
+        int ledIndex = stringToInt(readString);
+        if (ledIndex < LEDS_COUNT) {
+          matrix[ledIndex] = true;
+        }
+      }
+      readString="";
+      continue;
     }
-    if (c == START) {
+    else if (c == START) {
       reset();
-      break;
+      continue;
     }
-    if (c == RED) {
+    else if (c == RED) {
       if (readString.length() > 0) {
         r = stringToInt(readString);
         readString="";
       }
-      break;
+      continue;
     }
-    if (c == GREEN) {
+    else if (c == GREEN) {
       if (readString.length() > 0) {
         g = stringToInt(readString);
         readString="";
       }
-      break;
+      continue;
     }
-    if (c == BLUE) {
+    else if (c == BLUE) {
       if (readString.length() > 0) {
         b = stringToInt(readString);
         readString="";
       }
+      continue;
+    }
+    else if (c == END) {
+      // logMatrix(); //Useful for debugging
+      colorOn = pixels.Color(r, g, b);
+      updateLEDs();
+      pixels.show();
+      c = ' ';
       break;
     }
-    if (c == END) {
-      break;
-    }
-    readString += c;
+    readString += c;
   }
-
-  if (readString.length() > 0) {
-    int ledIndex = stringToInt(readString);
-    if (ledIndex < LEDS_COUNT) {
-      matrix[ledIndex] = true;
-    }
-
-    readString="";
-  }
-
-  if (c == END) {
-    // logMatrix(); //Useful for debugging
-    colorOn = pixels.Color(r, g, b);
-    updateLEDs();
-    pixels.show();
-    c = ' ';
-  }
 }

 void reset() {


Update _firmware2.ino

Update _firmware2.ino

--- Arduino/_firmware2/_firmware2.ino
+++ Arduino/_firmware2/_firmware2.ino
@@ -133,7 +133,7 @@
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //                                                5. LEVEL SENSOR

-int levelSensorPin = A4;
+int levelSensorPin = A3;

 //Insert Calibration Data Here: Level = AX + B format (rounded to the nearest integer N)
 //X is the water depth in cm


testing: wait till we have current

testing: wait till we have current

Signed-off-by: Robert Nelson <d6c41255011d14bfa93d8562b946ca186cfa0c7b@gmail.com>

--- BatteryCharger/BatteryCharger.ino
+++ BatteryCharger/BatteryCharger.ino
@@ -113,9 +113,19 @@
 		digitalWrite(XBee_wake, HIGH);

 		//Turn on
+//Testing
+//		if ( relay_mode == RELAY_A1_ON ) {
+//			if ( busvoltage_A > 13.1 ) {
+//				pinMode(A0, OUTPUT);
+//				digitalWrite(A0, HIGH);
+//				delay(10);
+//				digitalWrite(A0, LOW);
+//				relay_mode = RELAY_A0_ON;
+//			}
+//		}
+		//Turn on
 		if ( relay_mode == RELAY_A1_ON ) {
-//			if ( busvoltage_A > 13.1 ) {
-			if ( busvoltage_A > 12.6 ) {
+			if (( busvoltage_A > 12.6 ) && ( current_mA_B > 400 )) {
 				pinMode(A0, OUTPUT);
 				digitalWrite(A0, HIGH);
 				delay(10);
@@ -123,17 +133,6 @@
 				relay_mode = RELAY_A0_ON;
 			}
 		}
-		//Turn on
-//testing
-//		if ( relay_mode == RELAY_A1_ON ) {
-//			if (( busvoltage_A > 12.6 ) && ( current_mA_B > 400 )) {
-//				pinMode(A0, OUTPUT);
-//				digitalWrite(A0, HIGH);
-//				delay(10);
-//				digitalWrite(A0, LOW);
-//				relay_mode = RELAY_A0_ON;
-//			}
-//		}

 		//Turn off
 		if ( relay_mode == RELAY_A0_ON ) {


refine naming and comments

refine naming and comments

--- glass/glass.ino
+++ glass/glass.ino
@@ -41,9 +41,10 @@
 boolean isWaitingReply;
 char XBeeReturnIDs[20];
 int XBeeReturnCount;
-boolean ir_response_mode = true;
+boolean ir_cue_mode = true;
 unsigned long ir_time;
 unsigned int ir_cycle = 300;
+unsigned int

 void setup()
 {
@@ -88,8 +89,8 @@
     }
   }

-  if(ir_response_mode){
-    //constantly sending out ir broadcast
+  if(ir_cue_mode){
+    //constantly sending out ir broadcast as visual cue
     if(millis() - ir_time > ir_cycle) {
       // -1 indicates for broacast which is different than normal session id
       // DEBUG_PRINTLN("broadcasting IR");


update example

update example

--- examples/arduino/OscEtherUno/OscEtherUno.ino
+++ examples/arduino/OscEtherUno/OscEtherUno.ino
@@ -36,7 +36,7 @@
 String s;

 // required to use manual packet parsing
-OscEtherServer server;
+OscEtherServer server(recv_port);
 OscEtherClient client;
 // OscEtherClient client(1234);  // you can set the local port of client manually (default: 9)

@@ -46,7 +46,6 @@

     // Ethernet stuff
     Ethernet.begin(mac, ip);
-    server.begin(recv_port);

     // Ethernet with useful options
     // Ethernet.begin(mac, ip, dns, gateway, subnet); // full


Adding winch and conveyor unit tests.

Adding winch and conveyor unit tests.

--- src/SabertoothDriverROS/SabertoothDriverROS.ino
+++ src/SabertoothDriverROS/SabertoothDriverROS.ino
@@ -604,7 +604,8 @@
     delayMicroseconds(15000);
   }

-  // loop through and test all wheels
+  // loop through and test all drive motors:
+  // 1.5s clockwise, then 1.5s counterclockwise.
   for(int i = 0; i < 6; i++){
     // clockwise
     driveClockwise(i, 20);
@@ -625,6 +626,8 @@
     }
   }

+  // Test all articulation motors:
+  // 1.5s clockwise, then 1.5s counterclockwise.
   for(int i = 6; i < 12; ++i){
     // clockwise
     driveClockwise(i, 30);
@@ -644,6 +647,39 @@
       delayMicroseconds(15000);
     }
   }
+  // Test the winch.
+  unitTestWinch();
+  // Test the conveyor.
+  unitTestConveyor();
+}
+
+void unitTestConveyor()
+{
+  // Test the conveyor:
+  // 2s "dumping" / forwards (clockwise), 2s "collecting" / backwards (counterclockwise).
+
+  driveClockwise(LEFT_CONVEYOR_MOTOR_ID, CONVEYOR_SPEED);
+  driveClockwise(RIGHT_CONVEYOR_MOTOR_ID, CONVEYOR_SPEED);
+  delaySeconds(2);
+  driveCounterclockwise(LEFT_CONVEYOR_MOTOR_ID, CONVEYOR_SPEED);
+  driveCounterclockwise(RIGHT_CONVEYOR_MOTOR_ID, CONVEYOR_SPEED);
+  delaySeconds(2);
+  driveCounterclockwise(LEFT_CONVEYOR_MOTOR_ID, 0);
+  driveCounterclockwise(RIGHT_CONVEYOR_MOTOR_ID, 0);
+  delaySeconds(2);
+
+}
+
+void unitTestWinch()
+{
+  // Test the winch:
+  // 2s up (clockwise), 2s down (counterclockwise).
+  driveClockwise(WINCH_MOTOR_ID, WINCH_SPEED);
+  delaySeconds(2);
+  driveCounterclockwise(WINCH_MOTOR_ID, WINCH_SPEED);
+  delaySeconds(2);
+  driveCounterclockwise(WINCH_MOTOR_ID, 0);
+  delaySeconds(2);
 }

 void unitTest2(){


adding temtative alarm implementation

adding temtative alarm implementation

--- src/elm_clk.ino
+++ src/elm_clk.ino
@@ -50,9 +50,9 @@
 #define SHOW_ALARM_MODE 4
 #define ERROR_MODE      5

-#define SHOW_TIME_DURATION 7000
-#define SHOW_TEMP_DURATION 3000
-
+#define SHOW_TIME_DURATION    7000
+#define SHOW_TEMP_DURATION    3000
+#define ALARM_CLEAR_DURATION 61000
 // ---------------------- //
 //  Common definitions
 // ---------------------- //
@@ -65,12 +65,15 @@
 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 lastAlarmCleared  = 0;
+

 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);
@@ -123,6 +126,7 @@

 void setRtcAlarm(byte hour, byte minute)
 {
+	alarmTriggeredToday = 0;
 	tmElements_t hourSetting;
 	hourSetting.Hour = hour;
 	RTC.setAlarm(ALARM_0, makeTime(hourSetting));
@@ -299,7 +303,7 @@
 		activeDigit+=2;
 		activeDigit %= N;
 		display.enableBlink(activeDigit);
-	}
+	}
 }

 void singleClickA()
@@ -310,6 +314,13 @@
 		activeDigit++;
 		activeDigit %= N;
 		display.enableBlink(activeDigit);
+	} else if (fsmState == SHOW_ALARM_MODE)
+	{
+		lastAlarmCleared = millis();
+		oldFsmState = SHOW_ALARM_MODE;
+		fsmState    = SHOW_TIME_MODE;
+		Serial.print("ALARM CLEARED :");
+		digitalClockDisplay();
 	}
 }

@@ -368,9 +379,13 @@
 		digitValues[activeDigit]++;
 		digitValues[activeDigit] %= maxValueForDigit(activeDigit);
 		display.writeDigit(activeDigit, digitValues[activeDigit]);
-	} else if (fsmState == SHOW_TIME_MODE)
-	{
-		playSong();
+	} else if (fsmState == SHOW_ALARM_MODE)
+	{
+		lastAlarmCleared = millis();
+		oldFsmState = SHOW_ALARM_MODE;
+		fsmState    = SHOW_TIME_MODE;
+		Serial.print("ALARM CLEARED :");
+		digitalClockDisplay();
 	}
 }

@@ -429,18 +444,18 @@
 	} else
 	{
 		Serial.println("RTC has set the system time");
-		fsmState = ERROR_MODE;
+		//fsmState = ERROR_MODE;
 	}

 	// default alarm settings, 08:30, disabled
 	pinMode(ALARM_PIN, INPUT_PULLUP);
-	setRtcAlarm(8,30);
-	disableRtcAlarm();
+	//setRtcAlarm(8,30);
+	//disableRtcAlarm();
 }

 void loop()
 {
-	// If not in error state, increment button ticks
+	// If error detected, disable buttons.
 	if (fsmState != ERROR_MODE)
 	{
 		buttonA.tick();
@@ -449,10 +464,13 @@

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

 	switch (fsmState)
 	{
@@ -510,6 +528,11 @@

 			oldFsmState = fsmState;

+			if (alarmTriggeredToday && ((millis() - lastAlarmCleared) > ALARM_CLEAR_DURATION))
+			{
+				alarmTriggeredToday = 0;
+			}
+
 			if ((millis() - lastClockRead) > updateInterval)
 			{
 				updateTime();
@@ -549,11 +572,8 @@
 			break;

 		case SHOW_ALARM_MODE:
-			if (RTC.alarm(ALARM_0) | (RTC.alarm(ALARM_1)))
-				Serial.println("Alarm!");
-			else
-				oldFsmState = fsmState;
-				fsmState = SHOW_TIME_MODE;
+			Serial.print("ALARM TRIGGERED :");
+			digitalClockDisplay();
 			break;

 		case ERROR_MODE:


modified the nono file address

modified the nono file address

--- tictactoe/tictactoe.ino
+++ tictactoe/tictactoe.ino
@@ -21,7 +21,7 @@
 #define YOU_WIN 0x2 //The Player wins :-)
 #define YOU_LOSE 0x3 //The Rival wins :-(
 #define VICTORY_LOOP 0x4 //Victory loop!!!
-#define NO_NO 0x5 //Illegal move
+#define NO_NO 0x7 //Illegal move
 // Image addresses
 #define GAME_OVER 0x0049
 #define WINNER 0x00DB


Fix misleading comment.

Fix misleading comment.

--- Arduino/LaserHarpMultiplex/LaserHarpMultiplex.ino
+++ Arduino/LaserHarpMultiplex/LaserHarpMultiplex.ino
@@ -1,22 +1,5 @@
 /*
-  Analog input, analog output, serial output
-
- Reads an analog input pin, maps the result to a range from 0 to 255
- and uses the result to set the pulsewidth modulation (PWM) of an output pin.
- Also prints the results to the serial monitor.
-
- The circuit:
- * potentiometer connected to analog pin 0.
-   Center pin of the potentiometer goes to the analog pin.
-   side pins of the potentiometer go to +5V and ground
- * LED connected from digital pin 9 to ground
-
- created 29 Dec. 2008
- modified 9 Apr 2012
- by Tom Igoe
-
- This example code is in the public domain.
-
+  Analog input, serial output
  */

 // These constants won't change.  They're used to give names


wait is now handled in software in order to update display

--- uArm.ino
+++ uArm.ino
@@ -38,6 +38,7 @@

 typedef struct servoMove {
 	void (*moveServoFuncPtr)(uint8_t, uint8_t, bool, bool);
+	char servoShortName;
 	uint8_t pos;
 	uint8_t servoSpeed;
 } servoMoves_t;
@@ -74,6 +75,15 @@
 	extern int __heap_start, *__brkval;
 	int v;
 	return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
+}
+
+void servoWidgetUpdate(void) {
+	widgetL->setValue(servoL.read());
+	widgetR->setValue(servoR.read());
+	widgetRot->setValue(servoRot.read());
+	widgetHRot->setValue(servoHRot.read());
+	widgetH->setValue(servoH.read());
+	uView.display();
 }

 // setup functions
@@ -183,18 +193,23 @@
 	switch(servoShortName) {
 		case 'L': case 'l':
 			moveServoFuncPtr = &moveServoL;
+			servoShortName = 'L';
 			break;
 		case 'R': case 'r':
 			moveServoFuncPtr = &moveServoR;
+			servoShortName = 'R';
 			break;
 		case 'O': case 'o':
 			moveServoFuncPtr = &moveServoRot;
+			servoShortName = 'O';
 			break;
 		case 'T': case 't':
 			moveServoFuncPtr = &moveServoHRot;
+			servoShortName = 'T';
 			break;
 		case 'H': case 'h':
 			moveServoFuncPtr = &moveServoH;
+			servoShortName = 'H';
 			break;
 	};

@@ -204,6 +219,7 @@
 		if (*buf != endptr && pos >= 0 && pos <= 180) {
 			for (; **buf == ' ' || **buf == '\t'; (*buf)++);
 			servoMoves[servoMoveCount].moveServoFuncPtr = moveServoFuncPtr;
+			servoMoves[servoMoveCount].servoShortName = servoShortName;
 			servoMoves[servoMoveCount].pos = pos;
 			servoMoves[servoMoveCount].servoSpeed = servoSpeedLocal;
 			servoMoveCount++;
@@ -285,8 +301,42 @@
 			} while (parseCommandGServo(&endptr, speedControl, wait) && !servoMoveError);
 			for (i = 0; !servoMoveError && i < servoMoveCount; ++i) {
 				// perform this move, if the last move in the list, use the wait variable value and update display
-				servoMoves[i].moveServoFuncPtr(servoMoves[i].pos, servoMoves[i].servoSpeed,
-					(i == servoMoveCount - 1 ? false : wait), (i == servoMoveCount - 1 ? true : false));
+				servoMoves[i].moveServoFuncPtr(servoMoves[i].pos, servoMoves[i].servoSpeed, false,
+					(i == servoMoveCount - 1 ? true : false));
+			}
+			// do software wait while updating widgets
+			if (!servoMoveError && wait) {
+				bool done = false;
+				while (!done) {
+					servoWidgetUpdate();
+					done = true;
+					for (i = 0; i < servoMoveCount; ++i) {
+						switch (servoMoves[i].servoShortName) {
+							case 'L':
+								if (servoMoves[i].pos != servoL.read())
+									done = false;
+								break;
+							case 'R':
+								if (servoMoves[i].pos != servoR.read())
+									done = false;
+								break;
+							case 'O':
+								if (servoMoves[i].pos != servoRot.read())
+									done = false;
+								break;
+							case 'T':
+								if (servoMoves[i].pos != servoHRot.read())
+									done = false;
+								break;
+							case 'H':
+								if (servoMoves[i].pos != servoH.read())
+									done = false;
+								break;
+							default:
+								break;
+						}
+					}
+				}
 			}
 			if (i != 0) {
 				sendMsg(F("OK\n"));
@@ -385,11 +435,6 @@
 			}
 		}
 	} else {
-		widgetL->setValue(servoL.read());
-		widgetR->setValue(servoR.read());
-		widgetRot->setValue(servoRot.read());
-		widgetHRot->setValue(servoHRot.read());
-		widgetH->setValue(servoH.read());
-		uView.display();
+		servoWidgetUpdate();
 	}
 }


5seconds initial text delay

5seconds initial text delay

--- vibrate_alarm_clock.ino
+++ vibrate_alarm_clock.ino
@@ -17,7 +17,7 @@
 #define DISPLAY_CONTRAST 64

 #define INITIAL_TEXT "Happy 24th birthday\n Jason!\n\nBy: Yeo Kheng Meng\n(14 May 2014)"
-#define INITIAL_TEXT_DELAY 8000
+#define INITIAL_TEXT_DELAY 5000
 #define MIN_TIME_BETWEEN_BUTTON_PRESSES 100  //Debouncing purposes
 #define BLINK_INTERVAL 100


Changed writing to SD to the correct format

--- arduino/tempLogger/tempLogger.ino
+++ arduino/tempLogger/tempLogger.ino
@@ -20,19 +20,19 @@
     1) AFTER SETTING THE TIME COMMENT IT OUT
        OTHERWISE THE CLOCK IS SET TO THAT DATE EVERY
        TIME YOU BOOT UP
-
+
     2) The processor doesn't begin logging until the
        minute it is on finishes but then it consistently
        runs from there, so if it starts at 10:01:29 it waits
        until 10:02:00 to begin
-
+
     3) On power up, the temperature sensor sends 185 deg F to verify booting
        This code omits that initial log, so it may actually begin logging after
        up to one plus timeToSleep minutes
-
-    4) Currently, the processor wakes up every minute to see if the specified
+
+    4) Currently, the processor wakes up every minute to see if the specified
        timeToSleep minutes have passed, and then it logs when true. This is due
-       to the nature of the RTC's alarm, and with some math it can be configured
+       to the nature of the RTC's alarm, and with some math it can be configured
        to wake up only once every timeToSleep minutes
 */

@@ -192,29 +192,32 @@
   // retrieve data from DS3231
   readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
   &year);
-
-    // print to the serial port too:
-    Serial.print(month);
-    Serial.print("/");
-    Serial.print(dayOfMonth);
-    Serial.print("/");
-    Serial.print(year);
-    Serial.print(" ");
-    Serial.print(hour);
-    Serial.print(":");
-    Serial.print(minute);
-    Serial.print(":");
-    Serial.println(second);
-
-}
-
-/*
- *Write a string to sd
+
+  // print to the serial port:
+  //yyyy-mm-dd hh:mm:ss,temperature
+  Serial.print(year);
+  Serial.print("-");
+  Serial.print(dayOfMonth);
+  Serial.print("-");
+  Serial.print(day);
+  Serial.print(" ");
+  Serial.print(hour);
+  Serial.print(":");
+  Serial.print(minute);
+  Serial.print(":");
+  Serial.print(second);
+  Serial.print(",");
+  Serial.println(temp);
+
+}
+
+/*
+ *Write a string to sd
  */
 void write_Text_To_Disk(String filename,String str) {
   // open the file. note that only one file can be open at a time,
   // so you have to close this one before opening another.
-  File dataFile = SD.open(filename, FILE_WRITE);
+  File dataFile = SD.open(filename, FILE_WRITE);
   // if the file is available, write to it:
   if (dataFile) {
     delay(50);
@@ -223,7 +226,7 @@
     dataFile.close();
   }
   else{
-
+
     Serial.println("error writing text to disk data.txt");
   }
 }
@@ -235,13 +238,13 @@

   // open the file. note that only one file can be open at a time,
   // so you have to close this one before opening another.
-  File dataFile = SD.open("data.txt", FILE_WRITE);
-
+  File dataFile = SD.open("data.txt", FILE_WRITE);
+
   byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
   // retrieve data from DS3231
   readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
   &year);
-
+
   // if the file is available, write to it:
   if (dataFile) {
     delay(50);
@@ -252,32 +255,32 @@
     //don't write -1000 either
     if (temp == 185.0 || temp == -1000)
       return;
-#endif
-
-#if DEBUG
-     Serial.println("Printing Data:");
-#endif
-
- //print comma seperated values in form:
-    //mm/dd/yy hh:mm
-    dataFile.print(temp);
-    dataFile.print(", ");
-    dataFile.print(month);
-    dataFile.print("/");
-    dataFile.print(dayOfMonth);
-    dataFile.print("/");
-    dataFile.print(year);
-    dataFile.print(" ");
-    dataFile.print(hour);
-    dataFile.print(":");
-    dataFile.print(minute);
-    dataFile.print(":");
-    dataFile.println(second);
-    dataFile.close();
-
+#endif
+
+#if DEBUG
+  Serial.println("Printing Data:");
+#endif
+
+  //print comma seperated values in form:
+  //yyyy-mm-dd hh:mm:ss,temperature
+  dataFile.print(year);
+  dataFile.print("-");
+  dataFile.print(dayOfMonth);
+  dataFile.print("-");
+  dataFile.print(day);
+  dataFile.print(" ");
+  dataFile.print(hour);
+  dataFile.print(":");
+  dataFile.print(minute);
+  dataFile.print(":");
+  dataFile.print(second);
+  dataFile.print(",");
+  dataFile.println(temp);
+  dataFile.close();
+
 #if DEBUG
   printTime();
-#endif
+#endif

   }
   // if the file isn't open, pop up an error:
@@ -289,7 +292,7 @@
 /*
  * on clock alarm, this function wakes up the device to
  * allow the loop to log data and go back to sleep
- *
+ *
 */
 void alarmISR()
 {
@@ -326,13 +329,13 @@

 //set up the pin modes, the clock
-//sd card, temp sensor, and the
+//sd card, temp sensor, and the
 //device id
 void setup(void) {

 #if DEBUG
   Serial.begin(9600);
-#endif
+#endif

   // set pin 4 (POWA) to output so that we can control the
   //power of the sd reader and the temp sensor
@@ -347,7 +350,7 @@

   //set up sd card
   sd_setup();
-
+
   //set up clock
   setup_Clock();

@@ -355,7 +358,7 @@

   #if DEBUG_TO_SD
     write_Text_To_Disk("data.txt","setting up system");
-  #endif
+  #endif

 }

@@ -371,7 +374,7 @@

 #if DEBUG_TO_SD
   write_Text_To_Disk("data.txt","Going To Sleep");
-#endif
+#endif

   //enter deep sleep
   sleep_enable();
@@ -379,7 +382,7 @@
   cli();
   sleep_bod_disable();
   sei();
-
+
 #if DEBUG
   //let serial have time print
   delay(75);
@@ -397,9 +400,9 @@
 #endif

    //update until we hit the specified number of minutes to run
-
+
 #if 0
-  Serial.print("clock.isAlarm1() " + String(clock.isAlarm1(false)) + " && (timeCount < (timeToSleep - 1)) : ");
+  Serial.print("clock.isAlarm1() " + String(clock.isAlarm1(false)) + " && (timeCount < (timeToSleep - 1)) : ");
   Serial.println(clock.isAlarm1(false) && (timeCount < (timeToSleep - 1)));
 #endif

@@ -408,36 +411,33 @@
       timeCount++;
       clock.clearAlarm1();
     }
-
+
   //At this point, the ISR from the clock alarm woke up the
   //processor and the alarm flag is set. Clear the flag and
   //handle whatever we need to do.
   else {
 #if DEBUG_TO_SD
   write_Text_To_Disk("data.txt","Woke up, logging");
-#endif
+#endif

 #if DEBUG
     Serial.println("ALARM TRIGGERED!");
-#endif
-delay(1);
+#endif
+    delay(1);

     //we finally hit the specified number of minutes to run, reset and log
     timeCount = 0;
-
+
     float temperature = getTemp();
     delay(5);
     append_to_disk(temperature);
 #if DEBUG
     Serial.println(temperature);
-#endif
-
+#endif

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

   }

-
-}
-
+}


added abs to re-design dead reckoning for turning

--- arduino_motor/mains/movements.ino
+++ arduino_motor/mains/movements.ino
@@ -20,8 +20,8 @@
       leftPololuCount = PololuWheelEncoders::getCountsM1();
       rightPololuCount = PololuWheelEncoders::getCountsM2();
       long timez = millis() - timing; // time passed by
-      double leftTicks = leftPololuCount - previousLeftTick; // positive for forward, negative for backward
-      double rightTicks = rightPololuCount - previousRightTick;
+      double leftTicks = abs(leftPololuCount - previousLeftTick); // positive for forward, negative for backward
+      double rightTicks = abs(rightPololuCount - previousRightTick);

       // distanceToTravel is incremental
       double leftcm = DISTANCE_PER_TICK_CM * leftTicks;
@@ -43,12 +43,7 @@
       Serial.print("timez: "); Serial.println(timez);
       leftTicks /= (timez/1000.0);
       rightTicks /= (timez/1000.0); // ms
-      if(isM1Forward * isM2Forward < 0) { // Turning
-        InputMid = deltaX / DISTANCE_PER_TICK_CM;
-      }
-      else { // Straight Line
-        InputMid = deltaY / DISTANCE_PER_TICK_CM;
-      }
+      InputMid = deltaY / DISTANCE_PER_TICK_CM;
       if(leftTicks>0 && rightTicks>0) { // avoid overflow
         InputLeft = leftTicks;
         InputRight = rightTicks;
@@ -152,7 +147,7 @@
     rightTicksForAngleOrDist = PololuWheelEncoders::getCountsM2();
     rightTicksForAngleOrDist = abs(rightTicksForAngleOrDist - firstRightCount); // right backward

-    avgTicksForAngleOrDist = (isLeftForward * leftTicksForAngleOrDist + isRightForward * rightTicksForAngleOrDist) / 2; // turn right
+    avgTicksForAngleOrDist = (leftTicksForAngleOrDist + rightTicksForAngleOrDist) / 2; // turn right
     Serial.print("Turning right: "); Serial.print(avgTicksForAngleOrDist); Serial.print(" / "); Serial.println(noOfTicksForAngle);
     configureMotor(isLeftForward, isRightForward);
   }


logging and cleanups

logging and cleanups

--- client/RGB_control/RGB_control.ino
+++ client/RGB_control/RGB_control.ino
@@ -49,6 +49,7 @@

 unsigned long fadeRcvTime, lastFadePWMMillis=0;
+unsigned long lastCallback = 0;
 int curRGB[] = {0, 0, 0},
      wasRGB[3],
      toRGB[3];
@@ -128,6 +129,8 @@
 }

 void callback(char* topic, byte* payload, unsigned int length) {
+  String topicStr = String(topic);
+  unsigned long callbackTime = millis();
   String data = "";
   for (int i = 0; i < length; i++)
   {
@@ -135,16 +138,21 @@
   }
   #if DEBUG
     Serial.print("[");
-    Serial.print(topic);
+    Serial.print(topicStr);
     Serial.print("] ");
+    if (lastCallback != 0) {
+      Serial.print(millis() - lastCallback);
+      Serial.print(" ");
+    }
+    Serial.print(millis());
+    Serial.print(" ");
     Serial.println(data);
   #endif
-
-  if (String(topic) == subscriptions[0])
+  if (topicStr == subscriptions[0])
   {
     mqttClient.publish(String(domain + "/ack/" + thisMAC).c_str(), "ack");
   }
-  else if (String(topic) == subscriptions[1])
+  else if (topicStr == subscriptions[1])
   {
     parseRGB(data);
     setParsedRGB();
@@ -152,11 +160,16 @@
       Serial.println("Setting RGB " + data);
     #endif
   }
-  else if (String(topic) == subscriptions[2])
+  else if (topicStr == subscriptions[2])
   {
     parseFade(data);
     fadeActive = true;
   }
+  lastCallback = millis();
+  #if DEBUG
+  Serial.print("Callback prossesing time: ");
+  Serial.println(millis() - callbackTime);
+  #endif
 }