Delete Slave-Board.ino

Delete Slave-Board.ino

--- Firmware/Ball/Slave-Board/Slave-Board.ino
+++ Firmware/Ball/Slave-Board/Slave-Board.ino
@@ -1,616 +0,0 @@
-String version = "0.1.3";
-/*
-
- >      FIRMWARE ONLY FOR AN ARDUINO NANO !!    <
- > IF YOU USE ANOTHER ARDUINO, ADAPT THE PINOUT <
-
- ###################################################
-  ______  ______     _     _ ______  _____ _______
- (____  \(____  \   | |   | |  ___ \(_____|_______)
-  ____)  )____)  )__| |   | | |   | | | |    | |
- |  __  (|  __  (___) |   | | |   | | | |    | |
- | |__)  ) |__)  )  | |___| | |   | |_| |_   | |
- |______/|______/    \______|_|   |_(_____)  |_|
-    A open source project for create you own BB-8!
- ###################################################
-
- https://github.com/Gruniek/BB-UNIT
- Made by Daniel M/Gruniek/MOUS
-
- Compatible only with an Arduino Nano and the specific PCB.
- PCB Link : https://github.com/Gruniek/BB-UNIT/tree/master/Head/Stabiliser/PCB
-
- --------------
- - Change log -
- --------------
-
- 11/2016
- =========
- - FIX alls bug foe stabilisation
- - ADD BOOT, STAT, ROTATE command
- - ADD Z motor configuration and production
- - ADD BOOT mode, for initilize or reinizialize the Droid position
-
- 10/2016
- ==========
- - Add PID for X and Y
-
-
- To do list
- ==========
- - Add Z rotation controller
- - Add Rx/Tx from the motherboard for change de coordinate of the head,
-  rotate the head and report to the remote the status off all sensors/positiom.
-
-
-  Big thanks for http://r2builders.fr/ !
-  Initial project : http://r2builders.fr/forum/viewtopic.php?f=26&t=3928&hilit=BB8+par+MOUS
-
-  ===============
-  EXEMPLE COMMAND
-  ===============
-  < SET >
-  'SET x87 y75 h3 \n'        // SET a new setpoint for x and y with 3degree of Hysteressis
-  'SET x90 y90 i1 j0 k1 \n'  // SET an inversion of the sensor X Y and invert the direction of X
-
-  	x = SETPOINT for X
-	y = SETPOINT for Y
-	m = MULTIPLIER FOR THE SPEED OF THE MOTOR X and Y
-	i = INVERT the angle sensor ( X = Y and Y = X )
-	j = INVERT the direction of X
-	k = INVERT the direction of Y
-	h = SET a new HYSTERESSIS
-
-
-
-  < BOOT >
-  'BOOT \n'  // LAUNCH TEST for X, Y and Z -> Return X and Y to initial SETPOINT (x90 y90 ) and Z to ZERO
-
-
-
-  < RUN >
-  'RUN \n'   // RUN the code in production mode (Recieved all data, X and Y runing for the SETPOINT poistion and Z folow the remote controll
-
-  < STOP >
-  'STOP \n'  // STOP the production mode. All motors are stopped.
-
-
-  < ROTATE >
-  'ROTATE d1 s100 \n'   // ROTATE Z motor on the RIGHT DIRECTION (d0 LEFT, d1 RIGHT) WITH the SPEED at 1000/100 = 10 step/sec = 18dec/sec
-
-
-  < STAT >
-  // It is all data SENDED to the MASTER-BOARD
-
-*/
-
-#include "Wire.h"
-#include "MPU6050.h"
-
-
-
-// MOTOR CONFIGURATION // YOU CAN TOUCH THIS
-
-#define pinEnable        4      // Activation off all stepper
-
-#define pinStepX         3      // PIN STEP FOR X
-#define pinDirX          2      // PIN DIRECTION FOR X
-
-#define pinStepY         6      // PIN STEP FOR Y
-#define pinDirY          5      // PIN DIRECTION FOR Y
-
-#define pinStepZ         8      // PIN STEP FOR Y
-#define pinDirZ          7      // PIN DIRECTION FOR Y
-
-#define Z_POSITION       9      // PIN FOR THE DIGITAL INPUT FOR THE HEAD POSITION
-
-bool    invertX        = false; // INVERT THE X MOTOR DIRECTION
-bool    invertY        = true;  // INVERT THE Y MOTOR DIRECTION
-bool    invertXY       = false; // INVERT X Y AXIAL
-
-int     minX           = 45;    // SET THE MIN INCLINAISON FOR X
-int     maxX           = 135;   // SET THE MAX INCLINAISON FOR X
-int     minY           = 45;    // SET THE MIN INCLINAISON FOR Y
-int     maxY           = 135;   // SET THE MAX INCLINAISON FOR Y
-
-int     etalonX        = 0;     // AJUSTEMENT FOR X
-int     etalonY        = -6;    // AJUSTEMENT FOR Y
-
-int     hysteresis     = 1;     // HYSTERESSIS FOR THE ANGLE CALCULATION
-
-
-//=====================//
-// NOW YOU CAN'T TOUCH //
-//=====================//
-
-// MPU6050
-MPU6050 accelgyro;
-
-int16_t ax, ay, az;
-int16_t gx, gy, gz;
-
-// I2C
-int adress         = 2;
-int PING           = 13; // PIN
-int PING_MASTER    = 12;
-// VARIABLE
-int x              = 0;
-int y              = 0;
-int vx             = 0;
-int vy             = 0;
-
-int speedX         = 0;
-int speedY         = 0;
-int speedZ         = 0;
-int setpointX      = 90;
-int setpointY      = 90;
-
-int Zangle         = 0;
-
-
-int multiplier     = 15;
-int emergencyStop  = 11; // PIN
-int eStop          = 12; // PIN
-bool emgStop       = false;
-
-bool runX          = false;
-bool runY          = false;
-bool runZ          = false;
-bool directX       = false; // false = Gauche / true = droite
-bool directY       = false; // false = Gauche / true = droite
-bool directZ       = false; // false = Gauche / true = droite
-
-bool xok           = false;
-bool yok           = false;
-bool zok           = false;
-
-// PID
-unsigned long previousMillisX = 0;
-unsigned long previousMillisY = 0;
-unsigned long previousMillisZ = 0;
-
-long                    intX  = 0;
-long                    intY  = 0;
-
-
-unsigned long trigGyro = 100;
-unsigned long trigSec  = 1000;
-unsigned long trigG    = 0;
-unsigned long trigS    = 0;
-
-
-bool production = false;
-bool LED_PING   = false;
-bool BOOT = false;
-
-bool ifPing    = false;
-int tmpPing    = 0;
-int tmpPing2   = 0;
-int pingMaster = 0;
-
-//=============================================================================//
-//   SETUP
-//=============================================================================//
-void setup()
-{
-    pinMode( pinEnable   , OUTPUT );
-    pinMode( pinDirX     , OUTPUT );
-    pinMode( pinStepX    , OUTPUT );
-    pinMode( pinDirY     , OUTPUT );
-    pinMode( pinStepY    , OUTPUT );
-    pinMode( PING        , OUTPUT );
-    pinMode( PING_MASTER , INPUT  );
-    pinMode( Z_POSITION  , INPUT  );
-
-
-    Serial.begin(9600);
-
-    Serial.println(" ");
-    Serial.println("#######################################");
-    Serial.println("#         Astromech Industrie         #");
-    Serial.println("#                BB-UNIT              #");
-    Serial.println("# https://github.com/Gruniek/BB-UNIT/ #");
-    Serial.println("#######################################");
-    Serial.println(" ");
-    Serial.print("  BB-8 Version ");
-    Serial.println(version);
-    Serial.println("===================");
-    Serial.println(" ");
-
-    Serial.print("Initializing I2C devices...  I2C ADRESS :");
-    Serial.print(adress);
-    Wire.begin(adress);
-
-    accelgyro.initialize();
-    Serial.print("Connect to the MPU6050 : ");
-
-    Serial.println(accelgyro.testConnection() ? "Connection successful" : "Connection failed");
-
-    Serial.println("Booting successful !");
-    Serial.println("====================");
-
-
-}
-
-//=============================================================================//
-//   LOOP
-//=============================================================================//
-void loop()
-{
-    // GET MOTION
-    //-------------------------------------------------------------------------//
-    unsigned long currentG = millis(); // millis();
-
-    if (currentG - trigG  >= trigGyro)
-    {
-    	trigG = currentG;
-
-
-    	accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
-		if(invertXY)
-		{
-			y = (((ax/180)+etalonX)+90);
-  			x = (((ay/180)+etalonY)+90);
-		}
-		else
-		{
-			x = (((ax/180)+etalonX)+90);
-  			y = (((ay/180)+etalonY)+90);
-		}
-    }
-
-    // GET SERIAL DATA
-    //-------------------------------------------------------------------------//
-
-    char msg[30];
-    if (Serial.available() > 0)
-    {
-    	Serial.readBytesUntil('\n', msg, sizeof msg);
-
-    	if (strcmp(strtok(msg, " "), "SET") == 0)
-    	{
-        	Serial.println("UPDATE SETPOINT");
-      		// trouvé le message
-      		char *p;
-      		while ((p = strtok(NULL, " ")) != NULL)
-      		{
-        		int val = atoi(p + 1);
-        		switch (*p)
-        		{
-          			case 'x': setpointX  = val; break;
-          			case 'y': setpointY  = val; break;
-      	  			case 'm': multiplier = val; break;
-      				case 'i': invertXY   = val; break;
-      				case 'j': invertX    = val; break;
-      				case 'k': invertX    = val; break;
-      				case 'h': hysteresis = val; break;
-        		}
-      		}
-    	}
-
-    	if (strcmp(strtok(msg, " "), "RUN") == 0)
-    	{
-        	Serial.println("ROll BB-8 ROLL !");
-      	    production = true;
-      	    emgStop = false;
-    	}
-
-    	if (strcmp(strtok(msg, " "), "STOP") == 0)
-    	{
-    		Serial.println("STOP");
-    	    production = false;
-    	}
-
-    	if (strcmp(strtok(msg, " "), "RESET") == 0)
-    	{
-    		Serial.println("RESET");
-    	    production = false;
-    	}
-
-    	if (strcmp(strtok(msg, " "), "BOOT") == 0)
-    	{
-
-    	    BOOT = true;
-    	    Serial.println("BOOTING UP...");
-    	    delay(2000);
-    	}
-
-    	if (strcmp(strtok(msg, " "), "ROTATE") == 0) // ROTATE d1 s100  <-- Rotate Z right, 18c/sec
-    	{
-      		// trouvé le message
-      		char *p;
-      		while ((p = strtok(NULL, " ")) != NULL)
-      		{
-        		int val = atoi(p + 1);
-        		switch (*p)
-        		{
-          			case 'd': directZ  = val; break;
-          			case 's': speedZ   = val; break;
-        		}
-      		}
-    	}
-
-
-  }
-
-   if(BOOT)
-   {
-   	    // SET X IN POSITION
-   		if(x < 90) directX = false;
-  		else directX = true;
-
-  		if(invertX)
-  		{
-    		if(directX) directX = false;
-    		else directX = true;
-  		}
-  		digitalWrite(pinDirX, directX); // dirX
-
-  		if(x > (setpointX + hysteresis) || (x < setpointX - hysteresis ))
-  		{
-  	        digitalWrite(pinStepX, 1);
-        	delayMicroseconds( 500 );
-    	    digitalWrite(pinStepX, 0);
-    	    delayMicroseconds( 500 );
-  		}
-  		else
-  		{
-  			if(!xok)
-  			{
-  				Serial.println("BOOT x1 ");
-  				xok = true;
-  				delay(2000);
-  			}
-  		}
-
-
-  		// SET Y IN POSITION
-   		if(y < 90) directY = false;
-  		else directY = true;
-
-  		if(invertY)
-  		{
-    		if(directY) directY = false;
-    		else directY = true;
-  		}
-  		digitalWrite(pinDirY, directY); // dirX
-
-  		if(x > (setpointY + hysteresis) || (y < setpointY - hysteresis ))
-  		{
-  	        digitalWrite(pinStepY, 1);
-        	delayMicroseconds( 500 );
-    	    digitalWrite(pinStepY, 0);
-    	    delayMicroseconds( 500 );
-  		}
-  		else
-  		{
-  			if(!yok)
-  			{
-  				Serial.println("BOOT y1 ");
-  				yok = true;
-  				delay(2000);
-  			}
-  		}
-
-  		// SET Z IN POSITION
-
-  		if(!Z_POSITION)
-  		{
-  		  	digitalWrite(pinStepZ, 1);
-        	delayMicroseconds( 500 );
-    	    digitalWrite(pinStepZ, 0);
-    	    delayMicroseconds( 500 );
-  		}
-  		else
-  		{
-  		  	if(!zok)
-  			{
-  				Serial.println("BOOT z1 ");
-  				zok = true;
-  				Zangle = 0;
-  				delay(2000);
-  			}
-  		}
-
-  		if( xok && yok && zok)
-  		{
-			Serial.println("STAT b1 ");
-  			Serial.println("Booting UP OK!");
-  			Serial.println("SEND 'RUN \n' for start the production");
-  			BOOT = false;
-  		}
-
-
-   }
-
-	// PRODUCTION CODE
-    //-------------------------------------------------------------------------//
-    if(production && !emgStop)  //-
-    {
-
-  		// X //
-
-		// Direction
-  		if(x < 90) directX = false;
-  		else directX = true;
-
-  		if(invertX)
-  		{
-    		if(directX) directX = false;
-    		else directX = true;
-  		}
-  		digitalWrite(pinDirX, directX); // dirX
-
-  		// Si ont doit demarer le moteur
-  		if(x > (setpointX + hysteresis) || (x < setpointX - hysteresis ))
-  		{
-    		if(x > minX && x < maxX) runX = true;
-    		else runX = false;
-  		}
-  		else runX = false;
-
-  		// Calcul du PID X
-  		if(x < 90) vx = (90 - x);
-  		if(x == 0) vx = 0;
-  		if(x > 90) vx = (x - 90);
-
-  		speedX = 1000 / (vx);
-  		speedX = speedX * multiplier; // DEL
-  		if(speedX < 15) speedX = 15;
-
-		// Mise en route du moteur
-  		unsigned long currentX = millis();
-
-    	if (currentX - previousMillisX >= speedX)
-    	{
-      		previousMillisX = currentX;
-
-      		if(runX)
-      		{
-        		digitalWrite(pinStepX, 1);
-        		delayMicroseconds( 500 );
-        		digitalWrite(pinStepX, 0);
-    	 		delayMicroseconds( 500 );
-      		}
-  		}
-
-  		// Y //
-  		// Direction
-  		if(y < 90) directY = false;
-  		else directY = true;
-  		if(invertY)
-  		{
-    		if(directY) directY = false;
-    		else directY = true;
-  		}
-  		digitalWrite(pinDirY, directY);
-
-		// Si ont doit demarer le moteur
-  		if(y > (setpointY + hysteresis) || (y < setpointY - hysteresis ))
-  		{
-    		if(y > minY && y < maxY) runY = true;
-    		else runY = false;
-  		}
-  		else runY = false;
-
-  		// Calcul du PID Y
-  		if(y < 90) vy = (90 - y);
-  		if(y == 0) vy = 0;
-  		if(y > 90) vy = (y - 90);
-
-  		speedY = 1000 / (vy);
-  		speedY = speedY * multiplier; // DEL
-  		if(speedY < 15) speedY = 15;
-
-  		// Mise en route du moteur
-  		unsigned long currentY = millis(); // millis();
-
-    	if (currentY - previousMillisY >= speedY)
-    	{
-      		previousMillisY = currentY;
-
-      		if(runY)
-      		{
-        		digitalWrite(pinStepY, 1);
-        		delayMicroseconds( 500 );
-        		digitalWrite(pinStepY, 0);
-        		delayMicroseconds( 500 );
-      		}
-  		}
-
-  		//--- Z
-  		if(speedZ != 0)
-  		{
-  			unsigned long currentZ = millis();
-  			if (currentZ - previousMillisZ >= speedZ)
-    		{
-      			previousMillisZ = currentZ;
-
-    	 		digitalWrite(pinStepY, 1);
-    	    	delayMicroseconds( 500 );
-    	    	digitalWrite(pinStepY, 0);
-    	    	delayMicroseconds( 500 );
-    	    	if(directZ) Zangle++;
-    	    	else Zangle--;
-  			}
-  		}
-  		if(Zangle == 201) Zangle = 0;
-  		if(Zangle == -1)  Zangle = 0;
-
-
-  } //-
-
-  // Check if the Master-Board are ALIVE
-
-  if(digitalRead(PING_MASTER) && !ifPing)
-  {
-  	ifPing = true;
-  	pingMaster++;
-  }
-
-  if(digitalRead(PING_MASTER) && ifPing) ifPing = false;
-
-
-  	// SEND SERIAL DATA
-    //-------------------------------------------------------------------------//
-    unsigned long currentS = millis(); // millis();
-
-    if (currentS - trigS  >= trigSec)
-    {
-    	trigS = currentS;
-
-
-
-    	// PING
-    	if(LED_PING) LED_PING = false;
-    	else LED_PING = true;
-    	digitalWrite(PING, LED_PING);
-
-
-    	tmpPing2++;
-
-    	if(pingMaster > tmpPing)
-    	{
-    		tmpPing = pingMaster;
-    		tmpPing2 = 0;
-    	}
-    	if(tmpPing2 > 3) emgStop = true;
-
-
-
-    	if(!accelgyro.testConnection());
-    	{
-    		production = false;
-    		emgStop = true;
-    		accelgyro.initialize();
-    		if(accelgyro.testConnection())
-    		{
-    			production = true;
-    		}
-    	}
-
-
-
-
-
-    	// SEND STATUT
-    	Serial.print("STAT x");
-    	Serial.print(x);
-    	Serial.print(" y");
-    	Serial.print(y);
-    	Serial.print(" i");
-    	Serial.print(invertXY);
-    	Serial.print(" j");
-    	Serial.print(invertX);
-    	Serial.print(" k");
-    	Serial.print(invertY);
-    	Serial.print(" m");
-    	Serial.print(multiplier);
-    	Serial.print(" z");
-    	Serial.print(Zangle);
-
-    	Serial.println(" ");
-
-
-    }
-}


fix puzzled printf

fix puzzled printf

--- src/pm25/pm25.ino
+++ src/pm25/pm25.ino
@@ -133,8 +133,9 @@
   Serial.print(error);
   if(pdata)
   {
-      Serial.print("\n get data : ");
+      Serial.print("\n respond  : ");
       Serial.print(pdata);
+      Serial.print("\n");
     }
   if (arg)
      Serial.print(*(char*)arg);


AD7173-8.ino updated speed, mode and channel functions

--- AD7173-8.ino
+++ AD7173-8.ino
@@ -98,21 +98,33 @@
 #define SETUPCON7_REG 0x27

 /* ADC values */
-#define HZ_1 0x16
-#define HZ_10 0x13
-#define KHZ_1 0x0A
-#define KHZ_2 0x09
-#define KHZ_5 0x08
-#define KHZ_10 0x07
-#define KHZ_15 0x06
-#define KHZ_31 0x00
-#define HZ_500 0x0B
-#define DEBUG_ENABLED true
+#define SPS_1 0x16
+#define SPS_2 0x15
+#define SPS_5 0x14
+#define SPS_10 0x13
+#define SPS_16 0x12
+#define SPS_20 0x11
+#define SPS_50 0x10
+#define SPS_60 0x0F
+#define SPS_100 0x0E
+#define SPS_200 0x0D
+#define SPS_381 0x0C
+#define SPS_504 0x0B
+#define SPS_1007 0x0A
+#define SPS_2597 0x09
+#define SPS_5208 0x08
+#define SPS_10417 0x07
+#define SPS_15625 0x06
+#define SPS_31250 0x00
 #define CONTINUOUS_READ_MODE 0
 #define SINGLE_CONVERSION_MODE 1
 #define CONTINUOUS_CONVERSION_MODE 2
 #define DATA_READY digitalRead(MISO) == LOW

+/* enable/disable debug */
+#define DEBUG_ENABLED 1
+
+/* default adc data conversion mode */
 int adc_data_mode = CONTINUOUS_CONVERSION_MODE;

 /*
@@ -218,7 +230,7 @@
 @return int - error code
 =================================
 */
-int set_channel(byte channel, bool status) {
+int enable_adc_channel(byte channel, bool status) {
     /* when channel out of range */
     if (channel < 0x10 || channel > 0x1F) {
         if (DEBUG_ENABLED) {
@@ -234,10 +246,12 @@
     /* enable or disable this channel */
     value[0] |= (status << 7);
     /* set the correct analog inputs */
-    byte ain = (channel & 0x0F);
+    byte ain = ((channel & 0x0F) << 2);
     value[1] = (ain << 5) | (ain + 1);
     /* update specified channel configuration */
     write_adc_register(channel, value, 2);
+    /* return error code */
+    return 0;
 }

 /*
@@ -247,55 +261,61 @@
 @return int - error code
 ==================================
 */
-int set_adc_data_speed(int speed) {
+int set_adc_data_speed(byte data_speed) {
     byte value[2];
     read_adc_register(FILTCON0_REG, value, 2);
-    value[0] &= 0xE0;
-    value[0] |= speed >> 7;
-    value[1] |= speed;
+    value[1] &= 0xE0;
+    value[1] |= data_speed;
     write_adc_register(FILTCON0_REG, value, 2);
-    return 0;
-}
-
-/*
-===========================
-sets the adc data read mode
+    /* return error code */
+    return 0;
+}
+
+/*
+==================================
+sets the adc data converison mode
 @param int - data read mode
 @return int - error code
-===========================
+==================================
 */
 int set_adc_data_mode(int mode) {
-    byte value[2];
-    /* diable continuous read mode */
+    byte if_mode_value[2];
+    byte adc_mode_value[2];
+    /* read current values */
     read_adc_register(IFMODE_REG, value, 2);
-    value[1] &= 0xF7;
-    write_adc_register(IFMODE_REG, value, 2);
+    read_adc_register(ADCMODE_REG, adc_mode_value, 2);

     /* when continuous read mode */
     if (mode == CONTINUOUS_READ_MODE) {
+        /* enable continuouse conversion mode */
+        adc_mode_value[1] &= 0x8F;
         /* set the adc to continuous read mode, the data register can be read directly when DATA_READY */
-        set_adc_data_mode(CONTINUOUS_CONVERSION_MODE);
-        read_adc_register(IFMODE_REG, value, 2);
-        value[1] |= 0x08;
-        write_adc_register(IFMODE_REG, value, 2);
+        if_mode_value[1] |= 0x08;
+        adc_data_mode = CONTINUOUS_READ_MODE;
     /* when single conversion mode */
     } else if (mode == SINGLE_CONVERSION_MODE) {
+        /* diable continuous read mode */
+        if_mode_value[1] &= 0xF7;
         /* set the adc to single conversion mode, the ADC conversion has to be triggered manually */
-        read_adc_register(ADCMODE_REG, value, 2);
-        value[1] &= 0x8F;
-        value[1] |= 0x10;
-        write_adc_register(ADCMODE_REG, value, 2);
+        adc_mode_value[1] &= 0x8F;
+        adc_mode_value[1] |= 0x10;
+        adc_data_mode = SINGLE_CONVERSION_MODE;
     /* when continuous conversion mode */
     } else if (mode == CONTINUOUS_CONVERSION_MODE) {
+        /* diable continuous read mode */
+        if_mode_value[1] &= 0xF7;
         /* set the adc to continuous conversion mode, the communication register has to be notified for a ADC read */
-        read_adc_register(ADCMODE_REG, value, 2);
-        value[1] &= 0x8F;
-        value[1] |= 0x00;
-        write_adc_register(ADCMODE_REG, value, 2);
-    /* unknown data read mode */
+        adc_mode_value[1] &= 0x8F;
+        adc_data_mode = CONTINUOUS_CONVERSION_MODE;
+    /* unknown data conversion mode */
     } else {
+        /* return error code */
         return 1;
     }
+    /* write the specified value */
+    write_adc_register(IFMODE_REG, if_mode_value, 2);
+    write_adc_register(ADCMODE_REG, adc_mode_value, 2);
+    /* return error code */
     return 0;
 }

@@ -309,7 +329,7 @@
     if (adc_data_mode == CONTINUOUS_CONVERSION_MODE) {
         /* send communication register id 0x00 */
         SPI.transfer(0x00);
-        /* send read command to the data register 0x04 */
+        /* send read command 0x40 to the data register 0x04 */
         SPI.transfer(0x40 | DATA_REG);
     }
     /* read the received value 24 bits */
@@ -370,60 +390,25 @@
     /* initiate ADC */
     init_adc();
     /* set ADC configuration */
-    byte value[2];
-    /* read initial register values */
-    read_adc_register(CH0_REG, value, 2);
-    read_adc_register(FILTCON0_REG, value, 2);
-    /* write new values to registers */
-    /* set ch1 - 3 enabled */
-    value[0] = 0x80;
-    value[1] = 0x01;
-    write_adc_register(CH1_REG, value, 2);
-    write_adc_register(CH2_REG, value, 2);
-    write_adc_register(CH3_REG, value, 2);
-    /* set the samplingrate, register FILTCON0 0x28, reset  0x0000 */
-    /* last 5 bytes, 0x0000 - 31kHz, 0x0004 5208Hz */
-    value[0] = 0x00;
-    value[1] = 0x04;
-    write_adc_register(FILTCON0_REG, value, 2);
-    /* read set register values */
-    read_adc_register(CH1_REG, value, 2);
-    read_adc_register(CH2_REG, value, 2);
-    read_adc_register(CH3_REG, value, 2);
-    read_adc_register(FILTCON0_REG, value, 2);
+    /* enable ch0 and ch1 */
+    enable_adc_channel(CH0_REG, true);
+    enable_adc_channel(CH1_REG, true);
+    /* set the adc data mode */
+    set_adc_data_mode(CONTINUOUS_READ_MODE);
+    /* set the adc samplingrate to 1007 Hz*/
+    set_adc_data_speed(SPS_1007);
     /* wait for ADC */
     delay(100);
 }

 void loop() {
-    byte value[4][3];
-    /* read 4 adc channels */
-    for (int i = 0; i < 4; i++) {
-        /* when ADC conversion is finished */
-        if (DATA_READY) {
-            /* read ADC conversion result */
-            read_adc_data(value[i]);
-        }
-    }
-    /* convert the result into the desired protocol */
-    int ch0 = (value[0][0] << 2) | (value[0][1] & 0x03);
-    ch0 -= 512;
-    ch0 *= 2;
-    char str[3];
-    sprintf(str, "%d", ch0);
-    Serial.print(str);
-    Serial.write(0x09);
-
-    int ch1 = (value[2][0] << 2) | (value[2][1] & 0x03);
-    ch1 -= 512;
-    ch1 *= 2;
-    sprintf(str, "%d", ch1);
-    Serial.print(str);
-    Serial.write(0x09);
-
-    Serial.print(0x200);
-    Serial.write(0x09);
-
-    Serial.print(0x200);
-    Serial.write(0x0D);
-}
+    byte data[3];
+    /* when ADC conversion is finished */
+    if (DATA_READY) {
+        /* read ADC conversion result */
+        read_adc_data(data);
+        Serial.write(data[0]);
+        Serial.write(data[1]);
+        Serial.write(data[2]);
+    }
+}


The camera motor should no longer heat up like a torch.

--- src/RotatingCamera/RotatingCamera.ino
+++ src/RotatingCamera/RotatingCamera.ino
@@ -140,6 +140,7 @@
     digitalWrite(PULSE_PIN, LOW);
     stepCount = (stepCount + 1) % MAX_STEP_VALUE;
   }
+  digitalWrite(ENABLE, HIGH);
 }

 // Decreasing the step means we want to move clockwise (right).
@@ -159,6 +160,7 @@
       stepCount += MAX_STEP_VALUE;
     }
   }
+  digitalWrite(ENABLE, HIGH);
 }


Changes to use 12 LED instead of 11

Changes to use 12 LED instead of 11

--- rotate-redled.ino
+++ rotate-redled.ino
@@ -84,13 +84,13 @@
   //strip.setPixelColor(0, strip.Color(255, 0, 255));
   //strip.show();

-  pixelWipe(strip.Color(255, 0, 0),strip.Color(0, 0, 50), 50); // Red
-
+  pixelWipe(strip.Color(55, 0, 0),strip.Color(0, 0, 15), 30); // Red
+  //pixelWipeReverse(strip.Color(255, 128, 0),strip.Color(0, 0, 50), 50);
   //colorWipe(strip.Color(255, 0, 0), 50); // Red

-  //colorWipe(strip.Color(200, 255, 0), 50); // Green
+  //colorWipe(strip.Color(20, 25, 0), 50); // Green

-  //colorWipe(strip.Color(0, 0, 255), 50); // Blue
+  //colorWipe(strip.Color(0, 0, 25), 50); // Blue

   //rainbow(20);

@@ -121,8 +121,21 @@

 void pixelWipe(uint32_t c, uint32_t b, uint8_t wait) {
   for(uint16_t i=0; i<strip.numPixels(); i++) {
+    // Clear all
+    for(uint16_t t=0; t<strip.numPixels(); t++) {
+      strip.setPixelColor(t, b);
+    }
     strip.setPixelColor(i, c);
-    strip.setPixelColor(i - 1, b);
+    strip.show();
+    delay(wait);
+
+  }
+}
+
+void pixelWipeReverse(uint32_t c, uint32_t b, uint8_t wait) {
+  for(uint16_t i=strip.numPixels(); i>0; i--) {
+    strip.setPixelColor(i, c);
+    strip.setPixelColor(i + 1, b);
     strip.show();
     delay(wait);
   }
@@ -153,6 +166,7 @@
   }
 }

+
 // Input a value 0 to 255 to get a color value.
 // The colours are a transition r - g - b - back to r.
 uint32_t Wheel(byte WheelPos) {
@@ -166,4 +180,3 @@
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
   }
 }
-


Refactor buffer names

Refactor buffer names

--- software/XTendPayloadTeensy/XTendPayloadTeensy.ino
+++ software/XTendPayloadTeensy/XTendPayloadTeensy.ino
@@ -4,12 +4,12 @@
  */
 #include <TimeLib.h>
 char pkt_buffer[200];
-boolean sentencePending, sentenceRdy;
+boolean sentencePending, sentenceRdy, sentenceBufRdy;
 boolean txFlag, help;
+char sentence[GPSLEN];
 char sentenceBuf[GPSLEN];
-char sentenceBuf2[GPSLEN];
 String gpsTime, gpsDate, gpsLat, gpsLon, gpsAlt, gspVgnd, gpsHdng;
-int sentenceBufIndex = 0;
+int sentenceIndex = 0;
 String msgIn = "";

 String output = "hello";
@@ -23,8 +23,8 @@
   setSyncProvider( getTeensy3Time );
   sentencePending = false;
   sentenceRdy = false;
-  sentenceBuf[0] = 0;
-  sentenceBufIndex = 0;
+  sentence[0] = 0;
+  sentenceIndex = 0;
   txTimer.begin(transmit, 10000);
   pinMode(5,INPUT_PULLUP);
   while( !Serial1 );
@@ -33,9 +33,11 @@
 void loop(){
   // Copy any completed sentence to the buffer, set up for next sentence.
   if ( sentenceRdy ) {
+    sentenceBufRdy = false;
     for ( int i = 0 ; i < GPSLEN ; i++ ) {
-        sentenceBuf2[i] = sentenceBuf[i];
+        sentenceBuf[i] = sentence[i];
     }
+    sentenceBufRdy = true;
     sentenceRdy = false;
   }
   //RX section, READ from RF
@@ -80,16 +82,16 @@
     c = Serial1.read();
     if ( !sentenceRdy ) {
       if ( c == 36 ) { //36 is '$', start of GPS statement - KN
-        sentenceBufIndex = 0;
+        sentenceIndex = 0;
         sentencePending = true;
       }
       if ( sentencePending && c == 10 ) { //10 is new line - KN
         sentenceRdy = true;
         sentencePending = false;
       }
-      sentenceBuf[sentenceBufIndex] = c;
-      sentenceBufIndex++;
-      sentenceBuf[sentenceBufIndex] = 0;
+      sentence[sentenceIndex] = c;
+      sentenceIndex++;
+      sentence[sentenceIndex] = 0;
     }
   }
 }
@@ -98,7 +100,7 @@
   //print out sentence, all of it - KN
   int i = 0;

-  if ( sentenceRdy ) {
+  if ( sentenceBufRdy ) {
     while( sentenceBuf[i+1] != 0 ) {
         Serial2.write( sentenceBuf[i] );
         Serial1.write( sentenceBuf[i] );//for logging
@@ -106,7 +108,7 @@
     }
     sentenceRdy = false;
   } else { // Buffer data is being updated. Use current sentence
-    while( sentenceBuf2[i+1] != 0 ) {
+    while( sentence[i+1] != 0 ) {
         Serial2.write( sentenceBuf[i] );
         Serial1.write( sentenceBuf2[i] );//for logging
         i++;


Update ArduCAM_Mini_2MP_Plus_functions.ino

--- ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_functions/ArduCAM_Mini_2MP_Plus_functions.ino
+++ ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_functions/ArduCAM_Mini_2MP_Plus_functions.ino
@@ -49,8 +49,14 @@
 Serial.println(F("ACK CMD ArduCAM Start! END"));
 // set the CS as an output:
 pinMode(CS, OUTPUT);
+digitalWrite(CS, HIGH);
 // 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);


fixed bug (again) (sorry)

fixed bug (again) (sorry)

--- firmware/LO_mpr121_and_led_test_esp8266_cz/LO_mpr121_and_led_test_esp8266_cz.ino
+++ firmware/LO_mpr121_and_led_test_esp8266_cz/LO_mpr121_and_led_test_esp8266_cz.ino
@@ -165,9 +165,8 @@
       }
     }
   }
-}
-
-updateStation();
+
+  updateStation();
 }

 void updateStation() {


Re-organisation of the code

Re-organisation of the code

--- relais_serre_LCDi2c_V.2.ino
+++ relais_serre_LCDi2c_V.2.ino
@@ -1,8 +1,4 @@
-#include <DHT.h>
-#define DHTPIN A1
-#define DHTTYPE    DHT11
-DHT dht(DHTPIN, DHTTYPE);
-
+//--------------LCD 20x4--------------------
 #include <Wire.h>
 #include <LCD.h>
 #include <LiquidCrystal_I2C.h>
@@ -10,46 +6,12 @@
 #define I2C_ADDR    0x22  // Define I2C Address where the PCF8574A is
 #define BACKLIGHT_PIN     3
 LiquidCrystal_I2C  lcd(I2C_ADDR,2,1,0,4,5,6,7);
-/*
- *  En_pin  2
- *  Rw_pin  1
- *  Rs_pin  0
- *  D4_pin  4
- *  D5_pin  5
- *  D6_pin  6
- *  D7_pin  7
+/* En_pin  2, Rw_pin  1, Rs_pin  0, D4_pin  4, D5_pin  5, D6_pin  6, D7_pin  7
  */
- */
-//**********BLOC PROGRAMMABLE*************
-//Températures critiques et hysteresis
-
-//Rollup:
-const int TEMP_ROLLUP = 20; //température d'activation des rollup
-const int HYST_ROLLUP = 2;
-
-//Ventilation:
-const int TEMP_VENT = 22;
-const int HYST_VENT = 2;
-
-//Chauffage:
-const int TEMP_CHAUFFAGE1 = 18;//température d'activation de la 1re fournaise
-const int HYST_CHAUFFAGE1 = 2;//
-const int TEMP_CHAUFFAGE2 = 15;//température d'activation de la 2e fournaise
-const int HYST_CHAUFFAGE2 = 2;
-
-//incréments d'ouverture(nombre d'incréments d'ouverture = PCT_OPEN/NB_OF_STEPS_IN_ANIMATION = 25/5 = 5 incréments d'ouverture)
-const int PCT_OPEN = 25;
-const int NB_OF_STEPS_IN_ANIMATION = 5; //doit être un divisible de PCT_OPEN
-
-//temps de rotation et pauses
-const int ROTATION_TIME = 4000; //temps de rotation des moteurs(en mili-secondes)
-const int PAUSE_TIME = 2000; //temps d'arrêt entre chaque ouverture/fermeture(en mili-secondes)
-const int SLEEPTIME = 1000; //temps de pause entre chaque exécution du programme(en mili-secondes)
-
-//*************FIN DU BLOC PROGRAMMABLE**********
-
-//Entrées
-const int THERMOMETER_IN = A0;// sonde de température DHT11
+//--------------DHT11--------------------
+#include <DHT.h>
+#define DHTPIN A1
+//--------------Relais--------------------
 //Sorties
 const int ROLLUP1_POWER = 12;//relais on/off - moteur1
 const int ROLLUP1_DIRECTION = 11; //relais gauche/droite - moteur1
@@ -71,13 +33,47 @@
 boolean heating2 = false; //fournaise 2 éteinte par défaut
 boolean fan = false;//ventilation forcée éteinte par défaut
 float greenhouseTemperature = 20.0; //température par défaut : 20C (ajusté après un cycle)
+#define DHTTYPE    DHT11
+DHT dht(DHTPIN, DHTTYPE);
+
+
+
+//**********BLOC PROGRAMMABLE*************
+//Températures critiques et hysteresis
+//Rollup:
+const int TEMP_ROLLUP = 20; //température d'activation des rollup
+const int HYST_ROLLUP = 2;
+
+//Ventilation:
+const int TEMP_VENT = 22;
+const int HYST_VENT = 2;
+
+//Chauffage:
+const int TEMP_CHAUFFAGE1 = 18;//température d'activation de la 1re fournaise
+const int HYST_CHAUFFAGE1 = 2;//
+const int TEMP_CHAUFFAGE2 = 15;//température d'activation de la 2e fournaise
+const int HYST_CHAUFFAGE2 = 2;
+
+//incréments d'ouverture(nombre d'incréments d'ouverture = PCT_OPEN/NB_OF_STEPS_IN_ANIMATION = 25/5 = 5 incréments d'ouverture)
+const int PCT_OPEN = 25;
+const int NB_OF_STEPS_IN_ANIMATION = 5; //doit être un divisible de PCT_OPEN
+
+//temps de rotation et pauses
+const int ROTATION_TIME = 4000; //temps de rotation des moteurs(en mili-secondes)
+const int PAUSE_TIME = 2000; //temps d'arrêt entre chaque ouverture/fermeture(en mili-secondes)
+const int SLEEPTIME = 1000; //temps de pause entre chaque exécution du programme(en mili-secondes)
+
+//*************FIN DU BLOC PROGRAMMABLE**********

 //********INITIALISATION DU PROGRAMME**********
 void setup() {
-  Serial.begin(9600);   // démarre la communication sérielle
+  Serial.begin(9600);   // démarre la communication sérielle
+  Serial.println("");
   Serial.println("Starting");
-   lcd.begin (20,4); //démarre l'affichage LCD
+  Serial.println("-----------------------");
+//--------------LCD 20x4--------------------
+  lcd.begin (20,4); //démarre l'affichage LCD
   lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
   lcd.setBacklight(HIGH); //allume le rétro-éclairage
   lcd.home ();
@@ -93,8 +89,10 @@
   lcd.print("HEATING: ");
   lcd.setCursor(16,3);
   lcd.print("OFF");
-
-  //Définition et initalisation des sorties
+//--------------DHT11--------------------
+  dht.begin();
+//--------------General setup-------------------
+//Définition et initalisation des sorties
   pinMode(ROLLUP1_POWER, OUTPUT);
   digitalWrite(ROLLUP1_POWER, HIGH);

@@ -126,6 +124,95 @@
   Serial.println("Resetting done");
 }

+void loop() {
+//--------------DHT11--------------------
+  float greenhouseTemperature = dht.readTemperature();
+  float greenhouseHumidity = dht.readHumidity();
+//--------------Relais--------------------
+//Programme d'ouverture/fermeture des rollups
+  if(greenhouseTemperature < TEMP_ROLLUP-(HYST_ROLLUP/2)){
+    closeSides();
+  }else if(greenhouseTemperature > TEMP_ROLLUP+(HYST_ROLLUP/2)){
+    openSides();
+  }
+//Programme fournaise1
+  if (greenhouseTemperature < (TEMP_CHAUFFAGE1-(HYST_CHAUFFAGE1/2))){
+    setHeater1(ON);
+    digitalWrite(CHAUFFAGE1, ON);
+  }else if(greenhouseTemperature > (TEMP_CHAUFFAGE1+(HYST_CHAUFFAGE1/2))){
+    setHeater1(OFF);
+    digitalWrite(CHAUFFAGE1, OFF);
+  }
+//Programme fournaise2
+  if (greenhouseTemperature < (TEMP_CHAUFFAGE2-(HYST_CHAUFFAGE2/2))){
+    setHeater2(ON);
+    digitalWrite(CHAUFFAGE2, ON);
+  }else if(greenhouseTemperature > (TEMP_CHAUFFAGE2+(HYST_CHAUFFAGE2/2))){
+    setHeater2(OFF);
+    digitalWrite(CHAUFFAGE2, OFF);
+  }
+//Programme ventilation forcée
+   if (greenhouseTemperature > (TEMP_VENT - (HYST_VENT/2))){
+    setFan(ON);
+    digitalWrite(FAN, ON);
+  }else if(greenhouseTemperature < (TEMP_VENT + (HYST_VENT/2))){
+    setFan(OFF);
+    digitalWrite(FAN, OFF);
+  }
+//--------------Affichage sériel--------------------
+    Serial.print("Temperature actuelle: ");
+    Serial.print(greenhouseTemperature);
+    Serial.println(" C");
+    Serial.print("Humidite: ");
+    Serial.print(greenhouseHumidity);
+    Serial.println("%");
+    Serial.println("-----------------------");
+    if(fan == false){
+    Serial.println("FAN: OFF");}
+    else if(fan == true){
+    Serial.println("FAN: ON");}
+    if(heating1 == false){
+    Serial.println("HEATING1: OFF");}
+    else if(heating1 == true){
+    Serial.println("HEATING1: ON");}
+    if(heating2 == false){
+    Serial.println("HEATING2 : OFF");}
+    else if(heating2 == true){
+    Serial.println("HEATING2 : ON");}
+//--------------Affichage LCD--------------------
+  lcd.setCursor(0, 0);
+  lcd.print("T: ");
+  lcd.print(greenhouseTemperature);
+  lcd.print("C  ");
+  lcd.setCursor(10,0);
+  lcd.print("HR: ");
+  lcd.print(greenhouseHumidity);
+  lcd.print("%");
+  if(fan == false){
+      lcd.setCursor(0, 2);
+      lcd.print("FAN:");
+      lcd.setCursor(16,2);
+      lcd.print("OFF");}
+  else if(fan == true){
+      lcd.setCursor(0,2);
+      lcd.print("FAN:");
+      lcd.setCursor(16,2);
+      lcd.print("ON ");}
+  if(heating1 == false){
+      lcd.setCursor(0, 3);
+      lcd.print("HEATING:");
+      lcd.setCursor(16,3);
+      lcd.print("OFF");}
+  else if(heating1 == true){
+      lcd.setCursor(0,3);
+      lcd.print("HEATING: ");
+      lcd.setCursor(16,3);
+      lcd.print("ON ");}
+//--------------fin du cycle--------------------
+  delay(SLEEPTIME);
+}
+
+//--------------SOUS-PROGRAMMES--------------------
 //Affichage du % d'ouverture des rollup
 void setOpenedStatus(int pctIncrease){
   opened += pctIncrease;
@@ -152,6 +239,8 @@
 //Programme d'ouverture des rollup
 void openSides(){
   if(opened < 100){
+    Serial.println("");
+    Serial.println("  Opening");
     lcd.setCursor(0, 1);
     lcd.print("OUVERTURE... ");
     digitalWrite(ROLLUP1_POWER,ON);
@@ -171,6 +260,7 @@
 //Programme de fermeture des rollups
 void closeSides(){
   if (opened > 0){
+    Serial.println("");
     Serial.println("  Closing");
     lcd.setCursor(0, 1);
     lcd.print("FERMETURE... ");
@@ -191,9 +281,11 @@
 //État de la première fournaise
 void setHeater1(int heaterCommand1){
   if ((heaterCommand1 == ON) && (heating1 == false)){
+    Serial.println("");
     Serial.println("  Start heating1");
     heating1 = true;
   }else if ((heaterCommand1 == OFF) && (heating1 == true)){
+    Serial.println("");
     Serial.println("  Stop heating1");
     heating1 = false;
     }
@@ -202,9 +294,11 @@
 //État de la deuxième fournaise
 void setHeater2(int heaterCommand2){
   if ((heaterCommand2 == ON) && (heating2 == false)){
+    Serial.println("");
     Serial.println("  Start heating2");
     heating2 = true;
   }else if ((heaterCommand2 == OFF) && (heating2 == true)){
+    Serial.println("");
     Serial.println("  Stop heating2");
     heating2 = false;
     }
@@ -213,91 +307,17 @@
 //État de la ventilation
 void setFan(int fanCommand){
   if ((fanCommand == ON) && (fan == false)){
+    Serial.println("");
     Serial.println("  Start fan");

     fan = true;
   }else if ((fanCommand == OFF) && (fan == true)){
+    Serial.println("");
     Serial.println("  Stop fan");
     fan = false;
   }
 }

-void loop() {
-
-  float greenhouseTemperature = dht.readTemperature();
-  float greenhouseHumidity = dht.readHumidity();
-  Serial.print(greenhouseTemperature);//Affichage de la temperature
-  Serial.println ("C");
-  Serial.print(greenhouseHumidity);//Affichage de l'humidité
-  Serial.println ("%");
-  lcd.setCursor(0, 0);
-  lcd.print("T: ");
-  lcd.print(greenhouseTemperature);
-  lcd.print("C  ");
-  lcd.setCursor(10,0);
-  lcd.print("HR: ");
-  lcd.print(greenhouseHumidity);
-  lcd.print("%");
-  if(fan == false){                   //Affichage de l'etat de la fan
-      Serial.println("FAN: OFF");
-      lcd.setCursor(0, 2);
-      lcd.print("FAN:");
-      lcd.setCursor(16,2);
-      lcd.print("OFF");}
-  else if(fan == true){
-      Serial.println("FAN: ON");
-      lcd.setCursor(0,2);
-      lcd.print("FAN:");
-      lcd.setCursor(16,2);
-      lcd.print("ON ");}
-  if(heating1 == false){               //Affichage de l'etat du chauffage
-      Serial.println("HEATING1: OFF");
-      lcd.setCursor(0, 3);
-      lcd.print("HEATING:");
-      lcd.setCursor(16,3);
-      lcd.print("OFF");}
-  else if(heating1 == true){
-      Serial.println("HEATING1: ON");
-      lcd.setCursor(0,3);
-      lcd.print("HEATING: ");
-      lcd.setCursor(16,3);
-      lcd.print("ON ");}
-  if(heating2 == false){
-      Serial.println("HEATING2 : OFF");}
-  else if(heating2 == true);{
-      Serial.println("HEATING2 : ON");}
-
-//Programme d'ouverture/fermeture des rollups
-  if(greenhouseTemperature < TEMP_ROLLUP-(HYST_ROLLUP/2)){
-    closeSides();
-  }else if(greenhouseTemperature > TEMP_ROLLUP+(HYST_ROLLUP/2)){
-    openSides();
-  }
-//Programme fournaise1
-  if (greenhouseTemperature < (TEMP_CHAUFFAGE1-(HYST_CHAUFFAGE1/2))){
-    setHeater1(ON);
-    digitalWrite(CHAUFFAGE1, ON);
-  }else if(greenhouseTemperature > (TEMP_CHAUFFAGE1+(HYST_CHAUFFAGE1/2))){
-    setHeater1(OFF);
-    digitalWrite(CHAUFFAGE1, OFF);
-  }
-//Programme fournaise2
-  if (greenhouseTemperature < (TEMP_CHAUFFAGE2-(HYST_CHAUFFAGE2/2))){
-    setHeater2(ON);
-    digitalWrite(CHAUFFAGE2, ON);
-  }else if(greenhouseTemperature > (TEMP_CHAUFFAGE2+(HYST_CHAUFFAGE2/2))){
-    setHeater2(OFF);
-    digitalWrite(CHAUFFAGE2, OFF);
-  }
-//Programme ventilation forcée
-   if (greenhouseTemperature > (TEMP_VENT - (HYST_VENT/2))){
-    setFan(ON);
-    digitalWrite(FAN, ON);
-  }else if(greenhouseTemperature < (TEMP_VENT + (HYST_VENT/2))){
-    setFan(OFF);
-    digitalWrite(FAN, OFF);
-  }
-  delay(SLEEPTIME);
-}
-
+
+


add comment for long

add comment for long

--- vibrate_alarm_clock.ino
+++ vibrate_alarm_clock.ino
@@ -429,6 +429,7 @@

   int batteryRange = MAX_BATTERY_MILLIVOLT - MIN_BATTERY_MILLIVOLT;

+  //Cast to long as Arduino int is only 16 bits wide. Not enough to
   long numerator =  ((long) ((batteryMilliVolt - MIN_BATTERY_MILLIVOLT))) * 100;
   int batteryPercent = numerator / batteryRange;


clean up code

clean up code

--- arduino/switch_n_led/switch_n_led.ino
+++ arduino/switch_n_led/switch_n_led.ino
@@ -1,4 +1,3 @@
-#include <RCSwitch.h>
 #include <LowPower.h>

 /*
@@ -8,12 +7,7 @@
  * use the switch pin as a interrupt source.
  */

-//RCSwitch rfDevice = RCSwitch();
-
-int SERIAL_COMMUNICATION_SPEED = 9600;
-// How long do we sleep. The longer, the better for the battery but the
-// resolution of our switch will suffer.
-period_t SLEEP_PERIOD = SLEEP_15MS;
+int SERIAL_COMMUNICATION_SPEED = 9600;
 // Pin on which the magnetic swith is plugged.
 int MAGNETIC_SWITCH_PIN = 3;
 // Pin on which the RF device is plugged;
@@ -31,26 +25,17 @@
 void flashLED() {
   digitalWrite(RF_DEVICE_PIN, HIGH);
   delay(50);
-  digitalWrite(RF_DEVICE_PIN, LOW);
+  digitalWrite(RF_DEVICE_PIN, LOW);
 }

 void setup() {
-  /***********************  RF Device initialisation **************************/
   Serial.begin(SERIAL_COMMUNICATION_SPEED);
-  // Transmitter is connected to Arduino Pin #10
-  //rfDevice.enableTransmit(RF_DEVICE_PIN);
-  // Optional set pulse length.
-  // rfDevice.setPulseLength(320);
-  // Optional set protocol (default is 1, will work for most outlets)
-  // rfDevice.setProtocol(2);
-  // Optional set number of transmission repetitions.
-  // rfDevice.setRepeatTransmit(15);
   /*************************  Pins initialisation ****************************/
   // Allow wake up pin to trigger interrupt on state change.
   attachInterrupt(digitalPinToInterrupt(MAGNETIC_SWITCH_PIN), wakeUp, CHANGE);
   // Set the pin to PULLUP so we don't need an additional resistor
   // WARNING, the order of the instruction matters. attachInterrup will
-  // erase the PULLUP switch, so configure the PULLUP after the
+  // erase the PULLUP switch, so configure the PULLUP after the
   // attacheInterrupt
   pinMode(MAGNETIC_SWITCH_PIN, INPUT_PULLUP);
   pinMode(RF_DEVICE_PIN, OUTPUT);


Repeater: Phil: Adjsut node locations and beacon intervals.

--- arduino_repeater/arduino_repeater.ino
+++ arduino_repeater/arduino_repeater.ino
@@ -22,7 +22,7 @@
 #endif
 #ifdef P02
 char id[] = "P02";
-char location_string[] = "50.93623,-1.39876";
+char location_string[] = "50.93613,-1.39592";
 #define BATTV_FUDGE 0.943
 #endif
 #ifdef P5
@@ -30,7 +30,7 @@
 char location_string[] = "50.93897,-1.39774";
 #define BATTV_FUDGE 0.943
 #endif
-#define BEACON_INTERVAL 30
+#define BEACON_INTERVAL 50
 uint8_t rfm_power = 20; // dBmW

 //************* Sensors ****************/


Changes code variable to global

Changes code variable to global

--- booth_controller/booth_controller.ino
+++ booth_controller/booth_controller.ino
@@ -35,6 +35,9 @@

 // countdown timer = 5 seconds
 const long interval = 5000;
+
+// contains the last data received over the i2c bus
+int code;

 void setup() {
   // start I2C slave
@@ -89,7 +92,7 @@
 void receiveData(int numBytes) {
   while (Wire.available()) {
     // capture the data and decide which command it represents
-    int code = Wire.read();
+    code = Wire.read();
     switch (code) {
       case 1:
         armForCountdown();


Added in missing space in comment formatting ...yes, I'm    playing with github to get some practice.  :-)

--- DHT_Test.ino
+++ DHT_Test.ino
@@ -178,7 +178,7 @@
     dtostrf(vdd, 4, 2, vbuff);	// Convert to ASCII and store.

     /*
-     *This delay is for use when testing =without= using deep-sleep
+     * This delay is for use when testing =without= using deep-sleep
      * and should normally be commented-out.
      */
 //    delay(LDELAY);    // Disable this loop delay if using deep-sleep.


Cleaned up hotspot handlers

Cleaned up hotspot handlers

--- PixelVFO.ino
+++ PixelVFO.ino
@@ -14,7 +14,7 @@
 #include "hotspot.h"

 #define MAJOR_VERSION   "1"
-#define MINOR_VERSION   "0"
+#define MINOR_VERSION   "1"

 #define SCREEN_WIDTH    320
 #define SCREEN_HEIGHT   240
@@ -82,10 +82,12 @@
 #define ONLINE_X            0
 #define ONLINE_Y            (ts_height - ONLINE_HEIGHT)
 #define ONLINE_BG           ILI9341_RED
-#define ONLINE_BG2          ILI9341_RED
+#define ONLINE_BG2          0x4000
 #define STANDBY_BG          ILI9341_GREEN
 #define STANDBY_BG2         0x4000
-#define ONLINE_FG           ILI9341_BLACK
+//#define ONLINE_FG           ILI9341_BLACK
+#define ONLINE_FG           ILI9341_GREEN
+#define STANDBY_FG           ILI9341_BLACK

 // MENU button definitions
 #define MENU_WIDTH          110
@@ -208,7 +210,7 @@
     tft.fillRoundRect(ONLINE_X+1, ONLINE_Y+1, ONLINE_WIDTH-2, ONLINE_HEIGHT-2, BUTTON_RADIUS, STANDBY_BG);
     tft.setCursor(ONLINE_X + 7, SCREEN_HEIGHT - 10);
     tft.setFont(FONT_BUTTON);
-    tft.setTextColor(ONLINE_FG);
+    tft.setTextColor(STANDBY_FG);
     tft.print("Standby");
   }
   else
@@ -331,16 +333,16 @@
 // main screen HotSpot definitions
 HotSpot hs_mainscreen[] =
 {
-  {FREQ_OFFSET_X + 0*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, main_hs_handler, 0},
-  {FREQ_OFFSET_X + 1*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, main_hs_handler, 1},
-  {FREQ_OFFSET_X + 2*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, main_hs_handler, 2},
-  {FREQ_OFFSET_X + 3*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, main_hs_handler, 3},
-  {FREQ_OFFSET_X + 4*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, main_hs_handler, 4},
-  {FREQ_OFFSET_X + 5*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, main_hs_handler, 5},
-  {FREQ_OFFSET_X + 6*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, main_hs_handler, 6},
-  {FREQ_OFFSET_X + 7*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, main_hs_handler, 7},
-  {ONLINE_X, ONLINE_Y, ONLINE_WIDTH, ONLINE_HEIGHT, main_hs_handler, 10},
-  {MENU_X, MENU_Y, MENU_WIDTH, MENU_HEIGHT, main_hs_handler, 11},
+  {FREQ_OFFSET_X + 0*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, freq_hs_handler, 0},
+  {FREQ_OFFSET_X + 1*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, freq_hs_handler, 1},
+  {FREQ_OFFSET_X + 2*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, freq_hs_handler, 2},
+  {FREQ_OFFSET_X + 3*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, freq_hs_handler, 3},
+  {FREQ_OFFSET_X + 4*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, freq_hs_handler, 4},
+  {FREQ_OFFSET_X + 5*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, freq_hs_handler, 5},
+  {FREQ_OFFSET_X + 6*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, freq_hs_handler, 6},
+  {FREQ_OFFSET_X + 7*CHAR_WIDTH, 0, CHAR_WIDTH, DEPTH_FREQ_DISPLAY-4, freq_hs_handler, 7},
+  {ONLINE_X, ONLINE_Y, ONLINE_WIDTH, ONLINE_HEIGHT, online_hs_handler, 0},
+  {MENU_X, MENU_Y, MENU_WIDTH, MENU_HEIGHT, menu_hs_handler, 0},
 };

 #define MainScreenHSLen   (sizeof(hs_mainscreen)/sizeof(hs_mainscreen[0]))
@@ -382,6 +384,12 @@
   // draw the 'thousands' markers
   draw_thousands();

+#if 0
+  // draw the 'edge of digits' markers
+  for (int i = 0; i <= NUM_F_CHAR; ++i)
+    tft.drawFastVLine(char_x_offset[i], 44, 6, ILI9341_RED);
+#endif
+
   // show the frequency
   display_frequency();

@@ -389,12 +397,31 @@
 }

 //-----------------------------------------------
-// Main screen hotspot handler.
-//-----------------------------------------------
-
-void main_hs_handler(HotSpot *hs_ptr)
-{
-  Serial.printf("main_hs_handler: hs_ptr->%s\n", hs_display(hs_ptr));
+// Screen hotspot handlers.
+//-----------------------------------------------
+
+bool freq_hs_handler(HotSpot *hs_ptr)
+{
+  Serial.printf("freq_hs_handler: hs_ptr->%s\n", hs_display(hs_ptr));
+  return false;
+}
+
+bool online_hs_handler(HotSpot *hs_ptr)
+{
+  if (vfo_state == VFO_Standby)
+    vfo_state = VFO_Online;
+  else
+    vfo_state = VFO_Standby;
+
+  drawOnline();
+
+  return false;
+}
+
+bool menu_hs_handler(HotSpot *hs_ptr)
+{
+  Serial.printf("menu_hs_handler: would display menu\n");
+  return true;
 }

 //-----------------------------------------------


Renames buzzer_sound to buzzer_play, adds new buzzer_sound

--- buzzer.ino
+++ buzzer.ino
@@ -3,7 +3,7 @@
 #define BUZZER_FREQ_HZ                (4000)

 // standard duration of an alert
-#define BUZZER_DURATION_MS            (250)
+#define BUZZER_DURATION_MS            (50)

 void buzzer_init() {
 }
@@ -12,24 +12,27 @@
  * Plays jingle number n
  */
 void buzzer_jingle(uint8_t n) {
-  buzzer_sound(261, 100);
-  buzzer_sound(293, 100);
-  buzzer_sound(329, 100);
-  buzzer_sound(349, 100);
-  buzzer_sound(391, 100);
-  buzzer_sound(440, 100);
+  buzzer_play(261, 100);
+  buzzer_play(293, 100);
+  buzzer_play(329, 100);
+  buzzer_play(349, 100);
+  buzzer_play(391, 100);
+  buzzer_play(440, 100);
 }

 /**
- * Sounds the buzzer. If freq_hz is 0 then the centre frequency
- * of the piezo is used.
- *
- * If dur_ms is 0, then a default duration of 250 ms is used.
+ * Sounds the buzzer at some default frequency for some default
+ * duration
+ */
+void buzzer_sound() {
+  buzzer_play(440, BUZZER_DURATION_MS);
+}
+
+/**
+ * Plays the tone specified by freq_hz for duration specified by dur_ms. Units
+ * are in Hz and ms respectively.
  */
-void buzzer_sound(uint16_t freq_hz, millis_delta_t dur_ms) {
-  if (freq_hz == 0) freq_hz = BUZZER_FREQ_HZ;
-  if (dur_ms == 0) dur_ms = BUZZER_DURATION_MS;
-
+void buzzer_play(uint16_t freq_hz, millis_delta_t dur_ms) {
   // we need to end SPI b/c we use MISO to control
   // the buzzer
   SPI.end();


Add define to switch between pushbutton press and release

--- Timerino.ino
+++ Timerino.ino
@@ -65,6 +65,9 @@
   - 1: CMG-series (16x2 matrix LCD)
 */
 #define MYMODEL 0
+// change to LOW the following if you want relay be (de)activated on
+// pushbutton *release* instead of *press*
+#define ACTIONSIGNAL HIGH

 #include <Keypad.h>
 #include <avr/eeprom.h>
@@ -756,7 +759,7 @@
     btnstatus = digitalRead(mainbtn);
     if (btnstatus != lastbtnstatus) {
       // main button has been toggled
-      if (btnstatus == HIGH) {
+      if (btnstatus == ACTIONSIGNAL) {
         // main button has been pressed
         btnhigh = true;
       }


naming

naming

--- VardeLED.ino
+++ VardeLED.ino
@@ -13,7 +13,8 @@
 #define RGB_PER_UNIVERSE    RGBW_PER_UNIVERSE*4.0/3.0

 #define NUM_RGB_LEDS_4      (int)ceil(RGB_PER_UNIVERSE * 4)
-#define NUM_RGB_LEDS_3      287 //(int)ceil(RGB_PER_UNIVERSE * 3)
+//#define NUM_RGB_LEDS_3    (int)ceil(RGB_PER_UNIVERSE * 3)
+#define NUM_RGB_LEDS_3      287 // We never use 3 full universes, so cap the length for better performance
 #define NUM_RGB_LEDS_2      (int)ceil(RGB_PER_UNIVERSE * 2)
 #define NUM_RGB_LEDS_1      (int)ceil(RGB_PER_UNIVERSE)

@@ -36,10 +37,10 @@
 byte udp_buffer[600];

 CRGB led_data[NUM_RGB_LEDS_4];
-byte * led_pointer_1 = (byte*)led_data;
-byte * led_pointer_2 = (byte*)led_data + RGBW_PER_UNIVERSE * 4;
-byte * led_pointer_3 = (byte*)led_data + 2*RGBW_PER_UNIVERSE * 4;
-byte * led_pointer_4 = (byte*)led_data + 3*RGBW_PER_UNIVERSE * 4;
+byte * led_data_ptr_1 = (byte*)led_data;
+byte * led_data_ptr_2 = (byte*)led_data + RGBW_PER_UNIVERSE * 4;
+byte * led_data_ptr_3 = (byte*)led_data + 2*RGBW_PER_UNIVERSE * 4;
+byte * led_data_ptr_4 = (byte*)led_data + 3*RGBW_PER_UNIVERSE * 4;

 bool locateMode = false;

@@ -106,6 +107,7 @@
   // Open ArtNet
   node = ArtNode(config, sizeof(udp_buffer), udp_buffer);

+  // Create 4 outputs with different lengths (can be tweaked)
   FastLED.addLeds<WS2812, PIN_LED_1, RGB>(led_data, NUM_RGB_LEDS_3);
   FastLED.addLeds<WS2812, PIN_LED_2, RGB>(led_data, NUM_RGB_LEDS_3);
   FastLED.addLeds<WS2812, PIN_LED_3, RGB>(led_data, NUM_RGB_LEDS_2);
@@ -146,39 +148,41 @@
               ArtDmx* dmx = (ArtDmx*)udp_buffer;
               int port = node.getPort(dmx->SubUni, dmx->Net);
               if (!locateMode && port >= 0 && port < 4) {
-                // Bit swap length from dmx packet
-                int l = ((dmx->Length & 0xF) << 8) + ((dmx->Length & 0xF0) >> 8);
+                // Calculate length of DMX packet. Requires bit swap length from dmx packet
+                int dmx_length = ((dmx->Length & 0xF) << 8) + ((dmx->Length & 0xF0) >> 8);

                 // Check if length is longer then allocated data
-                if (l > RGBW_PER_UNIVERSE * 4) {
-                  l = RGBW_PER_UNIVERSE * 4;
+                if (dmx_length > RGBW_PER_UNIVERSE * 4) {
+                  dmx_length = RGBW_PER_UNIVERSE * 4;
                 }

                 switch (port) {
                   case 0: {
-                      memcpy(led_data, dmx->Data, l);
+                      // Copy dmx data to the first 1/4 of led_data
+                      memcpy(led_data_ptr_1, dmx->Data, dmx_length);
                       FastLED[0].show(led_data, NUM_RGB_LEDS_1, 255);
                       break;
                     }
-                  case 1: {
-                      memcpy(led_pointer_2, dmx->Data, l);
-                      FastLED[0].show((CRGB*)led_pointer_1, NUM_RGB_LEDS_2, 255);
-                      FastLED[1].show((CRGB*)led_pointer_2, NUM_RGB_LEDS_1, 255);
+                  case 1: {
+                      // Copy dmx data to the second 1/4 of the led_data
+                      memcpy(led_data_ptr_2, dmx->Data, dmx_length);
+                      FastLED[0].show((CRGB*)led_data_ptr_1, NUM_RGB_LEDS_2, 255);
+                      FastLED[1].show((CRGB*)led_data_ptr_2, NUM_RGB_LEDS_1, 255);
                       break;
                     }
                   case 2: {
-                      memcpy(led_pointer_3, dmx->Data, l);
-                      FastLED[0].show((CRGB*)led_pointer_1, NUM_RGB_LEDS_3, 255);
-                      FastLED[1].show((CRGB*)led_pointer_2, NUM_RGB_LEDS_2, 255);
-                      FastLED[2].show((CRGB*)led_pointer_3, NUM_RGB_LEDS_1, 255);
+                      memcpy(led_data_ptr_3, dmx->Data, dmx_length);
+                      FastLED[0].show((CRGB*)led_data_ptr_1, NUM_RGB_LEDS_3, 255);
+                      FastLED[1].show((CRGB*)led_data_ptr_2, NUM_RGB_LEDS_2, 255);
+                      FastLED[2].show((CRGB*)led_data_ptr_3, NUM_RGB_LEDS_1, 255);
                       break;
                     }
                   case 3: {
-                      memcpy(led_pointer_4, dmx->Data, l);
-                      //FastLED[0].show((CRGB*)led_pointer_1, NUM_RGB_LEDS_4, 255);
-                      FastLED[1].show((CRGB*)led_pointer_2, NUM_RGB_LEDS_3, 255);
-                      FastLED[2].show((CRGB*)led_pointer_3, NUM_RGB_LEDS_2, 255);
-                      FastLED[3].show((CRGB*)led_pointer_4, NUM_RGB_LEDS_1, 255);
+                      memcpy(led_data_ptr_4, dmx->Data, dmx_length);
+                      //FastLED[0].show((CRGB*)led_data_ptr_1, NUM_RGB_LEDS_4, 255);
+                      FastLED[1].show((CRGB*)led_data_ptr_2, NUM_RGB_LEDS_3, 255);
+                      FastLED[2].show((CRGB*)led_data_ptr_3, NUM_RGB_LEDS_2, 255);
+                      FastLED[3].show((CRGB*)led_data_ptr_4, NUM_RGB_LEDS_1, 255);
                       break;
                     }
                 }


Adding default definition for LED_BUILTIN.

--- support/Arduino/OneInOneOutASCII/OneInOneOutASCII.ino
+++ support/Arduino/OneInOneOutASCII/OneInOneOutASCII.ino
@@ -72,6 +72,12 @@

 // The maximum number of tokens in a single message.
 #define MAX_TOKENS 10
+
+// Some version of the Arduino IDE don't correctly define this symbol for an
+// Arduino Uno.
+#ifndef LED_BUILTIN
+#define LED_BUILTIN 13
+#endif

 /****************************************************************/
 /**** Utility functions *****************************************/


removing old source

removing old source

--- guitar.ino
+++ guitar.ino
@@ -1,175 +0,0 @@
-/*
-N = pick string
-   - block laser beam -> plays tone
-   - unblock laser beam -> do nothing
-
-len=release tab
-   - stop tone playing
-
-stop all tones button
-   - stop all tones
-
-/ = slide up
-   - needs to be tabbed with two finger next to each other and slide
-   - pitch of tone changes when following change on tabs is detected
-     - t1 is pressed > t1+t2 is pressed > t2 is pressed
-       where t1 can be > or < t2 with max distance 1
-
-\ = slide down
-   - see slide up
-
-h = hammer-on
-   - if more far tab is pressed and closer (max 4 tabs away) tab is pressed and depressed -> new tone is played
-     - if tone was played -> play new tone louder
-     - if tone did not play -> play new tone relativeli quiet
-
-p = pull-off
-   - not supported due to gesture not possible
-
-~ = vibrato
-   - using long lever
-
-+ = harmonic
-   - no need to suppot it yet
-
-x = Dead note
-   - disabled in chord library
-
-b = Bend
-   - using long vibrato lever
-pb = Pre-bend
-br = Bend release
-pbr = Pre-bend release
-brb = Bend release bend
-*/
-
-int fret_pins[12] = {22,23,24,25,26,27,28,29,30,31,32,33};
-int string_pins[6]= {36,37,38,39,40,41};
-int laser_pins[6] = {46,47,48,49,50,51};
-int emphasis_pin  = 52;
-int stop_tone_pin = 53;
-
-boolean fret_status[12][6];
-boolean laser_status[6];
-boolean emphasis_status = false;
-boolean stop_tone_status = false;
-
-inline void init_digital_in(int pin) {
-  pinMode(pin, INPUT);
-  digitalWrite(pin, HIGH);
-}
-
-inline boolean is_fret_pressed(int f) {
-  return digitalRead(fret_pins[f]);
-}
-
-//put hesitation delay in this function to prevent jitter when laser pressed half-way
-inline boolean is_laser_blocked(int l) {
-  //TODO prevent jitter
-  return digitalRead(laser_pins[l]);
-}
-
-inline boolean is_emphasis_blocked() {
-  return digitalRead(emphasis_pin);
-}
-
-inline boolean is_stop_tone_pressed() {
-  //TODO debounce
-  return digitalRead(stop_tone_pin);
-}
-
-inline void set_string(int s) {
-  digitalWrite(string_pins[s], HIGH);
-}
-
-inline void unset_string(int s) {
-  digitalWrite(string_pins[s], LOW);
-}
-
-inline void send_fret_event(boolean pressed, int f, int s) {
-  if (Serial.availableForWrite() >= 1)
-    Serial.write(s * 12 + f + 1);
-}
-
-inline void send_laser_event(boolean laser_blocked, int l) {
-  if (Serial.availableForWrite() >= 1)
-    Serial.write(78 + l + 128 * laser_blocked);
-}
-
-inline void send_emphasis_event(boolean emphasis_blocked) {
-  if (Serial.availableForWrite() >= 1)
-    Serial.write(84 + 128 * emphasis_blocked);
-}
-
-inline void send_stop_tone_event() {
-  if (Serial.availableForWrite() >= 1)
-    Serial.write(85);
-}
-
-//-------------------------
-void setup()
-{
-  Serial.begin(115200);
-
-  //zero fret_status
-  for (int f = 0; f <= 11; f++) {
-    for (int s = 0; s <= 5; s++) {
-      fret_status[f][s] = 0;
-    }
-  }
-  //zero laser_status
-  for (int l = 0; l <= 5; l++) {
-    laser_status[l] = 0;
-    init_digital_in(laser_pins[l]);
-  }
-
-  //init input pins with internal pullup resistors
-  init_digital_in(emphasis_pin);
-  init_digital_in(stop_tone_pin);
-}
-
-//-------------------------
-void loop()
-{
-  //scan string by string
-  for (int s = 0; s <= 5; s++) {
-    set_string(s);
-
-    //scan frets for this string
-    for (int f = 0; f <= 11; f++) {
-      boolean pressed = is_fret_pressed(f);
-      //emit event if status changed
-      if (pressed ^ fret_status[f][s]) {
-        send_fret_event(pressed, f, s);
-      }
-      fret_status[f][s] = pressed;
-    }
-    unset_string(s);
-
-    //read emphasis laser
-    boolean emphasis_blocked = is_emphasis_blocked();
-    if (emphasis_blocked ^ emphasis_status) {
-      send_emphasis_event(emphasis_blocked);
-    }
-    emphasis_status = emphasis_blocked;
-
-    //scan lasers (in time-multiplex to keep high scan freq)
-    for (int l = 0; l <= 5; l++) {
-      boolean laser_blocked = is_laser_blocked(l);
-      if (laser_blocked ^ laser_status[l]) {
-        send_laser_event(laser_blocked, l);
-      }
-      laser_status[l] = laser_blocked;
-    }
-
-    //read stop_tone button
-    boolean st = is_stop_tone_pressed();
-    if (st ^ stop_tone_status) {
-      send_stop_tone_event();
-    }
-    stop_tone_status = st;
-
-
-  }
-
-}


move setup function up

move setup function up

--- vibrate_alarm_clock.ino
+++ vibrate_alarm_clock.ino
@@ -65,6 +65,61 @@
 int previousNoteDuration;

 boolean showLCD = true;
+
+void setup(){
+
+  #ifndef DO_NOT_SHOW_SERIAL_OUT
+    Serial.begin(9600);
+  #endif
+
+ //Turn off TX and RX pin
+  pinMode(RXLED_PIN, OUTPUT);
+  digitalWrite(RXLED_PIN, LOW);
+  TXLED1;
+
+  Wire.begin();
+  RTC.begin();
+
+
+  // This section grabs the current datetime and compares it to
+  // the compilation time.  If necessary, the RTC is updated.
+  DateTime now = RTC.now();
+  DateTime compiled = DateTime(__DATE__, __TIME__);
+
+  if (now.unixtime() < compiled.unixtime()) {
+    RTC.adjust(DateTime(__DATE__, __TIME__));
+  }
+
+
+  // initialize with the OLED with I2C addr 0x3D (for the 128x64)
+  display.begin(SSD1306_SWITCHCAPVCC, 0x3D);
+
+  display.dim(DISPLAY_CONTRAST);
+
+  display.clearDisplay();
+  display.setTextColor(WHITE);
+  display.setTextSize(1);
+  display.setCursor(0,0);
+  display.println(INITIAL_TEXT);
+
+
+  display.display();
+
+
+  delay(INITIAL_TEXT_DELAY);
+
+
+  pinMode(LEFT_BUTTON_PIN, INPUT);
+  pinMode(MIDDLE_BUTTON_PIN, INPUT);
+  pinMode(RIGHT_BUTTON_PIN, INPUT);
+  pinMode(VOLTAGE_MEASURE_PIN, INPUT);
+
+  pinMode(MOTOR_PIN1, OUTPUT);
+  pinMode(MOTOR_PIN2, OUTPUT);
+  pinMode(MOTOR_SLEEP_PIN, OUTPUT);
+
+}
+

 void loop(){

@@ -754,62 +809,3 @@
   return (newValue % 60 + 60) % 60;
 }

-void setup(){
-
-  #ifndef DO_NOT_SHOW_SERIAL_OUT
-    Serial.begin(9600);
-  #endif
-
- //Turn off TX and RX pin
-  pinMode(RXLED_PIN, OUTPUT);
-  digitalWrite(RXLED_PIN, LOW);
-  TXLED1;
-
-  Wire.begin();
-  RTC.begin();
-
-
-  // This section grabs the current datetime and compares it to
-  // the compilation time.  If necessary, the RTC is updated.
-  DateTime now = RTC.now();
-  DateTime compiled = DateTime(__DATE__, __TIME__);
-
-  if (now.unixtime() < compiled.unixtime()) {
-    RTC.adjust(DateTime(__DATE__, __TIME__));
-  }
-
-
-  // initialize with the OLED with I2C addr 0x3D (for the 128x64)
-  display.begin(SSD1306_SWITCHCAPVCC, 0x3D);
-
-  display.dim(DISPLAY_CONTRAST);
-
-  display.clearDisplay();
-  display.setTextColor(WHITE);
-  display.setTextSize(1);
-  display.setCursor(0,0);
-  display.println(INITIAL_TEXT);
-
-
-  display.display();
-
-
-  delay(INITIAL_TEXT_DELAY);
-
-
-  pinMode(LEFT_BUTTON_PIN, INPUT);
-  pinMode(MIDDLE_BUTTON_PIN, INPUT);
-  pinMode(RIGHT_BUTTON_PIN, INPUT);
-  pinMode(VOLTAGE_MEASURE_PIN, INPUT);
-
-  pinMode(MOTOR_PIN1, OUTPUT);
-  pinMode(MOTOR_PIN2, OUTPUT);
-  pinMode(MOTOR_SLEEP_PIN, OUTPUT);
-
-}
-
-
-
-
-
-


Preliminary lower-right room code

Preliminary lower-right room code

Waiting on a better move function where we can actually specify the distance

--- 2018-Firefighter/lowerRightRoomL1/lowerRightRoomL1.ino
+++ 2018-Firefighter/lowerRightRoomL1/lowerRightRoomL1.ino
@@ -1,4 +1,34 @@
 void lowerRightRoom(){
+  turn(0); //turn(0) is a way to reset gyro measurements

+  turn(-20); //turn the robot 45, but since it's so close to the wall, this needs to happen gradually
+  moveForward();
+  delay(1000);
+  stopRobot();
+  turn(0);
+  turn(-25);
+
+  moveForward();  //CHANGE THIS BLOCK WHEN WE HAVE A BETTER MOVE FUNCTION
+  delay(5000);
+  stopRobot();
+
+  turn(0);
+  turn(-90);
+  delay(1000);  //see if there's fire in the upper corner
+  turn(180);
+  delay(1000);  //see if there's fire in the lower corner
+  turn(0);
+  turn(-45);
+
+  while(frontRightUltrasonic.getDistance() > closeToWall && frontLeftUltrasonic.getDistance() > closeToWall){ //roll forward until the robot gets close to the lower wall
+    moveForward();
+  }
+  stopRobot();
+
+  turn(-90);  //turn right towards the exit of the room
+  moveForward();  //AGAIN, CHANGE THIS WHEN WE HAVE A BETTER MOVE FUNCTION
+  delay(3000);
+  stopRobot();
+  turn(0);
 }


Reduced memory and variable usage

Reduced memory and variable usage

--- WebastoHeaterWBusArduinoInterface.ino
+++ WebastoHeaterWBusArduinoInterface.ino
@@ -58,11 +58,11 @@
 char textline1[15];
 char textline2[15];

-uint8_t dt_day = 1;
-uint8_t dt_month = 1;
-uint8_t dt_year = 12;
-uint8_t ti_hour = 1;
-uint8_t ti_mins = 1;
+//uint8_t dt_day = 1;
+//uint8_t dt_month = 1;
+//uint8_t dt_year = 12;
+//uint8_t ti_hour = 1;
+//uint8_t ti_mins = 1;

 uint8_t total_lines1 = 0;
 uint8_t first_visible_line1 = 0;
@@ -77,6 +77,7 @@
 bool updatedisplay;
 uint8_t footerToggle = 0;
 wb_sensor_t KeepAlive_wb_sensors;
+tmElements_t tm;

 //Display 84x48 pixels
@@ -105,7 +106,7 @@
 M2_ALIGN(el_bigclock, NULL, &vlist_clocklist);

 /* MAIN MENU */
-M2_STRLIST(el_strlist_menu, "l3w76" , &first_visible_line1, &total_menu_items, el_strlist_getstr);
+M2_STRLIST(el_strlist_menu, "l3w76" , &first_visible_line1, &total_menu_items, el_strlist_mainmenu);
 M2_VSB(el_vsb_menu, "l3w4" , &first_visible_line1, &total_menu_items);
 M2_LIST(list_menu_strlist) = { &el_strlist_menu, &el_vsb_menu };
 M2_HLIST(el_menu_hlist, NULL, list_menu_strlist);
@@ -128,19 +129,19 @@
 /* SET DATE */

 //= Set date menu =
-M2_U8NUM(el_dt_day, "c2", 1, 31, &dt_day);
+M2_U8NUM(el_dt_day, "c2", 1, 31, &tm.Day);
 M2_LABEL(el_dt_sep1, NULL, "/");
-M2_U8NUM(el_dt_month, "c2", 1, 12, &dt_month);
+M2_U8NUM(el_dt_month, "c2", 1, 12, &tm.Month);
 M2_LABEL(el_dt_sep2, NULL, "/20");
-M2_U8NUM(el_dt_year, "c2", 15, 35, &dt_year);
+M2_U8NUM(el_dt_year, "c2", 15, 35, &tm.Year);

 M2_LIST(list_date) = { &el_dt_day, &el_dt_sep1, &el_dt_month, &el_dt_sep2, &el_dt_year };
 M2_HLIST(el_date, NULL, list_date);

 //= Set time menu =
-M2_U8NUM(el_ti_hour, "c2", 0, 23, &ti_hour);
+M2_U8NUM(el_ti_hour, "c2", 0, 23, &tm.Hour);
 M2_LABEL(el_ti_sep1, NULL, ":");
-M2_U8NUM(el_ti_mins, "c2", 0, 59, &ti_mins);
+M2_U8NUM(el_ti_mins, "c2", 0, 59, &tm.Minute);

 M2_LIST(list_time) = { &el_ti_hour, &el_ti_sep1, &el_ti_mins};
 M2_HLIST(el_time, NULL, list_time);
@@ -326,7 +327,7 @@
 }

-void fn_clear_faults() {
+inline void fn_clear_faults() {
   clearBuffer();
   char* v = value;

@@ -354,17 +355,15 @@
   return v;
 }

-
-
 unsigned long getTimeFunction() {
   tmElements_t tm;

   if (RTC.read(tm)) {
     return makeTime(tm);
-  }
+  }

   //Error so just return what we already have
-  else return now();
+  return now();
 }

@@ -372,7 +371,6 @@
   if (timeStatus() != timeNotSet) {
     tmElements_t tm;
     breakTime(now(), tm);
-

     char* v = textline1;
     v = i2str_zeropad( tm.Hour, v);
@@ -405,8 +403,9 @@
 }

-const char *el_strlist_getstr(uint8_t idx, uint8_t msg) {
+const char *el_strlist_mainmenu(uint8_t idx, uint8_t msg) {
   char *v = value;
+  v[0] = 0;

   switch (idx)
   {
@@ -431,9 +430,6 @@
     case 6:
       strcpy_P(v, label_menu_fuelprime);
       break;
-    default:
-      //Null terminate string, just in case
-      v[0] = 0;
   };

   if ( msg == M2_STRLIST_MSG_SELECT ) {
@@ -476,7 +472,7 @@
         break;

       case 5:
-        fn_showdatetime();
+        fn_begin_set_date_time();
         break;

       case 6:
@@ -491,37 +487,16 @@
   return value;
 }

-
-
-void fn_showdatetime() {
-  tmElements_t tm;
+inline void fn_begin_set_date_time() {
   breakTime(getTimeFunction(), tm);
-
-  ti_hour = tm.Hour;
-  ti_mins = tm.Minute;
-
-  dt_day = tm.Day;
-  dt_month = tm.Month;
-  dt_year = tmYearToY2k(tm.Year);
-
+  tm.Year = tmYearToY2k(tm.Year);
   m2.setRoot(&el_top_dt);
 }

-
-void fn_button_confirmdatetime(m2_el_fnarg_p fnarg) {
-  tmElements_t tm;
-
-  tm.Hour = ti_hour;
-  tm.Minute = ti_mins;
-  tm.Second = 0;
-
-  tm.Day = dt_day;
-  tm.Month = dt_month;
-  tm.Year = y2kYearToTm(dt_year);
-
+inline void fn_button_confirmdatetime(m2_el_fnarg_p fnarg) {
+  tm.Year = y2kYearToTm(tm.Year);
   //Set the DS1307 RTC chip
   RTC.write(tm);
-
   home_menu();
 }


Update SDAnimation.ino

Update SDAnimation.ino

--- arduino-controller/SDAnimation.ino
+++ arduino-controller/SDAnimation.ino
@@ -7,9 +7,9 @@
 {
 	Serial.begin(9600);

-	pinMode(10, OUTPUT); // change this to 53 on a mega
+	pinMode(10, OUTPUT); // SS pin must be output, change this to 53 on a mega

-	bool sd_ok = SD.begin(9);
+	bool sd_ok = SD.begin(9); // chip select pin

 	if (!sd_ok)
 	{
@@ -49,7 +49,7 @@
 		char *p = file.name();
 		char *p_dot = strchr(p, '.');

-		if (p_dot != NULL && strcmp(p_dot, ".DAT") == 0)
+		if (p_dot != NULL && strcmp(p_dot, ".dat") == 0)
 		{
 			readAnimation(file);
 		}


Arduino: Add empirical rescaling for resistance

--- humidity1/humidity1.ino
+++ humidity1/humidity1.ino
@@ -100,6 +100,9 @@
     // if in range, calculate resistance value
     resistance = Re / ((Vref-Vm)/(voltage-Vm) - 1);
   }
+  // Empirical adjustment for the 1/s repetition rate
+  // because of the decay of capacitors during measurement
+  resistance = resistance / 0.9;
   return (resistance);
 }


Animate movement left/right

Animate movement left/right

--- attolass.ino
+++ attolass.ino
@@ -31,7 +31,10 @@
 uint8_t sectionOffset;          // Offset between the levelPosition and start of the position of the first section
 position_t playerX = PLAYER_POSITION_CENTER;
 position_t playerY = SCREEN_HEIGHT / 2;
-bool jumping;                   // Currently in a jump
+bool jumping = false;           // Currently in a jump
+bool moving = false;            // Currently moving left/right
+const uint8_t FPS = 30;
+uint8_t frame = 0;              // Frame number that loops back to 0 when it reaches FPS

 void updatePlayer() {
     if (arduboy.pressed(LEFT_BUTTON)) {
@@ -41,20 +44,25 @@
         if (playerX > 0) {
             playerX--;
         }
+        moving = true;
         // TODO: Update level pointer and sectionOffset
     }
-    if (arduboy.pressed(RIGHT_BUTTON)) {
+    else if (arduboy.pressed(RIGHT_BUTTON)) {
         playerX++;
         if (playerX >= PLAYER_POSITION_CENTER) {
             levelPosition++;
         }
+        moving = true;
         // TODO: Update level pointer and sectionOffset
+    }
+    else {
+        moving = false;
     }
     jumping = arduboy.pressed(A_BUTTON);
 }

 void drawLevel() {
-    // TODO: Allow a pixel offset
+    // TODO: Allow drawing using sectionOffset
     const level_t* pointer = level;
     level_t current = pgm_read_byte_near(pointer);
     coord_t x,y,width,height;
@@ -88,11 +96,18 @@
 }

 void drawPlayer() {
+    position_t drawPlayerX = playerX - levelPosition;
     if (jumping) {
-        arduboy.drawBitmap(playerX - levelPosition, playerY - 10, SPRITE(attolass_jump), BLACK);
+        arduboy.drawBitmap(drawPlayerX, playerY - 10, SPRITE(attolass_jump), BLACK);
+    }
+    else if (!moving) {
+        arduboy.drawBitmap(drawPlayerX, playerY, SPRITE(attolass_stand), BLACK);
+    }
+    else if ((frame % 6) < 3) {
+        arduboy.drawBitmap(drawPlayerX, playerY, SPRITE(attolass_walk_1), BLACK);
     }
     else {
-        arduboy.drawBitmap(playerX - levelPosition, playerY, SPRITE(attolass_stand), BLACK);
+        arduboy.drawBitmap(drawPlayerX, playerY, SPRITE(attolass_walk_2), BLACK);
     }
 }

@@ -101,7 +116,7 @@
     Serial.begin(9600);
 #endif
     arduboy.begin();
-    arduboy.setFrameRate(30);
+    arduboy.setFrameRate(FPS);

     level = levelStart = res_level_concept;
 }
@@ -119,6 +134,7 @@
     // pause render until it's time for the next frame
     if (!(arduboy.nextFrame()))
         return;
+    frame = (frame + 1) % FPS;
     // TODO: Allow scrolling level offset and redrawing
     // TODO: Allow character to move around and animate
     updatePlayer();


fixes comment typo in fona gps example

fixes comment typo in fona gps example

--- arduino-fona/gps/gps.ino
+++ arduino-fona/gps/gps.ino
@@ -92,8 +92,7 @@

   Serial.println(F("Adafruit FONA GPS MQTT demo"));

-  // Initialise the FONA module
-  while (! FONAconnect(F(FONA_APN), F(FONA_USERNAME), F(FONA_PASSWORD)))
+  if (! FONAconnect(F(FONA_APN), F(FONA_USERNAME), F(FONA_PASSWORD)))
     halt("Retrying FONA");

   Serial.println(F("Connected to Cellular!"));


change  led pin

change  led pin

--- jllockuno/jllockuno.ino
+++ jllockuno/jllockuno.ino
@@ -28,14 +28,15 @@
 #define ENABLE_STEPER 6
 #define SETP 5
 #define DIR 4
-
+#define LED 8

 MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance
 char charreceive;

+
 void setup() {
-       pinMode(7, OUTPUT);
+       pinMode(LED, OUTPUT);
       pinMode(ENABLE_STEPER,OUTPUT); // Enable
       pinMode(SETP,OUTPUT); // Step
       pinMode(DIR,OUTPUT); // Dir
@@ -86,10 +87,10 @@
         delay(2);
         if(charreceive=='Y')
           {
-            digitalWrite(7, HIGH);   // turn the LED on (HIGH is the voltage level)
-            delay(1000);              // wait for a second
-            digitalWrite(7, LOW);    // turn the LED off by making the voltage LOW
-            delay(1000);              // wait for a second
+            digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
+            delay(500);              // wait for a second
+            digitalWrite(LED, LOW);    // turn the LED off by making the voltage LOW
+            delay(500);              // wait for a second

             // open the door


fix com error that lets ff through

fix com error that lets ff through

--- bot_base.ino
+++ bot_base.ino
@@ -26,7 +26,9 @@
 }

 void loop(){
-  commandHandler(commandListen(Serial.read()));
+  if(Serial.available()){
+    commandHandler(commandListen(Serial.read()));
+  }
   /* pass the result of read into listener and listen into handler.
    * these are passed like this as a reminder that only one char is read on
    * any given program loop, new command processed when packet is finished
@@ -44,7 +46,7 @@
   // reset if a full packet has been recieved
   if(packet[0] && packet[1]){packet[0] = 0; packet[1] = 0;}

-  if(incoming != 0xFF){     // data available from Serial? 0xff signals no data
+  if(incoming){     // data available from Serial? 0xff signals no data
     if(packet[0]){          // do we already have the first char in packet?
       packet[1] = incoming; // then this this the second
       return packet;        // in this case a "packet" is 2 chars, we are done


Zahlenraum anpassen

Zahlenraum anpassen

--- QTRARawValuesExample.ino
+++ QTRARawValuesExample.ino
@@ -59,11 +59,11 @@
   float KD = 5;   //floating-point derivative constant
   int error = position - 3000;

-  int motorSpeed =  error + KD * (error - lastError);
+  int  =  error + KD * (error - lastError);
   lastError = error;

-  int m1Speed = M1 + motorSpeed;
-  int m2Speed = M2 - motorSpeed;
+  int m1Speed = (M1 + motorSpeed)*0.1275;
+  int m2Speed = (M2 - motorSpeed)*0.1275;

   if (m1Speed < 0)
     m1Speed = 0;


Update mDNS examples to use HTTP Server instead of TCP Server (#5589)

--- libraries/ESP8266mDNS/examples/LEAmDNS/mDNS_ServiceMonitor/mDNS_ServiceMonitor.ino
+++ libraries/ESP8266mDNS/examples/LEAmDNS/mDNS_ServiceMonitor/mDNS_ServiceMonitor.ino
@@ -32,6 +32,7 @@

 #include <ESP8266WiFi.h>
 #include <WiFiClient.h>
+#include <ESP8266WebServer.h>

 /*
    Include the MDNSResponder (the library needs to be included also)
@@ -69,8 +70,8 @@
 const String                                   cstrNoHTTPServices      = "Currently no 'http.tcp' services in the local network!
";
 String                                         strHTTPServices         = cstrNoHTTPServices;

-// TCP server at port 'SERVICE_PORT' will respond to HTTP requests
-WiFiServer                                     server(SERVICE_PORT);
+// HTTP server at port 'SERVICE_PORT' will respond to HTTP requests
+ESP8266WebServer                                     server(SERVICE_PORT);

 /*
@@ -145,21 +146,19 @@
       strHTTPServices = "";
       for (uint32_t u = 0; u < u32Answers; ++u) {
         // Index and service domain
-        strHTTPServices += u;
-        strHTTPServices += ": ";
+        strHTTPServices += "
";
         strHTTPServices += p_pMDNSResponder->answerServiceDomain(p_hServiceQuery, u);
         // Host domain and port
         if ((p_pMDNSResponder->hasAnswerHostDomain(p_hServiceQuery, u)) &&
             (p_pMDNSResponder->hasAnswerPort(p_hServiceQuery, u))) {
-
-          strHTTPServices += " at ";
+          strHTTPServices += "
Hostname: ";
           strHTTPServices += p_pMDNSResponder->answerHostDomain(p_hServiceQuery, u);
           strHTTPServices += ":";
           strHTTPServices += p_pMDNSResponder->answerPort(p_hServiceQuery, u);
         }
         // IP4 address
         if (p_pMDNSResponder->hasAnswerIP4Address(p_hServiceQuery, u)) {
-          strHTTPServices += " IP4: ";
+          strHTTPServices += "
IP4: ";
           for (uint32_t u2 = 0; u2 < p_pMDNSResponder->answerIP4AddressCount(p_hServiceQuery, u); ++u2) {
             if (0 != u2) {
               strHTTPServices += ", ";
@@ -169,10 +168,10 @@
         }
         // MDNS TXT items
         if (p_pMDNSResponder->hasAnswerTxts(p_hServiceQuery, u)) {
-          strHTTPServices += " TXT: ";
+          strHTTPServices += "
TXT: ";
           strHTTPServices += p_pMDNSResponder->answerTxts(p_hServiceQuery, u);
         }
-        strHTTPServices += "
";
+        strHTTPServices += "
";
       }
     } else {
       strHTTPServices = cstrNoHTTPServices;
@@ -180,7 +179,6 @@
   }
   return true;
 }
-

 /*
    MDNSProbeResultCallback
@@ -246,57 +244,23 @@
   return true;
 }

-
-/*
-   handleHTTPClient
-*/
-void handleHTTPClient(WiFiClient& client) {
+/*
+   HTTP request function (not found is handled by server)
+*/
+void handleHTTPRequest() {
   Serial.println("");
-  Serial.println("New client");
-
-  // Wait for data from client to become available
-  while (client.connected() && !client.available()) {
-    delay(1);
-  }
-
-  // Read the first line of HTTP request
-  String req = client.readStringUntil('\r');
-
-  // First line of HTTP request looks like "GET /path HTTP/1.1"
-  // Retrieve the "/path" part by finding the spaces
-  int addr_start = req.indexOf(' ');
-  int addr_end = req.indexOf(' ', addr_start + 1);
-  if (addr_start == -1 || addr_end == -1) {
-    Serial.print("Invalid request: ");
-    Serial.println(req);
-    return;
-  }
-  req = req.substring(addr_start + 1, addr_end);
-  Serial.print("Request: ");
-  Serial.println(req);
-  client.flush();
-
-  String s;
-  if (req == "/") {
-    IPAddress ip = WiFi.localIP();
-    String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
-    s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\nHello from ";
-    s += WiFi.hostname() + " at " + ipStr;
-    // Simple addition of the current time
-    s += "
Local HTTP services:
";
-    s += strHTTPServices;
-    // done :-)
-    s += "\r\n\r\n";
-    Serial.println("Sending 200");
-  } else {
-    s = "HTTP/1.1 404 Not Found\r\n\r\n";
-    Serial.println("Sending 404");
-  }
-  client.print(s);
-
-  Serial.println("Done with client");
-}
-
+  Serial.println("HTTP Request");
+
+  String s = "<!DOCTYPE HTML>\r\n
Hello from ";
+  s += WiFi.hostname() + ".local at " + WiFi.localIP().toString() + "
";
+  s += "

Local HTTP services are :

";
+  s += strHTTPServices;
+  // done :-)
+  s += "
";
+  Serial.println("Sending 200");
+  server.send(200, "text/html", s);
+  Serial.println("Done with request");
+}

 /*
    setup
@@ -320,6 +284,9 @@
   Serial.println(ssid);
   Serial.print("IP address: ");
   Serial.println(WiFi.localIP());
+
+  // Setup HTTP server
+  server.on("/", handleHTTPRequest);

   // Setup MDNS responder
   MDNS.setProbeResultCallback(MDNSProbeResultCallback, 0);
@@ -333,9 +300,9 @@
   }
   Serial.println("MDNS responder started");

-  // Start TCP (HTTP) server
+  // Start HTTP server
   server.begin();
-  Serial.println("TCP server started");
+  Serial.println("HTTP server started");
 }

@@ -343,14 +310,8 @@
    loop
 */
 void loop(void) {
-  // Check if a client has connected
-  WiFiClient    client = server.available();
-  if (client) {
-    handleHTTPClient(client);
-  }
-
+  // Check if a request has come in
+  server.handleClient();
   // Allow MDNS processing
   MDNS.update();
 }
-
-


A few fixes to handle maLevel properly

A few fixes to handle maLevel properly

--- arduino/rfglow_panstamp_ble/rfglow_panstamp_ble.ino
+++ arduino/rfglow_panstamp_ble/rfglow_panstamp_ble.ino
@@ -50,6 +50,7 @@
 unsigned long previousMs = 0;
 unsigned int sends = 255;
 unsigned int target_hue = 0, target_saturation = 0, target_brightness = 0, target_fade_ms = 0;
+unsigned int maLevel = 0;
 unsigned int current_hue = 0, current_saturation = 0, current_brightness = 0;
 long fade_dH = 0, fade_dS = 0, fade_dV = 0;
 unsigned long fade_start_ms = 0;
@@ -146,11 +147,17 @@
 //  DEBUG_PRINTLN("");

   if (len == 4 || len == 6) {
+    sends = 0;
+
     // 4 bytes means treat as 1 16-bit and 2 8-bit uints directly
     target_hue = (buffer[0] << 8) + buffer[1];
     target_saturation = buffer[2];
     target_brightness = buffer[3];
-    sends = 0;
+
+    // Extract maLevel to put back later, otherwuse 360 degree logic gets screwed up
+    maLevel = target_hue / 360;
+    target_hue = target_hue % 360;
+
     DEBUG_PRINTLN("Directly read: HSV=("+target_hue+"h, "+target_saturation+"s, "+target_brightness+"v)");
     if (len == 6) {
       target_fade_ms = (buffer[4] << 8) | buffer[5];
@@ -250,8 +257,15 @@
     current_saturation = target_saturation - dS;
     current_brightness = target_brightness - dV;
   }
-
-  sendCommand(current_hue, current_saturation, current_brightness);
+
+  // Add the maLevel back in when we send, and don't accidentally jump to another level.
+  uint16_t send_hue = current_hue;
+  if (send_hue == 360) {
+    send_hue = 0;
+  }
+  send_hue = send_hue + 360*maLevel;
+
+  sendCommand(send_hue, current_saturation, current_brightness);
 }

 void sendCommand(uint16_t hue, uint8_t saturation, uint8_t brightness) {


to make it more accurate maybe

to make it more accurate maybe

--- dorm-leds.ino
+++ dorm-leds.ino
@@ -85,18 +85,18 @@
 	init_lcd();

 	// mount other devices
+	Serial.println(F("Mounting Additional Devices..."));
 	mem_available = freeMemory();
-	Serial.println(F("Mounting Additional Devices..."));
 	mount_devices();

 	// manual queue
+	Serial.println(F("Queueing system threads..."));
 	mem_available = freeMemory();
-	Serial.println(F("Queueing system threads..."));
 	queue_sys_threads();

 	// manual queue
+	Serial.println(F("Manually queueing animations..."));
 	mem_available = freeMemory();
-	Serial.println(F("Manually queueing animations..."));
 	led_man_queue();

 	// initialize timing


Extract constants, blinkenlights on winning

--- crypt-gears/gear_arduino/gear_arduino.ino
+++ crypt-gears/gear_arduino/gear_arduino.ino
@@ -13,7 +13,14 @@

 // if the potentiometer is between pot_locs[2*i] and pod_locs[2*i+1], then we
 // say we are in position i.  otherwise, we are between positions.
-int pot_locs[14] = {1024, 885, 825, 690, 640, 450, 390, 280, 190, 70, 50, 24, 12, 0};
+// TODO(benkraft): Consider narrowing these.
+int pot_locs[14] = {1024, 885,
+                    825, 690,
+                    640, 450,
+                    390, 280,
+                    190, 70,
+                    50, 24,
+                    12, 0};

 // above this = white; below = black (unlodged is undefined)
 // TODO(benkraft): Recompute after we move them.
@@ -60,10 +67,11 @@
 // Note they get filled in in reverse order (see note by selector pos).
 boolean correct_positions[7];

-// -1 if not blinking, 0..19 when blinking (0..9 = on, 10..19 = off)
-int calibration_state = -1;
-
-// 0..9 or -1 to disable debug; only show state on 0
+// State of various timers.  For the blinkers, -1 is not blinking,
+// [0, BLINK_SPEED) is on, [BLINK_SPEED, 2*BLINK_SPEED) is off.
+// For debug, we just log on 0.
+int calibration_blink_state = -1;
+int winning_blink_state = -1;
 int debug_state = 0;

 // CONSTANTS DEFINING THE PUZZLE
@@ -84,6 +92,14 @@
   {1, 5}, {1, 9}, {5, 9},
   {2, 6}, {2, 10}, {6, 10}};

+// SETTINGS
+
+// How long in ms we wait between loops
+int FRAME_SPEED = 50; // 20 fps
+// How many frames to wait before toggling blinking lights
+int BLINK_SPEED = 10; // 0.5s
+// How many frames to wait before logging debug data, or 0 for never
+int DEBUG_FREQ = 20; // 1s

 // MAIN TOPLEVEL STUFF

@@ -103,15 +119,7 @@
 // this is run continuously after setup has completed
 void loop()
 {
-  delay(50);
-  if (debug_state == 0)
-  {
-    printState();
-  }
-  if (debug_state >= 0)
-  {
-    debug_state = (debug_state + 1) % 20;
-  }
+  delay(FRAME_SPEED);

   int selector_pos = getSelectorGearPosition();
   if (selector_pos == -2)
@@ -131,8 +139,6 @@
   if (state == 0)
   {
     setCalibration(false);
-    // TODO(benkraft): Should we only be starting here when the red button is
-    // pressed?
     if (selector_pos == 0 && buttonPressed())
     {
       // We have started calibrating!
@@ -151,7 +157,7 @@

   if (state == 1)
   {
-    stepCalibration();
+    blinkCalibration();
     if (selector_pos < last_selector_pos
         || selector_pos > last_selector_pos + 1)
     {
@@ -220,7 +226,6 @@
         || selector_pos < last_selector_pos - 1)
     {
       // They have gone backwards or too fast.
-      // TODO(benkraft): As above, we may wish to debounce.
       state = 0;
       resetLights();
     }
@@ -249,16 +254,25 @@
         if (winning)
         {
           state = 3;
+          winning_blink_state = 0;
           sendCastleSuccessMessage();
         }
       }
     }
   }

-  if (state == 3 && buttonPressed())
-  {
-    state = 0;
-    resetLights();
+  if (state == 3)
+  {
+    if (buttonPressed())
+    {
+      state = 0;
+      winning_blink_state = -1;
+      resetLights();
+    }
+    else
+    {
+      blinkWinningLights();
+    }
   }

   last_selector_pos = selector_pos;
@@ -280,6 +294,9 @@
   int positions_white = 0;
   for (int j=0; j<7; j++)
   {
+    // TODO(benkraft): If ambient light variation is an issue, we could compute
+    // the largest and smallest values we saw, and if they are far enough
+    // apart, set a dynamic threshold halfway between.
     photoresistor_history[j] = (
       photoresistor_totals[i][j] / photoresistor_counts[i][j]
       < photoresistor_thresholds[i]);
@@ -459,8 +476,6 @@
 // selector gear.)  Call only if all gears are lodged.
 boolean haveConnection(int rotation)
 {
-  // TODO(benkraft): Make sure these match the actual directions of rotation in
-  // the final mechanism.
   int rotation_0 = (rotation + gear_orientations[0]) % 12;
   int rotation_1 = (12 - rotation + gear_orientations[1]) % 12;
   int rotation_2 = (rotation + gear_orientations[2]) % 12;
@@ -530,7 +545,7 @@

 void setCalibration(boolean on)
 {
-  calibration_state = -1;
+  calibration_blink_state = -1;
   if (on)
   {
     digitalWrite(calibration_light, HIGH);
@@ -541,16 +556,34 @@
   }
 }

-void stepCalibration()
-{
-  calibration_state = (calibration_state + 1) % 20;
-  if (calibration_state < 10)
+void blinkCalibration()
+{
+  calibration_blink_state = (calibration_blink_state + 1) % (2 * BLINK_SPEED);
+  if (calibration_blink_state < BLINK_SPEED)
   {
     digitalWrite(calibration_light, HIGH);
   }
   else
   {
     digitalWrite(calibration_light, LOW);
+  }
+}
+
+void blinkWinningLights()
+{
+  winning_blink_state = (winning_blink_state + 1) % (2 * BLINK_SPEED);
+  int val;
+  if (winning_blink_state < BLINK_SPEED)
+  {
+    val = HIGH;
+  }
+  else
+  {
+    val = LOW;
+  }
+  for (int i=0; i<7; i++)
+  {
+    digitalWrite(output_lights[i], val);
   }
 }

@@ -566,56 +599,64 @@
 // Caller likely wants to reset internal state here.
 void sendCastleErrorMessage()
 {
-  // TODO(benkraft): May or may not need to wait a tick to be sure here.
-  // TODO(benkraft): May want to log debugging info here.
   Serial.println(21);
 }

 void printState()
 {
-  // print out position of the pot
-  Serial.print("pot: ");
-  Serial.println(getSelectorGearPosition());
-  // print out the three photoresistors.
-  Serial.print("photoresistors:");
-  for (int i=0; i<3; i++)
-  {
-    Serial.print(" ");
-    Serial.print(getRawPhotoresistor(i));
-    Serial.print(" (");
-    Serial.print(analogRead(photoresistors[i]));
-    Serial.print(")");
-  }
-  Serial.println("");
-
-  Serial.print("state: ");
-  Serial.println(state);
-  Serial.print("last selector pos: ");
-  Serial.println(last_selector_pos);
-
-  // history gets printed when we finish it
-
-  if (state == 2)
-  {
+  if (DEBUG_FREQ <= 0)
+  {
+    return;
+  }
+
+  if (debug_state == 0)
+  {
+    // print out position of the pot
+    Serial.print("pot: ");
+    Serial.println(getSelectorGearPosition());
+    // print out the three photoresistors.
+    Serial.print("photoresistors:");
     for (int i=0; i<3; i++)
     {
-      Serial.print("gear ");
-      Serial.print(i);
-      Serial.print("type: ");
-      Serial.print(gear_types[i]);
-      Serial.print(", orientation: ");
-      Serial.print(gear_orientations[i]);
-      Serial.println("");
-    }
-  }
-
-  Serial.println("");
+      Serial.print(" ");
+      Serial.print(getRawPhotoresistor(i));
+      Serial.print(" (");
+      Serial.print(analogRead(photoresistors[i]));
+      Serial.print(")");
+    }
+    Serial.println("");
+
+    Serial.print("state: ");
+    Serial.println(state);
+    Serial.print("last selector pos: ");
+    Serial.println(last_selector_pos);
+
+    // history gets printed when we finish it
+
+    if (state == 2)
+    {
+      for (int i=0; i<3; i++)
+      {
+        Serial.print("gear ");
+        Serial.print(i);
+        Serial.print("type: ");
+        Serial.print(gear_types[i]);
+        Serial.print(", orientation: ");
+        Serial.print(gear_orientations[i]);
+        Serial.println("");
+      }
+    }
+
+    Serial.println("");
+  }
+
+  debug_state = (debug_state + 1) % DEBUG_FREQ;
 }

 void printGearRead(int i, boolean failed)
 {
-  if (debug_state > 0)
+  if (DEBUG_FREQ > 0)
   {
     Serial.print("GEAR ");
     Serial.print(i);


fix applying color to every LED from a sequence

--- ArduinoArcReactor/ArduinoArcReactor.ino
+++ ArduinoArcReactor/ArduinoArcReactor.ino
@@ -122,10 +122,12 @@

 void everyindividual()
 {
+	int ledindex = 0;
 	int index = 1;
-	while (index < bufflen) {
-		strip.setPixelColor(index - 1, strip.Color(buffer[index], buffer[index + 1], buffer[index + 2]));
+	while (index <= bufflen) {
+		strip.setPixelColor(ledindex, strip.Color(buffer[index], buffer[index + 1], buffer[index + 2]));
 		index += 3;
+		ledindex++;
 	}

 	strip.show();


One last display code change

One last display code change

Added sd functionality check display mode

--- GroundStationCode/GroundStationCode.ino
+++ GroundStationCode/GroundStationCode.ino
@@ -1,5 +1,5 @@
 /*
-   Notre Dame Rocket Team Roll Control Payload Ground Station Code V. 1.1.3
+   Notre Dame Rocket Team Roll Control Payload Ground Station Code V. 1.1.4
    Aidan McDonald, 2/12/17
    Kyle Miller, 2/8/17

@@ -7,7 +7,7 @@
    Display-shifting code overhauled- previous configuration printed certain data subsets
    regardless of whether that data was part of the incoming packet. Current version receives data,
    then once the packet has been processed runs a switch-case based on the button input to
-   determine what to print to the LCD.
+   determine what to print to the LCD. (Added several new display modes as well- flag-confirmation, sd-check)
    Also slightly modified the button code to prevent multi-incrementing for each time the button is pushed
    Added code to control several LEDs- whether the fin override is in place, whether the servo has power,
    whether communications are working, and three which indicate the fin position
@@ -140,22 +140,20 @@

 void loop()
 {
-  static int buttonState = 0; //Button-display-toggle-tracking variable; has 4 potential display states
+  static int buttonState = 0; //Button-display-toggle-tracking variable; has 5 potential display states
   static bool buttonFlag = false; //Variable to prevent infinite cycline when the button is pushed

-if(millis() > lastRxTime + packetTimeDelay)//Update the communications LED
-  digitalWrite(packetLED, LOW);
+  if (millis() > lastRxTime + packetTimeDelay) //Update the communications LED
+    digitalWrite(packetLED, LOW);
   else
-  digitalWrite(packetLED, HIGH);
+    digitalWrite(packetLED, HIGH);

   if (digitalRead(buttonPin) == HIGH) {
     if (!buttonFlag) {
       buttonFlag = true; //Note that we've pushed the button, so that the counter only increments once
-      if (buttonState == 4) {
+      buttonState++;
+      if (buttonState == 5) {
         buttonState = 0;
-      }
-      else {
-        buttonState++;
       }
       lcd.setCursor(15, 1);
       lcd.print(buttonState);  //Update the button state on the LCD
@@ -253,7 +251,7 @@
       if (rf95.recv(buf, &len)) //Fills 'buf' with data, returns false if an error occurs
       {

-      lastRxTime = millis();
+        lastRxTime = millis();

         union { //Memory union used for the majority of data processing
           uint8_t tempBuff[3];
@@ -419,7 +417,19 @@
                 break;
             }
             break;
-          case 3: //Case 3 displays GPS altitude data if the GPS is enabled
+          case 3:
+            if (buf[7]) { //Datum 7 is the SD-working flag
+              lcd.print("SD Recording:");
+              lcd.setCursor(0, 1);
+              lcd.print("Working");
+            }
+            else {
+              lcd.print("SD Recording:");
+              lcd.setCursor(0, 1);
+              lcd.print("Failure");
+            }
+            break;
+          case 4: //Case 4 displays GPS altitude data if the GPS is enabled
             if (buf[5] == true) {
               if (gpsFix == 0 || gpsQuality == 0) {
                 lcd.print("No GPS fix.");
@@ -439,34 +449,34 @@
         }

         //Once data to the LCD have been displayed, update the LEDs with appropriate data
-        if(buf[2] == 1) //Confirmation of the Fin Override Flag
-        digitalWrite(finOverLED, HIGH);
+        if (buf[2] == 1) //Confirmation of the Fin Override Flag
+          digitalWrite(finOverLED, HIGH);
         else
-        digitalWrite(finOverLED, LOW);
-
-        if(buf[3] == 1) //Confirmation of the Servo Power Flag
-        digitalWrite(finOnLED, HIGH);
+          digitalWrite(finOverLED, LOW);
+
+        if (buf[3] == 1) //Confirmation of the Servo Power Flag
+          digitalWrite(finOnLED, HIGH);
         else
-        digitalWrite(finOnLED, LOW);
-
-        switch(buf[6]) { //Reports fin-position data
+          digitalWrite(finOnLED, LOW);
+
+        switch (buf[6]) { //Reports fin-position data
           case LEFT:
-          digitalWrite(finLLED, HIGH);
-          digitalWrite(finCLED, LOW);
-          digitalWrite(finRLED, LOW);
-          break;
+            digitalWrite(finLLED, HIGH);
+            digitalWrite(finCLED, LOW);
+            digitalWrite(finRLED, LOW);
+            break;
           case CENTER:
-          digitalWrite(finLLED, LOW);
-          digitalWrite(finCLED, HIGH);
-          digitalWrite(finRLED, LOW);
-          break;
+            digitalWrite(finLLED, LOW);
+            digitalWrite(finCLED, HIGH);
+            digitalWrite(finRLED, LOW);
+            break;
           case RIGHT:
-          digitalWrite(finLLED, LOW);
-          digitalWrite(finCLED, LOW);
-          digitalWrite(finRLED, HIGH);
-          break;
-        }
-
+            digitalWrite(finLLED, LOW);
+            digitalWrite(finCLED, LOW);
+            digitalWrite(finRLED, HIGH);
+            break;
+        }
+
       }
       else //If the data-retrieval statement returns FALSE, the packet is bad
         lcd.print("ERR: Bad Packet");


Added include

Added include

--- src/CAN/CAN_MD5_send/CAN_MD5_send.ino
+++ src/CAN/CAN_MD5_send/CAN_MD5_send.ino
@@ -1,5 +1,6 @@
 #include <MD5.h>
 #include <mcp_can.h>
+#include <SPI.h>

 const int SPI_CS_PIN = 9;
 const int HASH_LEN = 20;


turn off led on particle

turn off led on particle

--- embedded-particle/sense-motion.ino
+++ embedded-particle/sense-motion.ino
@@ -10,7 +10,7 @@
 convenient and doesn't require any wiring.
 */

-const bool kDebugLED = true;
+const bool kDebugLED = false;
 // in debug mode the rgb led changes color with the pir signal

 const int kGnd = D0;
@@ -118,7 +118,7 @@
       RGB.color(255, 0, 0);
     }
   } else {
-    RGB.color(0, 0, 50);
+    RGB.color(0, 0, 0);
   }
 }


refactor

refactor