Delete nrf24_client_6050_DMP.ino

Delete nrf24_client_6050_DMP.ino

--- nrf24_client_6050_DMP.ino
+++ nrf24_client_6050_DMP.ino
@@ -1,451 +0,0 @@
-#include <RadioHead.h>
-#include <radio_config_Si4460.h>
-#include <RHCRC.h>
-#include <RHDatagram.h>
-#include <RHGenericDriver.h>
-#include <RHGenericSPI.h>
-#include <RHHardwareSPI.h>
-#include <RHMesh.h>
-#include <RHNRFSPIDriver.h>
-#include <RHReliableDatagram.h>
-#include <RHRouter.h>
-#include <RHSoftwareSPI.h>
-#include <RHSPIDriver.h>
-#include <RHTcpProtocol.h>
-#include <RH_ASK.h>
-#include <RH_NRF24.h>
-#include <RH_NRF905.h>
-#include <RH_RF22.h>
-#include <RH_RF24.h>
-#include <RH_RF69.h>
-#include <RH_RF95.h>
-#include <RH_Serial.h>
-#include <RH_TCP.h>
-
-// nrf24_client.pde
-// -*- mode: C++ -*-
-// Example sketch showing how to create a simple messageing client
-// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
-// reliability, so you should only use RH_NRF24 if you do not need the higher
-// level messaging abilities.
-// It is designed to work with the other example nrf24_server.
-// Tested on Uno with Sparkfun NRF25L01 module
-// Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
-// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module
-
-// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
-// for both classes must be in the include path of your project
-#include "I2Cdev.h"
-#include "MPU6050_6Axis_MotionApps20.h"
-#include <SPI.h>
-#include <RH_NRF24.h>
-#include<Wire.h>
-#define Z_THRESHOLD_H 0
-#define Z_THRESHOLD_L 0
-#define THRESHOLD 500
-uint8_t doorClose[] = "close";
-uint8_t doorOpen[] = "open";
-uint8_t doorShake[] = "shake";
-
-// class default I2C address is 0x68
-// specific I2C addresses may be passed as a parameter here
-// AD0 low = 0x68 (default for SparkFun breakout and InvenSense evaluation board)
-// AD0 high = 0x69
-MPU6050 mpu;
-//MPU6050 mpu(0x69); // <-- use for AD0 high
-
-/* =========================================================================
-   NOTE: In addition to connection 3.3v, GND, SDA, and SCL, this sketch
-   depends on the MPU-6050's INT pin being connected to the Arduino's
-   external interrupt #0 pin. On the Arduino Uno and Mega 2560, this is
-   digital I/O pin 2.
- * ========================================================================= */
-
-/* =========================================================================
-   NOTE: Arduino v1.0.1 with the Leonardo board generates a compile error
-   when using Serial.write(buf, len). The Teapot output uses this method.
-   The solution requires a modification to the Arduino USBAPI.h file, which
-   is fortunately simple, but annoying. This will be fixed in the next IDE
-   release. For more info, see these links:
-
-   http://arduino.cc/forum/index.php/topic,109987.0.html
-   http://code.google.com/p/arduino/issues/detail?id=958
- * ========================================================================= */
-
-
-
-// uncomment "OUTPUT_READABLE_QUATERNION" if you want to see the actual
-// quaternion components in a [w, x, y, z] format (not best for parsing
-// on a remote host such as Processing or something though)
-//#define OUTPUT_READABLE_QUATERNION
-
-// uncomment "OUTPUT_READABLE_EULER" if you want to see Euler angles
-// (in degrees) calculated from the quaternions coming from the FIFO.
-// Note that Euler angles suffer from gimbal lock (for more info, see
-// http://en.wikipedia.org/wiki/Gimbal_lock)
-//#define OUTPUT_READABLE_EULER
-
-// uncomment "OUTPUT_READABLE_YAWPITCHROLL" if you want to see the yaw/
-// pitch/roll angles (in degrees) calculated from the quaternions coming
-// from the FIFO. Note this also requires gravity vector calculations.
-// Also note that yaw/pitch/roll angles suffer from gimbal lock (for
-// more info, see: http://en.wikipedia.org/wiki/Gimbal_lock)
-//#define OUTPUT_READABLE_YAWPITCHROLL
-
-// uncomment "OUTPUT_READABLE_REALACCEL" if you want to see acceleration
-// components with gravity removed. This acceleration reference frame is
-// not compensated for orientation, so +X is always +X according to the
-// sensor, just without the effects of gravity. If you want acceleration
-// compensated for orientation, us OUTPUT_READABLE_WORLDACCEL instead.
-//#define OUTPUT_READABLE_REALACCEL
-
-// uncomment "OUTPUT_READABLE_WORLDACCEL" if you want to see acceleration
-// components with gravity removed and adjusted for the world frame of
-// reference (yaw is relative to initial orientation, since no magnetometer
-// is present in this case). Could be quite handy in some cases.
-#define OUTPUT_READABLE_WORLDACCEL
-
-// uncomment "OUTPUT_TEAPOT" if you want output that matches the
-// format used for the InvenSense teapot demo
-//#define OUTPUT_TEAPOT
-
-
-
-#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)
-#define LED_PIN_Alarm 3 // (LED on TTC PCB and its Arduinopro mini is 3,
-
-bool blinkState = false;
-
-// MPU control/status vars
-bool dmpReady = false;  // set true if DMP init was successful
-uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU
-uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)
-uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)
-uint16_t fifoCount;     // count of all bytes currently in FIFO
-uint8_t fifoBuffer[64]; // FIFO storage buffer
-
-// orientation/motion vars
-Quaternion q;           // [w, x, y, z]         quaternion container
-VectorInt16 aa;         // [x, y, z]            accel sensor measurements
-VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements
-VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements
-VectorFloat gravity;    // [x, y, z]            gravity vector
-float euler[3];         // [psi, theta, phi]    Euler angle container
-float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector
-
-// packet structure for InvenSense teapot demo
-uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' };
-
-// ================================================================
-// ===                      My VAR                  ===
-// ================================================================
-
-float accel;
-float diff_acc;
-float ref=0;
-
-// ================================================================
-// ===               INTERRUPT DETECTION ROUTINE                ===
-// ================================================================
-
-volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high
-void dmpDataReady() {
-    mpuInterrupt = true;
-}
-
-
-//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
-//const int MPU=0x68;  // I2C address of the MPU-6050
-uint16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
-
-// Singleton instance of the radio driver
-//RH_NRF24 nrf24;
- RH_NRF24 nrf24(5, 10); // use this to be electrically compatible the TTC RFID pcb
-// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
-// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
-// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini
-
-
-// ================================================================
-// ===                      INITIAL SETUP                       ===
-// ================================================================
-void setup()
-{
-// .................................................................
-// ===                      INITIAL SETUP OF MPU6050_DMP        ===
-//..................................................................
- // join I2C bus (I2Cdev library doesn't do this automatically)
-    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
-        Wire.begin();
-        TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz)
-    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
-        Fastwire::setup(400, true);
-    #endif
-
-    // initialize serial communication
-    // (115200 chosen because it is required for Teapot Demo output, but it's
-    // really up to you depending on your project)
-    Serial.begin(9600);
-    //while (!Serial); // wait for Leonardo enumeration, others continue immediately
-
-    // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Ardunio
-    // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to
-    // the baud timing being too misaligned with processor ticks. You must use
-    // 38400 or slower in these cases, or use some kind of external separate
-    // crystal solution for the UART timer.
-
-    // initialize device
-    Serial.println(F("Initializing I2C devices..."));
-    mpu.initialize();
-
-    // verify connection
-    Serial.println(F("Testing device connections..."));
-    Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));
-
-    // wait for ready
-    //Serial.println(F("\nSend any character to begin DMP programming and demo: "));
-   // while (Serial.available() && Serial.read()); // empty buffer
-   // while (!Serial.available());                 // wait for data
-   // while (Serial.available() && Serial.read()); // empty buffer again
-
-    // load and configure the DMP
-    Serial.println(F("Initializing DMP..."));
-    devStatus = mpu.dmpInitialize();
-
-    // supply your own gyro offsets here, scaled for min sensitivity
-    mpu.setXGyroOffset(220);
-    mpu.setYGyroOffset(76);
-    mpu.setZGyroOffset(-85);
-    mpu.setZAccelOffset(1788); // 1688 factory default for my test chip
-
-    // make sure it worked (returns 0 if so)
-    if (devStatus == 0) {
-        // turn on the DMP, now that it's ready
-        Serial.println(F("Enabling DMP..."));
-        mpu.setDMPEnabled(true);
-
-        // enable Arduino interrupt detection
-        Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
-        attachInterrupt(0, dmpDataReady, RISING);
-        mpuIntStatus = mpu.getIntStatus();
-
-        // set our DMP Ready flag so the main loop() function knows it's okay to use it
-        Serial.println(F("DMP ready! Waiting for first interrupt..."));
-        dmpReady = true;
-
-        // get expected DMP packet size for later comparison
-        packetSize = mpu.dmpGetFIFOPacketSize();
-    }
-    else {
-        // ERROR!
-        // 1 = initial memory load failed
-        // 2 = DMP configuration updates failed
-        // (if it's going to break, usually the code will be 1)
-        Serial.print(F("DMP Initialization failed (code "));
-        Serial.print(devStatus);
-        Serial.println(F(")"));
-    }
-
-    // configure LED for output
-    pinMode(LED_PIN, OUTPUT);
-     pinMode(LED_PIN_Alarm, OUTPUT);
-
-
-//=================== End of initial setup of MPU_DMP =========
-//=================== INIT of radio ====================
-  if (!nrf24.init())
-    Serial.println("init failed");
-  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
-  if (!nrf24.setChannel(1))
-    Serial.println("setChannel failed");
-  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
-    Serial.println("setRF failed");
-}
-
-// ================================================================
-// ===                    MAIN PROGRAM LOOP                     ===
-// ================================================================
-void loop()
-{
-
-    // if programming failed, don't try to do anything
-    if (!dmpReady) return;
-
-    // wait for MPU interrupt or extra packet(s) available
-    while (!mpuInterrupt && fifoCount < packetSize) {
-        // other program behavior stuff here
-        // .
-        // .
-        // .
-        // if you are really paranoid you can frequently test in between other
-        // stuff to see if mpuInterrupt is true, and if so, "break;" from the
-        // while() loop to immediately process the MPU data
-        // .
-        // .
-        // .
-
-    }
-
-    // reset interrupt flag and get INT_STATUS byte
-    mpuInterrupt = false;
-    mpuIntStatus = mpu.getIntStatus();
-
-    // get current FIFO count
-    fifoCount = mpu.getFIFOCount();
-
-    // check for overflow (this should never happen unless our code is too inefficient)
-    if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
-        // reset so we can continue cleanly
-        mpu.resetFIFO();
-        Serial.println(F("FIFO overflow!"));
-
-    // otherwise, check for DMP data ready interrupt (this should happen frequently)
-    } else if (mpuIntStatus & 0x02) {
-        // wait for correct available data length, should be a VERY short wait
-        while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
-
-        // read a packet from FIFO
-        mpu.getFIFOBytes(fifoBuffer, packetSize);
-
-        // track FIFO count here in case there is > 1 packet available
-        // (this lets us immediately read more without waiting for an interrupt)
-        fifoCount -= packetSize;
-
-        #ifdef OUTPUT_READABLE_QUATERNION
-            // display quaternion values in easy matrix form: w x y z
-            mpu.dmpGetQuaternion(&q, fifoBuffer);
-            Serial.print("quat\t");
-            Serial.print(q.w);
-            Serial.print("\t");
-            Serial.print(q.x);
-            Serial.print("\t");
-            Serial.print(q.y);
-            Serial.print("\t");
-            Serial.println(q.z);
-        #endif
-
-        #ifdef OUTPUT_READABLE_EULER
-            // display Euler angles in degrees
-            mpu.dmpGetQuaternion(&q, fifoBuffer);
-            mpu.dmpGetEuler(euler, &q);
-            Serial.print("euler\t");
-            Serial.print(euler[0] * 180/M_PI);
-            Serial.print("\t");
-            Serial.print(euler[1] * 180/M_PI);
-            Serial.print("\t");
-            Serial.println(euler[2] * 180/M_PI);
-        #endif
-
-        #ifdef OUTPUT_READABLE_YAWPITCHROLL
-            // display Euler angles in degrees
-            mpu.dmpGetQuaternion(&q, fifoBuffer);
-            mpu.dmpGetGravity(&gravity, &q);
-            mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
-            Serial.print("ypr\t");
-            Serial.print(ypr[0] * 180/M_PI);
-            Serial.print("\t");
-            Serial.print(ypr[1] * 180/M_PI);
-            Serial.print("\t");
-            Serial.println(ypr[2] * 180/M_PI);
-        #endif
-
-        #ifdef OUTPUT_READABLE_REALACCEL
-            // display real acceleration, adjusted to remove gravity
-            mpu.dmpGetQuaternion(&q, fifoBuffer);
-            mpu.dmpGetAccel(&aa, fifoBuffer);
-            mpu.dmpGetGravity(&gravity, &q);
-            mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
-            Serial.print("areal\t");
-            Serial.print(aaReal.x);
-            Serial.print("\t");
-            Serial.print(aaReal.y);
-            Serial.print("\t");
-            Serial.println(aaReal.z);
-        #endif
-//================= we are using this =================================
-        #ifdef OUTPUT_READABLE_WORLDACCEL
-            // display initial world-frame acceleration, adjusted to remove gravity
-            // and rotated based on known orientation from quaternion
-            mpu.dmpGetQuaternion(&q, fifoBuffer);
-            mpu.dmpGetAccel(&aa, fifoBuffer);
-            mpu.dmpGetGravity(&gravity, &q);
-            mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
-            mpu.dmpGetLinearAccelInWorld(&aaWorld, &aaReal, &q);
-            Serial.print("aworld\t");
-            Serial.print(aaWorld.x);
-            Serial.print("\t");
-            Serial.print(aaWorld.y);
-            Serial.print("\t");
-            Serial.println(aaWorld.z);
-            if(aaWorld.x==0)
-              ref=abs(aaWorld.x)+abs(aaWorld.y)+abs(aaWorld.z);
-
-            accel=abs(aaWorld.x)+abs(aaWorld.y)+abs(aaWorld.z);
-            diff_acc=accel-ref;
-            Serial.print("\t");
-
-            Serial.println(ref);
-            Serial.println(accel);
-            Serial.println(diff_acc);
-        #endif
-
-        #ifdef OUTPUT_TEAPOT
-            // display quaternion values in InvenSense Teapot demo format:
-            teapotPacket[2] = fifoBuffer[0];
-            teapotPacket[3] = fifoBuffer[1];
-            teapotPacket[4] = fifoBuffer[4];
-            teapotPacket[5] = fifoBuffer[5];
-            teapotPacket[6] = fifoBuffer[8];
-            teapotPacket[7] = fifoBuffer[9];
-            teapotPacket[8] = fifoBuffer[12];
-            teapotPacket[9] = fifoBuffer[13];
-            Serial.write(teapotPacket, 14);
-            teapotPacket[11]++; // packetCount, loops at 0xFF on purpose
-        #endif
-
-        // blink LED to indicate activity
-        blinkState = !blinkState;
-        digitalWrite(LED_PIN, blinkState);
-    }
-  //&&&&&&&&&&&&&&&&&&&&&&& making decision to see if Door is moved &&&&&&&&&&&&&&&&&&&&&&&&&&&
-  // Send a message to nrf24_server
-  if ( diff_acc < THRESHOLD )
-    {
-      nrf24.send(doorClose,sizeof(doorClose));
-    digitalWrite(LED_PIN_Alarm , LOW);
-    }
-
-  else if (diff_acc > THRESHOLD )
-   {
-    nrf24.send(doorOpen,sizeof(doorOpen));
-    digitalWrite(LED_PIN_Alarm , HIGH);
-    }
-
- // nrf24.send(data,sizeof(data));
-   else nrf24.send(doorShake,sizeof(doorShake));
-
-    nrf24.waitPacketSent();
-  // Now wait for a reply
-  uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
-  uint8_t len = sizeof(buf);
-
-  if (nrf24.waitAvailableTimeout(500))
-  {
-    // Should be a reply message for us now
-    if (nrf24.recv(buf, &len))
-    {
-      Serial.print("got reply: ");
-      Serial.println((char*)buf);
-    }
-    else
-    {
-      Serial.println("recv failed");
-    }
-  }
-  else
-  {
-    Serial.println("No reply, is nrf24_server running?");
-  }
-  delay(10);
-}
-


Remove teensy screenshot debug

Remove teensy screenshot debug

--- examples/frogger.ino
+++ examples/frogger.ino
@@ -8,6 +8,8 @@
 #define CONTROL_RIGHT 2
 #define CONTROL_UP    4
 #define CONTROL_DOWN  8
+
+byte dazzler = 1, sf = 3;

 class Controller {
   public:
@@ -86,13 +88,14 @@
     GD.cmd_translate(F16(8),F16(8));
     GD.cmd_rotate(rot);
     GD.cmd_translate(F16(-8),F16(-8));
+    GD.cmd_scale(F16(sf), F16(sf));
     GD.cmd_setmatrix();
   }
+  GD.Cell(anim);
   if (x > 224) {
-    GD.Cell(anim);
-    GD.Vertex2f(16 * (x - 256), 16 * y);
+    GD.Vertex2f(sf * (x - 256), sf * y);
   } else {
-    GD.Vertex2ii(x, y, SPRITES_HANDLE, anim);
+    GD.Vertex2f(sf * x, sf * y);
   }
 }

@@ -206,17 +209,26 @@
 {
   static uint32_t counter;
   static int prevt;
-
+  int x0 = 0;
+
+  GD.VertexFormat(0);
   GD.Clear();
+  if (dazzler) {
+    x0 = (1280 - sf * 224) / 2;
+    GD.VertexTranslateX(16 * x0);
+    GD.cmd_scale(F16(sf), F16(sf));
+    GD.cmd_setmatrix();
+  }
   GD.Tag(1);
   GD.BitmapHandle(SPRITES_HANDLE);
   GD.SaveContext();
-  GD.ScissorSize(224, 256);
+  GD.ScissorXY(x0, 0);
+  GD.ScissorSize(sf * 224, sf * 256);
   GD.Begin(BITMAPS);
   GD.Vertex2ii(0, 0, BACKGROUND_HANDLE, 0);   // Background bitmap

-  GD.wr(REG_TAG_X, frogx - 8);
-  GD.wr(REG_TAG_Y, frogy);
+  GD.wr(REG_TAG_X, sf * (frogx - 8));
+  GD.wr(REG_TAG_Y, sf * (frogy));

   GD.Tag(2);
   GD.AlphaFunc(GREATER, 0); // on road, don't tag transparent pixels
@@ -289,14 +301,14 @@
   ti = max(0, ti - 1);
   if ((ti == 0) && (dying == 0))
     dying = 1;
-
+
   // Draw 'time remaining' by clearing a black rectangle
   {
     byte tw = 120 - (ti >> 7);
     byte tx = 72;
     GD.SaveContext();
-    GD.ScissorXY(tx, 248);
-    GD.ScissorSize(tw, 8);
+    GD.ScissorXY(sf * tx, sf * 248);
+    GD.ScissorSize(sf * tw, sf * 8);
     GD.Clear();
     GD.RestoreContext();
   }
@@ -337,29 +349,32 @@
 #define PADX(x) (480 + (x - 3) * 48)
 #define PADY(y) (272 + (y - 3) * 48)

-  GD.Tag(CONTROL_RIGHT);
-  GD.Vertex2ii(PADX(2), PADY(1), ARROW_HANDLE, 0);
-  rotate_around(24, 24, 3 * 0x4000);
-
-  GD.Tag(CONTROL_UP);
-  GD.Vertex2ii(PADX(1), PADY(0), ARROW_HANDLE, 0);
-  rotate_around(24, 24, 2 * 0x4000);
-
-  GD.Tag(CONTROL_LEFT);
-  GD.Vertex2ii(PADX(0), PADY(1), ARROW_HANDLE, 0);
-  rotate_around(24, 24, 1 * 0x4000);
-
-  GD.Tag(CONTROL_DOWN);
-  GD.Vertex2ii(PADX(1), PADY(2), ARROW_HANDLE, 0);
-  GD.RestoreContext();
-
-  GD.ColorRGB(255, 85, 0);
-  draw_score(3, 1, score);
-  draw_score(11, 1, hiscore);
-
-  GD.ColorRGB(255, 255, 255);
-  for (byte i = 0; i < lives; i++)
-    GD.Vertex2ii(8 * i, 30 * 8, LIFE_HANDLE, 0);
+  if (!dazzler) {
+    GD.Tag(CONTROL_RIGHT);
+    GD.Vertex2ii(PADX(2), PADY(1), ARROW_HANDLE, 0);
+    rotate_around(24, 24, 3 * 0x4000);
+
+    GD.Tag(CONTROL_UP);
+    GD.Vertex2ii(PADX(1), PADY(0), ARROW_HANDLE, 0);
+    rotate_around(24, 24, 2 * 0x4000);
+
+    GD.Tag(CONTROL_LEFT);
+    GD.Vertex2ii(PADX(0), PADY(1), ARROW_HANDLE, 0);
+    rotate_around(24, 24, 1 * 0x4000);
+
+    GD.Tag(CONTROL_DOWN);
+    GD.Vertex2ii(PADX(1), PADY(2), ARROW_HANDLE, 0);
+    GD.RestoreContext();
+
+    GD.ColorRGB(255, 85, 0);
+    draw_score(3, 1, score);
+    draw_score(11, 1, hiscore);
+
+    GD.ColorRGB(255, 255, 255);
+    GD.BitmapHandle(LIFE_HANDLE);
+    for (byte i = 0; i < lives; i++)
+      GD.Vertex2f(sf * (8 * i), sf * (30 * 8));
+  }

   // for (byte i = 0; i < 16; i++)
   //  GD.wr(atxy(i, 30), (i < lives) ? BG_LIFE : BG_BLACK);
@@ -430,5 +445,11 @@
   Serial.begin(1000000);    // JCB
   GD.begin(~GD_STORAGE);
   LOAD_ASSETS();
+  if (dazzler) {
+    GD.BitmapHandle(BACKGROUND_HANDLE);
+    GD.BitmapSize(NEAREST, BORDER, BORDER, GD.w, GD.h);
+    GD.BitmapHandle(SPRITES_HANDLE);
+    GD.BitmapSize(NEAREST, BORDER, BORDER, 3 * 16, 3 * 16);
+  }
   game_setup();
 }


Update ArduCAM_Shield_V2_Video2SD.ino

Update ArduCAM_Shield_V2_Video2SD.ino

--- ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Video2SD/ArduCAM_Shield_V2_Video2SD.ino
+++ ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Video2SD/ArduCAM_Shield_V2_Video2SD.ino
@@ -224,9 +224,15 @@
 Serial.println("ArduCAM Start!");
 // set the SPI_CS as an output:
 pinMode(SPI_CS, OUTPUT);
+digitalWrite(SPI_CS, HIGH);
 delay(1000);
 // initialize SPI:
 SPI.begin();
+//Reset the CPLD
+myCAM.write_reg(0x07, 0x80);
+delay(100);
+myCAM.write_reg(0x07, 0x00);
+delay(100);
 while(1){
   //Check if the ArduCAM SPI bus is OK
   myCAM.write_reg(ARDUCHIP_TEST1, 0x55);


Added victory dance

Added victory dance

--- sketch/CurieDice/CurieDice.ino
+++ sketch/CurieDice/CurieDice.ino
@@ -82,6 +82,7 @@
 #define COMMAND_REGISTER      1   // dice <--> server cmds
 #define COMMAND_REGISTER_ACK  2
 #define COMMAND_BUZZ          5
+#define COMMAND_WINNER        6
 // *******************************************************************
 // ************** Globals ********************************************
 // *******************************************************************
@@ -181,6 +182,19 @@
     digitalWrite(VIBE_PIN,0);
 }

+void winnerDance(int secs) {
+  static int danceVibe[] = {1,  0,  0,0,0, 1,0,1,0,0};
+  static int danceColor[] =     {0xf0,0x0,0xf,0x0,0xf0,0x0,0xf,0x0,0x0,0x0};
+  static int danceMask[] =      {0xaa,0xff,0x55,0xff,0xaa,0xff,0x55,0xff,0xff,0xff};
+
+  for (int j=0; j<secs; j++) {
+    for (int i=0; i<10; i++) {
+      pix.disp(danceMask[i], danceColor[i], 0);
+      digitalWrite(VIBE_PIN, danceVibe[i]);
+      delay(100);
+    }
+  }
+}
 // ************* BLE **************************************************
 void bleSetup() {
   blePeripheral.setLocalName("CurieDice");
@@ -198,6 +212,8 @@
   switch(cvalue) {
     case COMMAND_REGISTER_ACK: dice_registered = true; break;
     case COMMAND_BUZZ:         vibrate(50);       break;
+    case COMMAND_WINNER:
+      winnerDance(5); break;
   }
 }
 void registerDice() {
@@ -354,7 +370,7 @@
           }
           i = (i==0)? TSLOTS-1:i-1;
         }
-        if ((his+lows)>6 && his>0) {
+        if ((his+lows)>9 && his>3) {
           int roll = calcOrientation();
           SERIAL_PRINTLN(roll);
           resultShow(roll);
@@ -401,7 +417,8 @@

   readDiceId();
-
+
+  winnerDance(2);
   // *************** IMU Setup ***************************************
   // initialize device
   SERIAL_PRINTLN("Initializing IMU device...");


Update ssd1306_128x64_i2c.ino

Update ssd1306_128x64_i2c.ino

Removed random() function now implemented in firmware.

--- ssd1306_128x64_i2c.ino
+++ ssd1306_128x64_i2c.ino
@@ -27,9 +27,6 @@
 #define YPOS 1
 #define DELTAY 2

-int arandom(int maxRand) {
-    return rand() % maxRand;
-}

 #define LOGO16_GLCD_HEIGHT 16
 #define LOGO16_GLCD_WIDTH  16


Fixed format string

Fixed format string

--- buzzmobile/drive/arduino/src/car_driver/car_driver.ino
+++ buzzmobile/drive/arduino/src/car_driver/car_driver.ino
@@ -107,7 +107,7 @@

       lastCmdTime = millis();
       retMsg[0] = STX;
-      sprintf(retMsg+1, "%05i%05.4f%02.4", count, getSteeringAngle(), getSpeed());
+      sprintf(retMsg+1, "%05i%05.4f%05.4f", count, getSteeringAngle(), getSpeed());
       Serial.println(retMsg);
       count = 0;
     }


Remove interrupt (because we can't use that anymore :( )

--- code/oakpowerboard/oakpowerboard.ino
+++ code/oakpowerboard/oakpowerboard.ino
@@ -121,7 +121,7 @@
   // put your setup code here, to run once:
   // initialize the digital pin as an output.
   pinMode(1, OUTPUT); //LED on Model A
-  attachInterrupt(digitalPinToInterrupt(PULSE_PIN), trigger_pulse, FALLING);
+  //attachInterrupt(digitalPinToInterrupt(PULSE_PIN), trigger_pulse, FALLING);
 #ifdef DEBUG
   pinMode(DEBUG_LED, OUTPUT);//Debugging LED
 #endif
@@ -174,7 +174,6 @@
       analogCounter = 0;
     }

-    if(pulse_triggered == true) {
     /*if(pulse_triggered == true) {
         storage.pulse_count_current_kwh++;
         if(storage.pulse_count_current_kwh == PULSES_PER_KWH) {


Almost complete

Almost complete

--- _4DSystemDispalyBare/_4DSystemDispalyBare.ino
+++ _4DSystemDispalyBare/_4DSystemDispalyBare.ino
@@ -39,19 +39,26 @@
 int index;
 void setup()
 {
-
-  pinMode(13,OUTPUT);
-  pinMode(RESETLINE, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
-  digitalWrite(RESETLINE, 1);  // Reset the Display via D4
-  delay(100);
-  digitalWrite(RESETLINE, 0);  // unReset the Display via D4
-  delay(5000);
+  //MOTORS setup
+  //Setup Channel A
+  pinMode(12, OUTPUT); //Initiates Motor Channel A pin
+  pinMode(9, OUTPUT); //Initiates Brake Channel A pin
+
+  pinMode(13, OUTPUT); //Initiates Motor Channel A pin
+  pinMode(8, OUTPUT); //Initiates Brake Channel A pin
+
+//
+//  pinMode(RESETLINE, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
+//  digitalWrite(RESETLINE, 1);  // Reset the Display via D4
+//  delay(100);
+//  digitalWrite(RESETLINE, 0);  // unReset the Display via D4
+//  delay(5000);
   DisplaySerial.begin(9600) ;
   Display.TimeLimit4D   = 5000 ; // 5 second timeout on all commands
   Display.gfx_Cls();
   Display.gfx_ScreenMode(PORTRAIT) ;
   Display.putstr("Lunakhod loading...") ;
-  HWLOGGING.begin(9600);
+//  HWLOGGING.begin(9600);
 //  delay(5000); - uncomment in final
 }

@@ -71,6 +78,18 @@
 int state = INIT_STATE;
 void loop()
 {
+//    //forward @ full speed A
+//  digitalWrite(12, HIGH); //Establishes forward direction of Channel A
+//  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
+//  analogWrite(3, 255);   //Spins the motor on Channel A at full speed
+//
+//    //forward @ full speed B
+//  digitalWrite(13, LOW); //Establishes forward direction of Channel B
+//  digitalWrite(8, LOW);   //Disengage the Brake for Channel B
+//  analogWrite(11, 255);   //Spins the motor on Channel B at full speed
+//
+//  delay(1000);
+
   Display.touch_Set(TOUCH_ENABLE) ;
   Display.touch_Set(TOUCH_REGIONDEFAULT) ;
   drawInitialScreen();
@@ -391,8 +410,18 @@
     switch(commands[i])
     {
       case MOVE:
-//          motors();
+            HWLOGGING.println("move forward");
+            move_forward(duration[i]);
+
           break;
+      case ROTATE_LEFT:
+            HWLOGGING.println("rotate left");
+            rotate_left(duration[i]);
+          break;
+      case ROTATE_RIGHT:
+            HWLOGGING.println("rotate right");
+            rotate_right(duration[i]);
+          break;
       case SHOOT:
           break;
     }
@@ -424,3 +453,45 @@
       return "SHOOT";
   }
 }
+
+void move_forward(unsigned int duration)
+{
+  //forward @ full speed A
+  digitalWrite(12, HIGH); //Establishes forward direction of Channel A
+  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
+  analogWrite(3, 255);   //Spins the motor on Channel A at full speed
+
+    //forward @ full speed B
+  digitalWrite(13, LOW); //Establishes forward direction of Channel B
+  digitalWrite(8, LOW);   //Disengage the Brake for Channel B
+  analogWrite(11, 255);   //Spins the motor on Channel B at full speed
+
+  delay(duration);
+  stop();
+}
+
+void rotate_right(unsigned int duration)
+{
+  //forward @ full speed B
+  digitalWrite(13, LOW); //Establishes forward direction of Channel B
+  digitalWrite(8, LOW);   //Disengage the Brake for Channel B
+  analogWrite(11, 255);   //Spins the motor on Channel B at full speed
+
+  delay(duration);
+  stop();
+}
+
+void rotate_left(unsigned int duration)
+{
+  digitalWrite(12, HIGH); //Establishes forward direction of Channel A
+  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
+  analogWrite(3, 255);   //Spins the motor on Channel A at full speed
+  delay(duration);
+  stop();
+}
+
+void stop()
+{
+  digitalWrite(9, HIGH);   //Disengage the Brake for Channel A
+  digitalWrite(8, HIGH);   //Disengage the Brake for Channel B
+}


Commented one line out for the moment

Commented one line out for the moment

--- src/CAN/CAN_send_v2/CAN_send_v2.ino
+++ src/CAN/CAN_send_v2/CAN_send_v2.ino
@@ -180,7 +180,7 @@
     for (int i = 16; i < 20; i++) msg3[i - 16] = correct_hash[i];

     // Fill last 4 bytes of msg3 with the timestamp
-    StampTime(&msg3[4]);
+    //StampTime(&msg3[4]);

     CAN.sendMsgBuf(id, 0, 8, msg1);
     CAN.sendMsgBuf(id, 0, 8, msg2);


This wasn't old Night Sparkles at all

This wasn't old Night Sparkles at all

--- staff/staff.ino
+++ staff/staff.ino
@@ -90,26 +90,10 @@
   return value;
 }

-void oldNightSparkles() {
-  if (firstTimeRunningThroughPattern) {
-    hue = 32;
-    numberOfSparkles = 10;
-  }
-
-  fadeToBlackBy(leds, NUM_LEDS, 200);
-  numberOfSparkles = upAndDownBy(numberOfSparkles, 1, 30, 1);
-  for (int i = 0; i < numberOfSparkles; i++) {
-    int pos = random16(NUM_LEDS);
-    leds[pos] = leds[pos-8];
-    leds[pos-8] = CHSV(0, 0, 0);
-    leds[pos] = CHSV(hue+(pos / 18), 100+((double)pos/(double)NUM_LEDS)*255.0, 255);
-  }
-}
-
 int frameSize = 8;
 uint8_t counter = 0;
 void nightSparkles() {
-
+
   if (firstTimeRunningThroughPattern) {
     for (int i = NUM_LEDS; i > 0; i--) {
       int on = random(100) > 80 ? 255 : 0;


Update acrylic_sign.ino

Update acrylic_sign.ino

--- projects/arduino/acrylic_sign/acrylic_sign.ino
+++ projects/arduino/acrylic_sign/acrylic_sign.ino
@@ -1,6 +1,6 @@
 #include <Adafruit_NeoPixel.h>

-#define PIN 13
+#define PIN 3

 // Parameter 1 = number of pixels in strip
 // Parameter 2 = pin number (most are valid)


Exctracted all code from loop() to separate functions.

--- GPSModul.ino
+++ GPSModul.ino
@@ -32,19 +32,15 @@

 void loop()
 {
+  startGPS();
+}
+
+void startGPS(){
   // Nakon svake NMEA recenice ispisuju se podaci
   while (ss.available() > 0){
     if (gps.encode(ss.read())){
         displayInfo();
-
-        if(gps.location.isValid()){ // Zapisujemo samo ako imamo koordinate
-            sdCardObject = SD.open("gpsData.txt", FILE_WRITE); // Otvaramo gpsData za pisanje
-            sdCardObject.print(gps.location.lng(), 6);
-            sdCardObject.print(",");
-            sdCardObject.print(gps.location.lat(), 6);
-            sdCardObject.print(" ");
-            sdCardObject.close();
-        }
+        writeToSD();
       }
   }

@@ -53,6 +49,17 @@
     Serial.println(F("Veza sa GPS modulom nije uspostavljena."));
     while(true){};
   }
+}
+
+void writeToSD(){
+  if(gps.location.isValid()){ // Zapisujemo samo ako imamo koordinate
+            sdCardObject = SD.open("gpsData.txt", FILE_WRITE); // Otvaramo gpsData za pisanje
+            sdCardObject.print(gps.location.lng(), 6);
+            sdCardObject.print(",");
+            sdCardObject.print(gps.location.lat(), 6);
+            sdCardObject.print(" ");
+            sdCardObject.close();
+        }
 }

 void displayInfo() // Funkcija za ispis podataka


Bugzilla 509: IotKitSimpleExample not aware of new components

--- arduino/IoTkit/examples/IoTkitSimpleExample/IoTkitSimpleExample.ino
+++ arduino/IoTkit/examples/IoTkitSimpleExample/IoTkitSimpleExample.ino
@@ -1,4 +1,4 @@
-/*
+/*
 Copyright (c) 2015, Intel Corporation

 Redistribution and use in source and binary forms, with or without modification,
@@ -32,6 +32,8 @@
 //Following components should be registered (by running: iotkit-admin register NAME TYPE):
 //temperature of type temperature.v1.0
 //You can also use IoTkitRegisterExample to activate and register new components
+//Restart iotkit-agent for it to be aware of new components:
+//   # systemctl restart iotkit-agent

 #include <IoTkit.h>    // include IoTkit.h to use the Intel IoT Kit
 #include <Ethernet.h>  // must be included to use IoTkit


Fix #299 interrupt example

Fix #299 interrupt example

--- examples/More/Sync/ButtonInterrupt/ButtonInterrupt.ino
+++ examples/More/Sync/ButtonInterrupt/ButtonInterrupt.ino
@@ -39,14 +39,19 @@

 WidgetLED led1(V1);

+// We make these values volatile, as they are used in interrupt context
+volatile bool pinChanged = false;
+volatile int  pinValue   = 0;
+
+// Most boards won't send data to WiFi out of interrupt handler.
+// We just store the value and process it in the main loop.
 void checkPin()
 {
   // Invert state, since button is "Active LOW"
-  if (digitalRead(2)) {
-    led1.off();
-  } else {
-    led1.on();
-  }
+  pinValue = !digitalRead(2);
+
+  // Mark pin value changed
+  pinChanged = true;
 }

 void setup()
@@ -65,5 +70,18 @@
 void loop()
 {
   Blynk.run();
+
+  if (pinChanged) {
+
+    // Process the value
+    if (pinValue) {
+      led1.on();
+    } else {
+      led1.off();
+    }
+
+    // Clear the mark, as we have processed the value
+    pinChanged = false;
+  }
 }


Serial debug

Serial debug

--- modbusiptest/modbusiptest.ino
+++ modbusiptest/modbusiptest.ino
@@ -32,6 +32,7 @@
     byte subnet[] = { 255, 255, 255, 0 };

     mb.config(mac, ip, dns, gateway, subnet);
+    Serial.begin(9600);

     pinMode(ledPin, OUTPUT);

@@ -54,6 +55,7 @@

 void loop() {
    mb.proc();
+
    if (mb.Coil(COIL1) && mb.Coil(COIL2))
      mb.Coil(LAMP, true);
    else


add analogRead to example

add analogRead to example

this adds an analogRead function to the 7segment code.

--- arduino-makefile/examples/7segment/7segment.ino
+++ arduino-makefile/examples/7segment/7segment.ino
@@ -10,16 +10,16 @@
     #define CLOCK 13
     #define DATA 11
     #define pushButton 7
-
+    #define sliderPot 20

     /*
      clk=/sys/class/gpio/gpio2
      serial=/sys/class/gpio/gpio4
      latch=/sys/class/gpio/gpio5
     */
-    const byte ledCharSet[10] = {
+    const byte ledCharSet[11] = {

-      B00111111,B00000110,B01011011,B01001111,B01100110,B01101101,B01111101,B00000111,B01111111,B01101111
+      B00111111,B00000110,B01011011,B01001111,B01100110,B01101101,B01111101,B00000111,B01111111,B01101111,B10000000
     };

     void setup(){
@@ -36,9 +36,9 @@

     void loop(){
             int buttonState = digitalRead(pushButton);
+	    int sliderState = analogRead(sliderPot);
             /* Serial.println("Seven segment display test"); */
             /* print out the state of the button: */
-            printf("%d\n", buttonState);
             /* delay in between reads for stability */
             if (!buttonState) {
                     digitalWrite(LATCH,0);
@@ -50,6 +50,14 @@
                     }
             delay(250);
             }
+            else {
+
+		    i=abs(sliderState/100);
+                    digitalWrite(LATCH,0);
+                    shiftOut(DATA,CLOCK,MSBFIRST,~(ledCharSet[i]));
+                    digitalWrite(LATCH,1);
+
+	    }
             delay(10);
     }


Preparation for settings implementation

Preparation for settings implementation

--- DiveIno.ino
+++ DiveIno.ino
@@ -413,6 +413,8 @@
 		Serial.println(number);
 		tone(speakerPin, 261, 10);
 	}
+
+	// TODO
 }

 void hashButtonPressed()
@@ -648,10 +650,15 @@
 void displaySettingsScreen()
 {
 	// Settings:
-	//  seaLevelAtmosphericPressure = 1013.25
-	//  nitrogenRateInGas = 0.79  ->  oxygen: 0.21
-	//  testMode = On/Off
-	//  units = metric/imperial
+	//
+	// From SETTINGS.TXT:
+	//  seaLevelPressure = 1013.25
+	//  oxygenRate = 0.21
+	//  testMode = 1 :  0 = Off, 1 = On
+	//  sound = 1 : 0 = Off, 1 = On
+	//  units = 0 : 0 = metric, 1 = imperial
+	//
+	// Real Time Clock settings - for this a separate application can be used:
 	//  time = 18:05
 	//  date = 2015-11-14


Use LED range for solid rainbow as well

Use LED range for solid rainbow as well

--- main.ino
+++ main.ino
@@ -45,10 +45,10 @@
 #define MAX_PARAMETERS 7

 /* Holds the parameter that is currently changed using the rotary wheel. */
-uint8_t activeParameter = PARAMETER_MODE;
+uint8_t activeParameter = PARAMETER_SPEED;

 /* Holds the values of the different parameters. */
-uint8_t parameters[MAX_PARAMETERS] = { 1, 190, 255, 128, 5, 0, /*NUM_LEDS-1*/ 4 };
+uint8_t parameters[MAX_PARAMETERS] = { 2, 190, 255, 128, 5, 0, /*NUM_LEDS-1*/ 4 };

 /* Maximum values of the different parameters, plus one. Zero denotes that a
  * variable can stretch the full range of 0-255. */
@@ -151,60 +151,68 @@

     /* Contiguous block */
     if (end >= start) {
-        for (uint8_t led = start; led < end; led++) {
+        for (uint8_t led = start; led <= end; led++) {
             leds[led] = color;
         }
         return;
     }

     /* Split into two parts. Draw start first, then end. */
-    for (uint8_t led = 0; led < end; led++) {
+    for (uint8_t led = 0; led <= end; led++) {
         leds[led] = color;
     }

     for (uint8_t led = start; led < NUM_LEDS; led++) {
         leds[led] = color;
     }
+}
+
+/* animatedFill fills the portion of LEDs that should be lit up according to
+ * POSITION and SIZE. If an animation was triggered, return true. Otherwise,
+ * return false. */
+bool animatedFill(CHSV color) {
+    static uint8_t animation_start = 0;
+    uint8_t start;
+
+    start = (animation_start + parameters[PARAMETER_POSITION]) % NUM_LEDS;
+
+    fillSolid(start, start + parameters[PARAMETER_SIZE], color);
+
+    if (!stepAnimation()) {
+        return false;
+    }
+
+    animation_start++;
+    animation_start %= NUM_LEDS;
+
+    return true;
 }

 /* modeSolid draws a solid color across all LEDs, according to the parameters
  * HUE, SATURATION, VALUE. */
 void modeSolid() {
-    static uint8_t animation_start = 0;
-    uint8_t start;
-
-    start = (animation_start + parameters[PARAMETER_POSITION]) % NUM_LEDS;
-
-    fillSolid(start, start + parameters[PARAMETER_SIZE], CHSV(
+    animatedFill(CHSV(
         parameters[PARAMETER_HUE],
         parameters[PARAMETER_SATURATION],
         parameters[PARAMETER_VALUE]
     ));
-
-    if (!stepAnimation()) {
-        return;
-    }
-
-    animation_start++;
-    animation_start %= NUM_LEDS;
 }

 /* modeSolidRainbow draws a solid color across all LEDs, animating it according
  * to the color wheel. */
 void modeSolidRainbow() {
     static uint8_t hue = 0;
-
-    fill_solid(&leds[0], NUM_LEDS, CHSV(
+    bool animated;
+
+    animated = animatedFill(CHSV(
         hue + parameters[PARAMETER_HUE],
         parameters[PARAMETER_SATURATION],
         parameters[PARAMETER_VALUE]
     ));

-    if (!stepAnimation()) {
-        return;
-    }
-
-    hue++;
+    if (animated) {
+        hue++;
+    }
 }

 /* modeRainbow draws an animated rainbow across all LEDs. */


refactor wipeStaleStatus

refactor wipeStaleStatus

--- vfobox.ino
+++ vfobox.ino
@@ -96,6 +96,14 @@
   lcd.print(statusLine);
   statusDisplayed = true;
   lastStatus = millis();
+}
+
+//Wipe stale status
+void wipeStaleStatus() {
+  if (statusDisplayed && millis() - lastStatus > 2000) {
+    clear_line(1);
+    statusDisplayed = false;
+  }
 }

 // Display the frequency...
@@ -306,10 +314,5 @@
   }

   checkOutputLevel();
-
-  //wipe stale status
-  if (statusDisplayed && millis() - lastStatus > 2000) {
-    clear_line(1);
-    statusDisplayed = false;
-  }
-}
+  wipeStaleStatus();
+}


Altered the Arduino balcony script.

Altered the Arduino balcony script.

--- vendor/LowPowerLab/deviceBalconyClass/deviceBalconyClass.ino
+++ vendor/LowPowerLab/deviceBalconyClass/deviceBalconyClass.ino
@@ -156,9 +156,9 @@
   }

   unsigned long currentPeriod = millis();
-  if (currentPeriod - previousPeriod >= transPeriod || currentPeriod <= previousPeriod) {
+  if (currentPeriod - previousPeriod >= transPeriod || currentPeriod < previousPeriod) {
+    previousPeriod = currentPeriod;
     transPeriod = random((1000 * 60 * 60), ((1000 * 60 * 60) + (1000 * 60 * 5)));
-    previousPeriod += transPeriod; // this is for a more consistend frequentie instate of previousPeriod = currentPeriod;

     memset(&temperature, 0, sizeof(temperature)); // clear it
     strncpy( temperature, homedht.getTemperature(1), sizeof(temperature)-1 );


Update Noika5110.ino

Update Noika5110.ino

--- firmware/examples/Noika5110.ino
+++ firmware/examples/Noika5110.ino
@@ -19,7 +19,7 @@
 *********************************************************************/

 #include "Adafruit_GFX/Adafruit_GFX.h"
-#include "Adafruit_PCD8544.h"
+#include "Adafruit_PCD8544/Adafruit_PCD8544.h"

 // (FAST) SOFTWARE SPI
 // pin A3 - Serial clock out (SCLK) - User defined


Delete Lux.ino

Delete Lux.ino

--- Lux/Lux.ino
+++ Lux/Lux.ino
@@ -1,112 +0,0 @@
-#include <LiquidCrystal.h>
-
-//nano A4 is SDA A5 is SCL
-
- float dataAvg=0;
- float dataLux = 0;
- double num = 0.097656;
- LiquidCrystal lcd(3, 4, 5, 6, 7, 8);
-void setup()
-{
-      lcd.begin(16, 2);
-      Serial.begin(9600);
-      SensorInit();
-      delay(1000);
-
-     lcd.setCursor(0, 0);
-     lcd.print("   Welcome ! ");
-     lcd.setCursor(0, 1);
-     lcd.print("Press the switch");
-
-
-}
-
-void loop()
-{
-  unsigned int i,sum;
-  unsigned int datatmp=0;
-
-//
-//  for(i=0;i<10;i++)
-//  {
-//    j = Sensor_Lux_Read();
-//    delay(200);
-//    Serial.print("j:");
-//    Serial.println(dataLux);
-//    datatmp = j +  datatmp;
-//  }
-//
-//      datatmp = datatmp/10;
-  dataAvg = 0;datatmp=0;
-  sum=0;
-  int key=0 ;
-  key = analogRead(2);
-  delay(100);
-  if( key >= 1020 )
-  {
-     for(i=0;i<=30;i++)
-     {
-         datatmp = Sensor_Lux_Read();
-          delay(100);
-
-          dataLux = datatmp*num;
-          sum = sum +  dataLux;
-          Lcd1602();
-       }
-       dataAvg= sum / 30.0;
-       key=0 ;
-       lcd.clear();
-       delay(600);
-       Lcd1602_Avg();
-       delay(600);
-       lcd.clear();
-       delay(600);
-       Lcd1602_Avg();
-       delay(600);
-       lcd.clear();
-       delay(600);
-       Lcd1602_Avg();
-       delay(5000);
-       lcd.clear();
-
-  }
- else
- {
-
-     lcd.setCursor(0, 0);
-     lcd.print("   Welcome ! ");
-     lcd.setCursor(0, 1);
-     lcd.print("Press the switch");
-
-  }
-
-
-}
-
-void SensorInit()
-{
-	Sensor_Lux_Init();
-      //  Lcd_1602();
-}
-
-void Lcd1602()
-{
-      lcd.clear();
-      lcd.setCursor(0, 0);
-      lcd.print(" Density:");
-      lcd.print(dataLux, 1);
-      lcd.print(" N");
-}
-void Lcd1602_Avg()
-{
-
-      lcd.setCursor(0, 0);
-      lcd.print(" Density:");
-      lcd.print(dataAvg, 1);
-      lcd.print(" N");
-      lcd.setCursor(0, 1);
-      lcd.print(" Content:");
-      lcd.print(dataAvg, 1);
-      lcd.print(" mg");
-
-}


Added header comment to source code

Added header comment to source code


adding charge/discharge options

adding charge/discharge options

--- ChargerBox/ChargerBox.ino
+++ ChargerBox/ChargerBox.ino
@@ -14,6 +14,8 @@
     MODE_TIME,
     MODE_VOLTAGE,
     MODE_LCD_TIMER,
+    MODE_CHARGE,
+    MODE_DISCHARGE,
     NUM_MODE_ENUMS,
     MODE_SERIAL_MON,
 };
@@ -91,12 +93,13 @@
 {
     char line1[24] = "                         ";
     char line2[24] = "                         ";
-    sprintf(line1, "%02d:%02d:%02dHHHHHHHHHHHHHHHHHHH", hours, minutes, seconds);
+    sprintf(line1, "%02d:%02d:%02d%10s", hours, minutes, seconds, "");
     sprintf(line2, "%16s", "");

     switch ( _mode )
     {
     case MODE_VCC:
+        sprintf(line1, "%02d:%02d:%02d                ", hours, minutes, seconds);
         sprintf(line2, "VCC: %sV", str_vcc );
         break;
     case MODE_TIME:
@@ -120,6 +123,13 @@
     case MODE_SERIAL_MON:
         sprintf(line1, "%s", serial_buf2);
         sprintf(line2, "%s", serial_buf1);
+    case MODE_CHARGE:
+        sprintf(line1, "%s", "CHARGE");
+        sprintf(line2, "%s", str_volt);
+        break;
+    case MODE_DISCHARGE:
+        sprintf(line1, "%s", "DISCHARGE");
+        sprintf(line2, "%s", str_volt);
         break;
     default:
         sprintf(line2, "DFT mode %d %s", _mode, "      " );
@@ -204,6 +214,10 @@
     pinMode(7, INPUT);
     pinMode(8, INPUT);
     delay(500);
+    pinMode(3, OUTPUT);
+    pinMode(9, OUTPUT);
+    digitalWrite(3, HIGH);
+    digitalWrite(9, HIGH);

     Serial.begin(9600);
     while (!Serial);
@@ -260,8 +274,33 @@
         mode %= NUM_MODE_ENUMS;
         clear_screen();
     }
-
-    if ( mode == MODE_LCD_TIMER)
+    if ( mode == MODE_DISCHARGE)
+    {
+        if ( g_Buttons.up_button != 0 &&
+            g_LastButtons.up_button == 0)
+        {
+            digitalWrite(3, HIGH);
+        }
+        if ( g_Buttons.bottom_button != 0 &&
+            g_LastButtons.bottom_button == 0)
+        {
+            digitalWrite(3, LOW);
+        }
+    }
+    else if ( mode == MODE_CHARGE)
+    {
+        if ( g_Buttons.up_button != 0 &&
+            g_LastButtons.up_button == 0)
+        {
+            digitalWrite(9, HIGH);
+        }
+        if ( g_Buttons.bottom_button != 0 &&
+            g_LastButtons.bottom_button == 0)
+        {
+            digitalWrite(9, LOW);
+        }
+    }
+    else if ( mode == MODE_LCD_TIMER)
     {
         // Serial.write("mode timer");
         if ( g_Buttons.up_button != 0 &&


Better average handling.

Better average handling.

--- Alicorn.ino
+++ Alicorn.ino
@@ -241,12 +241,14 @@

 struct AVERAGE {
     float  temperature;
+    int    temperatureCount;
     float  humidity;
+    int    humidityCount;
     float  pressure;
+    int    pressureCount;
     float  gas;
+    int    gasCount;
 } average;
-
-int averageCount;

 // Utilities
 void resetLCD();
@@ -351,7 +353,10 @@
     average.pressure    = 0;
     average.gas         = 0;

-    averageCount        = 0;
+    average.temperatureCount = 0;
+    average.humidityCount    = 0;
+    average.pressureCount    = 0;
+    average.gasCount         = 0;
 }

 void geigerClick() {
@@ -713,27 +718,26 @@
 void processSensors() {
     if (intervals.measure) {
         intervals.measure = false;
-        averageCount++;

         float value;
         value = dht.readTemperature();
         if (String(value) != "nan") {
             data.temperature     = value;
-            average.temperature += value;
+            average.temperature += value;
+            average.temperatureCount++;
         }
         else {
             Serial.println("Error reading Temperature.");
-            average.temperature += data.temperature;
         }

         value = dht.readHumidity();
         if (String(value) != "nan") {
             data.humidity     = value;
-            average.humidity += value;
+            average.humidity += value;
+            average.humidityCount++;
         }
         else {
             Serial.println("Error reading Humidity.");
-            average.humidity += data.humidity;
         }

         char stat;
@@ -753,16 +757,18 @@
                         if (String(value) != "nan")
                             data.pressure     = value;
                             average.pressure += value;
+                            average.pressureCount++;
                     }
                 }
             }
         }

-        value = 0;
-        if (settings.gasSensor)
+        if (settings.gasSensor) {
             value = ((1023 - (float) analogRead(PIN_MQ)) / 1023) * 100;
-        data.gas     = value;
-        average.gas += value;
+            data.gas     = value;
+            average.gas += value;
+            average.gasCount++;
+        }
     }
 }

@@ -1050,11 +1056,11 @@
 void pushVariPass() {
     if (WiFi.status() == WL_CONNECTED) {
         int result;
-        varipassWriteFloat(KEY1, ID_TEMPERATURE, average.temperature / averageCount, &result);
-        varipassWriteFloat(KEY1, ID_HUMIDITY,    average.humidity    / averageCount, &result);
-        varipassWriteFloat(KEY1, ID_PRESSURE,    average.pressure    / averageCount, &result);
+        varipassWriteFloat(KEY1, ID_TEMPERATURE, average.temperature / average.temperatureCount, &result);
+        varipassWriteFloat(KEY1, ID_HUMIDITY,    average.humidity    / average.humidityCount,    &result);
+        varipassWriteFloat(KEY1, ID_PRESSURE,    average.pressure    / average.pressureCount,    &result);
         if (settings.gasSensor)
-            varipassWriteFloat(KEY1, ID_GAS,     average.gas         / averageCount, &result);
+            varipassWriteFloat(KEY1, ID_GAS,     average.gas         / average.gasCount,         &result);
         varipassWriteInt  (KEY1, ID_CPM,  data.cpm,  &result);
         varipassWriteFloat(KEY1, ID_DOSE, data.dose, &result);
     }


Fixed a typo.

Fixed a typo.

--- examples/HX711Serial/HX711Serial.ino
+++ examples/HX711Serial/HX711Serial.ino
@@ -11,7 +11,7 @@

   Serial.println("Before setting up the scale:");
   Serial.print("read: \t\t");
-  Serial.println(scale.read());			// print a waw reading from the ADC
+  Serial.println(scale.read());			// print a raw reading from the ADC

   Serial.print("read average: \t\t");
   Serial.println(scale.read_average(20));  	// print the average of 20 readings from the ADC


Update the MarqueeText example and clean up the documentation

--- examples/MarqueeText/MarqueeText.ino
+++ examples/MarqueeText/MarqueeText.ino
@@ -1,16 +1,22 @@
 #include <LEDMatrixDriver.hpp>

 // This sketch draw marquee text on your LED matrix using the hardware SPI driver Library by Bartosz Bielawski.
-// Example written 16.06.2017 by Marko Oette, www.oette.info
+// Example written 16.06.2017 by Marko Oette, www.oette.info

 // Define the ChipSelect pin for the led matrix (Dont use the SS or MISO pin of your Arduino!)
 // Other pins are arduino specific SPI pins (MOSI=DIN of the LEDMatrix and CLK) see https://www.arduino.cc/en/Reference/SPI
 const uint8_t LEDMATRIX_CS_PIN = 9;

-// Define LED Matrix dimensions (0-n) - eg: 32x8 = 31x7
-const int LEDMATRIX_WIDTH = 31;
-const int LEDMATRIX_HEIGHT = 7;
-const int LEDMATRIX_SEGMENTS = 1;
+// Define LED Matrix dimensions: 32x8, 16x8, or 8x8
+const int LEDMATRIX_WIDTH    = 32;
+const int LEDMATRIX_HEIGHT   = 8;
+const int LEDMATRIX_SEGMENTS = LEDMATRIX_WIDTH / LEDMATRIX_HEIGHT;
+
+// Marquee text
+char text[] = "** LED MATRIX DEMO! ** (1234567890) ++ \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" ++ <$%/=?'.@,> --";
+
+// Marquee speed (lower nubmers = faster)
+const int ANIM_DELAY = 30;

 // The LEDMatrixDriver class instance
 LEDMatrixDriver lmd(LEDMATRIX_SEGMENTS, LEDMATRIX_CS_PIN);
@@ -85,30 +91,26 @@
                      {0x00,0x44,0x44,0x28,0x10,0x10,0x10,0x10}, // Y
                      {0x00,0x7c,0x04,0x08,0x7c,0x20,0x40,0xfe}, // Z
                       // (the font does not contain any lower case letters. you can add your own.)
-                  };    // {}, //
+                  };    // {}, //

-// Marquee speed
-const int ANIM_DELAY = 20;

-// Marquee text
-char text[] = "** LED MATRIX DEMO! ** (1234567890) ++ \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" ++ <$%/=?'.@,> --";
-int len = strlen(text);
+void loop()
+{
+	// Draw the text to the current position
+	int len = strlen(text);
+	drawString(text, len, x, 0);
+	// In case you wonder why we don't have to call lmd.clear() in every loop: The font has a opaque (black) background...

-void loop()
-{
- // Draw the text to the current position
- drawString(text, len, x, 0);
-   // In case you wonder why we don't have to call lmd.clear() in every loop: The font has a opaque (black) background...
-
- // Toggle display of the new framebuffer
- lmd.display();
+	// Toggle display of the new framebuffer
+	lmd.display();

- // Wait to let the human read the display
- delay(ANIM_DELAY);
+	// Wait to let the human read the display
+	delay(ANIM_DELAY);

- // Advance to next coordinate
- if( --x < len * -8 )
-   x = LEDMATRIX_WIDTH;
+	// Advance to next coordinate
+	if( --x < len * -8 ) {
+		x = LEDMATRIX_WIDTH;
+	}
 }

@@ -138,7 +140,7 @@
 {
   // The mask is used to get the column bit from the sprite row
   byte mask = B10000000;
-
+
   for( int iy = 0; iy < height; iy++ )
   {
     for( int ix = 0; ix < width; ix++ )


Return NULL, not a dereferenced NULL...

Return NULL, not a dereferenced NULL...

Fix what would most likely have segsaulted on systems that can segfault!

--- alarm.ino
+++ alarm.ino
@@ -57,10 +57,10 @@
     linked_list_t * iterator = alarms;
     while (iterator != NULL) {
         if (GET_MEMBER(iterator, alarm_t, alarmno) == alarmno)
-            break;
+            return GET_ITEM(iterator, alarm_t);
         NEXT(iterator);
     }
-    return GET_ITEM(iterator, alarm_t);
+    return NULL;
 }

 static inline void prepare_action(alarm_t * alarm, actionspec_t * actionspec, bool invert) {


minor tweaks

minor tweaks

--- CS26410.ino
+++ CS26410.ino
@@ -24,7 +24,7 @@
 #define turret 13

 #define DrightStop 68
-#define DleftStop 84
+#define DleftStop 83
 #define TurretCenter 84

@@ -45,7 +45,6 @@
   Driveright.write(DrightStop);
   Turret.attach(turret);
   Turret.write(TurretCenter);
-

   pinMode(LDRLeft, INPUT);
   pinMode(LDRCenter, INPUT);
@@ -56,6 +55,9 @@
   pinMode(SharpIrEnable, OUTPUT);
   pinMode(LEDRed, OUTPUT);

+  Serial.begin(9600);
+
+

 }
@@ -63,3 +65,5 @@
 void loop(){
 delay(10);
 }
+
+


Setting the right way

Setting the right way

--- arduino.ino
+++ arduino.ino
@@ -47,8 +47,7 @@
 }

 void loop() {
-  is_tank_full = digitalRead(PIN_MOISTURE_SENSOR);
-  Serial.println(is_tank_full);
+  is_tank_full = !digitalRead(PIN_MOISTURE_SENSOR);
   // If the tank is not full, activate the water pump.
   digitalWrite(PIN_WATER_PUMP_RELAY, !is_tank_full);
   is_short_ordered = digitalRead(PIN_ORDER_SHORT);


sdfsdfg

sdfsdfg

--- serial/arduino/arduino.ino
+++ serial/arduino/arduino.ino
@@ -1,34 +1,38 @@
 const int relay = 2;
 int n = 0;
-int temp = 0;
-float temperature = 0;
-float referencevoltage;
+float referencevoltage = 5.0;
+//float temp = 0;
+//float temperature = 0;
 int light = 0;
-int sound = 0;
-
 void setup()
 {
   pinMode(relay, OUTPUT);
   digitalWrite(relay, LOW);
   Serial.begin(9600);
-  analogReference(INTERNAL);
-  referencevoltage = 1.1;
+  //analogReference(INTERNAL);
+  referencevoltage = 5;
 }

 void loop()
 {
+  float temp = 0;
+  for(int i=0; i<100; i++)
+  {
+    temp += analogRead(A5);
+  }
+  float temperature = (temp*referencevoltage)/1023.0 - 4;
+  //Serial.println(temperature);
+  light = analogRead(A4);
   if(Serial.available())
   {
     n = Serial.parseInt();
-    command(n);
+    command(n, temperature);
   }
-  temp = analogRead(A5);
-  temperature = (temp*referencevoltage*100)/1023 - 4;
-  light = analogRead(A4);
-  delay(100);
+
+  delay(500);
 }

-void command(int n)
+void command(int n, float temperature)
 {
   switch(n)
   {


Clean up

Clean up

--- module/module.ino
+++ module/module.ino
@@ -281,7 +281,7 @@
 	There are slight deviations at times, so summing the values together
 	and using the maximum possible sum as a check is a reliable way to
 	determine if a signal is valid.
-*/
+
 int inRange(unsigned long periodX, unsigned long periodY) {
 	unsigned int sum = periodX + periodY;

@@ -292,12 +292,14 @@
 		return 0;
 	}
 }
+*/
 /*
 	Calculate time elapsed in seconds.
-*/
+
 unsigned long calculateTime(unsigned long startTime) {
 	return (millis() - startTime)/1000;
 }
+*/
 /*
 	This will play 3 rapid notes or 1 long note.
 */


Lengthen delay of car system power-off

Lengthen delay of car system power-off

The delay was originally only 3 seconds for testing and demonstration;
however, in practicality, it should be 5+ minutes long.

--- arduino/src/car_system/car_system.ino
+++ arduino/src/car_system/car_system.ino
@@ -93,7 +93,12 @@
   // Power on/off
   if(!powerOn) {
     digitalWrite(pinPowerLED, LOW);
-    delay(3 * 1000);  // 3 seconds in addition to the 3 second delay
+
+    // 5 minutes
+    // 60 seconds per minute
+    // 1000 milliseconds per second
+    delay(5 * 60 * 1000);
+
     powerOn = true;
   }
   else {


Use Pro Micro pins instead of Duemilanove pins

--- avr/avr.ino
+++ avr/avr.ino
@@ -58,9 +58,9 @@
 int pwm_i = 0; // Current PWM cycle

 // Hardware configuration
-uint8_t pin_col[] = {6, 7, A0, A1, A2, A3, A4, A5};
-#define PIN_ROW_LATCH 4
-#define PIN_COL_LATCH 5
+uint8_t pin_col[] = {5, A0, 4, A1, 3, A2, 2, A3};
+#define PIN_ROW_LATCH 6
+#define PIN_COL_LATCH 8

 // Serial access
 unsigned int byte_i;


Consumption refactored and ready to test

--- MID/MID.ino
+++ MID/MID.ino
@@ -114,35 +114,15 @@
 #ifdef LPG_SWITCHING_DETECT
     lpgCom.begin();
 #endif
-
-
     //
     // Light lamps test
     pinMode(A12, INPUT_PULLUP);
     pinMode(A13, INPUT_PULLUP);
 }

-//void loop() {
-//    u8g2.firstPage();
-//    u8g2.enableUTF8Print();
-//    do {
-//        u8g2.setFont(u8g2_opel_font_bold);
-//        u8g2.setCursor(120, 10);
-//        u8g2.print(F("Testing"));    /* Hello World */
-//        u8g2.setCursor(120, 30);
-//        u8g2.print(F("Тестово"));    /* Hello World */
-//
-//    } while (u8g2.nextPage());
-//    delay(1000);
-//}

 void loop() {
-
-
-
-//    if (ampInt.is5Seconds())
-//        analogWrite(STT_OIL_PIN, 0);
     //
     // Amplitude loop init
     ampInt.listener();
@@ -155,7 +135,6 @@
     //
     // Reads buttons from steering
     whlSens.listener();
-
     //
     // Listener shutdown
     shutDown.listener();
@@ -170,45 +149,12 @@
     shutDown.cursor();
     //
     // Listen state pins
-    carStat.listener();
-
-//
-//    if(ampInt.isSens()){
-//        Serial.print("RPM: ");
-//        Serial.println(carSens.getRpm());
-//    }
+    carStat.listener();D
     //
     // Listen LPG fuel system from serial com
 #ifdef ADT_FUEL_SYSTEM_SERIAL
     lpgCom.listener();
     carSens.setFuelListener(&lpgCom);
-//
-
-
-    if (ampInt.isSecond()) {
-//        Serial.print("LPG ");
-//        Serial.println(eepRom.getAdtFuel());
-//        Serial.print(F("VSS: "));
-//        Serial.print(carSens.getVss());
-//        whlSens.getCurrentState();
-//        Serial.println();
-//        Serial.print(F("LEN: "));
-//        Serial.print(vssPulseLen);
-//        Serial.println();
-
-
-        //
-        // 5 - 70C
-//        Serial.print(F("ENT: "));
-//        Serial.println(analogRead(ENG_CLT_PIN));
-
-
-//        Serial.print(F("PEC: "));
-//        Serial.println(carSens.getPec());
-
-    }
-
-
     //
     // set usage of LPG system without the switching listener
 #elif defined(LPG_INSTALLATION)
@@ -224,25 +170,13 @@
     // ttd=<0000> INJECTS: Total distance
     // lpg=<0000> INJECTS: lpg consumption
     // bnz=<0000> INJECTS: bnz consumption
-//    dbgSerial.listener();
     eepRom.listener();

-//
-//    if (stringComplete) {
-//        Serial.print("Serial Event: ");
-//        for (int i = 0; i < lengthSerial2Data; ++i) {
-//            Serial.println(inputSerial2Data[i]);
-//            inputSerial2Data[i] = 0;
-//        }
-//
-//        Serial.println(inputSerial2String);
-//        inputSerial2String = "";
-//        // clear the data:
-//        lengthSerial2Data = 0;
-//        stringComplete = false;
-//    }

+    if (ampInt.isSecond()) {
+
+    }

 }


add Gemtek Lora verify sample

add Gemtek Lora verify sample

--- Device_Ameba/Example/GemtekLoRa/GemtekLoRa.ino
+++ Device_Ameba/Example/GemtekLoRa/GemtekLoRa.ino
@@ -8,7 +8,7 @@

 	History:
-	0.1.00  by Hu-Cheng, Lee (Jack, jack77121@gmail.com)  12/04/2016
+	0.1.00  by Hu-Cheng Lee (Jack, jack77121@gmail.com)  12/04/2016
 */

 #include <SoftwareSerial.h>


change rest to no aeration and change normal sequence slightly

--- SBR/SBR.ino
+++ SBR/SBR.ino
@@ -84,9 +84,6 @@

 void fill(int lvl, int airadd){//check depth and fill until level is 25gal plus stir
-  if (lvl<19){
-    digitalWrite(stir, HIGH);
-  }
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("FILL ");
@@ -115,6 +112,7 @@
   lcd.print("FILL ");
   lcd.setBacklight(TEAL);
   measurevol();
+  digitalWrite(air,LOW);
   lcd.setCursor(0,1);
   lcd.print(tank);lcd.print("gal");
   DateTime now = rtc.now();
@@ -128,7 +126,6 @@
       measurevol();
       lcd.setCursor(0,1);
       lcd.print(tank);lcd.print("gal");
-      //digitalWrite(air,LOW);
       if ((airadd == 1) && (millis()-lastair > 300000)){
        digitalWrite(air,HIGH);
        lastair = millis();
@@ -341,17 +338,20 @@
   digitalWrite(en1, HIGH);
 }
 }
-void weekend(){
-  aeration(15, 4);
-  rest(43);
+void weekend(){//in reality would do some aeration if system was idle for 24hrs
+  rest(5);
 }
 void normalsequence(){//10 hrs
   DateTime now = rtc.now();
   realstarttime = now.unixtime();
-  fillplusair(21,1);
+  fillplusair(21,0);
   now = rtc.now();
   delay(2000);
-  thirtysecaeration(60, 19);
+  aeration(.25,19);
+  delay(1000);
+  rest(30);
+  delay(2000);
+  thirtysecaeration(30, 19);
   delay(2000);
   aeration(60,19);
   delay(2000);


fix a var name

fix a var name

--- photon-firmware/nesnet.ino
+++ photon-firmware/nesnet.ino
@@ -33,7 +33,7 @@
 volatile unsigned long lastLoadBearingLatch = 0;
 volatile unsigned long experiment;
 volatile unsigned long a, b;
-volatile bool dongs = 0;
+volatile bool hasFormattedData = 0;
 volatile bool hasByteLatched = 0;
 volatile unsigned char repeatCount = 0;
 HttpClient http;
@@ -67,7 +67,7 @@
     receivingData = 0;
     hasByteLatched = 0;

-    dongs = 0;
+    hasFormattedData = 0;

     static int i;
     for (i = 0; i < 100; i++)
@@ -118,7 +118,7 @@

     }
-    if (finishedReceivingData && !dongs) {
+    if (finishedReceivingData && !hasFormattedData) {
         if (strcmp(receivedBytes, "/test") == 0) {
             tweetData[0] = 255;
             tweetData[1] = 'W';
@@ -128,7 +128,7 @@
             for (int i = 0; i < 7; i++) {
                 tweetData[5+i] = "TEST OK"[i];
             }
-            dongs = true;
+            hasFormattedData = true;
         } else {
             GetNetResponse();
             // Skip the first null byte
@@ -141,7 +141,7 @@
             // Response code
             tweetData[7] = response.status & 0xff;
             tweetData[8] = (unsigned char)((response.status>>8)+1) & 0xff; // HACK: Add 1 to the high byte so that it is never 0. (= null; confuses us + the driver)
-            dongs = true;
+            hasFormattedData = true;
         }

@@ -235,7 +235,7 @@
             lastLoadBearingLatch = micros();
         }

-    } else if (dongs) {
+    } else if (hasFormattedData) {
         readyToSendBytes = true;
         if (byteCount > 7 && tweetData[byteCount] == '\0') {
             latchedByte = 0xff;


Update Serial_Bridge_mDNS_websocket.ino

Update Serial_Bridge_mDNS_websocket.ino

--- src/libraries/arduino/Serial_Bridge_mDNS_websocket.ino
+++ src/libraries/arduino/Serial_Bridge_mDNS_websocket.ino
@@ -368,7 +368,7 @@
   if (config) ESP.reset();
 }

-int write_EEPROM(int address, String &s){
+int write_EEPROM(int address, const String &s){
     for(int i=0; i < s.length(); i++) {
        EEPROM.write(address++, s.charAt(i));
     }


Invert low and high

Invert low and high

--- arduino.ino
+++ arduino.ino
@@ -26,11 +26,11 @@
   Serial.begin(9600);
   // We init the in/out pins
   pinMode(PIN_POWER, OUTPUT);
-  digitalWrite(PIN_POWER, LOW);
+  digitalWrite(PIN_POWER, HIGH);
   pinMode(PIN_MAKE_SHORT, OUTPUT);
-  digitalWrite(PIN_MAKE_SHORT, LOW);
+  digitalWrite(PIN_MAKE_SHORT, HIGH);
   pinMode(PIN_MAKE_LONG, OUTPUT);
-  digitalWrite(PIN_MAKE_LONG, LOW);
+  digitalWrite(PIN_MAKE_LONG, HIGH);
   pinMode(PIN_ORDER_SHORT, INPUT);
   pinMode(PIN_ORDER_LONG, INPUT);
 }
@@ -40,20 +40,20 @@
   is_long_ordered = digitalRead(PIN_ORDER_LONG);
   if(is_short_ordered || is_long_ordered) {
     Serial.println("Powering the Senseo machine");
-    digitalWrite(PIN_POWER, HIGH);
+    digitalWrite(PIN_POWER, LOW);
     delay(PUSH_BTN_DELAY);
-    digitalWrite(PIN_POWER, LOW);
+    digitalWrite(PIN_POWER, HIGH);
     delay(10000);
     if(is_short_ordered) {
       Serial.println("Start a short coffee");
+      digitalWrite(PIN_MAKE_SHORT, LOW);
+      delay(PUSH_BTN_DELAY);
       digitalWrite(PIN_MAKE_SHORT, HIGH);
-      delay(PUSH_BTN_DELAY);
-      digitalWrite(PIN_MAKE_SHORT, LOW);
     } else {
       Serial.println("Start a long coffeee");
+      digitalWrite(PIN_MAKE_LONG, LOW);
+      delay(PUSH_BTN_DELAY);
       digitalWrite(PIN_MAKE_LONG, HIGH);
-      delay(PUSH_BTN_DELAY);
-      digitalWrite(PIN_MAKE_LONG, LOW);
     }
     Serial.println("Wait for the coffee to be ready");
     delay(30000);


Add external EEPROM & New Setup

Add external EEPROM & New Setup

--- arduino.ino
+++ arduino.ino
@@ -4,10 +4,11 @@
 #include "SPI.h"

 // MANUAL SETUP
-#define EEPROM_SIZE 1024  // EEPROM Max Size.
-#define INDICATOR_LED 13  // Main LED Indicator.
-#define DEBUG_SWITCH 4    // Toggle Switch Digital Pin.
-#define SAMPLING 1       // Samples Per Second.
+#define INTERNAL_EEPROM_SIZE 1024   // Internal EEPROM Max Size.
+#define EXTERNAL_EEPROM_SIZE 64000  // EEPROM Max Size.
+#define INDICATOR_LED 13            // Main LED Indicator.
+#define DEBUG_SWITCH 6              // Toggle Switch Digital Pin.
+#define SAMPLING 3                  // Samples Per Second.

 // DON'T TOUCH IN THE CODE BELOW
 BME280 barometer;
@@ -93,7 +94,7 @@
   barometer.begin();
   delay(50);

-  pinMode(DEBUG_SWITCH, INPUT);
+  pinMode(DEBUG_SWITCH, INPUT_PULLUP);
   pinMode(INDICATOR_LED, OUTPUT);

   EEPROM.get(EEPROM_SIZE-4, entriesCounter);


pins changed for another arduino clone board

--- PaperTapePuncher.ino
+++ PaperTapePuncher.ino
@@ -16,8 +16,10 @@
 #define PinBit6 7
 #define PinBit7 8
 #define PinTransportHole 9
-#define PinTransportMotor 11
-#define PinStepSensor 12
+//#define PinTransportMotor 11
+#define PinTransportMotor 16
+//#define PinStepSensor 12
+#define PinStepSensor 14

 #define highTime 2
 #define lowTime 18


Delete ArduinoLED.ino

Delete ArduinoLED.ino

--- files/ArduinoLED.ino
+++ files/ArduinoLED.ino
@@ -1,162 +0,0 @@
-#include <nRF24L01.h>
-#include <printf.h>
-#include <RF24.h>
-#include <RF24_config.h>
-
-
-/*
-* Getting Started example sketch for nRF24L01+ radios
-* This is a very basic example of how to send data from one node to another
-* Updated: Dec 2014 by TMRh20
-*/
-
-#include <SPI.h>
-#include "RF24.h"
-
-
-#define LED_GREEN 3
-#define LED_RED 4
-
-/****************** User Config ***************************/
-/***      Set this radio as radio number 0 or 1         ***/
-bool radioNumber = 0;
-
-/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
-RF24 radio(9,10);
-/**********************************************************/
-
-byte addresses[][6] = {"1Node","2Node"};
-
-// Used to control whether this node is sending or receiving
-bool role = 0;
-
-void setup() {
-
-    pinMode(LED_GREEN, OUTPUT);
-    pinMode(LED_RED, OUTPUT);
-
-    Serial.begin(115200);
-    Serial.println(F("RF24/examples/GettingStarted"));
-    Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));
-
-    radio.begin();
-
-    // Set the PA Level low to prevent power supply related issues since this is a
-    // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
-    radio.setPALevel(RF24_PA_LOW);
-
-    // Open a writing and reading pipe on each radio, with opposite addresses
-    if(radioNumber){
-      radio.openWritingPipe(addresses[1]);
-      radio.openReadingPipe(1,addresses[0]);
-    }else{
-      radio.openWritingPipe(addresses[0]);
-      radio.openReadingPipe(1,addresses[1]);
-    }
-
-    // Start the radio listening for data
-    radio.startListening();
-}
-
-void loop() {
-
-
-/****************** Ping Out Role ***************************/
-if (role == 1)  {
-
-    radio.stopListening();                                    // First, stop listening so we can talk.
-
-
-    Serial.println(F("Now sending"));
-
-    unsigned long start_time = micros();                             // Take the time, and send it.  This will block until complete
-
-    if (!radio.write( &start_time, sizeof(unsigned long) ))
-    {
-      Serial.println(F("failed"));
-    }
-
-    radio.startListening();                                    // Now, continue listening
-
-    unsigned long started_waiting_at = micros();               // Set up a timeout period, get the current microseconds
-    boolean timeout = false;                                   // Set up a variable to indicate if a response was received or not
-
-    while ( ! radio.available() ){                             // While nothing is received
-      if (micros() - started_waiting_at > 200000 ){            // If waited longer than 200ms, indicate timeout and exit while loop
-          timeout = true;
-          break;
-      }
-    }
-
-    if ( timeout ){                                             // Describe the results
-        Serial.println(F("Failed, response timed out."));
-
-        digitalWrite(LED_RED, LOW);
-    }else{
-         digitalWrite(LED_GREEN, HIGH);
-
-        unsigned long got_time;                                 // Grab the response, compare, and send to debugging spew
-        radio.read( &got_time, sizeof(unsigned long) );
-        unsigned long end_time = micros();
-
-        // Spew it
-        Serial.print(F("ID Sent: "));
-        Serial.print(start_time);
-        Serial.print(F("ID_Received: "));
-        Serial.print(got_time);
-        //Serial.print(F(", Round-trip delay "));
-        //Serial.print(end_time-start_time);
-        //Serial.println(F(" microseconds"));
-        Serial.printf(F("\nSuccess\n"));
-    }
-
-    // Try again 1s later
-    delay(1000);
-  }
-
-
-
-/****************** Pong Back Role ***************************/
-
-  if ( role == 0 )
-  {
-    unsigned long got_time;
-
-    if( radio.available()){
-                                                                    // Variable for the received timestamp
-      while (radio.available()) {                                   // While there is data ready
-        radio.read( &got_time, sizeof(unsigned long) );             // Get the payload
-      }
-
-      radio.stopListening();                                        // First, stop listening so we can talk
-      radio.write( &got_time, sizeof(unsigned long) );              // Send the final one back.
-      radio.startListening();                                       // Now, resume listening so we catch the next packets.
-      Serial.print(F("Sent response "));
-      Serial.println(got_time);
-   }
- }
-
-
-
-
-/****************** Change Roles via Serial Commands ***************************/
-
-  if ( Serial.available() )
-  {
-    char c = toupper(Serial.read());
-    if ( c == 'T' && role == 0 ){
-      Serial.println(F("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK"));
-      role = 1;                  // Become the primary transmitter (ping out)
-
-   }else
-    if ( c == 'R' && role == 1 ){
-      Serial.println(F("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK"));
-       role = 0;                // Become the primary receiver (pong back)
-       radio.startListening();
-
-    }
-  }
-
-
-} // Loop
-


Update ShowLEDs.ino

Update ShowLEDs.ino


pinout compatible with uno

pinout compatible with uno

--- arduino/scetch/scetch.ino
+++ arduino/scetch/scetch.ino
@@ -1,11 +1,11 @@
-const byte adjPowerPin = 45;
-const byte latchPin = 37;
-const byte eePin = 35;
-const byte emPin = 33;
-const byte prrPin = 31;
+const byte adjPowerPin = 3;
+const byte latchPin = 4;
+const byte eePin = 5;
+const byte emPin = 6;
+const byte prrPin = 7;
 const byte buttonPin = A0;
 const byte ledPin = 13;
-const byte guideLaserPin = 29;
+const byte guideLaserPin = 8;

 const byte powerLevel = 20;


couple of idiot checks

couple of idiot checks

--- intelli_fw/intelli_fw.ino
+++ intelli_fw/intelli_fw.ino
@@ -25,7 +25,8 @@
   //Our button int handler
   pinMode(BUTTON_PIN, INPUT_PULLUP);
 #ifndef TEST_MODE
-  //attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), pin_change_isr, CHANGE);
+//disable during testing - primarily because we have no button attached
+  attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), pin_change_isr, CHANGE);
 #endif

   //Make sure our application data is in the right state
@@ -101,6 +102,7 @@
     //We should tell the user the clock is not set as they will be able to set the clock with a button hold.
       //In test mode always sets the time
 #ifdef TEST_MODE
+  //when in test mode actaul set the real time and date
   rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
 #else
   lighting.show_error(ERROR_RTC_FAIL);


fix WebUpload example

fix WebUpload example

--- hardware/esp8266com/esp8266/libraries/ESP8266WebServer/examples/WebUpdate/WebUpdate.ino
+++ hardware/esp8266com/esp8266/libraries/ESP8266WebServer/examples/WebUpdate/WebUpdate.ino
@@ -30,15 +30,13 @@
         Serial.setDebugOutput(true);
         WiFiUDP::stopAll();
         Serial.printf("Update: %s\n", upload.filename.c_str());
-        uint32_t maxSketchSpace = ((ESP.getFreeSketchSpace() + ESP.getSketchSize()) / 2) & 0xFFFFF000;
+        uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
         if(!Update.begin(maxSketchSpace)){//start with max available size
           Update.printError(Serial);
-          return;
         }
       } else if(upload.status == UPLOAD_FILE_WRITE){
         if(Update.write(upload.buf, upload.currentSize) != upload.currentSize){
           Update.printError(Serial);
-          return;
         }
       } else if(upload.status == UPLOAD_FILE_END){
         if(Update.end(true)){ //true to set the size to the current progress
@@ -59,7 +57,7 @@
     server.begin();
     MDNS.addService("http", "tcp", 80);

-    Serial.println("Ready! Open http:\/\/%s.local in your browser\n", host);
+    Serial.printf("Ready! Open http://%s.local in your browser\n", host);
   } else {
     Serial.println("WiFi Failed");
   }


Updates to gateway control

Updates to gateway control

--- src/gateway/gateway.ino
+++ src/gateway/gateway.ino
@@ -0,0 +1,28 @@
+#include <RFM69.h>
+#include <SPI.h>
+#include "radioNode.h"
+
+RFM69 radio;
+byte ackCount=0;
+uint32_t packetCount = 0;
+
+void setup()
+{
+  Serial.begin(SERIAL_BAUD);
+  delay(10);
+  RadioNode::setupRadio();
+  radio = RadioNode::getRadio();
+}
+
+void loop()
+{
+  // check for new wireless data
+  // open connection to mqtt
+  // send data to mqtt
+  char input = Serial.read();
+  if (Serial.available() > 0)
+    RadioNode::executeCommand(input);
+  if (radio.receiveDone())
+    char[RF69_MAX_DATA_LEN] value;
+    value = RadioNode::readRadio();
+}


added multi sensor functiionality

added multi sensor functiionality

--- project.ino
+++ project.ino
@@ -1,38 +1,60 @@
 #include <Adafruit_NeoPixel.h>
 #include <Servo.h>
 #include <avr/power.h>
+#include <NewPing.h>
+
+//Max and Min value for the distance sensor
+float maxDistance = 400;
+float minDistance = 10;
+
+//Define 3 distance sensors
+NewPing sonar1(11, 12, maxDistance); // Sensor 1: trigger pin, echo pin, maximum distance in cm
+NewPing sonar2(9, 10, maxDistance); // Sensor 2: trigger pin, echo pin, maximum distance in cm
+NewPing sonar3(7, 6, maxDistance); // Sensor 3: trigger pin, echo pin, maximum distance in cm
+
+#define pingSpeed 100 // Ping frequency (in milliseconds), fastest we should ping is about 35ms per sensor
+unsigned long pingTimer1, pingTimer2, pingTimer3;

 //Hardware constants
-#define PIN_STRIP 6
-#define PIN_SENSOR 7
-#define PIN_SERVO 8
+#define PIN_STRIP 5
+//#define PIN_SENSOR 7
+//#define PIN_SERVO 8

 #define NUMBER_LEDS 48
 #define NUMBER_STRIPS 3

+#define PIN_SWITCH 2
+
 Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMBER_LEDS, PIN_STRIP, NEO_GRB + NEO_KHZ800);
-Servo servo;
+//Servo servo;

 //Servo variables
-int servoPos = 0;
-int servoSteps = 6;
-int servoMinAngle = 0;
-int servoMaxAngle = 90;
-int servoStepAngle = (servoMaxAngle-servoMinAngle)/(servoSteps-1);
-int servoMSPerDegree = 5;
-
-//Max and Min value for the distance sensor
-float maxDistance = 500;
-float minDistance = 10;
+//int servoPos = 0;
+//int servoSteps = 6;
+//int servoMinAngle = 0;
+//int servoMaxAngle = 90;
+//int servoStepAngle = (servoMaxAngle-servoMinAngle)/(servoSteps-1);
+//int servoMSPerDegree = 5;

 //Store of the measured distances of each servo step
-int distanceValues[6];
+//int distanceValues[6];
+  int distanceValues[3];

 void setup() {
   //Init distance store to far away
-  for(int i=0; i<servoSteps; i+=1){
-    distanceValues[i] = 0;
-  }
+//  for(int i=0; i<servoSteps; i+=1){
+//    distanceValues[i] = 0;
+//  }
+  distanceValues[0] = 0;
+  distanceValues[1] = 0;
+  distanceValues[2] = 0;
+
+  pinMode(PIN_SWITCH, INPUT_PULLUP);           // set pin to input with internal pullup resistor
+
+  //
+  pingTimer1 = millis() + pingSpeed; // Sensor 1 fires after 100ms (pingSpeed)
+  pingTimer2 = pingTimer1 + (pingSpeed / 2); // Sensor 2 fires 50ms later
+  pingTimer3 = pingTimer2 + (pingSpeed / 2); // Sensor 3 fires 50ms later

   //For console output
   Serial.begin(9600);
@@ -44,9 +66,9 @@

   //Set servo to init position
   //And wait for the servo reaching the position
-  servo.attach(PIN_SERVO);
-  servo.write(servoPos);
-  delay(5*360);
+//  servo.attach(PIN_SERVO);
+//  servo.write(servoPos);
+//  delay(5*360);
 }

 /**
@@ -56,35 +78,69 @@
  *
  */
 void loop(){
-  int i = 0;
-  for(servoPos = servoMinAngle; servoPos < servoMaxAngle; servoPos += servoStepAngle){
-    readSensorWriteLEDs(servoPos, i);
-    i+=1;
-  }
-
-  for(servoPos = servoMaxAngle; servoPos>servoMinAngle; servoPos-=servoStepAngle)
-  {
-    readSensorWriteLEDs(servoPos, i);
-    i-=1;
+//  int i = 0;
+//  for(servoPos = servoMinAngle; servoPos < servoMaxAngle; servoPos += servoStepAngle){
+//    readSensorWriteLEDs(servoPos, i);
+//    i+=1;
+//  }
+//
+//  for(servoPos = servoMaxAngle; servoPos>servoMinAngle; servoPos-=servoStepAngle)
+//  {
+//    readSensorWriteLEDs(servoPos, i);
+//    i-=1;
+//  }
+   if (millis() >= pingTimer1) {
+   pingTimer1 += pingSpeed; // Make sensor 1 fire again 100ms later (pingSpeed)
+   distanceValues[0] = sonar1.ping_cm();
+   Serial.print("Ping 1: ");
+   Serial.print(distanceValues[0]); // Convert ping time to distance and print result (0 = outside set distance range, no ping echo)
+   Serial.println("cm");
+
+ }
+ if (millis() >= pingTimer2) {
+   pingTimer2 = pingTimer1 + (pingSpeed / 2); // Make sensor 2 fire again 50ms after sensor 1 fires
+   distanceValues[1] = sonar2.ping_cm();
+   // Both sensors pinged, process results here
+   Serial.print("Ping 2: ");
+   Serial.print(distanceValues[1]); // Convert ping time to distance and print result (0 = outside set distance range, no ping echo)
+   Serial.println("cm");
+ }
+ if (millis() >= pingTimer3) {
+   pingTimer3 = pingTimer2 + (pingSpeed / 2); // Make sensor 2 fire again 50ms after sensor 1 fires
+   distanceValues[2] = sonar3.ping_cm();
+   // All three sensors pinged, process results here
+   Serial.print("Ping 3: ");
+   Serial.print(distanceValues[2]); // Convert ping time to distance and print result (0 = outside set distance range, no ping echo)
+   Serial.println("cm");
+
+   Serial.println("PIN_SWITCH: ");
+   Serial.println(digitalRead(PIN_SWITCH));
+
+   if(digitalRead(PIN_SWITCH)) {
+      visualizeWithDirection();
+    }
+    else {
+      visualizeLinear();
+    }
   }
 }

-void readSensorWriteLEDs(int servoPosition, int i){
-  servo.write(servoPosition);
-  delay(servoMSPerDegree*servoStepAngle);
-
-  triggerSensor();
-  int distance = readSensor();
-  printDistance(distance);
-
-  distance = max(minDistance, distance);
-  distance = min(maxDistance, distance);
-  distanceValues[i] = distance;
-
-  visualizeWithDirection();
-
-  delay(35);
-}
+//void readSensorWriteLEDs(int servoPosition, int i){
+//  servo.write(servoPosition);
+//  delay(servoMSPerDegree*servoStepAngle);
+//
+//  triggerSensor();
+//  int distance = readSensor();
+//  printDistance(distance);
+//
+//  distance = max(minDistance, distance);
+//  distance = min(maxDistance, distance);
+//  distanceValues[i] = distance;
+//
+//  visualizeWithDirection();
+//
+//  delay(35);
+//}

 /**
@@ -108,8 +164,17 @@

     //to get the with 1,2,3 the needed indices we use i*2 and i*2+1
     //0 = 0,1 / 1 = 2,3 / 2 = 4,5
-    int distance = (distanceValues[i*2] + distanceValues[i*2+1]) / 2;
-    Serial.println(distance);
+    //int distance = (distanceValues[i*2] + distanceValues[i*2+1]) / 2;
+    int distance = distanceValues[i];
+    if(distance < minDistance) {
+      if(distance == 0) {
+        distance = maxDistance;
+      }
+      else {
+        distance = minDistance;
+      }
+    }
+    //Serial.println(distance);
     int heightStrip = NUMBER_LEDS/NUMBER_STRIPS;

     //how many of the leds of one strip should be switched on
@@ -164,7 +229,16 @@

     //to get the with 1,2,3 the needed indices we use i*2 and i*2+1
     //0 = 0,1 / 1 = 2,3 / 2 = 4,5
-    int distance = (distanceValues[i*2] + distanceValues[i*2+1]) / 2;
+    //int distance = (distanceValues[i*2] + distanceValues[i*2+1]) / 2;
+    int distance = distanceValues[i];
+    if(distance < minDistance) {
+      if(distance == 0) {
+        distance = maxDistance;
+      }
+      else {
+        distance = minDistance;
+      }
+    }
     int heightStrip = NUMBER_LEDS/NUMBER_STRIPS;

     //how many of the leds of one strip should be switched on
@@ -211,27 +285,27 @@
  *
  **/

-long readSensor(){
-  // The same pin is used to read the signal from the PING))): a HIGH
-  // pulse whose duration is the time (in microseconds) from the sending
-  // of the ping to the reception of its echo off of an object.
-  pinMode(PIN_SENSOR, INPUT);
-  long duration = pulseIn(PIN_SENSOR, HIGH);
-
-  // convert the time into a distance
-  return microsecondsToCentimeters(duration);
-}
-
-void triggerSensor(){
-  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
-  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
-  pinMode(PIN_SENSOR, OUTPUT);
-  digitalWrite(PIN_SENSOR, LOW);
-  delayMicroseconds(2);
-  digitalWrite(PIN_SENSOR, HIGH);
-  delayMicroseconds(5);
-  digitalWrite(PIN_SENSOR, LOW);
-}
+//long readSensor(){
+//  // The same pin is used to read the signal from the PING))): a HIGH
+//  // pulse whose duration is the time (in microseconds) from the sending
+//  // of the ping to the reception of its echo off of an object.
+//  pinMode(PIN_SENSOR, INPUT);
+//  long duration = pulseIn(PIN_SENSOR, HIGH);
+//
+//  // convert the time into a distance
+//  return microsecondsToCentimeters(duration);
+//}
+
+//void triggerSensor(){
+//  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
+//  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
+//  pinMode(PIN_SENSOR, OUTPUT);
+//  digitalWrite(PIN_SENSOR, LOW);
+//  delayMicroseconds(2);
+//  digitalWrite(PIN_SENSOR, HIGH);
+//  delayMicroseconds(5);
+//  digitalWrite(PIN_SENSOR, LOW);
+//}

 /**
  *
@@ -239,26 +313,26 @@
  *
  **/

-void printDistance(int distance){
-  Serial.print(distance);
-  Serial.print(" cm");
-  Serial.println();
-}
-
-void printDistanceValues(){
-  for(int i=0; i<servoSteps; i++){
-    Serial.print(distanceValues[i]);
-    Serial.print(" ");
-  }
-  Serial.println();
-}
+//void printDistance(int distance){
+//  Serial.print(distance);
+//  Serial.print(" cm");
+//  Serial.println();
+//}
+//
+//void printDistanceValues(){
+//  for(int i=0; i<servoSteps; i++){
+//    Serial.print(distanceValues[i]);
+//    Serial.print(" ");
+//  }
+//  Serial.println();
+//}

-int microsecondsToCentimeters(long microseconds)
-{
-  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
-  // The ping travels out and back, so to find the distance of the
-  // object we take half of the distance travelled.
-  return microseconds / 29 / 2;
-}
-
-
+//int microsecondsToCentimeters(long microseconds)
+//{
+//  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
+//  // The ping travels out and back, so to find the distance of the
+//  // object we take half of the distance travelled.
+//  return microseconds / 29 / 2;
+//}
+
+


Include to allow parsing of JSON

Include to allow parsing of JSON

--- ESPert/examples/_0130_MQTT_Button/_0130_MQTT_Button.ino
+++ ESPert/examples/_0130_MQTT_Button/_0130_MQTT_Button.ino
@@ -2,6 +2,7 @@
 #include <ESP8266WebServer.h>
 #include <ESP8266mDNS.h>
 #include <ESPert.h>
+#include <ArduinoJSON.h>

 ESPert espert;


layout

layout

--- src/Arduino/_23cm-trx/PLL.ino
+++ src/Arduino/_23cm-trx/PLL.ino
@@ -1,9 +1,7 @@
 /*
  * Routines for setting the PLL frequency.
  *
- * The PLL is working as follows:
- *
- * fvco = (P*B + A)*REFin/R
+ * The PLL is working as follows:  fvco = (P*B + A)*REFin/R
  *
  * where
  *  fvco = output frequency of external voltage controlled oscillator (VCO).
@@ -14,19 +12,16 @@
  *     R = preset divide ratio of binary 14-bit programmable reference counter (1 to 16,383).
  *         The devide ratio is chosen to match the step/raster size e.g 25000, but this is arbitrary.
  *
- * If P = 16, and R = 25000, we need to do two calculations to get B and A from fvco:
- *
+ * If P and R are known, we need to do the following calculations to get B and A from fvco:
  * B = (fvco/R) / P (note: int, so truncated at decimal point)
  * A = (fvco/R) % P (the remainer to do without prescaler P)
  *
- * If we want fvco to be 1298.375 MHz, we need to set A and B to:
- *
+ * To set fvco to 1298.375 MHz, having P = 16 and R = 25000 we need to set A and B to:
  * B = (1298375000 / 25000) / 16 = 3245
  * A = (1298375000 / 25000) % 16 = 15
- *
  */

-#define LE       PC2
+#define LE        PC2
 #define DATA      PC1
 #define CLK       PC0


Lowered baudrate andadded notes on speed

--- Contrib/xopr/SPI_slave/SPI_slave.ino
+++ Contrib/xopr/SPI_slave/SPI_slave.ino
@@ -18,7 +18,13 @@

 void setup (void)
 {
-  Serial.begin( 9600 );
+  // Note: The Atmega16u2 uses U2X mode, where 300 baud isn't possible
+  // CH340G has a minimum of 2400 baud
+  // https://github.com/arduino/ArduinoCore-avr/issues/265
+  // Fetch updated firmware from: https://github.com/facchinm/Arduino_avrusb_firmware/tree/master/arduino-usbserial
+  // https://www.arduino.cc/en/Hacking/DFUProgramming8U2
+  // see https://forum.arduino.cc/index.php?topic=385567.0
+  Serial.begin( 300 );

   // have to send on master in, *slave out*
   pinMode(MISO, OUTPUT);


stop leaving test values in the code

stop leaving test values in the code

--- Pingduino/Pingduino.ino
+++ Pingduino/Pingduino.ino
@@ -9,7 +9,7 @@
 #define P1PIN           2
 #define P2PIN           3
 #define LONGPRESS_TIME  1000
-#define INACTIVEMILLIS  10000 // 1200000 // 20 minutes
+#define INACTIVEMILLIS  1200000 // 20 minutes

 // Game Logics
 volatile int p1Score = 0;


TODO-721: gone all quiet!

TODO-721: gone all quiet!

--- Arduino/V0p2_Main/V0p2_Main.ino
+++ Arduino/V0p2_Main/V0p2_Main.ino
@@ -184,15 +184,15 @@
   // FS20/FHT8V compatible channel 1 full config, used for TX only, not secure, unframed.
   OTRadioLink::OTRadioChannelConfig(OTRFM23BLink::StandardRegSettingsOOK5000, true, false, true, false, false, true),
   };
-//#elif defined(ENABLE_FAST_FRAMED_CARRIER_SUPPORT)
-//#define RADIO_CONFIG_NAME "GFSK ONLY"
-//// Nodes talking on fast GFSK channel 0.
-//static const uint8_t nPrimaryRadioChannels = 1;
-//static const OTRadioLink::OTRadioChannelConfig RFM23BConfigs[nPrimaryRadioChannels] =
-//  {
-//  // GFSK channel 0 full config, RX/TX, not in itself secure.
-//  OTRadioLink::OTRadioChannelConfig(OTRFM23BLink::StandardRegSettingsGFSK57600, true),
-//  };
+#elif defined(ENABLE_FAST_FRAMED_CARRIER_SUPPORT)
+#define RADIO_CONFIG_NAME "GFSK ONLY"
+// Nodes talking on fast GFSK channel 0.
+static const uint8_t nPrimaryRadioChannels = 1;
+static const OTRadioLink::OTRadioChannelConfig RFM23BConfigs[nPrimaryRadioChannels] =
+  {
+  // GFSK channel 0 full config, RX/TX, not in itself secure.
+  OTRadioLink::OTRadioChannelConfig(OTRFM23BLink::StandardRegSettingsGFSK57600, true),
+  };
 #else // !defined(ALLOW_CC1_SUPPORT) && !defined(ENABLE_FAST_FRAMED_CARRIER_SUPPORT)
 #define RADIO_CONFIG_NAME "OOK"
 // Nodes talking (including to to FHT8V) on slow OOK.


Clean up.

Clean up.

--- examples/Blink/CosaBlinkThread/CosaBlinkThread.ino
+++ examples/Blink/CosaBlinkThread/CosaBlinkThread.ino
@@ -53,7 +53,7 @@
 }

 // This class is a thread that periodically changes a LED delay
-// from low to high with a given incremment.
+// from low to high with a given increment
 template <uint16_t LOW, uint16_t HIGH, uint16_t INC, uint16_t PERIOD>
 class Controller : public Nucleo::Thread {
 private: