Use latest version of Bounce Arduino library.

The instructions don't mention downloading any particular version;
this will be less confusing for people, hopefully.

--- printer.ino
+++ printer.ino
@@ -4,7 +4,7 @@
 #include <EEPROM.h>

 #include <SoftwareSerial.h>
-#include <Bounce.h>
+#include <Bounce2.h>

 // -- Settings for YOU to change if you want

@@ -39,7 +39,7 @@

 // -- Everything below here can be left alone

-const char sketchVersion[] = "1.0.5";
+const char sketchVersion[] = "1.0.6";

 // -- Debugging

@@ -135,6 +135,15 @@
 }

+// -- Initialize debouncing of buttons
+
+Bounce bouncer = Bounce();
+
+void initBouncer() {
+  bouncer.attach(buttonPin);
+  bouncer.interval(5);
+}
+
 // -- Setup; runs once on boot.

 void setup(){
@@ -146,6 +155,7 @@
   initSD();
   initNetwork();
   initPrinter();
+  initBouncer();
 }

 // -- Check for new data and download if found
@@ -280,8 +290,6 @@

 // -- Check for new data, print if the button is pressed.

-Bounce bouncer = Bounce(buttonPin, 5); // 5 millisecond debounce
-
 void loop() {
   if (downloadWaiting) {
     bouncer.update();


new example

new example

--- examples/deepsleep/deepSleep_all_wakeups/deepSleep_all_wakeups.ino
+++ examples/deepsleep/deepSleep_all_wakeups/deepSleep_all_wakeups.ino
@@ -16,6 +16,8 @@
    * define the configuration
    * parameters for waking the
    * teensy up.
+   * Only pins:
+   * 2,4,6,7,9,10,11,13,16,21,22,26,30,33
    *****************************/
   config.pinMode(21, INPUT_PULLUP, RISING);//pin, mode, type
   config.pinMode(22, INPUT_PULLUP, RISING);//pin, mode, type


fix typo

fix typo

--- examples/sleep/pushbutton_pullup_sleep/pushbutton_pullup_sleep.ino
+++ examples/sleep/pushbutton_pullup_sleep/pushbutton_pullup_sleep.ino
@@ -1,6 +1,6 @@
 /***************************************
 * Sleep with pushbutton w/ pullup.
-* expect IID of around 900uA.
+* expect IDD of around 900uA.
 ****************************************/
 #include <Snooze.h>


Updated Arduino

Updated Arduino

--- firmware/arduPWM/arduPWM.ino
+++ firmware/arduPWM/arduPWM.ino
@@ -38,8 +38,8 @@
 #define PIN_PWM_L A0
 #define PIN_PWM_R A1
 #define PIN_PWM_MODE A2
-#define PIN_LED1 10
-#define PIN_LED2 11
+#define PIN_LED1 8
+#define PIN_LED2 10
 #define PIN_LED3 12
 #define PWM_MID 1500
 #define PWM_MID_DZ 100
@@ -165,6 +165,12 @@
   pinMode(PIN_LED1, OUTPUT);
   pinMode(PIN_LED2, OUTPUT);
   pinMode(PIN_LED3, OUTPUT);
+  pinMode(13, OUTPUT);
+
+  digitalWrite(PIN_LED1, HIGH);
+  digitalWrite(PIN_LED2, HIGH);
+  digitalWrite(PIN_LED3, HIGH);
+  digitalWrite(13, HIGH);

   pinMode(PIN_PWM_L, INPUT);
   pinMode(PIN_PWM_R, INPUT);
@@ -172,7 +178,12 @@

   Serial.begin(115200);

+//  digitalWrite(PIN_LED1, LOW);
+//  digitalWrite(PIN_LED2, LOW);
+//  digitalWrite(PIN_LED3, LOW);
   digitalWrite(PIN_LED1, HIGH);
+  digitalWrite(PIN_LED2, HIGH);
+  digitalWrite(PIN_LED3, HIGH);
 }

 void loop()


MultiColor lights

MultiColor lights

--- arduino/arduinoMultiColorLights/arduinoMultiColorLights.ino
+++ arduino/arduinoMultiColorLights/arduinoMultiColorLights.ino
@@ -76,19 +76,12 @@

 void ethernetSucceeded(){
   Serial.println("Ethernet Succeeded");
-      redIntensity = 255;
-      greenIntensity = 255;
-  for(blueIntensity= 225;blueIntensity > 0;blueIntensity-=5){
-
-

       analogWrite(GREEN_LED_PIN, 20);
     analogWrite(BLUE_LED_PIN, 0);
     analogWrite(RED_LED_PIN, 0);

-
-    delay(DISPLAY_TIME);
-  }
+
 }


Update Brief.ino

Update Brief.ino

--- examples/Brief/Brief.ino
+++ examples/Brief/Brief.ino
@@ -17,8 +17,6 @@
     // In the interactive: 100 'delay instruction
     // In .NET: compiler.Instruction("delay", 100)
     brief::bind(100, delayMillis);
-    pinMode(13, OUTPUT);
-    digitalWrite(13, LOW);
 }

 void loop()


Increased firing button debouce timing, timer for firing state and added LED animation in firing state

--- sploder.ino
+++ sploder.ino
@@ -46,7 +46,7 @@

 // Managing debounce of the button used to FIRE!
 long lastDebounceTime = 0;
-long debounceDelay = 250;
+long debounceDelay = 1000; // This needs to be fairly large for the big dome button; that large spring is pretty bouncy

 // We'll hold timing information about certain states here
 long timerStartupState = 0;
@@ -178,8 +178,13 @@
   startTimer(timerFiringState);
 }
 void updateFiringState() {
-
-  if(isTimerExpired(timerFiringState, 1000)) {
+  delay(100);
+  if (isFiringLEDOn()) {
+    firingLEDOff();
+  } else {
+    firingLEDOn();
+  }
+  if(isTimerExpired(timerFiringState, 5000)) {
     stateMachine.transitionTo(armedState);
   }
 }
@@ -212,6 +217,13 @@
 // Firing LED animation helpers
 void beginPulsingFiringLED() {
   firingLEDBrightness = START_RADIAN;
+}
+
+boolean isFiringLEDOn() {
+  if (digitalRead(FIRING_LED) == HIGH) {
+    return true;
+  }
+  return false;
 }

 // We use a sin wave to get a nice, clean pulse for the LED


float consistency

float consistency

--- main/main.ino
+++ main/main.ino
@@ -345,7 +345,7 @@
         engine_rpm.previousValue = engine_rpm.currentValue;
         //engine_rpm.currentValue = buf[2] * 256 + buf[3];
         //round rpm to nearest 10
-        engine_rpm.currentValue = round((buf[2] * 256 + buf[3]) / 10) * 10;
+        engine_rpm.currentValue = round((buf[2] * 256 + buf[3]) / 10.0) * 10.0;

         engine_clt.previousValue = engine_clt.currentValue;
         engine_clt.currentValue = (buf[4] * 256 + buf[5]) / 10.0;


checkpoint

checkpoint

--- main/main.ino
+++ main/main.ino
@@ -62,18 +62,20 @@
   B11111
 };

-//possible parameters to display
-double  engine_afr;         //AFR
-double  engine_afr_tgt;     //AFR target
-double  engine_map;         //MAP sensor
-double  engine_boost;       //boost (psi) calculated from map value
-double  engine_adv;         //ignition advance
-int     engine_rpm;         //RPM
-int     engine_tps;         //throttle position
-double  engine_vbat;        //battery voltage
-int     engine_clt;         //coolant temp
-int     engine_iat;         //intake air temp
+long startTime;
+long endTime;

+double afr;
+double tgt;
+
+unsigned long interval = 100;
+unsigned long lastMillis = 0;
+unsigned long currentMillis = 0;
+
+tCAN message;
+int messageReceived;
+
+tCAN emtpyMessage;

 void setup() {

@@ -88,38 +90,33 @@
   lcd.setCursor(0, 2);
   lcd.print("TGT");

-  //Serial.begin(115200);
+  Serial.begin(115200);
   int can_init = mcp2515_init(1); //CANSPEED_500 = 1
 }

 void loop() {

-  tCAN message;
   ecu_req(&message);
-  double tgt = (double)message.data[0] / 10.0;
-  double afr = (double)message.data[1] / 10.0;

-  //double afr = 12.5;
-  //double tgt = 14.7;
-  lcd.clear();
+  currentMillis = millis();

-  lcd.begin(20, 4);
-  lcd.print("AFR");
-  lcd.setCursor(0, 2);
-  lcd.print("TGT");
+  if(messageReceived == 1) {
+    if(currentMillis - lastMillis >= interval) {
+      Serial.println("===screen refresh===");
+      lastMillis = currentMillis;
+      lcd.setCursor(4, 2);
+      lcd.print(tgt);
+      Serial.print("===screen refresh===");
+      Serial.println(tgt);
+
+    }
+    messageReceived = 0;
+  }
+

-  if(afr >= 10.0 && afr <= 20.0) {
-    lcd.setCursor(4, 0);
-    lcd.print(afr);
-    draw_bar(afr, 1, 10, 20);
-  }
-  if(tgt >= 10.0 && tgt <= 20.0) {
-    lcd.setCursor(4, 2);
-    lcd.print(tgt);
-    draw_bar(tgt, 3, 10, 20);
-  }

-  delay(300);
+
+
 }

 void draw_bar(double value, int row, double minimum, double maximum) {
@@ -143,13 +140,26 @@
   message->header.length = 8;

   mcp2515_bit_modify(CANCTRL, (1<<REQOP2)|(1<<REQOP1)|(1<<REQOP0), 0);
-
-  if (mcp2515_get_message(message)) {
-    //Serial.println(message.data[0]);
-    //Serial.println(message.data[1]);
-    //return &message.data;
+  //Serial.println("trying to get data");
+  if(mcp2515_check_message()) {
+
+    Serial.print("there is a message ");
+    mcp2515_get_message(message);
+
+    if(message->data[0] >= 100) {
+        tgt = (double)message->data[0] / 10.0;
+        Serial.print("good data ");
+        Serial.println(tgt);
+    }
+    else {
+      Serial.println("bad data ");
+    }
+
+    messageReceived = 1;
   }
   else {
+    messageReceived = 0;
   }
+
 }


ADC - continues conversion IIR LPF

ADC - continues conversion IIR LPF

--- mech/mech.ino
+++ mech/mech.ino
@@ -21,6 +21,12 @@

 const byte fwdPwr = A5;     // Fwd signal from SWR sensor
 const byte rflPwr = A6;     // Rev. signal from SWR sensor
+const float adcFiltFactor = 0.99;
+
+volatile uint8_t adcPinCurr;
+volatile float fwdPwrVal = 0.0;
+volatile float rflPwrVal = 0.0;
+

 void busReceiver(const TCommand *payload, const PJON_Packet_Info &packet_info) {
 	switch (payload->id) {
@@ -45,11 +51,32 @@
 	}
 }

+// ADC complete ISR
+ISR (ADC_vect) {
+  if (adcPinCurr == fwdPwr) {
+	  fwdPwrVal = (1 - adcFiltFactor) * ADC + fwdPwrVal * adcFiltFactor;
+	  adcPinCurr = rflPwr;
+  }
+  if (adcPinCurr == rflPwr) {
+  	  rflPwrVal = (1 - adcFiltFactor) * ADC + rflPwrVal * adcFiltFactor;
+  	  adcPinCurr = fwdPwr;
+    }
+  ADMUX =  bit(REFS0) | (adcPinCurr & 0x07);
+  ADCSRA |= bit(ADSC) | bit(ADIE);
+}
+
 void setup()
 {
-  ADCSRA = (ADCSRA & 0xf8) | 0x04;      // Fast ADC
+  ADCSRA = bit(ADEN);                   // turn ADC on
+  ADCSRA &= ~(bit(ADPS0) |
+		  bit(ADPS1) |
+		  bit(ADPS2));                  // clear prescaler bits
+  ADCSRA |= bit(ADPS2);                 //  16
+  adcPinCurr = fwdPwr;
+  ADMUX  =  bit(REFS0) | (adcPinCurr & 0x07);
+  ADCSRA |= bit(ADSC) | bit(ADIE);

-  Serial.begin(115200);                   // Start Serial
+  Serial.begin(115200);                 // Start Serial
   busInit(busReceiver);

   pinMode(fwdPwr, INPUT);
@@ -127,8 +154,8 @@
 }

 void updateStatus() {
-	analogRead(fwdPwr);	status.adc.fwd = analogRead(fwdPwr);
-	analogRead(rflPwr);	status.adc.rfl = analogRead(rflPwr);
+	status.adc.fwd = round(fwdPwrVal);
+	status.adc.rfl = round(rflPwrVal);
 	status.flags = stepper1.isRunning() || stepper1.isRunning() << 1 || stepper3.isRunning() << 2;
 	status.cnt++;
 }


tuning on sound sensor

tuning on sound sensor

--- Modules/Sensor/SoundSensor/ArduinoCodes/SoundSensorATtiny/SoundSensorATtiny.ino
+++ Modules/Sensor/SoundSensor/ArduinoCodes/SoundSensorATtiny/SoundSensorATtiny.ino
@@ -24,9 +24,9 @@
 #include "SignalProcessing.h"

 //Pin Configurations:
-int output_pin = 1;
-int input_pin = A3;
-int sensor_pin = A2;
+int output_pin = 1;                      //Pin 6 on ATtiny
+int input_pin = A3;                      //Pin 2 on ATtiny
+int sensor_pin = A2;                     //Pin 3 on ATtiny
 int filter_size = 15;                        //Noise reduction filter size

 SignalProcessing input(input_pin, filter_size);
@@ -40,11 +40,12 @@

   int input_val = cutAndMap(input.filteredAnalogRead(AVERAGE), 50, 975, 0, 1023);
   int sensor_val = analogRead(A0);
-  int output_val = cutAndMap(input_val, 350, 475, 0, 255);              //350 and 475 experimentally determined
-
-  for(int i = output_val; i >= 25; i-=25){                            //fade output slightly
+  int output_val = cutAndMap(input_val, 300, 400, 0, 255);              //350 and 475 experimentally determined
+
+  analogWrite(output_pin, output_val);
+  /*for(int i = output_val; i >= 25; i-=25){                            //fade output slightly
     analogWrite(output_pin , i);
     delay(16);
   }
-  analogWrite(3, 0);
+  analogWrite(3, 0);*/
 }


Update catheter_arduino_ard_ide.ino

Update catheter_arduino_ard_ide.ino

Added the MRI pin feature so that the camera can detect the MRI imaging.

--- src/catheter_arduino_ard_ide/catheter_arduino_ard_ide.ino
+++ src/catheter_arduino_ard_ide/catheter_arduino_ard_ide.ino
@@ -36,18 +36,44 @@

 int camera_write(int counter)
 {
-	// make sure counter is integer 0 - 7
-	counter = counter % 4;
-	if (counter % 2 == 1) digitalWrite(CAMERA_PINS[0], HIGH);
-  else digitalWrite(CAMERA_PINS[0], LOW);
-  if ((counter >> 1) % 2 == 1) digitalWrite(CAMERA_PINS[1], HIGH);
-  else digitalWrite(CAMERA_PINS[1], LOW);
-  int mriStatus = digitalRead(mriPin);
-  if(mriStatus) digitalWrite(CAMERA_PINS[2],HIGH);
-  else digitalWrite(CAMERA_PINS[2],LOW);
-  // if (counter >= 4) digitalWrite(CAMERA_PINS[2], HIGH);
-  // else digitalWrite(CAMERA_PINS[2], LOW);
-  return mriStatus;
+    static unsigned long mriStartTime(0);
+
+    // make sure counter is integer 0 - 7
+    counter = counter % 4;
+    if (counter % 2 == 1) digitalWrite(CAMERA_PINS[0], HIGH);
+    else digitalWrite(CAMERA_PINS[0], LOW);
+    if ((counter >> 1) % 2 == 1) digitalWrite(CAMERA_PINS[1], HIGH);
+    else digitalWrite(CAMERA_PINS[1], LOW);
+
+    int mriStatus = digitalRead(mriPin);
+    if(mriStatus)
+    {
+        mriStartTime = millis();
+        digitalWrite(CAMERA_PINS[2],HIGH);
+    }
+    else if(mriStartTime != 0)
+    {
+        unsigned long currentTime(millis());
+        unsigned long minOn(25); //minimum on time for the MRI pin
+        if((mriStartTime + minOn) < currentTime)
+        {
+        	digitalWrite(CAMERA_PINS[2],LOW);
+        	mriStartTime = 0;
+        }
+        else if(mriStartTime > currentTime && currentTime > minOn )
+        {
+        	digitalWrite(CAMERA_PINS[2],LOW);
+        	mriStartTime = 0;
+        }
+    }
+    else
+    {
+    	digitalWrite(CAMERA_PINS[2],LOW);
+    	mriStartTime = 0;
+    }
+    // if (counter >= 4) digitalWrite(CAMERA_PINS[2], HIGH);
+    // else digitalWrite(CAMERA_PINS[2], LOW);
+    return mriStatus;
 }

 #include "cmd_support.h"


Firmware 010517

Firmware 010517

--- src/Deutsch/NOKO/NOKO.ino
+++ src/Deutsch/NOKO/NOKO.ino
@@ -80,18 +80,18 @@
 */

 // Softwareversion
-#define Firmware "-190417"
+#define Firmware "-010517"
 #define Version 10  // 1.0
 #define Build_by "by Nikolai Radke" // Your Name. Max. 20 chars, appears in "Mein NOKO" menu

 // Features on/off - comment out to disable
-#define def_radio             // Using Radio?
-#define def_external_eeprom   // Using external EEPROM?
-#define def_stories           // Stories on SD card?
+//#define def_radio             // Using Radio?
+//#define def_external_eeprom   // Using external EEPROM?
+//#define def_stories           // Stories on SD card?

 // Display selection
-#define display_address 0x27   // Blue
-//#define display_address 0x3F // Yellow
+//#define display_address 0x27   // Blue
+#define display_address 0x3F // Yellow

 // 24LC256 EEPROM addresses
 #define phrase_address 4000    // Starting address of the phrases in 24LC256


latest arduino software for pushing notifications via buttons

--- arduino/pusher/pusher.ino
+++ arduino/pusher/pusher.ino
@@ -26,10 +26,9 @@
   ethernetConnecting();
   Ethernet.begin(mac,ip);
   delay(1000); //Give time to initialize before connecting
-  if(pushMessage("arduino_test_channel", "arduino_event_register", "success"))
-    ethernetSucceeded();
-  else
+  while(!pushMessage("arduino_test_channel", "arduino_event_register", "success"))
     ethernetFailed();
+  ethernetSucceeded();

   for(int i = 0; i < 7; i++)
     pinMode(buttonPin[i], INPUT);
@@ -51,11 +50,17 @@

+
+
+
+
+
+
 void readButtons()
 {
   for(int i = 0; i < 7; i++)
   {
-    if(digitalRead(buttonPin[i]) == HIGH)
+    if(digitalRead(buttonPin[i]) == LOW)
     {
       if(buttonCountDown[i] == 0)
       {


Adjusting telemetry transmission frequency

--- examples/quadcopter/quadcopter.ino
+++ examples/quadcopter/quadcopter.ino
@@ -121,7 +121,7 @@

     // update yaw target
     if(fabs(yawCmd) > 0.1){
-        yawTarget += yawCmd/8;
+        yawTarget += yawCmd/160.0;
         yawTarget = truncateRadian(yawTarget);
     }

@@ -211,7 +211,7 @@
 }

 void sendTelemetry(){
-    static auto timer = Interval::every(100);
+    static auto timer = Interval::every(250);
     if(timer()){
         float voltage  = float((analogRead(67)/1024.l)*5.l*10.1f);
         float amperage = float((analogRead(66)/1024.l)*5.l*17.0f);


divers

divers

--- stripNeopixel/stripNeopixel.ino
+++ stripNeopixel/stripNeopixel.ino
@@ -54,8 +54,8 @@

 Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT); // , SPI_CLOCK_DIVIDER, &Serial

-#define WLAN_SSID       "Livebox-25A0"   // cannot be longer than 32 characters!
-#define WLAN_PASS       "3C7955CAEDD45C4E3766A7F9A9"
+#define WLAN_SSID       "Your-SSID"   // cannot be longer than 32 characters!
+#define WLAN_PASS       "Your-KEY-PASS"
 // Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
 #define WLAN_SECURITY   WLAN_SEC_WPA2


Serial print macros to disable.

Serial print macros to disable.

--- CatsCommandInterpreter/CatsCommander/CatsCommander.ino
+++ CatsCommandInterpreter/CatsCommander/CatsCommander.ino
@@ -22,6 +22,19 @@

 // ====== CUSTOM PIN SETUP ======
 #define ledPin 3
+
+// define next line to do serial debugging
+//#define ACTIVATE_SERIAL 1
+
+#ifdef ACTIVATE_SERIAL
+  #define sbegin(x) Serial.begin(x)
+  #define sprint(args...) Serial.print(args)
+  #define sprintln(args...) Serial.println(args)
+#else
+  #define sbegin(x)
+  #define sprint(args...)
+  #define sprintln(args...)
+#endif

 // ====================================
 // ===== COMMAND INTERPRETER      =====
@@ -215,9 +228,9 @@
     // ====== END ==== Bluefruit UART SETUP ======

     // ====== BEGIN == Start Serial Console ======
-    Serial.begin(9600); // print smart stuff to the console
+    sbegin(9600); // print smart stuff to the console
     delay(1000);
-    Serial.println(F("nRF8001 CommandInterpreter Demo"));
+    sprintln(F("nRF8001 CommandInterpreter Demo"));
     // ====== END ==== Start Serial Console ======

     // ======  ==============================
@@ -261,13 +274,13 @@
   switch(event)
   {
     case ACI_EVT_DEVICE_STARTED:
-      Serial.println(F("Advertising started"));
+      sprintln(F("Advertising started"));
       break;
     case ACI_EVT_CONNECTED:
-      Serial.println(F("Connected!"));
+      sprintln(F("Connected!"));
       break;
     case ACI_EVT_DISCONNECTED:
-      Serial.println(F("Disconnected or advertising timed out"));
+      sprintln(F("Disconnected or advertising timed out"));
       break;
     default:
       break;
@@ -281,9 +294,9 @@
 /**************************************************************************/
 void rxCallback(uint8_t *buffer, uint8_t len)
 {
-  Serial.print(F("Received "));
-  Serial.print(len);
-  Serial.print(F(" bytes: "));
+  sprint(F("Received "));
+  sprint(len);
+  sprint(F(" bytes: "));

   if(commandInterpreter.interpretCommand(buffer, len)) // check if command can be interpreted
       return;  // do not echo if command was a success
@@ -293,12 +306,12 @@

   // print buffer in HEX to the console:
   /*
-  Serial.print(F(" ["));
+  print(F(" ["));
   for(int i=0; i<len; i++)
   {
-      Serial.print(" 0x"); Serial.print((char)buffer[i], HEX);
+      print(" 0x"); print((char)buffer[i], HEX);
   }
-  Serial.println(F(" ]"));
+  println(F(" ]"));
   */
 }


Added support for saving configuration to AVR EEPROM Added support for intial dump (to save user time and knowledge required) Blink LED while waiting for serial connection

--- ED_BMSdiag/ED_BMSdiag.ino
+++ ED_BMSdiag/ED_BMSdiag.ino
@@ -22,18 +22,31 @@
 //! \brief   Only usable for third gen. model build from late 2012 to mid 2015!!!
 //! \brief   Build a diagnostic tool with the MCP2515 CAN controller and Arduino
 //! \brief   compatible hardware.
-//! \date    2017-September
+//! \date    2017-December
 //! \author  MyLab-odyssey
-//! \version 1.0.1
+//! \version 1.0.2
 //--------------------------------------------------------------------------------
 #include "ED_BMSdiag.h"

+#include <EEPROM.h>
+
 //--------------------------------------------------------------------------------
 //! \brief   SETUP()
 //--------------------------------------------------------------------------------
 void setup() {
+  pinMode(LED_BUILTIN, OUTPUT);
+
   Serial.begin(115200);
-  while (!Serial); // while the serial stream is not open, do nothing
+  while (!Serial) {
+    // while the serial stream is not open,  blink LED
+    digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
+    delay(500);                       // wait for a 1/2 second
+    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
+    delay(500);                       // wait for a 1/2 second
+  }
+
+  // Read configuration from EEPROM
+  ReadGlobalConfig(&myDevice);

   pinMode(CS, OUTPUT);
   pinMode(CS_SD, OUTPUT);
@@ -58,19 +71,25 @@
   if (NLG6TEST) nlg6_installed();

   //test valid VIN stored in battery
-  if (sizeof(myVIN) > 1) test_BattVIN();
+  test_BattVIN();

   //Read CAN-Bus IDs related to BMS (sniff traffic)
-  Serial.print(F("Reading data"));
   byte selected[] = {0,1,2,3,4,5,6,7};
   ReadCANtraffic_BMS(selected, sizeof(selected));

-  //Print standard data set as overview
-  printSplashScreen();
-
   //Setup CLI, display prompt and local echo
   setupMenu();
   init_cmd_prompt();
+
+  // For convenience of users, dump all data first (same as "all" from top-level menu)
+  // Do this after the setupMenu() call.
+  if (myDevice.initialDump)
+    get_all(0, (void**) 0L);
+
+  //Print standard data set as overview
+  printSplashScreen();
+
+  // Prompt user for what to do next
   cmd_display();
   set_local_echo(ECHO);

@@ -282,3 +301,20 @@

   return fOK;
 }
+
+
+boolean ReadGlobalConfig(deviceStatus_t *config, bool force_write = false)
+{
+  // If the EEPROM hasn't been programmed yet, program it
+  if (force_write || EEPROM.read(EE_Signature) != kMagicSignature) {
+    Serial.println("Setting factory defaults");
+    EEPROM.update(EE_IntialDumpAll, 1);
+    EEPROM.update(EE_logging, 0);
+    EEPROM.update(EE_logInterval, 30);
+    EEPROM.update(EE_Signature, kMagicSignature);
+  }
+  config->initialDump = (EEPROM.read(EE_IntialDumpAll) > 0);
+  config->logging = (EEPROM.read(EE_logging) > 0);
+  config->timer = EEPROM.read(EE_logInterval);
+}
+


20170627

--- FIREGOTO/LX200Command.ino
+++ FIREGOTO/LX200Command.ino
@@ -433,6 +433,13 @@
 {
   SerialPrint("N#");
 }
+
+
+
+void printalinhamento() //:GW# with "AN0#"
+{
+  SerialPrint("AN0#");
+}
 /*std Autostars return "Autostar"
   LX200s return "LX2001"
   RCXs return "RCX400"
@@ -468,18 +475,6 @@
   SerialPrint(str);
 }

-//:GW# Get Scope Alignment Status
-/*Returns:
-  <mount><tracking><alignment>#
-  where:
-  mount: A-AzEl mounted, P-Equatorially mounted, G-german mounted equatorial
-  tracking: T-tracking, N-not tracking
-  alignment: 0-needs alignment, 1-one star aligned, 2-two star aligned, 3-three star aligned.
-*/
-void printalinhamento()
-{
-  SerialPrint("ANO#");
-}

 /*:GZ# Get telescope azimuth
   Returns: DDD*MM#T or DDD*MM'SS#*/


demos guirlande

demos guirlande


make sketch compatible with "Arduino as ISP" programmer

--- examples/Ports/isp_flash/isp_flash.ino
+++ examples/Ports/isp_flash/isp_flash.ino
@@ -351,7 +351,7 @@
 }

 void setup() {
-    Serial.begin(19200);
+    Serial.begin(9600);
     pinMode(LED_PMODE, OUTPUT);
     digitalWrite(LED_PMODE, 1);
 }


Adjust MIDI tone number range in Tone example sketch.

--- examples/Sandbox/CosaTone/CosaTone.ino
+++ examples/Sandbox/CosaTone/CosaTone.ino
@@ -42,7 +42,7 @@
   sleep(3);

   // MIDI nodes (49..69..89)
-  for (uint8_t i = 39; i < 100; i++) {
+  for (uint8_t i = 49; i < 90; i++) {
     Tone::play(Note::MIDI(i), 5, 200);
     delay(200);
   }


reduce alarm time to 10 minutes

reduce alarm time to 10 minutes

--- vibrate_alarm_clock.ino
+++ vibrate_alarm_clock.ino
@@ -26,7 +26,7 @@
 #define MIN_TIME_BETWEEN_ALARM_STARTS 60000 //60 seconds
 #define MIN_TIME_TO_CHANGE_MOTOR_DIRECTION 1500

-#define MAX_ALARM_LENGTH 1200000 //Alarm rings for 20 minutes max
+#define MAX_ALARM_LENGTH 600000 //Alarm rings for 10 minutes max

 RTC_DS1307 RTC;
 Adafruit_SSD1306 display(OLED_RESET_PIN);


Update the JSON parsing buffer size for bigger JSON payload

--- arduino/ClipperTracker.ino
+++ arduino/ClipperTracker.ino
@@ -43,6 +43,9 @@

 #define RACETRACKER_URL "http://clipper.surfsoftconsulting.com"

+// see http://arduinojson.org/faq/how-to-determine-the-buffer-size/
+const int BUFFER_SIZE = 309; // JSON_OBJECT_SIZE(6) + JSON_OBJECT_SIZE(2);
+
 byte symbols[14][8] = {
     // ?
     { B00011100,
@@ -255,16 +258,32 @@
     int httpCode = http.GET();
     if (httpCode == HTTP_CODE_OK) {
       String jsonString = http.getString();
+
+#ifdef DEBUG
+  Serial.println(jsonString);
+#endif
+
       char json[jsonString.length() + 1];
       jsonString.toCharArray(json, jsonString.length() + 1);
-      StaticJsonBuffer<128> jsonBuffer;
+      StaticJsonBuffer<BUFFER_SIZE> jsonBuffer;
       JsonObject& root = jsonBuffer.parseObject(json);
-      String mode = root["mode"];
-      String position = root["position"];
-      if (mode == "s") {
-        position = mode;
-      }
-      iotCore.setApplicationParam(POSITION_PARAM, position);
+
+      if (!root.success()) {
+
+#ifdef DEBUG
+  Serial.println("parseObject() failed");
+#endif
+
+      }
+      else {
+        String mode = root["mode"];
+        String position = root["position"];
+        if (mode == "s") {
+          position = mode;
+        }
+        iotCore.setApplicationParam(POSITION_PARAM, position);
+      }
+
       lastRefreshChangeAt = millis();
     }
     http.end();


Some comments

Some comments

--- otto/otto.ino
+++ otto/otto.ino
@@ -92,13 +92,15 @@

 void stepForward() {
     int i = 0;
-
+
+    // rotate to center
     for (i = 0; i < MOVE; ++i) {
         rightHip.writeMicroseconds(RIGHT_HIP_MIDDLE - MOVE + i);
         leftHip.writeMicroseconds(LEFT_HIP_MIDDLE - MOVE + i);
         delay(DELAY);
     }

+    // rotate left
     for (i = 0; i < MOVE; ++i) {
         rightHip.writeMicroseconds(RIGHT_HIP_MIDDLE + i);
         leftHip.writeMicroseconds(LEFT_HIP_MIDDLE + i);
@@ -107,18 +109,21 @@
         delay(DELAY);
     }

+    // lean right
     for (i = 0; i < MOVE; ++i) {
         rightAnkle.writeMicroseconds(RIGHT_ANKLE_MIDDLE + i);
         leftAnkle.writeMicroseconds(LEFT_ANKLE_MIDDLE + i * FACTOR);
         delay(DELAY);
     }

+    // rotate to center
     for (i = 0; i < MOVE; ++i) {
         rightHip.writeMicroseconds(RIGHT_HIP_MIDDLE + MOVE - i);
         leftHip.writeMicroseconds(LEFT_HIP_MIDDLE + MOVE - i);
         delay(DELAY);
     }

+    // rotate right
     for (i = 0; i < MOVE; ++i) {
         rightHip.writeMicroseconds(RIGHT_HIP_MIDDLE - i);
         leftHip.writeMicroseconds(LEFT_HIP_MIDDLE - i);
@@ -127,6 +132,7 @@
         delay(DELAY);
     }

+    // lean left
     for (i = 0; i < MOVE; ++i) {
         rightAnkle.writeMicroseconds(RIGHT_ANKLE_MIDDLE - i * FACTOR);
         leftAnkle.writeMicroseconds(LEFT_ANKLE_MIDDLE - i);


Tested, works :fire:

Tested, works :fire:

--- src/main.ino
+++ src/main.ino
@@ -16,15 +16,18 @@
 /////////////
 // DEFINES //
 /////////////
-int step_mode = 8;
-#define motorSteps 2048 * (step_mode/4)   // not sure what the exact number is, but this works
+// step_mode let us use halfsteps (but we prolly don't need that)
+int step_mode = 8; // 4 = full, 8 = half
+
+#define fullRev 2048 * (step_mode/4)

 #define ledPin 13       // define test LED

 ////////////////////////
 // STEPPER INITIALIZE //
 ////////////////////////
-Stepper Stepper1(motorSteps, 2, 3, 4, 5, step_mode);
+// the four integers are the pins the motor is connected to.
+Stepper Stepper1(fullRev, 2, 3, 4, 5, step_mode);

 ///////////
@@ -38,7 +41,7 @@
   pinMode(ledPin, OUTPUT);
   blink(3);

-  // max: 160
+  // max is around 160
   Stepper1.setSpeed(100);
 }

@@ -48,10 +51,10 @@
 void loop() {
   // Step forward 100 steps:
   Serial.println("Forward");
-  Stepper1.step(motorSteps);
+  Stepper1.step(fullRev);
   delay(100);
   Serial.println("Backward");
-  Stepper1.step(-motorSteps);
+  Stepper1.step(-fullRev);
 }


add a bunch of effects, change communication protocol for easier chaining

--- Arduino/linkit_duo_led5/linkit_duo_led5.ino
+++ Arduino/linkit_duo_led5/linkit_duo_led5.ino
@@ -1,7 +1,8 @@

 #include <PololuLedStrip.h>
-
 PololuLedStrip<12> ledStrip;
+
+#define RANDOM_SEED_PIN A1

 #define LED_COUNT 72
 #define MAX_LED (LED_COUNT)
@@ -12,6 +13,13 @@

 #define BRIGHTNESS_DIVISOR 20.0
 #define DEFAULT_BRIGHTNESS_PERCENT 20
+#define DIM_BRIGHTNESS_PERCENT (DEFAULT_BRIGHTNESS_PERCENT / 2)
+#define BRIGHT_BRIGHTNESS_PERCENT (DEFAULT_BRIGHTNESS_PERCENT * 2)
+#define MAX_BRIGHTNESS_PERCENT (DEFAULT_BRIGHTNESS_PERCENT * 4)
+
+#define FADE_RATE 0.9999
+#define FADE_DELAY 10
+#define FADE_TIMES 40

 // Standard colors
 rgb_color black = {0, 0, 0};
@@ -29,12 +37,11 @@
 rgb_color purple = {10, 0, 20};
 rgb_color magenta = {20, 0, 20};
 rgb_color pink = {20, 0, 10};
-
-#define NPALETTE 6
-#define NPRETTY_COLORS 6
-rgb_color palette[NPALETTE] = { red, orange, yellow, green, blue, purple };
-//rgb_color palette[NPALETTE] = { red, orange, pink, magenta,      yellow, green, seafoam, ltgreen,       ltblue, cyan, blue, purple,        white };
-
+rgb_color dkgray = {5, 5, 5};
+
+#define NPALETTE 16
+#define NPRETTY_COLORS 13
+rgb_color palette[NPALETTE] = { white, red, orange, yellow, ltgreen, green, seafoam, cyan, ltblue, blue, purple, magenta, pink, black, gray, dkgray };
 rgb_color adjusted_palette[NPALETTE];

 rgb_color scale_color(rgb_color color, float scale){
@@ -120,9 +127,9 @@
   states[0] = BLINK_ON;
 }

-#define BREATHE_TIME 667
+#define BREATHE_TIME 500
 #define BREATHE_BRIGHTNESS_MAX DEFAULT_BRIGHTNESS_PERCENT
-#define BREATHE_MAX_STEP 24
+#define BREATHE_MAX_STEP 22
 #define BREATHE_BRIGHTNESS_MIN 0
 #define DEFAULT_BRIGHTNESS_SCALE (DEFAULT_BRIGHTNESS_PERCENT / 100.0)
 #define MINIMUM_BRIGHTNESS_SCALE 0.03
@@ -154,13 +161,69 @@
   0.0,
   0.0,  // a few extra make it feel more natural
   0.0,
-  0.0,
-  0.0,
+//  0.0,
+//  0.0,
   0,0
 };

 void start_breathing(){
   states[0] = BREATHE_ON;
+}
+
+rgb_color blend_colors(rgb_color color1, rgb_color color2){
+  rgb_color result;
+  result.red = (color1.red + color2.red) / 2;
+  result.green = (color1.green + color2.green) / 2;
+  result.blue = (color1.blue + color2.blue) / 2;
+  return result;
+}
+
+void do_blend(){
+  colors[0] = blend_colors(colors[0], colors[1]);
+  colors[1] = colors[0];
+}
+
+void do_max(){
+  colors[0] = scale_color(colors[0], MAX_BRIGHTNESS_PERCENT / 100.0);
+}
+
+void do_dim(){
+  colors[0] = scale_color(colors[0], DIM_BRIGHTNESS_PERCENT / 100.0);
+}
+
+void do_bright(){
+  colors[0] = scale_color(colors[0], BRIGHT_BRIGHTNESS_PERCENT / 100.0);
+}
+
+void fade(float rate = FADE_RATE){
+  unsigned char *p;
+  p = (unsigned char *)colors;
+  for(int i = 0; i < LED_COUNT * 3; i++){
+    *(p + i) *= rate;
+  }
+}
+
+void do_fade(float rate = FADE_RATE){
+  for(int i = 0; i < FADE_TIMES; i++){
+    fade(rate);
+    ledStrip.write(colors, LED_COUNT);
+    delay(FADE_DELAY);
+  }
+}
+
+void do_flood(){
+  for(int i = 1; i < LED_COUNT; i++){
+    colors[i] = colors[0];
+    states[i] = states[0];
+  }
+}
+
+rgb_color random_color(){
+  return palette[random(NPRETTY_COLORS)];
+}
+
+int do_random(){
+  push_color(random_color());
 }

 void setup_buffer(){
@@ -169,11 +232,10 @@
       if(blink_state){
         render[i] = scale_color(colors[i], DEFAULT_BRIGHTNESS_SCALE);
       } else {
-        //render[i] = black;
         render[i] = scale_color(colors[i], MINIMUM_BRIGHTNESS_SCALE);
       }
     } else if(states[i] == BREATHE_ON){
-      render[i] = scale_color(colors[i], DEFAULT_BRIGHTNESS_SCALE * breathe_steps[breathe_step]);
+      render[i] = scale_color(colors[i], DEFAULT_BRIGHTNESS_SCALE * breathe_steps[BREATHE_MAX_STEP - breathe_step]);
     } else {
       render[i] = scale_color(colors[i], DEFAULT_BRIGHTNESS_SCALE);
     }
@@ -191,6 +253,15 @@
     setup_buffer();
     display_buffer();
   }
+}
+
+// Compute a random seed by sampling an unconnected analog input pin
+int random_seed(){
+  int seed = analogRead(RANDOM_SEED_PIN);
+  for(int i = 0; i < 16; i++){
+    seed = (seed << 1) ^ analogRead(0);
+  }
+  randomSeed(seed);
 }

 void setup() {
@@ -199,7 +270,8 @@
   Serial1.begin(57600);  // open internal serial connection to
                          //MT7688
   //pinMode(13, OUTPUT); // in MT7688, this maps to device
-
+
+  random_seed();
   setup_colors(false);
   erase(true);
 }
@@ -215,7 +287,7 @@
   rgb_color color;

   if(Serial1.available() > 0){
-    int c = Serial1.readBytesUntil('\0', str, MAX_STRING_LENGTH);
+    int c = Serial1.readBytesUntil('|', str, MAX_STRING_LENGTH);
     str[c] = 0;

     // reset the states so the automatic render won't interfere
@@ -223,6 +295,16 @@
     blink_counter = 0;
     breathe_step = 0;
     breathe_counter = 0;
+
+// fast blink, breathe
+// static, flame
+// flame
+// tripple blink, rotating blink cycle, cop lights
+// invert hue, swing hue, back and forth between two arbitrary colors, rgb cube
+// rainbow colors incremental, or continuously changing
+// shooting up
+// push-down animation when a new build is seen (to emphasize its adding)
+// fade based on build time

     if     (is_command(str, "pause"))    paused = true;
     else if(is_command(str, "continue")) paused = false;
@@ -230,6 +312,13 @@
     else if(is_command(str, "blink"))    start_blinking();
     else if(is_command(str, "breathe"))  start_breathing();
     else if(is_command(str, "flush"))    flush();
+    else if(is_command(str, "blend"))    do_blend();
+    else if(is_command(str, "max"))      do_max();
+    else if(is_command(str, "dim"))      do_dim();
+    else if(is_command(str, "bright"))   do_bright();
+    else if(is_command(str, "fade"))     do_fade();
+    else if(is_command(str, "flood"))    do_flood();
+    else if(is_command(str, "random"))   do_random();
     else if(is_command(str, "red"))      push_color(red);
     else if(is_command(str, "green"))    push_color(green);
     else if(is_command(str, "blue"))     push_color(blue);
@@ -245,52 +334,8 @@
     else if(is_command(str, "ltgreen"))  push_color(ltgreen);
     else if(is_command(str, "seafoam"))  push_color(seafoam);
     else if(is_command(str, "ltblue"))   push_color(ltblue);
+    else if(is_command(str, "dkgray"))   push_color(dkgray);

-//
-//
-//    if(is_command(str, "pause")){
-//      paused = true;
-//    } else if(is_command(str, "continue")){
-//      paused = false;
-//    } else if(is_command(str, "erase")){
-//      erase(true);
-//    } else if(is_command(str, "red")){
-//      push_color(red);
-//    } else if(is_command(str, "blink")){
-//      start_blinking();
-//    } else if(is_command(str, "breathe")){
-//      start_breathing();
-//    } else if(is_command(str, "flush")){
-//      flush();
-//    } else if(is_command(str, "green")){
-//      push_color(green);
-//    } else if(is_command(str, "blue")){
-//      push_color(blue);
-//    } else if(is_command(str, "black")){
-//      push_color(black);
-//    } else if(is_command(str, "yellow")){
-//      push_color(yellow);
-//    } else if(is_command(str, "orange")){
-//      push_color(orange);
-//    } else if(is_command(str, "purple")){
-//      push_color(purple);
-//    } else if(is_command(str, "cyan")){
-//      push_color(cyan);
-//    } else if(is_command(str, "magenta")){
-//      push_color(magenta);
-//    } else if(is_command(str, "pink")){
-//      push_color(pink);
-//    } else if(is_command(str, "white")){
-//      push_color(white);
-//    } else if(is_command(str, "gray")){
-//      push_color(gray);
-//    } else if(is_command(str, "ltgreen")){
-//      push_color(ltgreen);
-//    } else if(is_command(str, "seafoam")){
-//      push_color(seafoam);
-//    } else if(is_command(str, "ltblue")){
-//      push_color(ltblue);
-//    }
   } else {
     bool should_flush = false;


pulse function v0.0

pulse function v0.0

--- wip/wip.ino
+++ wip/wip.ino
@@ -91,3 +91,22 @@
   FastLED.show();
   delay(ms);
 }
+
+
+void pulse(CRGB *leds, int numOfLeds, int red, int green, int blue, int ms){
+  int numOfSteps = 10;
+
+
+  for (int step = 0; step < numOfSteps; step++){
+
+    int tempRed = red - (step * (red / numOfSteps));
+    int tempGreen = green - (step * (green / numOfSteps));
+    int tempBlue = blue - (step * (blue / numOfSteps));
+
+    for (int i = 0; i < numOfLeds; i++){
+      leds[i].setRGB(tempGreen, tempBlue, tempRed);
+    }
+
+  }
+
+}


cosmetic bug fix for the updater.

cosmetic bug fix for the updater.

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

--- zimodem/zcommand.ino
+++ zimodem/zcommand.ino
@@ -1056,7 +1056,10 @@

   while((bufSize>0)
   &&((buf[bufSize-1]==10)||(buf[bufSize-1]==13)))
+  {
     bufSize--;
+    buf[bufSize] = 0;
+  }

   if((strlen(ZIMODEM_VERSION)==bufSize) && memcmp(buf,ZIMODEM_VERSION,strlen(ZIMODEM_VERSION))==0)
   {


4th Commit - Added LiPo Fuel Gauge

4th Commit - Added LiPo Fuel Gauge

Specifically, added code into the setup() function to initialize the the
device.

--- SmartPakku/SmartPakku.ino
+++ SmartPakku/SmartPakku.ino
@@ -6,6 +6,10 @@
 #include <nRF8001.h>

 #include "services.h"
+
+// For LiPo Fuel Gauge
+#include "MAX17043.h"
+#include "Wire.h"

 hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] = SETUP_MESSAGES_CONTENT;

@@ -21,6 +25,10 @@
 float temperatureC;
 uint8_t pipeStatusReceived, dataSent;
 unsigned long lastSent;
+
+// For LiPo Fuel Gauge
+MAX17043 batteryMonitor;
+

 // This function is called when nRF8001 responds with the temperature
 void temperatureHandler(float tempC)
@@ -42,8 +50,31 @@
 	pipeStatusReceived = 0;
 	lastSent = 0;

+	Wire.begin();
 	Serial.begin(115200);
 	Serial.println("Hello");
+
+	// LiPo Fuel Gauge Init Code
+
+	Serial.println("MAX17043 Example: reading voltage and SoC");
+	Serial.println();
+
+	batteryMonitor.reset();
+	batteryMonitor.quickStart();
+	delay(1000);
+
+	float cellVoltage = batteryMonitor.getVCell();
+	Serial.print("Voltage:\t\t");
+	Serial.print(cellVoltage, 4);
+	Serial.println("V");
+
+	float stateOfCharge = batteryMonitor.getSoC();
+	Serial.print("State of charge:\t");
+	Serial.print(stateOfCharge);
+	Serial.println("%");
+
+	// // LiPo Fuel Gauge Init Code End
+

 	// nRF8001 class initialized with pin numbers
 	nrf = new nRF8001(RESET_PIN, REQN_PIN, RDYN_PIN);


BARS_BORDER is now #defined.

BARS_BORDER is now #defined.

To make smaller bars, just increase BARS_BORDER.

--- tfttask.ino
+++ tfttask.ino
@@ -1,8 +1,11 @@
+#define TEXT_COLOR    ILI9341_YELLOW
+#define BACK_COLOR    ILI9341_BLACK
+
 void tftTask( void * pvParameters )
 {
   while (1)
   {
-    tft.setTextColor( ILI9341_YELLOW , ILI9341_BLACK );
+    tft.setTextColor( TEXT_COLOR , BACK_COLOR );
     tft.setCursor( 15, 0 );
     tft.setTextSize( 2 );

@@ -18,29 +21,36 @@

 #define BARS_BOTTOM    170
 #define BARS_HEIGHT    150
+#define BARS_BORDER    10
 #define BARS_WIDTH     ILI9341_TFTHEIGHT / 5
-#define HEIGHT_FACTOR  BARS_HEIGHT / 100
+#define HEIGHT_FACTOR  BARS_HEIGHT / 100.0

     for ( byte thisChannel = 0; thisChannel < NUMBER_OF_CHANNELS; thisChannel++ )
     {
-      // redraw the top part of the bar
-      tft.fillRect( thisChannel * BARS_WIDTH + 5,
-                    BARS_BOTTOM - BARS_HEIGHT,
-                    BARS_WIDTH - 10,
-                    BARS_HEIGHT - channel[thisChannel].currentPercentage * HEIGHT_FACTOR,
-                    ILI9341_WHITE );
-
+      //convert from String to RGB color
       //https://stackoverflow.com/questions/2342114/extracting-rgb-color-components-from-integer-value/2342149#2342149
       int r, g, b;
-      //convert from String to color
       int color = strtol( &channel[thisChannel].color[1], NULL, 16 );
       r = ( color & 0xFF0000 ) >> 16; // Filter the 'red' bits from color. Then shift right by 16 bits.
       g = ( color & 0x00FF00 ) >> 8;  // Filter the 'green' bits from color. Then shift right by 8 bits.
       b = ( color & 0x0000FF );       // Filter the 'blue' bits from color. No shift needed.

-      tft.fillRect( thisChannel * BARS_WIDTH + 5,
+      // redraw the top part of the bar
+      tft.fillRect( thisChannel * BARS_WIDTH + BARS_BORDER,
+                    BARS_BOTTOM - BARS_HEIGHT,
+                    BARS_WIDTH - BARS_BORDER * 2,
+                    BARS_HEIGHT - channel[thisChannel].currentPercentage * HEIGHT_FACTOR,
+                    BACK_COLOR );
+/*
+      //high water mark
+      tft.drawFastHLine( thisChannel * BARS_WIDTH + BARS_BORDER,
+                         BARS_BOTTOM - BARS_HEIGHT - 1,
+                         BARS_WIDTH - BARS_BORDER * 2,
+                         tft.color565( r, g, b ) );
+*/
+      tft.fillRect( thisChannel * BARS_WIDTH + BARS_BORDER,
                     BARS_BOTTOM - channel[thisChannel].currentPercentage * HEIGHT_FACTOR,
-                    BARS_WIDTH - 10,
+                    BARS_WIDTH - BARS_BORDER * 2,
                     channel[thisChannel].currentPercentage * HEIGHT_FACTOR,
                     tft.color565( r, g, b ) );
       tft.setTextSize( 1 );


speeding up screensaver refresh rate.

speeding up screensaver refresh rate.

--- src/rx5808-pro-diversity-oled/rx5808-pro-diversity-oled.ino
+++ src/rx5808-pro-diversity-oled/rx5808-pro-diversity-oled.ino
@@ -757,7 +757,7 @@
         display.print("B");
 #endif
         do{
-            delay(20); // timeout delay
+            delay(10); // timeout delay
             // show signal strength
             rssi = readRSSI(); // update LED
 #ifdef USE_DIVERSITY


Add conditional compilation for menu or Hayes mode

--- MicroView/WiFiModem-Menu/WiFiModem-Menu.ino
+++ MicroView/WiFiModem-Menu/WiFiModem-Menu.ino
@@ -3,6 +3,10 @@
     Author: Leif Bloomquist
     With assistance and code from Greg Alekel, Payton Byrd, Craig Bruce
 */
+
+// Defining HAYES enables Hayes commands and disables the 1) and 2) menu options for telnet and incoming connections.
+// This is required to ensure the compiled code is <= 30,720 bytes
+//#define HAYES

 #include <MicroView.h>
 #include <elapsedMillis.h>
@@ -116,7 +120,11 @@
         HandleAutoStart();

         C64Println();
+#ifdef HAYES
+        C64Println(F("Commodore Wi-Fi Modem Hayes"));
+#else
         C64Println(F("Commodore Wi-Fi Modem"));
+#endif // HAYES
         ShowInfo(true);
     }
     while (1)
@@ -126,10 +134,14 @@
         C64Println();
         ShowPETSCIIMode();
         C64Println();
+#ifdef HAYES
+        C64Println(F("1. Hayes Emulation Mode"));
+        C64Println(F("2. Configuration"));
+#else
         C64Println(F("1. Telnet to host or BBS"));
         C64Println(F("2. Wait for incoming connection"));
-        C64Println(F("3. Hayes Emulation Mode"));
-        C64Println(F("4. Configuration"));
+        C64Println(F("3. Configuration"));
+#endif // HAYES
         C64Println();
         C64Print(F("Select: "));

@@ -138,6 +150,15 @@

         switch (option)
         {
+#ifdef HAYES
+        case '1':
+            HayesEmulationMode();
+            break;
+
+        case '2':
+                Configuration();
+            break;
+#else
         case '1':
             DoTelnet();
             break;
@@ -145,15 +166,12 @@
         case '2':
             Incoming();
             break;
-
+
         case '3':
-            HayesEmulationMode();
-            break;
-
-        case '4':
                 Configuration();
             break;
-
+
+#endif // HAYES
         case '\n':
         case '\r':
         case ' ':
@@ -488,6 +506,7 @@
     }
 }

+#ifndef HAYES
 // ----------------------------------------------------------
 // Simple Incoming connection handling

@@ -523,9 +542,9 @@

     TerminalMode();
 }
-
 // ----------------------------------------------------------
 // Telnet Handling
+

 void DoTelnet()
 {
@@ -570,6 +589,7 @@
         }
     }
 }
+#endif // HAYES

 void Connect(String host, int port, boolean raw)
 {
@@ -807,10 +827,17 @@
         C64Println(F(")"));
         C64Println();
         C64Println(F("0. Clear Autostart Options"));
+#ifdef HAYES
         C64Println(F("1. Hayes Emulation Mode"));
         C64Println(F("2. CommodoreServer"));
         C64Println(F("3. QuantumLink Reloaded"));
         C64Println(F("4. Return to Main Menu"));
+#else
+        C64Println(F("1. CommodoreServer"));
+        C64Println(F("2. QuantumLink Reloaded"));
+        C64Println(F("3. Return to Main Menu"));
+#endif // HAYES
+
         C64Println();
         C64Print(F("Select: "));

@@ -821,7 +848,7 @@
         {
         case '0': autostart_mode = AUTO_NONE;
             break;
-
+#ifdef HAYES
         case '1': autostart_mode = AUTO_HAYES;
             break;

@@ -832,6 +859,15 @@
             break;

         case '4': return;
+#else
+        case '1': autostart_mode = AUTO_CSERVER;
+            break;
+
+        case '2': autostart_mode = AUTO_QLINK;
+            break;
+
+        case '3': return;
+#endif // HAYES

         case 8:
             SetPETSCIIMode(false);
@@ -864,11 +900,13 @@
         case AUTO_NONE:  // No Autostart, continue as normal
             return;

+#ifdef HAYES
         case AUTO_HAYES: // Hayes Emulation
             C64Println(F("Entering Hayes Emulation Mode"));
             break;

-        case AUTO_CSERVER: // Hayes Emulation
+#endif // HAYES
+        case AUTO_CSERVER: // Commodore Server
             C64Println(F("Connecting to CommodoreServer"));
             break;

@@ -898,10 +936,11 @@

     switch (autostart_mode)
     {
+#ifdef HAYES
         case AUTO_HAYES: // Hayes Emulation
             HayesEmulationMode();
             break;
-
+#endif // HAYES
         case AUTO_CSERVER: // CommodoreServer - just connect repeatedly
             while (true)
             {
@@ -920,6 +959,7 @@
     }
 }

+#ifdef HAYES
 // ----------------------------------------------------------
 // Simple Hayes Emulation
 // Portions of this code are adapted from Payton Byrd's Hayesduino - thanks!
@@ -1470,7 +1510,7 @@
     //digitalWrite(DCE_RTS, HIGH);
 }

-
+#endif // HAYES

 // -------------------------------------------------------------------------------------------------------------
 // QuantumLink Reloaded! Support


Fix debug output field mixup.

Fix debug output field mixup.

--- test/PoE-test/tussendeur-asis-2017/tussendeur-asis-2017.ino
+++ test/PoE-test/tussendeur-asis-2017/tussendeur-asis-2017.ino
@@ -622,7 +622,7 @@
     if (millis() - lastReport > 3000 || doorstate != lastdoorstate) {
       lastReport = millis();
       char msg[256];
-      snprintf(msg, sizeof(msg), "[%s] Door %sin an odd state-forcing close.", doorstate == lastdoorstate ? "still " : "",  pname);
+      snprintf(msg, sizeof(msg), "[%s] Door %sin an odd state-forcing close.", pname, doorstate == lastdoorstate ? "still " : "");
       Serial.println(msg);
       client.publish(log_topic, msg);
     };


feat: bluetooth debugging
fix: corrected spConst variable

added bluetooth debugging code in pid.ino file
minor fixes in other files

--- pid.ino
+++ pid.ino
@@ -16,16 +16,15 @@

 void setup() {
   // put your setup code here, to run once:
-
   motors.configure();
   sensors.configure();
   Serial.begin(9600);
-
+
 }

 void loop() {
   // put your main code here, to run repeatedly:
-
+    phone();
     sensors.updateError();
     calculate_pid();
     motors.drive(PID_value);
@@ -36,7 +35,7 @@

 void calculate_pid()
 {
-    error = sensors.error * 10;
+    error = (sensors.error)*10;
     P = error;
     I = I + error;
     D = error - previous_error;
@@ -45,10 +44,14 @@

     previous_error=error;

-    Serial.print("pidval : ");
-      Serial.print(PID_value);
-    Serial.println("\t");
-/**
+   // Serial.print("pidval : ");
+     // Serial.print(PID_value);
+    //Serial.println("\t");
+    /**Serial.print("\n");
+    Serial.print("PIDVal : ");
+    Serial.print(PID_value);
+    Serial.print("\t");
+
     Serial.print("P : ");
     Serial.print(P);
     Serial.print("\t");
@@ -61,9 +64,7 @@
     Serial.print(D);
     Serial.print("\t");

-    Serial.print("PIDVal : ");
-    Serial.print(PID_value);
-    Serial.print("\t");
+

     Serial.print("Prvs_error : ");
     Serial.print(previous_error);
@@ -71,3 +72,34 @@
    **/
 }

+void phone()
+{
+
+  if(Serial.available())
+    {
+      if(Serial.read()=='1'){
+          Ki+=0.1;
+          Serial.write("Ki value is incremented");
+      }
+      else if(Serial.read()=='0'){
+          Kd+=1;
+          Serial.write("Kd value is incremented");
+      }
+      else if(Serial.read()=='2'){
+          Kp+=1;
+          Serial.write("Kp value is incremented");
+      }
+      else if(Serial.read()=='3'){
+          Ki-=0.1;
+          Serial.write("Ki value is decremented");
+      }
+      else if(Serial.read()=='4'){
+          Kd-=1;
+          Serial.write("Kd value is decremented");
+      }
+      else if(Serial.read()=='5'){
+          Kp-=1;
+          Serial.write("Kp value is decremented");
+      }
+  }
+}


new blah

new blah

--- proj/hypercube/HCS/HCS.ino
+++ proj/hypercube/HCS/HCS.ino
@@ -106,7 +106,7 @@
   gBrightness = maxBrightness;
   gBlending = LINEARBLEND;
   iPaletteCounter = 0;
-  oPaletteCounter = iPaletteCounter;
+  oPaletteCounter = iPaletteCounter + 2;
   gPaletteCounter = 0;

   iAnimCounter = 0;


v2.0

v2.0

Now with correct current conversion and averaging of 10 samples

--- photon-files/powermonitor.ino
+++ photon-files/powermonitor.ino
@@ -1,8 +1,8 @@
 #include "math.h"
 int analogvals[2500];
-int cnt;
+int cnt,cnt2;
 double Vmid = 1.61;
-double RMScurrent;
+double avgsamp, RMScurrent;
 char publishString[40];

 void setup() {
@@ -28,12 +28,19 @@

     while(cnt<2500){

-        RMScurrent = RMScurrent + pow((3.3*((double) analogvals[cnt])/4095-Vmid)*200,2); ///store current read to the array location cnt
-        cnt = cnt + 1;
+        //create a averaged point of 10 samples
+        cnt2 = 0;
+        avgsamp = 0;
+        while (cnt2<10){
+            avgsamp = avgsamp + (double) analogvals[cnt];
+            cnt = cnt + 1;
+            cnt2 = cnt2 + 1;
+        }

+        RMScurrent = RMScurrent + pow((3.3*avgsamp/4095-Vmid)*20,2);//convert to a current, square it, and sum
     }

-    RMScurrent = sqrt(RMScurrent/2500);
+    RMScurrent = sqrt(RMScurrent/250);//root mean of 2500/10 = 250 averaged samples

     sprintf(publishString, "%lf", RMScurrent);
     Particle.publish("RMScurrent",publishString);


Add a response code and message for timeouts

--- barf_esp8266.ino
+++ barf_esp8266.ino
@@ -277,6 +277,9 @@
 			response_data = response_data.substring(7);
 		} else if (!response_data.length()) {
 			status_code = 404;
+		} else if (response_data == TIMEOUT) {
+			response_data = "";
+			status_code = 504;
 		}
 	}

@@ -293,6 +296,8 @@
 		status_reason = "I'm a teapot";
 	} else if (status_code == 500) {
 		status_reason = "Internal Server Error";
+	} else if (status_code == 504) {
+		status_reason = "Gateway Timeout";
 	} else {
 		status_reason = "";
 	}


moving to another computer

moving to another computer

--- proj/ledvo_lounge_v0/ledvo_lounge_v0.ino
+++ proj/ledvo_lounge_v0/ledvo_lounge_v0.ino
@@ -459,37 +459,34 @@
   FastLED.show();
 }

-/*void palette_eq_tri() {
+
+// FINISH THIS SHIT
+void palette_eq_tri() {
   static uint8_t pal_index = 0;
   static uint8_t lead_max = numLED / 2;
   static uint8_t lead = 0;
+  static uint8_t prev;

   // Fill bar at input dependent rate. First record the previous lead value
   // so that we can check which diretion we are heading on the sin wave later on
-
+  EVERY_N_MILLISECONDS_I(thisTimer, 50) {
+    thisTimer.setPeriod(map(analogRead(RATE_POT), 0, 1253, 10, 200));
+  }

   // If the eq bar is about to be empty, generate a new max length to fill.
   // Also increment the index of the palette, for a little more modulation cuz
   // why not.
-  if (lead == 0 && (lead - prev) < 0) {
+  if (lead == 0) {
     pal_index+=16;
     lead_max = random8(numLED / 3, numLED);

   }

-  // Check for rate change here so we don't interrupt the color and length
-  // assignment
-  if (lead == 0 && (lead - prev) < 0 && last_second != second) {
-    last_second = second;
-    bpm = map(analogRead(RATE_POT), 0, 1253, 120, 10);
-    lead = 0;
-  }
-
   //fill_palette(leds, lead, pal_index, 16, gPalette, maxBrightness, gBlending);
   fill_solid(leds, lead, ColorFromPalette(gPalette, pal_index, gBrightness, gBlending));
   FastLED.show();
   fadeToBlackBy(leds, numLED, 20);
-}*/
+}

 void starry_night() {


Made the lower threshold a bit higher, so it turns off more quickly

--- shofanduino2/shofanduino2.ino
+++ shofanduino2/shofanduino2.ino
@@ -148,7 +148,7 @@
   // want the fan to turn on pretty quickly, but we don't
   // want it to turn off quickly. This explains the difference
   // in factors between low and high.
-  thresholdLow = env_min + (env_max - env_min) / 10.0f;
+  thresholdLow = env_min + (env_max - env_min) / 8.0f;
   thresholdHigh = env_min + (env_max - env_min) / 2.0f;

   /*


COH-80: WIP

COH-80: WIP

--- COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
+++ COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
@@ -368,26 +368,29 @@
     return(PrimaryRadio.sendRaw(txbuf, bodylen, 0, OTRadioLink::OTRadioLink::TXmax));
     }
 #else
-    uint8_t key[16];
-    if(!OTV0P2BASE::getPrimaryBuilding16ByteSecretKey(key))
-      {
-      OTV0P2BASE::serialPrintlnAndFlush("!TX key");
-      return(false); // Failed.
-      }
-    const OTRadioLink::SimpleSecureFrame32or0BodyTXBase::fixed32BTextSize12BNonce16BTagSimpleEnc_ptr_t e = OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleEnc_DEFAULT_STATELESS;
-    const uint8_t txIDLen = OTRadioLink::ENC_BODY_DEFAULT_ID_BYTES;
-    uint8_t buf[OTRadioLink::SimpleSecureFrame32or0BodyTXBase::generateSecureBeaconMaxBufSize];
-    const uint8_t bodylen = secureTXState.generateSecureBeaconRawForTX(buf, sizeof(buf), 2, e, NULL, key);
-    // ASSUME FRAMED CHANNEL 0 (but could check with config isUnframed flag).
-    // When sending on a channel with framing, do not explicitly send the frame length byte.
-    // DO NOT attempt to send if construction of the secure frame failed;
-    // doing so may reuse IVs and destroy the cipher security.
-    const bool success = (0 != bodylen) && PrimaryRadio.sendRaw(buf+1, bodylen-1);
+  uint8_t key[16];
+  if(!OTV0P2BASE::getPrimaryBuilding16ByteSecretKey(key))
+    {
+    OTV0P2BASE::serialPrintlnAndFlush("!TX key");
+    return(false); // Failed.
+    }
+  const OTRadioLink::SimpleSecureFrame32or0BodyTXBase::fixed32BTextSize12BNonce16BTagSimpleEnc_ptr_t e = OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleEnc_DEFAULT_STATELESS;
+  const uint8_t txIDLen = OTRadioLink::ENC_BODY_DEFAULT_ID_BYTES;
+  uint8_t buf[OTRadioLink::SimpleSecureFrame32or0BodyTXBase::generateSecureBeaconMaxBufSize];
+  const uint8_t bodylen = secureTXState.generateSecureBeaconRawForTX(buf, sizeof(buf), 2, e, NULL, key);
+  // ASSUME FRAMED CHANNEL 0 (but could check with config isUnframed flag).
+  // When sending on a channel with framing, do not explicitly send the frame length byte.
+  // DO NOT attempt to send if construction of the secure frame failed;
+  // doing so may reuse IVs and destroy the cipher security.
+  const bool success = (0 != bodylen) && PrimaryRadio.sendRaw(buf+1, bodylen-1);
 #if 1 && defined(DEBUG)
-    if(!success) { OTV0P2BASE::serialPrintlnAndFlush("!TX"); }
-#endif
+  if(!success) { OTV0P2BASE::serialPrintlnAndFlush("!TX"); }
+  else { OTV0P2BASE::serialPrintlnAndFlush("TX alert"); }
+#endif
+  if(success) { return(true); } // Done!
 #endif // ENABLE_OTSECUREFRAME_ENCODING_SUPPORT
-  return(false); // Failed.
+  // FAILED if fallen through to here.
+  return(false);
   }
 #endif


Fix LCD bug.

Fix LCD bug.

Pins 11, 12, and 13 were being used by the Wave Shield, so I those pins
needed to be used somewhere else. The only other place left for them
were pins 1, and 0. Consequently, this removes the ability to use the
Serial Monitor, which I am okay with.

--- EmotionalClothing.ino
+++ EmotionalClothing.ino
@@ -6,7 +6,7 @@

 #include "ColorUtil.h"

-LiquidCrystal lcd(12, 11, 9, 8, 7, 6);
+LiquidCrystal lcd(1, 0, 9, 8, 7, 6);

 String fileNames[4] = {"BUGS2.WAV", "DAFFY1.WAV", "BUGS1.WAV", "DAFFY2.WAV"};

@@ -39,12 +39,12 @@
 }

 void setup() {
-  Serial.begin(9600);
   setupSdReader(card);
   setupFatVolume(vol);
   setupFatReader(root);
   setupRGBSensor(tcs);
   lcd.begin(16, 2);
+  lcd.clear();
   lcd.print("Before");
 }


implementado desligamento suave, resolves #19

--- EMP-B-Due.ino
+++ EMP-B-Due.ino
@@ -108,6 +108,8 @@
 boolean maquina_ligada = FALSO;
 boolean dosador_ligado = FALSO;
 boolean datador_ligado = FALSO;
+boolean desligamento_suave = FALSO;
+unsigned long desligarEm = 0;
 boolean alarme_ativo = FALSO;
 boolean fotocelula_liberada = FALSO;
 boolean fotocelula_cortou = FALSO;
@@ -203,7 +205,7 @@
       geraPWM(pot_solda_vertical, &tempo_PWM_vertical, solda_vertical_PWM);
       geraPWM(pot_solda_horizontal, &tempo_PWM_horizontal, solda_horizontal_PWM);
       geraPWM(pot_solda_datador, &tempo_PWM_datador, solda_datador_PWM);
-      if (maquina_ligada) {
+      if (maquina_ligada || desligamento_suave) {
         iniciaTrabalho(); // Inicia Ciclos de Produção
       }
     } else {
@@ -269,11 +271,13 @@
   if (maquina_ligada) {
     ligaFuncao(geral, NomeGeral);
   } else {
-    if (ligado(geral)){
+    if (ligado(geral) && !desligamento_suave){
+      desligamento_suave = VERDADEIRO;
+      escreveSerial("Fazendo desligamento suave.");
+    } else if (conta_ciclos == desligarEm) {
       desligaFuncao(geral, NomeGeral);
       resetCompleto();
     }
-    // desligaFuncao(geral, NomeGeral);
   }
 }

@@ -330,6 +334,15 @@
   resetado = VERDADEIRO;
   fotocelula_liberada = FALSO;
   fotocelula_cortou = FALSO;
+  // if (desligamento_suave && desligarEm){
+  //   reiniciaSaidas();
+  //   resetCompleto();
+  // } else
+  if (desligamento_suave && dosador_ligado){
+    dosador_ligado = FALSO;
+    desligaFuncao(dosador, NomeDosador);
+    desligarEm = conta_ciclos + 1;
+  }
 }

 void cicloMedio() {
@@ -535,6 +548,8 @@
   maquina_ligada = FALSO;
   dosador_ligado = FALSO;
   datador_ligado = FALSO;
+  desligamento_suave = FALSO;
+  desligarEm = 0;
   fotocelula_liberada = FALSO;
   fotocelula_cortou = FALSO;
   produzindo = FALSO;


working test code to check SPI flash chip connected

--- spi_flash.ino
+++ spi_flash.ino
@@ -7,12 +7,51 @@
   Serial.begin(115200);
   // if this is run before setup, then doesn't work.
   // other option is to have an init function.
-  spiFlash = new S25FL208K(4);
+  //spiFlash = new S25FL208K(4);
   Serial.println("Setup complete.");

-  Serial.println(spiFlash->readStatus(),BIN);
-  spiFlash->writeEnable();
-  Serial.println(spiFlash->readStatus(),BIN);
+  //Serial.println(spiFlash->readStatus(),BIN);
+  //spiFlash->writeEnable();
+  //Serial.println(spiFlash->readStatus(),BIN);
+
+  SPI.begin();
+  int csPin = 4;
+  pinMode(csPin, OUTPUT);
+  digitalWrite(csPin, 1);
+
+  uint8_t res = 0;
+  digitalWrite(csPin, 0);
+  SPI.transfer(0x05);
+  res = SPI.transfer(0);
+  digitalWrite(csPin, 1);
+
+  Serial.println(res,BIN);
+
+  digitalWrite(csPin, 0);
+  SPI.transfer(0x06);
+  digitalWrite(csPin, 1);
+
+  digitalWrite(csPin, 0);
+  SPI.transfer(0x05);
+  res = SPI.transfer(0);
+  digitalWrite(csPin, 1);
+
+  Serial.println(res,BIN);
+
+  digitalWrite(csPin, 0);
+  SPI.transfer(0x04);
+  digitalWrite(csPin, 1);
+
+  digitalWrite(csPin, 0);
+  SPI.transfer(0x05);
+  res = SPI.transfer(0);
+  digitalWrite(csPin, 1);
+
+  Serial.println(res,BIN);
+
+
+
+
 }

 void loop(){


define and fix bug

define and fix bug

--- scripts-arduino/bp_led_lp.ino
+++ scripts-arduino/bp_led_lp.ino
@@ -3,6 +3,10 @@
 const int LED_PIN =  2;             // the number of the LED pin
 const String CONST_ID = "01";       // the main Id
 const String CONST_TYPE = "01";     // the id of press button
+
+// ######## DEF ########
+#define LONGPRESS_LEN    25         // Min nr of loops for a long press
+#define DELAY            20         // Delay per loop in ms

 // ######## VAR ########
 int buttonState = 0;                // variable for reading the pushbutton status
@@ -21,15 +25,15 @@
 // ######## SETUP ########
 void setup() {
     Serial.begin(9600);
-    pinMode(ledPin, OUTPUT);          // initialize the LED pin as an output:
-    pinMode(buttonPin, INPUT);        // initialize the pushbutton pin as an input:
+    pinMode(LED_PIN, OUTPUT);          // initialize the LED pin as an output:
+    pinMode(BUTTON_PIN, INPUT);        // initialize the pushbutton pin as an input:
     button_was_pressed = false;       // initialize the pushbutton to false (not pressed)
     button_pressed_counter = 0;       // initialize the pusbutton counter
 }

 // ######## LOOP ########
 void loop(){
-    boolean eventResult = eventButton();
+    boolean eventResult = handle_button();

     switch(eventResult){
         case EV_NONE:               // if nothing append
@@ -52,6 +56,8 @@
             //TODO : Faire clignoter la LED et attendre la fin d'une synchronisation.
             break;
     }
+
+    delay(DELAY);
 }

 // ####### Function ########


1h before sunrise, small formatting, ina smoothing


Calculations clarified

Calculations clarified

--- src/Arduino/_23cm-trx/PLL.ino
+++ src/Arduino/_23cm-trx/PLL.ino
@@ -7,6 +7,8 @@
 #define DATA      PC1
 #define CLK       PC0

+unsigned long fref = 12800000; // reference frequency from the TCXO
+unsigned long fraster = 25000; // raster/step frequency

 /*
  * Initialize the PLL using the "Counter Reset Method" as
@@ -18,47 +20,60 @@
   digitalWrite(LE,  LOW)

   // Step 2, Conduct a function latch load with F1 bit set.
-  unsigned long reg = 0x438086;
+  //
+  // Set function latch (bits 0,1):
+  // - Hold R/A/B counters on reset (F1, bit 2)
+  // - Normal power                 (bit 3)
+  // - Three state muxout           (bit 4,5,6)
+  // - Positive Phase detection     (bit 7)
+  // - Three-state Charge pump      (bit 8)
+  // - High current Charge pump     (bits 15,16,17)
+  // - Prescaler 16/17              (bits 22,23)
+  unsigned long reg = 0x438086;
   writePLL(reg);

   // Step 3, Conduct an R counter load.
-  reg = (2UL<<16) + ((fref/F_RASTER)<<2);
+  //
+  // Set reference counter latch     (bit 0,1):
+  // 7.2nS anti-backlash pulse width (bit 16,17)
+  // Devide ratio                    (bits 2 to 15)
+  reg  = 0x020000;
+  reg != ((fref/fraster) << 2) | 0x00fffa // Calculate devide ratio, mask those bits for safety
   writePLL(reg);

   // Step 4, Conduct an AB counter load.
-  setFreq(f);
+  setVCOFreq(f);

   // Step 5, conduct a function latch load with F1 bit cleared
+  //
+  // Set function latch (bits 0,1):
+  // - Normal R/A/B counters on reset (F1, bit 2)
+  // - Normal power                   (bit 3)
+  // - Three state muxout             (bit 4,5,6)
+  // - Positive Phase detection       (bit 7)
+  // - Three-state Charge pump        (bit 8)
+  // - High current Charge pump       (bits 15,16,17)
+  // - Prescaler 16/17                (bits 22,23)
   reg = 0x438082;
   writePLL(reg);
 }

+/*
+ * Sets the PLL A/B counters so that the PLL sets the output frequency
+ * of the VCO to the given frequency.
+ */
+void setVCOFreq(unsigned long freq) {
+  // At which raster slot is the given frequency
+  unsigned long channel = freq/fraster;

-void setFreq(long int f)
-{
-  long int reg, frast, A, B;
+  unsigned long B = (channel / 16) & 0x1fff; // Calculate the 13 bits in B
+  unsigned long A = (channel % 16) & 0x3f;   // Calculate the  7 bits in A
+
+  unsigned long reg 0x000001; // Load AB Counter Latch
+  reg != (B << 8); // Load B in bits 8-13
+  reg != (A << 2); // Load A in bits 2-7

-  frast = f/F_RASTER;
-  B = frast/16;
-  A = frast%16;
-
-  reg = ((B & 0x1fff)<<8) + ((A & 0x3f)<<2) + 1;
-
-    setPLL(reg);
-}
-
-
-void setFreq(long int f)
-{
-  long int reg, frast, A, B;
-
-  frast = f/F_RASTER;
-  B = frast/16;
-  A = frast%16;
-
-  reg = ((B & 0x1fff)<<8) + ((A & 0x3f)<<2) + 1;
-
-    setPLL(reg);
+  writePLL(reg);
 }

 /*


fix add ";"

fix add ";"

--- examples/UltrasonicDisplayOnTerm/UltrasonicDisplayOnTerm.ino
+++ examples/UltrasonicDisplayOnTerm/UltrasonicDisplayOnTerm.ino
@@ -54,7 +54,7 @@
 	RangeInInches = ultrasonic.MeasureInInches();
 	Serial.print(RangeInInches);//0~157 inches
 	Serial.println(" inch");
-	delay(250)
+	delay(250);

 	RangeInCentimeters = ultrasonic.MeasureInCentimeters(); // two measurements should keep an interval
 	Serial.print(RangeInCentimeters);//0~400cm


set contrast to 38 - this is screen specific, so i wont bother changing it again

--- examples/gps_time_sync_nokia5110/gps_time_sync_nokia5110.ino
+++ examples/gps_time_sync_nokia5110/gps_time_sync_nokia5110.ino
@@ -158,7 +158,7 @@
 	gps.setup(ttl);

 	nokia5110.begin();
-	nokia5110.setContrast(40);
+	nokia5110.setContrast(38);
 	nokia5110.setTextSize(1);
 	nokia5110.setTextColor(BLACK);

@@ -236,7 +236,7 @@
 	if (sync_gpstime)
 	{
 		// increment the internal time while wwvb is stopped (as it is syncing with gps)
-		addTimezone<uint8_t>(ss, mm, hh, DD, MM, YY, 0, 0, 1);
+		addTimezone<uint8_t>(ss, mm, hh, DD, MM, YY, 0, 0, 1);
 	}
 	else
 	{


renaming vars for ease of readability

renaming vars for ease of readability

--- plantstation.ino
+++ plantstation.ino
@@ -45,9 +45,9 @@
 //=====these i am still thinking about=========
 String appId = "Plant01";
 String location = "Dinning Room Window";
-boolean lightStatus = false;
+boolean lightIsOn = false;
 String waterLevelStatus = "OK";
-boolean waterPumpStatus = false;
+boolean waterPumpIsOn = false;

 void setup() {
   Serial.begin(9600);
@@ -64,8 +64,8 @@
 }

 void loop() {
-  getAirMeasurements();
-  getSoilMeasurements();
+  readAirMeasurements();
+  readSoilMeasurements();
   readLightResistor();
   readMoistureSensor();
   outputEvent();
@@ -89,7 +89,7 @@
   moistureSensor = analogRead(hygroPin);
 }

-void getAirMeasurements() {
+void readAirMeasurements() {
   am.humidityAir = myDHT.readHumidity();
   am.tempAirC = myDHT.readTemperature();
   am.tempAirF = myDHT.readTemperature(true);
@@ -101,7 +101,7 @@
   }
 }

-void getSoilMeasurements() {
+void readSoilMeasurements() {

   byte data[12];
   byte addr[8];
@@ -169,10 +169,10 @@
   my_output += waterLevelStatus;
   my_output += "\",\"Location\":\"";
   my_output += location;
-  my_output += "\",\"LightStatus\":";
-  my_output += lightStatus;
-  my_output += ",\"WaterPumptStatus\":";
-  my_output += waterPumpStatus;
+  my_output += "\",\"LightIsOn\":";
+  my_output += lightIsOn;
+  my_output += ",\"WaterPumptIsOn\":";
+  my_output += waterPumpIsOn;
   my_output += "}";

   myKeen.setApiVersion(F("3.0"));
@@ -215,17 +215,14 @@
   my_output += moistureSensor;
   my_output += ";WaterLevelStatus:";
   my_output += waterLevelStatus;
-  my_output += ";LightStatus:";
-  my_output += lightStatus;
+  my_output += ";LightIsOn:";
+  my_output += lightIsOn;
   my_output += ";Location:";
   my_output += location;
-  my_output += ";WaterPumptStatus:";
-  my_output += waterPumpStatus;
+  my_output += ";WaterPumptIsOn:";
+  my_output += waterPumpIsOn;

   Serial.println(my_output);
   Console.println(my_output);
 }

-// todo: add led and red led for status of whole thing!
-
-


Fixed buttons function

Fixed buttons function

--- Pad/pad/pad.ino
+++ Pad/pad/pad.ino
@@ -49,8 +49,9 @@
     button_read = digitalRead(Button[i]);
     if (button_read == LOW) {
       Serial.println("ok");
+      button_(i);
       delay(responseDelay);
-      button_(i);
+      Keyboard.releaseAll();
     }
   }
   // check buttons states for move the eyes
@@ -78,16 +79,17 @@

 void button_(byte i) {
   if (i == 0) // up
-    Keyboard.write('w');
+    //Keyboard.write('w');
+    Keyboard.press('w');
   if (i == 1) // down
-    Keyboard.write('s');
+    Keyboard.press('s');
   if (i == 2) // left
-    Keyboard.write('a');
+    Keyboard.press('a');
   if (i == 3) // right
-    Keyboard.write('d');
+    Keyboard.press('d');
   if (i == 4) // mouseLeft
     Mouse.click(MOUSE_LEFT);
   if (i == 5) // jumpButton
-    Keyboard.write(' ');
+    Keyboard.press(' ');
 }


almost final this time

almost final this time

--- turtleCode/arduino/final/LCD12864_test/LCD12864_test.ino
+++ turtleCode/arduino/final/LCD12864_test/LCD12864_test.ino
@@ -43,6 +43,7 @@

 #define mouth_open_pos    100
 #define mouth_closed_pos  30
+#define mouth_wait_pos    77

 MFRC522 mfrc522(SS_PIN, RST_PIN);	// Create MFRC522 instance
 MFRC522::MIFARE_Key key;
@@ -82,6 +83,10 @@
   }
 }

+void waitMouth(){ //open the mouth
+  mouthservo.write(mouth_wait_pos);
+}
+
 void closeMouth(){ //close the mouth
   delay(750);
   for(int i = mouthservo.read(); i > mouth_closed_pos; i--){
@@ -114,15 +119,15 @@
 }

 int getAnswer(int firstnumber, int operation , int secondnumber){
-  int answer;
+
   switch(operation){
-    case 10:
+    case 'D':
       answer = firstnumber + secondnumber;
       break;
-    case 11:
+    case 'E':
       answer = firstnumber - secondnumber;
       break;
-    case 12:
+    case 'F':
       answer = firstnumber * secondnumber;
       break;
   }
@@ -131,14 +136,19 @@

 void checkInput(int input, int answer){
   if (input == answer){
-    Serial.print("cor");
+    Serial.println("cor");
+
     closeMouth();
+    //displaySingle("h", "a", "p"); //show happy face (when implemented)
     delay(3000);
 //    openMouth();
     Serial.flush();
   }
   else{
-    Serial.print("w");
+    Serial.println("wro");
+    openMouth();
+    delay(2000);
+    waitMouth();
   }
 }

@@ -146,7 +156,6 @@
   char str[] = {a,b,c,NULL};
   Serial.write(str);
   if(strcmp(str,"anr")==0){
-    Serial.write("anr123123");
     LCDA.DrawFullScreen(angryFace);
   }
 }
@@ -214,7 +223,6 @@
      input = buffer[0];
    }

-   Serial.println(input);
    checkInput(input, answer);

@@ -240,9 +248,9 @@
         b2=Serial.read();
         b3=Serial.read();
         b4=Serial.read();
-      answer = getAnswer(b2-48, b3-48, b4-48);
-
-      openMouth();
+      answer = getAnswer(b2-48, b3, b4-48);
+
+      waitMouth();
       displayfuse(b2-48,b3-48,b4-48); //fuses the three numbers after the s to a math problem.

     }else{


Parameter

Parameter

Parameter angepasst, original speed

--- GoTender.ino
+++ GoTender.ino
@@ -105,7 +105,7 @@

 #define HEATER_ON_TIME_S      ( 30 )    // in seconds
-#define HEATER_OFF_TIME_S     ( 12*60 ) //
+#define HEATER_OFF_TIME_S     ( 10*60 ) //
 #define SMOKER_ON_TIME_S      ( 40 )    //
 #define SMOKER_OFF_TIME_S     ( 7*60 )  //

@@ -214,8 +214,7 @@
    TCCR3A = 0;
    TCCR3B = 0xc;     // CTC mode, prescaler = 256+ (clk/256 (From prescaler)

-   //OCR3A = 62500;    // 16 MHz / 256 = 62500 gives exactly one second (2 Output Compare Register)
-   OCR3A = 6250; //TBD
+   OCR3A = 62500;    // 16 MHz / 256 = 62500 gives exactly one second (2 Output Compare Regis
    TIMSK3 |= 0x02;   // Enable output compare match ints


Rebase

Rebase

--- BotCode/movement.ino
+++ BotCode/movement.ino
@@ -91,7 +91,7 @@
       left.write(leftForwardSpeed);
       right.write(rightForwardSpeed);
     }
-    // Check if robot has enetered a board square
+    // Check if robot has entered a board square
     if (event.magnetic.z < Z_threshold || event.magnetic.z < -400)
     {
       if (!crossing)


AD7173-8.ino fixed enable_adc_channel

AD7173-8.ino fixed enable_adc_channel

--- AD7173-8.ino
+++ AD7173-8.ino
@@ -246,7 +246,7 @@
     /* enable or disable this channel */
     value[0] |= (status << 7);
     /* set the correct analog inputs */
-    byte ain = ((channel & 0x0F) << 2);
+    byte ain = ((channel & 0x0F) << 1);
     value[1] = (ain << 5) | (ain + 1);
     /* update specified channel configuration */
     write_adc_register(channel, value, 2);
@@ -282,7 +282,7 @@
     byte if_mode_value[2];
     byte adc_mode_value[2];
     /* read current values */
-    read_adc_register(IFMODE_REG, value, 2);
+    read_adc_register(IFMODE_REG, if_mode_value, 2);
     read_adc_register(ADCMODE_REG, adc_mode_value, 2);

     /* when continuous read mode */


Remove auto-attach for stability

Remove auto-attach for stability

--- AutoChime/chime.ino
+++ AutoChime/chime.ino
@@ -9,7 +9,6 @@
 void Chime::SetPinNumber(char pin1, char pin2) {
   servo_pin_[(char)Serv::Big] = pin1;
   servo_pin_[(char)Serv::Small] = pin2;
-  AttachAll();
 }

 void Chime::SetChimeDirection(int pos1, int pos2, int pos3) {
@@ -57,6 +56,7 @@
     delay(230);
   }
   MoveServo(Serv::Small, hammer_dir_release_);
+  delay(300);
 }

 void Chime::PlayScore(int score_index, int before_delay_ms) {
@@ -65,7 +65,7 @@
     Serial.printf("Tone: %d, IsShort: %d\n", note.GetTone(), note.GetIsShort());
     Ring(note.GetTone(), note.GetIsShort(), false);
     if(note.GetIsShort()) {
-      delay(300);
+      delay(1);
     } else {
       delay(570);
     }


resolves character issue in source that prevented compiling

tactA_single sketch couldn't be compiled with Arduino IDE
due to the following exception: "error: stray '\302' in program"

--- tactA_single/tactA_single.ino
+++ tactA_single/tactA_single.ino
@@ -79,7 +79,7 @@

   // If signal data has been requested
   // by the client (i.e. Processing) ...
-  if (state == STATE_TRANSMIT_SPECTRUM || state == STATE_TRANSMIT_PEAK || state == STATE_TRANSMIT_BIAS || state == STATE_TRANSMIT_BIAS_PEAK ) {
+  if (state == STATE_TRANSMIT_SPECTRUM || state == STATE_TRANSMIT_PEAK || state == STATE_TRANSMIT_BIAS || state == STATE_TRANSMIT_BIAS_PEAK) {
     // Declare sensor value buffer
     int results[cmdBuffer[CMD_BUFFER_INDEX_COUNT]];
     // Declare peak and bias vars
@@ -199,5 +199,3 @@
     break;
   }
 }
-
-


Beter encoding routine.

Beter encoding routine.

--- Pianist/Pianist.ino
+++ Pianist/Pianist.ino
@@ -1,25 +1,28 @@
+#include <Encoder.h>
+
 //Arduino PWM Speed Contro
-short E1 = 5;
-short M1 = 4;
-short E2 = 6;
-short M2 = 7;
+#define E1 5
+#define M1 4
+#define E2 6
+#define M2 7

-short ST = 8;
+// Calibration sensor
+#define ST 8

-#include <PinChangeInt.h> // necessary otherwise we get undefined reference errors.
-#include <AdaEncoder.h>
+// Encoders
+#define ENC1 2
+#define ENC2 3

-int8_t clicks=0;
-long pos = 0;
-char id=0;
+#define EPSILON 10

 char buf [20];

 signed int motorSpeed = 0;
+long pos = 0;
+long oldPos = 0;

-#include <Encoder.h>

-Encoder encoder(10, 12);
+Encoder myEncoder(ENC1, ENC2);

 void setup()
 {
@@ -29,13 +32,12 @@
     pinMode(E1, OUTPUT);
     pinMode(E2, OUTPUT);
     pinMode(ST, INPUT);
-
-    AdaEncoder::addEncoder('a', 2, 3);
+    pinMode(ENC1, INPUT);
+    pinMode(ENC2, INPUT);
 }

 void loop()
 {
-  encoder *thisEncoder;
   Serial.println("Hallo Welt!.");
   delay(3000);
   Serial.println("Calibrating...");
@@ -43,38 +45,48 @@
   Calibrate();
   Serial.println("Done.");

-  thisEncoder=AdaEncoder::genie(&clicks, &id);
+  pos = 0;

-  int oldPos = 0;
   while(true)
   {
-    thisEncoder=AdaEncoder::genie(&clicks, &id);
-    if (thisEncoder != NULL) {
-      pos += clicks;
-      if (clicks != 0)
-      {
-        Serial.println(pos);
-      }
-    }
-  }
-
-    /*
-    int i = digitalRead(Enc1);
-    int j = digitalRead(Enc2);
-    sprintf(buf, "%d %d", i, j);
-    Serial.println(buf);
-    */
-
-   /*
-    int newPos = encoder.read();
-    if (newPos != oldPos)
-    {
-      Serial.println(newPos);
-      oldPos = newPos;
-    }
-    */
+    GoTo(1000);
+    delay(500);
+    pos = myEncoder.read();
+    Serial.println(pos);
+
+    GoTo(8000);
+    delay(500);
+    pos = myEncoder.read();
+    Serial.println(pos);
   }
 }
+
+void GoTo(long pos)
+{
+  long myPos;
+  do
+  {
+    myPos = myEncoder.read();
+    if (abs(myPos - pos) < EPSILON)
+    {
+      SetMotorSpeed(0);
+    }
+    else if (myPos < pos)
+    {
+      SetMotorSpeed(255);
+    }
+    else
+    {
+      SetMotorSpeed(-255);
+    }
+  }
+  while (abs(myPos - pos) > EPSILON);
+
+  SetMotorSpeed(0);
+  sprintf(buf, "%ld %ld", pos, myPos);
+  Serial.println(buf);
+}
+

 void Calibrate()
 {
@@ -96,10 +108,12 @@
   {
     ;
   }
-  encoder.write(0);
+  myEncoder.write(0);
   }
   SetMotorSpeed(0);
 }
+
+

 void SetMotorSpeed(signed int motorSpeed)


ajout qques commentaires + valeurs absolue lignes 329 et 355

--- calibrateur.ino
+++ calibrateur.ino
@@ -278,7 +278,9 @@
                     compteur=0;
                     for (i=0;i<NBRCYCLE_AR;i=i+1)
                     {
-                        Serial.print(F("iteration de mesure de ref="));
+                        //mesure milieu+delta, tempo, get_compteur
+						//milieu, tempo, raz_compteur
+						Serial.print(F("iteration de mesure de ref="));
                         leServo.setObjectif(leServo.getMilieu()+DELTA);
                         sleep(TEMPOSLEEP);
                         mesureRef[i]=compteur;
@@ -288,11 +290,13 @@
                         Serial.println(mesureRef[i]);
                     }
                     etatCalibrateur=FINDMINMAX;
+					//Affichage de ce resultat
                     compteurRef=moyenne(NBRCYCLE_AR,mesureRef);
                     Serial.print(F(" SUPERcmpteurRefMoyenne="));
                     Serial.print(compteurRef);
                     Serial.print(F(" (ecart type : "));
                     Serial.println(ecartType(NBRCYCLE_AR,mesureRef));
+					// 2 petites vérification ref <> 0 et ref pqs trop petit
                     if (compteurRef==0)
                         {
                             Serial.println(F("PB : compteur Ref=0 aucune impulsion fourche optique détecté"));
@@ -314,9 +318,21 @@
                     //les pwm Min et Max du servo
                     //----------------------------------------------------------
                     //find max
+					// Principe : on commande un DELTA déplacement, on laisse
+					//   compter et on regarde si le compteur est égal
+					//   à ref +/- une petite erreur autorisée
+					//   Si oui alors on recommence sinon on doit etre en butee
+
                     compteur=compteurRef;
-                    while (compteur>compteurRef-ERREURCOMPTAGE\
-                            && compteur<compteurRef+ERREURCOMPTAGE)
+					while (abs(compteur)>(abs(compteurRef)-ERREURCOMPTAGE)\
+                            && abs(compteur)<(abs(compteurRef)+ERREURCOMPTAGE))
+/*
+Correction integre par JSO le 29/9 mail Gilles
+-                    while (compteur>compteurRef-ERREURCOMPTAGE\
+-                            && compteur<compteurRef+ERREURCOMPTAGE)
++                    while (abs(compteur)>(abs(compteurRef)-ERREURCOMPTAGE)\
++                            && abs(compteur)<(abs(compteurRef)+ERREURCOMPTAGE))
+*/
                         {
                             Serial.print("M+.....");
                             compteur=0;
@@ -333,8 +349,15 @@
                     //----------------------------------------------------------
                     //find mmin
                     compteur=compteurRef;
-                    while (compteur>compteurRef-ERREURCOMPTAGE\
-                            && compteur<compteurRef+ERREURCOMPTAGE  )
+                    while (abs(compteur)>(abs(compteurRef)-ERREURCOMPTAGE)\
+                            && abs(compteur)<(abs(compteurRef)+ERREURCOMPTAGE)
+/*
+Correction integre par JSO le 29/9 mail Gilles
+-                    while (compteur>compteurRef-ERREURCOMPTAGE\
+-                            && compteur<compteurRef+ERREURCOMPTAGE  )
++                    while (abs(compteur)>(abs(compteurRef)-ERREURCOMPTAGE)\
++                            && abs(compteur)<(abs(compteurRef)+ERREURCOMPTAGE))
+*/
                         {
                             Serial.print(F("M-......"));
                             compteur=0;


Add token init

Add token init

--- examples/Basics/WidgetBridge/WidgetBridge.ino
+++ examples/Basics/WidgetBridge/WidgetBridge.ino
@@ -38,6 +38,11 @@
 void setup()
 {
   Blynk.begin(auth);
+
+  if (Blynk.connect()) {
+    bridge1.setAuthToken("OtherAuthToken");
+  }
+
   // Call blynkAnotherDevice periodically
   timer.setInterval(1000, blynkAnotherDevice);
 }


Setup idle every time

Setup idle every time

--- Cymatic-Triangles/Cymatic-Triangles.ino
+++ Cymatic-Triangles/Cymatic-Triangles.ino
@@ -55,6 +55,8 @@
 CHSV color(0, 255, 255);
 float leds_inner_mapping[NUM_LEDS]; // Represents LED strip
 float leds_outer_mapping[NUM_LEDS]; // Represents LED strip
+
+bool first_idle = true;

 //____________Function declarations______
 int get_freq_sum(int pin);
@@ -134,10 +136,16 @@
     next_animate_tick = current_time + ANIMATE_MILLIS_PER_TICK;

     if (!shouldIdle()) {
+      if (!first_idle) { first_idle = true; }
+
       animateTriangles(leds_inner_values, leds_inner_mapping);
       animateTriangles(leds_outer_values, leds_outer_mapping);
       animateMic();
     } else {
+      if (first_idle) {
+        first_idle = false;
+        setupIdleAnimation();
+      }
       animateIdle();
     }


alarm while sleep

alarm while sleep

--- vibrate_alarm_clock_2.ino
+++ vibrate_alarm_clock_2.ino
@@ -1,7 +1,7 @@
 #include <Wire.h>
 #include <MicroView.h>
-#include <DS3232RTC.h>    //http://github.com/JChristensen/DS3232RTC
-#include <Time.h>         //http://www.arduino.cc/playground/Code/Time
+#include <DS3232RTC.h>
+#include <Time.h>

 #include "LowPower.h"

@@ -16,6 +16,8 @@
 #define MOTOR_PIN2 3
 #define MOTOR_SLEEP_PIN 6

+#define ALARM_PIN INT0 //Driven LOW by Chronodot on alarm triggered
+
 #define ADC_PRECISION 1024

 #define MIN_BATTERY_MILLIVOLT 3200 //You may need to calibrate this
@@ -38,7 +40,7 @@
 typedef enum {
   NORMAL, ALARM, SETTING_TIME, SETTING_ALARM}
 CLOCK_STATE ;
-CLOCK_STATE currentState = NORMAL;
+volatile CLOCK_STATE currentState = NORMAL;

 typedef enum {
   T_HOUR, T_MINUTE}
@@ -90,6 +92,13 @@
   Serial.begin(9600);

   setSyncProvider(RTC.get);
+
+    //Clear prior alarm settings on reload
+  RTC.squareWave(SQWAVE_NONE);
+  RTC.alarmInterrupt(ALARM_1, false);
+  RTC.alarmInterrupt(ALARM_2, false);
+
+

   uView.begin();      // begin of MicroView
   uView.clear(ALL);   // erase hardware memory inside the OLED controller
@@ -118,11 +127,17 @@

   delay(INITIAL_TEXT_DELAY);
+
+  attachInterrupt(ALARM_PIN, alarmTriggered, FALLING);
+
+

 }

 void loop (){
+
+  setSyncProvider(RTC.get);

   int leftButtonState = digitalRead(LEFT_BUTTON_PIN);
   int middleButtonState = digitalRead(MIDDLE_BUTTON_PIN);
@@ -141,9 +156,6 @@
     processRightButtonPressed();
   }

-
-
-  checkAndSoundAlarm(hour(), minute());
   soundAlarmAtThisPointIfNeeded();

   //Disable alarm if it has gone longer than maximum
@@ -176,11 +188,11 @@
   }

-//  if(currentState == NORMAL){
-//    //Only sleep if not doing anything else
-//     LowPower.powerDown(SLEEP_15Ms, ADC_OFF, BOD_OFF);
-//
-//  }
+  if(currentState == NORMAL){
+    //Only sleep if not doing anything else
+     LowPower.powerDown(SLEEP_15Ms, ADC_OFF, BOD_OFF);
+
+  }

 }
@@ -297,6 +309,12 @@
         settingAlarmProcess = A_TYPE;
       }
       else {
+        if(vibrate){
+            RTC.setAlarm(ALM2_MATCH_HOURS, alarmMinute, alarmHour, 0);
+            RTC.alarmInterrupt(ALARM_2, true);
+        } else{
+            RTC.alarmInterrupt(ALARM_2, false);
+        }
         currentState = NORMAL;
       }

@@ -361,6 +379,7 @@
       else if(settingAlarmProcess == A_TYPE){
         vibrate = !vibrate;
       }
+
     }
     break;
   case SETTING_TIME:
@@ -389,20 +408,12 @@
 }

-
-void checkAndSoundAlarm(int hour, int minute){
-  unsigned long currentMillis = millis();
-
-
-  if(hour == alarmHour && minute == alarmMinute && currentState == NORMAL
-    && ((currentMillis - alarmLastStarted) > MIN_TIME_BETWEEN_ALARM_STARTS)
-    && (vibrate)){
+void alarmTriggered(){
+
+  if(currentState == NORMAL && currentState != ALARM){
     currentState = ALARM;
-    alarmLastStarted = currentMillis;
     motorDriverState(true);
-
-  }
-
+  }
 }

@@ -434,6 +445,7 @@

 void stopAlarm(){
+  RTC.alarm(ALARM_2);
   currentState = NORMAL;
   motorDriverState(false);
   turnOffLCDIfCommandIsOff();


Basic robotic movements are working.

Basic robotic movements are working.

--- Project/demo_just_get_it_working/demo_just_get_it_working.ino
+++ Project/demo_just_get_it_working/demo_just_get_it_working.ino
@@ -20,10 +20,10 @@

 void setup()
 {
-  servo[1].attach( 9 );
-  servo[2].attach( 6 );
-  servo[3].attach( 5 );
-  servo[4].attach( 3 );
+  servo[0].attach( 9 );
+  servo[1].attach( 6 );
+  servo[2].attach( 5 );
+  servo[3].attach( 3 );

   int n;
   for ( n=0; n<4; n++ )
@@ -32,6 +32,8 @@
   }

   Serial.begin(9600);
+
+  pinMode(13, OUTPUT);
 }


minor change

minor change

--- crossbow.ino
+++ crossbow.ino
@@ -270,6 +270,8 @@
 void loop(void)
 {

+    uint32_t currentMillis = millis();
+
     /*
      * Detect the moment when radio module stopped transmittig and put it
      * back in to receive state
@@ -297,7 +299,6 @@
         radioState.bytesToRead = NO_DATA_TO_READ;
     }

-    uint32_t currentMillis = millis();
     bool transmitPayload = false;

     /*


Delete K_Nearest_Neighbors_Template.ino

Delete K_Nearest_Neighbors_Template.ino

--- K_Nearest_Neighbors_Template/K_Nearest_Neighbors_Template.ino
+++ K_Nearest_Neighbors_Template/K_Nearest_Neighbors_Template.ino
@@ -1,218 +0,0 @@
-#include <Arduino.h>
-#include <math.h>
-// FIXME: Add the libraries needed for each pin
-
-#include "Object.h"
-
-// FIXME: Can change pin number
-#define IR_SENSOR_PIN_1 6
-
-// Define Pins for each sensor
-// Distance Sensor (Height)
-
-int test = 0;
-bool wait = false;
-
-// Define anything else needed for sensors
-
-// K Nearest Neighbors
-// FIXME: Change when necessary
-const int K = [number];
-
-// FIXME: Change when necessary
-const size_t NUM_OF_KNOWN_OBJECTS = [number];
-const size_t NUM_OF_OBJECT_TYPES = [number];
-
-// FIXME: Change object types
-String Known_Object_Types[NUM_OF_OBJECT_TYPES] = {[object types]};
-
-Object knownObjects[NUM_OF_KNOWN_OBJECTS];
-
-// Define max height/weight/etc.
-// FIXME: For each feature
-const int [feature]_MIN = [number];
-const int [feature]_MAX = [number];
-
-// Takes the features from the current object and converts them to strings and integers
-// **
-void ObjectFeatureExtraction(Object &currObject) {
-  // Define necessary variables for height/weight/etc.
-
-  // Read features from sensors (ex: sonar.ping_cm())
-
-  // Assign each of those features to currObject.
-}
-
-float RescaleValue(float value, const float min, const float max) {
-  return (value-min)/(max-min);
-}
-
-// Rescale object features to 1-0 range
-void RescaleObject(Object *object) {
-  // FIXME: For each feature
-  object->[feature] = RescaleValue(object->[feature], [feature]_MIN, [feature]_MAX);
-}
-
-//  Computes the euclidean distance between the known and the current object's rgb values
-// FIXME: Remove if there are no colors
-float ComputeDistanceofColors(Object currObject, Object knownObject) {
-  float red = currObject.r - knownObject.r;
-  float green = currObject.g - knownObject.g;
-  float blue = currObject.b - knownObject.b;
-  float dist = pow(red, 2) + pow(green, 2) + pow(blue, 2);
-  dist = roundf(dist* 100.0) / 100.0;
-  return dist;
-}
-
-// Computes the euclidean distance between the known and the current object's features
-float ComputeDistanceofObjects(Object currObject, Object knownObject) {
-  // FIXME: For each feature
-  float [feature]_dist = (currObject.[feature] - knownObject.[feature]);
-  // FIXME: Remove if there are no colors
-  float color_dist = ComputeDistanceofColors(currObject, knownObject);
-  // FIXME: For each feature, remove color_dist if there are no colors
-  float dist = [feature]_dist*[feature]_dist + color_dist*color_dist;
-
-  return dist;
-}
-
-// Finds the patterns from the current object and compares them to patterns from the given objects
-// **
-String ObjectPatternRecognition(Object currObject, Object knownObjects[]) {
-  int count = 0;
-  int max_count = 0;
-  String most_frequent_type;
-
-  Object kNearestObjects[K];
-
-  // First K known objects are the closest K, obviously, so just fill array
-  for(int i = 0; i < K; ++i) {
-    kNearestObjects[i].type = knownObjects[i].type;
-    // FIXME: For each feature
-    kNearestObjects[i].[feature] = knownObjects[i].[feature];
-  }
-
-  // Now, determine if each remaining object is among the K closest, and if so insert into array (thus dropping one obj)
-  for(int i = K; i < NUM_OF_KNOWN_OBJECTS; ++i) { // For each remaining known object
-    int j;
-
-    // Find the current max difference in the K nearest objects
-    float max_diff_of_K_nearest = 0;
-    int max_index = 0;
-    float temp_dist = 0;
-
-    for(j = 0; j < K; ++j) {
-      // kNearest Objects is the difference between the currObject and the knownObjects
-      // ComputeDistanceofObjects should compute the total distance for kNearestObjects[j]
-      // May just add this to the above
-      temp_dist = ComputeDistanceofObjects(currObject, kNearestObjects[j]);
-
-      if(temp_dist > max_diff_of_K_nearest) { // Update max
-        max_diff_of_K_nearest = temp_dist;
-        max_index = j;
-      }
-    }
-
-    // If the current known object's difference < the max difference in the current K nearest neighbors
-    temp_dist = ComputeDistanceofObjects(currObject, knownObjects[i]);
-
-    if(temp_dist < max_diff_of_K_nearest) {
-      // Replace the existing neighbor having max_diff_of_K_nearest, by the current known object, in the K nearest neighbors array
-      kNearestObjects[max_index].type = knownObjects[i].type;
-      // FIXME: For each feature
-      kNearestObjects[max_index].[feature] = knownObjects[i].[feature];
-    }
-  }
-
-  // For testing purposes
-  for(int i = 0; i < K; ++i) {
-    Serial.println(kNearestObjects[i].type);
-    // FIXME: For each feature
-    Serial.println(kNearestObjects[i].[feature]);
-  }
-
-  // Find out which object type occurs most frequently
-  for(int i = 0; i < NUM_OF_OBJECT_TYPES; ++i) {
-    int j;
-    count = 0;
-    for(j = 0; j < K; ++j) {
-      if(kNearestObjects[j].type == Object_Types[i]) {
-        count++;
-      }
-    }
-    if(count > max_count) {
-      max_count = count;
-      most_frequent_type = Object_Types[i];
-    }
-  }
-
-  return most_frequent_type;
-}
-
-// Prints the type of object that is being passed through the project
-// **
-void Actuation(String object) {
-  if(object != "") {
-    Serial.print("\t");
-    Serial.println(object);
-  }
-}
-
-void PopulateKnownObjects() {
-  // Change values and measure
-  // FIXME: For each feature
-  // FIXME: Add as many known objects as needed
-  knownObjects[0].type = "[Object type]";
-  knownObjects[0].[feature] = [feature value];
-}
-
-
-void setup() {
-  Serial.begin(9600);
-
-  PopulateKnownObjects();
-
-  pinMode(IR_SENSOR_PIN_1, INPUT);
-  digitalWrite(IR_SENSOR_PIN_1, HIGH);
-
-  // Setup any features that need it
-}
-
-void loop() {
-  bool IR_Sensor1;
-  String closestObject;
-
-  IR_Sensor1 = digitalRead(IR_SENSOR_PIN_1);
-
-  // Sensor was tripped and wasn't right before.
-  if(IR_Sensor1 == LOW && !wait) {
-    // FIXME: Can change what the object is (ex: Box, Fruit, etc.)
-    Serial.println("[Object] Detected");
-
-    delay(1000);
-
-    digitalWrite(LED_BUILTIN, HIGH);
-
-    Object currObject;
-
-    ObjectFeatureExtraction(currObject);
-
-    closestObject = ObjectPatternRecognition(currObject, knownObjects);
-
-    Actuation(closestObject);
-
-    wait = true;
-
-    delay(1000);
-  }
-  // Sensor was tripped and was right before.
-  else if(IR_Sensor1 == LOW && wait) {
-    digitalWrite(LED_BUILTIN, LOW);
-  }
-  // Sensor was not tripped.
-  else if(IR_Sensor1 == HIGH){
-    digitalWrite(LED_BUILTIN, LOW);
-    wait = false;
-  }
-
-}


Fix compiler errors

Fix compiler errors

--- ESP8266/alarm-monitor/alarm-monitor.ino
+++ ESP8266/alarm-monitor/alarm-monitor.ino
@@ -31,7 +31,7 @@
 #define WLAN_SSID       "YOUR_SSID" //change to your Wifi SSID
 #define WLAN_PASS       "YOUR_WIFI_PASSWORD" //change to your Wifi Password
 #define SERVER_PORT     80
-#define MDNS_NAME       "alarm-monitor";
+#define MDNS_NAME       "alarm-monitor"

 MDNSResponder mdns;
 ESP8266WebServer server(SERVER_PORT);
@@ -61,7 +61,7 @@
   DEBUG_OUTPUT.print("  Connecting to WiFi...");
   connectToNetwork();
   if (mdns.begin(MDNS_NAME, WiFi.localIP())) {
-    DEBUG_OUTPUT.println("    MDNS responder started. [" + MDNS_NAME + "]");
+    DEBUG_OUTPUT.println("    MDNS responder started. [" + String(MDNS_NAME) + "]");
     mdns.addService("http", "tcp", SERVER_PORT);
   }


Header, comment changes.

Header, comment changes.

--- Arduino/victoria_teensy_circuit_test_ros_node/victoria_teensy_circuit_test_ros_node.ino
+++ Arduino/victoria_teensy_circuit_test_ros_node/victoria_teensy_circuit_test_ros_node.ino
@@ -1,3 +1,22 @@
+/*
+ * Victoria Teensy Circuit Test ROS Node
+ *
+ * This code is a ROS node that executes all of the components
+ * on the Teensy circuit or the Victoria RoboMagellan team. It
+ * publishes the various data on ROS publishers to be used as
+ * a debugging tool. This code does not drive or control the robot,
+ * it just reports on the states of the various components as the
+ * robot is operated remotele.
+ *
+ * It uses the rosserial library to communicate with ROS. It uses
+ * Arduino and Teensy libraries to interact with systems and
+ * circuits connected to the Teensy processor. This code assumes
+ * that a Teensy 3.5 is used.
+ *
+ * https://github.com/victoriarobotics
+ *
+ */
+
 // Teensy includes
 #define ENCODER_OPTIMIZE_INTERRUPTS
 #include <Encoder.h>
@@ -122,4 +141,6 @@

   // Send all the ROS messages
   ros_nh.spinOnce();
+
+  // TODO: control the rate that messages are published?
 }