comment fixed

comment fixed

--- jenny5-firmware/jenny5-firmware.ino
+++ jenny5-firmware/jenny5-firmware.ino
@@ -8,11 +8,11 @@
 int enable_pins[4] = {4,7,10,13};

 int default_motor_speed = 200; //maximum steps per second
-int default_motor_acceleration = 800; //steps/second/second to accelerate
+int default_motor_acceleration = 100; //steps/second/second to accelerate

 char is_command_running;

-char firmware_version[] = "2015.11.10.7";
+char firmware_version[] = "2015.11.10.8";

 AccelStepper *steppers[num_motors];

@@ -190,7 +190,7 @@
 //--------------------------------------------------------------------------------------------
 void lock_motor(int motor_index)
 {
-  digitalWrite(enable_pins[motor_index], LOW); // disable motor
+  digitalWrite(enable_pins[motor_index], LOW); // enable motor
 }
 //--------------------------------------------------------------------------------------------
 //Reset pins to default states


added CP command

added CP command

--- jenny5-firmware/jenny5-firmware.ino
+++ jenny5-firmware/jenny5-firmware.ino
@@ -14,7 +14,7 @@
 byte infrared_pins[2] = {52, 53};

 t_motors_controller motors_controller;
-t_potentiometers_controller potentiometers_control;
+t_potentiometers_controller potentiometers_controller;
 t_ultrasonic_sensors_controller ultrasonic_sensors_controller;
 t_infrared_sensors_controller *infrared_sensors_control;

@@ -34,7 +34,7 @@
 void setup()
 {
   first_start = 0;
-  strcpy(firmware_version, "2016.01.24.0");
+  strcpy(firmware_version, "2016.01.31.0");

   //motors_controller.set_num_motors(2);

@@ -65,6 +65,8 @@
   Serial.println(F("GPx# // Gets the parameters for potentiometer x: min max home. Outputs PPx l u h#"));
   Serial.println(F("GUx# // Gets the parameters for ultrasound x: trig_pin echo_pin. Outputs UPx t e#"));
   Serial.println(F("CM n d1 s1 e1 d2 s2 e2# // Creates the motors controller and set some of its parameters. n is the number of motors, d, s, e are dir, step and enable pins. Outputs CM# when done."));
+  Serial.println(F("CP n p1 l1 h1 _h1# // Creates the potentiometers controller and set some of its parameters. n is the number of potentiometers, p is the output pin, l, h and _h are bottom, upper and home position. Outputs CP# when done."));
+  Serial.println(F("CU n t1 e1# // Creates the ultrasonic controllers and set some of its parameters. n is the number of sonars, t and e are trigger and echo pins. Outputs CU# when done."));

   Serial.println(F("V# // Outputs version string. eg: 2016.01.17.0#"));

@@ -99,7 +101,7 @@
           if (tmp_str[i] == 'P' || tmp_str[i] == 'p'){// potentiometer
             int sensor_index;
             sscanf(tmp_str + i + 1, "%d", &sensor_index);
-            int sensor_value = potentiometers_control.get_position(sensor_index);
+            int sensor_value = potentiometers_controller.get_position(sensor_index);
             sprintf(serial_out, "P%d %d#", sensor_index, sensor_value);
             i += 2;
           }
@@ -156,7 +158,7 @@
               if (tmp_str[i + 1] == 'P' || tmp_str[i + 1] == 'p'){ // potentiometer min max home
                 int pot_index, pot_min, pot_max, pot_home, pot_pin;
                 sscanf(tmp_str + i + 2, "%d%d%d%d%d", &pot_index, &pot_pin, &pot_min, &pot_max, &pot_home);
-                potentiometers_control.set_params(pot_index, pot_pin, pot_min, pot_max, pot_home);
+                potentiometers_controller.set_params(pot_index, pot_pin, pot_min, pot_max, pot_home);
                 i += 7;
             }
           }
@@ -194,7 +196,7 @@
                 int pot_index, pot_min, pot_max, pot_home;
                 byte pot_pin;
                 sscanf(tmp_str + i + 2, "%d", &pot_index);
-                potentiometers_control.get_params(pot_index, &pot_pin, &pot_min, &pot_max, &pot_home);
+                potentiometers_controller.get_params(pot_index, &pot_pin, &pot_min, &pot_max, &pot_home);
                 sprintf(serial_out, "PP%d %d %d %d %d#", pot_index, (int)pot_pin, pot_min, pot_max, pot_home);
                 i += 4;
               }
@@ -241,7 +243,7 @@
                }
              }
              else
-               if (tmp_str[i + 1] == 'U' || tmp_str[i + 1] == 'u'){// create a list of motors
+               if (tmp_str[i + 1] == 'U' || tmp_str[i + 1] == 'u'){// create a list of ultrasonic sensors

                  int num_sonars = 0;

@@ -260,6 +262,27 @@
                  sprintf(serial_out, "CU#");
                  i += num_consumed_total;
              }
+             else
+               if (tmp_str[i + 1] == 'P' || tmp_str[i + 1] == 'p'){// create a list of potentiometers
+
+                 int num_potentiometers = 0;
+
+                 int num_consumed = 0;
+                 sscanf(tmp_str + i + 3, "%d%n", &num_potentiometers, &num_consumed);
+
+                 int num_consumed_total = 3 + num_consumed;
+                 potentiometers_controller.set_num_sensors(num_potentiometers);
+                 for (int k = 0; k < num_potentiometers; k++){
+                   int _out_pin;
+                   int _low, _high, _home;
+                   sscanf(tmp_str + i + num_consumed_total, "%d%d%d%d%n", &_out_pin, &_low, &_high, &_home, &num_consumed);
+                   potentiometers_controller.set_params(k, _out_pin, _low, _high, _home);
+                   num_consumed_total += num_consumed + 1;
+                 }
+
+                 sprintf(serial_out, "CP#");
+                 i += num_consumed_total;
+               }
          }
     }
     else
@@ -340,7 +363,7 @@
         }
     }
   }
-  motors_controller.run_motors(&potentiometers_control, serial_out);
+  motors_controller.run_motors(&potentiometers_controller, serial_out);
   if (serial_out[0])
     Serial.write(serial_out);


[bugfix] Put output message to correctly UART

--- control_sensor_via_Flask/control_sensor_via_Flask.ino
+++ control_sensor_via_Flask/control_sensor_via_Flask.ino
@@ -26,14 +26,14 @@
 }

 void loop() {
-    // Wait a few seconds between measurements.
-    delay(2100);
-
     while(Serial1.available())
     {
         char c = Serial1.read();
         if(c == '1')
         {
+            // Wait a few seconds between measurements.
+            delay(2100);
+
             // Reading temperature or humidity takes about 250 milliseconds!
             // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
             float h = dht.readHumidity();
@@ -41,16 +41,16 @@
             float t = dht.readTemperature();
             // Read temperature as Fahrenheit (isFahrenheit = true)
             float f = dht.readTemperature(true);
-
+
             // Check if any reads failed and exit early (to try again).
             if (isnan(h) || isnan(t) || isnan(f)) {
-                Serial.println("Failed to read from DHT sensor!");
+                Serial1.println("Failed to read from the sensor!");
                 return;
             }
-
+
             // Compute heat index in Celsius (isFahreheit = false)
             float hic = dht.computeHeatIndex(t, h, false);
-
+
             Serial1.print("Humidity: ");
             Serial1.print(h);
             Serial1.print("% ");


Remove stray ";" from #endif in LCD_screen_test.ino

--- build/shared/examples/09.EducationalBP_MKII/LCD_screen_test/LCD_screen_test.ino
+++ build/shared/examples/09.EducationalBP_MKII/LCD_screen_test/LCD_screen_test.ino
@@ -313,7 +313,7 @@

 #if defined(PicasoSPE)
     mySerial.begin(9600);
-#endif;
+#endif

     myScreen.begin();
     Serial.println(myScreen.WhoAmI());
@@ -325,7 +325,7 @@
     myScreen.setSpeed((uint32_t) 38400); // 38400 ok, 57600 ok, 115200 nok, 256000 nok
     mySerial.begin((uint32_t) 38400);
     Serial.println((uint32_t) 38400, DEC);
-#endif;
+#endif

     myScreen.setFontSize(myScreen.fontMax());
     myScreen.clear(darkGrayColour);


Add Blog Post URL

Add Blog Post URL

--- ClassicJoyStick_USB/ClassicJoyStick_USB.ino
+++ ClassicJoyStick_USB/ClassicJoyStick_USB.ino
@@ -1,5 +1,6 @@
 /* Commodore 64/Amiga, Atari 2600/XL/ST, ZX Spectrum, Amstrad CPC, MSX and many others compatible Joystick to USB
  * Auth: John Milner / jfrmilner
+ * Blog Post URL: https://jfrmilner.wordpress.com/2016/07/17/arduino-project-commodore-64amiga-atari-2600xlst-zx-spectrum-joystick-to-windowslinux-retropie-usb/
  *
  * Version
  * 1.0


8085: Remove dead include.

8085: Remove dead include.

--- InCircuitTester8085/InCircuitTester8085.ino
+++ InCircuitTester8085/InCircuitTester8085.ino
@@ -27,7 +27,6 @@
 #include <DFR_Key.h>
 #include <zutil.h>

-//#include <C6809ECpu.h>
 #include <CPhoenixGame.h>

 //


Menu flow c64 to modem, +++ guard cmd mode for outbound.

--- MicroView/WiFiModem-Menu/WiFiModem-Menu.ino
+++ MicroView/WiFiModem-Menu/WiFiModem-Menu.ino
@@ -34,7 +34,7 @@

 ;  // Keep this here to pacify the Arduino pre-processor

-#define VERSION "0.09b2"
+#define VERSION "0.09b3"

 unsigned int BAUD_RATE=2400;
 unsigned int WiFly_BAUD_RATE=2400;
@@ -114,8 +114,6 @@
 char Modem_LastCommandBuffer[COMMAND_BUFFER_SIZE];
 char Modem_CommandBuffer[COMMAND_BUFFER_SIZE];

-int Modem_EscapeCount = 0;
-
 // Misc Values
 #define TIMEDOUT  -1
 boolean baudMismatch = (BAUD_RATE != WiFly_BAUD_RATE ? 1 : 0);
@@ -1038,9 +1036,8 @@
 #else
     if (Modem_DCDFollowsRemoteCarrier)
         digitalWriteFast(C64_DCD, Modem_ToggleCarrier(true));
+    TerminalMode();
 #endif
-
-    TerminalMode();
 }

 void TerminalMode()
@@ -1192,7 +1189,7 @@
         // Check that C64 is ready to receive
         while (digitalReadFast(WIFI_RTS) == HIGH)   // If not...
         {
-            digitalWriteFast(C64_CTS, LOW);     // ..stop data from Wi-Fi and wait
+            digitalWriteFast(C64_CTS, LOW);     // ..stop data from C64 and wait
         }
         digitalWriteFast(C64_CTS, HIGH);
     }
@@ -1363,9 +1360,7 @@

     if (Modem_DCDFollowsRemoteCarrier == true)
       digitalWriteFast(C64_DCD, Modem_ToggleCarrier(false));
-
-    Modem_EscapeCount = 0;
-
+
     Modem_LoadDefaults();

     Modem_LoadSavedSettings();
@@ -2344,28 +2339,43 @@
         {
             if (Modem_isConnected)
             {
-                char inbound = C64Serial.read();
-
-                if (inbound == Modem_S2_EscapeCharacter)
+                char C64input = C64Serial.read();
+
+                if ((millis() - ESCAPE_GUARD_TIME) > escapeTimer)
                 {
-                    Modem_EscapeCount++;
+
+                    if (C64input == '+' && lastC64input != '+')
+                    {
+                        escapeCount = 1;
+                        lastC64input = C64input;
+                    }
+                    else if (C64input == '+' && lastC64input == '+')
+                    {
+                        escapeCount++;
+                        lastC64input = C64input;
+                    }
+                    else
+                    {
+                        escapeCount = 0;
+                        escapeTimer = millis();   // Last time non + data was read
+                    }
                 }
                 else
                 {
-                    Modem_EscapeCount = 0;
-                    // TODO, guard time!
+                    escapeTimer = millis();   // Last time data was read
                 }

-                if (Modem_EscapeCount == 3)
-                {
-                    Modem_EscapeCount = 0;
-                    Modem_isCommandMode = true;   // TODO, guard time!
-
+                if (escapeCount == 3) {
+                    Display("Escape!");
+                    escapeReceived = true;
+                    escapeCount = 0;
+                    escapeTimer = 0;
+                    Modem_isCommandMode = true;
+                    C64Println();
                     Modem_PrintOK();
                 }
-
                 DoFlowControlC64ToModem();
-                int result = wifly.write(inbound);
+                int result = wifly.write(C64input);
             }
         }
     }
@@ -2388,6 +2398,11 @@
 // Main processing loop for the virtual modem.  Needs refactoring!
 void Modem_Loop()
 {
+    int data;
+    char buffer[100];
+    int buffer_index = 0;
+    // int max_buffer_size_reached = 0;
+
     boolean wiflyIsConnected = wifly.isConnected();

     if (wiflyIsConnected) {
@@ -2406,15 +2421,61 @@
             // Echo an error back to remote terminal if in command mode.
             if (Modem_isCommandMode && wifly.available() > 0)
             {
-                wifly.println(F("error: remote modem is in command mode."));
+                // If we print this, remote end gets flooded with this message
+                // if we go to command mode on the C64 and remote side sends something..
+                //wifly.println(F("error: remote modem is in command mode."));
             }
             else
             {
-                while (wifly.available() > 0)
-                {
-                    DoFlowControlModemToC64();
-                    C64Serial.write(wifly.read());
-                    // TODO:  Review..  Flow control?
+                if (baudMismatch) {   // If host is slower than WiFly we need to buffer.  Only used for 1200 baud.
+                    while (wifly.available() > 0)
+                    {
+                        digitalWriteFast(WIFI_CTS, HIGH);     // ..stop data from Wi-Fi
+
+                        data = wifly.read();
+                        buffer[buffer_index++] = data;
+                        if (buffer_index > 99)
+                            buffer_index = 99;
+                    }
+
+                    // Dump the buffer to the C64 before clearing WIFI_CTS
+                    for (int i = 0; i<buffer_index; i++) {
+                        C64Serial.write(buffer[i]);
+
+                        /* NOTE:  For Menu firmware, we also process C64Serial.available here.
+                                  May not be needed as 1200 baud upload and download test passed,
+                                  but when trying to use joe editor in Linux at 1200 baud, it loses
+                                  a lot of characters when typing.  Same for Menu firmware. */
+                    }
+
+
+                    // Only used for displaying max buffer size on Microview for testing
+                    if (max_buffer_size_reached < buffer_index)
+                    max_buffer_size_reached = buffer_index;
+                    char message[20];
+                    sprintf_P(message, PSTR("Buf: %d"), max_buffer_size_reached);
+                    Display(message);
+
+                    // Show largest buffer size on Microview
+                    // 4800/9600 = 3
+                    // 4800/19200 = 5
+                    // 1200/19200 = doesn't work
+                    // 4800/38400 = 12
+                    // 2400/38400 = 40 - bbs.jammingsignal.com:23 (1200 baud) worked.
+                    // 2400/38400 = 40 - cib.dyndns.com:6400 (19200 baud) worked.
+                    // 2400/38400 = 40 - Linux telnet did not work with Novaterm.  Default flow tolerance = 200.  Set to 100 and sometimes connected.
+                    // 9600/38400 = 11
+
+                    buffer_index = 0;
+
+                    digitalWriteFast(WIFI_CTS, LOW);
+                }
+                else {
+                    while (wifly.available() > 0)
+                    {
+                        DoFlowControlModemToC64();
+                        C64Serial.write(wifly.read());
+                    }
                 }
             }
         }
@@ -2435,16 +2496,6 @@
             return;
         }
     }
-
-    // Flow control, revisit
-    //else if (!modem.getIsConnected() && modem.getIsCommandMode())
-    //{
-        //digitalWrite(DCE_RTS, LOW);
-    //}
-    //else if(digitalRead(DTE_CTS) == HIGH)
-    //{
-    //	digitalWrite(DTE_RTS, LOW);
-    //}

     // Handle all other data arriving on the serial port of the virtual modem.
     Modem_ProcessData();
@@ -2680,7 +2731,8 @@
         escapeCount = 0;
         escapeTimer = 0;
     }
-
+
+    DoFlowControlC64ToModem();
     wifly.write(C64input);
     //wifly.write(C64Serial.read());
 }
@@ -2793,3 +2845,4 @@
     //isSleeping = false;
 }

+// #EOF - Leave this at the very end...


remove debug msg

remove debug msg

--- client/client.ino
+++ client/client.ino
@@ -2,7 +2,7 @@
 #include <IRremote.h>
 #include <string.h>

-#define DEBUG
+// #define DEBUG
 #include "utils.h"

 // Trying to elucidate the way communication works first


Arduino Code minor changes

Arduino Code minor changes

--- ArduinoRadar/ArduinoRadar.ino
+++ ArduinoRadar/ArduinoRadar.ino
@@ -1,33 +1,33 @@
 #include <Servo.h>
-int trigPin, echoPin, servoPin, Angle, turnLeft;
+int trigPin, echoPin, servoPin, Angle, turnLeft;// "turnLeft" variable will be used as a boolean in a if statement
 Servo radarServo; //Creating a servo object

-void setup()
-{
-  trigPin = 11; echoPin = 10; servoPin = 2; Angle = 10; turnLeft = 1;
+void setup(){
+  trigPin = 11; echoPin = 10; servoPin = 2; Angle = 10; turnLeft = 1;
   pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
   pinMode(echoPin, INPUT); // Sets the echoPin as an Input
   radarServo.attach(servoPin); // Defines on which pin is the servo motor attached
-  Serial.begin(9600); // Begin a sirial communication
+  Serial.begin(9600); // Starts a new serial communication with baud rate 9600 bps
 }

-void loop()
-{
-  if (Angle < 170 && turnLeft) Angle ++;
+void loop(){
+  if (Angle < 170 && turnLeft) Angle ++;
   else if (Angle >= 170 || !turnLeft) { turnLeft = (Angle <= 11); Angle--; }
   radarServo.write(Angle);
   Serial.print(String(Angle) + "," + String(calculateDistance()) + ".\n");
   delay(50);
 }

-long calculateDistance()
-{
-  digitalWrite(trigPin, LOW); // Clean the trigPin to begin the measurment
+long calculateDistance(){
+  digitalWrite(trigPin, LOW); // Clean the trigPin
   delayMicroseconds(2);
-  digitalWrite(trigPin, HIGH); // Sets the trigPin on HIGH state for 10 Microseconds
+  digitalWrite(trigPin, HIGH); // Creates a new sound wave
   delayMicroseconds(10);
   digitalWrite(trigPin, LOW);
-  //U(m/s)=dX(m)/dT(s) In dry air at 20 °C, the speed of sound is 343.2 m/s or 0.003432 m/Microsecond or 0,03434 cm/Microseconds
-  return pulseIn(echoPin, HIGH) * 0.034 / 2; // Reads the echoPin, returns the sound wave travel time in microseconds
+  return pulseIn(echoPin, HIGH) * 0.034 / 2;
 }

+  // U(m/s)=dX(m)/dT(s)
+  // In dry air at 20 °C, the speed of sound is 343.2 m/s or 0,03434 cm/Microseconds.
+  // The function pulseIn(echoPin, HIGH) reads the echoPin until it catches a reflection
+  // of the sound wave and returns the time that sound wave traveled in microseconds


small improvements

small improvements

--- DanceFeather/DanceFeather.ino
+++ DanceFeather/DanceFeather.ino
@@ -258,7 +258,7 @@
     for (int i = startIndex; i < endIndex; i++) {
         float magnitude = mag[i];
         magAvg[i] = magAvg[i] * 0.99 + magnitude * 0.01;
-        if (magAvg[i] > maxMag && i > 0) {
+        if (magAvg[i] > maxMag && i > 1) {
             maxMag = magAvg[i];
             maxIndex = i;
         }
@@ -350,8 +350,7 @@

   }

-  if (diff > magAvg[0] && phaseNearZero) {
-    Serial.print("Diff:\t"); Serial.println(diff);
+  if (diff > 2 * magAvg[0] && phaseNearZero) {
     digitalWrite(LED_PIN, HIGH);

     Serial.print("BPM:\t");


output phase only

output phase only

--- DanceFeather/DanceFeather.ino
+++ DanceFeather/DanceFeather.ino
@@ -350,48 +350,49 @@
   fft_phase(FS, 0, F2, FFT_SIZE, fftBuffer, mag, phase, startIndex, endIndex);
   updatePhase(mag, phase, startIndex, endIndex);
   bool phaseNearZero = false;
-  for (int i = startIndex; i < endIndex; i++) {
-      if (i == winningIndex && abs(phaseAvg[i]) < 0.05f * i) {
-        phaseNearZero = true;
-      }
+  float winningPhase = phaseAvg[winningIndex];
+  if (abs(winningPhase) < 0.05f * winningIndex) {
+    phaseNearZero = true;
   }

   if (diff > 2 * magAvg[0]) {
     digitalWrite(LED_PIN, LOW);

-    Serial.print("Prev :\t");
-    for (int i = 0; i < endIndex; i++) {
-      float phase = prevPhase[i];
-      Serial.print(phase);
-      Serial.print("\t");
-    }
-    Serial.println("");
-
-    // Serial.print("Diff:\t"); Serial.println(diff);
-    Serial.print("Phase:\t");
-    for (int i = 0; i < endIndex; i++) {
-      float phase = phaseAvg[i];
-      Serial.print(phase);
-      Serial.print("\t");
-    }
-    Serial.println("");
-
-    Serial.print("BPM:\t");
-    for (int i = 0; i < endIndex; i++) {
-      float hz = FS * phaseRateAverage[i] / 2 / PI;
-      float bpm = hz * 60;
-      Serial.print(bpm);
-      Serial.print("\t");
-    }
-    Serial.println("");
-
-    Serial.print("Mag:\t");
-    for (int i = 0; i < endIndex; i++) {
-      float mag = magAvg[i];
-      Serial.print(mag);
-      Serial.print("\t");
-    }
-    Serial.println("");
+    Serial.print("Phase: "); Serial.println(winningPhase);
+
+    // Serial.print("Prev :\t");
+    // for (int i = 0; i < endIndex; i++) {
+    //   float phase = prevPhase[i];
+    //   Serial.print(phase);
+    //   Serial.print("\t");
+    // }
+    // Serial.println("");
+
+    // // Serial.print("Diff:\t"); Serial.println(diff);
+    // Serial.print("Phase:\t");
+    // for (int i = 0; i < endIndex; i++) {
+    //   float phase = phaseAvg[i];
+    //   Serial.print(phase);
+    //   Serial.print("\t");
+    // }
+    // Serial.println("");
+
+    // Serial.print("BPM:\t");
+    // for (int i = 0; i < endIndex; i++) {
+    //   float hz = FS * phaseRateAverage[i] / 2 / PI;
+    //   float bpm = hz * 60;
+    //   Serial.print(bpm);
+    //   Serial.print("\t");
+    // }
+    // Serial.println("");
+
+    // Serial.print("Mag:\t");
+    // for (int i = 0; i < endIndex; i++) {
+    //   float mag = magAvg[i];
+    //   Serial.print(mag);
+    //   Serial.print("\t");
+    // }
+    // Serial.println("");

   }


Further improved accuracy

Further improved accuracy

--- arduino-nixie-clock/arduino-nixie-clock.ino
+++ arduino-nixie-clock/arduino-nixie-clock.ino
@@ -17,14 +17,14 @@
 #define BLANKING_US 200

 extern volatile unsigned long timer0_millis;
-const unsigned long millisMax = (unsigned long)12 * 60 * 60 * 1000,
+const unsigned long maxMilliseconds = (unsigned long)12 * 60 * 60 * 1000,
                     secondDivisor = 1000,
                     minuteDivisor = secondDivisor * 60,
                     hourDivisor = minuteDivisor * 60;
 bool hourIncremented = false,
      minuteIncremented = false;

-void addMillis(unsigned long offset)
+void offsetMillis(unsigned long offset)
 {
   uint8_t oldSREG = SREG;

@@ -64,18 +64,19 @@
 }

 void loop()
-{
+{
+  unsigned long milliseconds = millis();
   bool setHourPressed = !digitalRead(SET_HOUR),
        setMinutePressed = !digitalRead(SET_MINUTE);

   if (setHourPressed && !hourIncremented)
   {
-    addMillis(hourDivisor);
+    offsetMillis(hourDivisor);
     hourIncremented = true;
   }
   else if (setMinutePressed && !minuteIncremented)
   {
-    addMillis(minuteDivisor - millis() % minuteDivisor);
+    offsetMillis(minuteDivisor - milliseconds % minuteDivisor);
     minuteIncremented = true;
   }
   else if (!setHourPressed && hourIncremented)
@@ -86,19 +87,19 @@
   {
     minuteIncremented = false;
   }
-
-  if (millis() >= millisMax)
+
+  if (milliseconds >= maxMilliseconds)
   {
-    addMillis(-millisMax);
+    offsetMillis(-maxMilliseconds);
   }

-  unsigned short hour = millis() / hourDivisor % 12,
-                 minute = millis() / minuteDivisor % 60,
-                 second = millis() / secondDivisor % 60;
+  unsigned short hour = milliseconds / hourDivisor % 12,
+                 minute = milliseconds / minuteDivisor % 60,
+                 second = milliseconds / secondDivisor % 60;

-  if (millis() < 10 * secondDivisor)
+  if (milliseconds < 10 * secondDivisor)
   {
-    hour = minute = second = second * 11;
+    hour = minute = second *= 11;
   }
   else if (hour == 0)
   {


streamのinterval対応

streamのinterval対応

--- arduino/GeneralIoSerial/GeneralIoSerial.ino
+++ arduino/GeneralIoSerial/GeneralIoSerial.ino
@@ -304,41 +304,24 @@
     }
   }

-  // enabledがtrueかつ、portsのどれか一つが有効になっていれば
-  // 変換を行う
-  /*
-  if( di_stream_enable_ports != 0){
-    Serial.print(eventResponseHeader("di"));
-    bool first = true;
-    for(uint8_t i = 0; i < DI_MAX_PORT_NUM; i++){
-      if(bitRead(di_stream_enable_ports, i) == 1){
-        if(first){
-          first = false;
-        }else{
-          Serial.print(",");
-        }
-        Serial.print(diRead(i));
+  for(uint8_t i = 0; i < AI_MAX_PORT_NUM; i++){
+    if(ai_stream_info[i].interval_ms){
+      if(ai_stream_info[i].counter > ai_stream_info[i].interval_ms){
+        ai_stream_info[i].counter = 0;
+        Serial.println(aiRead(i));
       }
     }
-    Serial.println("]}");
-  }
-
-  if( ai_stream_enable_ports != 0){
-    Serial.print(eventResponseHeader("ai"));
-    bool first = true;
-    for(uint8_t i = 0; i < AI_MAX_PORT_NUM; i++){
-      if(bitRead(ai_stream_enable_ports, i) == 1){
-        if(first){
-          first = false;
-        }else{
-          Serial.print(",");
-        }
-        Serial.print(aiRead(i));
+  }
+
+  for(uint8_t i = 0; i < DI_MAX_PORT_NUM; i++){
+    if(di_stream_info[i].interval_ms){
+      if(di_stream_info[i].counter > di_stream_info[i].interval_ms){
+        di_stream_info[i].counter = 0;
+        Serial.println(diRead(i));
       }
     }
-    Serial.println("]}");
-  }
-  */
+  }
+
 }

 String eventResponseHeader(String event){


During dev.

During dev.

--- examples/basic/basic.ino
+++ examples/basic/basic.ino
@@ -1,9 +1,20 @@
+#include <Technoshield-ui.h>
+
+Technoshield_ui ui(0,0);
+
 void setup() {
-  // put your setup code here, to run once:
-
+  ui.begin();
+  ui.print("hello, world!");
 }

 void loop() {
-  // put your main code here, to run repeatedly:
+   ui.setCursor(0, 1);
+  // print the number of seconds since reset:
+  ui.print(millis()/1000);
+
+  ui.setBacklight(HIGH);
+  delay(500);
+  ui.setBacklight(LOW);
+  delay(500);

 }


No front panel leds for now

No front panel leds for now

--- Receiver/LoRa_RX/LoRa_RX.ino
+++ Receiver/LoRa_RX/LoRa_RX.ino
@@ -9,7 +9,7 @@
 //#include <AES.h>
 #include <RH_RF95.h>

-#include "config.h"
+//#include "config.h"
 #include "Payload.h"
 #include "GardenPayload.h"
 #include "AckPayload.h"
@@ -59,7 +59,8 @@
   Serial.begin(115200);

   // Show the led panel is working.
-  garden_payload.setMsgId(0b10101010);
+  //garden_payload.setMsgId(0b10101010);
+  garden_payload.setMsgId(0);
   updateLedPanel();

   Serial.println("LoRa RX");
@@ -94,7 +95,8 @@
     uint8_t len = sizeof(buf);

     if (rf95.recv(buf, &len)) {
-      digitalWrite(LED, HIGH);
+      //digitalWrite(LED, HIGH);
+
       Serial.println();
       RH_RF95::printBuffer("Received: ", buf, len);
       //Serial.print("headerFrom: "); Serial.println(rf95.headerFrom());
@@ -128,27 +130,27 @@
       Serial.write('\t'); // Payload start byte
       Serial.write(signal_payload_buf, signal_payload.size());

-      updateLedPanel();
+      //updateLedPanel();

-      // There needs to be a small delay before sending the reply.
-      // YUK
-      delay(100);
-
-      // Send a reply
-      ack_payload.setMsgId(garden_payload.getMsgId());
-      //ack_payload.setValue(1234);
-      uint8_t ack_payload_buf[ack_payload.size()];
-      ack_payload.serialize(ack_payload_buf);
-      rf95.send(ack_payload_buf, ack_payload.size());
-      //uint8_t encrypted_ack_buffer[16];
-      //cipher.encryptBlock(encrypted_ack_buffer, ack_payload_buf);
-      //rf95.setHeaderTo(garden_node_id);
-      //rf95.setHeaderFrom(rx_node_id);
-      //rf95.send(encrypted_ack_buffer, 16);
-      rf95.waitPacketSent();
+//      // There needs to be a small delay before sending the reply.
+//      // YUK
+//      delay(100);
+//
+//      // Send a reply
+//      ack_payload.setMsgId(garden_payload.getMsgId());
+//      //ack_payload.setValue(1234);
+//      uint8_t ack_payload_buf[ack_payload.size()];
+//      ack_payload.serialize(ack_payload_buf);
+//      rf95.send(ack_payload_buf, ack_payload.size());
+//      //uint8_t encrypted_ack_buffer[16];
+//      //cipher.encryptBlock(encrypted_ack_buffer, ack_payload_buf);
+//      //rf95.setHeaderTo(garden_node_id);
+//      //rf95.setHeaderFrom(rx_node_id);
+//      //rf95.send(encrypted_ack_buffer, 16);
+//      rf95.waitPacketSent();

-      digitalWrite(LED, LOW);
+      //digitalWrite(LED, LOW);

     } else {
       Serial.println("Receive failed");


rm extra line

rm extra line

--- src/arduino/touchy.ino
+++ src/arduino/touchy.ino
@@ -150,4 +150,3 @@

   send(cmd + 2, 1, 1);
 }
-


bug fixes and visual updates

bug fixes and visual updates

--- rx5808-pro-diversityGc9n/rx5808-pro-diversityGc9n.ino
+++ rx5808-pro-diversityGc9n/rx5808-pro-diversityGc9n.ino
@@ -64,8 +64,8 @@
 #define EEPROM_ADR_TUNE_FAV_LAST 108
 #define EEPROM_ADR_TUNE_FAV_LAST_SEARCH 109
 int EEPROM_ADR_TUNE_FAV[10]  = {100, 101, 102, 103, 104, 105, 106,107,110,111};
-
-//setting the 8 favorite channels memory blocks George Chatzisavvidis GC9N
+int temp_EEPROM_ADR_TUNE_FAV[10]  = {255, 255, 255, 255, 255, 255, 255,255,255,255};
+//setting the 10 favorite channels memory blocks George Chatzisavvidis GC9N

@@ -287,8 +287,8 @@
 #endif
     // Setup Done - Turn Status LED off.
     digitalWrite(led, LOW);
+}

-}

 // LOOP ----------------------------------------------------------------------------

@@ -382,7 +382,7 @@
             } // end switch

             // draw mode select screen
-            //Serial.println (state);
+            ////Serial.println (state);
             if (menu_id>4)
             {drawScreen.mainMenuSecondPage(menu_id);}
             else
@@ -544,19 +544,19 @@

             if (last_state!=STATE_SETUP_MENU  && state_last_used!=STATE_FAVORITE ) // if you didnt came from menu setup  save favorite
             {
-                // Serial.println("bike sto vasiko");
+                // //Serial.println("bike sto vasiko");
                  if ( EEPROM.read(EEPROM_ADR_TUNE_FAV[10]) != 255) //ALL FAVS full gc9n
                   {
                     int lfav;
                     lfav=EEPROM.read(EEPROM_ADR_TUNE_FAV_LAST);
-                    if (lfav==10)
+                    if (lfav<10)
                     {
-                      lfav=1;
+                      lfav=0;
                     }
                     else
                     {
                       lfav=lfav+1;
-                      }
+                    }
                     EEPROM.write(EEPROM_ADR_TUNE_FAV[lfav],255); // rotate the favs if full
                     EEPROM.write(EEPROM_ADR_TUNE_FAV_LAST,lfav);

@@ -571,7 +571,7 @@
                       }
                 }

-                drawScreen.save(state_last_used, channelIndex, pgm_read_word_near(channelFreqTable + channelIndex), call_sign,EEPROM.read(EEPROM_ADR_TUNE_FAV_LAST));
+                drawScreen.save(state_last_used, channelIndex, pgm_read_word_near(channelFreqTable + channelIndex), call_sign,EEPROM.read(EEPROM_ADR_TUNE_FAV_LAST)+1);
             }
             if (last_state==STATE_SETUP_MENU)
             {
@@ -580,14 +580,36 @@
             }

             ///LONG PRESS IN FAVORITES WILL DELETE THE CURRENT FAVORITE CHANNEL
-            if  (state_last_used==STATE_FAVORITE )
-            {
-
+            if  (state_last_used==STATE_FAVORITE && last_state==255)
+            {
               EEPROM.write(EEPROM_ADR_TUNE_FAV[lfavs],255);
-              drawScreen.FavDelete(   pgm_read_word_near(channelFreqTable + channelIndex), lfavs);
+              drawScreen.FavDelete(   pgm_read_word_near(channelFreqTable + channelIndex), lfavs+1);
               RefreshFav=false;
-            }
-
+              for(int i = 0; i<10; i++) {temp_EEPROM_ADR_TUNE_FAV[i] =255;   }  //empty temp
+              //--REORGANIZE FAVS
+                  byte MaxFav=0;
+                  for(int i = 0; i<10; i++)
+                    {
+
+                        if ( EEPROM.read(EEPROM_ADR_TUNE_FAV[i]) != 255) //not used  gc9n
+                        {
+                          FillTemp_Tune_fav(EEPROM.read(EEPROM_ADR_TUNE_FAV[i]));
+                          MaxFav++;
+                        }
+                      }
+
+
+                       for(int i = 0; i<10; i++)
+                        {
+                          EEPROM.write(EEPROM_ADR_TUNE_FAV[i],temp_EEPROM_ADR_TUNE_FAV[i] );
+                          RefreshFav=false;
+                        }
+                        beep(100); // beep
+                         delay(1000);
+                        drawScreen.FavReorg(MaxFav);
+
+            }
+           ///END LONG PRESS IN FAVORITES WILL DELETE THE CURRENT FAVORITE CHANNEL
                 for (uint8_t loop=0;loop<5;loop++)
                 {
                     beep(100); // beep
@@ -698,13 +720,12 @@
     /*****************************************/
     if(state == STATE_FAVORITE )//|| state == STATE_SEEK)
     {
-
         // read rssi
         wait_rssi_ready();
         rssi = readRSSI();
         rssi_best = (rssi > rssi_best) ? rssi : rssi_best;

-//         //Serial.println ("---------------START");
+////Serial.println ("---------------START");

          if (!RefreshFav)
          {
@@ -713,34 +734,30 @@
           HaveFav=false;
           for(int i = 0; i<10; i++)
                 {
-                  //NoFav
+                      //NoFav
                       if (EEPROM.read(EEPROM_ADR_TUNE_FAV[i])!=255)
-                      {  FirstFav=i+1;
+                      {  FirstFav=i;
                         HaveFav=true;
                         }
                 }
                 RefreshFav=true;
         //channel=channel_from_index(channelIndex); // get 0...48 index depending of current channel
-         }
-
-           // handling of keys
+         }  // handling of keys
             if( digitalRead(buttonUp) == LOW)        // channel UP
             {
               delay(KEY_DEBOUNCE); // debounce
                   lfavs++;
-                  if (lfavs>10)
-                  {lfavs=FirstFav;}
+                  if (lfavs>FirstFav){lfavs=0;}
                  //Serial.println  ("UPEEPROM.read(EEPROM_ADR_TUNE_FAV[lfavs]) ");
                  //Serial.print  (EEPROM.read(EEPROM_ADR_TUNE_FAV[lfavs]) );
                  //Serial.print  (" lfavs");
-                 // Serial.println  (lfavs );
-
+                 //Serial.println  (lfavs );
+                  //Serial.print  (" FirstFav");
+                 //Serial.println  (FirstFav );
                     channelIndex=EEPROM.read(EEPROM_ADR_TUNE_FAV[lfavs]) ;
                     if (channelIndex!=255)
                      {
-
-
-                        drawScreen.FavSel(lfavs);
+                        drawScreen.FavSel(lfavs+1);
                         channel=channel_from_index(channelIndex); // get 0...48 index depending of current channel
                         time_screen_saver=millis();
                         beep(50); // beep & debounce
@@ -752,11 +769,12 @@
                         }
                         drawScreen.seekMode(state);
                         EEPROM.write(EEPROM_ADR_TUNE,channelIndex);
-                        Serial.println(channelIndex);
+                        //Serial.println(channelIndex);
                     }
                       else
-                    {lfavs--;}
-
+                    {
+                    lfavs--;
+                      }
             }

@@ -766,13 +784,13 @@

                 delay(KEY_DEBOUNCE); // debounce
                 lfavs--;
-                 if (lfavs<=0)
+                 if (lfavs<0)
                 {lfavs=FirstFav;}

                 channelIndex=EEPROM.read(EEPROM_ADR_TUNE_FAV[lfavs]) ;
                  if (channelIndex!=255)
                 {
-                    drawScreen.FavSel(lfavs);
+                    drawScreen.FavSel(lfavs+1);
                     channel=channel_from_index(channelIndex); // get 0...48 index depending of current channel
                     time_screen_saver=millis();
                     beep(50); // beep & debounce
@@ -1452,3 +1470,16 @@
   digitalWrite(slaveSelectPin, HIGH);
   delayMicroseconds(1);
 }
+
+
+void FillTemp_Tune_fav(int FavChannelx) {
+        for(int i = 0; i<10; i++)
+                {
+                    if ( temp_EEPROM_ADR_TUNE_FAV[i] == 255 && FavChannelx != 255) //not used  gc9n
+                    {
+                      temp_EEPROM_ADR_TUNE_FAV[i]=FavChannelx;
+                      i=12;
+                    }
+
+                }
+}


Automatisch aan voor KAKU

Automatisch aan voor KAKU

--- Arduino/KAKUSender/KAKUSender.ino
+++ Arduino/KAKUSender/KAKUSender.ino
@@ -13,9 +13,9 @@

 // Used for smart lights
 const byte ldrPin = A0;
-const short numValues = 3;
-const short timeFrameBefore = 30;
-const short timeFrameAfter = 90;
+const short numValues = 4;
+const short timeFrameBefore = 30; // 0.5 Hour before
+const short timeFrameAfter = 150; // 2.5 Hour after
 const unsigned long interval = 1000;

 // Smart learning variables
@@ -28,11 +28,14 @@
 byte timeArrayPosition = 0;
 unsigned long lastCheck;

+unsigned short lastDay = 0;
+
 // KAKU Transmitter
 NewRemoteTransmitter transmitter(transmitterAddress, transmitterPin, transmitterPeriod);

 // Ethernet details
-byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
+byte mac[] = {
+  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
 char hostname[] = "ardnmtn.barthopster.nl";
 int port = 8181;

@@ -67,7 +70,8 @@
 void onData(SocketIOClient client, char *data) {
   if (strstr(data, "Time:")) {
     timeUpdate(data + 5);
-  } else {
+  }
+  else {
     int lightNumber;

     // Light 1
@@ -96,8 +100,10 @@
     // Turn on the light
     if (strstr(data, "on")) {
       transmitter.sendUnit(lightNumber, true);
-      updateSmartValues((hour()*60) + minute(),analogRead(ldrPin));
-    } else { // Turn off
+      // Enable this to update SmartValue updating, untested
+      // updateSmartValues();
+    }
+    else { // Turn off
       transmitter.sendUnit(lightNumber, false);
     }

@@ -118,8 +124,9 @@
     sprintf(lightCommand, "light%01u:%s", receivedCode.unit, receivedCode.switchType == NewRemoteCode::off ? "false" : "true");

     client.send(lightCommand);
-
-    updateSmartValues((hour()*60) + minute(),analogRead(ldrPin));
+
+    // Enable this to update SmartValue updating, untested
+    // updateSmartValues();
   }

   // Enable the receiver again
@@ -129,7 +136,7 @@
 // Check for turing on the light using the smart function
 void smartCheck() {
   unsigned long curTime = millis();
-  if (curTime > (lastCheck + interval) || lastCheck < curTime) {
+  if ((day() != lastDay)&&(curTime > (lastCheck + interval) || lastCheck < curTime)) {
     lastCheck = curTime;
     //Serial.println("Check");
     short currentLightValue = analogRead(ldrPin);
@@ -139,6 +146,7 @@
       short curTimeMinutes = hour() * 60 + minute();
       if (curTimeMinutes > (minutesThreshold - timeFrameBefore) && curTimeMinutes < (minutesThreshold + timeFrameAfter)) {
         Serial.println("Lights on");
+        lastDay = day();
         NewRemoteReceiver::disable();
         for (int i = 0; i < 4; i++) {
           transmitter.sendUnit(i, true);
@@ -152,7 +160,11 @@
   }
 }

-void updateSmartValues(short timeMinutes, short LDRLight) {
+// Adds current values to the smartlearning, currently not used because of lack of time
+void updateSmartValues() {
+  short timeMinutes = hour() * 60 + minute();
+  short LDRLight = analogRead(ldrPin);
+
   // Add the new values
   if (timeArrayPosition >= numValues)
     timeArrayPosition = 0;
@@ -196,3 +208,4 @@

   setTime(hour, minute, second, day, month, year);
 }
+


Remove useless sample code

Remove useless sample code

--- Arduino/McLighting/McLighting.ino
+++ Arduino/McLighting/McLighting.ino
@@ -376,8 +376,8 @@
   server.on("/esp_status", HTTP_GET, []() {
     String json = "{";
     json += "\"heap\":" + String(ESP.getFreeHeap());
-    json += ", \"analog\":" + String(analogRead(A0));
-    json += ", \"gpio\":" + String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));
+    // json += ", \"analog\":" + String(analogRead(A0));
+    // json += ", \"gpio\":" + String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));
     json += "}";
     server.send(200, "text/json", json);
     json = String();


Changed fire to A_BUTTON

Changed fire to A_BUTTON

--- ArduBreakout/ArduBreakout.ino
+++ ArduBreakout/ArduBreakout.ino
@@ -8,8 +8,18 @@
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  */
+
+ /*
+  * 11/19/2015
+  * Modifications to game by Darrell Little
+  * Fire Button changed to A_BUTTON (B_BUTTON for
+  * pause still does not work).
+  * Increase game play to 9 lives, display the
+  * remaining lives.
+  */

 #include <SPI.h>
+
 #include "Arduboy.h"

 #include <EEPROM.h>
@@ -235,7 +245,7 @@
     xb=xPaddle + 5;

     //Release ball if FIRE pressed
-    pad3 = arduboy.pressed(B_BUTTON);
+    pad3 = arduboy.pressed(A_BUTTON);
     if (pad3 == 1 && oldpad3 == 0)
     {
       released=true;
@@ -322,7 +332,7 @@
   {
     delay(150);
     //Unpause if FIRE is pressed
-    pad2 = arduboy.pressed(B_BUTTON);
+    pad2 = arduboy.pressed(A_BUTTON);
     if (pad2 > 1 && oldpad2 == 0 && released)
     {
         arduboy.fillRect(52, 45, 30, 11, 0);
@@ -382,7 +392,7 @@
   for(int i = 0; i < n; i++)
   {
     delay(15);
-    pad = arduboy.pressed(B_BUTTON);
+    pad = arduboy.pressed(A_BUTTON);
     if(pad == 1 && oldpad == 0)
     {
       oldpad3 = 1; //Forces pad loop 3 to run once
@@ -589,7 +599,7 @@
       }
     }

-    if (arduboy.pressed(B_BUTTON))
+    if (arduboy.pressed(A_BUTTON))
     {
       if (index < 2)
       {
@@ -719,8 +729,8 @@
     drawPaddle();

     //Pause game if A button pressed
-    // 11/15/2015 - Changed to A_BUTTON
-    pad = arduboy.pressed(A_BUTTON);
+    // 11/19/2015 - Changed to B_BUTTON
+    pad = arduboy.pressed(B_BUTTON);

     if(pad >1 && oldpad==0 && released)
     {


Adjusting baudrate for ATtiny85 VirtualWire example.

--- examples/VWI/CosaVWIsender/CosaVWIsender.ino
+++ examples/VWI/CosaVWIsender/CosaVWIsender.ino
@@ -48,12 +48,12 @@
  || defined(__AVR_ATtiny85__)
 VWI::Transmitter tx(Board::D2);
 OutputPin pw(Board::D1);
-#define SPEED 2000
 #else
 VWI::Transmitter tx(Board::D12);
 OutputPin pw(Board::D10);
-#define SPEED 4000
 #endif
+
+const uint16_t SPEED = 4000;

 void setup()
 {


Correct motors pins (new board)

Correct motors pins (new board)

--- pug.ino
+++ pug.ino
@@ -4,11 +4,11 @@
 #define DEBUG_ULTRASON false

 // Pins
-#define RIGHT_MOTOR_PIN_1 11
-#define RIGHT_MOTOR_PIN_2 10
-
-#define LEFT_MOTOR_PIN_1 8
-#define LEFT_MOTOR_PIN_2 9
+#define RIGHT_MOTOR_PIN_1 8
+#define RIGHT_MOTOR_PIN_2 9
+
+#define LEFT_MOTOR_PIN_1 11
+#define LEFT_MOTOR_PIN_2 10

 #define COLOR_ANALOG_PIN 1
 #define JUMPER_PIN 3


This commit is a very big release. You can see the notes in the Releases section

--- TinyScreenClockAndDisplay.ino
+++ TinyScreenClockAndDisplay.ino
@@ -23,54 +23,48 @@

 DS1339 RTC = DS1339();

-unsigned long lastReceivedTime=0;
+int displayState=0;
+int buttonReleased=0;
+int countdown = 0;

-unsigned long lastDisplayUpdate=0;
-unsigned long displayUpdateInterval=1000;
-
-
-unsigned long sleepTimer=0;
-unsigned long sleepTimeout=5000;
-int displayState=0;
-int buttonReleased=1;
-
-char notificationLine1[20]="Release 2.0.0";
-char notificationLine2[20]="";
+char notificationLine1[20]="Release 2.1.1";

 void setup(void) { // setup
   Wire.begin();
   display.begin();
   display.setFlip(1);
-  display.setBrightness(3);
+  display.setBrightness(4);
   RTC.start();
+  displayBattery();
   display.fontColor(GREEN,BLACK);
   display.setFont(liberationSans_16ptFontInfo);
   display.setCursor(0,10);
-  display.print("Hello");
+  display.print("Welcome");
+  display.setCursor(0,40);
+  display.print("Booting up");
+  Serial.print("Initializing");
   delay(2000);
   display.clearWindow(0,0,0,0);
 }

 void loop() {
   byte buttons = display.getButtons();
-  if(buttonReleased && buttons){
-  	if(displayState){
-      notificationLine1[0]='\0';
-      memcpy(notificationLine2,"  No notifications.",strlen("  No notifications."));
-      displayNotifications();
+  if(buttons != 0)
+  {
+    displayState = 1;
+    display.on();
+    countdown = 90;
   	}
-    display.on();
-    buttonReleased=0;
-  }
-  if(!buttonReleased && !(buttons&0x0F)){
-    buttonReleased=1;
-  }
-  if(millis() > sleepTimer+sleepTimeout){
-    if(displayState){
-      displayState=0;
-      display.off();
+    if(buttons == 0){
+      countdown=countdown-1;
+      Serial.println(countdown);
     }
-  }
+  if (countdown<=0){
+  displayState=0;
+  display.off();
+}
+  displayNotifications();
+  displayBattery();
   unsigned char second;
   unsigned char minute;
   unsigned char hour;
@@ -85,8 +79,7 @@
         day = RTC.getDays();
         month = RTC.getMonths();
         year = RTC.getYears();
-
-  display.setFont(liberationSans_10ptFontInfo);
+  display.setFont(liberationSans_10ptFontInfo);
   // Date
   display.setCursor(0,10);
   display.fontColor(BLUE,BLACK);
@@ -100,7 +93,12 @@
   // Time
   display.setCursor(0,30);
   display.fontColor(GREEN,BLACK);
-  display.print(hour);
+  int hours = RTC.getHours();
+  if (hours > 12)
+{
+  hours = hours - 12;
+}
+display.print(hours);
   display.print(":");

   if (RTC.getMinutes() < 10) // if minutes under 10
@@ -129,8 +127,6 @@
    {
      display.fontColor(RED,BLACK);
      display.print(second);
-     displayBattery();
-     displayNotifications();
    }
 }
 void displayNotifications(){


Update iGPS.ino

Update iGPS.ino

添加注释


lcd update

lcd update

--- _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
+++ _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
@@ -71,7 +71,7 @@
   B01110,
   B11111,
   B11111,
-  B01110
+  B01110,
 };

 byte picatura[8] = //icon for water droplet
@@ -146,6 +146,7 @@
   B11011,
 };

+/*
 byte watticon[8] =
 {
   B00000,
@@ -157,8 +158,7 @@
   B01110,
   B00000,
 };
-
-
+*/

 PubSubClient client(wifiClient, server);

@@ -335,7 +335,9 @@
   lcd.createChar(5, pirfill);
   lcd.createChar(6, powericon);
   lcd.createChar(7, nemoicon);
+  /*
   lcd.createChar(8, watticon);
+  */

   lcd.setCursor(0, 1);
   lcd.write(1);
@@ -372,8 +374,10 @@
   lcd.setCursor(6, 2);
   lcd.print("%");

+/*
   lcd.setCursor(14, 2);
   lcd.write(8);
+*/

   H  = -1000 ;
   T1 = -1000 ;
@@ -570,28 +574,34 @@

 void displaydustDensity()
 {
-  /*
-  int n = int(dustDensity / 0.065) ;
-
+
+  int n = int(dustDensity / 0.05) ;
+
+  if ( n > 9 ) {
+    n = 9 ;
+  }
+
   if (DEBUG_PRINT) {
-    Serial.print("===> dustDensity ");
+    Serial.print(" ===> dustDensity ");
     Serial.print(dustDensity);
     Serial.print(" ===>  ");
-    Serial.println(int(dustDensity / 0.065));
-  }
-
-  lcd.setCursor(10, 3);
+    Serial.println(int(dustDensity / 0.05));
+  }
+
+
   for ( int i = 0 ; i < n ; i++) {
     lcd.setCursor(10 + i, 3);
+    Serial.print("*");
     lcd.write(4);
   }

-  lcd.setCursor(10 + i, 3);

   for ( int o = 0 ; o < ( 9 - n) ; o++) {
-    lcd.print(" ");
-  }
-  */
+    lcd.setCursor(10 + n + o, 3);
+    lcd.print(".");
+    Serial.print("+");
+  }
+  Serial.println("");
 }

 void requestSharp()


Change SHT10 library for correct readings

--- arduinoApp/gardenSketch/gardenSketch.ino
+++ arduinoApp/gardenSketch/gardenSketch.ino
@@ -2,16 +2,17 @@
 Arduino based self regulating kitchen garden

  */
-
-#include <SHT1x.h>
 #include <DHT.h>

+#include <Sensirion.h>
+
 // soil related setup
-#define soilDataPin  3
-#define soilClockPin 4
-SHT1x soilSensor(soilDataPin, soilClockPin);
+#define dataPin 3
+#define clockPin 4
+Sensirion sht = Sensirion(dataPin, clockPin);
 float soilTemperature;
 float soilMoisture;
+float dewpoint;

 // air temperature related setup
 #define DHTPIN 2        // Humidity and temperature sensor pin
@@ -29,11 +30,14 @@
 int ledPin = 13; // this is just for checking activity

 // setup sensor reading interval
-unsigned long prevMillis = 0;
-unsigned long interval = 1000;
+unsigned long prevMillis = 0; // initialize previous milliseconds variable
+unsigned long interval = 5000; // number of milliseconds to wait

 // Initialize settings
 void setup() {
+  // start serial
+  Serial.begin(9600);
+
   // Initialize output pins.
   pinMode(ledPin, OUTPUT);

@@ -56,13 +60,15 @@
     LDRValue = analogRead(lightSensorPin); // read light level from LDR
     airHumidity = airSensor.readHumidity(); // read humidity from DHT
     airTemperature = airSensor.readTemperature(); // read temperature from DHT
-    soilMoisture = soilSensor.readHumidity(); // read temperature from SHT10
-    soilTemperature = soilSensor.readTemperatureC(); // read humidity from SHT10
-    Serial.println(LDRValue);
-    Serial.println(airHumidity);
-    Serial.println(airTemperature);
-    Serial.println(soilMoisture);
-    Serial.println(soilTemperature);
+    sht.measure(&soilTemperature, &soilMoisture, &dewpoint);
+
+  Serial.print("Temperature: ");
+  Serial.print(temperature);
+  Serial.print(" C, Moisture: ");
+  Serial.print(moisture);
+  Serial.print(" %, Dewpoint: ");
+  Serial.print(dewpoint);
+  Serial.println(" C");
   }

 }


Added whitespace to test Github app functionality

--- sketch_oct19a/sketch_oct19a.ino
+++ sketch_oct19a/sketch_oct19a.ino
@@ -1,5 +1,5 @@
-// Including the dht library used by the humidity/temperature sensor
-#include <dht.h>
+// Including the dht library used by the humidity/temperature sensor
+#include <dht.h>

 // Including the LiquidCrystal library used by the LCD display
 #include <LiquidCrystal.h>
@@ -14,25 +14,25 @@
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

 void setup() {
-
+
   // Initialize the serial virtual output display
   Serial.begin(9600);
-
+
   // Inizialize the lcd instance
   lcd.begin(16, 2);
-
+
   // Let system settle
   delay(300);

   // Print in Serial display
   Serial.println("Humidity and temperature\n\n");
-
+
   // Wait rest of 1000ms recommended delay before accessing the sensor
   delay(700);
 }

 void loop() {
-
+
   //This is the "heart" of the sketch
   DHT.read11(dht_dpin);


Verbessert_delaytime

--- Projekt-Code/Projekt-Code.ino
+++ Projekt-Code/Projekt-Code.ino
@@ -33,19 +33,19 @@
       lcd.cursor();
       lcd.blink();
       digitalWrite(13,LOW);
-      delay(300);
+      delay(500);
       digitalWrite(13,HIGH);
-      delay(300);
+      delay(500);
       digitalWrite(13,LOW);
-      delay(300);
+      delay(500);
       digitalWrite(13,HIGH);
-      delay(300);
+      delay(500);
       digitalWrite(13,LOW);
-      delay(300);
-      d = ultras()*10/58;
+      delay(500);
       digitalWrite(8,HIGH);
       digitalWrite(13,HIGH);
-      delay(500);
+      delay(800);
+      d = ultras()*10/58;
       digitalWrite(8,LOW);
       digitalWrite(13,LOW);
       lcd.print("Abstand:");


trying to fix mm/h non-reporting alert bug

--- mwsIWMIv3/mwsIWMIv3.ino
+++ mwsIWMIv3/mwsIWMIv3.ino
@@ -383,6 +383,12 @@
     minutes = 0;
     //SMS Alert if hourly rain > 10 mm/h
     //Modified after Lasindu's request 22 April 2016
+    //Calculate amount of rainfall for the last 60 minutes
+    rainin = 0;
+
+    for(int i = 0 ; i < 60 ; i++)
+     rainin += rainHour[i];
+
     if(rainin > 10.0){
       sendSMS();
     }


Added Outside temperature sensor

Added Outside temperature sensor

--- freezer_monitor_v0_5/freezer_monitor_v0_5.ino
+++ freezer_monitor_v0_5/freezer_monitor_v0_5.ino
@@ -39,6 +39,7 @@
   unsigned int ldr;
   unsigned int hall;
   float tempInsideC;
+  float tempOutsideC;
 };

 struct SensorThresholds {
@@ -46,6 +47,8 @@
   unsigned int door;
   float minTempInsideC;
   float maxTempInsideC;
+  float minTempOutsideC;
+  float maxTempOutsideC;
 };

 // Controller MAC address - must be unique on network for DHCP to work
@@ -61,6 +64,8 @@
 OneWire oneWire(DPIN_ONEWIRE);
 DallasTemperature oneWireSensors(&oneWire);
 DeviceAddress thermometerInside  = { 0x10, 0x9B, 0x96, 0x53, 0x02, 0x08, 0x00, 0xF0 };
+DeviceAddress thermometerOutside  = { 0x10, 0x74, 0x6C, 0x53, 0x02, 0x08, 0x00, 0xE6 };
+

 // container for sensor data
 SensorData sensorData;
@@ -155,8 +160,10 @@
 void default_sensor_thresholds() {
   sensorThresholds.light = 50;
   sensorThresholds.door = HIGH;
-  sensorThresholds.minTempInsideC = 19.00;
-  sensorThresholds.maxTempInsideC = 20.00;
+  sensorThresholds.minTempInsideC = 0.00;
+  sensorThresholds.maxTempInsideC = 2.00;
+  sensorThresholds.minTempOutsideC = 19.00;
+  sensorThresholds.maxTempOutsideC = 20.00;
 }

 //------------------------------------------------------------------------------
@@ -184,6 +191,8 @@
   strcat(content, buffer);
   sprintf_float_field(buffer, false, "tempInsideC", sensorData.tempInsideC, 100);
   strcat(content, buffer);
+  sprintf_float_field(buffer, false, "tempOutsideC", sensorData.tempOutsideC, 100);
+  strcat(content, buffer);
   strcat(content, "}");
   restServer.generate_response(client, content);
 }
@@ -200,6 +209,10 @@
   strcat(content, buffer);
   sprintf_float_field(buffer, false, "maxTempInsideC", sensorThresholds.maxTempInsideC, 100);
   strcat(content, buffer);
+  sprintf_float_field(buffer, false, "minTempOutsideC", sensorThresholds.minTempOutsideC, 100);
+  strcat(content, buffer);
+  sprintf_float_field(buffer, false, "maxTempOutsideC", sensorThresholds.maxTempOutsideC, 100);
+  strcat(content, buffer);
   strcat(content, "}");
   restServer.generate_response(client, content);
 }
@@ -219,6 +232,7 @@
   // read one-wire sensors
   oneWireSensors.requestTemperatures();
   sensorData.tempInsideC = oneWireSensors.getTempC(thermometerInside);
+  sensorData.tempOutsideC = oneWireSensors.getTempC(thermometerOutside);

   // enable access to sensor data
   sensorData.available = true;


it's gonna work this time

it's gonna work this time

--- examples/pseudopod-wifi/pseudopod-wifi.ino
+++ examples/pseudopod-wifi/pseudopod-wifi.ino
@@ -4,6 +4,8 @@

 #include "pb_arduino_encode.h"
 #include "pb_arduino_decode.h"
+
+#include "MemoryFree.h"

 #include <tentacle-pseudopod.h>
 #include <tentacle.h>
@@ -26,6 +28,7 @@

 int status = WL_IDLE_STATUS;
 WiFiClient conn;
+std::vector<Pin> pins;

 void setup() {
   Serial.begin(9600);
@@ -36,18 +39,32 @@
   pseudopod = new Pseudopod(conn, conn);
 }

+int freeRam ()
+{
+  extern int __heap_start, *__brkval;
+  int v;
+  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
+}
+
 void loop() {
+  connectToServer();
   Serial.println("writing");
   Serial.flush();
-  std::vector<Pin> pins;
-  for(int i = 0; i < 300; i++) {
+  pins.clear();
+  for(int i = 0; i < 80; i++) {
     pins.push_back(Pin(i,NULL, i));
   }
+  Serial.println("pushed a lot of pins into a vector");
   int written = pseudopod->writeStateMessage(pins);
   Serial.print(written);
-  Serial.println("bytes written.");
+  Serial.println(" bytes written.");
+  Serial.print(freeMemory());
+  Serial.print(" : ");
+  Serial.print(freeRam());
+  Serial.println(" bytes free");
   Serial.flush();
   delay(2000);
+  conn.stop();
 }

 void setupWifi() {
@@ -55,14 +72,17 @@

   Serial.println("\nWifi initialized. Connecting to server.");
   printWifiStatus();
-  while(!conn.connect(server, port)) {
-    Serial.println("Can't connect to the server. Rebooting.");
-    Serial.flush();
-    softReset();
-  }

   Serial.println("connected to server");
   Serial.flush();
+}
+
+void connectToServer() {
+  while(!conn.connect(server, port)) {
+      Serial.println("Can't connect to the server.");
+      Serial.flush();
+      delay(1000);
+    }
 }

 void initWifi() {


Update Rollup_logic.ino

Update Rollup_logic.ino

--- Rollup_logic/Rollup_logic.ino
+++ Rollup_logic/Rollup_logic.ino
@@ -4,9 +4,10 @@
 #define Open 1
 #define Close 0

+#define LIMITSWITCH 2
 #define ONE_WIRE_BUS 3
-#define ROLLUP1_OPEN  12//relais on/off - moteur1
-#define ROLLUP1_CLOSE  11 //relais gauche/droite - moteur1
+#define ROLLUP1_OPEN  10//relais on/off - moteur1
+#define ROLLUP1_CLOSE  9 //relais gauche/droite - moteur1
 #define FAN  8 //relais ventilation forcée
 #define CHAUFFAGE1 7 //relais fournaise1
 #define CHAUFFAGE2 6 // relais fournaise2
@@ -36,12 +37,12 @@
 int TEMP_FOURNAISE1 = TEMP_CIBLE-2;
 int TEMP_FOURNAISE2 = TEMP_CIBLE-4;

-byte HYST_ROLLUP = 2;           //hysteresis rollup
-byte HYST_VENT = 2;             //hysteresis ventilation
+byte HYST_ROLLUP = 1;           //hysteresis rollup
+byte HYST_VENT = 1;             //hysteresis ventilation
 byte HYST_FOURNAISE1 = 2;       //hysteresis fournaise 1
 byte HYST_FOURNAISE2 = 2;       //hysteresis fournaise 2

-long OPENING_TIME= 3000;       //temps de rotation des moteurs pour ouvrir d'un quart de tour(en mili-secondes)
+long OPENING_TIME = 3000;       //temps de rotation des moteurs pour ouvrir d'un quart de tour(en mili-secondes)
 long CLOSING_TIME = 2000;       //temps de rotation des moteurs pour fermer d'un quart de tour(en mili-secondes)
 long PAUSE_TIME = 1000;         //temps d'arrêt entre chaque ouverture/fermeture(en mili-secondes)
 //incréments d'ouverture(nombre d'incréments d'ouverture = PCT_OPEN/NB_OF_STEPS_IN_ANIMATION = 25/5 = 5 incréments d'ouverture)
@@ -50,14 +51,13 @@
 //Autres variables
 const int SLEEPTIME = 900; //temps de pause entre chaque exécution du programme(en mili-secondes)

-
-volatile byte rollupState = LOW;
+volatile byte rollupState = HIGH;

 void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   sensors.begin();
-
+  pinMode(LIMITSWITCH, INPUT_PULLUP);
   pinMode(ROLLUP1_OPEN, OUTPUT);
   digitalWrite(ROLLUP1_OPEN, LOW);
   pinMode(ROLLUP1_CLOSE, OUTPUT);
@@ -71,7 +71,7 @@
   attachInterrupt(digitalPinToInterrupt(2), confirmOpening, CHANGE);

   //Remise à niveau des rollup
-  Reset();
+  //Reset();
 }

 void loop() {
@@ -137,6 +137,7 @@
   } else if ((greenhouseTemperature < (TEMP_VENTILATION - HYST_VENT))||(rollupState == LOW)) {
     setFan(OFF);
   }
+  delay(1000);
 }

@@ -175,6 +176,7 @@
 //Programme d'ouverture des rollup
 void openSides() {
   if (opened < 100) {
+    Serial.println(opened);
     Serial.println(F(""));
     Serial.println(F("  Opening"));
     digitalWrite(ROLLUP1_OPEN, ON);
@@ -190,6 +192,7 @@
 //Programme de fermeture des rollups
 void closeSides() {
   if (opened > 0) {
+    Serial.println(opened);
     Serial.println(F(""));
     Serial.println(F("  Closing"));
     digitalWrite(ROLLUP1_CLOSE, ON);
@@ -250,5 +253,3 @@
 void confirmOpening() {
   rollupState =! rollupState;
 }
-
-


pruned images from Tunes example

pruned images from Tunes example


cleanup!

cleanup!

--- gps-clock/main.ino
+++ gps-clock/main.ino
@@ -9,13 +9,16 @@
 int lastSecond = 0;
 bool ledState = false;

+// lets keep the radio off until we get a fix, or 2 minutes go by.
 SYSTEM_MODE(SEMI_AUTOMATIC);
+

 void setup() {
     // electron asset tracker shield needs this to enable the power to the gps module.
     pinMode(D6, OUTPUT);
     digitalWrite(D6, LOW);

+    // for blinking.
     pinMode(D7, OUTPUT);
     digitalWrite(D7, LOW);

@@ -31,13 +34,10 @@

     // request everything!
     GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_ALLDATA);
-
-    // request absolutely everything!
-    //GPS.sendCommand("$PMTK314,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1*29");
     delay(250);

     // turn off antenna updates
-    GPS.sendCommand(PGCMD_ANTENNA);
+    GPS.sendCommand(PGCMD_NOANTENNA);
     delay(250);
 }

@@ -51,6 +51,7 @@
     while (mySerial.available()) {
         char c = GPS.read();

+        // lets echo the GPS output until we get a good clock reading, then lets calm things down.
         if (!hasGPSTime) {
             Serial.print(c);
         }
@@ -86,65 +87,9 @@
                 );

             Serial.println(currentTime);
-
-
         }
         else {
             Serial.println("GPS TIME: searching the skies...");
         }
     }
-}
-
-
-
-
-
-//
-//void buildGpsDebugOutput() {
-//
-
-//    Serial.print("Fix: "); Serial.print((int)GPS.fix);
-//    Serial.print(" quality: "); Serial.println((int)GPS.fixquality);
-//
-//    //if (GPS.fix)
-//    //{
-//    Serial.print("Location: ");
-//    Serial.print(GPS.latitude, 4);
-//    Serial.print(GPS.lat);
-//    Serial.print(", ");
-//
-//    Serial.print(GPS.longitude, 4);
-//    Serial.println(GPS.lon);
-//
-//    Serial.print("Speed (knots): "); Serial.println(GPS.speed);
-//    Serial.print("Angle: "); Serial.println(GPS.angle);
-//    Serial.print("Altitude: "); Serial.println(GPS.altitude);
-//    Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
-//
-//    //TODO: BETTER +/- for longitude
-//
-//   // _gpsDebugLines = ...
-//}
-//
-
-
-//int performGPSCommand(String gpsCmd) {
-//    nextGpsCommand = gpsCmd;
-//
-//    String cmd = String::format("$%s*%02x", gpsCmd.c_str(), crc8(gpsCmd));
-//    mySerial.println(cmd);
-//    return 1;
-//}
-
-
-
-int crc8(String str) {
-  int len = str.length();
-  const char * buffer = str.c_str();
-
-  int crc = 0;
-  for(int i=0;i<len;i++) {
-    crc ^= (buffer[i] & 0xff);
-  }
-  return crc;
-}
+}


Added input open/closed detection

Added input open/closed detection

--- arduinoHouse/mqttRelayWithState/mqttRelayWithState.ino
+++ arduinoHouse/mqttRelayWithState/mqttRelayWithState.ino
@@ -22,10 +22,13 @@

   The current state is stored in EEPROM and restored on bootup

+  Pins 2->7 are used as input (switch) detection. Their state are published on domogik/relayArduinoPin1
+
 */
 #include <Ethernet.h>
 #include <PubSubClient.h>
 #include <EEPROM.h>
+#include <Bounce2.h>

 // Update these with values suitable for your network.
 byte mac[]    = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEE };
@@ -46,6 +49,7 @@
 const char* outTopic = "domogik/relayClient";
 const char* inTopic = "domogik/in/relay/#";
 const char* outRelayTopic = "domogik/in/relay/r";
+const char* outPinTopic = "domogik/relayArduinoPin";

 bool relayStates[] = {
   HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH
@@ -55,6 +59,20 @@
   22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53
 };       // an array of pin numbers to which LEDs are attached
 int pinCount = 32;
+
+#define PIN_DETECT_1 2
+#define PIN_DETECT_2 3
+#define PIN_DETECT_3 4
+#define PIN_DETECT_4 5
+#define PIN_DETECT_5 6
+#define PIN_DETECT_6 7
+Bounce debounce1 = Bounce();
+Bounce debounce2 = Bounce();
+Bounce debounce3 = Bounce();
+Bounce debounce4 = Bounce();
+Bounce debounce5 = Bounce();
+Bounce debounce6 = Bounce();
+

 void setup_ethernet() {

@@ -90,6 +108,15 @@
   strcpy(outputTopicBuff, outRelayTopic);
   char relaybuffer[5];
   sprintf(relaybuffer, "%d", relayNbr);
+  strcat(outputTopicBuff, relaybuffer);
+  client.publish(outputTopicBuff, state);
+}
+
+void publishPinState(int pinNbr, char* state) {
+  char outputTopicBuff[100];
+  strcpy(outputTopicBuff, outPinTopic);
+  char relaybuffer[5];
+  sprintf(relaybuffer, "%d", pinNbr);
   strcat(outputTopicBuff, relaybuffer);
   client.publish(outputTopicBuff, state);
 }
@@ -179,6 +206,28 @@
     digitalWrite(relayPins[thisPin], relayStates[thisPin]);
   }

+
+  //input
+  pinMode(PIN_DETECT_1, INPUT_PULLUP);
+  pinMode(PIN_DETECT_2, INPUT_PULLUP);
+  pinMode(PIN_DETECT_3, INPUT_PULLUP);
+  pinMode(PIN_DETECT_4, INPUT_PULLUP);
+  pinMode(PIN_DETECT_5, INPUT_PULLUP);
+  pinMode(PIN_DETECT_6, INPUT_PULLUP);
+  debounce1.attach(PIN_DETECT_1);
+  debounce2.attach(PIN_DETECT_2);
+  debounce3.attach(PIN_DETECT_3);
+  debounce4.attach(PIN_DETECT_4);
+  debounce5.attach(PIN_DETECT_5);
+  debounce6.attach(PIN_DETECT_6);
+  debounce1.interval(50);
+  debounce2.interval(50);
+  debounce3.interval(50);
+  debounce4.interval(50);
+  debounce5.interval(50);
+  debounce6.interval(50);
+
+
   digitalWrite(13, LOW);
   delay(500);
   digitalWrite(13, HIGH);
@@ -195,6 +244,49 @@
   if (!client.connected()) {
     reconnect();
   }
+  debounce1.update();
+  if ( debounce1.fell() ) {
+    publishPinState(1, "1");
+  }
+  if ( debounce1.rose() ) {
+    publishPinState(1, "0");
+  }
+  debounce2.update();
+  if ( debounce2.fell() ) {
+    publishPinState(2, "1");
+  }
+  if ( debounce2.rose() ) {
+    publishPinState(2, "0");
+  }
+  debounce3.update();
+  if ( debounce3.fell() ) {
+    publishPinState(3, "1");
+  }
+  if ( debounce3.rose() ) {
+    publishPinState(3, "0");
+  }
+  debounce4.update();
+  if ( debounce4.fell() ) {
+    publishPinState(4, "1");
+  }
+  if ( debounce4.rose() ) {
+    publishPinState(4, "0");
+  }
+  debounce5.update();
+  if ( debounce5.fell() ) {
+    publishPinState(5, "1");
+  }
+  if ( debounce5.rose() ) {
+    publishPinState(5, "0");
+  }
+  debounce6.update();
+  if ( debounce6.fell() ) {
+    publishPinState(6, "1");
+  }
+  if ( debounce6.rose() ) {
+    publishPinState(6, "0");
+  }
+
   client.loop();
 }


removed -Wconversions flag

removed -Wconversions flag

--- Arduino/hardware/V0p2_Main_PCB_REV7_DORM1_and_REV8/testsuite/201611/REV7Minimal/REV7Minimal.ino
+++ Arduino/hardware/V0p2_Main_PCB_REV7_DORM1_and_REV8/testsuite/201611/REV7Minimal/REV7Minimal.ino
@@ -289,3 +289,11 @@
  * Date:        Device: Wake (Sleep) @ Voltage
  * 20161111     REV7:   1.5 (1.1) @ 2.5V        REV11:  0.45 (0.03) @ 2.5 V
  */
+
+/**
+ * @note    REV7 Power consumption investigation
+ * Baseline:                1.1 mA
+ * - Motor decoupling caps: 1.1 mA
+ * - Potentiometer:         1.0 mA
+ *
+ */


Function ProcessReadEEPROM() improved. Uses iterative appending to the buffer via sprintf(buf + strlen(buf), data) instead of hard coding every value.

--- skypointer.ino
+++ skypointer.ino
@@ -232,25 +232,26 @@
 // Read errors from EEPROM
 void ProcessReadEEPROM () {
   /* Reads 12 bytes from EEPROM, 4 by each error, and sends them via Serial port.
-
-  */
-  /*
+
   A string is generated in the form:
     R b_0 b_1 b_2 ... b_10 b_11\r
   where 'b_n' is the n-th byte.
   The size of the buffer is then obtained:
     R   --> 1 byte
-    b_x --> 3 bytes
+    b_x --> 3 bytes + y space
     \r  --> 2 bites
-  So we need to store (1 + 12x3 + 2) bytes = 39 bytes
+  So we need to store (1 + 12x4 + 2) bytes = 51 bytes
   */
-  char buf[39];
-  uint8_t d[12];    // We have 12 values
-  for (int k = 0; k < sizeof(d); k++) {
-    d[k] = EEPROM.read(k); // Read data
-  }
-  // Fill the buffer with the read data
-  sprintf (buf, "R %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d\r", d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10], d[11]);
+  char buf[51];
+  // Init the buffer with the respose code letter
+  sprintf (buf, "R");
+  // Read EEPROM positions
+  for (int k = 0; k < 12; k++) {
+    // Append to the buffer
+    sprintf(buf + strlen(buf), " %03d", EEPROM.read(k));
+  }
+  // Append eol
+  sprintf (buf + strlen(buf), "\r");
   // Send the buffer via Serial
   Serial.print(buf);
 }


Update JSON generator

Update JSON generator

--- tests/GenerateJSON/GenerateJSON.ino
+++ tests/GenerateJSON/GenerateJSON.ino
@@ -1,24 +1,24 @@
-#include "BlynkApiArduino.h"
-#include "Blynk/BlynkDetectDevice.h"
+#include <Blynk.h>
+#include <Blynk/BlynkDetectDevice.h>

-#if !defined(BOARD_PWM_MAX)
-  #if   defined(PWMRANGE)
-    #define BOARD_PWM_MAX    PWMRANGE
-  #elif defined(PWM_RESOLUTION)
-    #define BOARD_PWM_MAX    (2^(PWM_RESOLUTION)-1)
-  #else
-    #error "Cannot detect BOARD_PWM_MAX"
-  #endif
+/*
+ * Pins Quantity
+ */
+
+#if defined(NUM_DIGITAL_PINS)
+  #define BOARD_DIGITAL_MAX int(NUM_DIGITAL_PINS)
+#elif defined(PINS_COUNT)
+  #define BOARD_DIGITAL_MAX int(PINS_COUNT)
+#else
+  #warning "BOARD_DIGITAL_MAX not detected"
+  #define BOARD_DIGITAL_MAX 32
 #endif

-#if !defined(BOARD_ANALOG_MAX)
-  #if   defined(PWMRANGE)
-    #define BOARD_ANALOG_MAX    PWMRANGE
-  #elif defined(PWM_RESOLUTION)
-    #define BOARD_ANALOG_MAX    (2^(PWM_RESOLUTION)-1)
-  #else
-    #error "Cannot detect BOARD_ANALOG_MAX"
-  #endif
+#if defined(NUM_ANALOG_INPUTS)
+  #define BOARD_ANALOG_IN_MAX int(NUM_ANALOG_INPUTS)
+#else
+  #warning "BOARD_ANALOG_IN_MAX not detected"
+  #define BOARD_ANALOG_IN_MAX 0
 #endif

 #if defined(BLYNK_USE_128_VPINS)
@@ -27,96 +27,157 @@
   #define BOARD_VIRTUAL_MAX 31
 #endif

+/*
+ * Pins Functions
+ */
+
+#ifndef digitalPinHasPWM
+  #warning "No digitalPinHasPWM"
+  #define digitalPinHasPWM(x) false
+#endif
+
+#if !defined(analogInputToDigitalPin)
+  #warning "No analogInputToDigitalPin"
+  #define analogInputToDigitalPin(x) -1
+#endif
+
+/*
+ * Pins Ranges
+ */
+
+#if !defined(BOARD_PWM_MAX)
+  #if   defined(PWMRANGE)
+    #define BOARD_PWM_MAX    PWMRANGE
+  #elif defined(PWM_RESOLUTION)
+    #define BOARD_PWM_MAX    ((2^(PWM_RESOLUTION))-1)
+  #else
+    #warning "Cannot detect BOARD_PWM_MAX"
+    #define BOARD_PWM_MAX    255
+  #endif
+#endif
+
+#if !defined(BOARD_ANALOG_MAX)
+  #if   defined(ADC_RESOLUTION)
+    #define BOARD_ANALOG_MAX    ((2^(ADC_RESOLUTION))-1)
+  #else
+    #warning "Cannot detect BOARD_ANALOG_MAX"
+    #define BOARD_ANALOG_MAX    1023
+  #endif
+#endif
+
+#if defined(clockCyclesPerMicrosecond)
+  #define BOARD_INFO_MHZ clockCyclesPerMicrosecond()
+#elif defined(F_CPU)
+  #define BOARD_INFO_MHZ ((F_CPU)/1000000UL)
+#endif
+
+
+struct Ser {
+  template<typename T, typename... Args>
+  void print(T last) {
+    Serial.print(last);
+  }
+
+  template<typename T, typename... Args>
+  void print(T head, Args... tail) {
+    Serial.print(head);
+    print(tail...);
+  }
+} ser;
+
 const char* JS[] = {
-R"raw(
-{
-    "name": ")raw", R"raw(",
-    "map": {
-        "digital": {
-            "pins": {
-                 )raw", R"raw(
-            },
-            "ops": [ "dr", "dw" ]
-        },
-        "analog": {
-            "pins": {
-                 )raw", R"raw(
-            },
-            "ops": [ "dr", "dw", "ar" ],
-            "arRange": [ 0, )raw", R"raw( ]
-        },
-        "pwm": {
-            "pins": [
-                )raw", R"raw(
-            ],
-            "ops": [ "aw" ],
-            "awRange": [ 0, )raw", R"raw( ]
-        },
-        "virtual":  {
-            "pinsRange": [ 0, )raw", R"raw( ],
-            "ops": [ "vr", "vw" ]
-        }
-    }
-}
-)raw" };
-
+"\n"
+"{\n"
+"    ",
+     "\"map\": {\n"
+"        \"digital\": {\n"
+"            \"pins\": {\n"
+"                 ", "\n"
+"            },\n"
+"            \"ops\": [ \"dr\", \"dw\" ]\n"
+"        },\n"
+"        \"analog\": {\n"
+"            \"pins\": {\n"
+"                 ", "\n"
+"            },\n"
+"            \"ops\": [ \"dr\", \"dw\", \"ar\" ],\n"
+"            \"arRange\": [ 0, ", " ]\n"
+"        },\n"
+"        \"pwm\": {\n"
+"            \"pins\": [\n"
+"                ", "\n"
+"            ],\n"
+"            \"ops\": [ \"aw\" ],\n"
+"            \"awRange\": [ 0, ", " ]\n"
+"        },\n"
+"        \"virtual\":  {\n"
+"            \"pinsRange\": [ 0, ", " ],\n"
+"            \"ops\": [ \"vr\", \"vw\" ]\n"
+"        }\n"
+"    }\n"
+"}\n"
+};
+
+
+
 void setup() {
   Serial.begin(9600);
   delay(10);
 }

 void loop() {
-  Serial.print(JS[0]);
-  Serial.print(BLYNK_INFO_DEVICE);
-  Serial.print(JS[1]);
+  ser.print(JS[0]);
+  ser.print("\"name\": \"", BLYNK_INFO_DEVICE, "\",\n    ");
+#ifdef BLYNK_INFO_CPU
+  ser.print("\"cpu\": \"",  BLYNK_INFO_CPU, "\",\n    ");
+#endif
+#ifdef BOARD_INFO_MHZ
+  ser.print("\"mhz\": ",  BOARD_INFO_MHZ, ",\n    ");
+#endif
+  ser.print(JS[1]);

-  for (int i = 0; i < NUM_DIGITAL_PINS; i++) {
-    Serial.print("\"D");
-    Serial.print(i);
-    Serial.print("\": ");
-    Serial.print(i);
+  for (int i = 0; i < BOARD_DIGITAL_MAX; i++) {
+    ser.print("\"D", i, "\": ", i);
     if (i % 5 != 4) {
-      Serial.print(", ");
+      ser.print(", ");
     } else {
-      Serial.print(",\n                 ");
+      ser.print(",\n                 ");
     }
   }

-  Serial.print(JS[2]);
+  ser.print(JS[2]);

-  for (int i = 0; i < NUM_ANALOG_INPUTS; i++) {
+  for (int i = 0; i < BOARD_ANALOG_IN_MAX; i++) {
     int pin = analogInputToDigitalPin(i);
-    Serial.print("\"A");
-    Serial.print(i);
-    Serial.print("\": ");
-    Serial.print(pin);
-    if (i % 5 != 4) {
-      Serial.print(", ");
-    } else {
-      Serial.print(",\n                 ");
+    if (pin != -1) {
+      ser.print("\"A", i, "\": ", pin);
+      if (i % 5 != 4) {
+        ser.print(", ");
+      } else {
+        ser.print(",\n                 ");
+      }
     }
   }

-  Serial.print(JS[3]);
-  Serial.print(BOARD_ANALOG_MAX);
-  Serial.print(JS[4]);
+  ser.print(JS[3]);
+  ser.print(BOARD_ANALOG_MAX);
+  ser.print(JS[4]);

-  for (int i = 0; i < NUM_DIGITAL_PINS; i++) {
+  for (int i = 0; i < BOARD_DIGITAL_MAX; i++) {
     bool hasPWM = digitalPinHasPWM(i);
-    bool hasInt = digitalPinToInterrupt(i) != NOT_AN_INTERRUPT;
+    //bool hasInt = digitalPinToInterrupt(i) != NOT_AN_INTERRUPT;

     if (hasPWM) {
-      Serial.print("\"D");
-      Serial.print(i);
-      Serial.print("\", ");
+      ser.print("\"D", i, "\", ");
     }
   }

-  Serial.print(JS[5]);
-  Serial.print(BOARD_PWM_MAX);
-  Serial.print(JS[6]);
-  Serial.print(BOARD_VIRTUAL_MAX);
-  Serial.print(JS[7]);
+  ser.print(JS[5]);
+  ser.print(BOARD_PWM_MAX);
+  ser.print(JS[6]);
+  ser.print(BOARD_VIRTUAL_MAX);
+  ser.print(JS[7]);
+
   delay(10000);
 }


Callback function header added

Callback function header added

Callback function header added because the callback function header
needs to be declared before the PubSubClient constructor.

Name of the callback function changed from sensorCallback to
mqttCallback.

--- Arduino-Domoticz-Gateway.ino
+++ Arduino-Domoticz-Gateway.ino
@@ -34,8 +34,11 @@
 char topic[] = "domoticz/in"; // Default incoming topic in Domoticz is domoticz/in
 int temperatureSensordtype = 80; // dtype (device type for temperature sensor) is used to help creating MQTT payload

+// MQTT callback function header
+void mqttCallback(char* topic, byte* payload, unsigned int length);
+
 //MQTT initialisation
-PubSubClient mqttClient(MQTT_SERVER, 1883, sensorCallback, ethernetClient);
+PubSubClient mqttClient(MQTT_SERVER, 1883, mqttCallback, ethernetClient);
 char clientID[50];
 char msg[80];

@@ -300,4 +303,4 @@

 /* Handles message arrived on subscribed topic(s).
    In this sketch we do not subscribe to any topics, so this is a dummy method*/
-void sensorCallback(char* topic, byte* payload, unsigned int length) { }
+void mqttCallback(char* topic, byte* payload, unsigned int length) { }


modified:   full_expriment/full_expriment.ino

--- full_expriment/full_expriment.ino
+++ full_expriment/full_expriment.ino
@@ -3,8 +3,8 @@
 const int C = 10;
 const int D = 11;

-// max speed at 20
-const unsigned width = 20;
+// speed at 20-500
+const unsigned width = 500;

 void setup() {
   pinMode(A, OUTPUT);
@@ -17,26 +17,26 @@

   digitalWrite(A, HIGH);
   digitalWrite(B, LOW);
-  digitalWrite(C, LOW);
+  digitalWrite(C, HIGH);
   digitalWrite(D, LOW);
   delay(width);

-  digitalWrite(A, LOW);
+  digitalWrite(A, HIGH);
   digitalWrite(B, LOW);
-  digitalWrite(C, HIGH);
-  digitalWrite(D, LOW);
+  digitalWrite(C, LOW);
+  digitalWrite(D, HIGH);
   delay(width);

   digitalWrite(A, LOW);
   digitalWrite(B, HIGH);
   digitalWrite(C, LOW);
-  digitalWrite(D, LOW);
+  digitalWrite(D, HIGH);
   delay(width);

   digitalWrite(A, LOW);
-  digitalWrite(B, LOW);
-  digitalWrite(C, LOW);
-  digitalWrite(D, HIGH);
+  digitalWrite(B, HIGH);
+  digitalWrite(C, HIGH);
+  digitalWrite(D, LOW);
   delay(width);
 }


cmd mode

cmd mode

--- arduino_motor/mains/mains.ino
+++ arduino_motor/mains/mains.ino
@@ -68,21 +68,20 @@

   //delay(1000);

-  turnRight(90);
+  //turnRight(90);
   //moveForward(80);
   //turnLeft(90);
   //motorShield.setSpeeds(-400, -400);
   //serialCommnder->send_command_complete(1, 200);
   //Serial.println(errorCumulator->get_compass_read());
-  //serialCommnder->receive_exec_command();
+  serialCommnder->receive_exec_command();

   //servo_ir->servoScan(60, 120);
   //servo_ir->print_dist_array();
   //delay(5000); //to slow down the serial print

-  //serialCommnder->send_sensor_readings(100, 30, 30);
-  getSensorReadings();
+  //getSensorReadings();

   delay(1000);


remove serial

remove serial

--- arduino_pico/arduino_pico.ino
+++ arduino_pico/arduino_pico.ino
@@ -1,7 +1,7 @@
 #include "OneWire.h"
 #include "DallasTemperature.h"
 #include "TimerOne.h"
-#include "SPI.h" // new include
+#include "SPI.h"
 #include "Ethernet.h"
 #include "WebServer.h"
 #include "typedefs.h"
@@ -215,8 +215,6 @@

 void setup(void)
 {
-  // start serial port
-  Serial.begin(57600);

   // 1-wire devices temperature

@@ -372,26 +370,6 @@
     // Add the millilitres passed in this second to the cumulative total
     sensor_t->totalMilliLitres += sensor_t->flowMilliLitres;
     sensor_t->orderMilliLitres += sensor_t->flowMilliLitres;
-
-    unsigned int frac;
-
-    // Print the flow rate for this second in litres / minute
-    Serial.print("Flow rate: ");
-    Serial.print(int(sensor_t->flowRate));  // Print the integer part of the variable
-    Serial.print(".");             // Print the decimal point
-    // Determine the fractional part. The 10 multiplier gives us 1 decimal place.
-    frac = (sensor_t->flowRate - int(sensor_t->flowRate)) * 10;
-    Serial.print(frac, DEC) ;      // Print the fractional part of the variable
-    Serial.print("L/min");
-    // Print the number of litres flowed in this second
-    Serial.print("  Current Liquid Flowing: ");             // Output separator
-    Serial.print(sensor_t->flowMilliLitres);
-    Serial.print("mL/Sec");
-
-    // Print the cumulative total of litres flowed since starting
-    Serial.print("  Output Liquid Quantity: ");             // Output separator
-    Serial.print(sensor_t->totalMilliLitres);
-    Serial.println("mL");

     // Reset the pulse counter so we can start incrementing again
     sensor_t->pulseCount = 0;


Test remote control code

Test remote control code

--- src/wolves.ino
+++ src/wolves.ino
@@ -21,6 +21,7 @@
 #include "RGBLED.h"
 #include "RFIDSensor.h"
 #include "Solenoid.h"
+#include "RemoteControl.h"

 #define VERSION "0.0.1"

@@ -46,6 +47,8 @@
     Solenoid(45, sensors[2], leds[2]),
 };

+RemoteControl remoteCtrl(11);
+
 void checkSolenoids() {
     for (int i = 0; i < N_OF_QUESTIONS; i++)
         solenoids[i].selfCheck0();
@@ -60,7 +63,11 @@
 void checkRFIDSensors() {
     int countOk = 0;
     for (int i = 0; i < N_OF_QUESTIONS; i++) {
-        if (sensors[i].selfCheck()) countOk++;
+        bool ok = sensors[i].selfCheck();
+        if (ok) countOk++;
+        #ifdef APP_DEBUG
+        Serial << "Checking Sensor " << i << ": " << (ok ? "OK" : "FAILED") << endl;
+        #endif
     }
     if (countOk != N_OF_QUESTIONS) {
         while(1) {
@@ -78,26 +85,35 @@
     Serial << "Copyright (c) 2016 BlueMasters Fribourg" << endl;
     SPI.begin();
     app.statusLed.begin(2,3,4);
+    remoteCtrl.begin();
     for (int i = 0; i < N_OF_QUESTIONS; i++) {
         leds[i].begin();
         solenoids[i].begin();
         sensors[i].begin();
     }
-    app.statusLed.selfCheck();
-    checkSolenoids();
+    // app.statusLed.selfCheck();
+    // checkSolenoids();
     checkRFIDSensors();
+    for (int i = 0; i < 4; i++) {
+        app.pinCode[i] = i+1;
+    }
+
 }

 void loop() {
     static long heartbeat = 0;
+    remoteCtrl.tick();
+    for (int i = 0; i < N_OF_QUESTIONS; i++) {
+        sensors[i].tick();
+    }
     for (int i = 0; i < N_OF_QUESTIONS; i++) {
         solenoids[i].tick();
     }
-    heartbeat++;
-    if (heartbeat > HEARTBEAT_COUNTER) {
-        app.statusLed.off();
-        heartbeat = 0;
-    } else if (heartbeat > HEARTBEAT_COUNTER - HEARTBEAT_WIDTH){
-        app.statusLed.setColor(COLOR_BLUE);
-    }
+    // heartbeat++;
+    // if (heartbeat > HEARTBEAT_COUNTER) {
+    //     app.statusLed.off();
+    //     heartbeat = 0;
+    // } else if (heartbeat > HEARTBEAT_COUNTER - HEARTBEAT_WIDTH){
+    //     app.statusLed.setColor(COLOR_BLUE);
+    // }
 }


fixed conflicts in main

fixed conflicts in main

--- arduino_motor/mains/movements.ino
+++ arduino_motor/mains/movements.ino
@@ -175,8 +175,8 @@

   double realNoOfTicksForAngle = reachTickTarget(isLeftForward, isRightForward, noOfTicksForAngle);

-  errorCumulator->record_turning_error(isRightForward*adjusted_angle, (realNoOfTicksForAngle - noOfTicksForAngle)/Config::TICKS_PER_DEGREE);
-
+  //errorCumulator->record_turning_error(isRightForward*adjusted_angle, (realNoOfTicksForAngle - noOfTicksForAngle)/Config::TICKS_PER_DEGREE);
+  errorCumulator->record_turning_error_compass(isRightForward*adjusted_angle);
 }

 ///////////////////////////////////////////////////////////////////////////////////////////////////


removed serial.println for val poti

removed serial.println for val poti

--- arduino_script/arduino_script.ino
+++ arduino_script/arduino_script.ino
@@ -35,7 +35,6 @@
 // Actual Request Pattern. Check if there was an Input and send the right Value via Serial Connection if there was one
 void checkRequestAndReturn() {
   // Check if serial Connection is available and send answer, if there was a Serial.Read()
-  Serial.println(formatReturn(valPoti));
   if (Serial.available()) {
     requestDigit = Serial.read();
     if(requestDigit == '1') {


set coorect led pin and pulse clock delay

--- examples/AO_Resonate16/AO_Resonate16.ino
+++ examples/AO_Resonate16/AO_Resonate16.ino
@@ -27,7 +27,7 @@
 #define SENSOR_PIN A0
 #define MOTOR_DIR_PIN 3
 #define MOTOR_STEP_PIN 4
-#define LED_PIN 13 // original value: 5
+#define LED_PIN 5
 #define INIT_DELAY 1000

 SensorOrchestra* mOrchestra;
@@ -57,7 +57,7 @@
   // setup playlist
   mOrchestra->setPlaylist(new SensorPlaylist());
   // setup clock
-  mOrchestra->setClock(new PulseClock(1000));
+  mOrchestra->setClock(new PulseClock(100));

   // Initialize synth engine
   Music.init();


Fixed hand rotation in the game

Fixed hand rotation in the game

--- examples/K1200_example/K1200_example.ino
+++ examples/K1200_example/K1200_example.ino
@@ -164,7 +164,7 @@
     if (endgame == true) {
       break;
     }
-    state = showGameAnim(randnumber,true);
+    state = showGameAnim(randnumber,false);
     switch(state)
     {
       case none:


add pin macros to rdm device example

add pin macros to rdm device example

--- examples/RDMDeviceTest/RDMDeviceTest.ino
+++ examples/RDMDeviceTest/RDMDeviceTest.ino
@@ -27,14 +27,17 @@
 #define MFG_LABEL             "LXDMX"
 #define MODEL_DESCRIPTION     "RDMDeviceTest"

+#define DIRECTION_PIN 15
+#define LED_PIN       14
+
 void setup() {
   WiFi.forceSleepBegin();
   delay(1);
   Serial.setDebugOutput(1); //use uart0 for debugging

   pinMode(BUILTIN_LED, OUTPUT);
-  pinMode(4, OUTPUT);
-  pinMode(14, OUTPUT);
+  pinMode(DIRECTION_PIN, OUTPUT);
+  pinMode(LED_PIN, OUTPUT);
   //diagnostic pins
   pinMode(12, OUTPUT);
   pinMode(16, INPUT_PULLUP);
@@ -45,7 +48,7 @@
   ESP8266DMX.setRDMReceivedCallback(&gotRDMCallback);
   LX8266DMX::THIS_DEVICE_ID.setBytes(0x6C, 0x78, 0x0F, 0x0A, 0x0C, 0x0E);    //change device ID from default

-  ESP8266DMX.startRDM(4, DMX_TASK_RECEIVE);
+  ESP8266DMX.startRDM(DIRECTION_PIN, DMX_TASK_RECEIVE);
 }

@@ -71,7 +74,7 @@
   if ( got_dmx ) {

     //ESP8266 PWM is 10bit 0-1024
-    analogWrite(14,2*ESP8266DMX.getSlot(start_address));
+    analogWrite(LED_PIN,2*ESP8266DMX.getSlot(start_address));
     got_dmx = 0;  //reset

   } else if ( got_rdm ) {


Prep Arduino to receive serial parameters

--- code/lissajous/lissajous.ino
+++ code/lissajous/lissajous.ino
@@ -3,7 +3,7 @@

 #include <Servo.h>
-
+
 // Create the servo objects
 Servo servox;
 Servo servoy;
@@ -12,13 +12,12 @@
 float spd = 0.005; // This value seems to work for reasonable speed.
 float facter = 1.0; // Ratio between servox and servoy periods.
 float starter = 0; // Starting position offset between the servos.
-float facter2 = 1.0; // Ratio between servox and servoy periods.
-float starter2 = 0; // Starting position offset between the servos.
+//float facter2 = 1.0; // Ratio between servox and servoy periods.
+//float starter2 = 0; // Starting position offset between the servos.
 int adjx = 90; // Position of servox
 int adjy = 90; // Position of servoy
 float decay = 60000; // Gives the amount of steps to run on. Higher gives a slower decay.
 int scale = 70; // Scaling the image to maximum size. Gets adjusted after first run.
-int max_dev = 0; // Keeping track of maximum deviation of the servos.
 int counter = 0; // How many times through the main loop.

 void setup()
@@ -27,6 +26,7 @@
   servoy.attach(7);  // attaches the servo on pin 10 to the servo object
   pinMode(3, INPUT_PULLUP); // Starting button input
   randomSeed(analogRead(0)); // Just seed with a random value
+  Serial.begin(9600);
 }

 void loop()
@@ -36,46 +36,29 @@
     {
         // Keep generating random values. Only on button press do we lock in the values.
         // The random seed is not random enough, so this provides a more random result.
-        facter = random(1001, 1021)/1000.0; // Increase the second number for variation.
-        starter = random(3141)/1000.0; // offset the starting point by 0-3.141 radians
-        facter2 = random(990, 1010)/1000.0;
-        starter2 = random(3141)/1000.0;
-        decay = 100000 + random(100000);
+        //facter = 1.015; // Increase the second number for variation.
+        //starter = 3.141; // offset the starting point by 0-3.141 radians
+        if (Serial.available() > 0 ) {
+          facter = Serial.parseFloat();
+          starter = Serial.parseFloat();
+        };
     }
     // Main loop, to 90% decay in amplitude of the movements.
+    decay = 60000;

     counter = 0;
-    max_dev = 0;
     scale = 70;
-    while (counter < 2)
-    {
-        for(pos = int(decay*0.1); pos < decay; pos += 1)
-        {
-            // Adjx just gives me a nice sine wave
-            adjx = int(90 + int(scale * pos/decay * sin(pos * spd)));
+    for(pos = int(decay*0.1); pos < decay; pos += 1)
+    {
+        // Adjx just gives me a nice sine wave
+        adjx = int(90 + int(scale * pos/decay * sin(pos * spd)));

-            // Also a sinewave, with offsets and different period.
-            adjy = int(90 + int(scale * (pos/decay) * sin(starter + (pos * spd * facter))));
+        // Also a sinewave, with offsets and different period.
+        adjy = int(90 + int(scale * (pos/decay) * sin(starter + (pos * spd * facter))));

-            // Add a circular motion.
-            adjx += int(scale * (pos/decay) * sin(starter2 + (pos * spd * facter2)));
-            adjy += int(scale * (pos/decay) * cos(starter2 + (pos * spd * facter2)));
-
-            if (counter == 0)
-            {
-                max_dev = max(max_dev, abs(adjx - 90));
-                max_dev = max(max_dev, abs(adjy - 90));
-            }
-            if (counter == 1)
-            {
-                // Get the values to the servos.
-                servox.write(adjx);
-                servoy.write(adjy);
-                delay(1); // Just for consistent speed.
-            }
-        }
-    counter += 1;
-    scale = int(scale*scale/max_dev);
+        servox.write(adjx);
+        servoy.write(adjy);
+        delay(1); // Just for consistent speed.
     }

     // Return to center after drawing.


Update DCS Alpha 2

Update DCS Alpha 2

--- BiotechHardware/dcs/dcs_alpha2/dcs_alpha2.ino
+++ BiotechHardware/dcs/dcs_alpha2/dcs_alpha2.ino
@@ -59,7 +59,7 @@
   lcd.setCursor(3, 0);
   lcd.print("Keamanan Pintu");
   lcd.setCursor(0,1);
-  lcd.print("Inisialisasi...");
+  lcd.print("Inisialisasi");

   device_status = check_device();
   device_condition = check_condition();
@@ -69,7 +69,7 @@
   digitalWrite(sensor, HIGH);
   pinMode(push_btn, INPUT);
   digitalWrite(push_btn, HIGH);
-  myservo.write(60);
+  myservo.write(70);
 }

 void loop(){
@@ -119,7 +119,7 @@

 boolean check_device(){
   Serial.print("Cek Status");
-  if(read_server("/api/dcs_get_value/status") == "1"){
+  if(read_server("/api/dcs/dcs_get_value/status") == "1"){
     if(!display_armed){
       lcd_init();
       display_armed = true;
@@ -141,7 +141,7 @@

 boolean check_condition(){
   Serial.print("Cek Kondisi");
-  if(read_server("/api/dcs_get_value/condition") == "0"){
+  if(read_server("/api/dcs/dcs_get_value/condition") == "0"){
     if(!display_unlocked){
       lcd_init();
       display_unlocked = true;
@@ -205,7 +205,7 @@

   if (client.connect(server,80))
   {
-    client.print("POST /api/dcs_check_password HTTP/1.1\n");
+    client.print("POST /api/dcs/dcs_check_password HTTP/1.1\n");
     client.print("Host: 192.168.2.4\n");
     client.print("Connection: close\n");
     client.print("Content-Type: application/x-www-form-urlencoded\n");
@@ -215,12 +215,12 @@
     client.print(data);
   }
   delay(50);
-  check_result(read_server("/api/dcs_get_value/result"));
+  check_result(read_server("/api/dcs/dcs_get_value/result"));
 }

 void check_result(String result){
   if(attempt == 1){
-    max_attempt = read_server("/api/dcs_get_value/password_attempts").toInt();
+    max_attempt = read_server("/api/dcs/dcs_get_value/password_attempts").toInt();
     lcd_attempts(attempt, max_attempt);
   }
   if(result == "1"){
@@ -242,14 +242,14 @@
 void open_door(){
   attempt = 0;
   lcd_print("Pintu Terbuka");
-  myservo.write(0);
+  myservo.write(30);
   delay(3000);
   int val = digitalRead(sensor);
   while(digitalRead(sensor) == HIGH){
     val = digitalRead(sensor);
   }
   delay(1000);
-  myservo.write(60);
+  myservo.write(70);
 }

 String read_server(String url){
@@ -299,7 +299,7 @@

   if (client.connect(server,80))
   {
-    client.print("POST /api/dcs_lock HTTP/1.1\n");
+    client.print("POST /api/dcs/dcs_lock HTTP/1.1\n");
     client.print("Host: 192.168.2.4\n");
     client.print("Connection: close\n");
     client.print("Content-Type: application/x-www-form-urlencoded\n");


updated example

updated example

--- examples/webcontroller/webcontroller.ino
+++ examples/webcontroller/webcontroller.ino
@@ -1,22 +1,28 @@
-#include<Angduino.h>
+/*
+    This is an simple example showing how to use the Angduino Library.
+*/

-Angduino angduino;
+#include<Angduino.h>  //including the library
+
+Angduino angduino;    //creating the object
 void setup()
 {

-  Serial.begin(9600);
-  Serial.println("Hello Terminal");
+  Serial.begin(9600);                  //You set this up your sell
+  //Important: DO NOT USE the Serial function from this point onwards.
+  //Angduino take the control if Serial channels for communication.
+
   //NOTE: Always call setKey in the setup. Should be called only once.
-  angduino.setKey("led1");
-    delay(1000);
+  angduino.setKey("led2");            //Setting the key.Default allowed keys: 50
+  delay(1000);                        //Its recommended that you set this delay for proper start up
+
   pinMode(13, OUTPUT);           // set pin to input
 }

 void loop ()
 {
-  angduino.update();
-  delay(100);
-  if(angduino.getValue("led1")==1)
+  angduino.update();   //necessary, otherwise changes wont be Updated.
+  if(angduino.getValue("led2")==1)    //get the value from the key.
     digitalWrite(13,HIGH);
   else
     digitalWrite(13,LOW);


indent

indent

--- scripts-arduino/bp_led_lp.ino
+++ scripts-arduino/bp_led_lp.ino
@@ -23,10 +23,10 @@

 void setup() {
   Serial.begin(9600);
-  pinMode(ledPin, OUTPUT);        // initialize the LED pin as an output:
-  pinMode(buttonPin, INPUT);      // initialize the pushbutton pin as an input:
-  button_was_pressed = false;     // initialize the pushbutton to false (not pressed)
-  button_pressed_counter = 0;     // initialize the pusbutton counter
+  pinMode(ledPin, OUTPUT);          // initialize the LED pin as an output:
+  pinMode(buttonPin, INPUT);        // initialize the pushbutton pin as an input:
+  button_was_pressed = false;       // initialize the pushbutton to false (not pressed)
+  button_pressed_counter = 0;       // initialize the pusbutton counter
 }

 // ######## LOOP ########
@@ -34,14 +34,11 @@
     boolean eventResult = eventButton();

     switch(eventResult){
-        case EV_NONE:
-            //TODO
-            // Ne rien faire de particulier, ou attendre la fin d'une synchronisation
+        case EV_NONE:               // if nothing append
+            //TODO : Ne rien faire de particulier, ou attendre la fin d'une synchronisation
             break;
-        case EV_SHORTPRESS:
-            //TODO
-            // Allumer ou éteindre la LED
-
+        case EV_SHORTPRESS:         // if short press
+            //TODO : Allumer ou éteindre la LED (a check)
             if(ledState == HIGH){
                 if (buttonState == LOW) {
                     turnOff();
@@ -53,9 +50,8 @@
                 }
             }
             break;
-        case EV_LONGPRESS:
-            //TODO
-            // Faire clignoter la LED et attendre la fin d'une synchronisation.
+        case EV_LONGPRESS:          // if long press
+            //TODO : Faire clignoter la LED et attendre la fin d'une synchronisation.
             break;
     }
 }


delete UDP

delete UDP

--- UDPSendReceiveString/UDPSendReceiveString.ino
+++ UDPSendReceiveString/UDPSendReceiveString.ino
@@ -1,53 +0,0 @@
-#include <SPI.h>
-#include <Ethernet.h>
-#include <EthernetUdp.h>
-
-
-byte mac[] = {
-  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
-};
-
-IPAddress ip(192, 168, 1, 177);
-
-unsigned int localPort = 8789;
-
-char packetBuffer[UDP_TX_PACKET_MAX_SIZE];
-
-EthernetUDP udp;
-
-void setup()
-{
-    Ethernet.begin(mac, ip);
-    udp.begin(localPort);
-
-    Serial.begin(9600);
-}
-
-void loop()
-{
-    int packetSize = udp.parsePacket();
-    if (packetSize)
-    {
-        Serial.print("Received packet of size ");
-        Serial.println(packetSize);
-        Serial.print("From ");
-        IPAddress remote = udp.remoteIP();
-        for (int i = 0; i < 4; i++)
-        {
-            Serial.print(remote[i], DEC);
-            if (i < 3)
-            {
-                Serial.print(".");
-            }
-        }
-        Serial.print(", port ");
-        Serial.println(udp.remotePort());
-
-        udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
-        Serial.println("Contents:");
-        Serial.println(packetBuffer);
-    }
-
-    delay(1000);
-}
-


added memory buffers

added memory buffers

--- aquaponicMCP/aquaponicMCP.ino
+++ aquaponicMCP/aquaponicMCP.ino
@@ -11,10 +11,22 @@
 float watherTurb = 0.0;
 float waterPH = 0.0;

+uint16_t lightRBuffer[64];
+uint16_t lightLBuffer[64];
+uint16_t tempBuffer[64];
+uint16_t turbBuffer[64];
+uint16_t pHRBuffer[64];
+
+uint8_t bufferCounter = 1;
+

 void setup() {
-  //setup digital connections
-  //setup serial
+  Serial.begin(9600);
+  lightRBuffer[0] = 1791;
+  lightLBuffer[0] = 1792;
+  tempBuffer[0] = 1793;
+  turbBuffer[0] = 1794;
+  pHRBuffer[0] = 1795;
 }

 void loop() {
@@ -22,7 +34,6 @@
   SendData();
   GetInput();
   SendCommands();
-
 }

 /*these will be raw readings, converting from voltage to
@@ -35,10 +46,19 @@
   waterTemp = analogRead(waterTempSensor);
   waterTurb = analogRead(waterTurbSensor);
   waterPH = analogRead(waterPHSensor);
+  lightRBuffer[bufferCounter] = lightR;
+  lightLBuffer[bufferCounter] = lightL;
+  tempBuffer[bufferCounter] = waterTemp;
+  turbBuffer[bufferCounter] = waterTurb;
+  pHBuffer[bufferCounter] = waterPH;
+  bufferCounter += 1;
 }

 void SendData(){
 //  send buffered frame every x seconds
+  if(bufferCounter >= 64){
+
+  }
 }

 void GetInput(){


Minor formatting cleanup

Minor formatting cleanup

--- arduino/autofowl/autofowl.ino
+++ arduino/autofowl/autofowl.ino
@@ -77,25 +77,25 @@

 // Pins
 // Arduino Uno / Buttons
-const int PIN_MODE_BUTTON = 6;
-const int PIN_UP_BUTTON   = 8;
-const int PIN_DOWN_BUTTON = 7;
+const int PIN_MODE_BUTTON                   = 6;
+const int PIN_UP_BUTTON                     = 8;
+const int PIN_DOWN_BUTTON                   = 7;
 // Arduino Uno / LCD screen
-const int PIN_LCD_RS      = A1;
-const int PIN_LCD_ENABLE  = A2;
-const int PIN_LCD_D4      = 5;
-const int PIN_LCD_D5      = 4;
-const int PIN_LCD_D6      = 3;
-const int PIN_LCD_D7      = 2;
-const int PIN_LCD_BL      = 9;
+const int PIN_LCD_RS                        = A1;
+const int PIN_LCD_ENABLE                    = A2;
+const int PIN_LCD_D4                        = 5;
+const int PIN_LCD_D5                        = 4;
+const int PIN_LCD_D6                        = 3;
+const int PIN_LCD_D7                        = 2;
+const int PIN_LCD_BL                        = 9;
 // Arduino Uno / Photocell
-const int PIN_PHOTOCELL     = A0;
+const int PIN_PHOTOCELL                     = A0;
 // Arduino Uno / Motor controller
-const int PIN_MOTOR_1       = 13; // pin 2 on L293D
-const int PIN_MOTOR_2       = 12; // pin 7 on L293D
-const int PIN_MOTOR_3       = 11; // pin 15 on L293D
-const int PIN_MOTOR_4       = 10; // pin 10 on L293D
-const int PIN_MOTOR_ENABLE  = A3;
+const int PIN_MOTOR_1                       = 13; // pin 2 on L293D
+const int PIN_MOTOR_2                       = 12; // pin 7 on L293D
+const int PIN_MOTOR_3                       = 11; // pin 15 on L293D
+const int PIN_MOTOR_4                       = 10; // pin 10 on L293D
+const int PIN_MOTOR_ENABLE                  = A3; // pin 1 and 9 on L293D

 // --------------------------------------
 // -- Runtime variables


new feature: now the rover is using a servo to be able to look 180 degree left or right

--- arduino/pi_rover/pi_rover.ino
+++ arduino/pi_rover/pi_rover.ino
@@ -1,5 +1,6 @@
 #include <AFMotor.h>
 #include <NewPing.h>
+#include <Servo.h>

 #define runEvery(t) for (static typeof(t) _lasttime;\
                          (typeof(t))((typeof(t))millis() - _lasttime) > (t);\
@@ -23,12 +24,30 @@
 bool safetyDriveMode = true;
 bool debugMode = false;

+int ledPin = 10;
+
 String input = "";
+
+// DC hobby servo
+Servo servo;

 void setup()
 {
   Serial.begin(9600);
   Serial.print("Ready\n");
+  pinMode(ledPin, OUTPUT);
+
+  servo.attach(9);
+
+  servo.write(0);
+  delay(500);
+  servo.write(180);
+  delay(500);
+  servo.write(90);
+
+  delay(350);
+
+  servo.detach();
 }

 void loop()
@@ -131,6 +150,8 @@
     result = checkBatteryStatus(argument);
   } else if(command == "distance") {
     result = measureDistance(argument);
+  } else if(command == "look") {
+    result = lookDirection(argument);
   } else if(command == "forward") {
     result = forward(argument);
   } else if(command == "backward") {
@@ -150,6 +171,45 @@
   return result;
 }

+String lookDirection(int argument) {
+  String result;
+
+  Serial.print("arg: " +String(argument)+ "\n");
+
+  if (argument >= 0 && argument <= 180) {
+
+    digitalWrite(ledPin, HIGH);
+
+    if (servo.attached() == false) {
+      servo.attach(9);
+    }
+
+    int waitTimeInMs;
+
+    if (servo.read() > argument) {
+      waitTimeInMs = servo.read() - argument;
+    } else {
+      waitTimeInMs = servo.read() + argument;
+    }
+
+    servo.write(argument);
+
+    Serial.print(waitTimeInMs);
+
+    delay(waitTimeInMs * 3);
+
+    servo.detach();
+
+    digitalWrite(ledPin, LOW);
+
+    result = "ok";
+  } else {
+    result = "failed";
+  }
+
+  return result;
+}
+
 String forward(int speedInPercentage)
 {
   if (speedInPercentage > 0)