Use GD.random()

Use GD.random()

--- invaders.ino
+++ invaders.ino
@@ -295,7 +295,7 @@
                         fake = (fake + 1) & 511;
                         control_right = fake < 256;
                         control_left  = 256 <= fake;
-                        control_fire = (random() % 70) == 0;
+                        control_fire = (GD.random(70)) == 0;

                         if (control_left) {
                         xpos -= playerSpeed;


add config for rtos

add config for rtos

--- arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/OPM_for_Arduino/Chain/d_open_manipulator_chain/d_open_manipulator_chain.ino
+++ arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/OPM_for_Arduino/Chain/d_open_manipulator_chain/d_open_manipulator_chain.ino
@@ -0,0 +1,74 @@
+/*******************************************************************************
+* Copyright 2016 ROBOTIS CO., LTD.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+/* Authors: Darby Lim */
+
+#include <RTOS.h>
+#include <OpenManipulator.h>
+#include "OpenManipulator_Chain.h"
+
+namespace THREAD
+{
+osThreadId loop;
+osThreadId robot_state;
+}
+
+void setup()
+{
+  Serial.begin(57600);
+
+  initThread();
+  startThread();
+
+  MY_ROBOT::initManipulator();
+  MY_ROBOT::initDyanmixel();
+}
+
+void loop()
+{
+
+  osDelay(100);
+}
+
+
+/// DON'T TOUCH ///
+void initThread()
+{
+  // define thread
+  osThreadDef(THREAD_NAME_LOOP,         Thread_Loop,                           osPriorityNormal, 0, 1024*10);
+  osThreadDef(THREAD_NAME_ROBOT_STATE,  OPEN_MANIPULATOR::Thread_Robot_State,  osPriorityNormal, 0, 1024*10);
+
+  // create thread
+  THREAD::loop         = osThreadCreate(osThread(THREAD_NAME_LOOP), NULL);
+  THREAD::robot_state  = osThreadCreate(osThread(THREAD_NAME_ROBOT_STATE), NULL);
+}
+
+void startThread()
+{
+  // start kernel
+  osKernelStart();
+  Serial.println("Thread Start");
+}
+
+static void Thread_Loop(void const *argument)
+{
+  (void) argument;
+
+  for(;;)
+  {
+    loop();
+  }
+}


blink ok with delay and response correctif

--- scripts-arduino/bp_led_lp.ino
+++ scripts-arduino/bp_led_lp.ino
@@ -124,4 +124,5 @@
             break;
         }
     }
+    isSync = false;
 }


esp8266_160602_udpTxToLogger > reduce retry from 100 to 10

--- esp8266_160602_udpTxToLogger.ino
+++ esp8266_160602_udpTxToLogger.ino
@@ -32,7 +32,7 @@
 {
   WiFi.begin(kWifiSsid, kWifiPass);

-  for(int loop = 0; loop < 100; loop++) {
+  for(int loop = 0; loop < 10; loop++) {
     if (WiFi.status() == WL_CONNECTED) {
       s_isWiFiConnected = true;


fix char to int conversion

fix char to int conversion

--- Arduino/ODriveArduino/examples/ODriveArduinoTest/ODriveArduinoTest.ino
+++ Arduino/ODriveArduino/examples/ODriveArduinoTest/ODriveArduinoTest.ino
@@ -46,19 +46,20 @@

     // Run calibration sequence
     if (c == '0' || c == '1') {
+      int motornum = c-'0';
       int requested_state;

       requested_state = ODriveArduino::AXIS_STATE_MOTOR_CALIBRATION;
       Serial << "Axis" << c << ": Requesting state " << requested_state << '\n';
-      odrive.run_state(atoi(c), requested_state, true);
+      odrive.run_state(motornum, requested_state, true);

       requested_state = ODriveArduino::AXIS_STATE_ENCODER_OFFSET_CALIBRATION;
       Serial << "Axis" << c << ": Requesting state " << requested_state << '\n';
-      odrive.run_state(atoi(c), requested_state, true);
+      odrive.run_state(motornum, requested_state, true);

       requested_state = ODriveArduino::AXIS_STATE_CLOSED_LOOP_CONTROL;
       Serial << "Axis" << c << ": Requesting state " << requested_state << '\n';
-      odrive.run_state(atoi(c), requested_state, false); // don't wait
+      odrive.run_state(motornum, requested_state, false); // don't wait
     }

     // Sinusoidal test move


[bug] Found temp calc bug, when testing with real temp sensors. This is why I have changed the calibration values of adArr.

--- heater_control.ino
+++ heater_control.ino
@@ -56,11 +56,11 @@

-struct ad adArr[]= {
-  {0,"boiler",  0,0,0.0,0,0.5,0,0.0,1023,120.0,0,0.0,0,0.0},
-  {1,"ambient", 0,0,0.0,0,0.5,0,0.0,1023,60.0,0,0.0,0,0.0},
-  {2,"hothousewater",0,0,0.0,0,0.5,0,0.0,1023,100.0,0,0.0,0,0.0},
-  {3,"radiator",0,0,0.0,0,0.5,0,0.0,1023,60.0,0,0.0,0,0.0}
+struct ad adArr[]= { //prev   dif    min       max         meas    delta
+  {0,"boiler",  0,     0,0.0, 0,0.5, 174,21.0, 935, 100.0,  0,0.0,  0,0.0},
+  {1,"ambient", 0,     0,0.0, 0,0.3, 372,2.2,  964,  36.5,  0,0.0,  0,0.0},
+  {2,"hothousewater",0,0,0.0, 0,0.5, 7,  21.0, 1023,100.0,  0,0.0,  0,0.0},
+  {3,"radiator",0,     0,0.0, 0,0.3, 7,  21.0, 539,  36.5,  0,0.0,  0,0.0}
 };

 int readAdChannels(struct ad *ad, int cnt);
@@ -352,7 +352,6 @@
     ad[analogChannel].delta.digital=ad[analogChannel].maxcal.digital - ad[analogChannel].mincal.digital;
     ad[analogChannel].delta.analog=ad[analogChannel].maxcal.analog - ad[analogChannel].mincal.analog;
   }
-  // todo: calculate diff in digital from diff.analog values.
 }

@@ -380,7 +379,10 @@
     // inter- and extrapolation
     ddelta=ad[analogChannel].delta.digital ;
     adelta=ad[analogChannel].delta.analog;
-    ad[analogChannel].measured.analog  = digital * adelta / ddelta;
+
+    ad[analogChannel].measured.analog  = ad[analogChannel].mincal.analog +
+      (digital - ad[analogChannel].mincal.digital) * adelta / ddelta;
+
     ad[analogChannel].changed=0;
     if ((abs(ad[analogChannel].measured.analog - ad[analogChannel].prev.analog)) > ad[analogChannel].diff.analog) {
       ad[analogChannel].prev.analog = ad[analogChannel].measured.analog;


Added DCC Decoder logic to move levels

Added DCC Decoder logic to move levels

--- examples/Fahrstuhl/Fahrstuhl.ino
+++ examples/Fahrstuhl/Fahrstuhl.ino
@@ -8,12 +8,21 @@
 #include <SSD1306Ascii.h>
 #include <SSD1306AsciiWire.h>
 #include <EEPROM.h>
-
+#include <NmraDcc.h>
+
+// Define the Arduino Pin to connect to the DCC input signal
+#define DCC_PIN 2
+
+// Define the DCC Turnout Address to select the first level = 1
+#define DCC_ACCESSORY_DECODER_BASE_ADDRESS  200
+
+// Define the manimus numbr of Levels
 #define NUM_LIFT_LEVELS  8

 #define PROGRAM_NAME     "Fahrstuhl"
-#define PROGRAM_VERSION  "1.0"
-
+#define PROGRAM_VERSION  "1.1"
+
+// Locate the Persistant State storage EEPROM space well above the DCC Accessory Decoder CV Storage
 #define EEPROM_BASE_ADDR  100
 #define EEPROM_VALID_DATA_SIGNATURE 0xA5A5
 // Uncomment the line below to force the EEPROM values to be reset to defaults
@@ -21,11 +30,40 @@

 #define BUTTON_LONG_PRESS_DELAY 2000

-#if defined (ARDUINO_AVR_NANO)  // Setting for Uwe's Fahrstuhl System
-
-// Uncomment the next line to reverse the direction of the stepper movement
+#define AJS_BOARD_SETTINGS
+//#define UWE_BOARD_SETTINGS
+
+#if defined(AJS_BOARD_SETTINGS)  // Setting for AJS Dev System
+
+// Uncomment the next line to reverse the direction of the stepper movement
+#define REVERSE_STEPPER_DIRECTION
+
+#define HOME_SENSOR_PIN     10
+
+#define STEPPER_PULSE_PIN   11
+#define STEPPER_ENABLE_PIN  12
+#define STEPPER_DIR_PIN     13
+
+#define STEPPER_MAX_SPEED             2100
+#define STEPPER_NORMAL_ACCELERATION   5000
+#define STEPPER_MAX_POSITION  300000U // Maximum Steps to allow the stepper to drive Up Saftey mechanism
+
+#define BUTTON_MANUAL     A3
+#define BUTTON_DOWN       A2
+#define BUTTON_UP         A1
+#define BUTTON_STOP_HOME  A0
+
+long defaultPositions[NUM_LIFT_LEVELS] = {1000, 4000, 7000, 10000, 13000, 16000, 19000, 22000}; // Default positions
+
+#define STEPPER_INC_SPEED             (STEPPER_MAX_SPEED / 10)
+
+#define OLED_DISPLAY_I2C_ADDRESS  0x3C
+
+#elif defined (UWE_BOARD_SETTINGS)  // Setting for Uwe's Fahrstuhl System
+
+// Uncomment the next line to reverse the direction of the stepper movement
 //#define REVERSE_STEPPER_DIRECTION
-
+
 #define HOME_SENSOR_PIN     7

 #define STEPPER_PULSE_PIN   4
@@ -34,47 +72,24 @@

 #define STEPPER_MAX_SPEED             2100
 #define STEPPER_NORMAL_ACCELERATION   5000
-#define STEPPER_MAX_POSITION  30000U // Maximum Steps to allow the stepper to drive Up Saftey mechanism
+#define STEPPER_MAX_POSITION  1970000U // Maximum Steps to allow the stepper to drive Up Saftey mechanism

 #define BUTTON_MANUAL     8
 #define BUTTON_DOWN       9
 #define BUTTON_UP         10
 #define BUTTON_STOP_HOME  11

-long defaultPositions[NUM_LIFT_LEVELS] = {1000, 4000, 7000, 10000, 13000, 16000, 19000, 22000}; // Default positions
+long defaultPositions[NUM_LIFT_LEVELS] = {0, 161064, 32500, 483284, 645326, 808041, 1967457, 1130774}; // Default positions
+
+#define STEPPER_INC_SPEED             (STEPPER_MAX_SPEED / 2)

 #define OLED_DISPLAY_I2C_ADDRESS  0x3C
-
 #else
-//#if defined(ARDUINO_AVR_UNO)  // Setting for AJS Dev System
-
-// Uncomment the next line to reverse the direction of the stepper movement
-#define REVERSE_STEPPER_DIRECTION
-
-#define HOME_SENSOR_PIN     10
-
-#define STEPPER_PULSE_PIN   11
-#define STEPPER_ENABLE_PIN  12
-#define STEPPER_DIR_PIN     13
-
-#define STEPPER_MAX_SPEED             2100
-#define STEPPER_NORMAL_ACCELERATION   5000
-#define STEPPER_MAX_POSITION  30000U // Maximum Steps to allow the stepper to drive Up Saftey mechanism
-
-#define BUTTON_MANUAL     A3
-#define BUTTON_DOWN       A2
-#define BUTTON_UP         A1
-#define BUTTON_STOP_HOME  A0
-
-long defaultPositions[NUM_LIFT_LEVELS] = {1000, 4000, 7000, 10000, 13000, 16000, 19000, 22000}; // Default positions
-
-#define OLED_DISPLAY_I2C_ADDRESS  0x3C
-
+#error No Board Settings Defined
 #endif

 SSD1306AsciiWire oled;
-
-#define STEPPER_INC_SPEED             (STEPPER_MAX_SPEED / 10)
+
 #define STEPPER_MAN_SPEED_CHANGE_MILLIS 5
 #define STEPPER_EMERGENCY_STOP_ACCELERATION   100000
 #define LIFT_LEVEL_NOT_SET -1
@@ -100,6 +115,9 @@
 EncButton2<EB_BTN> btnUp(INPUT, BUTTON_UP);
 EncButton2<EB_BTN> btnStopHome(INPUT, BUTTON_STOP_HOME);

+// NMRA DCC Accessory Decoder object
+NmraDcc  Dcc;
+
 void displayLevel(int newLevel)
 {
   oled.setCursor(0,0);
@@ -137,15 +155,15 @@
 void initPersistentValues()
 {
   EEPROM.get(EEPROM_BASE_ADDR, persistentValues);
-
+
 #ifdef EEPROM_FORCE_RELOAD_DEFAULT_VALUES
   persistentValues.objectSignature = 0;
 #endif
-
+
   if(persistentValues.objectSignature != EEPROM_VALID_DATA_SIGNATURE)
   {
     Serial.println("initPersistentValues: set detault values");
-
+
     persistentValues.numLiftLevels = NUM_LIFT_LEVELS;
     persistentValues.lastLiftLevel = 0;
     persistentValues.lastStepperPosition = 0;
@@ -192,38 +210,44 @@
   stepper.setCurrentPosition(persistentValues.lastStepperPosition);

   stepper.setEnablePin(STEPPER_ENABLE_PIN);
-#ifdef REVERSE_STEPPER_DIRECTION
+#ifdef REVERSE_STEPPER_DIRECTION
   stepper.setPinsInverted(true, false, true);
 #else
   stepper.setPinsInverted(false, false, true);
 #endif
-
+
   stepper.setMaxSpeed(STEPPER_MAX_SPEED);

   btnStopHome.setHoldTimeout(BUTTON_LONG_PRESS_DELAY);
   btnManual.setHoldTimeout(BUTTON_LONG_PRESS_DELAY);
+
+    // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up
+  Dcc.pin(DCC_PIN, 1);
+
+    // Call the main DCC Init function to enable the DCC Receiver
+  Dcc.init(MAN_ID_DIY, 10, CV29_ACCESSORY_DECODER | CV29_OUTPUT_ADDRESS_MODE, 0);
 }

 void stepperMoveTo(long newPosition)
 {
   stepper.enableOutputs();
   stepper.setAcceleration(STEPPER_NORMAL_ACCELERATION);
-  stepper.moveTo(newPosition);
+  stepper.moveTo(newPosition);
 }

 void stepperMove(long newRelPosition)
 {
   stepper.enableOutputs();
   stepper.setAcceleration(STEPPER_NORMAL_ACCELERATION);
-  stepper.move(newRelPosition);
+  stepper.move(newRelPosition);
 }
 void stopStepper(void)
 {
   stepper.setAcceleration(STEPPER_EMERGENCY_STOP_ACCELERATION);
-  stepper.move(0);
+  stepper.move(0);
   stepper.stop();
   while(stepper.run());
-  stepper.disableOutputs();
+  stepper.disableOutputs();
 }

 int lastSpeed = 0;
@@ -233,8 +257,32 @@
 bool homing = false;
 elapsedMillis lastSpeedChange = 0;

+
+  // This function is called whenever a normal DCC Turnout Packet is received
+  // The DCC Turnout Address is checked to see if it is within the range used to Select Elevator levels and starts a Move if a new level is selected
+void notifyDccAccTurnoutOutput(uint16_t receivedAddress, uint8_t direction, uint8_t outputPower)
+{
+  if((receivedAddress >= DCC_ACCESSORY_DECODER_BASE_ADDRESS) && (receivedAddress < (DCC_ACCESSORY_DECODER_BASE_ADDRESS + NUM_LIFT_LEVELS)))
+  {
+    uint8_t newLevel = receivedAddress - DCC_ACCESSORY_DECODER_BASE_ADDRESS;
+    if(persistentValues.lastLiftLevel != newLevel)
+    {
+      persistentValues.lastLiftLevel = newLevel;
+
+      long newPos = persistentValues.levelPositions[persistentValues.lastLiftLevel];
+      stepperMoveTo(newPos);
+
+      Serial.print("notifyDccAccTurnoutOutput: Move to Level: "); Serial.print(persistentValues.lastLiftLevel); Serial.print("  Pos: "); Serial.println(newPos);
+
+      displayMessageNumber("Mv To: ", persistentValues.lastLiftLevel + 1);
+    }
+  }
+}
+
 void loop()
 {
+  Dcc.process();
+
     //First check the Home Sensor and stop the motor if going in the down direction
   homeSensor.tick();
   if(homeSensor.state())
@@ -254,9 +302,9 @@
       persistentValues.lastLiftLevel = 0;
       persistentValues.lastStepperPosition = 0;
       stepper.setCurrentPosition(persistentValues.lastStepperPosition);
-
+
       EEPROM.put(EEPROM_BASE_ADDR, persistentValues);
-
+
       if(homing)
       {
         long newPos = persistentValues.levelPositions[persistentValues.lastLiftLevel];
@@ -273,19 +321,19 @@
     if(configMode && stepper.isRunning() && (lastSpeed >= 0))
     {
       stopStepper();
-
+
       Serial.print("Maximum Position Hit - LastSpeed: ");
       Serial.print(lastSpeed);
       Serial.print("  Last Position: ");
       Serial.println(stepper.currentPosition());
-
+
       newSpeed = 0;
       lastSpeed = newSpeed;

       displayMessage("At Max");
     }
   }
-
+
   btnStopHome.tick();
   if(btnStopHome.press())
   {
@@ -305,7 +353,7 @@
     homing = true;
     newSpeed = -STEPPER_MAX_SPEED;
   }
-
+
   btnManual.tick();
   if(btnManual.press())
   {
@@ -331,11 +379,11 @@
       newSpeed = lastSpeed + STEPPER_INC_SPEED;
       lastSpeedChange = STEPPER_MAN_SPEED_CHANGE_MILLIS;
       Serial.print("Down Press - Current Pos: "); Serial.print(stepper.currentPosition()); Serial.print("  New Speed: "); Serial.println(newSpeed);
-
+
       displayMessage("Down");
     }
   }
-
+
   else if((btnDown.press() || btnDown.step()) && persistentValues.lastLiftLevel > 0)
   {
     Serial.print("Down Press - Current Level: "); Serial.print(persistentValues.lastLiftLevel);
@@ -346,7 +394,7 @@

     displayMessageNumber("Dn To: ", persistentValues.lastLiftLevel + 1);
   }
-
+
   btnUp.tick();
   if(configMode)
   {
@@ -355,7 +403,7 @@
       newSpeed = lastSpeed - STEPPER_INC_SPEED;
       lastSpeedChange = STEPPER_MAN_SPEED_CHANGE_MILLIS;
       Serial.print("Up Press - Current Pos: "); Serial.print(stepper.currentPosition()); Serial.print("  New Speed: "); Serial.println(newSpeed);
-
+
       displayMessage("Up");
     }
   }
@@ -371,12 +419,12 @@
     displayMessageNumber("Up To: ", persistentValues.lastLiftLevel + 1);
   }

-
+
   if(lastSpeed != newSpeed)
   {
 //    Serial.print("Speed Change: Last: "); Serial.print(lastSpeed); Serial.print("  New: "); Serial.print(newSpeed);
 //    Serial.print(" - Current Pos: "); Serial.print(stepper.currentPosition());
-
+
     if( newSpeed == 0)
     {
       lastSpeed = newSpeed;


delete 2bk

delete 2bk

--- examples/RFID_UART/RFID_UART.ino
+++ examples/RFID_UART/RFID_UART.ino
@@ -14,7 +14,7 @@

 void setup() {
 	Serial.begin(57600);
-	Serial.println("Hello, double bk!");
+	Serial.println("RFID Test..");
 }

 void loop() {


Removed excess code

Removed excess code

--- LSM9DS0_AHRS/LSM9DS0_AHRS.ino
+++ LSM9DS0_AHRS/LSM9DS0_AHRS.ino
@@ -173,7 +173,7 @@
 float ax, ay, az, gx, gy, gz, mx, my, mz; // variables to hold latest sensor data values
 float q[4] = {1.0f, 0.0f, 0.0f, 0.0f};    // vector to hold quaternion
 float eInt[3] = {0.0f, 0.0f, 0.0f};       // vector to hold integral error for Mahony method
-float temperature;
+//float temperature;

 double XYZ[3];
 double XYZmin[] = {258.758,283.705,140.1667};
@@ -205,7 +205,7 @@
 void setup()
 {
   Serial.begin(38400); // Start serial at 38400 bps
-
+
   // Set up interrupt pins as inputs:
   pinMode(INT1XM, INPUT);
   pinMode(INT2XM, INPUT);
@@ -305,8 +305,8 @@
     my = dof.calcMag(dof.my);
     mz = dof.calcMag(dof.mz);

-    dof.readTemp();
-    temperature = 21.0 + (float) dof.temperature/8.; // slope is 8 LSB per degree C, just guessing at the intercept
+    //dof.readTemp();
+    //temperature = 21.0 + (float) dof.temperature/8.; // slope is 8 LSB per degree C, just guessing at the intercept
   }

   Now = micros();


GPIO swap and PWS change

GPIO swap and PWS change

--- hvacMonitor.ino
+++ hvacMonitor.ino
@@ -7,7 +7,7 @@
 #include <DallasTemperature.h>
 #include <TimeLib.h> // Used by WidgetRTC.h
 #include <WidgetRTC.h>
-#define ONE_WIRE_BUS 2
+#define ONE_WIRE_BUS 0
 #include <ArduinoJson.h>
 #include <EEPROM.h>

@@ -31,8 +31,9 @@
 // HTTP request
 const char WUNDERGROUND_REQ[] =
   //"GET /test.json HTTP/1.1\r\n"  // Keep for test/debug
-  //"GET /api/myApiKey/conditions/q/pws:KAZTEMPE29.json HTTP/1.1\r\n" // Local PWS
-  "GET /api/myApiKey/conditions/q/KPHX.json HTTP/1.1\r\n" // Airport
+  "GET /api/myApiKey/conditions/q/pws:KAZTEMPE29.json HTTP/1.1\r\n" // Local PWS
+  //"GET /api/myApiKey/conditions/q/KPHX.json HTTP/1.1\r\n" // Airport
+  //"GET /api/myApiKey/conditions/q/pws:KAZTEMPE47.json HTTP/1.1\r\n" // Local PWS #2
   "User-Agent: ESP8266/0.1\r\n"
   "Accept: */*\r\n"
   "Host: " WUNDERGROUND "\r\n"
@@ -45,7 +46,7 @@
 WidgetRTC rtc;
 BLYNK_ATTACH_WIDGET(rtc, V8);

-int blowerPin = 0;  // 3.3V logic source from blower
+int blowerPin = 2;  // 3.3V logic source from blower
 int xStop = 1;
 int xStart = 1;
 int alarmTrigger = 0;


Read buzzer test

Read buzzer test

--- Arduino/ReadBuzzer/ReadBuzzer.ino
+++ Arduino/ReadBuzzer/ReadBuzzer.ino
@@ -4,55 +4,54 @@
 const int buzzerPin = A0;

 int buzzer = 0;
-const int beeps = 2;
-
+int beeps = 0;
 bool on = false;

+bool connected = false;
+
 void setup() {
+  Serial.begin(9600);
+
+  pinMode(slaveSelectPin, OUTPUT);
   pinMode(buzzerPin, INPUT);

-  Serial.begin(9600);
-  Serial.println("EPAHA");
+  SPI.begin();
 }

 void loop() {
   buzzer = analogRead(buzzerPin);
+  Serial.println(String(beeps) + " | " + String(buzzer));

   if (buzzer > 400) on = true;
-  Serial.println("EPAHA");

-  if (on && buzzer == 0 && beeps < 2) {
-    //beeps++;
-    Serial.println("UP");
-    Serial.println(beeps);
-    delay(beeps * 1000);
-    Serial.println("OK");
-  }
-  Serial.println("EPAHA");
-
-  if (beeps == 2)   {
-    Serial.println("EPAHA");
-
-    digitalPotWrite(0, 255);
-    Serial.println("EPAHA");
-
-    Serial.println("2 .");
-    delay(1000);
-    //beeps++;
-  }
-  Serial.println("EPAHA");
-
-  if (beeps == 3)  {
-    digitalPotWrite(0, 0);
-    Serial.println("3 .");
-    delay(1000);
-    //beeps++;
+  if (buzzer == 0 && on) {
+    Serial.println("piiiiiiipp");
+    switch (beeps) {
+      case 0:
+        Serial.println("0");
+        digitalPotWrite(0, 0);
+        delay(1000);
+        break;
+      case 1:
+        Serial.println("1");
+        delay(2000);
+        digitalPotWrite(0, 255);
+        break;
+      case 2:
+        Serial.println("2");
+        delay(1000);
+        digitalPotWrite(0, 0);
+        break;
+      case 3:
+        Serial.println("3");
+        delay(1000);
+        connected = true;
+    }
+    beeps++;
+    delay(100);
   }

-  Serial.println("EPAHA");
-
-
-  Serial.println(beeps);
+  if (connected) digitalPotWrite(0, 127);
 }

 void digitalPotWrite(int address, int value) {


Removing test output.

Removing test output.

--- examples/Sandbox/CosaVCC/CosaVCC.ino
+++ examples/Sandbox/CosaVCC/CosaVCC.ino
@@ -44,8 +44,8 @@
   virtual void run()
   {
     m_vcc = AnalogPin::bandgap();
+    if (m_vcc > m_threshold) return;
     on_low_voltage();
-    if (m_vcc > m_threshold) return;
   }
 public:
   VCC(uint16_t mv, uint16_t ms = 1024) :
@@ -59,7 +59,7 @@
   }
 };

-VCC lowPower(4500);
+VCC lowPower(4900);

 void setup()
 {


handle scaling up/down too

handle scaling up/down too

--- status.ino
+++ status.ino
@@ -7,7 +7,10 @@
 #define BLUE 4

 #define RESPONSE_OK 1
-#define RESPONSE_RESTART 2
+#define RESPONSE_SCALE_UP 2
+#define RESPONSE_SCALE_DOWN 3
+#define RESPONSE_RESTART 4
+

 SparkButton strip = SparkButton();

@@ -28,10 +31,16 @@
 }

 void loop() {
+    if (strip.buttonOn(1)) {
+        processButton(RESPONSE_SCALE_UP);
+    }
+
     if (strip.buttonOn(2)) {
-        drainResponse = RESPONSE_RESTART;
-        strip.allLedsOn(10, 10, 10);
-        resetAllColors();
+        processButton(RESPONSE_RESTART);
+    }
+
+    if (strip.buttonOn(3)) {
+        processButton(RESPONSE_SCALE_DOWN);
     }

     if (drainResponse == RESPONSE_OK) {
@@ -64,9 +73,12 @@
     }
 }

-void resetAllColors() {
+void processButton(int response) {
+    drainResponse = response;
+    strip.allLedsOn(10, 10, 10);
     for(int i=0; i<12; i++) {
-        current[i] = 99; // flag as dirty
+        // flag as dirty so it will go back to whatever color it was
+        current[i] = 99;
     }
 }


Fix function pointer signature.

Fix function pointer signature.

--- examples/vseg/vseg.ino
+++ examples/vseg/vseg.ino
@@ -117,7 +117,7 @@

   virtual bool inverted() const { return inverted_; }

-  void attach_invert_callback(void (*callback)())
+  void attach_invert_callback(void (*callback)(uint8_t))
   {
     invert_callback_ = callback;
   }


Use ds_addr instead of ds

Use ds_addr instead of ds

--- Examples/ReadAll.ino
+++ Examples/ReadAll.ino
@@ -15,9 +15,9 @@
   ds.begin();
 }

-void sendAddress(DSAddress ds) {
+void sendAddress(DSAddress ds_addr) {
   for(int i = 0 ; i < 8 ; i++) {
-    Serial.print(ds.value[i], HEX);
+    Serial.print(ds_addr.value[i], HEX);
     Serial.print(" ");
   }
   Serial.println();


Clean up the remote IR read function a bit

--- projects/arduino/led_matrix_256/led_matrix_256.ino
+++ projects/arduino/led_matrix_256/led_matrix_256.ino
@@ -16,8 +16,6 @@
 //int sensorPin = A5;    // select the input pin for the potentiometer
 //int sensorValue = 0;  // variable to store the value coming from the sensor

-int j;
-uint32_t i;
 uint8_t d = 0;
 uint8_t b = pow(2,7);
 uint8_t g = pow(2,15);
@@ -97,6 +95,9 @@
     strip.setBrightness(1);
     strip.show(); // Initialize all pixels to 'off'

+
+    Serial.print("Total number of frames: "); Serial.println(MAX_FRAME + 1);
+
 }

 void loop() {
@@ -124,31 +125,36 @@
 }

 uint16_t myRemoteRead() {
-    uint16_t remoteframe=3;
-    Serial.print("remoteframe=");
-    Serial.print(remoteframe);
+    uint16_t remoteFrame = MAX_FRAME + 1; // Start off with an invalid frame to ease debugging
+    uint32_t remoteValue = 0;
+
+    if (irrecv.decode(&results))  {  // have we received an IR signal?
+      remoteValue = results.value;
+
+      switch(remoteValue) {
+        case 0xA3C8EDDB: // + button pressed
+          remoteFrame = 0;
+          break;
+
+        case 0xE5CFBD7F: // - button pressed
+          remoteFrame = 1;
+          break;
+
+        default: // Go here if none of the above buttons are pressed
+          remoteFrame = 2;
+          break;
+      }
+
+      irrecv.resume(); // Receive the next value
+    }
+
+    Serial.print("remoteValue = ");
+    Serial.print(remoteValue);
     Serial.println();
-    if (irrecv.decode(&results)) // have we received an IR signal?
-    {
-//switch(results.value){
-        if(results.value==0xA3C8EDDB) {
-
-//case 0xA3C8EDDB: // + button pressed
-            remoteframe=1;  //set frame to 1 if remote control + button is pressed
-            return remoteframe;
-//break;
-        }
-
-        else if (results.value==0xE5CFBD7F) {
-//case 0xE5CFBD7F: // - button pressed
-            remoteframe=2;  //set frame to 1 if remote control + button is pressed
-            return remoteframe;
-//break;
-        }
-
-//frame=3; //set frame to default 3
-
-    }
-//irrecv.resume(); // receive the next value
-    return remoteframe;
+
+    Serial.print("remoteFrame = ");
+    Serial.print(remoteFrame);
+    Serial.println();
+
+    return remoteFrame;
 }


additional i2c slave code

additional i2c slave code

--- IMUtest.ino
+++ IMUtest.ino
@@ -14,14 +14,15 @@
 // arduino I2C slave address: ensure no conflict with LSM303 or L3G addresses
 const byte slaveAdd = 0x44;
 int registerAddr;
-int data[12];      // I2C data registers 0x00 to 0x0b
+int16_t data[12];      // I2C data registers 0x00 to 0x0b

 // speed settings
 int  msecPerCycle = 50;
 long baud = 115200; // typically 9600, 57600, 115200

 // generally have only one of the following set to TRUE, depending upon task
-bool PRINTSCREEN  = true;   // compare gyro fusion 'on' to gyro fusion 'off',
+bool I2C          = true;   // run in I2C slave mode
+bool PRINTSCREEN  = false;  // compare gyro fusion 'on' to gyro fusion 'off',
                             // user-friendly print of roll, pitch, heading
 bool RPH          = false;  // roll, pitch, heading, formatted for visual python
 bool RPH2         = false;  // compare gyro fusion 'on' to gyro fusion 'off',
@@ -94,13 +95,29 @@
   if (CALIBACC) {withGyro.doCalibrateAcc(CALIB_TEST);}
   if (CALIBMAG) {withGyro.doCalibrateMag(CALIB_TEST);}

-  if (PRINTSCREEN || RPH  || RPH2 || DEVTYPE) {
+  if (PRINTSCREEN || RPH  || RPH2 || DEVTYPE || I2C) {
     withGyro.getRollPitchHeading();
     noGyro.getRollPitchHeading();
     printResults();
   }

   delay(msecPerCycle);
+}
+
+
+void fillI2CRegisters() {
+  data[ 0] = (int16_t)withGyro.roll  >>   8;  // MSB
+  data[ 1] = (int16_t)withGyro.roll  & 0xFF;  // LSB
+  data[ 2] = (int16_t)withGyro.pitch >>   8;
+  data[ 3] = (int16_t)withGyro.pitch & 0xFF;
+  data[ 4] = (int16_t)withGyro.head  >>   8;
+  data[ 5] = (int16_t)withGyro.head  & 0xFF;
+  data[ 6] = (int16_t)noGyro.roll    >>   8;
+  data[ 7] = (int16_t)noGyro.roll    & 0xFF;
+  data[ 8] = (int16_t)noGyro.pitch   >>   8;
+  data[ 9] = (int16_t)noGyro.pitch   & 0xFF;
+  data[10] = (int16_t)noGyro.head    >>   8;
+  data[11] = (int16_t)noGyro.head    & 0xFF;
 }

@@ -111,7 +128,7 @@

 void respondData(){
   byte dataValue = 0x00;  // default value
-  if ((registerAddr >= 0x00) && (registerAddr < 0x0b)) {
+  if ((registerAddr >= 0x00) && (registerAddr < 0x0c)) {
     dataValue = data[registerAddr];
   }
   Wire.write(dataValue);
@@ -120,8 +137,11 @@

 void printResults() {

-  if (PRINTSCREEN)
-  {
+  if (I2C) {
+    fillI2CRegisters();
+  }
+
+  if (PRINTSCREEN) {
    char report[120];
    snprintf(report, sizeof(report),
     "ROLL-NG:%+4d  ROLL:%+4d   PITCH-NG:%+4d  PITCH:%+4d   HEADING-NG:%+4d  HEADING: %+4d",
@@ -131,8 +151,7 @@
    Serial.println(report);
   }

- if (RPH)
-  {
+ if (RPH) {
     Serial.print("RPH ");
     Serial.print((int)withGyro.roll);
     Serial.print(",");
@@ -144,8 +163,7 @@
   }

  // comparison of gyro fusion and no gyro, format for realtimeplotter
- if (RPH2)
-  {
+ if (RPH2) {
     //Serial.print("RPH2 ");
     Serial.print((int)noGyro.roll);
     Serial.print(" ");
@@ -163,8 +181,7 @@
     Serial.println();
   }

- if (DEVTYPE)
- {
+ if (DEVTYPE) {
    Serial.print("Accelerometer & Magnetometer: ");
    Serial.print(withGyro.getMagAccType());
    Serial.print("    Gyro: ");


for IRremoteESP8266 version 2.2.1

for IRremoteESP8266 version 2.2.1

--- minirum/minirum.ino
+++ minirum/minirum.ino
@@ -2,6 +2,8 @@
 #include <ESP8266WebServer.h>
 #include <ESP8266mDNS.h>
 #include <IRremoteESP8266.h>
+#include <IRsend.h>
+#include <IRrecv.h>
 #include <aJSON.h>

 const int send_pin = 12;
@@ -27,13 +29,13 @@
       aJsonObject* freq = aJson.getObjectItem(root, "freq");
       aJsonObject* data = aJson.getObjectItem(root, "data");
       if (freq != NULL && data != NULL) {
-        const int d_size = aJson.getArraySize(data);
-        unsigned int rawData[d_size];
+        const uint16_t d_size = aJson.getArraySize(data);
+        uint16_t rawData[d_size];
         for (int i = 0; i < d_size; i++) {
           aJsonObject* d_int = aJson.getArrayItem(data, i);
           rawData[i] = d_int->valueint;
         }
-        irsend.sendRaw(rawData, d_size, freq->valueint);
+        irsend.sendRaw(rawData, d_size, (uint16_t)freq->valueint);
         irrecv.enableIRIn();
         req = "";
         aJson.deleteItem(root);
@@ -70,7 +72,7 @@
 String dumpIRcode (decode_results *results) {
   String s = "";
   for (int i = 1;  i < results->rawlen;  i++) {
-    s += results->rawbuf[i] * USECPERTICK;
+    s += results->rawbuf[i] * RAWTICK;
     if ( i < results->rawlen - 1 ) s += ",";
   }
   return s;


updates by adding comments and naming melody to PwrRngrs

--- WalkieTalkie/WalkieTalkie.ino
+++ WalkieTalkie/WalkieTalkie.ino
@@ -1,14 +1,18 @@
 /*
-  FILENAME:   walkie talkie basic.ino
-  AUTHOR:     Orlando S. Hoilett
-  CONTACT:    orlandohoilett@gmail.com
-  VERSION:    0.0.0
-  WEBSITE:    http://www.instructables.com/member/ohoilett/
+  FILENAME:       WalkieTalkie.ino
+  AUTHOR:         Orlando S. Hoilett
+  CONTACT:        orlandohoilett@gmail.com
+  VERSION:        2.0
+
+
+  INSTRUCTABLE:   http://www.instructables.com/member/ohoilett/
+  GITHUB:         https://github.com/hoilett/Arduino-Walkie-Talkie-Instructable.git
+  HACKADAY:       https://hackaday.io/project/8598-wristwatch-walkie-talkie

   AFFILIATIONS:
   Institute for Innovation, Creative Exploration, and Personal
-      Development, West Lafayette, IN
+      Development (IICEPD), West Lafayette, IN
   Calvary Engineering, USA
       A group electronics enthusiasts
       "let's have a little fun, and save teh world while we are at it"
@@ -18,11 +22,19 @@
   Version 0.0.0
   2015/11/23:2100>
             Instructables release version.
+  Version 2.0
+  2016/05/30:2322>
+            Includes buzzer for playing Mighty Morphin Power Rangers
+            Communicator notification when called.

   DESCRIPTION
   Simple example for creating a walkie talkie by sending audio
-  using the nRF24L01 RF transceiver module.
+  using the nRF24L01 RF transceiver module. Also uses a call
+  button which plays the Mighty Morphin Power Rangers Communicator
+  notification when pressed for under a specified amount of time.
+  Otherwise, audio is transmitted when Analog In 0 goes LOW. This
+  is handled by the rfAudio library.

   DISCLAIMER
@@ -60,27 +72,19 @@
 #include <RF24.h>
 #include <SPI.h>
 #include <RF24Audio.h>
-#include "printf.h"    // General includes for radio and audio lib
+#include "printf.h"
 #include <MusicPlayer.h>

 RF24 radio(7,8);    // Set radio up using pins 7 (CE) 8 (CS)
 RF24Audio rfAudio(radio,0); // Set up the audio using the radio, and set to radio number 0
-
 const uint8_t callDetector = 3;
-const uint16_t callThreshold = 20; //20% duty cycle?
-//
-//
-//int melody[] = { E6,E6,D6,E6,G6,E6  };
-int melody[] = { E7,E7,D7,E7,G7,E7 };
-
-//unsigned int duration[] = { E, E, E, E, E, E  };
-unsigned int duration[] = { E, E, S, E, E, E  };
-//unsigned int duration[] = { S, S, S, S, S, S };
-
-int melodyPin = 5;
-int melodyLength = 6;

 MusicPlayer myPlayer = MusicPlayer(melodyPin);
+int PwrRngrs[] = { E7,E7,D7,E7,G7,E7 };
+unsigned int duration[] = { E, E, S, E, E, E  };
+int melodyPin = 5;
+const uint8_t melodyLength = 6;
+unsigned long notify = 500;

 void setup() {
@@ -93,32 +97,51 @@

   pinMode(callDetector, INPUT);

-  //sets interrupt to check for call button
-  //attachInterrupt(digitalPinToInterrupt(callDetector), sample, RISING);
-
   //sets the default state for each module to recevie
+  //the RFAudio library has automatically handles, rfAudio.transmit()
+  //when the Analog In 0 goes LOW so no need to add code to activate
+  //rfAudio.transmit();
   rfAudio.receive();
-}
-
-
-//horrible way to use interrupts :)
-void sample()
-{
-  unsigned long time0 = micros();
-  unsigned long i = 0;
-
-  while((micros() - time0) < 2000) //2 milliseconds
-  {
-    if (digitalRead(callDetector)) i++;
-    delayMicroseconds(20);
-  }
-
-  if (i > callThreshold) myPlayer.playMelody(melody, duration, melodyLength);
-  delay(200);
 }

 void loop()
 {
-  if(digitalRead(callDetector)) sample();
+  unsigned long strt = 0;
+  unsigned long fin = 0;
+
+  //The code waits while the call detector pin is LOW (no audio is
+  //being transmitted. When a call is detected, the time marked
+  //and the code waits until transmission is complete again. If
+  //the time for transmission is under 500 ms, then the call
+  //button was pressed as opposed to the talk button and the
+  //sender wanted to issue a call notification. The Mighty Morphin
+  //Power Rangers Communicator tone is played to indicate the
+  //notification.
+  while(!digitalRead(callDetector));
+  strt = millis();
+  while(digitalRead(callDetector));
+  fin = millis();
+  if ((fin - strt) < notify) myPlayer.playMelody(PwrRngrs, duration, melodyLength);
+
+//  while(((PIND>>3)&0x01) == 0)
+//  {
+//    Serial.println("hello world");
+//  }
+//
+//  if(digitalRead(3))
+//  {
+//    strt = millis();
+//    flag = true;
+//  }
+//
+//  while(digitalRead(3));
+//
+//  if(flag) fin = millis();
+//
+//  if (((fin - strt) < 500) && flag)
+//  {
+//    myPlayer.playMelody(melody, duration, melodyLength);
+//    flag = false;
+//  }
 }


Made small changes to taks list and started some functions to be ignored for the time being.

--- WeatherClock/WeatherClock.ino
+++ WeatherClock/WeatherClock.ino
@@ -4,20 +4,21 @@

    List of higher-level tasks:
-    1) Figure out how to perform timed tasks
-      a) Update weather forecast at 45mins
-      b) Update display at 0mins and 30mins
+  - 1) Figure out how to perform timed tasks
+  -   a) Update weather forecast at 45mins
+  -   b) Update display at 0mins and 30mins
     2) Merge NTP into weather code
       a) add way to keep trying until time RX'd first time
       b) count sequential failures and retry if failed x times in a row.
     3) Set up NTP and weather updates to reconnect to Wifi if lost
-    4) Parse hour data from weather forecast to sync DST
-    5) Figure out display cycle timing
-      a) propbably need 2 timers or one and loop
-      b) one timer for next event, need FSM
-      c) other timer for cycling LEDS, less complicated FSM
-      d) actually timers aren't necessary. We can use an FSM in loop. Less overhead, simpiler
-    6) Merge LED code in rest of code
+  - 4) Parse hour data from weather forecast to sync DST
+  - 5) Figure out display cycle timing
+  -   a) propbably need 2 timers or one and loop
+  -   b) one timer for next event, need FSM
+  -   c) other timer for cycling LEDS, less complicated FSM
+  -   d) actually timers aren't necessary. We can use an FSM in loop. Less overhead, simpiler
+    6) Merge LED code into rest of code
+    7) Add not-connected state with LED display mode

 */

@@ -102,7 +103,6 @@
   setSyncProvider(getNtpTime);
   setSyncInterval(300);

-  //  Alarm.timerRepeat(5, updateDisplay);
   /*
     while(timeStatus() == timeNotSet){
       delay(10000);
@@ -264,7 +264,7 @@
 }

 // NTP Functions from TimeNTP_ESP8266WiFi.ino ===============================================
-// Todo trim these down and ifdef print statement
+// Todo trim these down and ifdef print statements

 time_t getNtpTime()
 {
@@ -354,3 +354,28 @@
 #endif

+// Ignore this, I'll come back to it
+/*
+// returns the next int
+int getNextIntFromString(String str, int startIdx){
+  return 0;
+}
+
+int findNextDigit(String str, startIdx){
+  if(startIdx >= str.length()){
+    return -1;
+  }
+
+  for(int idx = startIdx
+
+  char chr = str.charAt(startIdx);
+
+  do {
+
+  } while();
+
+
+  return 0;
+}
+*/
+


lcd.backlight control

lcd.backlight control


icon add

icon add

--- _09_ir_tx_rx/_09_ir_tx_rx.ino
+++ _09_ir_tx_rx/_09_ir_tx_rx.ino
@@ -1,5 +1,6 @@
 /* bugs
 * 001 : initialise_number_select cause reset when called minno ~ maxno loop moret han 3 times
+* 002 : o_tempCinside is not a moving point
 */

 #include <Wire.h>
@@ -76,8 +77,13 @@
 boolean o_tempminpassed = 0;

 // sw status
-int setUpStatus;
-int wrkModeStatus;
+boolean setUpStatus;
+boolean wrkModeStatus;
+boolean tvPowerStatus = 0;
+boolean timerStatus   = 0;
+
+int r   = LOW;
+int o_r = LOW;

 // eeprom status
 boolean o_pwrSrc;
@@ -102,6 +108,55 @@
   B01110,
 };

+
+byte tvicon[8] =
+{
+  B10001,
+  B01010,
+  B00100,
+  B11111,
+  B10001,
+  B10001,
+  B10001,
+  B11111,
+};
+
+byte beepicon[8] =
+{
+  B00000,
+  B11111,
+  B10001,
+  B10101,
+  B10101,
+  B10101,
+  B10001,
+  B00000,
+};
+
+byte timericon[8] =
+{
+  B01110,
+  B10101,
+  B10101,
+  B10101,
+  B10101,
+  B10011,
+  B10001,
+  B01110,
+};
+
+byte powericon[8] =
+{
+  B11111,
+  B11011,
+  B10001,
+  B11011,
+  B11111,
+  B11000,
+  B11000,
+  B11000,
+};
+
 void(* resetFunc) (void) = 0; //declare reset function @ address 0

 void setup()
@@ -161,6 +216,10 @@
   eeprom_read(o_tvOnTime, tvOnTime);
   eeprom_read(o_tvOffTime, tvOffTime);

+  if ( wrkModeStatus == 0 ) {
+    o_wrkMode = wrkModeStatus;
+  }
+
   // temp sensor
   sensors.begin();
   if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
@@ -182,11 +241,37 @@
   lcd.setCursor(6, 0);
   lcd.print((char)223);

+  lcd.createChar(2, tvicon);
+  lcd.createChar(3, beepicon);
+  lcd.createChar(4, timericon);
+  lcd.createChar(5, powericon);
+
+  if ( o_wrkMode == True && o_startMode == True )
+    lcd.setCursor(0, 1);
+    lcd.write(2);
+
+    if ( o_beepMode == True) {
+      lcd.setCursor(1, 1);
+      lcd.write(3);
+    }
+
+    lcd.setCursor(2, 1);
+    lcd.write(4);
+  }
+
 }

 void loop()
 {
+
+  // receiving ir and change status
+  // remote on / off, tv remote on / off
+  decode_results results;
+
+  if (irrecv.decode(&results)) {
+    changemodebyir(&results);
+  }

   if ( (millis() - tempMills) >= 2000 ) {
     getdalastemp();
@@ -203,6 +288,9 @@

   }

+  if ( r != o_r ) {
+    changelcdicon();
+  }

   /*
    *
@@ -232,6 +320,63 @@

 }

+void changelcdicon()
+{
+
+  if ( o_wrkMode == True && o_startMode == True ){
+    lcd.setCursor(0, 1);
+    lcd.write(2);
+
+    if ( o_beepMode == True) {
+      lcd.setCursor(1, 1);
+      lcd.write(3);
+    }
+
+    if ( timerStatus == True) {
+      lcd.setCursor(2, 1);
+      lcd.write(4);
+    }
+  } else {
+    lcd.setCursor(0, 1);
+    lcd.print("    ");
+  }
+
+  if ( tvPowerStatus == True) {
+      lcd.setCursor(3, 1);
+      lcd.write(4);
+  } else {
+    lcd.setCursor(3, 1);
+    lcd.print(" ");
+  }
+
+}
+
+void changemodebyir (decode_results *results)
+{
+  //Serial.println("======> IR code received");
+
+  if ( results->bits > 0 && results->bits == 32 ) {
+    switch (results->value) {
+      case 0xFF02FD: // remote on
+        o_wrkMode = ! o_wrkMode;
+        o_startMode = True;
+        r = !r;
+        break;
+      case 0xFF9867: // remote off
+        timerStatus = ! timerStatus;
+        r = !r;
+        break;
+      case 0x20DF10EF: // tv remore on/off
+        tvPowerStatus = ! tvPowerStatus ;
+        r = !r;
+        break;
+    }
+  }
+  delay(50);
+  irrecv.resume(); // Continue receiving
+}
+
+

 void displayTemperaturedigit(float Temperature)
 {
@@ -272,34 +417,6 @@
     }

   }
-
-
-}
-
-
-
-
-
-
-
-
-
-void  dumpInfo (decode_results *results)
-{
-  // Check if the buffer overflowed
-  if (results->overflow) {
-    Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWLEN");
-    return;
-  }
-
-  if ( results->bits > 0 && results->bits == 32 ) {
-
-    // Show Code & length
-    Serial.print("Code      : ");
-    Serial.println(results->value, HEX);
-  }
-  delay(50);
-  irrecv.resume();
 }

 void getdalastemp()
@@ -318,7 +435,7 @@
   Serial.println("===> alarm_set");

   digitalWrite(BZ_OU_PIN, LOW);
-  delay(100);
+  delay(50);
   digitalWrite(BZ_OU_PIN, HIGH);
 }

@@ -350,6 +467,7 @@
   decode_results results;
   irrecv.resume();
   while (irrecv.decode(&results) != 1 ) { }
+  alarm_set();

   switch (results.value) {
     case 0xFF02FD:
@@ -385,6 +503,7 @@

   irrecv.resume();
   while (irrecv.decode(&results) != 1 ) { }
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -396,6 +515,7 @@

   irrecv.resume();
   while (irrecv.decode(&results) != 1 ) { }
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -404,6 +524,7 @@
   lcd.print("OFF: from other");

   boolean pwrSrc = initialise_boolean_select();
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -415,6 +536,7 @@

   irrecv.resume();
   while (irrecv.decode(&results) != 1 ) { }
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -423,6 +545,7 @@
   lcd.print("OFF: thermo");

   boolean wrkMode = initialise_boolean_select();
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -434,6 +557,7 @@

   irrecv.resume();
   while (irrecv.decode(&results) != 1 ) { }
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -442,6 +566,7 @@
   lcd.print("OFF: do nothing");

   boolean startMode = initialise_boolean_select();
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -453,6 +578,7 @@

   irrecv.resume();
   while (irrecv.decode(&results) != 1 ) { }
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -461,6 +587,7 @@
   lcd.print("OFF: beep off");

   boolean beepMode = initialise_boolean_select();
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -472,6 +599,7 @@

   irrecv.resume();
   while (irrecv.decode(&results) != 1 ) { }
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -480,6 +608,7 @@
   lcd.print("OFF: IN change");

   boolean offMode = initialise_boolean_select();
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -491,6 +620,7 @@

   irrecv.resume();
   while (irrecv.decode(&results) != 1 ) { }
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -499,6 +629,7 @@
   lcd.print("OFF: done");

   int channelGap = initialise_number_select(1, 5, 1, 1);
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -510,6 +641,7 @@

   irrecv.resume();
   while (irrecv.decode(&results) != 1 ) { }
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -518,6 +650,7 @@
   lcd.print("OFF: done");

   int tvOnTime = initialise_number_select(30, 90, 50, 5);
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -529,6 +662,7 @@

   irrecv.resume();
   while (irrecv.decode(&results) != 1 ) { }
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -537,6 +671,7 @@
   lcd.print("OFF: done");

   int tvOffTime = initialise_number_select(5, 20, 10, 5);
+  alarm_set();

   //
   boolean initialise_eeprom_done =  initialise_eeprom(pwrSrc, wrkMode, startMode, beepMode, offMode, channelGap, tvOnTime, tvOffTime) ;
@@ -555,6 +690,7 @@

   irrecv.resume();
   while (irrecv.decode(&results) != 1 ) { }
+  alarm_set();

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -564,7 +700,9 @@

   irrecv.resume();
   while (irrecv.decode(&results) != 1 ) { }
-
+  alarm_set();
+  alarm_set();
+  alarm_set();
 }

@@ -580,6 +718,8 @@
   eeprom_write(i_tvOffTime, tvOffTime);
   eeprom_write(magic_number, magic);

+  alarm_set();
+  alarm_set();
   return 1;
 }


status update

status update

--- _85-doorbot2/_85-doorbot2.ino
+++ _85-doorbot2/_85-doorbot2.ino
@@ -70,6 +70,7 @@
   root["channel"] = SLACK_CHANNEL;

   String msg = "door status : ";
+  door_status = digitalRead(DOOR_PIN);
   if (door_status) {
     msg += "open";
   } else {
@@ -92,6 +93,7 @@
   root["channel"] = SLACK_CHANNEL;

   String msg = "pir status : ";
+  pir_status = digitalRead(PIR_PIN);
   if (pir_status) {
     msg += "detected";
   } else {


Updated the DumpInfo example

Updated the DumpInfo example

--- examples/DumpInfo/DumpInfo.ino
+++ examples/DumpInfo/DumpInfo.ino
@@ -1,44 +1,57 @@
 /*
- * MFRC522 - Library to use ARDUINO RFID MODULE KIT 13.56 MHZ WITH TAGS SPI W AND R BY COOQROBOT.
- * The library file MFRC522.h has a wealth of useful info. Please read it.
- * The functions are documented in MFRC522.cpp.
- *
- * Based on code Dr.Leong   ( WWW.B2CQSHOP.COM )
- * Created by Miguel Balboa (circuitito.com), Jan, 2012.
- * Rewritten by Søren Thing Andersen (access.thing.dk), fall of 2013 (Translation to English, refactored, comments, anti collision, cascade levels.)
+ * ----------------------------------------------------------------------------
+ * This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid
+ * for further details and other examples.
+ *
+ * NOTE: The library file MFRC522.h has a lot of useful info. Please read it.
+ *
  * Released into the public domain.
- *
- * Sample program showing how to read data from a PICC using a MFRC522 reader on the Arduino SPI interface.
- *----------------------------------------------------------------------------- empty_skull
- * Aggiunti pin per arduino Mega
- * add pin configuration for arduino mega
- * http://mac86project.altervista.org/
- ----------------------------------------------------------------------------- Nicola Coppola
- * Pin layout should be as follows:
- * Signal     Pin              Pin               Pin
- *            Arduino Uno      Arduino Mega      MFRC522 board
+ * ----------------------------------------------------------------------------
+ * Example sketch/program showing how to read data from a PICC (that is: a RFID
+ * Tag or Card) using a MFRC522 based RFID Reader on the Arduino SPI interface.
+ *
+ * When the Arduino and the MFRC522 module are connected (see the pin layout
+ * below), load this sketch into Arduino IDE then verify/compile and upload it.
+ * To see the output: use Tools, Serial Monitor of the IDE (hit Ctrl+Shft+M).
+ * When you present a PICC (that is: a RFID Tag or Card) at reading distance
+ * of the MFRC522 Reader/PCD, the output will show the ID, type and any data
+ * blocks it can read. Note that you may see some "Timeout in communication"
+ * messages when removing the PICC from reading distance to early.
+ *
+ * If your reader supports it, this sketch/program will read all the PICCs
+ * presented (that is: multiple tag reading). So if you stack* two or more
+ * PICCs on top of each other and present them to the reader, it will first
+ * output all details of the first and then the next PICC. Note that this
+ * may take some time as all data blocks are dumped, so keep the PICCs at
+ * reading distance until complete.
+ *
+ * Typical pin layout used:
  * ------------------------------------------------------------
- * Reset      9                5                 RST
- * SPI SS     10               53                SDA
- * SPI MOSI   11               51                MOSI
- * SPI MISO   12               50                MISO
- * SPI SCK    13               52                SCK
- *
- * The reader can be found on eBay for around 5 dollars. Search for "mf-rc522" on ebay.com.
+ *             MFRC522      Arduino   Arduino   Arduino
+ *             Reader/PCD   Uno       Mega      Nano v3
+ * Signal      Pin          Pin       Pin       Pin
+ * ------------------------------------------------------------
+ * RST/Reset   RST          9         5         D9
+ * SPI SS      SDA          10        53        D10
+ * SPI MOSI    MOSI         11        51        D11
+ * SPI MISO    MISO         12        50        D12
+ * SPI SCK     SCK          13        52        D13
  */

 #include <SPI.h>
 #include <MFRC522.h>

-#define SS_PIN 10
-#define RST_PIN 9
-MFRC522 mfrc522(SS_PIN, RST_PIN);	// Create MFRC522 instance.
+#define RST_PIN		9		//
+#define SS_PIN		10		//
+
+MFRC522 mfrc522(SS_PIN, RST_PIN);	// Create MFRC522 instance

 void setup() {
-	Serial.begin(9600);	// Initialize serial communications with the PC
+	Serial.begin(9600);		// Initialize serial communications with the PC
 	SPI.begin();			// Init SPI bus
-	mfrc522.PCD_Init();	// Init MFRC522 card
-	Serial.println("Scan PICC to see UID and type...");
+	mfrc522.PCD_Init();		// Init MFRC522
+	ShowReaderDetails();	// Show details of PCD - MFRC522 Card Reader details
+	Serial.println("Scan PICC to see UID, type, and data blocks...");
 }

 void loop() {
@@ -52,6 +65,24 @@
 		return;
 	}

-	// Dump debug info about the card. PICC_HaltA() is automatically called.
+	// Dump debug info about the card; PICC_HaltA() is automatically called
 	mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
 }
+
+void ShowReaderDetails() {
+	// Get the MFRC522 software version
+	byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
+	Serial.print("MFRC522 Software Version: 0x");
+	Serial.print(v, HEX);
+	if (v == 0x91)
+		Serial.print(" = v1.0");
+	else if (v == 0x92)
+		Serial.print(" = v2.0");
+	else
+		Serial.print(" (unknown)");
+	Serial.println("");
+	// When 0x00 or 0xFF is returned, communication probably failed
+	if ((v == 0x00) || (v == 0xFF)) {
+		Serial.println("WARNING: Communication failure, is the MFRC522 properly connected?");
+	}
+}


increase samples and printing

increase samples and printing

--- examples/adc_test/adc_test.ino
+++ examples/adc_test/adc_test.ino
@@ -48,7 +48,7 @@
 uint8_t adc_pins_dig[] = {A0,A1,A2,A3,A4,A5,A6,A7,A8, A9, A12,A13,A14,A15,A16,A17,A18,A19,A20,A23,A24};
 uint8_t adc_pins_diff[] = {A10, A11};

-#elif defined(ADC_TEENSY_4)  // Teensy 3.6
+#elif defined(ADC_TEENSY_4)  // Teensy 4
 #define PINS 14
 #define DIG_PINS 10
 #define PINS_DIFF 0
@@ -152,29 +152,33 @@
 bool test_averages() {
     elapsedMicros timeElapsed;
     bool pass_test = true;
-    const uint32_t num_samples = 100;
+    const uint32_t num_samples = 10000;
     const uint8_t averages[] = {4, 8, 16, 32};
     float avg_times[4];
+    volatile int value = 0;

     adc->setAveraging(1);
     timeElapsed = 0;
     for(uint32_t i=0; i<num_samples; i++) {
-        adc->analogRead(A0, ADC_0);
-    }
-    float one_avg_time = timeElapsed/num_samples;
-    //Serial.print("1: "); Serial.println(one_avg_time);
+        value += adc->analogRead(A0, ADC_0);
+    }
+    float one_avg_time = (float)timeElapsed/num_samples;
+//    Serial.print("1: "); Serial.println(one_avg_time);
+//    Serial.print("value: "); Serial.println(value/num_samples);

     for(uint8_t i=0; i<4; i++) {
         adc->setAveraging(averages[i]);
         timeElapsed = 0;
+        value = 0;
         for(uint32_t j=0; j<num_samples; j++) {
-            adc->analogRead(A0, ADC_0);
+            value += adc->analogRead(A0, ADC_0);
         }
         float time = (float)timeElapsed/num_samples;
         avg_times[i] = time;
-        //Serial.print(averages[i]); Serial.print(": "); Serial.print(time);
-        //Serial.print(", "); Serial.println(time/one_avg_time);
+//        Serial.print(averages[i]); Serial.print(": "); Serial.print(time);
+//        Serial.print(", "); Serial.println(time/one_avg_time);
+//        Serial.print("value: "); Serial.println(value/num_samples);
     }

     // the 4 averages is not 4 times as long as the 1 average because
@@ -190,7 +194,7 @@
     for(uint8_t i=1; i<4; i++) {
         if((avg_times[i] < 2*0.9*avg_times[i-1]) || (avg_times[i] > 2*1.1*avg_times[i-1])) {
             pass_test = false;
-            Serial.print(averages[i]); Serial.print(" averages should take about twice as long as "); Serial.print(pow(2, i-1), 0);
+            Serial.print(averages[i]); Serial.print(" averages should take about twice as long as "); Serial.print(averages[i-1]);
             Serial.print(", but it took "); Serial.print(avg_times[i]/avg_times[i-1]); Serial.println(" times longer.");
         }
     }
@@ -258,9 +262,10 @@
     Serial.print("COMPARE RANGE TEST "); Serial.println(compare_range_test ? "PASS" : "FAIL");
     bool averages_test = test_averages();
     Serial.print("AVERAGES TEST "); Serial.println(averages_test ? "PASS" : "FAIL");
-}
-
-
+    if (pullup_test & pulldown_test & compare_test & compare_range_test & averages_test) {
+      Serial.println("ALL TEST PASSED.");
+    }
+}

 void loop() {


changed to i2c drive

changed to i2c drive

--- arduino/serial_turret_test/serial_turret_test.ino
+++ arduino/serial_turret_test/serial_turret_test.ino
@@ -1,5 +1,7 @@
 #include <ax12.h>
 #include <BioloidController.h>
+#include <Wire.h>
+

 #define BAUDRATE 9600
 #define PAN 1
@@ -24,15 +26,21 @@
     turret.interpolateStep();
     delay(3);
   }
+  Wire.begin(17); // join i2cbus with SDA on digital pin 17
+  Wire.onReceive(receiveEvent);
+}
+
+void loop() {
+    delay( 100 );
 }

 // 1-9 map to tilt
 // a-z map to pan
 // esc to quit

-void loop() {
-  if ( Serial.available() > 0 ) {
-     unsigned char inByte = Serial.read();
+void receiveEvent(int howMany) {
+  while( Wire.available() ) {
+     unsigned char inByte = Wire.read();

       if ( inByte >= 'a' && inByte <= 'z' ) {
           int pan = inByte - 'a';
@@ -40,6 +48,8 @@
           pan /= 'z' - 'a';
           pan = (pan>1023)?1023:pan;
           SetPosition(PAN,pan);
+          Serial.print("pan: ");
+          Serial.println( pan );
       }

       if ( inByte >= '1' && inByte <= '9' ) {
@@ -50,8 +60,9 @@
           tilt = (tilt>TILT_MAX)?TILT_MAX:tilt;
           tilt = (tilt<TILT_MIN)?TILT_MIN:tilt;
           SetPosition(TILT,tilt);
+          Serial.print("tilt: ");
+          Serial.println( tilt );
       }
   }
 }
-
-
+


Fix buffer swapping bug which caused tearing

--- avr/avr.ino
+++ avr/avr.ino
@@ -20,11 +20,16 @@
 uint8_t col_i = 0;
 uint8_t row_i = 0;
 int buf_i = 0;
+volatile uint8_t may_flip = 0;

 void buf_swap(void) {
 	uint8_t *tmp = buf_front;
 	buf_front = buf_back;
 	buf_back = tmp;
+	if (may_flip) {
+		Serial.write('S');
+		may_flip = 0;
+	}
 }

 void setup() {
@@ -52,12 +57,13 @@
 	}

 	// Store the data to back buffer
+	may_flip = false;
 	buf_back[buf_i++] = data;

 	// If we have reached the end of frame, flip buffers
 	if (buf_i == sizeof(buf_a)) {
 		buf_i = 0;
-		buf_swap();
+		may_flip = true;
 		Serial.write('K');
 	}
 }
@@ -91,7 +97,12 @@
 	if (col_i > 7) {
 		col_i = 0;
 		row_i++;
-		if (row_i > 6) row_i = 0;
+		if (row_i > 6) {
+			row_i = 0;
+			if (may_flip) {
+				buf_swap();
+			}
+		}
 	}

 	// Column driver latches on rising edge so we can already pull


Yellow strategy is OK (LaB)

Yellow strategy is OK (LaB)

--- pug.ino
+++ pug.ino
@@ -133,6 +133,18 @@
   delay(rotateTimeLeft);
   stopMotors();
 }
+
+// Vitesse entre 0 et 100
+void goBackward(int vitesse){
+  setLeftSpeed(-vitesse);
+  setRightSpeed(-vitesse);
+      }
+
+      // Vitesse entre 0 et 100
+void goForward(int vitesse){
+  setLeftSpeed(vitesse);
+  setRightSpeed(vitesse);
+      }

 // Servo control methods
 void smoothSploch () {
@@ -218,6 +230,30 @@
     prepareToStart();
     Serial.println("Retirer le jumper...");
     while(digitalRead(JUMPER));
+    smoothSploch();
+    Serial.println("Descente!");
+    Serial.println("Calibrage en cours...");
+    goBackward(35);
+    delay(3000);
+    stopMotors();
+
+    goForward(30);
+    delay(1800);
+    goForward(1);
+    delay(500);
+    stopMotors();
+    delay(1000);
+    rotateRight();
+    delay(1000);
+    goBackward(60);
+    delay(900);
+    goBackward(1);
+    delay(100);
+    stopMotors();
+
+
+
+    Serial.println("Calibrage OK!");

     endScript = true;


WDRC_8BandFIr_Stereo_Prescrip_wApp: enable highspeed BT

--- examples/05-FullSystems/WDRC_8BandFIR_Stereo_Prescrip_wApp/WDRC_8BandFIR_Stereo_Prescrip_wApp.ino
+++ examples/05-FullSystems/WDRC_8BandFIR_Stereo_Prescrip_wApp/WDRC_8BandFIR_Stereo_Prescrip_wApp.ino
@@ -130,6 +130,7 @@
   setupAudioProcessing(); //see function in ConfigureAlgorithms.h

   //setup BLE
+  ble.setUseFasterBaudRateUponBegin(true); //speeds up baudrate to 115200.  ONLY WORKS FOR ANDROID.  If iOS, you must set to false.
   delay(500); ble.setupBLE(myTympan.getBTFirmwareRev()); delay(500); //Assumes the default Bluetooth firmware. You can override!

   //setup the serial manager


Make arduino_io compatible with Arduino Mega boards

Using slower reading, but only using standard arduino functionality.

--- arduino/libraries/SequantoAutomation/examples/arduino_io/arduino_io.ino
+++ arduino/libraries/SequantoAutomation/examples/arduino_io/arduino_io.ino
@@ -11,12 +11,12 @@
  * name arduino_io
  * property /sequanto_automation_version sequanto_automation_version
  *
- * property /digital/(2..13)/direction digital_direction_get digital_direction_set
- * property /digital/(2..13)/pin digital_pin_get digital_pin_set
- * property /digital/(2..13)/counter digital_counter_get digital_counter_set
- * property /digital/(2..13)/counter_enabled digital_counter_enabled_get digital_counter_enabled_set
- * property /digital/(2..13)/count_on_high2low digital_counter_high2low_get digital_counter_high2low_set
- * property /digital/(2..13)/count_on_low2high digital_counter_low2high_get digital_counter_low2high_set
+ * property /digital/(2..54)/direction digital_direction_get digital_direction_set
+ * property /digital/(2..54)/pin digital_pin_get digital_pin_set
+ * #property /digital/(2..54)/counter digital_counter_get digital_counter_set
+ * #property /digital/(2..54)/counter_enabled digital_counter_enabled_get digital_counter_enabled_set
+ * #property /digital/(2..54)/count_on_high2low digital_counter_high2low_get digital_counter_high2low_set
+ * #property /digital/(2..54)/count_on_low2high digital_counter_low2high_get digital_counter_low2high_set
  *
  * # property /digital/(0..14)/mode digital_mode_get digital_mode_set
  * # property /digital/(0..14)/counter digital_counter_get digital_counter_set
@@ -31,8 +31,11 @@

 /* Skip the first two pins, they are used by the USB port for communication. */
 #define PIN_OFFSET 2
-#define NUMBER_OF_PINS 14
-#define IO_MASK 0x3FFC
+#ifdef  ARDUINO_AVR_MEGA2560
+#define NUMBER_OF_PINS 54
+#else
+#define NUMBER_OF_PINS 13
+#endif

 static char buff[10];

@@ -48,34 +51,25 @@
 };

 static int s_counters[NUMBER_OF_PINS];
-
-
-static unsigned int io_direction = 0;   // All input on startup; for safety reasons.
-static unsigned int io_last_read = IO_MASK; // Pull-up on all; all high on startup.
-static unsigned int io_last_written = 0;    // Pull-up on all; all high on startup.
-static unsigned int io_counter_enable = 0;  // No counters enabled
-static unsigned int io_trig_h2l = IO_MASK;  // default counter edge
-static unsigned int io_trig_l2h = 0;
+static SQBool io_direction[NUMBER_OF_PINS];
+static SQBool io_last_read[NUMBER_OF_PINS];
+static SQBool io_last_written[NUMBER_OF_PINS];
+static SQBool io_counter_enable[NUMBER_OF_PINS];
+static SQBool io_trig_h2l[NUMBER_OF_PINS];
+static SQBool io_trig_l2h[NUMBER_OF_PINS];

 static const char DIGITAL_PIN_INPUT_TEXT[] SQ_CONST_VARIABLE = "Input";
 static const char DIGITAL_PIN_OUTPUT_TEXT[] SQ_CONST_VARIABLE = "Output";

-void update_direction_mask( void )
-{
-    io_direction = (DDRD | (((unsigned int)DDRB) << 8 )) & IO_MASK;
-}
-
-#define PIN_MASK(pin) (((unsigned int)1) << pin)
-
 SQBool digital_pin_get ( int _pin )
 {
-    if ((io_direction& PIN_MASK(_pin)) != 0)
-    {
-        return ((io_last_written & PIN_MASK(_pin)) != 0);
+    if ( io_direction[_pin] == SQ_TRUE )
+    {
+      return io_last_written[_pin];
     }
     else
     {
-        return ((io_last_read & PIN_MASK(_pin)) != 0);
+      return io_last_read[_pin];
     }
 }

@@ -84,7 +78,7 @@
     //if ((io_direction& PIN_MASK(_pin)) != 0)
     {
         digitalWrite ( _pin, _value == SQ_TRUE ? HIGH : LOW );
-        io_last_written = (io_last_written & (~(PIN_MASK(_pin)))) | (_value >> _pin);
+        io_last_written[_pin] = _value;
         //sq_digital_pin_updated ( _pin, _value );
     }
     /*
@@ -97,8 +91,7 @@

 const char * digital_direction_get ( int _pin )
 {
-    update_direction_mask();
-    if ( io_direction & PIN_MASK(_pin) )
+    if ( io_direction[_pin] == SQ_TRUE )
     {
         sq_get_constant_string_copy(DIGITAL_PIN_OUTPUT_TEXT, buff);
     }
@@ -133,14 +126,15 @@
         /* Set pull-up resistor. */
         digitalWrite ( _pin, HIGH );
         //sq_digital_pin_updated ( _pin, digital_pin_get(_pin) );
+        io_direction[_pin] = SQ_FALSE;
         break;

     case DIGITAL_PIN_OUTPUT:
         pinMode ( _pin, OUTPUT );
         digitalWrite ( _pin, LOW );
+        io_direction[_pin] = SQ_TRUE;
         break;
     }
-    update_direction_mask();
 }

 int digital_counter_get ( int _pin )
@@ -155,35 +149,32 @@

 SQBool digital_counter_enabled_get ( int _pin )
 {
-    return ((io_counter_enable & PIN_MASK(_pin)) != 0) ? SQ_TRUE : SQ_FALSE;
+    return io_counter_enable[_pin];
 }

 void digital_counter_enabled_set ( int _pin, SQBool _value )
 {
-    unsigned int mask = PIN_MASK(_pin);
-    io_counter_enable = (io_counter_enable & ~mask) | ((_value == SQ_TRUE) ? mask : 0);
+    io_counter_enable[_pin] = _value;
 }

 SQBool digital_counter_high2low_get ( int _pin )
 {
-    return ((io_trig_h2l & PIN_MASK(_pin)) != 0) ? SQ_TRUE : SQ_FALSE;
+    return io_trig_h2l[_pin];
 }

 void digital_counter_high2low_set ( int _pin, SQBool _value )
 {
-    unsigned int mask = PIN_MASK(_pin);
-    io_trig_h2l= (io_trig_h2l & ~mask) | ((_value == SQ_TRUE) ? mask : 0);
+    io_trig_h2l[_pin] = _value;
 }

 SQBool digital_counter_low2high_get ( int _pin )
 {
-    return ((io_trig_l2h & PIN_MASK(_pin)) != 0) ? SQ_TRUE : SQ_FALSE;
+    return io_trig_l2h[_pin];
 }

 void digital_counter_low2high_set ( int _pin, SQBool _value )
 {
-    unsigned int mask = PIN_MASK(_pin);
-    io_trig_l2h = (io_trig_l2h & ~mask) | ((_value == SQ_TRUE) ? mask : 0);
+    io_trig_l2h[_pin] = _value;
 }

 int analog_in_get_value ( int _pin )
@@ -218,32 +209,46 @@
         pinMode ( i, INPUT);
         digitalWrite ( i, HIGH );   // pull-up
         s_counters[i] = 0;
+        io_direction[i] = SQ_FALSE;
+        io_last_read[i] = SQ_FALSE;
+        io_last_written[i] = SQ_FALSE;
+        io_counter_enable[i] = SQ_FALSE;
+        io_trig_h2l[i] = SQ_TRUE;
+        io_trig_l2h[i] = SQ_FALSE;
     }
     SequantoAutomation::init();
 }

-unsigned int inputs = PIND | (((unsigned int)PINB) << 8 );
-unsigned int changed, trigged = 0;
+//unsigned int inputs = PIND | (((unsigned int)PINB) << 8 );
+//unsigned int changed, trigged = 0;

 void loop ( void )
 {
     int i;
     SequantoAutomation::poll();
-
-    inputs = (PIND | (((unsigned int)PINB) << 8 )) & (~io_direction);
-    changed = inputs ^ io_last_read;
-    trigged = changed & io_counter_enable & (((io_trig_h2l ^ inputs ) & io_trig_h2l) | (((~io_trig_l2h) ^ inputs ) & io_trig_l2h));
-    io_last_read = inputs;
-
+
     for ( i = PIN_OFFSET ; i < NUMBER_OF_PINS ; i++ )
     {
-        if ( ( changed & PIN_MASK(i) ) != 0 )
+        if ( io_direction[i] == SQ_FALSE )
         {
-            //sq_digital_pin_updated ( i, digital_pin_get(i) );
-        }
-        if ( ( trigged & PIN_MASK(i) ) != 0 )
-        {
-            s_counters[i]++;
+          SQBool read = digitalRead(i) == HIGH ? SQ_TRUE : SQ_FALSE;
+          if ( read != io_last_read[i] )
+          {
+             //sq_digital_pin_updated ( i, digital_pin_get(i) );
+
+            if ( io_counter_enable[i] == SQ_TRUE )
+            {
+              if ( read == SQ_FALSE && io_trig_h2l[i] == SQ_TRUE )
+              {
+                  s_counters[i]++;
+              }
+              if ( read == SQ_TRUE && io_trig_l2h[i] == SQ_TRUE )
+              {
+                  s_counters[i]++;
+              }
+            }
+            io_last_read[i] = read;
+          }
         }
     }
 }


completed board v1

completed board v1

--- Testbench/Motor_Shield_Testbench/MotorShieldTestBench_Master/MotorShieldTestBench_Master.ino
+++ Testbench/Motor_Shield_Testbench/MotorShieldTestBench_Master/MotorShieldTestBench_Master.ino
@@ -5,7 +5,7 @@
 const int leftDir = 18;
 const int lSpeed = A9;

-const int led = 78;
+const int led = 1;

 const int lSelect = 67;
 const int rSelect = 75;
@@ -48,8 +48,8 @@
   pinMode(leftDir, INPUT);
   pinMode(lSpeed, INPUT);

-  pinMode(select, OUTPUT);
-  digitalWrite(select, HIGH);
+  pinMode(lSelect, OUTPUT);
+  digitalWrite(lSelect, HIGH);
 }

 void loop()
@@ -58,14 +58,14 @@
   {
     if (desiredSpeedR[i] < 0)
     {
-      digitalWrite(select, LOW);
+      digitalWrite(lSelect, LOW);
     }
     Wire.beginTransmission(7);
-    Wire.write(abs(desiredSpeedL[i] * 100 * ticksPerMile));
+    Wire.write(2);
     Wire.endTransmission();

     Wire.beginTransmission(8);
-    Wire.write(abs(desiredSpeedR[i] * 100 * ticksPerMile));
+    Wire.write(2);
     Wire.endTransmission();

     delay(1000);
@@ -75,7 +75,7 @@
     leftSpeed[i] = analogRead(lSpeed);
     rightSpeed[i] = analogRead(rSpeed);

-    digitalWrite(select, HIGH);
+    digitalWrite(lSelect, HIGH);
   }

   for (int i = 0; i < 11; i ++)


IRMQTTServer: Fix compile error when `MQTT_ENABLE` is false. (#933)

--- examples/IRMQTTServer/IRMQTTServer.ino
+++ examples/IRMQTTServer/IRMQTTServer.ino
@@ -649,13 +649,6 @@
   for (int16_t i = 0; i < kNrOfIrTxGpios; i++)
     if (txGpioTable[i] != kGpioUnused) return txGpioTable[i];
   return kGpioUnused;
-}
-
-String genStatTopic(const uint16_t channel) {
-  if (channel)  // Never use the '*_0' state channel.
-    return MqttClimate + "_" + String(channel) + '/' + MQTT_CLIMATE_STAT + '/';
-  else
-    return MqttClimate + '/' + MQTT_CLIMATE_STAT + '/';
 }

 // Return a string containing the comma separated list of sending gpios.
@@ -2225,6 +2218,13 @@
 }

 #if MQTT_ENABLE
+String genStatTopic(const uint16_t channel) {
+  if (channel)  // Never use the '*_0' state channel.
+    return MqttClimate + "_" + String(channel) + '/' + MQTT_CLIMATE_STAT + '/';
+  else
+    return MqttClimate + '/' + MQTT_CLIMATE_STAT + '/';
+}
+
 // MQTT subscribing to topic
 void subscribing(const String topic_name) {
   // subscription to topic for receiving data with QoS.


Example updated — TimerSerial.h no longer needed

--- examples/3.Analog/AnalogInput_InternalThermometer_430/AnalogInput_InternalThermometer_430.ino
+++ examples/3.Analog/AnalogInput_InternalThermometer_430/AnalogInput_InternalThermometer_430.ino
@@ -15,16 +15,14 @@
 //   Rei VILO, Mar 13, 2012 - More precise algorithm
 //   Rei VILO, Mar 14, 2012 - Average
 //   Rei VILO, May 21, 2012 - Updated with GREEN_LED, RED_LED and PUSH2
+//   Rei VILO, Sep 09, 2012 - TimerSerial.h no longer required
 //   Press push 2 to end
 //   Tested on msp430g2452 and msp430g2553
 //   2196 bytes

-#include <TimerSerial.h>
-
 // RED_LED, GREEN_LED, TEMPSENSOR, PUSH2 already defined
 #define NUMBER 4 // take number / 2

-TimerSerial mySerial;
 int ledState = HIGH;
 uint8_t i = 0;
 uint32_t average = 0;
@@ -39,16 +37,16 @@
   analogReference(INTERNAL1V5);
   analogRead(TEMPSENSOR); // first reading usually wrong

-  mySerial.begin();
+  Serial.begin(9600);
   pinMode(PUSH2, INPUT_PULLUP);

   digitalWrite(RED_LED, HIGH);
   digitalWrite(GREEN_LED, LOW);

-  mySerial.print("\n\n\n*** MSP430 Thermometer \n");
-  mySerial.print("Press PUSH2 to end\n");
-  mySerial.print("instant\taverage\n");
+  Serial.print("\n\n\n*** MSP430 Thermometer \n");
+  Serial.print("Press PUSH2 to end\n");
+  Serial.print("instant\taverage\n");

   for (j=0; j<NUMBER; j++) values[j]=0;
   average = 0;
@@ -56,9 +54,9 @@
 }

 void printDec(uint32_t ui) {
-  mySerial.print(ui/10, DEC);
-  mySerial.print(".");
-  mySerial.print(ui%10, DEC);
+  Serial.print(ui/10, DEC);
+  Serial.print(".");
+  Serial.print(ui%10, DEC);
 }

@@ -77,11 +75,11 @@

     // Print measure
     printDec(values[j]);
-    mySerial.print("\t");
+    Serial.print("\t");

     // Print average
     if (flag) printDec(average/NUMBER);
-    mySerial.print("\n");
+    Serial.print("\n");

     j++;
     if (j==NUMBER) flag=true;
@@ -89,8 +87,8 @@
   }

   if (digitalRead(PUSH2)==LOW) {
-    mySerial.print("\n\n*** End \n");
-    mySerial.end();
+    Serial.print("\n\n*** End \n");
+    Serial.end();
     while(true); // endless loop
   }
   delay(100);


v1.5 Add On-board LED

v1.5 Add On-board LED

--- GPSLCD.ino
+++ GPSLCD.ino
@@ -35,6 +35,8 @@
   // Selects either altitude or the date/time to be displayed
   pinMode(ALTITUDE_DATE_TIME_SW, INPUT);
 #endif
+  pinMode (ON_BOARD_LED, OUTPUT); // Turn off on-board LED
+  digitalWrite (ON_BOARD_LED, LOW); //       "

   GPSModule.begin(9600); // This opens up communications to the software serial tx and rx lines
   GPSModule.flush();


Delete GPSLCD.ino

Delete GPSLCD.ino

--- GPSLCD.ino
+++ GPSLCD.ino
@@ -1,612 +0,0 @@
-/* GPS LCD
-
-  By GK Grotsky
-  8/30/16
-
-  This program communicate with the u-blox NEO-6M GPS module
-  through a software serial interface. It then displays certain GPS
-  parameters on a I2C 20x4 character LCD display module. The
-  GPS messages are received by the on-board Arduino UART circuit using
-  the SoftwareSerial library. It then uses the TinyGPS++ library to
-  decode the GPS NMEA messages. The parameters are then displayed on a
-  20x4 LCD using the LiquidCrystal_I2C library.
-
-  https://github.com/Grommet123/GPSLCD
-
-  The MIT License (MIT)
-
-  Permission is hereby granted, free of charge, to any person obtaining a copy
-  of this software and associated documentation files (the "Software"), to deal
-  in the Software without restriction, including without limitation the rights
-  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-  copies of the Software, and to permit persons to whom the Software is
-  furnished to do so, subject to the following conditions:
-
-  The above copyright notice and this permission notice shall be included in all
-  copies or substantial portions of the Software.
-
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-  SOFTWARE.
-
-*/
-
-#include "GPSLCD.h"
-#include <TinyGPS++.h>
-#include <SoftwareSerial.h>
-#include <LiquidCrystal_I2C.h>
-
-TinyGPSPlus gps; // This is the GPS object that will pretty much do all the grunt work with the NMEA data
-SoftwareSerial GPSModule(10, 11); // RX, TX
-// Initializes class variables and defines the I2C address of the LCD
-LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);
-
-// The setup (runs once at start up)
-void setup()
-{
-  pinMode(BACKLIGHT_SW, INPUT);
-  // Selects either altitude or the date/time to be displayed
-  pinMode(ALTITUDE_DATE_TIME_SW, INPUT);
-  // Select switches
-  pinMode(DISPLAY_12_HOUR_SW, INPUT);
-  pinMode(CONVERT_TO_LOCAL_SW, INPUT);
-  pinMode(DISPLAY_HDOP_SW, INPUT);
-  pinMode(CARDINAL_SW, INPUT);
-  pinMode(LOW_SPEED_OVERRIDE, INPUT);
-  pinMode(ON_BOARD_LED, OUTPUT); // Turn off on-board LED
-  digitalWrite(ON_BOARD_LED, LOW); //       "
-
-  GPSModule.begin(9600); // This opens up communications to the software serial tx and rx lines
-  GPSModule.flush();
-
-  lcd.begin(COLUMN, ROW); // Defines LCD type
-  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE); // Sets the pin to control the backlight
-  lcd.clear(); // Clear the LCD
-  lcd.home(); // Go to the home position on the LCD
-} // setup
-
-// The loop (runs forever and a day :-))
-void loop()
-{
-  static uint32_t pastSatellites = 0;
-  static uint8_t initializingCounter = 0;
-  static unsigned long prevInitializationTime = INITIALIZATION_INTERVAL;
-  static unsigned long prevCreditTime = TOGGLETIME_INTERVAL;
-  static unsigned long prevInvalidSatellitesTime = TOGGLETIME_INTERVAL;
-  static bool leftInitialization = false;
-  static bool creditToggle = true;
-  static bool invalidSatellitesToggle = true;
-  static unsigned long prevDateTime = TOGGLETIME_INTERVAL;
-  static unsigned long prevHeadingTime = TOGGLETIME_INTERVAL;
-  static unsigned long prevHdopTime = TOGGLETIME_INTERVAL;
-  static bool dateTimeToggle = true;
-  static bool headingToggle = true;
-  static bool hdopToggle = true;
-  bool display12_24_Hour = !digitalRead(DISPLAY_12_HOUR_SW);
-  bool localUTCTimeDate = !digitalRead(CONVERT_TO_LOCAL_SW);
-  bool displayHdop = !digitalRead(DISPLAY_HDOP_SW);
-  bool cardinal8_16 = !digitalRead(CARDINAL_SW);
-  bool lowSpeedOverride = !digitalRead(LOW_SPEED_OVERRIDE);
-  bool dataValid; // Data valid from the GPS module
-  GPSStruct GPSData; // Holds the GPS data coming from the GPS module
-  unsigned long now = millis(); // The time "now"
-
-#ifdef DATA_VALID_OVERRIDE
-  const bool dataValidOverride = true; // Set true to override data valid for debugging
-#else
-  const bool dataValidOverride = false; // Set false not to override data valid
-#endif
-
-#ifdef BACKLIGHT_OVERRIDE
-  // Override LCD backlight switch
-  // Force LCD backlight on/off
-  lcd.setBacklight(BACKLIGHT_ONOFF);
-#else
-  // Turn LCD backlight on/off
-  lcd.setBacklight(digitalRead(BACKLIGHT_SW));
-#endif
-
-  // Get the data from the GPS module
-  while (GPSModule.available()) // While there are characters coming from the GPS module
-  {
-    bool b = gps.encode(GPSModule.read()); // This feeds the serial NMEA data into the GPS library one char at a time
-  }
-  // Get the GPS data valid flags
-  dataValid =
-    gps.location.isValid()   &&
-    gps.speed.isValid()      &&
-    gps.altitude.isValid()   &&
-    gps.course.isValid()     &&
-    gps.date.isValid()       &&
-    gps.time.isValid()       &&
-    gps.satellites.isValid() &&
-    gps.hdop.isValid();
-  // Check if the GPS data is valid or data valid override is set (for debugging)
-  if (dataValid || dataValidOverride) {
-#ifndef DATA_VALID_OVERRIDE
-    // Store the real GPS data
-    GPSData.satellites = gps.satellites.value();
-    GPSData.lat        = gps.location.lat();
-    GPSData.lon        = gps.location.lng();
-    GPSData.speed      = gps.speed.mph();
-    GPSData.altitude   = gps.altitude.feet();
-    GPSData.heading    = gps.course.deg();
-    GPSData.hdop       = gps.hdop.value();
-    GPSData.year       = gps.date.year();
-    GPSData.month      = gps.date.month();
-    GPSData.day        = gps.date.day();
-    GPSData.hour       = gps.time.hour();
-    GPSData.minute     = gps.time.minute();
-    GPSData.second     = gps.time.second();
-#else // #ifndef DATA_VALID_OVERRIDE
-    // Store the fake GPS data (for debugging)
-    GPSData.satellites = 0; // Invalid satellites
-    GPSData.lat        = 40.71d;  // East coast (NYC)
-    GPSData.lon        = -74.00d; //   "
-    GPSData.speed      = 5.0d;
-    GPSData.altitude   = 555.0d;
-    GPSData.heading    = 60.0d; // ENE or NE (16 cardinal points or 8 cardinal points)
-    GPSData.hdop       = 150; // 1.5
-    GPSData.year       = 2017;
-    GPSData.month      = 11; // Day before ST starts
-    GPSData.day        = 5;  //      "
-    GPSData.hour       = 23; // 7pm my local time
-    GPSData.minute     = 10;
-    GPSData.second     = 25;
-#endif // #ifndef DATA_VALID_OVERRIDE
-
-    // Clear the screen once when leaving initialization
-    if (!leftInitialization) {
-      leftInitialization = true;
-      lcd.clear(); // Clear the LCD
-    }
-
-    // Display the latest info from the gps object
-    // which it derived from the data sent by the GPS unit
-    // Send data to the LCD
-    lcd.home(); // Go to 1st line
-    lcd.print("Lat: ");
-    lcd.print(GPSData.lat);
-    lcd.setCursor(15, 0);
-    lcd.print("SV:");
-    if ((pastSatellites != GPSData.satellites) || (GPSData.satellites == 0)) {
-      pastSatellites = GPSData.satellites;
-      if (GPSData.satellites == 0) {
-        // Toggle invalid satellites indicator every TOGGLETIME_INTERVAL seconds
-        if (now - prevInvalidSatellitesTime > TOGGLETIME_INTERVAL / 4) {
-          prevInvalidSatellitesTime = now;
-          if (invalidSatellitesToggle) {
-            invalidSatellitesToggle = false;
-            lcd.print("XX");
-          }
-          else {
-            invalidSatellitesToggle = true;
-            lcd.print("  ");
-          } // if (invalidSatellitesToggle)
-        } // if (now - prevInvalidSatellitesTime > TOGGLETIME_INTERVAL)
-      } // if (GPSData.satellites == 0)
-      else if (GPSData.satellites <= 9) {
-        lcd.print(" "); // Blank leading char
-        lcd.print(GPSData.satellites);
-      }
-      else {
-        lcd.print(GPSData.satellites);
-      }
-    } // if ((pastSatellites != GPSData.satellites) || (GPSData.satellites == 0))
-    lcd.setCursor(0, 1); // Go to 2nd line
-    lcd.print("Lon: ");
-    lcd.print(GPSData.lon);
-    // Only display if time/date is selected
-    if ((digitalRead(ALTITUDE_DATE_TIME_SW))) {
-      if (!localUTCTimeDate) {
-        lcd.print("      "); // Clear the extra chars
-        uint8_t DOW = dayOfWeek(GPSData.year, GPSData.month, GPSData.day);
-        if (IsDST(GPSData.day, GPSData.month, DOW)) {
-          lcd.print("DST");
-        }
-        else {
-          lcd.print(" ST");
-        }
-      }
-      else { // if (!localUTCTimeDate)
-        // Display Hdop
-        displayHdopOnLCD(GPSData.hdop, displayHdop, now,
-                         &prevHdopTime, &hdopToggle);
-      } // if (!localUTCTimeDate)
-    } // if ((digitalRead(ALTITUDE_DATE_TIME_SW)))
-    else {
-      // Display Hdop
-      displayHdopOnLCD(GPSData.hdop, displayHdop, now,
-                       &prevHdopTime, &hdopToggle);
-    } // if ((digitalRead(ALTITUDE_DATE_TIME_SW)))
-    lcd.setCursor(0, 2); // Go to 3rd line
-    lcd.print("Spd: ");
-    if ((GPSData.speed < SPEED_CUTOUT) && (lowSpeedOverride)) {
-      lcd.print("0  ");
-    }
-    else {
-      lcd.print((int16_t)GPSData.speed);
-      lcd.print(" "); // Clear the extra chars
-    } // if ((GPSData.speed < SPEED_CUTOUT) && (lowSpeedOverride))
-    lcd.setCursor(12, 2);
-    lcd.print("Hdg: ");
-    if ((GPSData.speed < SPEED_CUTOUT) && (lowSpeedOverride)) {
-      lcd.print("0  ");
-    }
-    else {
-      // Toggle heading every TOGGLETIME_INTERVAL seconds
-      if (now - prevHeadingTime > TOGGLETIME_INTERVAL) {
-        prevHeadingTime = now;
-        if (headingToggle) { // Display cardinal heading
-          headingToggle = false;
-          lcd.print(cardinal(GPSData.heading, cardinal8_16));
-        }
-        else { // Display degrees heading
-          headingToggle = true;
-          lcd.print((int16_t)GPSData.heading);
-          if (GPSData.heading <= 99.9) lcd.print(" "); // Clear the extra char
-        } // if (headingToggle)
-      } // if (now - prevHeadingTime > TOGGLETIME_INTERVAL)
-    } // if ((GPSData.speed < SPEED_CUTOUT) && (lowSpeedOverride))
-    lcd.setCursor(0, 3); // Go to 4th line
-    if ((digitalRead(ALTITUDE_DATE_TIME_SW))) {
-      lcd.print("Alt: ");
-      lcd.print((int16_t)GPSData.altitude);
-      // Toggle credit every TOGGLETIME_INTERVAL seconds
-      if (now - prevCreditTime > (TOGGLETIME_INTERVAL / 2)) {
-        prevCreditTime = now;
-        if (creditToggle) { // Display credit
-          creditToggle = false;
-          lcd.print("         "); // Clear the extra chars
-          lcd.print(CREDIT); // Yours truly :-)
-        }
-        else {
-          creditToggle = true;
-          lcd.print("            "); // Clear the extra chars
-        }
-      } // if (now - prevCreditTime > TOGGLETIME_INTERVAL)
-    } // if ((digitalRead(ALTITUDE_DATE_TIME_SW)))
-    else {
-      // Toggle date/time every TOGGLETIME_INTERVAL seconds
-      if (now - prevDateTime > TOGGLETIME_INTERVAL) {
-        prevDateTime = now;
-        if (dateTimeToggle) {
-          // Display time
-          dateTimeToggle = false;
-          lcd.print("Time: ");
-          uint8_t hour = GPSData.hour;
-          uint8_t day  = GPSData.day;
-          uint8_t month = GPSData.month;
-          uint16_t year = GPSData.year;
-          bool DST = false;
-          if (localUTCTimeDate) {
-            // Convert UTC time to local time (no need to convert the date)
-            DST = convertToLocal(&hour, &year, &month,
-                                 &day, GPSData.lon, false); // false means no date conversion
-          }
-          else { // if (localUTCTimeDate)
-            if (display12_24_Hour) {
-              if (hour == 0) { // 12 hour clocks don't display 0
-                hour = 12;
-              }
-            } // if (display12_24_Hour)
-          } // if (localUTCTimeDate)
-          char AMPM[] = "am";
-          if (display12_24_Hour) {
-            if (hour >= 12) { // Convert to 12 hour format
-              if (hour > 12) hour -= 12;
-              strcpy(AMPM, "pm");
-            }
-          } // if (display12_24_Hour)
-          if (hour < 10) lcd.print("0");
-          lcd.print(hour);
-          lcd.print(":");
-          if (GPSData.minute < 10) lcd.print("0");
-          lcd.print(GPSData.minute);
-          lcd.print(":");
-          if (GPSData.second < 10) lcd.print("0");
-          lcd.print(GPSData.second);
-          if (display12_24_Hour) {
-            lcd.print(AMPM);
-          }
-          if (localUTCTimeDate) {
-            if (display12_24_Hour) {
-              (DST) ? lcd.print(" DST") : lcd.print("  ST");
-            }
-            else {
-              (DST) ? lcd.print("   DST") : lcd.print("    ST");
-            } // if (display12_24_Hour)
-          } // if (localUTCTimeDate)
-          if (!localUTCTimeDate) {
-            if (display12_24_Hour) {
-              lcd.print(" UTC");
-            }
-            else {
-              lcd.print("   UTC");
-            } // if (display12_24_Hour)
-          } // if (!localUTCTimeDate)
-        } // if (dateTimeToggle)
-        else {
-          // Display date
-          dateTimeToggle = true;
-          lcd.print("Date: ");
-          uint8_t hour = GPSData.hour;
-          uint8_t day  = GPSData.day;
-          uint8_t month = GPSData.month;
-          uint16_t year = GPSData.year;
-          if (localUTCTimeDate) {
-            // Convert UTC date to local date
-            bool DST = convertToLocal(&hour, &year, &month,
-                                      &day, GPSData.lon, true); // true means date conversion
-          } // if (localUTCTimeDate)
-          if (month < 10) lcd.print("0");
-          lcd.print(month);
-          lcd.print("/");
-          if (day < 10) lcd.print("0");
-          lcd.print(day);
-          lcd.print("/");
-          lcd.print(year);
-          displayDayOnLCD(dayOfWeek(year, month, day));
-        } // if (dateTimeToggle)
-      } // if (now - prevDateTime > TOGGLETIME_INTERVAL)
-    } // if ((digitalRead(ALTITUDE_DATE_TIME_SW)))
-  } // if (dataValid)
-  else {
-    // GPS data is not valid, so it must be initializing
-    // Display initialization screen once every INITIALIZATION_INTERVAL
-    if (now - prevInitializationTime > INITIALIZATION_INTERVAL) {
-      prevInitializationTime = now;
-      lcd.setCursor(8, 0); // Go to 1st line
-      lcd.print("GPS");
-      lcd.setCursor(16, 0);
-      lcd.print("v");
-      lcd.print(VERSION);
-      lcd.setCursor(4, 1); // Go to 2nd line
-      lcd.print("Initializing");
-      lcd.setCursor(6, 2); // Go to 3rd line
-      lcd.print("Data Not");
-      lcd.setCursor(7, 3); // Go to 4th line
-      lcd.print("Valid");
-      lcd.setCursor(19, 3);
-      if (++initializingCounter > 9) initializingCounter = 1; // Limit 1 - 9
-      lcd.print(initializingCounter);
-      leftInitialization = false;
-    }
-  } // GPS data is not valid
-} // loop
-
-/* Helper functions start here
-
-  The following three functions ripped off from Electrical Engineering Stack Exchange
-  http://electronics.stackexchange.com/questions/66285/how-to-calculate-day-of-the-week-for-rtc
-
-   Returns the number of days to the start of the specified year, taking leap
-   years into account, but not the shift from the Julian calendar to the
-   Gregorian calendar. Instead, it is as though the Gregorian calendar is
-   extrapolated back in time to a hypothetical "year zero".
-*/
-uint16_t leap(uint16_t year)
-{
-  return year * 365 + (year / 4) - (year / 100) + (year / 400);
-}
-/* Returns a number representing the number of days since March 1 in the
-   hypothetical year 0, not counting the change from the Julian calendar
-   to the Gregorian calendar that occurred in the 16th century. This
-   algorithm is loosely based on a function known as "Zeller's Congruence".
-   This number MOD 7 gives the day of week, where 0 = Monday and 6 = Sunday.
-*/
-uint16_t zeller(uint16_t year, uint8_t month, uint8_t day)
-{
-  year += ((month + 9) / 12) - 1;
-  month = (month + 9) % 12;
-  return leap(year) + month * 30 + ((6 * month + 5) / 10) + day + 1;
-}
-
-// Returns the day of week for a given date.
-uint8_t dayOfWeek(uint16_t year, uint8_t month, uint8_t day)
-{
-  return (zeller(year, month, day) % 7) + 1;
-}
-
-// Display the day of the week on the LCD
-void displayDayOnLCD(uint8_t day)
-{
-  if (day == 7) day = 0;
-  switch (day)
-  {
-    case 0:  lcd.print(" Mon"); break;
-    case 1:  lcd.print(" Tue"); break;
-    case 2:  lcd.print(" Wed"); break;
-    case 3:  lcd.print(" Thu"); break;
-    case 4:  lcd.print(" Fri"); break;
-    case 5:  lcd.print(" Sat"); break;
-    case 6:  lcd.print(" Sun"); break;
-    default: lcd.print(" Err");
-  }
-}
-
-// Compute the cardinal points of the compass (16 or 8 cardinal points)
-const char* cardinal(double course, bool cardinalSelect)
-{
-  if (!cardinalSelect) {
-    const char* directions[] = {"N  ", "NNE", "NE ", "ENE", "E  ", "ESE", "SE ", "SSE",
-                                "S  ", "SSW", "SW ", "WSW", "W  ", "WNW", "NW ", "NNW"
-                               };
-    uint8_t direction = (uint8_t)((course + 11.25d) / 22.5d);
-    return directions[direction % 16];
-  }
-  else {
-    const char* directions[] = {"N  ", "N  ", "NE ", "NE ", "E  ", "E  ", "SE ", "SE ",
-                                "S  ", "S  ", "SW ", "SW ", "W  ", "W  ", "NW ", "NW "
-                               };
-    uint8_t direction = (uint8_t)((course + 11.25d) / 22.5d);
-    return directions[direction % 16];
-  } // if (!cardinalSelect)
-}
-
-/* Ripped off from Stackoverflow
-  http://stackoverflow.com/questions/5590429/calculating-daylight-saving-time-from-only-date
-
-  Check to see if it's Daylight Savings Time (DST)
-*/
-bool IsDST(uint8_t day, uint8_t month , uint8_t DOW)
-{
-  // Make Day of Week (DOW) match with what Stackoverflow suggests
-  // for DOW (Sunday = 0 to Saturday = 6)
-  switch (DOW)
-  {
-    case 6:  DOW = 0; break; // Sun
-    case 7:  DOW = 1; break; // Mon
-    case 1:  DOW = 2; break; // Tue
-    case 2:  DOW = 3; break; // Wed
-    case 3:  DOW = 4; break; // Thu
-    case 4:  DOW = 5; break; // Fri
-    case 5:  DOW = 6; break; // Sat
-    default: break;
-  }
-  // January, February, and December are out
-  if (month < 3 || month > 11) {
-    return false;
-  }
-  // April to October are in
-  if (month > 3 && month < 11) {
-    return true;
-  }
-  int8_t previousSunday = (int8_t)(day - DOW);
-  // In march, we are DST if our previous Sunday was on or after the 8th
-  if (month == 3) {
-    return previousSunday >= 8;
-  }
-  // In November we must be before the first Sunday to be DST
-  // That means the previous Sunday must be before the 1st
-  return previousSunday <= 0;
-}
-
-/* Convert UTC time and date to local time and date
-   Difference between UTC time/date (at Greenwich) and local time/date is 15 minutes
-   per 1 degree of longitude. See the following:
-   http://www.edaboard.com/thread101516.html
-*/
-bool convertToLocal(uint8_t* hour, uint16_t* year, uint8_t* month,
-                    uint8_t* day, const double lon, bool convertDate) {
-
-  uint8_t DaysAMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
-
-  // Get Day of Week (DOW)
-  uint8_t DOW = dayOfWeek(*year, *month, *day);
-  // Get Daylight Saving Time (DST) or Standard Time (ST)
-  bool DST = IsDST(*day, *month, DOW);
-  // Compute local time (hours)
-  int8_t UTCOffset = (int8_t)round((lon / 15.0d)); // UTC offset
-  if (UTCOffset < 0) {
-    // West of Greenwich, subtract
-    UTCOffset = abs(UTCOffset); // Make offset positive
-    if (DST) --UTCOffset; // Compensate for DST
-    if (*hour <= UTCOffset) *hour += 24;
-    *hour -= UTCOffset; // Subtract offset
-  }
-  else {
-    // East of Greenwich, add
-    if (DST) ++UTCOffset; // Compensate for DST
-    if (*hour <= UTCOffset) *hour += 24;
-    *hour += UTCOffset; // Add offset
-  }
-  // Convert date if convertDate flag is set
-  // Portions of the following code (with some modifications) ripped off from Instructables
-  // http://www.instructables.com/id/GPS-time-UTC-to-local-time-conversion-using-Arduin/?ALLSTEPS
-  if (convertDate) {
-    if ((24 - *hour) <= UTCOffset) { // A new UTC day started
-      if (*year % 4 == 0) DaysAMonth[1] = 29; //leap year check (the simple method)
-      if (*hour < 24) {
-        *day -= 1;
-        if (*day < 1) {
-          if (*month == 1) {
-            *month = 12;
-            *year -= 1;
-          } // if (*month == 1)
-          else {
-            *month -= 1;
-          }
-          *day = DaysAMonth[*month - 1];
-        } // if (*day < 1)
-      } // if (*hour < 24)
-      else if (*hour >= 24) {
-        *day += 1;
-        if (*day > DaysAMonth[*month - 1]) {
-          *day = 1;
-          *month += 1;
-          if (*month > 12) *year += 1;
-        } // if (*day > DaysAMonth[*month - 1])
-      } // if (*hour >= 24)
-    } // if ((24 - *hour) <= UTCOffset)
-  } // if (convertDate)
-  return (DST);
-}
-
-// Dislpays Hdop or horizontal position error on the LCD
-void displayHdopOnLCD(uint32_t Hdop, bool HdopSelect, unsigned long now,
-                      unsigned long* prevHdopTime, bool* hdopToggle) {
-  if (!HdopSelect) {
-    // Display Horizontal Dilution of Precision (Hdop) with the format X.X
-    // It comes in from the GPS module as XXX
-    // If you care how Hdop is computed (I don't :-)), see the following:
-    // http://www2.unb.ca/gge/Resources/gpsworld.may99.pdf
-    float hdop = (float)Hdop / 100.0f; // Hdop in X.X format
-    lcd.print(" Hdop:");
-    if (hdop < 10.0f) {
-      lcd.print((uint32_t)hdop);
-      lcd.print(".");
-      lcd.print((uint32_t)((hdop - (uint32_t)hdop) * 10.0f));
-    }
-    else {
-      // Hdop value too large for my LCD, so cross it out
-      // Toggle Hdop indicator every TOGGLETIME_INTERVAL seconds
-      if (now - *prevHdopTime > TOGGLETIME_INTERVAL / 3) {
-        *prevHdopTime = now;
-        if (*hdopToggle) {
-          *hdopToggle = false;
-          lcd.print("XXX");
-        }
-        else {
-          *hdopToggle = true;
-          lcd.print("   ");
-        } // if (hdopToggle)
-      } // if (now - prevHdopTime > TOGGLETIME_INTERVAL)
-    } // if (hdop < 10.0f)
-  }
-  else { // if (!HdopSelect)
-    // Display horizontal position error in feet
-    float hError = (float)Hdop / 100.0f; // Error in X.X format
-    hError *= GPS_RECEIVER_ERROR; // Error in meters
-    hError *= _GPS_FEET_PER_METER; // Error in feet
-    lcd.print(" Err: ");
-    if (hError < 100.0f) {
-      lcd.print((uint8_t)hError);
-      if (hError < 10.0f) {
-        lcd.print("f "); // feet
-      }
-      else {
-        lcd.print("f"); // feet
-      }
-    }
-    else { // if (hError < 100.0f)
-      // horizontal position error value too large for my LCD, so cross it out
-      // Toggle Hdop indicator every TOGGLETIME_INTERVAL seconds
-      if (now - *prevHdopTime > TOGGLETIME_INTERVAL / 3) {
-        *prevHdopTime = now;
-        if (*hdopToggle) {
-          *hdopToggle = false;
-          lcd.print("XXX");
-        }
-        else {
-          *hdopToggle = true;
-          lcd.print("   ");
-        } // if (hdopToggle)
-      } // if (now - prevHdopTime > TOGGLETIME_INTERVAL)
-    } // if (hError < 100.0f)
-  } // if (!HdopSelect)
-}


Bug fix (see issue #17)

Bug fix (see issue #17)

https://github.com/markszabo/IRremoteESP8266/issues/17

--- examples/IRServer/IRServer.ino
+++ examples/IRServer/IRServer.ino
@@ -27,7 +27,7 @@
     if(server.argName(i) == "code")
     {
       unsigned long code = server.arg(i).toInt();
-      irsend.sendNEC(code, 36);
+      irsend.sendNEC(code, 32);
     }
   }
   handleRoot();


Fixed some things in StepTest.ino

Fixed some things in StepTest.ino

--- examples/StepTest/StepTest.ino
+++ examples/StepTest/StepTest.ino
@@ -95,7 +95,7 @@

   if (readReg(WR) != 0b01111000)
   {
-    Serial.println(F("Writing or reading WR failed."));
+    Serial.println(F("Writing or reading WR failed; driver power might be off."));
     error();
   }

@@ -395,7 +395,7 @@
       // By triggering on channel 3 and zooming in to 100 ns/div,
       // verify that the PWM fall (or rise) time increases every 2
       // seconds, for a total of 4 different settings.
-      //stepper.setPwmSlope(m);
+      stepper.setPwmSlope(mode);

       // Verify that the SLA gain changes every two seconds.
       // (The two settings are 0.5 and 0.25.)
@@ -424,13 +424,7 @@
       if (!stepper.verifySettings())
       {
         stepper.applySettings();
-
-        if (stepper.verifySettings())
-        {
-          // TODO: fix the  API so this part really works
-          Serial.println(F("Successfully reapplied settings."));
-        }
-        else
+        if (!stepper.verifySettings())
         {
           Serial.println(F("Could not verify settings; driver power might be off."));
         }


Changed RAISING for FALLING

Changed RAISING for FALLING

--- Bounce/examples/change/change.ino
+++ Bounce/examples/change/change.ino
@@ -1,4 +1,6 @@
 #include <Bounce.h>
+
+// Detect the falling edge

 // Circuit :
 // https://raw.github.com/thomasfredericks/Bounce-Arduino-Wiring/master/Bounce/examples/circuit-bounce-change-duration-retrigger.png
@@ -33,7 +35,7 @@
   boolean stateChanged = debouncer.update();
   int state = debouncer.read();

-  // Detect the raising edge
+  // Detect the falling edge
    if ( stateChanged && state == LOW ) {

        if ( ledState == LOW ) {