Add files via upload

Add files via upload

with voltage output

--- code/feather_code.ino
+++ code/feather_code.ino
@@ -38,6 +38,7 @@
 #include <Adafruit_BME280.h> //bme library einbinden
 #include <Adafruit_Sensor.h> //Zusatz zur bme library
 #define SEALEVELPRESSURE_HPA (1013.25) //
+#define VBATPIN A7

 Adafruit_BME280 bme; //I2C

@@ -78,7 +79,7 @@

-static uint8_t sensordata[7];
+static uint8_t sensordata[8];
 static osjob_t sendjob;

 // Schedule TX every this many seconds (might become longer due to duty
@@ -90,7 +91,7 @@
   .nss = 8,
   .rxtx = LMIC_UNUSED_PIN,
   .rst = 5,
-  .dio = {3, 6, LMIC_UNUSED_PIN},
+  .dio = {3, 6, LMIC_UNUSED_PIN},
 };

 void onEvent (ev_t ev) {
@@ -163,7 +164,7 @@
   //Temperatur
   float tempratureReadout = (bme.readTemperature() + 50) * 100; //Temperatur wird um 50°C nach rechts verschoben, dass Temperaturen von -50°C bis +50°C gemessen werden, danach wird mit 100 multipliziert, um Komma zahlen zu vermeiden
   uint16_t temperature = (uint16_t) tempratureReadout; //Temperatur wird gecastet, also von float in ein uint16_t umgewandelt
-  uint8_t hightempratureByte = (uint8_t) ((temperature & 0xFF00) >> 8); // bitshift um 8 Stellen nach rechts
+  uint8_t hightempratureByte = (uint8_t) ((temperature & 0xFF00) >> 8); // bitshift um 8 Stellen nach rechts
   uint8_t lowtempratureByte = (uint8_t) (temperature & 0xFF); //bitshift um 8 Stellen nach links
   Serial.println(hightempratureByte);
   Serial.println(lowtempratureByte);
@@ -171,9 +172,9 @@

   //Luftdruck
   float pressureReadout = bme.readPressure() / 100.0F;
-  uint16_t pressure = (uint16_t ) ((pressure / 1013.25) * 100);
+  uint16_t pressure = (uint16_t ) ((pressureReadout / 1013.25) * 100);
   uint8_t pressureByte = (uint8_t) pressure;
-  Serial.println(pressureByte);
+  Serial.println(pressureByte);

   //Luftfeuchtigkeit
@@ -182,24 +183,32 @@
   uint8_t highhumidityByte = (uint8_t) ((humidity & 0xFF00) >> 8);
   uint8_t lowhumidityByte = (uint8_t) (humidity & 0xFF);
   Serial.println(highhumidityByte);
-  Serial.println(lowhumidityByte);
-
-
+  Serial.println(lowhumidityByte);
+
+
   //Lichtsensor
   lightsensorValue = analogRead(analogInPin);
-  float lightsensorVoltage = (3.3/4096*lightsensorValue);
-  float lightsensorStrom = (lightsensorVoltage/10020);
-  float lightstrom = (lightsensorStrom*2*1000000);
+  float lightsensorVoltage = (3.3 / 4096 * lightsensorValue);
+  float lightsensorStrom = (lightsensorVoltage / 10020);
+  float lightstrom = (lightsensorStrom * 2 * 1000000);
   lightstrom = lightstrom / 6.5852;         //In Prozent 658,52 (Maximalwert) / 100
   uint8_t lightstromInt = (uint8_t) lightstrom;
   Serial.println(lightstromInt);

   //Bodenfeuchtigkeitssensor
-  gndSoilPower = analogRead(gndSoilPin);
-  uint8_t gndPercent = (uint8_t) ((analogRead(A2)/33.30F) * 100);
+  gndSoilPower = analogRead(gndSoilPin);
+  uint8_t gndPercent = (uint8_t) ((analogRead(A2) / 33.30F) * 100);
   Serial.println(gndPercent);

+  //Akkustand auslesen
+  float measuredvbat = analogRead(VBATPIN);
+  measuredvbat *= 2;    // we divided by 2, so multiply back
+  measuredvbat *= 3.3;  // Multiply by 3.3V, our reference voltage
+  measuredvbat /= 1024; // convert to voltage
+  uint16_t akkuvoltageInt16 = (uint16_t) (measuredvbat * 100);
+  uint8_t akkuVoltage = (uint8_t) akkuvoltageInt16;
+  Serial.print("VBat: " ); Serial.println(measuredvbat);

   //Werte ins Array schreiben
   sensordata[0] = hightempratureByte;
@@ -209,13 +218,14 @@
   sensordata[4] = lowhumidityByte;
   sensordata[5] = lightstromInt;
   sensordata[6] = gndPercent;
-
-
+  sensordata[7] = akkuVoltage;
+
+
 }

 void do_send(osjob_t* j) {
-
+
   sensor_data();

   // Check if there is not a current TX/RX job running
@@ -328,3 +338,4 @@
   os_runloop();

 }
+


Repackaged SesameStream from net.fortytwo to edu.rpi.twc

--- eddie/head/head.ino
+++ eddie/head/head.ino
@@ -1,9 +1,21 @@
 #include <Wire.h>

+////////////////////////////////////////
+
+#define AUDIO_PIN A0
+#define VIBRO_PIN A1
+#define PHOTO_PIN A2
+// A4 is reserved for I2C
+// A5 is reserved for I2C
+
+////////////////////////////////////////
+
+#define AUDIO_OSC_PREFIX         "/eddie/head/sensor/phone"
+#define BMP085_OSC_PREFIX        "/eddie/head/sensor/BMP085"
+#define DHT22_OSC_PREFIX         "/eddie/head/sensor/dht22"
+#define PHOTO_OSC_PREFIX         "/eddie/head/sensor/photo"
 #define TIMER_OSC_PREFIX         "/eddie/head/timer"
-#define PHOTO_OSC_PREFIX         "/eddie/head/sensor/photo"
-#define DHT22_OSC_PREFIX         "/eddie/head/sensor/dht22"
-#define BMP085_OSC_PREFIX        "/eddie/head/sensor/BMP085"
+#define VIBRO_OSC_PREFIX         "/eddie/head/sensor/piezo"

 // Each sampling cycle must take at least this long.
 // If a cycle is finished sooner, we will wait before starting the next cycle.
@@ -12,6 +24,14 @@
 // A sampling cycle may take at most this long.
 // If the sample runs over, an error message will be generated
 #define CYCLE_MILLIS_MAX  5000
+
+////////////////////////////////////////
+
+#include <AnalogSampler.h>
+
+AnalogSampler audioSampler(AUDIO_PIN);
+AnalogSampler vibroSampler(VIBRO_PIN);
+AnalogSampler photoSampler(PHOTO_PIN);

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

@@ -30,18 +50,17 @@

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

-#define PHOTO_PIN A2
+#include "eh_timer.h"
+#include "eh_rgb_led.h"
+#include "eh_vibration.h"

 ////////////////////////////////////////
-
-#include "eh-timer.h"
-
-////////////////////////////////////////
-

 void setup() {
     Serial.begin(9600);
     bmp085.setup();
+
+    rgb_led_setup();

     //lastCycle_highBits = 0;
     //lastCycle_lowBits = millis();
@@ -49,15 +68,43 @@

 void loop()
 {
+    writeColor(GREEN);
+
     startCycle();

-    samplePhotoresistor();
+    //samplePhotoresistor();
+    sampleAnalog(10000);
     sampleDHT22();
     sampleBMP085();

     //rateTest();

     endCycle();
+}
+
+void sampleAnalog(unsigned long iterations)
+{
+    int len = 3;
+    AnalogSampler samplers[] = {audioSampler, vibroSampler, photoSampler};
+    char* prefixes[] = {AUDIO_OSC_PREFIX, VIBRO_OSC_PREFIX, PHOTO_OSC_PREFIX};
+
+    for (unsigned long i = 0; i < iterations; i++)
+    {
+        for (int j = 0; j < len; j++)
+        {
+            samplers[j].sample();
+        }
+    }
+
+    for (int j = 0; j < len; j++)
+    {
+        Serial.print(prefixes[j]);
+        Serial.print("/data ");
+        Serial.print(samplers[j].getMinValue());
+        Serial.print(" ");
+        Serial.println(samplers[j].getMaxValue());
+        samplers[j].reset();
+    }
 }

 void samplePhotoresistor()


Changed for consistency with MotorShield.ino

--- proj/SpeedLight/SpeedLight.ino
+++ proj/SpeedLight/SpeedLight.ino
@@ -4,17 +4,23 @@
  * and compares to arbitrary speed setpoint value. Lights up LED when difference is larger than arbitrary threshold.
  */

-#define encoder0PinA  2
-#define encoder0PinB  3
-#define ledPin 13
-#define errorThreshold 20
-#define cpr 200 // Cycles per revolution of encoder disk
+const int encoder0PinA = 2;
+const int encoder0PinB = 3;
+const int ledPin = 13;
+const float deadband = 20.0; // Error threshold/deadband in ticks per second

-int targetSpeed = 40; // Target angulary velocity / setpoint in degrees per second
+// Following constants are taken from MotorShield.ino
+const float ticksPerRev = 200.0; // Cycles/ticks per revolution of encoder disk
+const float gearRatio = 32.0;
+const float wheelCir = 1.092; // Meters
+const float metersPerTick = wheelCir / (ticksPerRev * gearRatio);

-volatile long encoder0Pos = 0; // Delta of encoder position since last loop iteration
+float targetSpeed = 40; // Target velocity/setpoint in m/s
+float targetAngSpeed = targetSpeed / metersPerTick; // Target angular velocity/setpoint in ticks per second
+
+volatile int encoder0Pos = 0; // Delta of encoder position since last loop iteration
 long oldTime = 0; // Time in ms from last loop iteration
-int dps = 0; // Angular velocity in degrees per second
+float angSpeed = 0; // Angular velocity in ticks per second

 void setup() {
   pinMode(encoder0PinA, INPUT);
@@ -30,11 +36,11 @@
 }

 void loop() {
-  // Divide delta of position by 4*cpr (because 4X decoding of quadrature encoder)
-  // and multiply by 360 for change in degrees, divide by delta time, & convert from ms^-1 to s^-1.
-  dps = ((encoder0Pos) * 360 * 1000 / (4*cpr)) / (millis() - oldTime);
-  Serial.println(dps);
-  if (abs(dps - targetSpeed) > errorThreshold) {
+  // Divide delta of position by 4 (because 4X decoding of quadrature encoder)
+  // to get ticks from edges, divide by delta time & convert from ms^-1 to s^-1.
+  angSpeed = encoder0Pos * 1000 / 4.0 / (millis() - oldTime);
+  Serial.println(angSpeed);
+  if (abs(angSpeed - targetAngSpeed) > deadband) {
     digitalWrite(ledPin, HIGH);
   } else {
     digitalWrite(ledPin, LOW);


UART_RECEIVER_DISABLE flag is added

UART_RECEIVER_DISABLE flag is added

it's better to define this when RXI of Dongle is connected to nothing
(i.e., Dongle #1)

--- GenlockDongle.ino
+++ GenlockDongle.ino
@@ -49,6 +49,9 @@
 #define DISABLE_PCINT_MULTI_SERVICE
 #include <PinChangeInt.h>

+// it is better to define this when RXI is connected to nothing (eg. Dongle #1 of Genlock system)
+#undef  UART_RECEIVER_DISABLE
+
 // end of Options
 //////////////////////////////////////////////////////////

@@ -70,7 +73,10 @@
   //     cf. http://forum.arduino.cc/index.php?topic=54623.0
   // Set 57600 baud or slower.
   Serial.begin(57600);
-
+#ifdef UART_RECEIVER_DISABLE
+  UCSR0B &= (~_BV(RXEN0));
+#endif
+
   pinMode(BPRDY, INPUT_PULLUP);
   pinMode(PWRBTN, INPUT_PULLUP);
   digitalWrite(HBUSRDY, LOW);


cleanups, add factory reset on btn press 5s

--- neurite.ino
+++ neurite.ino
@@ -105,7 +105,7 @@
 StaticJsonBuffer<NEURITE_CFG_SIZE> json_buf;
 static char cfg_buf[NEURITE_CFG_SIZE];

-static char uid[32];
+static void reboot(struct neurite_data_s *nd);

 enum {
 	WORKER_ST_0 = 0,
@@ -387,10 +387,12 @@
 static void button_hold_handler(struct neurite_data_s *nd, int dts)
 {
 	if (dts > 5000) {
-		if (SPIFFS.remove(NEURITE_CFG_PATH))
-			log_dbg("%s removed\n\r", NEURITE_CFG_PATH);
-		else
+		if (SPIFFS.remove(NEURITE_CFG_PATH)) {
+			log_info("%s removed\n\r", NEURITE_CFG_PATH);
+			reboot(nd);
+		} else {
 			log_err("%s failed to remove\n\r", NEURITE_CFG_PATH);
+		}
 	}
 }

@@ -465,6 +467,17 @@
 	ticker_but.attach_ms(50, ticker_button_task, nd);
 }

+static void reboot(struct neurite_data_s *nd)
+{
+	log_info("rebooting...\n\r");
+	stop_ticker_but(nd);
+	stop_ticker_mon(nd);
+	stop_ticker_worker(nd);
+	stop_ticker_led(nd);
+	stop_ticker_cmd(nd);
+	ESP.restart();
+}
+
 static void cmd_completed_cb(struct cmd_parser_s *cp)
 {
 	struct neurite_data_s *nd = &g_nd;
@@ -618,64 +631,12 @@
   return true;
 }
 #endif
-void neurite_init(void)
-{
-	struct neurite_data_s *nd = &g_nd;
-	log_dbg("in\n\r");
-
-	__bzero(cfg_buf, NEURITE_CFG_SIZE);
-	__bzero(nd, sizeof(struct neurite_data_s));
-	__bzero(&g_cp, sizeof(struct cmd_parser_s));
-	nd->cp = &g_cp;
-	__bzero(cmd_buf, NEURITE_CMD_BUF_SIZE);
-	cmd_parser_init(nd->cp, cmd_buf, NEURITE_CMD_BUF_SIZE);
-
-	fs_init(nd);
-#if 1
-	if (cfg_validate(nd)) {
-		cfg_load_sync(nd);
-		b_cfg_ready = true;
-		log_dbg("cfg ready\n\r");
-	} else {
-		cfg_init(nd);
-		b_cfg_ready = false;
-		log_dbg("cfg not ready\n\r");
-	}
-#else
-	if (!saveConfig()) {
-		Serial.println("Failed to save config");
-	} else {
-		Serial.println("Config saved");
-	}
-
-	if (!loadConfig()) {
-		Serial.println("Failed to load config");
-	} else {
-		Serial.println("Config loaded");
-	}
-#endif
-	log_info("chip id: %08x\n\r", system_get_chip_id());
-	log_info("uid: %s\n\r", nd->cfg.uid);
-	log_info("topic_to: %s\n\r", nd->cfg.topic_to);
-	log_info("topic_from: %s\n\r", nd->cfg.topic_from);
-#if 0
-	log_dbg("device id: %s\n\r", nd->cfg->device_id);
-	log_dbg("ssid: %s\n\r", nd->cfg->ssid);
-	log_dbg("psk : %s\n\r", nd->cfg->sta_pwd);
-	log_dbg("mqtt user: %s\n\r", nd->cfg->mqtt_user);
-	log_dbg("mqtt pass: %s\n\r", nd->cfg->mqtt_pass);
-#endif
-	start_ticker_but(nd);
-	start_ticker_cmd(nd);
-	log_dbg("out\n\r");
-}
-
 /* TODO server test */

 ESP8266WebServer *server;
 File fsUploadFile;

-void handleNotFound() {
+static void handleNotFound() {
 	if (!handleFileRead(server->uri())) {
 		String message = "File Not Found\n\n";
 		message += "URI: ";
@@ -977,10 +938,6 @@
 #endif
 			server = new ESP8266WebServer(80);
 			server->on("/list", HTTP_GET, handleFileList);
-			server->on("/edit", HTTP_GET, []() {
-				if (!handleFileRead("/edit.htm"))
-					server->send(404, "text/plain", "FileNotFound");
-			});
 			server->on("/edit", HTTP_PUT, handleFileCreate);
 			server->on("/edit", HTTP_DELETE, handleFileDelete);
 			server->on("/edit", HTTP_POST, []() {
@@ -1013,6 +970,40 @@
 			log_err("unknown cfg state: %d\n\r", worker_st);
 			break;
 	}
+}
+
+void neurite_init(void)
+{
+	struct neurite_data_s *nd = &g_nd;
+	log_dbg("in\n\r");
+
+	__bzero(cfg_buf, NEURITE_CFG_SIZE);
+	__bzero(nd, sizeof(struct neurite_data_s));
+	__bzero(&g_cp, sizeof(struct cmd_parser_s));
+	nd->cp = &g_cp;
+	__bzero(cmd_buf, NEURITE_CMD_BUF_SIZE);
+	cmd_parser_init(nd->cp, cmd_buf, NEURITE_CMD_BUF_SIZE);
+
+	fs_init(nd);
+
+	if (cfg_validate(nd)) {
+		cfg_load_sync(nd);
+		b_cfg_ready = true;
+		log_dbg("cfg ready\n\r");
+	} else {
+		cfg_init(nd);
+		b_cfg_ready = false;
+		log_dbg("cfg not ready\n\r");
+	}
+
+	log_info("chip id: %08x\n\r", system_get_chip_id());
+	log_info("uid: %s\n\r", nd->cfg.uid);
+	log_info("topic_to: %s\n\r", nd->cfg.topic_to);
+	log_info("topic_from: %s\n\r", nd->cfg.topic_from);
+
+	start_ticker_but(nd);
+	start_ticker_cmd(nd);
+	log_dbg("out\n\r");
 }

 void setup()


bugfix

bugfix

--- KISS_OSD/KISS_OSD.ino
+++ KISS_OSD/KISS_OSD.ino
@@ -426,7 +426,7 @@

     while(recBytes < minBytes && micros()-LastLoopTime < 20000){
       #define STARTCOUNT 2
-      while(Serial.available()) serialBuf[recBytes++] = Serial.read();
+      while(Serial.available() && recBytes < 255) serialBuf[recBytes++] = Serial.read();
       if(recBytes == 1 && serialBuf[0] != 5)recBytes = 0; // check for start byte, reset if its wrong
       if(recBytes == 2) minBytes = serialBuf[1]+STARTCOUNT+1; // got the transmission length
       if(recBytes == minBytes){
@@ -735,6 +735,7 @@
     print_time(time, Time);
     if(armed == 0 && armedOnce && last_Aux_Val != AuxChanVals[DV_CHAN-1]) {
       DV_change_time = millis();
+      last_Aux_Val = AuxChanVals[DV_CHAN-1];
     }
     if(BAT_AUX_DV_CHANNEL > 0 && armedOnce && armed != 0 && last_Bat_Aux_Val != AuxChanVals[BAT_AUX_DV_CHANNEL-1]) {
       last_Bat_Aux_Val = AuxChanVals[BAT_AUX_DV_CHANNEL-1];


T# not sent automatically during setup

T# not sent automatically during setup

--- jenny5-firmware/jenny5-firmware.ino
+++ jenny5-firmware/jenny5-firmware.ino
@@ -1,5 +1,4 @@
 #include <Wire.h>
-//#include <avr/pgmspace.h>

 #include "ultrasonic_sensors.h"
 #include "potentiometers.h"
@@ -42,14 +41,20 @@
 //--------------------------------------------------------------------------------------------
 void setup()
 {
+
 	first_start = 0;
-	strcpy(firmware_version, "2019.01.07.1");
+	strcpy(firmware_version, "2019.01.09.1");

 	current_buffer[0] = 0;

 	tera_ranger_one_lidar = NULL;

 	Serial.begin(115200); //Open Serial connection
+
+	//delay(2000);
+
+	//Serial.write("T#");// initialization is over; must check for T# string (which is the alive test)
+	//Serial.flush();

   /*
 	Serial.write("Commands are:");
@@ -90,7 +95,7 @@
 	Serial.println(F("GAx# // Gets the parameters for AS5147 x: CS pin. Outputs GAx p d#"));

 	Serial.println(F("CS n d1 s1 e1 d2 s2 e2# // Creates the stepper motors controller and set some of its parameters. n is the number of motors, d, s, e are dir, step and enable pins. Outputs CS# when done."));
-	CS 3 5 4 11 7 6 11 9 8 11#
+	CS 3 5 4 12 7 6 12 9 8 12#
 	Serial.println(F("CD n p1 d11 d12 e1 p2 d21 d22 e2# // Creates the dc motors controller and set some of its parameters. n is the number of motors, p is the pwm_pin, d1 and d2 are the direction pins and e is the enable pins. Outputs CD# when done."));
 	Serial.println(F("CV n# // Creates the servo motors controller and set some of its parameters. n is the number of motors, Outputs CV# when done."));

@@ -112,7 +117,8 @@

 	Serial.println();
   */
-	Serial.write("T#");// initialization is over; must check for T# string (which is the alive test)
+
+
 }
 //--------------------------------------------------------------------------------------------
 void parse_and_execute_commands(char* tmp_str, byte str_length, char *serial_out)


Disable serial output

Disable serial output

--- magicwallet_tx/magicwallet_tx.ino
+++ magicwallet_tx/magicwallet_tx.ino
@@ -1,6 +1,6 @@
 #include <RH_ASK.h>

-#define DEBUG
+/* #define DEBUG */

 #define die()	while (1)


A few fixes to get this to work - still have not tested...

--- miscr.ino
+++ miscr.ino
@@ -63,12 +63,11 @@
  public:
   int pin;
   int times; // TODO double data type for half-steps
-}
-
-Command::Command() {
-  pin = 0;
-  times = 0;
-}
+  Command() {
+    pin = 0;
+    times = 0;
+  }
+};

 /*
  * Stepper class, defines pins, whether it should be updated and a few control
@@ -84,7 +83,24 @@
   bool update;
   Command command;
   int incr;
-
+
+  Stepper(int stepPinIn, int dirPinIn, int enablePinIn,
+          int minPinIn, int maxPinIn) {
+    stepPin = stepPinIn;
+    dirPin = dirPinIn;
+    enablePin = enablePinIn;
+    minPin = minPinIn;
+    maxPin = maxPinIn;
+    update = false;
+    incr = 0;
+  }
+
+  void begin() {
+    pm(stepPin, OUTPUT);
+    pm(dirPin, OUTPUT);
+    pm(enablePin, OUTPUT);
+    dw(enablePin, LOW);
+  }
   //void step(double times) {}
   void testSpin(bool clockwise, int amount) {
     if(clockwise)
@@ -97,21 +113,6 @@
   }
 };

-Stepper::Stepper(int stepPinIn, int dirPinIn, int enablePinIn,
-                 int minPinIn, int maxPinIn) {
-  stepPin = stepPinIn;
-  dirPin = dirPinIn;
-  enablePin = enablePinIn;
-  minPin = minPinIn;
-  maxPin = maxPinIn;
-  update = false;
-  incr = 0;
-
-  pm(stepPin, OUTPUT);
-  pm(dirPin, OUTPUT);
-  pm(enablePin, OUTPUT);
-  dw(enable, LOW);
-}

 // Initialise Steppers
 //         stepPin | dirPin | enablePin | minPin | maxPin
@@ -141,9 +142,9 @@
     return true;
   } else if(in == "?") {
     Serial.println("TODO Display info...");
-  } else {
-    return false;
-  }
+    return true;
+  }
+  return false;
 }

@@ -156,11 +157,11 @@

   while(Serial.available()) {
       c = Serial.read();
-      out.concat(character);
-  }
-
-  if(content != "") {
-    if(!parseGCode()) {
+      out.concat(c);
+  }
+
+  if(out != "") {
+    if(!parseGCode(out)) {
       Serial.println("Invalid GCode entered!");
     }
   }
@@ -172,6 +173,9 @@

   // Print welcome message
   Serial.println("miscr v0.1 [enter \"?\" for commands and \"$\" for status]\n\n");
+
+  sX.begin();
+  sY.begin();
 }

 void loop() {


Fixing comma erroa

Fixing comma erroa

--- computer_box/computer_box.ino
+++ computer_box/computer_box.ino
@@ -51,14 +51,13 @@
 void loop() {
   Serial.print("{");

-  read_voltages();
+  read_voltages(); Serial.print(",");

-  Serial.print(",");
+  read_dht_temp(); Serial.print(",");

-  read_dht_temp();
-  read_ds18b20_temp();
+  read_ds18b20_temp(); Serial.print(",");

-  read_fan_status();
+  read_fan_status(); Serial.print(",");

   Serial.print("\"count\":"); Serial.print(++counter);
   if(counter > 65000){


Update _05-two-ds18b20.ino

Update _05-two-ds18b20.ino

--- _05-two-ds18b20/_05-two-ds18b20.ino
+++ _05-two-ds18b20/_05-two-ds18b20.ino
@@ -77,7 +77,9 @@
   WiFi.mode(WIFI_STA);

   WiFi.begin(ssid, password);
+  #ifdef __IS_MY_HOME
   WiFi.config(IPAddress(192, 168, 10, 13), IPAddress(192, 168, 10, 1), IPAddress(255, 255, 255, 0));
+  #endif

   while (WiFi.status() != WL_CONNECTED) {
     delay(100);


Derp, remove errant if.

Derp, remove errant if.

--- Box_joint_final/Box_joint_final.ino
+++ Box_joint_final/Box_joint_final.ino
@@ -48,7 +48,6 @@
 }

 void loop() { //high speed code goes here
-if
 mainMenu();
 }


Added analogReference

Added analogReference

--- examples/ATtiny.ino
+++ examples/ATtiny.ino
@@ -75,7 +75,7 @@
   reg = TinyWireS.receive();
   uint8_t val;
   bytesReceived--;
-  uint8_t value; //will be zero [off/input] if missing the value param in transmission
+  uint8_t value; //will be zero [off/input/VCCRef] if missing the value param in transmission
   if (bytesReceived) {
     value = TinyWireS.receive(); //will discard second param if sent and not needed (read action)
     bytesReceived--;
@@ -90,6 +90,8 @@
     aVal = analogRead(arpins[reg-24]);fBit=true;return;
   } else if (reg < 32) {
      analogWrite(awpins[reg-29], value);return;
+  } else if (reg == 32) {
+    analogReference(value);
   }
   while (bytesReceived) {
     TinyWireS.receive(); //discard


Greens and Reds

Greens and Reds

--- f-alpha/f-alpha.ino
+++ f-alpha/f-alpha.ino
@@ -584,7 +584,7 @@
             newxy(x + x - xPrev, y + y - yPrev, vector);
             return;
         }
-    if (vector = GREENS)
+    if (vector = GREENS)
     {
         if (button14.flagClick == 1)
         {
@@ -634,7 +634,25 @@
         }
     }

-
+    if (field[x][y][1] == GREENS)
+    {
+      if (button11.flagClick == 1)
+        {
+           ballkick = false;
+           vector == GREENS;
+        }
+
+    }
+    if (field[x][y][1] == REDS)
+    {
+      if (button21.flagClick == 1)
+        {
+           ballkick = false;
+           vector == REDS;
+        }
+
+    }
+
 }


Add Visual Studio Project Structure Fix a compile Issue in wled19_json.ino with Visual Studio / Visual Assist

--- wled00/wled19_json.ino
+++ wled00/wled19_json.ino
@@ -101,6 +101,35 @@
   return stateResponse;
 }

+void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id)
+{
+	root["id"] = id;
+	root["start"] = seg.start;
+	root["stop"] = seg.stop;
+	root["len"] = seg.stop - seg.start;
+
+	JsonArray colarr = root.createNestedArray("col");
+
+	for (uint8_t i = 0; i < 3; i++)
+	{
+		JsonArray colX = colarr.createNestedArray();
+		colX.add((seg.colors[i] >> 16) & 0xFF);
+		colX.add((seg.colors[i] >> 8) & 0xFF);
+		colX.add((seg.colors[i]) & 0xFF);
+		if (useRGBW)
+			colX.add((seg.colors[i] >> 24) & 0xFF);
+	}
+
+	root["fx"] = seg.mode;
+	root["sx"] = seg.speed;
+	root["ix"] = seg.intensity;
+	root["pal"] = seg.palette;
+	root["sel"] = seg.isSelected();
+	root["rev"] = seg.getOption(1);
+	root["cln"] = -1;
+}
+
+
 void serializeState(JsonObject root)
 {
   root["on"] = (bri > 0);
@@ -130,34 +159,6 @@
       serializeSegment(seg0, sg, s);
     }
   }
-}
-
-void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id)
-{
-  root["id"] = id;
-  root["start"] = seg.start;
-  root["stop"] = seg.stop;
-  root["len"] = seg.stop - seg.start;
-
-  JsonArray colarr = root.createNestedArray("col");
-
-  for (uint8_t i = 0; i < 3; i++)
-  {
-    JsonArray colX = colarr.createNestedArray();
-    colX.add((seg.colors[i] >> 16) & 0xFF);
-    colX.add((seg.colors[i] >>  8) & 0xFF);
-    colX.add((seg.colors[i]      ) & 0xFF);
-    if (useRGBW)
-    colX.add((seg.colors[i] >> 24) & 0xFF);
-  }
-
-  root["fx"] = seg.mode;
-  root["sx"] = seg.speed;
-  root["ix"] = seg.intensity;
-  root["pal"] = seg.palette;
-  root["sel"] = seg.isSelected();
-  root["rev"] = seg.getOption(1);
-  root["cln"] = -1;
 }

 void serializeInfo(JsonObject root)


Test compiles

Test compiles

not tested on real device

--- Arduino/hardware/REV10/REV10HardwareTest/REV10HardwareTest.ino
+++ Arduino/hardware/REV10/REV10HardwareTest/REV10HardwareTest.ino
@@ -32,7 +32,7 @@
 // Get defaults for valve applications.
 #include <OTV0p2_valve_ENABLE_defaults.h>
 // All-in-one valve unit (DORM1).
-#include <OTV0p2_CONFIG_REV11.h>
+#include <OTV0p2_CONFIG_REV10.h>
 // I/O pin allocation and setup: include ahead of I/O module headers.
 #include <OTV0p2_Board_IO_Config.h>
 // OTV0p2Base Libraries
@@ -40,6 +40,7 @@
 // Radio Libraries
 //#include <OTRadioLink.h>
 #include <OTRFM23BLink.h>
+#include <OTSIM900Link.h>
 // RadValve libraries
 #include <OTRadValve.h>

@@ -122,6 +123,7 @@
                                                 SIM900_APN,
                                                 SIM900_UDP_ADDR,
                                                 SIM900_UDP_PORT);
+static const OTRadioLink::OTRadioChannelConfig SecondaryRadioConfig(&SIM900Config, true, true, true);
 OTSIM900Link::OTSIM900Link<8, 5, RADIO_POWER_PIN, OTV0P2BASE::getSecondsLT> SecondaryRadio; // (REGULATOR_POWERUP, RADIO_POWER_PIN);

@@ -265,10 +267,6 @@
     DEBUG_SERIAL_PRINT_FLASHSTRING("T: ");
     DEBUG_SERIAL_PRINT(heat);
     DEBUG_SERIAL_PRINTLN();
-    const uint8_t rh = RelHumidity.read();
-    DEBUG_SERIAL_PRINT_FLASHSTRING("RH%: ");
-    DEBUG_SERIAL_PRINT(rh);
-    DEBUG_SERIAL_PRINTLN();
     const int light = AmbLight.read();
     DEBUG_SERIAL_PRINT_FLASHSTRING("L: ");
     DEBUG_SERIAL_PRINT(light);


0.7.17beta3

0.7.17beta3

change load up pin to A2

--- Device_LinkItOne/LASS_WEB/LASS_WEB.ino
+++ Device_LinkItOne/LASS_WEB/LASS_WEB.ino
@@ -1231,8 +1231,10 @@
     }
     // close the file:
     settingFile.close();
-  }
-
+    return 1;
+  } else {
+    return 0;
+  }
 }
 // show current setting from setting memory
 void setting_show(){
@@ -2086,11 +2088,6 @@
 //----- setup -----

 void setup() {
-  if(LED_MODE != LED_MODE_OFF){ // LED_MODE_OFF never light on
-    pinMode(ARDUINO_LED_PIN, OUTPUT);
-  }
-  lightBlink();
-
   Serial.begin(SERIAL_BAUDRATE);
   Serial.println("System starting....");

@@ -2117,13 +2114,14 @@
   Serial.println(", Flash initialized.");

   //Web Setup Server
-  pinMode(INPUT_PULLUP,13);
   boolean isHigh=false;
-  for(int i=0;i<=10;i++){
-     if(digitalRead(13)==1) isHigh=true;
-     delay(50);
-  }
-  if(!setting_load() || isHigh){
+  for(int i=0;i<=5;i++){
+     if(analogRead(A2)>500) isHigh=true;
+     Serial.println(isHigh);
+     delay(10);
+  }
+
+  if((!setting_load()) || isHigh){
     setting_init();
     setting_save();
     LWiFiEncryption wifi_auth;
@@ -2150,7 +2148,12 @@
       webserver_loop();
     }
   }
-
+
+   if(LED_MODE != LED_MODE_OFF){ // LED_MODE_OFF never light on
+    pinMode(ARDUINO_LED_PIN, OUTPUT);
+  }
+
+  lightBlink();
   setting_show();
   clientIDStr = setting.device_id;
   clientIDStr.toCharArray(clientID, clientIDStr.length()+1);


Drinks now get made when the button is released. Pressing either
button while a drink is being dispensed will stop the bot.

Also added some switch bounce protection...

--- arduino/tequila_sunrise_bot/tequila_sunrise_bot.ino
+++ arduino/tequila_sunrise_bot/tequila_sunrise_bot.ino
@@ -1,10 +1,68 @@

-//
-// Copyright (c) Party Robotics LLC 2012
-// Written by Robert Kaye <rob@partyrobotics.com>
-//
+/*
+   Copyright (c) Party Robotics LLC 2012
+   Written by Robert Kaye <rob@partyrobotics.com>
+
+Welcome hacker!
+
+Not liking what the bot is churning out right now?
+
+GOOD! Read on!
+
+The tequila sunrise bot is nothing more than three peristaltic pumps, each
+independently driven by a motor. How long the pumps run while making a drink,
+determines how much of each ingredient is dispensed. To make a tequila sunrise
+you need to dispense:
+
+- grenadine for 3560 milliseconds, equivalent to 1 part
+- tequila for 10680 milliseconds, equivalent to 3 parts
+- orange juice for 21360 milliseconds, equivalent to 6 parts
+
+Down below is the definition of our drinks -- those initializers define the
+drinks. And there are two drinks: normal and STRONG. You get to decide on
+durations for each of these two drinks.
+
+In order to deploy the bot for your bidding, you'll need to get the required
+booze. Please run water through the lines before you start making your new drinks.
+
+Have fun!
+
+*/

 #include "defs.h"
+
+// ---------------------------------------------
+// Drink definition. HACK ME!
+// ---------------------------------------------
+
+// the proportions of the drink expressed in ms of motoro run time
+static motor_command drinks[2][3] =
+{
+    { // Normal
+        { 0, 21360 },  // OJ
+        { 1, 10680 },  // tequila
+        { 2, 3560 }    // grenadine
+
+    },
+    { // Strong
+        { 0, 19150 },  // OJ
+        { 1, 12770 },  // tequila
+        { 2, 3830 }    // grenadine
+    }
+};
+
+// ---------------------------------------------
+// End of easily hackable section
+// ---------------------------------------------
+
+// ---------------------------------------------
+// Print debug output to the serial port.
+// ---------------------------------------------
+
+// Set this to 0 before deploying. Sometimes the arduino will wait until a
+// USB cable is connected to start running.
+#define DEBUG 0
+
 // ---------------------------------------------
 // defintions for the TSB motors
 // ---------------------------------------------
@@ -13,11 +71,13 @@
 // ---------------------------------------------
 // debugging support stuff
 // ---------------------------------------------
+

 #define MAX 80
 // debugging printf function. Max MAX characters per line!!
 void dprintf(const char *fmt, ...)
 {
+#if DEBUG
     va_list va;
     va_start (va, fmt);
     char buffer[MAX];
@@ -25,23 +85,8 @@
     vsnprintf(buffer, MAX, fmt, va);
     va_end (va);
     Serial.print(buffer);
-}
-
-
-// the proportions of the drink expressed in ms of motoro run time
-static motor_command drinks[2][3] =
-{
-    { // Normal
-        { 0, 3560 },  // grenadine
-        { 1, 21360 }, // tequila
-        { 2, 10680 }  // OJ
-    },
-    { // Strong
-        { 0, 3830 },  // grenadine
-        { 1, 19150 }, // tequila
-        { 2, 12770 }  // OJ
-    }
-};
+#endif
+}

 // ---------------------------------------------
 // TSB driver code
@@ -94,6 +139,19 @@
             delay(d);
             duration -= d;
             t += d;
+
+            // If the button is pressed during dispense, STOP!
+            if (digitalRead(2) == LOW || digitalRead(3) == LOW)
+            {
+                digitalWrite(8, LOW);
+                digitalWrite(9, LOW);
+                digitalWrite(10, LOW);
+
+                // Wait until no more buttons are pressed
+                while(digitalRead(2) == LOW || digitalRead(3) == LOW)
+                     ;
+                return;
+            }
         }
         if (cmds[i].motor == 0)
             digitalWrite(8, LOW);
@@ -106,7 +164,9 @@

 void setup()
 {
+#if DEBUG
     Serial.begin(38400);
+#endif

     // Set motor pins as outputs
     pinMode(8, OUTPUT);
@@ -121,19 +181,27 @@
 }

 void loop()
-{
-
+{
     dprintf("\nTequila Sunrise bot. What shall be your bidding?\n\n");
     for(;;)
     {
+        // Let everything settle, avoid bouncy startups
+        delay(100);
         if (digitalRead(2) == LOW)
         {
+            // wait for the button to be depressed
+            while(digitalRead(2) == LOW)
+                     ;
+
             dprintf("making normal drink\n");
             make_drink(3, drinks[0]);
             dprintf("drink complete. bottoms up!\n");
         }
         if (digitalRead(3) == LOW)
         {
+            // wait for the button to be depressed
+            while(digitalRead(3) == LOW)
+                     ;
             dprintf("making strong drink\n");
             make_drink(3, drinks[1]);
             dprintf("drink complete. bottoms up!\n");


Add MIDI receive support to arduino code

--- arduino/walt/walt.ino
+++ arduino/walt/walt.ino
@@ -36,6 +36,7 @@
 #define CMD_AUDIO               'A'
 #define CMD_BEEP                'B'

+#define CMD_MIDI                'M'
 #define CMD_NOTE                'N'

@@ -77,9 +78,9 @@
   char tag;
 };

-#define TRIGGER_COUNT 4
-struct trigger laser, screen, sound, gshock, zero_trigger, copy_trigger;
-struct trigger * triggers[TRIGGER_COUNT] = {&laser, &screen, &sound, &gshock};
+#define TRIGGER_COUNT 5
+struct trigger laser, screen, sound, midi, gshock, zero_trigger, copy_trigger;
+struct trigger * triggers[TRIGGER_COUNT] = {&laser, &screen, &sound, &midi, &gshock};

 #define CLOCK_SYNC_N 9
 struct clock_sync {
@@ -140,6 +141,7 @@
   screen.tag = 'S';
   gshock.tag = 'G';
   sound.tag = 'A';  // for Audio
+  midi.tag = 'M';

   led_state = false;
   interrupts();
@@ -235,6 +237,12 @@
       Serial.print(" ");
       Serial.println(beep_time);
       Serial.send_now();
+    } else if (cmd == CMD_MIDI) {
+      midi.t = 0;
+      midi.count = 0;
+      midi.probe = true;
+      midi.autosend = true;
+      send_ack(CMD_MIDI);
     } else if (cmd == CMD_NOTE) {
       long note_time = time_us;
       usbMIDI.sendNoteOn(60, 99, 1);
@@ -297,6 +305,16 @@
     }
   }

+  // Probe MIDI
+  if(midi.probe) {
+    if(usbMIDI.read()) {
+      midi.t = time_us;
+      midi.count++;
+      midi.probe = false;
+      led_state = !led_state;
+    }
+  }
+
   // Probe screen
   if (screen.probe) {
     int v = analogRead(PD_SCREEN_PIN);


ecart type corrigé

ecart type corrigé

--- calibrateur.ino
+++ calibrateur.ino
@@ -42,15 +42,15 @@
 #include "potar.h"

 //------------------------------------------------------------------------------
-#define DELTA 120
+#define DELTA 150
 #define TEMPOSLEEP 800
 //en ms le temps d'etre sur que le servo ait bougé
 //d'un increment quand on fait les mesure à la roue codeuse

-#define ERREURCOMPTAGE 15 //la tolérance de comptage avant que l'on estime que le servo est arrivé au bout
+#define ERREURCOMPTAGE 10 //la tolérance de comptage avant que l'on estime que le servo est arrivé au bout
 #define NBRCYCLE_AR 10 //nbre de cycle d'aller et retour pour la fin des mesure de caractérisation et nbr de cycle pour la mesure des PWMIN et PWMMAX
-#define TEMPO_STAT 100 // tempo pour laisser le servo avancr lors des mesures
-                       // statistique à la fin de la calibration
+#define TEMPO_STAT 200 // tempo pour laisser le servo avancer lors des mesures
+                       // statistique à la fin de la calibration ATTENTION 100ms semble etre trop court!!!!
 #define ADRESSE_EEPROM 42//position de leeprom ou la valeur de reglage de vitesse est stocké
 #define VITESSEMAXSERVO 3500 // vitesse max d'un servo en microsecond de PWM par seconde
 #define PINSERVO 5 // pin arduino ou est branché le servo
@@ -118,7 +118,7 @@
     {
         ecType=ecType+pow(tab[j]-moy,2);
     }
-    ecType=sqrt(ecType);
+    ecType=sqrt(ecType/tailleTab);
     return ecType;
 }

@@ -131,7 +131,7 @@
     {
         ecType=ecType+pow(tab[j]-moy,2);
     }
-    ecType=sqrt(ecType);
+    ecType=sqrt(ecType/tailleTab);
     return ecType;
 }

@@ -454,7 +454,7 @@
                     etatCalibrateur=WAITCLIC2;
                     break;

-                case WAITCLIC2:
+                case WAITCLIC2:
                     if (boutonP.hasBeenClicked())
                         {
                             boutonP.acquit();
@@ -618,6 +618,7 @@
     if (millis()>5000+temp)
         {
             temp=millis();
+			Serial.println();
             Serial.print("stackLeft=");
             Serial.println(reflechi.stackLeft());
         }


fusion : positioné dans compteimpulsion2 et merge de bugeeprom

# Conflicts:
#	calibrateur.ino

--- calibrateur.ino
+++ calibrateur.ino
@@ -195,10 +195,13 @@
 						{
 							boutonP.acquit();
 							EEPROM.get(ADRESSE_EEPROM, bonnePositionPotence); //lire la prom
-              Serial.println("j'ai lu");
+
+              Serial.println(F("j'ai lu"));
               Serial.println(bonnePositionPotence);
               potence.setObjectif(bonnePositionPotence);
+              sleep( TEMPOSLEEP );
               etatCalibrateur=MESREFPULSE;
+
 						}

 					if (boutonP.hasBeenDoubleClicked())
@@ -234,7 +237,8 @@
 							bonnePositionPotence=map(lePotar.getValue(),0,1023,potence.getMin(),potence.getMax());
 							boutonP.acquit();
               EEPROM.put(ADRESSE_EEPROM, bonnePositionPotence);//enregistre en eeprom
-              Serial.println("sauver en prom");
+              Serial.print(F("sauver en prom = ")); Serial.println( bonnePositionPotence );
+
 							etatCalibrateur=MESREFPULSE;
 						}
 					break;
@@ -262,23 +266,22 @@

 					etatCalibrateur=FINDMINMAX;
 					compteurRef=moyenne(NBRCYCLE_AR,mesureRef);
-          Serial.print(" SUPERcmpteurRefMoyenne=");
+          Serial.print(F(" SUPERcmpteurRefMoyenne="));
           Serial.println(compteurRef);
-
-
-
-
 					if (compteurRef==0)
 						{
 							Serial.println(F("PB : compteur Ref=0 aucune impulsion fourche optique détecté"));
 							Serial.println(F("retour au début de procédure"));
 							etatCalibrateur=USB;
 						}
+
           if (ERREURCOMPTAGE*3>compteurRef)
              {
-              Serial.println("ce serait bien que la marge d'erreur soit de l'ordre de 30% de la mesure de reference");
-							Serial.println("je vais faire autre chose.... Programme a recompiler");
-              Serial.println("modifier macro ERREURCOMPTAGE et DELTA");
+              Serial.println(F("ce serait bien que la marge d'erreur soit de l'ordre de 30% de la mesure de reference"));
+							Serial.println(F("je vais faire autre chose.... Programme a recompiler"));
+              Serial.println(F("modifier macro ERREURCOMPTAGE et DELTA"));
+
+
 							etatCalibrateur=POTAR;
               affichage.affiche(POTAR);
               }


consolodating header checks.

consolodating header checks.

git-svn-id: d8bfcd070c2c81762cca1b3912331324182919ba@17144 0d6f1817-ed0e-0410-87c9-987e46238f29

--- zimodem/proto_http.ino
+++ zimodem/proto_http.ino
@@ -262,24 +262,30 @@
         respCode = atoi(ln.c_str());
       }
       else
-      if(ln.startsWith("Content-length: ")
-      ||ln.startsWith("Content-Length: "))
       {
-        ln.remove(0,16);
-        respLength = atoi(ln.c_str());
-      }
-      else
-      if(ln.startsWith("Location: ")
-      ||ln.startsWith("location: "))
-      {
-        reUrl = ln;
-        reUrl.remove(0,10);
-      }
-      else
-      if(ln.startsWith("Transfer-Encoding: ")
-      ||ln.startsWith("Transfer-encoding: "))
-      {
-          chunked = (ln.indexOf("chunked") > 0) || (ln.indexOf("Chunked") > 0) || (ln.indexOf("CHUNKED") > 0);
+        int x=ln.indexOf(':');
+        if(x>0)
+        {
+          String header = ln.substring(0,x);
+          header.toLowerCase();
+          if(header == "content-length")
+          {
+            ln.remove(0,16);
+            respLength = atoi(ln.c_str());
+          }
+          else
+          if(header == "location")
+          {
+            reUrl = ln;
+            reUrl.remove(0,10);
+          }
+          else
+          if(header == "transfer-encoding")
+          {
+              ln.toLowerCase();
+              chunked = ln.indexOf("chunked") > 0;
+          }
+        }
       }
       ln = "";
     }
@@ -312,6 +318,7 @@
   ||(respCode != 200)
   ||(respLength <= 0))
   {
+
     c->stop();
     delete c;
     return null;


Working version

Working version

--- compare-arduino/compare-arduino.ino
+++ compare-arduino/compare-arduino.ino
@@ -4,18 +4,21 @@

 // A4 pin 1   -> +5V
 // A4 pin 2   -> GND
-// A4 pin 5   -> 7688 Duo pin D0
-// G3 pin 5   -> 7688 Duo pin D11
+// A4 pin 5   -> 7688 Duo pin D11
+// G3 pin 5   -> 7688 Duo pin D9
 // SHT-31 SDA -> 7688 Duo pin D2
 // SHT-31 SCL -> 7688 Duo pin D3
 // DHT-22 DAT -> 7688 Duo pin D4

+#include <stdarg.h>
 #include <Wire.h>
 #include <SoftwareSerial.h>
 #include <Adafruit_SHT31.h>
 #include <DHT.h>
 #include <AM2321.h>

+#define SERIAL_DEBUG  true  // Comment to disable it
+
 #define DHTTYPE DHT22
 #define DHTPIN  4
 #define G3PIN   8
@@ -32,14 +35,22 @@
 DHT dht(DHTPIN, DHTTYPE);
 AM2321 am2321;

+void p(const char *s) {
+#ifdef SERIAL_DEBUG
+  Serial.print(s);
+#endif
+}
+
 void setup() {
   Serial.begin(9600);
   Serial1.begin(57600);
+  p("A4 vs. G3 / DHT22 vs. SHT31\n");
   g3.begin(9600);
   a4.begin(9600);
   dht.begin();
   if (!sht31.begin(0x44)) {
-    Serial.println("Couldn't find SHT31");
+    p("Couldn't find SHT31\n");
+    while(1) delay(1000);
   }
   delay(500);
 }
@@ -47,35 +58,59 @@
 void loop() {
   float t;
   float h;
-  Serial.println("A4 vs. G3 / DHT22 vs. SHT31");
-  /*
   if(readA4()) {
-    Serial.print("A4 :: ");
-    Serial.print("PM 1.0 = ");
+    Serial1.print("A4 ");
+    Serial1.print(pm10);
+    Serial1.print(" ");
+    Serial1.print(pm25);
+    Serial1.print(" ");
+    Serial1.print(pm100);
+    Serial1.print("|");
+#ifdef SERIAL_DEBUG
+    Serial.print("A4 :: PM 1.0 = ");
     Serial.print(pm10);
     Serial.print("   PM 2.5 = ");
     Serial.print(pm25);
     Serial.print("   PM 10 = ");
     Serial.println(pm100);
+#endif
+  } else {
+    return;
   }
   if(readG3()) {
-    Serial.print("G3 :: ");
-    Serial.print("PM 1.0 = ");
+    Serial1.print("G3 ");
+    Serial1.print(pm10);
+    Serial1.print(" ");
+    Serial1.print(pm25);
+    Serial1.print(" ");
+    Serial1.print(pm100);
+    Serial1.print("|");
+#ifdef SERIAL_DEBUG
+    Serial.print("G3 :: PM 1.0 = ");
     Serial.print(pm10);
     Serial.print("   PM 2.5 = ");
     Serial.print(pm25);
     Serial.print("   PM 10 = ");
     Serial.println(pm100);
-  }
-  */
+#endif
+  } else {
+    return;
+  }
   t = sht31.readTemperature();
   h = sht31.readHumidity();
   delay(100);
   if(!isnan(t) && !isnan(h)) {
+    Serial1.print("SHT31 ");
+    Serial1.print(t);
+    Serial1.print(" ");
+    Serial1.print(h);
+    Serial1.print("|");
+#ifdef SERIAL_DEBUG
     Serial.print("SHT31 :: temp=");
     Serial.print(t);
     Serial.print("   hum=");
     Serial.println(h);
+#endif
   } else {
     t = -1;
     h = -1;
@@ -83,20 +118,36 @@
   t = dht.readTemperature();
   h = dht.readHumidity();
   if(!isnan(t) && !isnan(h)) {
+    Serial1.print("AM2302 ");
+    Serial1.print(t);
+    Serial1.print(" ");
+    Serial1.print(h);
+    Serial1.print("|");
+#ifdef SERIAL_DEBUG
     Serial.print("AM2302 :: temp=");
     Serial.print(t);
     Serial.print("   hum=");
     Serial.println(h);
+#endif
   } else {
     t = -1;
     h = -1;
   }
   delay(100);
   am2321.read();
+  t = am2321.temperature / 10.0;
+  h = am2321.humidity / 10.0;
+  Serial1.print("AM2320 ");
+  Serial1.print(t);
+  Serial1.print(" ");
+  Serial1.print(h);
+  Serial1.print("|");
+#ifdef SERIAL_DEBUG
   Serial.print("AM2320 :: temp=");
-  Serial.print(am2321.temperature / 10.0);
+  Serial.print(t);
   Serial.print("   hum=");
-  Serial.println(am2321.humidity / 10.0);
+  Serial.println(h);
+#endif
   delay(1000);
 }

@@ -108,6 +159,7 @@
   pm25 = -1;
   pm100 = -1;
   memset(buf, 0, 32);
+  a4.listen();
   for(x = 0; x < 32;) {
     if(a4.available()) {
       data = a4.read();
@@ -158,11 +210,12 @@
 boolean readG3() {
   unsigned short x;
   byte data;
-  boolean start = false;
+  unsigned short start = 0;
   pm10 = -1;
   pm25 = -1;
   pm100 = -1;
   memset(buf, 0, 24);
+  g3.listen();
   for(x = 0; x < 24;) {
     if(g3.available()) {
       data = g3.read();


fill master

fill master

--- coni/arduino/main/master/master.ino
+++ coni/arduino/main/master/master.ino
@@ -0,0 +1,221 @@
+void setup() {
+  // put your setup code here, to run once:
+  pinMode(53, OUTPUT);
+  pinMode(52, OUTPUT);
+  pinMode(51, OUTPUT);
+  pinMode(50, OUTPUT);
+
+  Serial.begin(9600);
+  Serial2.begin(4800);
+
+  pinMode(12, INPUT_PULLUP);
+
+  pinMode(6, OUTPUT);
+  pinMode(7, OUTPUT);
+  digitalWrite(6, HIGH);
+  digitalWrite(7, HIGH);
+
+}
+
+bool oki = false;
+uint32_t dataOut = 0;
+long dataIn = 0;
+char tag;
+bool inv = false;
+
+String inString = "";
+
+void loop() {
+  /*// put your main code here, to run repeatedly:
+    if (digitalRead(12)) {
+    digitalWrite(52,HIGH);
+    if (oki) {
+      Serial2.println("ciao");
+      oki = false;
+    }
+    }
+    else {
+    digitalWrite(52,LOW);
+    oki = true;
+    }*/
+  if (Serial.available() > 0) {
+    int inChar = Serial.read();
+    if (isDigit(inChar)) {
+      inString += (char)inChar;
+    }
+    else {
+      if ((inChar != '\n') && (inChar != '-')) {
+        tag = ((char)inChar);
+      }
+      else if (inChar == '-') {
+        inv = true;
+      }
+    }
+
+    if (inChar == '\n') {
+
+      dataIn = inString.toInt();
+      if (inv) {
+        dataIn *= -1;
+        inv = false;
+      }
+
+      switch (tag) {
+        case 'a':   //pos A
+          dataOut = dataIn * (100800 / 360) + 500000;
+          Serial.print(tag);
+          Serial.print(dataIn);
+          Serial.print(" // ");
+          Serial.println(dataOut);
+          Serial2.print(dataOut);
+          break;
+        case 'A':
+          if (dataIn > 360) { //vel A
+            dataOut = dataIn + 1500000;
+          }
+          else { //abs A
+            dataOut = dataIn * (100800 / 360) + 16500000;
+          }
+          Serial.print(tag);
+          Serial.print(dataIn);
+          Serial.print(" // ");
+          Serial.println(dataOut);
+          Serial2.print(dataOut);
+          break;
+        case 'b':   //pos B
+          dataOut = dataIn * (100800 / 360) + 2500000;
+          Serial.print(tag);
+          Serial.print(dataIn);
+          Serial.print(" // ");
+          Serial.println(dataOut);
+          Serial2.print(dataOut);
+          break;
+        case 'B':   //vel B
+          if (dataIn > 360) { //vel B
+            dataOut = dataIn + 3500000;
+          }
+          else { //abs B
+            dataOut = dataIn * (100800 / 360) + 17500000;
+          }
+          Serial.print(tag);
+          Serial.print(dataIn);
+          Serial.print(" // ");
+          Serial.println(dataOut);
+          Serial2.print(dataOut);
+          break;
+        case 'c':   //pos C
+          dataOut = dataIn * (100800 / 360) + 6500000;
+          Serial.print(tag);
+          Serial.print(dataIn);
+          Serial.print(" // ");
+          Serial.println(dataOut);
+          Serial2.print(dataOut);
+          break;
+        case 'C':
+          if (dataIn > 360) { //vel C
+            dataOut = dataIn + 7500000;
+          }
+          else { //abs C
+            dataOut = dataIn * (100800 / 360) + 18500000;
+          }
+          Serial.print(tag);
+          Serial.print(dataIn);
+          Serial.print(" // ");
+          Serial.println(dataOut);
+          Serial2.print(dataOut);
+          break;
+        case 'd':   //pos D
+          dataOut = dataIn * (100800 / 360) + 8500000;
+          Serial.print(tag);
+          Serial.print(dataIn);
+          Serial.print(" // ");
+          Serial.println(dataOut);
+          Serial2.print(dataOut);
+          break;
+        case 'D':
+          if (dataIn > 360) { //vel D
+            dataOut = dataIn + 9500000;
+          }
+          else { //abs D
+            dataOut = dataIn * (100800 / 360) + 19500000;
+          }
+          Serial.print(tag);
+          Serial.print(dataIn);
+          Serial.print(" // ");
+          Serial.println(dataOut);
+          Serial2.print(dataOut);
+          break;
+        case 'e':   //pos E
+          dataOut = dataIn * (100800 / 360) + 10500000;
+          Serial.print(tag);
+          Serial.print(dataIn);
+          Serial.print(" // ");
+          Serial.println(dataOut);
+          Serial2.print(dataOut);
+          break;
+        case 'E':
+          if (dataIn > 360) { //vel E
+            dataOut = dataIn + 11500000;
+          }
+          else { //abs E
+            dataOut = dataIn * (100800 / 360) + 20500000;
+          }
+          Serial.print(tag);
+          Serial.print(dataIn);
+          Serial.print(" // ");
+          Serial.println(dataOut);
+          Serial2.print(dataOut);
+          break;
+        case 's':
+          dataOut = 15500000;
+          Serial.print("Stop // ");
+          Serial.println(dataOut);
+          Serial2.print(dataOut);
+          break;
+        case 'z':
+          switch (dataIn) {
+            case 1:
+              dataOut = 4500000;
+              Serial.print("zerosA // ");
+              Serial.println(dataOut);
+              Serial2.print(dataOut);
+              break;
+            case 2:
+              dataOut = 5500000;
+              Serial.print("zerosB // ");
+              Serial.println(dataOut);
+              Serial2.print(dataOut);
+              break;
+            case 3:
+              dataOut = 12500000;
+              Serial.print("zerosC // ");
+              Serial.println(dataOut);
+              Serial2.print(dataOut);
+              break;
+            case 4:
+              dataOut = 13500000;
+              Serial.print("zerosD // ");
+              Serial.println(dataOut);
+              Serial2.print(dataOut);
+              break;
+            case 5:
+              dataOut = 14500000;
+              Serial.print("zerosE // ");
+              Serial.println(dataOut);
+              Serial2.print(dataOut);
+              break;
+            default:
+              Serial.println("motore non esistente");
+              break;
+          }
+          break;
+        default:
+          Serial.println("comando inesistente");
+          break;
+      }
+
+      inString = "";
+
+    }
+  }
+}


Encoder reset functionality; reset encoder to open or closed if both emergency stop and an open or close button are being pressed on startup

--- KomaRoof.ino
+++ KomaRoof.ino
@@ -95,9 +95,11 @@

     if (digitalRead(PIN_BUTTON_EMERGENCYSTOP) == LOW && digitalRead(PIN_BUTTON_CLOSE) == LOW) {
         encoderPosition = ENCODER_RESET_CLOSED;
+        roofState = CLOSED;
     }
     if (digitalRead(PIN_BUTTON_EMERGENCYSTOP) == LOW && digitalRead(PIN_BUTTON_OPEN) == LOW) {
         encoderPosition = ENCODER_RESET_OPEN;
+        roofState = OPEN;
     }

     attachInterrupt(digitalPinToInterrupt(PIN_BUTTON_EMERGENCYSTOP), emergencyStopISR, CHANGE);


Fixed a connection bug in BA4_TGA_Pro_delay_reverb.ino.

--- examples/BA4_TGA_Pro_delay_reverb/BA4_TGA_Pro_delay_reverb.ino
+++ examples/BA4_TGA_Pro_delay_reverb/BA4_TGA_Pro_delay_reverb.ino
@@ -35,13 +35,14 @@
 AudioConnection      patch2b(gainModule, 0, reverb, 0); // then to the reverb

-AudioConnection      patch1(i2sIn,1, mixer,0); // mixer input 0 is our original dry signal
+AudioConnection      patch1(i2sIn,0, mixer,0); // mixer input 0 is our original dry signal
 AudioConnection      patch3(reverb, 0, mixer, 1); // mixer input 1 is our wet

 AudioConnection      patch4(mixer, 0, cabFilter, 0); // mixer outpt to the cabinet filter

 AudioConnection      patch5(cabFilter, 0, i2sOut, 0); // connect the cab filter to the output.
+AudioConnection      patch5b(cabFilter, 0, i2sOut, 1); // connect the cab filter to the output.

 void setup() {


Update arduino.ino

Update arduino.ino

--- arduino/arduino.ino
+++ arduino/arduino.ino
@@ -1,10 +1,140 @@
+float sensitivity = 900.0;
+
+boolean check0 = false;
+boolean check1 = false;
+boolean check2 = false;
+boolean check3 = false;
+boolean check4 = false;
+boolean check5 = false;
+boolean check6 = false;
+boolean check7 = false;
+
 void setup() {
-  Serial.begin(9600);
+Serial.begin(9600);
 }

-int i=1;
 void loop() {
-  Serial.println(i++);
-  if(i==7){i=1;}
-  delay(1000); // poll every 100ms
-}+
+
+float a = analogRead(0);
+float b = analogRead(1);
+float c = analogRead(2);
+float d = analogRead(3);
+float e = analogRead(4);
+float f = analogRead(5);
+float g = analogRead(6);
+float h = analogRead(7);
+
+
+if (a < sensitivity ) {
+if (!check0){
+Serial.println("1");
+check0 = !check0;
+
+}
+}
+
+if (b < sensitivity) {
+if (!check1){
+Serial.println("2");
+check1 = !check1;
+
+}
+}
+
+if (c < sensitivity ) {
+if (!check2){
+Serial.println("3");
+check2 = !check2;
+
+}
+}
+
+if (d < sensitivity ) {
+if (!check3){
+Serial.println("4");
+check3 = !check3;
+
+}
+}
+
+if (e < sensitivity ) {
+if (!check4){
+Serial.println("5");
+check4 = !check4;
+
+}
+}
+
+if (f < sensitivity ) {
+     if (!check5){
+Serial.println("6");
+check5 = !check5;
+}
+}
+
+if (g < sensitivity ) {
+     if (!check6){
+Serial.println("7");
+check6 = !check6;
+}
+}
+
+
+if (h < sensitivity ) {
+     if (!check7){
+Serial.println("8");
+check7 = !check7;
+}
+}
+
+if (a >sensitivity) {
+if (check0){
+check0 = !check0;
+}
+}
+
+if (b >sensitivity) {
+if (check1){
+check1 = !check1;
+}
+}
+
+if (c >sensitivity) {
+if (check2){
+check2 = !check2;
+}
+}
+
+if (d >sensitivity) {
+if (check3){
+check3 = !check3;
+}
+}
+
+if (e >sensitivity) {
+if (check4){
+check4 = !check4;
+}
+}
+
+if (f >sensitivity) {
+if (check5){
+check5 = !check5;
+}
+}
+
+if (g >sensitivity) {
+if (check6){
+check6 = !check6;
+}
+}
+
+if (h >sensitivity) {
+if (check7){
+check7 = !check7;
+}
+}
+
+delay(100);
+}


Update motor_2.ino

Update motor_2.ino

--- arduino/motor_2.ino
+++ arduino/motor_2.ino
@@ -1,11 +1,11 @@
-
+#include <Wire.h>

 double potcurval;    // variable to read the value from the analog pin
 int angel; //Integer value of angle
- double angle =0;
+double angle =0;

- double curangle,kP=28.00,kI=42,kD=4,Last=0;
- double P=0,I=0,D=0,Drive,Error=0,Integral=0;
+double curangle,kP=28.00,kI=42,kD=4,Last=0;
+double P=0,I=0,D=0,Drive,Error=0,Integral=0;

  void backward() {
@@ -27,25 +27,21 @@
   // myservo.attach(6);  // attaches the servo on pin 9 to the servo object
   pinMode(9,OUTPUT);
   pinMode(12,OUTPUT);
-  Serial.begin(9600);
   pinMode(11,OUTPUT);
+  Wire.begin(2);
   Serial.begin(9600);
 }
  void Errorcalc()
  {
    potcurval=(double)analogRead(A0)+1;
    potcurval=(potcurval/1024)*5;
-    curangle=(potcurval/5)*270;
-
-                Error = curangle-angle;
+   curangle=(potcurval/5)*270;
+   Error = curangle-angle;
  }
 void loop()
-{             if(Serial.available()>0)
 {
-   angle=(double)Serial.parseInt()+85;
-
-}
-
+
+  Serial.println(angle);

                  Errorcalc();
                 if (abs(Error) <.8){ // prevent integral 'windup'
@@ -95,3 +91,9 @@
     */

 }
+
+void receiveEvent(int howMany)
+{
+  int x = Wire.read();
+  angle = (double) x;
+}


logger sketch LCD pin modified

logger sketch LCD pin modified

--- code/arduino/logger/logger_sketch/logger_sketch.ino
+++ code/arduino/logger/logger_sketch/logger_sketch.ino
@@ -21,13 +21,13 @@
 // @change pins
 #define DHT11_PIN 2

-int lcd_pin = 13;
-int ldr_pin = A0 ;
+int LCD_PIN = 13;
+int LDR_PIN = A0 ;
 const int chipSelect = 9;

 dht11 DHT11;
 File dataFile;
-LiquidCrystal lcd(7,8, 9, 10, 11, 12);
+LiquidCrystal lcd(7,8, 3, 4, 5, 6);

 void setup() {
@@ -69,8 +69,8 @@

 void lcd_print(char* line1, char* line2) {

-    pinMode(lcd_pin, OUTPUT);
-    digitalWrite(lcd_pin, HIGH);
+    pinMode(LCD_PIN, OUTPUT);
+    digitalWrite(LCD_PIN, HIGH);
     lcd.begin(16,2);
     lcd.clear();
     // line1
@@ -80,7 +80,7 @@
     lcd.print(line2);
 }

-log_data() {
+void log_data() {

     char ts[18] ;
 	char data[12] ;
@@ -117,17 +117,17 @@
     int mm = minute();
     int ss = second();
 	int yyyy = year();
-	int mm = month();
+	int mt = month();
 	int dd = day();

 	// 18 char excel timestamp
-    sprintf(ts,"%02d-%02d-%02d %02d:%02d:%02d",yyyy,mm,dd,hh,mm,ss);
+    sprintf(ts,"%02d-%02d-%02d %02d:%02d:%02d",yyyy,mt,dd,hh,mm,ss);
 	ts[17] = '\0' ;

 	// sensors
     int dht11_code = DHT11.read(DHT11_PIN);
     micro_delay(200);
-	int ldr = analogRead(LDR_Pin);
+	int ldr = analogRead(LDR_PIN);

     if(dht11_code != 0 ) {
         // error


Using pointers instead of by value for the SerialCommunication and MagicRemoteIrCommunication objects.

--- Arduino/Arduino.ino
+++ Arduino/Arduino.ino
@@ -10,34 +10,36 @@
  * - If exists, remove the folder 'RobotIRremote' from C:\Program Files\Arduino\libraries\ (on 64-bit system: C:\Program Files (x86)\Arduino\libraries\)
  * - Connect an IR LED to Arduino pin D3 and GND using a 100 ohm resistor.
  */
-
+
 #include <IRremote.h>

 #include "SerialCommunication.h"
 #include "MagicRemoteIrCommunication.h"

-SerialCommunication serialCommunication;
-MagicRemoteIrCommunication magicRemoteIrCommunication;
+SerialCommunication* serialCommunication;
+MagicRemoteIrCommunication* magicRemoteIrCommunication;

 void setup()
 {
+  serialCommunication = new SerialCommunication();
+  magicRemoteIrCommunication = new MagicRemoteIrCommunication();
 }

 void loop()
 {
-  while(serialCommunication.byteAvailable())
+  while(serialCommunication->byteAvailable())
   {
-    serialCommunication.shiftByteReadIntoReceiveBuffer();
+    serialCommunication->shiftByteReadIntoReceiveBuffer();

-    if(serialCommunication.completeCommandReceived())
+    if(serialCommunication->completeCommandReceived())
     {
-      serialCommunication.sendAcknowledge();
-      byte colorCode = serialCommunication.getColorCodeFromCommand();
-      magicRemoteIrCommunication.sendColorCode(colorCode);
+      serialCommunication->sendAcknowledge();
+      byte colorCode = serialCommunication->getColorCodeFromCommand();
+      magicRemoteIrCommunication->sendColorCode(colorCode);
     }
   }

-  magicRemoteIrCommunication.resendColorCode(3000);
+  magicRemoteIrCommunication->resendColorCode(3000);

   delay(100);  // Sleep 100 millis
 }


Fix circle build?

Fix circle build?

--- photon-firmware/nesnet.ino
+++ photon-firmware/nesnet.ino
@@ -210,7 +210,7 @@
     // What kind of request do we wanna make today? Or... do we need to get more from the NES?
     if (receivedBytes[0] == HTTP_GET) {
         // Get request
-        request.body = NULL;
+        request.body = "\0";
         http.get(request, response, headers);
         // TODO: Implement PUT/POST... Thinking wait for /0 for the main string, then 1 (or 2?) byte length, then data.
     } else if (receivedBytes[0] == HTTP_POST) {
@@ -220,7 +220,7 @@
         request.body = String(receivedPostData);
         http.put(request, response, headers);
     } else if (receivedBytes[0] == HTTP_DELETE) {
-        request.body = NULL;
+        request.body = "\0";
         http.del(request, response, headers);
     } else {
         Particle.publish("unkEvtType", receivedBytes);


Fixed RGB order and 2^10 to 2^8 RGB

Fixed RGB order and 2^10 to 2^8 RGB

--- Tacco_corno/esp_tacco/esp_tacco.ino
+++ Tacco_corno/esp_tacco/esp_tacco.ino
@@ -22,24 +22,24 @@

 // Your WiFi credentials.
 // Set password to "" for open networks.
-//  char ssid[] = "Azionecoop";
-//  char pass[] = "azionecoop2014";
+char ssid[] = "Azionecoop";
+char pass[] = "azionecoop2014";

-char ssid[] = "xxx";
-char pass[] = "xxx";
+//char ssid[] = "xxx";
+//char pass[] = "xxx";

 void showled(int R, int G, int B) {
   //FastLED.clear();
   for (int i = 0; i < NUM_LEDS; i++) {
-    leds[i].setRGB( R, G, B);
+    leds[i].setRGB( R/4, G/4, B/4);
   }
   FastLED.show();
 }

 //Add a zeRGBa Widget and set it to MERGE mode. Choose Virtual Pin V1
 BLYNK_WRITE(V1) {
-  int R = param[0].asInt();
-  int G = param[1].asInt();
+  int G = param[0].asInt();
+  int R = param[1].asInt();
   int B = param[2].asInt();

   showled(R, G, B);


Bugfix: typo

Bugfix: typo

--- GarHAge/GarHAge.ino
+++ GarHAge/GarHAge.ino
@@ -227,9 +227,9 @@

 void publish_birth_message() {
   // Publish the birthMessage
-  Serial.print("Publishing birth message ");
+  Serial.print("Publishing birth message \"");
   Serial.print(birthMessage);
-  Serial.print(" to ");
+  Serial.print("\" to ");
   Serial.print(availabilityTopic);
   Serial.println("...");
   client.publish(availabilityTopic, birthMessage, true);


set reverse to 0 by default

set reverse to 0 by default

--- EggBotArduino/EggBotArduino.ino
+++ EggBotArduino/EggBotArduino.ino
@@ -56,7 +56,7 @@
 #define XAXIS_MAX_STEPCOUNT 300
 #define DEFAULT_ZOOM_FACTOR 1. // With a Zoom-Faktor of .65, I can print gcode for Makerbot Unicorn without changes.
 // The zoom factor can be also manipulated by the propretiary code M402
-#define SERVO_REVERSE 1
+#define SERVO_REVERSE 0  // Set to 1 if your servo is mounted the other way around

 /* --------- */


logToFile

logToFile

--- homemonitor/homemonitor.ino
+++ homemonitor/homemonitor.ino
@@ -1,32 +1,26 @@
 /*
-  SD card read/write
-
- This example shows how to read and write data to and from an SD card file
+Temperature Monitoring system
+
  The circuit:
  * SD card attached to SPI bus as follows:
  ** MOSI - pin 11
  ** MISO - pin 12
  ** CLK - pin 13
  ** CS - pin 4
-
- created   Nov 2010
- by David A. Mellis
- modified 9 Apr 2012
- by Tom Igoe
-
- This example code is in the public domain.
-
+
+  filename has to be short :\ *NOTE*
+
  */
-
-#include <SD.h>
+#include <SD.h> // Modified SD.cpp in SD library to allow for multiple SD.begin() calls
+// Add to Line 343 of SD.cpp: 'if (root.isOpen()) {root.close();}'

 File myFile;
 void readFileToSerial()
 {
   // re-open the file for reading:
-  myFile = SD.open("test.txt");
+  myFile = SD.open("mtest.txt");
   if (myFile) {
-    Serial.println("test.txt:");
+    Serial.println("mtest.txt:");

     // read from the file until there's nothing else in it:
     while (myFile.available()) {
@@ -36,7 +30,39 @@
     myFile.close();
   } else {
   	// if the file didn't open, print an error:
-    Serial.println("error opening test.txt");
+    Serial.println("error opening mtest.txt");
+  }
+}
+
+int counter = 0;
+
+// Append int value to file
+void logToFile(char* filename, int value)
+{
+  // open the file. note that only one file can be open at a time,
+  // so you have to close this one before opening another.
+  myFile = SD.open(filename, FILE_WRITE);
+
+  // if the file opened okay, write to it:
+  if (myFile) {
+    // Serial info
+    Serial.print("Writing ");
+    Serial.print(value);
+    Serial.print(" to ");
+    Serial.print(filename);
+    Serial.print("... ");
+
+    // Write value to file and close
+    myFile.println(value);
+    myFile.close();
+
+    // Update counter
+    counter++;
+
+    Serial.println("done.");
+  } else {
+    // if the file didn't open, print an error:
+    Serial.println("error opening for writing.");
   }
 }

@@ -60,7 +86,7 @@
 {
  // Open serial communications and wait for port to open:
   Serial.begin(9600);
-   while (!Serial) {
+  while (!Serial) {
     ; // wait for serial port to connect. Needed for Leonardo only
   }

@@ -77,21 +103,7 @@
     return;
   }

-  // open the file. note that only one file can be open at a time,
-  // so you have to close this one before opening another.
-  myFile = SD.open("test.txt", FILE_WRITE);
-
-  // if the file opened okay, write to it:
-  if (myFile) {
-    Serial.print("Writing to test.txt...");
-    myFile.println("testing 1, 2, 3.");
-	// close the file:
-    myFile.close();
-    Serial.println("done.");
-  } else {
-    // if the file didn't open, print an error:
-    Serial.println("error opening test.txt");
-  }
+  logToFile("mtest.txt", counter);

   readFileToSerial();

@@ -107,6 +119,7 @@
     Serial.println("Woo");
     if (startSD())
     {
+      logToFile("mtest.txt", counter);
       readFileToSerial();
     }
     buttonPressed = false;


telemeter scan

telemeter scan

--- polar-scanner.ino
+++ polar-scanner.ino
@@ -12,7 +12,7 @@
 #define BPS_HOST 9600
 #define COMMS_BUFFER_SIZE 1024
 #define SERIAL_HOST_DELAY_MS 10000
-
+#define SCAN_STEP_DELAY_MS 600
 /*
  * ultra sonic telemeter mesure
  */
@@ -45,6 +45,7 @@
 	IN_CMD,
 	IN_SERVO,
 	IN_STEPPER,
+	IN_SCAN_PARAMETERS,
 	SENSOR_MESURE
 };

@@ -145,6 +146,28 @@
 	echoDuration = pulseIn(INECHO, HIGH, ECHO_TIMEOUT);
 	mesureCm = echoDuration ? ECHO2CM(echoDuration) : MAX_CM;
 	return mesureCm;
+}
+
+/*
+ * telemeter scan
+ */
+int telemeterscan(int stepperStep, int stepperN, int servoStep, int servoN, int servoFrom) {
+	int stepperInc, servoInc;
+	Serial.println();
+	for (stepperInc=0; stepperInc<stepperN; stepperInc++) {
+		Serial.print(stepperInc * stepperStep);
+		Serial.print(" / ");
+		for (servoInc=0; servoInc<servoN; servoInc++) {
+			servoCommand(servoFrom + (servoInc * servoStep));
+			delay(SCAN_STEP_DELAY_MS);
+			Serial.print(servoFrom + (servoInc * servoStep));
+			Serial.print(":");
+			Serial.print(telemeterMesure());
+			Serial.print(" ");
+		}
+		Serial.println();
+		stepperCommand(stepperStep);
+	}
 }

 /*
@@ -194,6 +217,8 @@
 				newState = IN_STEPPER;
 			else if (!strcmp(input,"MESURE"))
 				newState = SENSOR_MESURE;
+			else if (!strcmp(input,"SCAN"))
+				newState = IN_SCAN_PARAMETERS;
 			break;

 		case IN_SERVO:
@@ -209,6 +234,27 @@
 				while (!(input = userInput(NULL)));
 			value = atoi(input);
 			stepperCommand(value);
+			newState = IN_CMD;
+			break;
+
+		case IN_SCAN_PARAMETERS:
+			int stSt, stNb, srSt, srNb, srFr;
+			if (!(input = userInput("STEPPER STEP: ")))
+				while (!(input = userInput(NULL)));
+			stSt = atoi(input);
+			if (!(input = userInput("STEPPER NBR: ")))
+				while (!(input = userInput(NULL)));
+			stNb = atoi(input);
+			if (!(input = userInput("SERVO STEP: ")))
+				while (!(input = userInput(NULL)));
+			srSt = atoi(input);
+			if (!(input = userInput("SERVO NBR: ")))
+				while (!(input = userInput(NULL)));
+			srNb = atoi(input);
+			if (!(input = userInput("SERVO FROM: ")))
+				while (!(input = userInput(NULL)));
+			srFr = atoi(input);
+			telemeterscan(stSt, stNb, srSt, srNb, srFr);
 			newState = IN_CMD;
 			break;

@@ -226,5 +272,6 @@
 }

 void loop() {
+//	telemeterscan(64, 8, 30, 4, 30);
 	currentState = stateTransition(currentState);
 }


Finer control intervals.

Finer control intervals.

--- C2_JoyStick_Control.ino
+++ C2_JoyStick_Control.ino
@@ -40,14 +40,14 @@
  Quiescent current calculation works on brake and steer; motor current seems high.
  Steering servo works. Steering limits have been set and linkage reattached.
  Wrote routines to ease back on servo requests when too much current is drawn.
-
+ Phsically put everything back together.
+ Test all systems on test stand.
+
  To Do:
  Joystick Center is not read properly. See 2.38V at joystick for center; that voltage does not make it
  to analog input pin 8; continuity problem? Problem bypassed by setting a wide deadband.
- Phsically put everything back together.
  Motor gives jerky response at low speeds; need to smooth it out.
  Brake pusher rod sometimes slips off lever.
- Test all systems on test stand.
  Do a road test.
  Shoot a video and post it.
  */
@@ -101,12 +101,19 @@
 const int BRAKE = 2;
 /* Steering servo can handle 44 counts per second;
    Brake servo is good for 88 counts per second.
-   BigChange is based on being updated every 500 mSec.
 */
-const int BigChange = 20;  // counts per step
-const int MaxBrakeChange = 40; // counts per step
-const int MotorFull = 179;   // fully on for PWM signals
-const int MotorMin  = 69;
+const int MaxBrakeSlew = 88;  // counts / sec
+const int MaxSteerSlew = 44;  // counts / sec
+const int LoopPeriod = 100;  // msec
+/* The mechanical throttle outputs a voltage between 0.84V (32 counts)
+   and 3.55 V (181 counts).
+   The motor does not respond until about 1.30 V (66 counts)
+*/
+const int MaxMotorChange = (70*LoopPeriod)/1000;  // counts per step for motor
+const int MaxBrakeChange = (MaxBrakeSlew*LoopPeriod)/1000; // counts per step
+const int MaxSteerChange = (MaxSteerSlew*LoopPeriod)/1000;
+const int MotorFull = 186;   // fully on for PWM signals
+const int MotorMin  = 66;
 const int MotorOff = 0;
 const int FullThrottle =  179;   // 3.5 V
 const int MinimumThrottle = 39;  // Throttle has no effect until 0.75 V
@@ -245,19 +252,23 @@
      TargetMotor = MotorOff;
      TargetBrake = BrakeOff + (throttle + 84) / 3;
   }
-  else if (throttle < 84)
+  else if (throttle < 45)
   {  // deadband
      TargetMotor = MotorOff;
      TargetBrake = BrakeOff;
   }
+  else if (throttle < 111)
+  {  // deadband
+     TargetMotor = throttle-45;
+     TargetBrake = BrakeOff;
+  }
   else
   {
     TargetBrake = BrakeOff;
-    TargetMotor = MotorMin + (throttle - 84) / 2;
+    TargetMotor = MotorMin + (throttle - 111) / 3;
   }
   ChangeBrake = TargetBrake - Servos[BRAKE].OutputValue;
-  ChangeMotor = TargetMotor - Servos[MOTOR].OutputValue;
-  if (Servos[BRAKE].mAmp > 4700)
+  /* if (Servos[BRAKE].mAmp > 4700)
   { // ease back to keep from blowing fuse
       ChangeBrake = (ChangeBrake > 0)? -2: 2;
   }
@@ -265,7 +276,8 @@
   {
       ChangeBrake = (ChangeBrake>0)? 2: -2;
   }
-  else if (ChangeBrake > MaxBrakeChange)
+  else */
+  if (ChangeBrake > MaxBrakeChange)
   {
       ChangeBrake = MaxBrakeChange;
   }
@@ -273,13 +285,17 @@
   {
       ChangeBrake = -MaxBrakeChange;
   }
-  if (ChangeMotor > BigChange)
-  {
-      ChangeMotor = BigChange;
-  }
-  else if (ChangeMotor < -BigChange)
-  {
-      ChangeMotor = -BigChange;
+  ChangeMotor = TargetMotor - Servos[MOTOR].OutputValue;
+  int EffectiveMotorChange = ChangeMotor > 0?
+      min(TargetMotor, MotorFull) - max(MotorMin, Servos[MOTOR].OutputValue):
+      min(Servos[MOTOR].OutputValue, MotorFull) - max(MotorMin, TargetMotor);
+  if (EffectiveMotorChange > MaxMotorChange)
+  {
+      ChangeMotor = MaxMotorChange;
+  }
+  else if (EffectiveMotorChange < -MaxMotorChange)
+  {
+      ChangeMotor = -MaxMotorChange;
   }
   Servos[BRAKE].OutputValue += ChangeBrake;
   Servos[BRAKE].OutputValue = max(BrakeOn /*128 */, Servos[BRAKE].OutputValue);
@@ -315,7 +331,7 @@
       TargetSteer = HalfRight /* 159 */ - (steer - 468);
   }
   Change = TargetSteer - Servos[STEER].OutputValue;
-  if (Servos[STEER].mAmp > 4700)
+/*  if (Servos[STEER].mAmp > 4700)
   { // ease back to keep from blowing fuse
       if (Servos[STEER].OutputValue < HalfRight)
         Change = 2;
@@ -328,13 +344,14 @@
   {
       Change = (Change>0)? 2: -2;
   }
-  else if (Change > BigChange)
-  {
-      Change = BigChange;
-  }
-  else if (Change < -BigChange)
-  {
-      Change = -BigChange;
+  else */
+  if (Change > MaxSteerChange)
+  {
+      Change = MaxSteerChange;
+  }
+  else if (Change < -MaxSteerChange)
+  {
+      Change = -MaxSteerChange;
   }
   Servos[STEER].OutputValue += Change;
   Servos[STEER].OutputValue = max(HardRight /*128 */, Servos[STEER].OutputValue);
@@ -385,9 +402,8 @@

 void loop()
 {
-  const unsigned long pause = 500; // msec
   unsigned long time = millis();
-  unsigned long endTime = time + pause;
+  unsigned long endTime = time + LoopPeriod;

 // Read joy stick and 3 switches; Send stick to enabled servos.
   int  n;


Add option for RX pin pullup and send whole buffer for received raw messages in IRMQTTServer.ino (#589)

* Add option for RX pin pullup in IRMQTTServer.ino
* Send whole buffer for received raw messages in IRMQTTServer.ino
* Make sending the whole buffer optional.
* Add comments to increase MQTT_MAX_PACKET_SIZE.

--- examples/IRMQTTServer/IRMQTTServer.ino
+++ examples/IRMQTTServer/IRMQTTServer.ino
@@ -27,6 +27,7 @@
  *     - WiFiManager (https://github.com/tzapu/WiFiManager) (Version >= 0.14)
  *     - PubSubClient (https://pubsubclient.knolleary.net/)
  *   o You MUST change <PubSubClient.h> to have the following (or larger) value:
+ *     (with REPORT_RAW_UNKNOWNS 1024 or more is recommended)
  *     #define MQTT_MAX_PACKET_SIZE 512
  * - PlatformIO IDE:
  *     If you are using PlatformIO, this should already been done for you in
@@ -151,6 +152,8 @@
 // Change to 'true'/'false' if you do/don't want these features or functions.
 #define USE_STATIC_IP false  // Change to 'true' if you don't want to use DHCP.
 #define REPORT_UNKNOWNS false  // Report inbound IR messages that we don't know.
+#define REPORT_RAW_UNKNOWNS false  // Report the whole buffer, recommended:
+                                   // MQTT_MAX_PACKET_SIZE of 1024 or more
 #define MQTT_ENABLE true  // Whether or not MQTT is used at all.
 // 'kHtmlUsername' & 'kHtmlPassword' are used by the following two items:
 #define FIRMWARE_OTA true  // Allow remote update of the firmware via http.
@@ -190,6 +193,7 @@
 // GPIO the IR RX module is connected to/controlled by. GPIO 14 = D5.
 // Comment this out to disable receiving/decoding IR messages entirely.
 #define IR_RX 14  // <=- CHANGE_ME (optional)
+#define IR_RX_PULLUP false
 const uint16_t kHttpPort = 80;  // The TCP port the HTTP server is listening on.
 // Name of the device you want in mDNS.
 // NOTE: Changing this will change the MQTT path too unless you override it
@@ -381,7 +385,11 @@
     "Last message sent: " + String(lastSendSucceeded ? "Ok" : "FAILED") +
     " (" + timeSince(lastSendTime) + ")
"
 #ifdef IR_RX
-    "IR Recv GPIO: " + String(IR_RX) + "
"
+    "IR Recv GPIO: " + String(IR_RX) +
+#if IR_RX_PULLUP
+    " (pullup)"
+#endif  // IR_RX_PULLUP
+    "
"
     "Total IR Received: " + String(irRecvCounter) + "
"
     "Last IR Received: " + lastIrReceived +
     " (" + timeSince(lastIrReceivedTime) + ")
"
@@ -1112,6 +1120,9 @@
   irsend.begin();
   offset = irsend.calibrate();
 #if IR_RX
+#if IR_RX_PULLUP
+  pinMode(IR_RX, INPUT_PULLUP);
+#endif  // IR_RX_PULLUP
 #if DECODE_HASH
   // Ignore messages with less than minimum on or off pulses.
   irrecv.setUnknownThreshold(kMinUnknownSize);
@@ -1283,6 +1294,22 @@
     lastIrReceivedTime = millis();
     lastIrReceived = String(capture.decode_type) + "," +
         resultToHexidecimal(&capture);
+#if REPORT_RAW_UNKNOWNS
+    if (capture.decode_type == UNKNOWN) {
+      lastIrReceived += ";";
+      for (uint16_t i = 1; i < capture.rawlen; i++) {
+        uint32_t usecs;
+        for (usecs = capture.rawbuf[i] * kRawTick; usecs > UINT16_MAX;
+             usecs -= UINT16_MAX) {
+          lastIrReceived += uint64ToString(UINT16_MAX);
+          lastIrReceived += ",0,";
+        }
+        lastIrReceived += uint64ToString(usecs, 10);
+        if (i < capture.rawlen - 1)
+          lastIrReceived += ",";
+      }
+    }
+#endif  // REPORT_RAW_UNKNOWNS
     // If it isn't an AC code, add the bits.
     if (!hasACState(capture.decode_type))
       lastIrReceived += "," + String(capture.bits);


Addedd missing comments, and removed useless code in the .ino file

--- sketch_oct19a/sketch_oct19a.ino
+++ sketch_oct19a/sketch_oct19a.ino
@@ -1,41 +1,64 @@
+// Including the dht library used by the humidity/temperature sensor
 #include <dht.h>
+
+// Including the LiquidCrystal library used by the LCD display
 #include <LiquidCrystal.h>

-#define dht_dpin A0 //no ; here. Set equal to channel sensor is on
+// Defining the analog in used by the DHT sensor
+#define dht_dpin A0

+// Creating a DHT instance
 dht DHT;
+
+// Creating a LiquidCrystal instance
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

-void setup(){
+void setup() {
+
+  // Initialize the serial virtual output display
   Serial.begin(9600);
+
+  // Inizialize the lcd instance
   lcd.begin(16, 2);
-  delay(300);//Let system settle
+
+  // Let system settle
+  delay(300);
+
+  // Print in Serial display
   Serial.println("Humidity and temperature\n\n");
-  delay(700);//Wait rest of 1000ms recommended delay before
-  //accessing sensor
-}//end "setup()"
+
+  // Wait rest of 1000ms recommended delay before accessing the sensor
+  delay(700);
+}

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

-    Serial.print("Current humidity = ");
-    Serial.print(DHT.humidity);
-    Serial.print("%  ");
-    Serial.print("temperature = ");
-    Serial.print(DHT.temperature);
-    lcd.setCursor(0, 0);
-    lcd.print("Temp: ");
-    lcd.print(DHT.temperature);
-    lcd.print(" ");
-    lcd.print(char(223));
-    lcd.print("C");
-    lcd.setCursor(0, 1);
-    lcd.print("Hum: ");
-    lcd.print(DHT.humidity);
-    lcd.print(" %");
-    Serial.println("C  ");
-  delay(2000);//Don't try to access too frequently... in theory
-  //should be once per two seconds, fastest,
-  //but seems to work after 0.8 second.
-}// end loop()
+  // Print the data received from the DHT sensor in the serial display
+  Serial.print("Current humidity = ");
+  Serial.print(DHT.humidity);
+  Serial.print("%  ");
+  Serial.print("temperature = ");
+  Serial.print(DHT.temperature);
+  Serial.println("C  ");
+  // End
+
+  // Now do the same thing for the LCD display
+  lcd.setCursor(0, 0);
+  lcd.print("Temp: ");
+  lcd.print(DHT.temperature);
+  lcd.print(" ");
+  lcd.print(char(223));
+  lcd.print("C");
+  lcd.setCursor(0, 1);
+  lcd.print("Hum: ");
+  lcd.print(DHT.humidity);
+  lcd.print(" %");
+  // End
+
+  // Don't try to access too frequently.
+  // Theoretically should be once per two seconds
+  delay(2000);
+}


some cleaning and add 3 show and the selector

--- coni/arduino/test/remote/button.ino
+++ coni/arduino/test/remote/button.ino
@@ -5,12 +5,17 @@
 #define BT_B A8 //1 premuto
 #define SEL_Gp A5 //0 su G e 1 su p

+#define passetto 10
+#define vel_passetti 3000
+
+#define NUM_CHANNELS 16
+
 long muovi(char let, int vel, int posA, int posB, int posC = 0);
 long t0 = 0;
 long dd = 100;
 long tdd = 0;

-uint8_t channels[16] = {53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38};
+uint8_t channels[NUM_CHANNELS] = {53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38};

 void setup() {
   pinMode(MAINSW, INPUT_PULLUP);
@@ -20,6 +25,10 @@
   pinMode(BT_B, INPUT_PULLUP);
   pinMode(SEL_Gp, INPUT_PULLUP);

+  for (int i=0; i<NUM_CHANNELS; i++) {
+    pinMode(channels[i], OUTPUT);
+  }
+
   Serial.begin(9600);

   Serial2.begin(4800);
@@ -35,189 +44,70 @@
   while (digitalRead(MAINSW)) //SHOW
   {
     if (act == 0) {
-      t0= millis();
+      t0 = millis();
       Serial.println("ACT 0");
       inviatop = false;
       inviatoG = false;
       act++;
-    }
-    show_uno();
+      att1 = 0;
+      att2 = 0;
+    }
+    if ((digitalRead(SEL_A) == 0) && (digitalRead(SEL_B) == 1)) //A
+    {
+      show_uno();
+    }
+    else if ((digitalRead(SEL_A) == 1) && (digitalRead(SEL_B) == 1)) //B
+    {
+      show_due();
+    }
+    else if ((digitalRead(SEL_A) == 1) && (digitalRead(SEL_B) == 0)) //C
+    {
+      show_tre();
+    }
+
+
   }
   while (!digitalRead(MAINSW)) //TEST
   {
+    // Reset the Act. for the Next Show.
     act = 0;

+    // COMMAND FROM SERIAL AVAILABLE
+    // p 20 -60     >> move little cone A: 20 degree clockwise - B: 60 degree counterclockwise
+    // P 2000       >> set velocity of little cone to 2000
+    // g 90 -90 90  >> move big cone
+    // G 4000       >> set velocity of big cone
     if (Serial.available() > 0) {
       Serial2.write(Serial.read());
     }

-    if ((digitalRead(SEL_A) == 0) && (digitalRead(SEL_B) == 1)) //A
-    {
-      if (digitalRead(BT_A) == 0)  //premuto
-      {
-        if (digitalRead(SEL_Gp)) //1 è piccolo
-        {
-          Serial.println("motore A orario");
-          ///////////////////////////
-          Serial2.print("P 3000");
-          Serial2.print('\r');
-          delay(100);
-          Serial2.print("p 10 0");
-          Serial2.print('\r');
-        }
-        else
-        {
-          Serial.println("motore C orario");
-          Serial2.print("G 3000");
-          Serial2.print('\r');
-          delay(100);
-          Serial2.print("g 10 0 0");
-          Serial2.print('\r');
-          ////////////////////////////
-        }
-        delay(1000);
-      }
-      else if (digitalRead(BT_B) == 1)  //premuto
-      {
-        if (digitalRead(SEL_Gp)) //1 è piccolo
-        {
-          Serial.println("motore A antiorario");
-          ///////////////////////////
-          Serial2.print("P 3000");
-          Serial2.print('\r');
-          delay(100);
-          Serial2.print("p -10 0");
-          Serial2.print('\r');
-        }
-        else
-        {
-          Serial.println("motore C antiorario");
-          Serial2.print("G 3000");
-          Serial2.print('\r');
-          delay(100);
-          Serial2.print("g -10 0 0");
-          Serial2.print('\r');
-          ////////////////////////////
-        }
-        delay(1000);
-      }
-    }
-    else if ((digitalRead(SEL_A) == 1) && (digitalRead(SEL_B) == 1)) //B
-    {
-      if (digitalRead(BT_A) == 0)  //premuto
-      {
-        if (digitalRead(SEL_Gp)) //1 è piccolo
-        {
-          Serial.println("motore B orario");
-          ///////////////////////////
-          Serial2.print("P 3000");
-          Serial2.print('\r');
-          delay(100);
-          Serial2.print("p 0 10");
-          Serial2.print('\r');
-        }
-        else
-        {
-          Serial.println("motore D orario");
-          Serial2.print("G 3000");
-          Serial2.print('\r');
-          delay(100);
-          Serial2.print("g 0 -10 0");
-          Serial2.print('\r');
-          ////////////////////////////
-        }
-        delay(1000);
-      }
-      else if (digitalRead(BT_B) == 1)  //premuto
-      {
-        if (digitalRead(SEL_Gp)) //1 è piccolo
-        {
-          Serial.println("motore B antiorario");
-          ///////////////////////////
-          Serial2.print("P 3000");
-          Serial2.print('\r');
-          delay(100);
-          Serial2.print("p 0 -10");
-          Serial2.print('\r');
-        }
-        else
-        {
-          Serial.println("motore D antiorario");
-          Serial2.print("G 3000");
-          Serial2.print('\r');
-          delay(100);
-          Serial2.print("g 0 10 0");
-          Serial2.print('\r');
-          ////////////////////////////
-        }
-
-        delay(1000);
-      }
-    }
-    else if ((digitalRead(SEL_A) == 1) && (digitalRead(SEL_B) == 0)) //C
-    {
-      if (digitalRead(BT_A) == 0)  //premuto
-      {
-        if (digitalRead(SEL_Gp)) //1 è piccolo
-        {
-          Serial.println("motore inesistente");
-        }
-        else
-        {
-          Serial.println("motore E orario");
-          Serial2.print("G 3000");
-          Serial2.print('\r');
-          delay(100);
-          Serial2.print("g 0 0 10");
-          Serial2.print('\r');
-          ////////////////////////////
-        }
-        delay(1000);
-      }
-      else if (digitalRead(BT_B) == 1)  //premuto
-      {
-        if (digitalRead(SEL_Gp)) //1 è piccolo
-        {
-          Serial.println("motore inesistente");
-        }
-        else
-        {
-          Serial.println("motore E antiorario");
-
-          Serial2.print("G 3000");
-          Serial2.print('\r');
-          delay(100);
-          Serial2.print("g 0 0 -10");
-          Serial2.print('\r');
-          ////////////////////////////
-        }
-        delay(1000);
-      }
-    }
-  }
-}
-
-void attore(int scena,char let_G, int vel_G, int posG_a, int posG_b, int posG_c, char let_p, int vel_p, int posp_a, int posp_b, int pausa) {
+    // Check button
+    checkButton();
+
+  }
+}
+
+void attore(int scena, char let_G, int vel_G, int posG_a, int posG_b, int posG_c, char let_p, int vel_p, int posp_a, int posp_b, int pausa) {

   if (act == scena) {
     if (inviatoG == false) {
-      att1 = muovi(let_G,vel_G,posG_a,posG_b,posG_c);
-      digitalWrite(channels[act], HIGH);
+      att1 = muovi(let_G, vel_G, posG_a, posG_b, posG_c);
+      digitalWrite(channels[act-1], HIGH);
       Serial.println("mando scena G");
       Serial.println(act);
       inviatoG = true;
       tdd = millis();
     }
     if ((inviatop == false) && ((long)(millis() - tdd) > dd)) {
-      att2 = muovi(let_p,vel_p,posp_a,posp_b);
+      att2 = muovi(let_p, vel_p, posp_a, posp_b);
       Serial.println("mando scena p");
       Serial.println(act);
       inviatop = true;
     }
-    if ((long)(millis() - t0) > (long)(magg(att1,att2) + pausa)) {
+    if ((long)(millis() - t0) > (long)(magg(att1, att2) + pausa)) {
       inviatop = false;
       inviatoG = false;
-      digitalWrite(channels[act], LOW);
+      digitalWrite(channels[act-1], LOW);
       t0 = millis();

       act++;
@@ -227,35 +117,55 @@

 void show_uno() {

-  // //intro
-  attore(1,'g',2000, -180,  -180,  180, 'p',2000, -150, 180,  8000); //def
-  attore(2,'g',2000, 0,  -180,  -180, 'p',2500, 150, -180,  8000); //def
-  attore(3,'g',2000, 0,  80,  110, 'p',3400, -130, 180,  8000); //def
-  attore(4,'g',3000, 180,  -250,  -110, 'p',1800, 130, -180,  8000); //def
+  //intro
+  attore(1, 'g', 2000, -180,  -180,  180, 'p', 2000, -150, 180,  8000); //def
+  attore(2, 'g', 2000, 0,  -180,  -180, 'p', 2500, 150, -180,  8000); //def
+  attore(3, 'g', 2000, 0,  80,  110, 'p', 3400, -130, 180,  8000); //def
+  attore(4, 'g', 3000, 180,  -250,  -110, 'p', 1800, 130, -180,  8000); //def

   //dance
-  attore(5,'g',4000, -640,  300,  -720, 'p',3000, 540, -540,  15000); //def
-  attore(6,'g',4000, 110,  -310,  -190, 'p',3000, -360, 360,  6000); //def
+  attore(5, 'g', 4000, -640,  300,  -720, 'p', 3000, 540, -540,  15000); //def
+  attore(6, 'g', 4000, 110,  -310,  -190, 'p', 3000, -360, 360,  6000); //def

   //outro
-  attore(7,'g',2000, 160,  170,  180, 'p',1500, 175, -170,  6000); //def
-  //
-
-}
-
-void show_def() {
+  attore(7, 'g', 2000, 160,  170,  180, 'p', 1500, 175, -170,  6000); //def
+
+}
+
+void show_due() {

   //intro
-  attore(1,'g',2000, -180,  -180,  180, 'p',3000, -240, 180,  2000); //def
-  attore(2,'g',2000, 0,  -180,  -180, 'p',2000, 240, -180,  2000); //def
-  attore(3,'g',2000, 0,  80,  110, 'p',3000, -130, 180,  2000); //def
-  attore(4,'g',2800, 180,  -80,  -110, 'p',2800, 130, -180,  2000); //def
+  attore(1, 'g', 2000, -180,  -180,  180, 'p', 2000, -150, 180,  8000); //def
+  attore(2, 'g', 2000, 0,  -180,  -180, 'p', 2500, 150, -180,  8000); //def
+  attore(3, 'g', 2000, 0,  80,  110, 'p', 3400, -130, 180,  8000); //def
+  attore(4, 'g', 3000, 180,  -250,  -110, 'p', 1800, 130, -180,  5000); //def

   //dance
-  attore(5,'g',4000, -720,  -90,  -720, 'p',4000, 720, 720,  2000); //def
-  attore(6,'g',4000, 720,  90,  720, 'p',4000, -720, -720,  2000); //def
-
-}
+  attore(5, 'g', 4000, -640,  300,  -720, 'p', 2800, 540, -540,  13000); //def
+  attore(6, 'g', 4000, 110,  -310,  -190, 'p', 3000, -360, 360,  6000); //def
+
+  //outro
+  attore(7, 'g', 2000, 160,  170,  180, 'p', 1500, 175, -170,  6000); //def
+
+}
+
+void show_tre() {
+
+  //intro
+  attore(1, 'g', 2000, -180,  -180,  180, 'p', 2000, -150, 180,  8000); //def
+  attore(2, 'g', 2000, 0,  -180,  -180, 'p', 2500, 150, -180,  8000); //def
+  attore(3, 'g', 2000, 0,  80,  110, 'p', 3400, -130, 180,  8000); //def
+  attore(4, 'g', 3000, 180,  -250,  -110, 'p', 1800, 130, -180,  8000); //def
+
+  //dance
+  attore(5, 'g', 4000, -640,  300,  -720, 'p', 3000, 540, -540,  15000); //def
+  attore(6, 'g', 4000, 110,  -310,  -190, 'p', 3000, -360, 360,  6000); //def
+
+  //outro
+  attore(7, 'g', 2000, 160,  170,  180, 'p', 1500, 175, -170,  6000); //def
+
+}
+

 long magg(long a, long b) {
   if (a >= b) {
@@ -271,42 +181,30 @@

   if (let == 'p') {
     char LET = 'P';
-
     payload = "";
-
     payload += LET;
     payload += " ";
     payload += String(vel);
     payload += '\r';
-
     Serial2.print(payload);
-
     payload = "";
-
     payload += let;
     payload += " ";
     payload += String(posA);
     payload += " ";
     payload += String(posB);
     payload += '\r';
-
     Serial2.print(payload);
-
   }
   else if (let == 'g') {
     char LET = 'G';
-
     payload = "";
-
     payload += LET;
     payload += " ";
     payload += String(vel);
     payload += '\r';
-
     Serial2.print(payload);
-
     payload = "";
-
     payload += let;
     payload += " ";
     payload += String(posA);
@@ -315,7 +213,6 @@
     payload += " ";
     payload += String(posC);
     payload += '\r';
-
     Serial2.print(payload);
   }

@@ -337,9 +234,100 @@
     }
   }

-
-
-  return ((maxx * 100800 / 360) / vel) * 1000;
-
-
-}
+  return (long)(((maxx * 100800 / 360) / vel) * 1000);
+}
+
+void checkButton() {
+  if ((digitalRead(SEL_A) == 0) && (digitalRead(SEL_B) == 1)) //A
+  {
+    if (digitalRead(BT_A) == 0)  //premuto
+    {
+      if (digitalRead(SEL_Gp)) //1 è piccolo
+      {
+        Serial.println("motore A orario");
+        muovi('p', vel_passetti, passetto, 0);
+      }
+      else
+      {
+        Serial.println("motore C orario");
+        muovi('g',3000, vel_passetti,0,0);
+      }
+      delay(1000);
+    }
+    else if (digitalRead(BT_B) == 1)  //premuto
+    {
+      if (digitalRead(SEL_Gp)) //1 è piccolo
+      {
+        Serial.println("motore A antiorario");
+        muovi('p', vel_passetti, -passetto, 0);
+      }
+      else
+      {
+        Serial.println("motore C antiorario");
+        muovi('g',vel_passetti,-passetto, 0, 0);
+      }
+      delay(1000);
+    }
+  }
+  else if ((digitalRead(SEL_A) == 1) && (digitalRead(SEL_B) == 1)) //B
+  {
+    if (digitalRead(BT_A) == 0)  //premuto
+    {
+      if (digitalRead(SEL_Gp)) //1 è piccolo
+      {
+        Serial.println("motore B orario");
+        muovi('p',vel_passetti,0, passetto);
+      }
+      else
+      {
+        Serial.println("motore D orario");
+        muovi('g',vel_passetti,0, passetto, 0);
+      }
+      delay(1000);
+    }
+    else if (digitalRead(BT_B) == 1)  //premuto
+    {
+      if (digitalRead(SEL_Gp)) //1 è piccolo
+      {
+        Serial.println("motore B antiorario");
+        muovi('p',vel_passetti,0, -passetto);
+      }
+      else
+      {
+        Serial.println("motore D antiorario");
+        muovi('g',vel_passetti,0, -passetto, 0);
+      }
+
+      delay(1000);
+    }
+  }
+  else if ((digitalRead(SEL_A) == 1) && (digitalRead(SEL_B) == 0)) //C
+  {
+    if (digitalRead(BT_A) == 0)  //premuto
+    {
+      if (digitalRead(SEL_Gp)) //1 è piccolo
+      {
+        Serial.println("motore inesistente");
+      }
+      else
+      {
+        Serial.println("motore E orario");
+        muovi('g',vel_passetti,0, 0, passetto);
+      }
+      delay(1000);
+    }
+    else if (digitalRead(BT_B) == 1)  //premuto
+    {
+      if (digitalRead(SEL_Gp)) //1 è piccolo
+      {
+        Serial.println("motore inesistente");
+      }
+      else
+      {
+        Serial.println("motore E antiorario");
+        muovi('g',vel_passetti,0, 0, -passetto);
+      }
+      delay(1000);
+    }
+  }
+}


update fireflies to use fairy lights

update fireflies to use fairy lights

--- Fireflies/Fireflies.ino
+++ Fireflies/Fireflies.ino
@@ -6,45 +6,24 @@

 #include "Color3F.h"

-// Which pin on the Arduino is connected to the NeoPixels?
-// On a Trinket or Gemma we suggest changing this to 1
 const int pinNeopixels = 5;
-const int numNeopixels = 5;
 const bool newPixelsAreRgb = false;
-const int pinNeopixels2 = 3;
-const int numNeopixels2 = 1;
-const bool newPixelsAreRgb2 = true;
+auto pixels = Adafruit_NeoPixel(1, pinNeopixels, (newPixelsAreRgb ? NEO_RGB : NEO_GRB) + NEO_KHZ800);

-// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
-// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
-// example for more information on possible values.
-auto pixels = Adafruit_NeoPixel(numNeopixels, pinNeopixels, (newPixelsAreRgb ? NEO_RGB : NEO_GRB) + NEO_KHZ800);
-auto pixels2 = Adafruit_NeoPixel(numNeopixels2, pinNeopixels2, (newPixelsAreRgb2 ? NEO_RGB : NEO_GRB) + NEO_KHZ800);
+const int fireflyPins[] = { 9, 10, 11 };
+const int fireflyPinCount = sizeof(fireflyPins) / sizeof(fireflyPins[0]);

 struct Firefly
 {
-  Color3F color;
   bool active = false;
   int lifetime = 0;
   int progress = 0;
 };

-Firefly fireflies[numNeopixels];
+Firefly fireflies[fireflyPinCount];

 int fireflyChance() { return 400; }
 int fireflyLifetime() { return random (150, 250); }
-
-Color3F fireflyColor()
-{
-  switch (random(0, 3))
-  {
-    case 0: return Color3F(102, 255, 64) / 255.f;
-    case 1: return Color3F(32, 128, 48) / 255.f;
-    case 2: return Color3F(255, 255, 32) / 255.f;
-  }
-
-  return Color3Fs::Blue();
-}

 void setup()
 {
@@ -55,20 +34,24 @@
   // End of trinket special code

   pixels.begin();
-  pixels2.begin();
+
+  for (int i = 0; i < fireflyPinCount; i++)
+  {
+    pinMode(fireflyPins[i], OUTPUT);
+  }
 }

 void loop()
 {
   bool anyFirefliesActive = false;
-  for (int i = 0; i < numNeopixels; i++)
+  for (int i = 0; i < fireflyPinCount; i++)
   {
     anyFirefliesActive = anyFirefliesActive || fireflies[i].active;
   }

-  int forceActivateIndex = anyFirefliesActive ? -1 : random(numNeopixels);
+  int forceActivateIndex = anyFirefliesActive ? -1 : random(fireflyPinCount);

-  for (int i = 0; i < numNeopixels; i++)
+  for (int i = 0; i < fireflyPinCount; i++)
   {
     auto& firefly = fireflies[i];

@@ -88,21 +71,17 @@
         firefly.active = true;
         firefly.lifetime = fireflyLifetime();
         firefly.progress = 0;
-        firefly.color = fireflyColor();
       }
     }

     int s = sin((float)firefly.progress / firefly.lifetime * PI) * 255;
-    auto color = firefly.active ? firefly.color * s : Color3Fs::Black();
-
-    pixels.setPixelColor(i, color.R, color.G, color.B);
+    analogWrite(fireflyPins[i], firefly.active ? s : 0);
   }

+  auto glowScale = (sin((millis() % 4000) / 4000.f * 2 * PI) * 3 / 8 + 0.625);
+  auto color = Color3F(255, 255, 64) * glowScale;
+  pixels.setPixelColor(0, color.R, color.G, color.B);
   pixels.show();
-  auto glowScale = (sin((millis() % 2000) / 2000.f * 2 * PI) / 4 + 0.75);
-  auto color2 = Color3F(255, 255, 64) * glowScale;
-  pixels2.setPixelColor(0, color2.R, color2.G, color2.B);
-  pixels2.show();

   delay(10);
 }


Make heartbeat peaks less intense to avoid sensor overload

--- heartbeat_with_pulse.ino
+++ heartbeat_with_pulse.ino
@@ -32,7 +32,7 @@
 // config
 int staticBpm = 60; // From http://ecg.utah.edu/img/items/Normal%2012_Lead%20ECG.jpg
 int maxBpm = 180; // avoids the system going crazy
-byte beat[]  = {2,2,2,2,3,4,3,2,1,0,12,2,2,3,4,6,8,5,3,3,3,3};
+byte beat[]  = {2,2,2,2,3,4,3,2,1,0,10,2,2,3,4,6,8,5,3,3,3,3}; // From http://ecg.utah.edu/img/items/Normal%2012_Lead%20ECG.jpg
 byte beatLength = 22;
 int beatMaxIntensity = 12; // max value in beat array
 int movesPerBeat = 4;


Change wt_init calls to supply basefreq

Change wt_init calls to supply basefreq

--- dds_playground/src/sketch.ino
+++ dds_playground/src/sketch.ino
@@ -45,7 +45,10 @@

     initialize_datatables();
     for (int i=0; i<N_WAVETABLES; i++) {
-        wt_init(&wavetables[i], wt_sine_data, WT_SINE_LENGTH);
+        wt_init(&wavetables[i],
+            wt_sine_data,
+            WT_SINE_LENGTH,
+            WT_SINE_BASEFREQ);
         wavetables[i].increment = 0; // all oscillators silent
     }


Make each led leaving take as long as the others

--- countdown/countdown.ino
+++ countdown/countdown.ino
@@ -19,28 +19,17 @@
   }
 }

-void setup(){
-  // Delay in case the LEDs draw a lot of current and kill the power supply
-  delay(1000);
-  // Let the controller know we're using WS2801 leds, and give a pointer to the current colour array
-  LEDS.addLeds<WS2801, RGB>(leds, NUM_LEDS);
-  // Limit the brightness somewhat (scale is 0-255)
-  LEDS.setBrightness(64);
-
-  for(uint8_t i=0; i<NUM_LEDS; ++i)
-    leds[i] = CRGB::White;
-
-  LEDS.show();
-}

-#define TIMESTEP 25
+#define UPDATE_TIME 20
+#define TIMESTEP 5
+uint16_t step_period = 1;
 uint8_t leds_index = 0;
 uint8_t colour_counter=0; //keep track of the remaining colours in led (100-leds_left)
 uint8_t step_counter=0; //keep track of the remaining steps of the currently-moving colour

 const CRGB moving_colours[] = {CRGB::Red, CRGB::Green, CRGB::Blue};

-void update(){
+void step_led(){
   // First, turn off completely the led at step_counter (the light will leave this spot)
   leds[step_counter] = CRGB::Black;

@@ -69,15 +58,51 @@
   step_counter--;
   // Light up the properly-coloured led in the current position
   leds[step_counter] = moving_colours[colour_counter];
-
+
+  // take just as long for the first as for the last leds to move out:
+  step_period = 1000/(1+leds_index);
+}
+
+void update(){
   LEDS.show();
 }

+
+void setup(){
+  // Delay in case the LEDs draw a lot of current and kill the power supply
+  delay(1000);
+  // Let the controller know we're using WS2801 leds, and give a pointer to the current colour array
+  LEDS.addLeds<WS2801, RGB>(leds, NUM_LEDS);
+  // Limit the brightness somewhat (scale is 0-255)
+  LEDS.setBrightness(64);
+
+  for(uint8_t i=0; i<NUM_LEDS; ++i)
+    leds[i] = CRGB::White;
+
+  LEDS.show();
+  Serial.begin(57600);
+}
+
 unsigned long prevStepTime = 0;
+unsigned long prevUpdateTime = 0;
+unsigned long prevReportTime = 0;
 void loop(){
   if(millis()-prevStepTime >= TIMESTEP){
     prevStepTime = millis();
+    if(--step_period == 0){
+      // step_period is reset inside step_led();
+      step_led();
+    }
+  }
+
+  if(millis()-prevUpdateTime >= UPDATE_TIME){
+    prevUpdateTime = millis();
     update();
+  }
+
+  if(millis()-prevReportTime >= 500){
+    prevReportTime = millis();
+    Serial.println(step_period);
   }
 }


pressButtons returns correct delay

pressButtons returns correct delay

--- ps2_controller/ps2_controller.ino
+++ ps2_controller/ps2_controller.ino
@@ -493,7 +493,7 @@
   readMotorsStatus = serial_rx_buffer_change_motors_status[8];
   serial_rx_buffer_change_motors_status[0] = 0x0F;
   serial_rx_buffer_change_motors_status[11] = 0x0F;
-
+
   for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer_reset_controller); serial_rx_buffer_counter++) {
     //  Write back data as a way to tell the Status changed correctly
     Serial.write(serial_rx_buffer_change_motors_status[serial_rx_buffer_counter]);
@@ -927,9 +927,9 @@
           serial_rx_buffer_controller[6] = 0x7F;
           serial_rx_buffer_controller[7] = 0x00;
           serial_rx_buffer_controller[8] = 0x00;
-          serial_rx_buffer_controller[9] = 0x00;
-          serial_rx_buffer_controller[10] = 0x00;
-
+          //serial_rx_buffer_controller[9] = 0xFF;
+          //serial_rx_buffer_controller[10] = 0xFF;
+
           for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer_controller); serial_rx_buffer_counter++) {
             Serial.write(serial_rx_buffer_controller[serial_rx_buffer_counter]); //  This line writes the serial data back to the computer as a way to check if the Arduino isn't interpreting wrong values
             //  Invert 0 to 255 and vice versa to make it easier to determine which commands to enable or not, and their values
@@ -1413,6 +1413,7 @@
 void manualResetControllerData()
 {
   //  This function resets controller data when requested by the computer. Can be used for example when something goes wrong on the computer's end.
+  inputDelay = 0;
   serial_rx_buffer_controller[0] = 0x01; //  Preamble
   serial_rx_buffer_controller[1] = 0x00; //  SELECT, L3, R3, START, DUP, DRIGHT, DDOWN, DLEFT
   serial_rx_buffer_controller[2] = 0x00; //  L2, R2, L1, R1, Triangle/Delta, Circle/O, Cross/X, Square
@@ -1474,6 +1475,7 @@
   if (currentMillis - previousResetControllerDataDelay >= resetControllerDataDelay) {
     if (isInputting == false) {
       //  This function resets contreoller data when requested by the computer. Can be used for example when something goes wrong on the computer's end.
+      inputDelay = 0;
       serial_rx_buffer_controller[0] = 0x01; //  Preamble
       serial_rx_buffer_controller[1] = 0x00; //  SELECT, L3, R3, START, DUP, DRIGHT, DDOWN, DLEFT
       serial_rx_buffer_controller[2] = 0x00; //  L2, R2, L1, R1, Triangle/Delta, Circle/O, Cross/X, Square


Zero button press issue in logbook was fixed.

--- DiveIno.ino
+++ DiveIno.ino
@@ -670,7 +670,7 @@

 void numericButtonPressed(byte number)
 {
-	if (currentScreen == PROFILE_SCREEN) {
+	if (currentScreen == PROFILE_SCREEN && number > 0) {
 		logbook.drawProfileItems(&tft, currentProfileNumber, number);
 	}
 }