Examples: rename outputToneWithSteppedAmplitude to outputTone

--- examples/02-Utility/OutputToneWithSteppedAmplitude/OutputToneWithSteppedAmplitude.ino
+++ examples/02-Utility/OutputToneWithSteppedAmplitude/OutputToneWithSteppedAmplitude.ino
@@ -1,100 +0,0 @@
-/*
-  Output Tone With Stepped Amplitude
-
-  Chip Audette, OpenAudio 2018
-
-  Plays a single tone followed by silence.  Repeats the tone+silence at increasing amplitude.
-  The last tone should definitely distort.  The 2nd-to-last tone should be on the edge of distorting.
-  WARNING: DO NOT LISTEN TO THIS WITH HEADPHONES ON
-
-  MIT License, Use at your own risk.
-*/
-
-#include <Tympan_Library.h>
-
-//set the sample rate and block size
-const float sample_rate_Hz = 44100.0f ; //24000 or 44117 (or other frequencies in the table in AudioOutputI2S_F32)
-const int audio_block_samples = 128;     //do not make bigger than AUDIO_BLOCK_SAMPLES from AudioStream.h (which is 128)
-AudioSettings_F32 audio_settings(sample_rate_Hz, audio_block_samples);
-
-
-// Create the audio library objects that we'll use
-Tympan                    myTympan(TympanRev::E, audio_settings);   //use TympanRev::D or TympanRev::E
-AudioSynthWaveform_F32    sineWave(audio_settings);   //from the Tympan_Library
-AudioOutputI2S_F32        audioOutput(audio_settings);//from the Tympan_Library
-
-// Create the audio connections from the sineWave object to the audio output object
-AudioConnection_F32 patchCord10(sineWave, 0, audioOutput, 0);  //connect to left output
-AudioConnection_F32 patchCord11(sineWave, 0, audioOutput, 1);  //connect to right output
-
-
-// Define the parameters of the tone
-float tone_freq_Hz = 1000.0;   //frequency of the tone
-#define N_AMP (8)              //How many different amplitudes to test
-float tone_amp[N_AMP] = {0.1, 0.2, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2};     //here are the amplitudes (1.0 is digital full scale) to test
-float tone_dur_msec = 1000.0;  // Length of time for the tone, milliseconds
-int amp_index = N_AMP-1;       //a counter to use when stepping through the given amplitudes
-
-// define setup()...this is run once when the hardware starts up
-void setup(void)
-{
-  //Open serial link for debugging
-  myTympan.beginBothSerial(); delay(1000); //both Serial (USB) and Serial1 (BT) are started here
-  myTympan.println("OutputTone: starting setup()...");
-
-  //allocate the audio memory
-  AudioMemory_F32(20,audio_settings); //I can only seem to allocate 400 blocks
-
-  //set the sine wave parameters
-  sineWave.frequency(tone_freq_Hz);
-  sineWave.amplitude(0.0);
-  myTympan.setAmberLED(LOW);
-
-  //start the audio hardware
-  myTympan.enable();
-
-  //Set the baseline volume levels
-  myTympan.volume_dB(0);                   // headphone amplifier.  -63.6 to +24 dB in 0.5dB steps.
-
-  myTympan.println("Setup complete.");
-}
-
-// define loop()...this is run over-and-over while the device is powered
-#define START_SILENCE 0
-#define PLAY_SILENCE 1
-#define START_TONE 2
-#define PLAY_TONE 3
-int state = START_SILENCE;
-unsigned long start_time_millis = 0;
-float silence_dur_msec = 1000.f;
-int iteration_count = 0;
-void loop(void)
-{
-  switch (state) {
-    case START_SILENCE:
-      sineWave.amplitude(0.0f);
-      start_time_millis = millis();
-      myTympan.setAmberLED(LOW);
-      state = PLAY_SILENCE;
-      break;
-    case PLAY_SILENCE:
-      if ((millis() - start_time_millis) >= silence_dur_msec) {
-        state = START_TONE;
-      }
-      break;
-    case START_TONE:
-      amp_index++; if (amp_index == N_AMP) { amp_index = 0; iteration_count++;}
-      sineWave.amplitude(tone_amp[amp_index]);
-      myTympan.print("Changing to start tone, amplitude = ");myTympan.println(tone_amp[amp_index]);
-      myTympan.setAmberLED(HIGH);
-      start_time_millis = millis();
-      state = PLAY_TONE;
-      break;
-    case PLAY_TONE:
-      if ((millis() - start_time_millis) >= tone_dur_msec) {
-        state = START_SILENCE;
-        myTympan.println("Changing to start silence...");
-      }
-      break;
-  }
-}


Removed changelog since it never was synchronized to GIT very well anyway.

Anyone who'd like to know what changed should read the GIT commits for now. Eventually a real changelog should be written.

--- GEVCU.ino
+++ GEVCU.ino
@@ -32,32 +32,8 @@
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

  */
-
-
-
-
-/*
-Changelog (Update with very brief message along with build # - Dates wouldn't hurt either
-Sept 9 2013:
-1000 - First build # enabled build - Comment out hard coded line for # of throttles
-1001 - Proper fix for issue corrected by build 1000
-1002 - Show build # on startup and in menu
-1003 - Implementation of RC precharging mode for motor controller
-Sept 12 2013:
-1004 - Change some variables in brake to 32 bit
-1005 - bug fix in in ichip routines
-Sept 19 2013:
-1006 - Added ability to configure debugging output - switched DeviceManager to not create null objects
-1007 - Allow the DMOC to start up ready to go. It now must be explicitly disabled via the second digital input
-1008 - Implement (initial support) reverse limit, switch brake to using indep. min value, get existing values settable with serial console
-1009 - Implemented message passing and hooked up the rest of the code to use it.
-1010 - Support for GEVCU3 boards
-1011 - Added support for Think City battery packs with BMS
-1012 - Tons of changes to MotorController and SerialConsole
-1013 - New release in master - Addition of Wifi configuration pages, throttle changes
-1014 - Brand new system in place that allows devices to be configured based on EEPROM instead of compiler defines.
-*/
-
+
+/*Changelog removed. All changes are logged to GIT */

 /*
 Random comments on things that should be coded up soon:


use return

use return

--- _25-attiny85-nrf24-ds18b20/_25-attiny85-nrf24-ds18b20.ino
+++ _25-attiny85-nrf24-ds18b20/_25-attiny85-nrf24-ds18b20.ino
@@ -60,7 +60,7 @@
   sensors.begin();
   if (!sensors.getAddress(outsideThermometer, 0)) {
     sleep();
-    abort();
+    return();
   }
   // ds18b20 getTem 766ms
   // 12bit - 750ms, 11bit - 375ms, 10bit - 187ms, 9bit - 93.75ms
@@ -69,7 +69,7 @@
   // radio begin to power down : 80 ms
   radio.begin();
   //radio.enableDynamicPayloads();
-  // default is on
+  // setAutoAck default is on
   //radio.setAutoAck(1);
   radio.setRetries(15, 15);
   radio.setPALevel(RF24_PA_LOW);
@@ -94,7 +94,7 @@

   if (isnan(tempCoutside) || tempCoutside < -50 || tempCoutside > 50 ) {
     sleep();
-    abort();
+    return();
   }

   payload.temp = tempCoutside * 10 ;
@@ -102,24 +102,21 @@

   if ( payload.volt > 5000 || payload.volt <= 0 ) {
     sleep();
-    abort();
+    return();
   }

   if ( payload.humi < 0 ) {
     sleep();
-    abort();
+    return();
   }

   radio.powerUp();
   radio.write(&payload , sizeof(payload));
-  yield();
-  //delay(100);
   radio.powerDown();
   unsigned long stopmilis = millis();

   payload.humi = ( stopmilis - startmilis ) * 10 ;
-  //payload._salt++;
   sleep();
 }


Make some of the init statements debug prints

--- Event_Printer/Event_Printer.ino
+++ Event_Printer/Event_Printer.ino
@@ -140,12 +140,12 @@
 void setup_CAN_Bus_Filters()
 {
   while (CAN_OK != CAN.begin(CAN_500KBPS)) {
-    Serial.println("Failed to initialize CAN");
-    Serial.println("Retrying..");
+    DEBUG_PRINT_LN("Failed to initialize CAN");
+    DEBUG_PRINT_LN("Retrying..");
     delay(100);
   }

-  Serial.println("Starting to initialize CAN");
+  DEBUG_PRINT_LN("Starting to initialize CAN");

   // Set filter masks
   CAN.init_Mask(0, 0, 0xfff);


Edit SD Server example to use the new Write(Stream) method

--- hardware/esp8266com/esp8266/libraries/ESP8266WebServer/examples/SDWebServer/SDWebServer.ino
+++ hardware/esp8266com/esp8266/libraries/ESP8266WebServer/examples/SDWebServer/SDWebServer.ino
@@ -111,23 +111,10 @@
     dataType = 0;
     path = 0;

-    uint8_t obuf[WWW_BUF_SIZE];
+    if(client.write(dataFile) != dataFile.size()){
+      DBG_OUTPUT_PORT.println("Sent less data than expected!");
+    }

-    while (dataFile.available() > WWW_BUF_SIZE){
-      dataFile.read(obuf, WWW_BUF_SIZE);
-      if(client.write(obuf, WWW_BUF_SIZE) != WWW_BUF_SIZE){
-        DBG_OUTPUT_PORT.println("Sent less data than expected!");
-        dataFile.close();
-        return true;
-      }
-    }
-    uint16_t leftLen = dataFile.available();
-    dataFile.read(obuf, leftLen);
-    if(client.write(obuf, leftLen) != leftLen){
-      DBG_OUTPUT_PORT.println("Sent less data than expected!");
-      dataFile.close();
-      return true;
-    }
     dataFile.close();
     client.stop();
     return true;


Fix 2 minor errors

Fix 2 minor errors


Comentarios

Comentarios

--- arduino/Alarma/Alarma.ino
+++ arduino/Alarma/Alarma.ino
@@ -82,6 +82,11 @@
   // wait for a second
 }

+//Prende o apaga las luces
+//Recibe como parámetro el número de pin al que está conectada la luz
+//Si el número es positivo prende la luz y si es negativo la apaga
+//Como no se pueden recibir números negativos se le resta 256 para
+//obtener el número de pin.
 void switchLights(int light) {
   if ((light >= 2 && light <= 7) || (light >= 248 && light <= 254)) {
     //Serial.println(light);


v3.0 Add date to displays

v3.0 Add date to displays

--- WeatherDisplay.ino
+++ WeatherDisplay.ino
@@ -182,9 +182,10 @@
   String windSpeed = root["list"]["wind"]["speed"];
   String windDirection = root["list"]["wind"]["deg"];

-  int riseI;
-  int setI;
-  timeS = convertGMTTimeToLocal(timeS, latitude, longitude, &riseI, &setI);
+  int riseI, setI, monthI, dayI, yearI;
+  timeS = convertGMTTimeToLocal(timeS, latitude, longitude,
+                                &riseI, &setI, &monthI, &dayI, &yearI);
+  String dateS = String(monthI) + '/' + String(dayI) + '/' + String(yearI);

   int length = temperature.length();
   if (length == 5)
@@ -239,15 +240,17 @@
                  timeS,
                  riseI,
                  setI,
-                 idString.toInt());
+                 idString.toInt(),
+                 dateS);
   }
   else {
     printMainData(humidity,
                   temperature,
                   timeS,
-                  idString.toInt());
-  }
-}
+                  idString.toInt(),
+                  dateS);
+  }
+} // void getWeatherData()

 void printAuxData(String location,
                   String temperature,
@@ -258,10 +261,12 @@
                   String time,
                   int rise,
                   int set,
-                  int weatherID)
+                  int weatherID,
+                  String dateS)
 {
   static long lastRandomNumber;
   long randomColor;
+  long newRandomColor;
   unsigned int textColor[] = {
     BLUE,
     RED,
@@ -279,60 +284,57 @@
     randomColor = random(0, 7);
   }
   lastRandomNumber = randomColor;
+  if (randomColor == 0) {
+    newRandomColor = 1;
+  }
+  else if (randomColor == 6) {
+    newRandomColor = 5;
+  }
+  else {
+    newRandomColor = randomColor + 1;
+  }
   tft.setTextColor(textColor[randomColor]);
   tft.setTextSize(1);
   tft.setCursor(0, 0);
   tft.print("Location: ");
   tft.println(location);
-  tft.println("");
   tft.print("Temperature: ");
   tft.print(temperature.toInt());
   tft.println(" F");
-  tft.println("");
   tft.print("Humidity: ");
   tft.print(humidity.toInt());
   tft.println("% RH");
-  if (randomColor == 0) {
-    tft.setTextColor(textColor[1]);
-  }
-  else if (randomColor == 6) {
-    tft.setTextColor(textColor[5]);
-  }
-  else {
-    tft.setTextColor(textColor[randomColor + 1]);
-  }
   tft.print("Weather ID ");
   tft.println(weatherID);
   tft.setTextColor(textColor[randomColor]);
   tft.print("Sky: ");
   tft.println(description);
-  tft.println("");
   tft.print("Wind Spd: ");
   tft.print(windSpeed.toInt());
   tft.println(" Knots");
-  tft.println("");
   tft.print("Wind Dir: ");
   tft.print(windDirection.toInt());
   tft.println(" Degs");
-  tft.println("");
+  tft.setTextColor(textColor[newRandomColor]);
   tft.print("Time: ");
   tft.println(time);
-  tft.println("");
+  tft.print("Date: ");
+  tft.println(dateS);
+  tft.setTextColor(textColor[randomColor]);
   tft.print("Sunrise: ");
   tft.print(rise);
   tft.println(":00am");
-  tft.println("");
   tft.print("Sunset: ");
   tft.print(set);
   tft.println(":00pm");
-  tft.println("");
   tft.println((night) ? "It is Night time" : "It is Day time");
 }

 void printMainData(String humidityString,
                    String temperature,
                    String time,
-                   int weatherID)
+                   int weatherID,
+                   String dateS)
 {
   tft.setTextColor(WHITE);
   tft.setTextSize(1);
@@ -353,6 +355,9 @@
   tft.setCursor(27, 132);
   tft.print(humidityString);
   tft.print("% RH");
+  tft.setTextSize(1);
+  tft.setCursor(40, 150);
+  tft.print(dateS);
 }

 void printWeatherIcon(int id)
@@ -424,7 +429,8 @@
   }
 }

-String convertGMTTimeToLocal(String timeS, String latitude, String longitude, int* riseI, int* setI)
+String convertGMTTimeToLocal(String timeS, String latitude, String longitude,
+                             int* riseI, int* setI, int* monthI, int* dayI, int* yearI)
 {
   double rise, set;

@@ -435,6 +441,10 @@
   int month = monthS.toInt();
   String dayS = timeS.substring(8, 10);
   int day = dayS.toInt();
+  *monthI = month;
+  *dayI = day;
+  *yearI = year;
+
   timeS = timeS.substring(length - 8, length - 6); // Strip out the hours
   int time = timeS.toInt();


v4.0 Add minor enhancements

v4.0 Add minor enhancements

--- WeatherDisplay.ino
+++ WeatherDisplay.ino
@@ -267,7 +267,7 @@
 {
   static long lastRandomNumber;
   long randomColor;
-  long newRandomColor;
+  long anotherRandomColor;
   unsigned int textColor[] = {
     BLUE,
     RED,
@@ -286,13 +286,13 @@
   }
   lastRandomNumber = randomColor;
   if (randomColor == 0) {
-    newRandomColor = 1;
+    anotherRandomColor = 1;
   }
   else if (randomColor == 6) {
-    newRandomColor = 5;
+    anotherRandomColor = 5;
   }
   else {
-    newRandomColor = randomColor + 1;
+    anotherRandomColor = randomColor + 1;
   }
   tft.setTextColor(textColor[randomColor]);
   tft.setTextSize(1);
@@ -307,8 +307,8 @@
   tft.println("% RH");
   tft.print("Weather ID ");
   tft.println(weatherID);
-  tft.setTextColor(textColor[randomColor]);
   tft.print("Sky: ");
+  if ((sizeof("Sky: ") + description.length()) >= 21 /*Length of line*/) description.replace(' ', '\n');
   tft.println(description);
   tft.print("Wind Spd: ");
   tft.print(windSpeed.toInt());
@@ -316,8 +316,8 @@
   tft.print("Wind Dir: ");
   tft.print(windDirection.toInt());
   tft.println(" Degs");
-  tft.setTextColor(textColor[newRandomColor]);
-  tft.print("Time: ");
+  tft.setTextColor(textColor[anotherRandomColor]);
+  tft.print("Time LU: ");
   tft.println(time);
   tft.print("UTC: ");
   tft.println(timeUTC);
@@ -339,10 +339,11 @@
                    int weatherID,
                    String dateS)
 {
+  tft.setTextColor(YELLOW);
+  tft.setTextSize(1);
+  tft.setCursor(17, 5);
+  tft.print("Updated " + time);
   tft.setTextColor(WHITE);
-  tft.setTextSize(1);
-  tft.setCursor(40, 5);
-  tft.print(time);
   tft.setTextSize(2);
   tft.setCursor(27, 20);
   tft.print(temperature);
@@ -358,6 +359,7 @@
   tft.setCursor(27, 132);
   tft.print(humidityString);
   tft.print("% RH");
+  tft.setTextColor(YELLOW);
   tft.setTextSize(1);
   tft.setCursor(40, 150);
   tft.print(dateS);


Update Razor_AHRS.ino

Update Razor_AHRS.ino

--- sandbox/Razor_AHRS/Razor_AHRS.ino
+++ sandbox/Razor_AHRS/Razor_AHRS.ino
@@ -1,53 +1,11 @@
 /***************************************************************************************************************
-* Razor AHRS Firmware v1.4.2
+* Razor AHRS Firmware
 * 9 Degree of Measurement Attitude and Heading Reference System
 * for Sparkfun "9DOF Razor IMU" (SEN-10125 and SEN-10736)
-* and "9DOF Sensor Stick" (SEN-10183, 10321 and SEN-10724)
 *
-* Released under GNU GPL (General Public License) v3.0
-* Copyright (C) 2013 Peter Bartz [http://ptrbrtz.net]
-* Copyright (C) 2011-2012 Quality & Usability Lab, Deutsche Telekom Laboratories, TU Berlin
+* Copyright (C) 2013 GNU GPL (General Public License) v3.0 - Peter Bartz [http://ptrbrtz.net]
+* Copyright (C) 2011-2012 GNU GPL (General Public License) v3.0 -  Quality & Usability Lab, Deutsche Telekom Laboratories, TU Berlin
 *
-* Infos, updates, bug reports, contributions and feedback:
-*     https://github.com/ptrbrtz/razor-9dof-ahrs
-*
-*
-* History:
-*   * Original code (http://code.google.com/p/sf9domahrs/) by Doug Weibel and Jose Julio,
-*     based on ArduIMU v1.5 by Jordi Munoz and William Premerlani, Jose Julio and Doug Weibel. Thank you!
-*
-*   * Updated code (http://groups.google.com/group/sf_9dof_ahrs_update) by David Malik (david.zsolt.malik@gmail.com)
-*     for new Sparkfun 9DOF Razor hardware (SEN-10125).
-*
-*   * Updated and extended by Peter Bartz (peter-bartz@gmx.de):
-*     * v1.3.0
-*       * Cleaned up, streamlined and restructured most of the code to make it more comprehensible.
-*       * Added sensor calibration (improves precision and responsiveness a lot!).
-*       * Added binary yaw/pitch/roll output.
-*       * Added basic serial command interface to set output modes/calibrate sensors/synch stream/etc.
-*       * Added support to synch automatically when using Rovering Networks Bluetooth modules (and compatible).
-*       * Wrote new easier to use test program (using Processing).
-*       * Added support for new version of "9DOF Razor IMU": SEN-10736.
-*       --> The output of this code is not compatible with the older versions!
-*       --> A Processing sketch to test the tracker is available.
-*     * v1.3.1
-*       * Initializing rotation matrix based on start-up sensor readings -> orientation OK right away.
-*       * Adjusted gyro low-pass filter and output rate settings.
-*     * v1.3.2
-*       * Adapted code to work with new Arduino 1.0 (and older versions still).
-*     * v1.3.3
-*       * Improved synching.
-*     * v1.4.0
-*       * Added support for SparkFun "9DOF Sensor Stick" (versions SEN-10183, SEN-10321 and SEN-10724).
-*     * v1.4.1
-*       * Added output modes to read raw and/or calibrated sensor data in text or binary format.
-*       * Added static magnetometer soft iron distortion compensation
-*     * v1.4.2
-*       * (No core firmware changes)
-*
-* TODOs:
-*   * Allow optional use of EEPROM for storing and reading calibration values.
-*   * Use self-test and temperature-compensation features of the sensors.
 ***************************************************************************************************************/

 /*
@@ -61,15 +19,6 @@
   ITG-3200 : Gyro

   Arduino IDE : Select board "Arduino Pro or Pro Mini (3.3v, 8Mhz) w/ATmega328"
-*/
-
-/*
-  "9DOF Sensor Stick" hardware versions: SEN-10183, SEN-10321 and SEN-10724
-
-  ADXL345  : Accelerometer
-  HMC5843  : Magnetometer on SEN-10183 and SEN-10321
-  HMC5883L : Magnetometer on SEN-10724
-  ITG-3200 : Gyro
 */

 /*
@@ -119,6 +68,12 @@
                 One frame consist of three 3x3 float values = 36 bytes. Order is: acc x/y/z, mag x/y/z, gyr x/y/z.
       "#osbb" - Output BOTH raw and calibrated SENSOR data of all 9 axes in BINARY format.
                 One frame consist of 2x36 = 72 bytes - like #osrb and #oscb combined (first RAW, then CALIBRATED).
+
+      // Angle output and sensor data output
+      "#oat" - Output CALIBRATED SENSOR data of accelerometer and gyros in TEXT format.
+               One frame consist of three lines - one for RPY, accel, gyro
+      "#oab" - Output CALIBRATED SENSOR data of accelerometer and gyros in BINARY format.
+               One frame consist of two 3x3 float values and one RPY 3x4 (24 bytes + 12 bytes = bytes long)

       // Error message output
       "#oe0" - Disable ERROR message output.
@@ -302,6 +257,7 @@
 // Stuff
 #define STATUS_LED_PIN 13  // Pin number of status LED
 #define GRAVITY 256.0f // "1G reference" used for DCM filter and accelerometer calibration
+#define GRAVITY_MS_REF(x) ((x) * 9.7951 / 256) // convert from raw accelerometer value using local ATL gravity and an assumed 256 value for 1g reading
 #define TO_RAD(x) (x * 0.01745329252)  // *pi/180
 #define TO_DEG(x) (x * 57.2957795131)  // *180/pi

@@ -634,7 +590,7 @@
       Drift_correction();
       Euler_angles();

-      if (output_stream_on || output_single_on) output_sensor_angles();
+      if (output_stream_on || output_single_on) output_sensors_and_angles();
     }
     else  // Output sensor values
     {


Corrected typos in SerialSequenceUploader sketch.

--- Software/BasicController/ArduinoSketch/SerialSequenceUploader/SerialSequenceUploader.ino
+++ Software/BasicController/ArduinoSketch/SerialSequenceUploader/SerialSequenceUploader.ino
@@ -25,6 +25,7 @@
  *  V - Return version string.
  *  W BXXXXXX - Turn on array BXXXXXX directly.  No sequencing or triggering.
  *  X - All off and reset to trigger-enabled setting.
+ *  Y - Return device ID ('NicoLaseSequencer')
  *  ? X - Query state of device X.  Supported devices : S = shutter open (0 = closed, 1 = open)
  *
  *
@@ -35,7 +36,7 @@
 */

 // Version variables
-const String version = 1.2;
+const String version = "1.2";

 // Serial variables
 String inputString = "";         // a string to hold incoming data
@@ -431,7 +432,7 @@
             Serial.println(seqArray[arraySize], BIN);

             if (shutterState) {
-              Q
+
               PORTC = seqArray[0];
             }

@@ -637,7 +638,12 @@
         PORTC = 0x00;
         attachInterrupt(digitalPinToInterrupt(triggerPin), ToggleLED,  CHANGE);

-        break;
+        break;
+
+	   case ('Y') :
+		// Return device ID
+		Serial.println("NicoLaseSequencer");
+		break;

       case ('?') :
@@ -651,10 +657,10 @@

           // Return current shutter state
             if (shutterState){
-              Serial.println('1');
+              Serial.println("1");
             }
             else {
-              Serial.println('0');
+              Serial.println("0");
             }

             break;
@@ -662,6 +668,12 @@
         }

         break;
+
+	  default :
+	  // Command not recognized. Return error character 0x15.
+	      Serial.println(15, HEX);
+
+		break;


Update comments

Update comments

--- moros/moros.ino
+++ moros/moros.ino
@@ -126,10 +126,11 @@
     screen->tft->text(text, 0, 20);
     if(text[i] != p->display_time[i]) {

-      // draw a rect
+      // erase this character cell
       screen->tft->stroke(0,0,0);
       screen->tft->rect(CHAR_WIDTH_PX * i , 20, CHAR_WIDTH_PX, CHAR_HEIGHT_PX);
-      //p->tft->background(0,0,0);
+
+      // print the new character
       char next_char[2] = {text[i], '\0' };
       screen->tft->stroke(255,255,255);
       screen->tft->text(next_char, CHAR_WIDTH_PX * i, 20);


cleaned up bmc.ino

cleaned up bmc.ino

--- Arduino/sketches/TGimbal/BMC.ino
+++ Arduino/sketches/TGimbal/BMC.ino
@@ -1,10 +1,4 @@
-//#include "definitions.h"
-
-/*
-
-
-
-https://sites.google.com/site/qeewiki/books/avr-guide/timers-on-the-atmega328
+/*https://sites.google.com/site/qeewiki/books/avr-guide/timers-on-the-atmega328

 // CS BITS
 CS02	CS01    CS00 	 DESCRIPTION
@@ -86,7 +80,8 @@

 */
-#define N_SIN 256
+#include "defines.h"
+
 #define CC_FACTOR 32
 #define PWM_A_MOTOR1 OCR2A
 #define PWM_B_MOTOR1 OCR1B


add SLEEP_DELAY for serial output

add SLEEP_DELAY for serial output

--- examples/SchedulerWithOtherTaskPriority/SchedulerWithOtherTaskPriority.ino
+++ examples/SchedulerWithOtherTaskPriority/SchedulerWithOtherTaskPriority.ino
@@ -1,3 +1,4 @@
+#define SLEEP_DELAY 100
 #include <DeepSleepScheduler.h>

 void setup() {


Morse beacon: generate morse code.

Morse beacon: generate morse code.

--- microcontrollers/arduino-esp32/lora32-morse-beacon/lora32-morse-beacon.ino
+++ microcontrollers/arduino-esp32/lora32-morse-beacon/lora32-morse-beacon.ino
@@ -20,12 +20,18 @@
 //
 #define FREQ_HZ 433575000   // 433.575 MHz

-unsigned int counter = 0;
-
 //
 // On Lora32 module, OLED reset signal is connected to gpio16.
 //
 Adafruit_SSD1306 display(16);
+
+//
+// Timing for 10 words per minute.
+//
+int dot_msec   = 120;
+int dash_msec  = 360;
+int pause_msec = 360;
+int space_seen;

 void setup()
 {
@@ -37,7 +43,8 @@
     while (!Serial)
         ;
     Serial.println();
-    Serial.println("LoRa Sender Test");
+    delay(1000);
+    Serial.println("LoRa Morse Beacon v1.0, by Serge Vakulenko KK6ABQ");

     // Initialize LoRa chip.
     SPI.begin(SCK, MISO, MOSI, SS);
@@ -47,13 +54,7 @@
         while (1)
             ;
     }
-    //LoRa.setSignalBandwidth(7800);
-    //LoRa.setSignalBandwidth(10400);
-    //LoRa.setSignalBandwidth(15600);
-    //LoRa.setSignalBandwidth(20800);
-    //LoRa.setSignalBandwidth(31250);
     LoRa.setSignalBandwidth(41700);
-    //LoRa.setSignalBandwidth(62500);
     LoRa.setCodingRate4(5);
     LoRa.setSpreadingFactor(6);
     LoRa.disableCrc();
@@ -69,14 +70,12 @@
     display.setTextSize(1);
     display.setTextColor(WHITE);
     display.setCursor(0, 20);
-    display.print("Init...");

     // Visualize the result.
     display.display();
-    delay(1500);
-}
-
-void send(int msec)
+}
+
+void beep(int msec)
 {
     // Compute preamble length of required duration.
     // To measure the timing, use plen = msec.
@@ -94,24 +93,117 @@
     digitalWrite(LED, LOW);
 }

+void send_morse(char *sym, char *str)
+{
+    display.print(sym);
+    display.display();
+    Serial.print(sym);
+
+    if (*str++ == '.')
+        beep(dot_msec);
+    else
+        beep(dash_msec);
+
+    while (*str) {
+        delay(dot_msec);
+
+        if (*str++ == '.')
+            beep(dot_msec);
+        else
+            beep(dash_msec);
+    }
+}
+
+void send_char(int c)
+{
+    if (isspace(c) || ! isprint(c))
+        c = ' ';
+    else if (isalpha(c) && islower(c))
+        c = toupper(c);
+
+    switch (c) {
+    default:
+        return;
+    case ' ' :
+        if (! space_seen) {
+            display.print(" ");
+            display.display();
+            Serial.write(c);
+            delay(dot_msec + pause_msec);
+        }
+        space_seen = 1;
+        return;
+
+    case 'A': send_morse("A", ".-");     break;
+    case 'B': send_morse("B", "-...");   break;
+    case 'C': send_morse("C", "-.-.");   break;
+    case 'D': send_morse("D", "-..");    break;
+    case 'E': send_morse("E", ".");      break;
+    case 'F': send_morse("F", "..-.");   break;
+    case 'G': send_morse("G", "--.");    break;
+    case 'H': send_morse("H", "....");   break;
+    case 'I': send_morse("I", "..");     break;
+    case 'J': send_morse("J", ".---");   break;
+    case 'K': send_morse("K", "-.-");    break;
+    case 'L': send_morse("L", ".-..");   break;
+    case 'M': send_morse("M", "--");     break;
+    case 'N': send_morse("N", "-.");     break;
+    case 'O': send_morse("O", "---");    break;
+    case 'P': send_morse("P", ".--.");   break;
+    case 'Q': send_morse("Q", "--.-");   break;
+    case 'R': send_morse("R", ".-.");    break;
+    case 'S': send_morse("S", "...");    break;
+    case 'T': send_morse("T", "-");      break;
+    case 'U': send_morse("U", "..-");    break;
+    case 'V': send_morse("V", "...-");   break;
+    case 'W': send_morse("W", ".--");    break;
+    case 'X': send_morse("X", "-..-");   break;
+    case 'Y': send_morse("Y", "-.--");   break;
+    case 'Z': send_morse("Z", "--..");   break;
+    case '0': send_morse("0", "-----");  break;
+    case '1': send_morse("1", ".----");  break;
+    case '2': send_morse("2", "..---");  break;
+    case '3': send_morse("3", "...--");  break;
+    case '4': send_morse("4", "....-");  break;
+    case '5': send_morse("5", ".....");  break;
+    case '6': send_morse("6", "-....");  break;
+    case '7': send_morse("7", "--...");  break;
+    case '8': send_morse("8", "---..");  break;
+    case '9': send_morse("9", "----.");  break;
+    case '.': send_morse(".", ".-.-.-"); break;
+    case ',': send_morse(",", "--..--"); break;
+    case '?': send_morse("?", "..--.."); break;
+    case '/': send_morse("/", "-..-.");  break;
+    case '=': send_morse("=", "-...-");  break;
+    }
+    space_seen = 0;
+}
+
+void send_message(const char *str)
+{
+    while (*str) {
+        send_char(*str++);
+        delay(pause_msec);
+    }
+    // TODO: fix scrooling
+    display.print("=\n");
+    display.display();
+    Serial.println(" =");
+    delay(dot_msec + pause_msec);
+    send_morse("", "-...-");
+    delay(dot_msec + pause_msec);
+}
+
 void loop()
 {
-    counter++;
-    display.clearDisplay();
-    display.setCursor(0, 20);
-    display.print("Send ");
-    display.print(counter);
-
-    display.setCursor(0, 42);
-    display.print(LoRa.getSignalBandwidth());
-    display.display();
-
+    send_message("KK6ABQ/B");
+#if 0
     // Measure timing.
     unsigned long t0, t1, t2, t3, t4, t5, t6, t7;
-    t0 = micros(); send(300); t1 = micros(); delay(300);
-    t2 = micros(); send(100); t3 = micros(); delay(300);
-    t4 = micros(); send(100); t5 = micros(); delay(300);
+    t0 = micros(); send(300); t1 = micros(); delay(100);
+    t2 = micros(); send(100); t3 = micros(); delay(100);
+    t4 = micros(); send(100); t5 = micros(); delay(100);
     t6 = micros(); send(300); t7 = micros(); delay(900);
-
-    Serial.printf("%u: %u %u %u %u %u %u %u %u\r\n", counter, t0, t1, t2, t3, t4, t5, t6, t7);
-}
+    Serial.printf("%u %u %u %u %u %u %u %u\r\n", t0, t1, t2, t3, t4, t5, t6, t7);
+#endif
+}


use default interface I2C

use default interface I2C

--- examples/Accelerometer_Compass/Accelerometer_Compass.ino
+++ examples/Accelerometer_Compass/Accelerometer_Compass.ino
@@ -72,8 +72,8 @@
 	char rtn = 0;
     Serial.begin(9600);  // Serial is used for debugging
     Serial.println("\r\npower on");
-    //rtn = Lsm303d.initI2C();
-    rtn = Lsm303d.initSPI(SPI_CS);
+    rtn = Lsm303d.initI2C();
+    //rtn = Lsm303d.initSPI(SPI_CS);
     if(rtn != 0)  // Initialize the LSM303, using a SCALE full-scale range
 	{
 		Serial.println("\r\nLSM303D is not found");
@@ -121,4 +121,4 @@
 	Serial.println(" of the positive x-axis in the horizontal plane: ");
 	Serial.print(titleHeading, 3);  // see how awesome tilt compensation is?!
 	Serial.println(" degrees");
-}+}


Update Kochen.ino

Update Kochen.ino

Textausgaben optimiert, Konsolenausgaben entfernt

--- Kochen.ino
+++ Kochen.ino
@@ -16,7 +16,7 @@
       kochzeit = 1;

     clrScr(false,false);
-    lcd.print("Kochzeit",0,16);
+    lcd.print("Kochzeit:",0,16);
     lcd.invertText(true);
     lcd.printNumI(int(kochzeit),15,24);
     lcd.invertText(false);
@@ -95,7 +95,6 @@
 }

 void enterDoKochen() {
-  Serial.println("Kochen");
   first = true;
   fsmKochProzess.immediateTransitionTo(stateReachKochTemp);
 }
@@ -142,10 +141,7 @@
     long sec = (rest/1000) % 60;

     clrScr(false,false);
-    String s = "Kochen:";
-    char buf[14];
-    s.toCharArray(buf,14);
-    lcd.print(buf, CENTER, 16);
+    lcd.print("Kochen:", CENTER, 16);

     s = "noch ";
     if(kochzeit > 60){


Update writing for arduino code

Update writing for arduino code

--- cirkit_unit03_driver/arduino/steer_ctrl/steer_ctrl.ino
+++ cirkit_unit03_driver/arduino/steer_ctrl/steer_ctrl.ino
@@ -34,13 +34,15 @@
 /* Define pulse width time of the stepping motor. */
 #define PULSE_WIDTH_MICRO_SECOND 500

-enum {
+enum
+{
   LEFT,
   RIGHT,
   KEEP
 };

-enum {
+enum
+{
   cw_plus = 3,
   cw_minus,
   ccw_plus,
@@ -57,9 +59,11 @@
 ros::NodeHandle nh; // The nodeHandle.
 ros::Subscriber<geometry_msgs::Twist> sub("steer_ctrl", &steerCb); // Set subscribe the motor_driver topic.

-void setup() {
+void setup()
+{
   /* Set pins Mode. */
-  for (int i = cw_plus; i < ccw_minus + 1; i++) { // 3: CW+, 4: CW-, 5: CCW+, 6:CCW-
+  for (int i = cw_plus; i < ccw_minus + 1; i++)
+  { // 3: CW+, 4: CW-, 5: CCW+, 6:CCW-
     pinMode(i, OUTPUT);
     digitalWrite(i, LOW); // Default pin status is LOW.
   }
@@ -68,7 +72,8 @@
   nh.subscribe(sub); // Start subscribe the "steer_ctrl" topic.
 }

-void loop() {
+void loop()
+{
   nh.spinOnce(); // Check topic and if change it, run the call back function.
 }

@@ -79,7 +84,8 @@
  * @author "Yusuke Doi"
  * @param msg This param is msg object of the motor_driver topic.
  */
-void steerCb(const geometry_msgs::Twist& msg) {
+void steerCb(const geometry_msgs::Twist& msg)
+{
   int time = msg.angular.x * 10;
   if (msg.angular.z < 0 && time > 50) gen_pluse(LEFT, time); // Minus mean CCW or right.
   else if (msg.angular.z > 0 && time > 50) gen_pluse(RIGHT, time); // Plus mean CW or left.
@@ -92,8 +98,10 @@
  * @author "Yusuke Doi"
  * @param direction Steer to direction.
  */
-void gen_pluse(const char direction, double time) {
-  switch (direction) {
+void gen_pluse(const char direction, double time)
+{
+  switch (direction)
+  {
   case LEFT: // Task steer left.
     noTone(cw_plus); // Unset tone. If don't running tone, not happen.
     tone(ccw_plus, PULSE_FREQUENCY, time); // Write pulse to CCW pin. turn to CW.


Writing characters to USB as HID device. Removed display output.

--- nanowriter.ino
+++ nanowriter.ino
@@ -1,12 +1,7 @@
-#include <Adafruit_GFX.h>
-#include <Adafruit_SSD1306.h>
-
-#define OLED_RESET 4
-
-Adafruit_SSD1306 display(OLED_RESET);
+#include <Keyboard.h>

 char layer_a[] = {
-   ' ', //B00000
+   0, //B00000
    'u', //B00001
    's', //B00010
    'g', //B00011
@@ -45,28 +40,31 @@
   DDRB = B00000000;
   PORTB |= B11111111;

-  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
-  display.clearDisplay();
-  display.display();
-
+  Keyboard.begin();
 }

 int readButtons() {
   return (~(PINB >> 2)) & B00011111;
 }

-String decodeInput(int input) {
-  return String(layer_a[input]);
+char decodeInput(int input) {
+  return layer_a[input];
 }

+char prevCharacter = 0;
+
 void loop() {
-  String character = decodeInput(readButtons());
-  display.clearDisplay();
-  display.setTextColor(WHITE);
-  display.setCursor(0,0);
-  display.setTextSize(3);
-  display.print(character);
-  display.display();
+  char firstRead = readButtons();
+  delay(25);
+  char secondRead = readButtons();
+  if (firstRead == secondRead) {
+    char character = decodeInput(firstRead);
+    if (character != prevCharacter) {
+      prevCharacter = character;
+      if (character != 0) {
+        Keyboard.write(character);
+      }
+    }
+  }
 }
-


set_retain

--- _03-hx711-scale/_03-hx711-scale-v3-adaptor/_03-hx711-scale-esp-12/_03-hx711-scale-esp-12.ino
+++ _03-hx711-scale/_03-hx711-scale-v3-adaptor/_03-hx711-scale-esp-12/_03-hx711-scale-esp-12.ino
@@ -41,7 +41,7 @@

 boolean reconnect() {
   if  ( client.connect(MQTT::Connect((char*) clientName.c_str()).set_clean_session().set_keepalive(120))) {
-    client.publish(hellotopic, "hello again from ESP8266 s06");
+    client.publish(hellotopic, "hello again 1 from ESP8266 s06");
   }
   return client.connected();
 }
@@ -151,7 +151,7 @@
           payload += ave.stddev();
           payload += "}";

-          sendHx711toMqtt(payload, topicAverage);
+          sendHx711toMqtt(payload, topicAverage, 1);
         } else {
           if ( nofchecked > 3 )
           {
@@ -159,7 +159,7 @@
             payload += ( measured - measured_empty );
             payload += "}";

-            sendHx711toMqtt(payload, topicEvery);
+            sendHx711toMqtt(payload, topicEvery, 0);
           }
         }
       }
@@ -175,10 +175,10 @@
           payload = "{\"WeightPoop\":";
           payload += ( int(ave.mean()) - measured_empty );
           payload += ",\"NemoWeight\":0}";
-          sendHx711toMqtt(payload, topicEvery);
+          sendHx711toMqtt(payload, topicEvery, 0);

           payload = "{\"WeightAvg\":0}";
-          sendHx711toMqtt(payload, topicAverage);
+          sendHx711toMqtt(payload, topicAverage, 0);

           AvgMeasuredIsSent = LOW;
         } else {
@@ -192,7 +192,7 @@
           payload += WiFi.RSSI();
           payload += "}";

-          sendHx711toMqtt(payload, topicEvery);
+          sendHx711toMqtt(payload, topicEvery, 0);
         }
         nofnotinuse = 0;
       }
@@ -243,34 +243,38 @@
   r = !r;
 }

-void sendHx711toMqtt(String payload, char* topic)
-{
-  if (WiFi.status() == WL_CONNECTED) {
-    if (!client.connected()) {
-      if ( client.connect(MQTT::Connect((char*) clientName.c_str()).set_clean_session().set_keepalive(120))) {
-        client.publish(hellotopic, "hello again from ESP8266 s06");
-      }
-    }
-
-    if (client.connected()) {
-      Serial.print("Sending payload: ");
-      Serial.println(payload);
-
-      if (client.publish(MQTT::Publish(topic, (char*) payload.c_str()).set_retain())) {
+void sendHx711toMqtt(String payload, char* topic, int retain)
+{
+  if (!client.connected()) {
+    if ( client.connect(MQTT::Connect((char*) clientName.c_str()).set_clean_session().set_keepalive(120))) {
+      client.publish(hellotopic, "hello again 2 from ESP8266 s06");
+    }
+  }
+
+  if (client.connected()) {
+    Serial.print("Sending payload: ");
+    Serial.println(payload);
+
+    if ( retain == 1 ) {
+      if ( client.publish(MQTT::Publish(topic, (char*) payload.c_str()).set_retain()) ) {
+        if ( topic == "esp8266/arduino/s06" ) { AvgMeasuredIsSent = HIGH; }
         Serial.println("Publish ok");
-        if ( topic == "esp8266/arduino/s06" ) {
-          AvgMeasuredIsSent = HIGH;
-        }
-      }
-      else {
+      } else {
         Serial.println("Publish failed");
-        ESP.restart();
-      }
-    }
-  } else {
-    Serial.println("Could not connect to WIFI");
-    ESP.restart();
-  }
+        abort();
+      }
+    } else {
+      if ( client.publish(MQTT::Publish(topic, (char*) payload.c_str()) ) {
+        if ( topic == "esp8266/arduino/s06" ) { AvgMeasuredIsSent = HIGH; }
+        Serial.println("Publish ok");
+      } else {
+        Serial.println("Publish failed");
+        abort();
+      }
+    }
+
+  }
+
 }


Added extra WiFiManger settings

Added extra WiFiManger settings

--- Arduino/McLighting/McLighting.ino
+++ Arduino/McLighting/McLighting.ino
@@ -319,6 +319,10 @@
   #endif

   WiFi.setSleepMode(WIFI_NONE_SLEEP);
+
+  // Uncomment if you want to restart ESP8266 if it cannot connect to WiFi.
+  // Value in brackets is in seconds that WiFiManger waits until restart
+  //wifiManager.setConfigPortalTimeout(180);

   // Uncomment if you want to set static IP
   // Order is: IP, Gateway and Subnet
@@ -331,8 +335,8 @@
   if (!wifiManager.autoConnect(HOSTNAME)) {
     DBG_OUTPUT_PORT.println("failed to connect and hit timeout");
     //reset and try again, or maybe put it to deep sleep
-    ESP.reset();
-    delay(1000);
+    ESP.reset();  //Will be removed when upgrading to standalone offline McLightingUI version
+    delay(1000);  //Will be removed when upgrading to standalone offline McLightingUI version
   }

   #if defined(ENABLE_MQTT) or defined(ENABLE_AMQTT)


cc_per_S improved

cc_per_S improved

--- Arduino/_firmware3/_firmware3.ino
+++ Arduino/_firmware3/_firmware3.ino
@@ -44,15 +44,15 @@
   return result;
 }

-float smoothing_Vin(const int* numb_readings, float* total_sum,
-                float* array_item){
-
-  *total_sum -= *array_item;
-  *array_item = emon1.readVcc()*0.001;
-  *total_sum += *array_item;
-  float result = *total_sum / *numb_readings;
-  return result;
-}
+// float smoothing_Vin(const int* numb_readings, float* total_sum,
+//                 float* array_item){
+
+//   *total_sum -= *array_item;
+//   *array_item = emon1.readVcc()*0.001;
+//   *total_sum += *array_item;
+//   float result = *total_sum / *numb_readings;
+//   return result;
+// }

 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //                                            0. NODE ID
@@ -156,7 +156,7 @@

 boolean solenoid_valve_open = false;
 float flow_rate_cc_per_sec = 0.0;
-float water_level_buffer=1; //The water level buffer is how much the water level should increase before calculating a new flow rate
+float water_level_buffer=1.0; //The water level buffer is how much the water level should increase before calculating a new flow rate

 void solenoid_drain_valve(){
    //Start the drain if the water level is too high
@@ -176,10 +176,20 @@
      //Serial.println(water_level_delta);
     // Serial.println(time_delta/1000);
      flow_rate_cc_per_sec = ( water_level_delta ) / (time_delta/1000.0);
+     flow_rate_cc_per_sec *= vesicle_area_cm_2;

      //set the last calculation references
      flow_calc_water_level_cm = water_level_cm;
      calc_time_ms = millis();
+    }
+    else if (600000.0 <= (millis() - calc_time_ms) && water_level_cm >= flow_calc_water_level_cm){
+      float water_level_delta = water_level_cm - flow_calc_water_level_cm;
+      float time_delta = millis() - calc_time_ms;
+      flow_rate_cc_per_sec = ( water_level_delta ) / (time_delta/1000.0);
+      flow_rate_cc_per_sec *= vesicle_area_cm_2;
+      //set the last calculation references
+      flow_calc_water_level_cm = water_level_cm;
+      calc_time_ms = millis();
     }
    }

@@ -456,7 +466,8 @@

 float load1_v_out = 0.0;
 float load2_v_out = 0.0;
-float res_1 = 50350.0; // Measure the value of R1 in voltage divider circuit.
+float res1_1 = 50400.0; // Measure the value of R1 in voltage divider circuit.
+float res2_1 = 50700.0;
 float res_2 = 0.0;

 float load_cap = 10000000.0;
@@ -471,21 +482,22 @@
                             &load1_array[analog_index], &load1_pin);
   load2_average = smoothing(&number_of_readings, &load2_total,
                             &load2_array[analog_index], &load2_pin);
-  v_in = smoothing_Vin(&number_of_readings, &v_in_total, &v_in_array[analog_index]);
+  // v_in = smoothing_Vin(&number_of_readings, &v_in_total, &v_in_array[analog_index]);
   //////////////////// For debugging
   // Serial.println(analogRead(load1_pin));
   // Serial.println(analogRead(load2_pin));
   // Serial.println(load2_average);
   // Serial.println(load2_average);
   //Serial.println(v_in);
+  //Serial.println(emon1.readVcc());

   //Convert analog signal to voltage
   load1_v_out = load1_average / 1023 * v_in;
   load2_v_out = load2_average / 1023 * v_in;

   //Calculate the resistance value of the film sensor
-  load1_res2 = res_1 / (v_in / load1_v_out - 1.0);
-  load2_res2 = res_1 / (v_in / load2_v_out - 1.0);
+  load1_res2 = res1_1 / (v_in / load1_v_out - 1.0);
+  load2_res2 = res2_1 / (v_in / load2_v_out - 1.0);

   //If value is higher than the cap, it sets to the cap value, because the value can reach INF
   if(load1_res2 > load_cap){
@@ -532,7 +544,7 @@
   pinMode(TestPin,OUTPUT);
   digitalWrite(TestPin, HIGH);

-  //Initialize the fuild level, load film & position samples arrays
+  //Initialize the fuild level, load film & positi[on samples arrays
   for (int i = 0; i<number_of_readings; i++){
     fluidLevel_array[i] = 0;
     position1_array[i] = 0;
@@ -582,12 +594,12 @@
   position_sensors();
   fluid_level_sensor();
   film_sensor();
-
+  solenoid_drain_valve();
   analog_index++;
   if (analog_index == number_of_readings) analog_index = 0;
   ////////////////////////////////////////////////////////////////

-  solenoid_drain_valve();
+
   tachometer_sensor();
   flow_rate_sensor();

@@ -600,6 +612,7 @@
     //shaft_temp();
     one_wire_temps();
     Irms = emon1.calcIrms(1480);  // Calculate Irms only
+    if (Irms < 2) Irms = 0;//Until library is fixed

     data = "D";
@@ -619,6 +632,7 @@
    * 10.flowrate
    * 11. posistion1_mm
    * 12. position2_mm
+   * 13. Irms
    * */
     receive_FFT();
     Serial.println(data);


change sensor , moisture

change sensor , moisture

--- Arduino/nfc_flower/nfc_flower.ino
+++ Arduino/nfc_flower/nfc_flower.ino
@@ -1,17 +1,14 @@
-#include <dht11.h>
-#include <EEPROM.h>
-
-dht11 DHT11;
-#define DHT11PIN 12 //define DHT11 pin
-#define RELAY 2    //define relay pin
 /* Copyright 2013 Ten Wong, wangtengoo7@gmail.com
 *
 */
-
-/*********************************************************
-** sample: when reset the rf430, it will write the uri to
-** rf430 tag.
-***********************************************************/
+//#include <dht11.h>
+#include <EEPROM.h>
+
+//dht11 DHT11;
+//#define DHT11PIN 12 //define DHT11 pin
+//#define RELAY 2    //define relay pin
+
+
 #if ARDUINO >= 100
  #include "Arduino.h"
 #else
@@ -23,11 +20,11 @@
 #include <NdefRecord.h>

-//#define IRQ   (7)
-//#define RESET (6)
+#define IRQ   (7)
+#define RESET (6)
 //use UNO
-#define IRQ   (3)
-#define RESET (4)
+//#define IRQ   (3)
+//#define RESET (4)
 int led = 13;
 RF430CL330H_Shield nfc(IRQ, RESET);

@@ -55,8 +52,8 @@
     Serial.println("Hello!");
     pinMode(led, OUTPUT);
     digitalWrite(led, HIGH);
-    pinMode(RELAY,OUTPUT);
-    digitalWrite(RELAY,LOW);
+//    pinMode(RELAY,OUTPUT);
+//    digitalWrite(RELAY,LOW);
     nfc.begin();
     if(EEPROM.read(address+2)!=1)
     {
@@ -67,13 +64,13 @@
     /// init data here
     Restore_Default();//write sensor data to DNFC TAG
     //Serial.println(EEPROM.read(address));
-   // Serial.println(EEPROM.read(address+1));
+    //Serial.println(EEPROM.read(address+1));
     //enable interrupt 1
-    attachInterrupt(1, RF430_Interrupt, FALLING);
+    attachInterrupt(IRQ, RF430_Interrupt, FALLING);
     Serial.println("Wait for read or write...");
-    Serial.println("DHT11 TEST PROGRAM ");
-    Serial.print("LIBRARY VERSION: ");
-    Serial.println(DHT11LIB_VERSION);
+    //Serial.println("DHT11 TEST PROGRAM ");
+    //Serial.print("LIBRARY VERSION: ");
+    //Serial.println(DHT11LIB_VERSION);
 }

 void loop(void)
@@ -122,15 +119,15 @@
         nfc.Write_Register(CONTROL_REG, INT_ENABLE + INTO_DRIVE + RF_ENABLE);

         //re-enable INTO
-        attachInterrupt(1, RF430_Interrupt, FALLING);
+        attachInterrupt(IRQ, RF430_Interrupt, FALLING);
     }
 //
-    if (DHT11.humidity < EEPROM.read(address)) //auto control relay watering
-    {
-      digitalWrite(RELAY,HIGH);
-      delay(2000);
-      digitalWrite(RELAY,LOW);
-    }
+    //if (DHT11.humidity < EEPROM.read(address)) //auto control relay watering
+    //{
+    //  digitalWrite(RELAY,HIGH);
+    //  delay(2000);
+    //  digitalWrite(RELAY,LOW);
+    //}
     if (loop_num == 50) //5s refresh tag
     {
         Restore_Default();
@@ -149,7 +146,7 @@
 void RF430_Interrupt()
 {
     into_fired = 1;
-    detachInterrupt(1);//cancel interrupt
+    detachInterrupt(IRQ);//cancel interrupt
 }

 boolean ByteArrayCompare(byte a[], byte b[], uint8_t array_size)
@@ -162,15 +159,18 @@

 void Restore_Default()
 {
-    int chk = DHT11.read(DHT11PIN);
-    NdefRecord records[4];
+    //int chk = DHT11.read(DHT11PIN);
+    NdefRecord records[5];
     /** here get data from sensor **/
     //get sensor data
     byte exData0[] = {60}; //humidity 60%  form sensor
     byte exData1[] = {24}; //temperature 24 C  form sensor
     byte exData2[] = {50}; //humidity 50%  warm line 50%
-    exData0[0] = DHT11.humidity;
-    exData1[0] = DHT11.temperature;
+    //exData0[0] = DHT11.humidity;
+    //exData1[0] = DHT11.temperature;
+    long a = analogRead(A2);
+    long b = (a*100)/900;
+    exData0[0] = b;
     Serial.println(exData0[0]);
     Serial.println(exData1[0]);
     //Serial.println( DHT11.temperature);
@@ -178,6 +178,7 @@
     records[1].createExternal("flower", "humidity", exData0, sizeof(exData0));
     records[2].createExternal("flower", "temperature", exData1, sizeof(exData1));
     records[3].createExternal("flower", "setting", exData2, sizeof(exData2));
+    records[4].createApplicationRecord("com.flower.nfcaction");

     NdefMessage msg(records, sizeof(records)/sizeof(NdefRecord));
     uint16_t msg_length = msg.getByteArrayLength();
@@ -203,9 +204,9 @@
             {
                 Serial.println("water");
                 //deal with relay
-               digitalWrite(RELAY,HIGH);
-               delay(2000);
-               digitalWrite(RELAY,LOW);
+               //digitalWrite(RELAY,HIGH);
+               //delay(2000);
+               //digitalWrite(RELAY,LOW);
             }
             //do water flower operate
         }


don't use debounce in the buttonAndLed sketch

--- examples/02.IO/ButtonAndLed/ButtonAndLed.ino
+++ examples/02.IO/ButtonAndLed/ButtonAndLed.ino
@@ -2,7 +2,9 @@
 ParkingShield shield;

 void setup()
-{ }
+{
+  shield.setDebounceInterval(0);
+}

 void loop()
 {


Fixed Example

Fixed Example

--- examples/RandomOrnaments/RandomOrnaments.ino
+++ examples/RandomOrnaments/RandomOrnaments.ino
@@ -38,14 +38,14 @@

 void loop()
 {
-    if ( (unsigned long) (millis() - time_ref) > period )
+    if ( (unsigned long) (millis() - time_ref) > PERIOD )
     {
         // Picks an ornament at random.
         // It's a bit esoteric, but basically setting a bit in a byte enables a specific ornament
         uint8_t new_ornament = 0x02 << ( rand() % 6 );

         ornament.setOrnaments(SNOW_BACK + new_ornament);  // Sets the new ornament
-        timeout = millis();
+        time_ref = millis();
     }

     // Refreshes the drawing on the matrix.


If dosing screen times out, save settings

--- src/aquarium_wise_controller.ino
+++ src/aquarium_wise_controller.ino
@@ -234,6 +234,13 @@
       unsigned long pastMillis = (currentMillis - millisHome);
       if (pastMillis > (60000 * screenRetHome))
       {
+        if (dispScreen == 10)
+        {
+          for (byte i = 0; i <= numDosingPumps; i++)
+          {
+            dosingPumps[i].saveSettings();
+          }
+        }
         screenHome();
       }
     }


Fixed number sequence.

Fixed number sequence.

--- examples/VWI/CosaVWItempmonitor/CosaVWItempmonitor.ino
+++ examples/VWI/CosaVWItempmonitor/CosaVWItempmonitor.ino
@@ -64,7 +64,7 @@
 void loop()
 {
   // Check message number and count errors
-  static uint8_t next = 0;
+  static uint16_t next = 0;
   static uint32_t err = 0;
   static uint32_t cnt = 0;


Factor out TFT stuff into Screen

Factor out TFT stuff into Screen

--- moros/moros.ino
+++ moros/moros.ino
@@ -59,55 +59,58 @@
   unsigned int cs_pin;
   unsigned int dc_pin;
   unsigned int rst_pin;
+  TFT *tft;
 } Screen;

 Screen screens[2] = {
   {
     .cs_pin = 4,
     .dc_pin = 5,
-    .rst_pin = 6
+    .rst_pin = 6,
   },
   {
     .cs_pin = 7,
     .dc_pin = 8,
-    .rst_pin = 9
+    .rst_pin = 9,
   }
 };

 typedef struct {
   long time_remaining_ms;
   long last_update_ms;
-  TFT tft;
   char display_time[12];
   int display_width_chars;
   Button *button;
+  Screen *screen;
 } player;

 player players[2] = {
   {
     .time_remaining_ms = INITIAL_TIME_MS,
     .last_update_ms = 0,
-    .tft = TFT(screens[0].cs_pin, screens[0].dc_pin, screens[0].rst_pin),
     .display_time = {},
     .display_width_chars = 0,
-    .button = &buttons[0]
+    .button = &buttons[0],
+    .screen = &screens[0]
   },
   {
     .time_remaining_ms = INITIAL_TIME_MS,
     .last_update_ms = 0,
-    .tft = TFT(screens[1].cs_pin, screens[1].dc_pin, screens[1].rst_pin),
     .display_time = {},
     .display_width_chars = 0,
-    .button = &buttons[1]
+    .button = &buttons[1],
+    .screen = &screens[1]
   }
 };

 void init_display(player *p) {
-  p->tft.begin();
-  p->tft.background(0,0,0);
-  p->tft.stroke(255,255,255);
-  p->tft.fill(0,0,0);
-  p->tft.setTextSize(DISPLAY_FONT_SIZE);
+  Screen *screen = p->screen;
+  screen->tft = new TFT(screen->cs_pin, screen->dc_pin, screen->rst_pin);
+  screen->tft->begin();
+  screen->tft->background(0,0,0);
+  screen->tft->stroke(255,255,255);
+  screen->tft->fill(0,0,0);
+  screen->tft->setTextSize(DISPLAY_FONT_SIZE);
 }

 void update_timer(player *p) {
@@ -116,17 +119,18 @@
 }

 void update_changed_chars(player *p, const char *text) {
+  Screen *screen = p->screen;
   for(unsigned int i = 0; i < strlen(text); i++) {
-    p->tft.text(text, 0, 20);
+    screen->tft->text(text, 0, 20);
     if(text[i] != p->display_time[i]) {

       // draw a rect
-      p->tft.stroke(0,0,0);
-      p->tft.rect(CHAR_WIDTH_PX * i , 20, CHAR_WIDTH_PX, CHAR_HEIGHT_PX);
-      //p->tft.background(0,0,0);
+      screen->tft->stroke(0,0,0);
+      screen->tft->rect(CHAR_WIDTH_PX * i , 20, CHAR_WIDTH_PX, CHAR_HEIGHT_PX);
+      //p->tft->background(0,0,0);
       char next_char[2] = {text[i], '\0' };
-      p->tft.stroke(255,255,255);
-      p->tft.text(next_char, CHAR_WIDTH_PX * i, 20);
+      screen->tft->stroke(255,255,255);
+      screen->tft->text(next_char, CHAR_WIDTH_PX * i, 20);
     }
   }
   strncpy(p->display_time, text, sizeof(p->display_time));


Move font #defines into Screen

Move font #defines into Screen

These really should be constants or something

--- moros/moros.ino
+++ moros/moros.ino
@@ -15,11 +15,6 @@
 #include "printf.h"

 #define NONE -1
-
-#define DISPLAY_FONT_SIZE 7
-#define CHAR_HEIGHT_PX DISPLAY_FONT_SIZE * 10
-#define CHAR_WIDTH_PX 42
-#define DISPLAY_WIDTH_CHAR 4

 //#define INITIAL_TIME_MS 300000
 #define INITIAL_TIME_MS 5000
@@ -51,6 +46,12 @@
 class Screen {
 private:
   char prev_text[12];
+
+#define DISPLAY_FONT_SIZE 7
+#define CHAR_HEIGHT_PX DISPLAY_FONT_SIZE * 10
+#define CHAR_WIDTH_PX 42
+#define DISPLAY_WIDTH_CHAR 4
+
 public:
   TFT *tft;
   Screen(unsigned int cs_pin, unsigned int dc_pin, unsigned int rst_pin) {


No need to disable the watchdog

No need to disable the watchdog

--- libraries/esp8266/examples/Blink/Blink.ino
+++ libraries/esp8266/examples/Blink/Blink.ino
@@ -10,8 +10,6 @@

 void setup() {
   pinMode(ledPin, OUTPUT);     // Initialize the ledPin as an output
-  ESP.wdtDisable();            // Disable the watchdog timer built into the ESP8266
-                               // otherwise the ESP8266 reboots during the "delay(1000);"
 }

 // the loop function runs over and over again forever


Update Wrench-Mask-BLE_Unicorn-Hat-HD.ino

Removed superfluous comments that were from the Adafruit BLE example as I don't expect needed to change those functions.
Added comments with links to additional libraries / example code used.
Cleaned up the formatting a bit more.

--- NRF52832/Unicorn_Hat_HD/Wrench-Mask-BLE_Unicorn-Hat-HD.ino
+++ NRF52832/Unicorn_Hat_HD/Wrench-Mask-BLE_Unicorn-Hat-HD.ino
@@ -2,20 +2,23 @@
  *
  *  Hardware Used:
  *  Adafruit Feather NRF52
- *  Pimoroni Unicorn Hat HD
+ *  Pimoroni Unicorn Hat HD x2
  *
  *  by Brandon C. Allen
  *
- *  Based on the bleuart example from AdaFruit:
+ *  BLE Functions based on the bleuart example from AdaFruit:
  *  https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino
- *
+ *  Additional portions of the code are based on the matrixdraw example from gguuss's branch of the AdaFruit NeoPixel library:
+ *  https://github.com/gguuss/Adafruit_NeoPixel/blob/master/examples/matrixdraw/matrixdraw.ino
+ *  My Library for controlling the Unicorn Hat HD with the Arduino can found here:
+ *  https://github.com/Arudinne/Unicorn-Hat-HD-Arduino
 */

-// Byte Masks for facial expressions
+// Byte masks for facial expressions

 #define ROW_SIZE 16

-//  X_X - face001
+//  X_X - Face001

 byte face001_Left [][ROW_SIZE] = {
   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
@@ -979,19 +982,20 @@
 #include <SPI.h>
 #include <Unicorn_Hat_HD.h>

-const int slaveSelectPinA = 7;
-const int slaveSelectPinB = 27;
-
 // BLE Service
 BLEDis  bledis;
 BLEUart bleuart;
 BLEBas  blebas;

 // Define the matrix CS pins
-Unicorn_Hat_HD lefteye = Unicorn_Hat_HD(slaveSelectPinA);
-Unicorn_Hat_HD righteye = Unicorn_Hat_HD(slaveSelectPinB);
-
-// Define color parameters
+const int matrixAChipSelectPin = 7;
+const int matrixBChipSelectPin = 27;
+
+// Define the matrices
+Unicorn_Hat_HD lefteye = Unicorn_Hat_HD(matrixAChipSelectPin);
+Unicorn_Hat_HD righteye = Unicorn_Hat_HD(matrixBChipSelectPin);
+
+// Define preset color variables
 uint32_t colorRed = 0xFF0000;
 uint32_t colorGreen = 0x00FF00;
 uint32_t colorBlue = 0x0000FF;
@@ -1000,18 +1004,16 @@
 // Define initial color
 uint32_t color = colorWhite;

-// Define Variables for blinking the LEDs
+// Define variables for blinking the LEDs
 unsigned long currentMillis = 0;
 unsigned long previousMillis = 0;
 int ledState = 0; //
 long OnTime = 6000; // milliseconds of on-time
 long OffTime = 70; // milliseconds of off-time
-byte EyeBrightness = 50;
-
-// Initialize boolean variables for face status checks when switching faces
-
-//Startup
-bool startupCheck = false;
+
+// Set default brightness level
+byte eyeBrightness = 50;
+
 bool drawGivenMask(int row, int col, byte mask[][ROW_SIZE])
 {
   col = col % ROW_SIZE;
@@ -1025,8 +1027,8 @@
 {
   lefteye.begin();
   righteye.begin();
-  lefteye.setBrightness(EyeBrightness);
-  righteye.setBrightness(EyeBrightness);
+  lefteye.setBrightness(eyeBrightness);
+  righteye.setBrightness(eyeBrightness);
   lefteye.show();
   righteye.show();

@@ -1036,53 +1038,32 @@
   Serial.println("|| Opening Serial port for Debugging ||");
   Serial.println("=======================================");

-  //Configure BLE
+  // Configure BLE
   Bluefruit.begin();
-  // Set Max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
   Bluefruit.setTxPower(4);
   Bluefruit.setName("Wrench Mask");
   Bluefruit.setConnectCallback(connect_callback);
   Bluefruit.setDisconnectCallback(disconnect_callback);
-
-  // Configure and Start Device Information Service
   bledis.setManufacturer("Adafruit Industries");
   bledis.setModel("Bluefruit Feather52");
   bledis.begin();
-
-  // Configure and Start BLE Uart Service
   bleuart.begin();
-
-  // Start BLE Battery Service
   blebas.begin();
   blebas.write(100);

   // Set up and start advertising
   startAdv();
-  Face001();
+
+  // Draw Initial Face Pattern
+  face001();
 }

 void startAdv(void)
 {
-  // Advertising packet
   Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
   Bluefruit.Advertising.addTxPower();
-
-  // Include bleuart 128-bit uuid
   Bluefruit.Advertising.addService(bleuart);
-
-  // Secondary Scan Response packet (optional)
-  // Since there is no room for 'Name' in Advertising packet
   Bluefruit.ScanResponse.addName();
-
-  /* Start Advertising
-   * - Enable auto advertising if disconnected
-   * - Interval:  fast mode = 20 ms, slow mode = 152.5 ms
-   * - Timeout for fast mode is 30 seconds
-   * - Start(timeout) with timeout = 0 will advertise forever (until connected)
-   *
-   * For recommended advertising interval
-   * https://developer.apple.com/library/content/qa/qa1931/_index.html
-   */
   Bluefruit.Advertising.restartOnDisconnect(true);
   Bluefruit.Advertising.setInterval(32, 244);    // in unit of 0.625 ms
   Bluefruit.Advertising.setFastTimeout(30);      // number of seconds in fast mode
@@ -1101,39 +1082,39 @@
     Serial.println("");
     switch (ch)
    {
-    case 0x2B: IncrementBrightness(); break;
-    case 0x2D: DecrementBrightness(); break;
-    case 0x30: Face010(); break; // Draw Face010
-    case 0x31: Face001(); break; // Draw Face001
-    case 0x32: Face002(); break; // Draw Face002
-    case 0x33: Face003(); break; // Draw Face003
-    case 0x34: Face004(); break; // Draw Face004
-    case 0x35: Face005(); break; // Draw Face005
-    case 0x36: Face006(); break; // Draw Face006
-    case 0x37: Face007(); break; // Draw Face007
-    case 0x38: Face008(); break; // Draw Face008
-    case 0x39: Face009(); break; // Draw Face009
-    case 0x41: Face011(); break; // Draw Face011
-    case 0x42: Face012(); break; // Draw Face012
-    case 0x43: Face013(); break; // Draw Face013
-    case 0x44: Face014(); break; // Draw Face014
-    case 0x45: Face015(); break; // Draw Face015
-    case 0x46: Face016(); break; // Draw Face016
-    case 0x47: Face017(); break; // Draw Face017
-    case 0x48: Face018(); break; // Draw Face018
-    case 0x49: Face019(); break; // Draw Face019
-    case 0x4A: Face020(); break; // Draw Face020
-    case 0x4B: Face021(); break; // Draw Face021
-    case 0x4C: Face022(); break; // Draw Face022
-    case 0x4D: Face023(); break; // Draw Face023
-    case 0x4E: Umbrella(); break; // Draw Umbrella Corp logo
+    case 0x2B: incrementBrightness(); break;
+    case 0x2D: decrementBrightness(); break;
+    case 0x30: face010(); break; // Draw Face010
+    case 0x31: face001(); break; // Draw Face001
+    case 0x32: face002(); break; // Draw Face002
+    case 0x33: face003(); break; // Draw Face003
+    case 0x34: face004(); break; // Draw Face004
+    case 0x35: face005(); break; // Draw Face005
+    case 0x36: face006(); break; // Draw Face006
+    case 0x37: face007(); break; // Draw Face007
+    case 0x38: face008(); break; // Draw Face008
+    case 0x39: face009(); break; // Draw Face009
+    case 0x41: face011(); break; // Draw Face011
+    case 0x42: face012(); break; // Draw Face012
+    case 0x43: face013(); break; // Draw Face013
+    case 0x44: face014(); break; // Draw Face014
+    case 0x45: face015(); break; // Draw Face015
+    case 0x46: face016(); break; // Draw Face016
+    case 0x47: face017(); break; // Draw Face017
+    case 0x48: face018(); break; // Draw Face018
+    case 0x49: face019(); break; // Draw Face019
+    case 0x4A: face020(); break; // Draw Face020
+    case 0x4B: face021(); break; // Draw Face021
+    case 0x4C: face022(); break; // Draw Face022
+    case 0x4D: face023(); break; // Draw Face023
+    case 0x4E: umbrella(); break; // Draw Umbrella Corp logo
     case 0x57: setFaceColor(colorRed); break;
     case 0x58: setFaceColor(colorGreen); break;
     case 0x59: setFaceColor(colorBlue); break;
     case 0x5A: setFaceColor(colorWhite); break;
    }
   }
-  BlinkFunction();
+  blinkFunction();
 }

 void connect_callback(uint16_t conn_handle)
@@ -1153,44 +1134,12 @@
   Serial.println();
   Serial.println("Disconnected");
 }
-
-/**
- * RTOS Idle callback is automatically invoked by FreeRTOS
- * when there are no active threads. E.g when loop() calls delay() and
- * there is no bluetooth or hw event. This is the ideal place to handle
- * background data.
- *
- * NOTE: It is recommended to call waitForEvent() to put MCU into low-power mode
- * at the end of this callback. You could also turn off other Peripherals such as
- * Serial/PWM and turn them back on if wanted
- *
- * e.g
- *
- * void rtos_idle_callback(void)
- * {
- *    Serial.stop(); // will lose data when sleeping
- *    waitForEvent();
- *    Serial.begin(115200);
- * }
- *
- * NOTE2: If rtos_idle_callback() is not defined at all. Bluefruit will force
- * waitForEvent() to save power. If you don't want MCU to sleep at all, define
- * an rtos_idle_callback() with empty body !
- *
- * WARNING: This function MUST NOT call any blocking FreeRTOS API
- * such as delay(), xSemaphoreTake() etc ... for more information
- * http://www.freertos.org/a00016.html
- */
 void rtos_idle_callback(void)
 {
-  // Don't call any other FreeRTOS blocking API()
-  // Perform background task(s) here
-
-  // Request CPU to enter low-power mode until an event/interrupt occurs
   waitForEvent();
 }

-void Face001()
+void face001()
 {
   lefteye.clear();
   righteye.clear();
@@ -1198,7 +1147,7 @@
   maskedColorWipeRightEye(color, face001_Right);
 }
 // Draw Face002
-void Face002()
+void face002()
 {
   lefteye.clear();
   righteye.clear();
@@ -1206,7 +1155,7 @@
   maskedColorWipeRightEye(color, face002_Right);
 }
 // Draw Face003
-void Face003()
+void face003()
 {
   lefteye.clear();
   righteye.clear();
@@ -1214,7 +1163,7 @@
   maskedColorWipeRightEye(color, face003_Right);
 }
 // Draw Face004
-void Face004()
+void face004()
 {
   lefteye.clear();
   righteye.clear();
@@ -1222,7 +1171,7 @@
   maskedColorWipeRightEye(color, face004_Right);
 }
 // Draw Face005
-void Face005()
+void face005()
 {
   lefteye.clear();
   righteye.clear();
@@ -1230,7 +1179,7 @@
   maskedColorWipeRightEye(color, face005_Right);
 }
 // Draw Face006
-void Face006()
+void face006()
 {
   lefteye.clear();
   righteye.clear();
@@ -1238,7 +1187,7 @@
   maskedColorWipeRightEye(color, face006_Right);
 }
 // Draw Face007
-void Face007()
+void face007()
 {
   lefteye.clear();
   righteye.clear();
@@ -1246,7 +1195,7 @@
   maskedColorWipeRightEye(color, face007_Right);
 }
 // Draw Face008
-void Face008()
+void face008()
 {
   lefteye.clear();
   righteye.clear();
@@ -1254,7 +1203,7 @@
   maskedColorWipeRightEye(color, face008_Right);
 }
 // Draw Face009
-void Face009()
+void face009()
 {
   lefteye.clear();
   righteye.clear();
@@ -1262,7 +1211,7 @@
   maskedColorWipeRightEye(color, face009_Right);
 }
 // Draw Face010
-void Face010()
+void face010()
 {
   lefteye.clear();
   righteye.clear();
@@ -1270,7 +1219,7 @@
   maskedColorWipeRightEye(color, face010_Right);
 }
 // Draw Face011
-void Face011()
+void face011()
 {
   lefteye.clear();
   righteye.clear();
@@ -1278,7 +1227,7 @@
   maskedColorWipeRightEye(color, face011_Right);
 }
 // Draw Face012
-void Face012()
+void face012()
 {
   lefteye.clear();
   righteye.clear();
@@ -1286,7 +1235,7 @@
   maskedColorWipeRightEye(color, face012_Right);
 }
 // Draw Face013
-void Face013()
+void face013()
 {
   lefteye.clear();
   righteye.clear();
@@ -1294,7 +1243,7 @@
   maskedColorWipeRightEye(color, face013_Right);
 }
 // Draw Face014
-void Face014()
+void face014()
 {
   lefteye.clear();
   righteye.clear();
@@ -1302,7 +1251,7 @@
   maskedColorWipeRightEye(color, face014_Right);
 }
 // Draw Face015
-void Face015()
+void face015()
 {
   lefteye.clear();
   righteye.clear();
@@ -1310,7 +1259,7 @@
   maskedColorWipeRightEye(color, face015_Right);
 }
 // Draw Face016
-void Face016()
+void face016()
 {
   lefteye.clear();
   righteye.clear();
@@ -1318,7 +1267,7 @@
   maskedColorWipeRightEye(color, face016_Right);
 }
 // Draw Face017
-void Face017()
+void face017()
 {
   lefteye.clear();
   righteye.clear();
@@ -1326,14 +1275,14 @@
   maskedColorWipeRightEye(color, face017_Right);
 }
 // Draw Face018
-void Face018()
+void face018()
 {
   lefteye.clear();
   righteye.clear();
   maskedColorWipeLeftEye(color, face018_Left);
   maskedColorWipeRightEye(color, face018_Right);
 }
-void Face019()
+void face019()
 {
   lefteye.clear();
   righteye.clear();
@@ -1341,7 +1290,7 @@
   maskedColorWipeRightEye(color, face019_Right);
 }
 // Draw Face020
-void Face020()
+void face020()
 {
   lefteye.clear();
   righteye.clear();
@@ -1349,7 +1298,7 @@
   maskedColorWipeRightEye(color, face020_Right);
 }
 // Draw Face021
-void Face021()
+void face021()
 {
   lefteye.clear();
   righteye.clear();
@@ -1357,7 +1306,7 @@
   maskedColorWipeRightEye(color, face021_Right);
 }
 // Draw Face022
-void Face022()
+void face022()
 {
   lefteye.clear();
   righteye.clear();
@@ -1365,7 +1314,7 @@
   maskedColorWipeRightEye(color, face022_Right);
 }
 // Draw Face023
-void Face023()
+void face023()
 {
   lefteye.clear();
   righteye.clear();
@@ -1374,41 +1323,44 @@
 }

 // Umbrella Logo
-void Umbrella()
-{
-  DrawUmbrella();
-}
-
-void IncrementBrightness()
-{
-  if (EyeBrightness < 255){
-    EyeBrightness += 1;
+void umbrella()
+{
+  lefteye.clear();
+  righteye.clear();
+  dualMaskedColorWipeLeftEye(colorRed, colorWhite, face024_Red, face024_White);
+  dualMaskedColorWipeRightEye(colorRed, colorWhite, face024_Red, face024_White);
+}
+
+void incrementBrightness()
+{
+  if (eyeBrightness < 255){
+    eyeBrightness += 1;
     Serial.println("Incrementing Brightness by 1");
     Serial.print("Brightness:");
-    Serial.println(EyeBrightness);
-    lefteye.setBrightness(EyeBrightness);
-    righteye.setBrightness(EyeBrightness);
+    Serial.println(eyeBrightness);
+    lefteye.setBrightness(eyeBrightness);
+    righteye.setBrightness(eyeBrightness);
     lefteye.show();
     righteye.show();
   }
-  else if(EyeBrightness = 255){
+  else if(eyeBrightness = 255){
     Serial.println("Brightness already at maximum");
   }
 }

-void DecrementBrightness()
-{
-  if (EyeBrightness > 1){
-    EyeBrightness -= 1;
+void decrementBrightness()
+{
+  if (eyeBrightness > 1){
+    eyeBrightness -= 1;
     Serial.println("Decrementing Brightness by 1");
     Serial.print("Brightness:");
-    Serial.println(EyeBrightness);
-    lefteye.setBrightness(EyeBrightness);
-    righteye.setBrightness(EyeBrightness);
+    Serial.println(eyeBrightness);
+    lefteye.setBrightness(eyeBrightness);
+    righteye.setBrightness(eyeBrightness);
     lefteye.show();
     righteye.show();
   }
-  else if(EyeBrightness = 1){
+  else if(eyeBrightness = 1){
     Serial.println("Brightness already at minimum");
   }
 }
@@ -1487,7 +1439,7 @@
   delay(1);
 }

-void BlinkFunction()
+void blinkFunction()
 {
   currentMillis = millis(); // Set variable to see if it's time to change the state of the LEDs
   if ((ledState == 0) && (currentMillis - previousMillis >= OffTime)) // Turn on the LEDs
@@ -1495,8 +1447,8 @@
     ledState = 1; // Set the LEDs status to on
     previousMillis = currentMillis;   // Remember the time
     Serial.println("Blink - LEDs ON"); // Debug output
-    lefteye.setBrightness(EyeBrightness);
-    righteye.setBrightness(EyeBrightness);
+    lefteye.setBrightness(eyeBrightness);
+    righteye.setBrightness(eyeBrightness);
     lefteye.show();
     righteye.show();
   }
@@ -1518,11 +1470,3 @@
 {
   color=colorVariable;
 }
-
-void DrawUmbrella()
-{
-  lefteye.clear();
-  righteye.clear();
-  dualMaskedColorWipeLeftEye(colorRed, colorWhite, face024_Red, face024_White);
-  dualMaskedColorWipeRightEye(colorRed, colorWhite, face024_Red, face024_White);
-}


Delete afsk_decoder.ino

Delete afsk_decoder.ino

--- afsk_decoder.ino
+++ afsk_decoder.ino
@@ -1,127 +0,0 @@
-/*
- A start of a AFSK decoder for the Tiva C Series EK-TM4C1294XL
-
- This code is not complete, and can only do some basic tone detection
- currently. Will not decode AFSK signals yet.
-
- */
-#include "Energia.h"
-#include "inc/hw_ints.h"
-#include "inc/hw_memmap.h"
-#include "driverlib/interrupt.h"
-#include "driverlib/pin_map.h"
-#include "driverlib/rom.h"
-#include "driverlib/timer.h"
-#include "driverlib/sysctl.h"
-
-#define FREQ_MARK 1200
-#define FREQ_SPACE 2200
-#define FREQ_SAMP 48016
-#define BAUD 1200
-
-int     sk,mk,i;
-float   floatnumSamples;
-float   somega,ssine,scosine,scoeff,momega,msine,mcosine,mcoeff,q0,q1,q2,i0,i1,i2,magnitude,real,imag;
-
-float   scalingFactor = 40 / 2.0;
-int     count = 0;
-int     sample_position = 0;
-
-void SamplerInterrupt(void)
-{
-  // clear the timer interrupt
-  ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
-
-  float tmp = analogRead(A0);
-
-  // mark
-  q0 = mcoeff * q1 - q2 + tmp;
-  q2 = q1;
-  q1 = q0;
-
-  // space
-  i0 = scoeff * i1 - i2 + tmp;
-  i2 = i1;
-  i1 = i0;
-  sample_position++;
-
-  if (sample_position == 40) {
-    real = (q1 - q2 * mcosine) / scalingFactor;
-    imag = (q2 * msine) / scalingFactor;
-
-    // check if signal is mark
-    magnitude = sqrtf(real*real + imag*imag);
-    if (magnitude > 500) {
-      Serial.print("1");
-    }
-    else {
-      real = (i1 - i2 * scosine) / scalingFactor;
-      imag = (i2 * ssine) / scalingFactor;
-
-      // check if signal is space
-      magnitude = sqrtf(real*real + imag*imag);
-      if (magnitude > 500) {
-        Serial.print("0");
-      }
-    }
-
-    // reset
-    q0=0;
-    q1=0;
-    q2=0;
-    i0=0;
-    i1=0;
-    i2=0;
-    sample_position = 0;
-  }
-
-  // for debug
-  count++;
-}
-
-void setup()
-{
-  // init serial port
-  Serial.begin(9600);
-
-  // initialise the sampler interrupt
-  ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
-  ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
-  TimerIntRegister(TIMER0_BASE, TIMER_A, SamplerInterrupt);
-  ROM_TimerEnable(TIMER0_BASE, TIMER_A);
-  ROM_IntEnable(INT_TIMER0A);
-  ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
-
-  // setup goertzel variables for mark detection
-  floatnumSamples = (float) 128;
-  mk = (int) (0.5 + ((floatnumSamples * FREQ_MARK) / FREQ_SAMP));
-  momega = (2.0 * M_PI * mk) / floatnumSamples;
-  msine = sin(momega);
-  mcosine = cos(momega);
-  mcoeff = 2.0 * mcosine;
-  q0=0;
-  q1=0;
-  q2=0;
-
-  // setup goertzel variables for space detection
-  sk = (int) (0.5 + ((floatnumSamples * FREQ_SPACE) / FREQ_SAMP));
-  somega = (2.0 * M_PI * sk) / floatnumSamples;
-  ssine = sin(somega);
-  scosine = cos(somega);
-  scoeff = 2.0 * scosine;
-  i0=0;
-  i1=0;
-  i2=0;
-}
-
-void loop()
-{
-  // start the timer then loop forever
-  ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, 2498); // 2498 =~ 48000Hz
-  while (1)
-  {
-    Serial.println(count);
-    count = 0;
-    delay(1000);
-  }
-}


GT test fine. char & chinese

GT test fine. char & chinese

--- examples/GT20L16_test/GT20L16_test.ino
+++ examples/GT20L16_test/GT20L16_test.ino
@@ -11,6 +11,41 @@

 unsigned char matrix[32];

+void dispMatrix(int len, unsigned char *Matrix)
+{
+
+    for(int k = 0; k<2; k++)
+    {
+        for(int i=0; i<8; i++)
+        {
+            for(int j=0; j<(len/2); j++)
+            {
+
+                if(Matrix[j+(len/2)*k] & (0x01<<(7-i)))
+                {
+                    //Serial.print("**");
+                    Serial.write(random('A', 'Z'));         // dandom...fuck
+                    Serial.write(random('A', 'Z'));         // ...
+                }
+                else
+                {
+                    Serial.print("  ");
+                }
+            }
+            Serial.println();
+        }
+    }
+}
+
+void dispMatrixs(int len, unsigned int *unicode)
+{
+    for(int i=0; i<len; i++)
+    {
+        int dtaLen = GT20L16.getMatrixUnicode(unicode[i], matrix);
+        dispMatrix(dtaLen, matrix);
+    }
+}
+
 void setup()
 {
     Serial.begin(38400);
@@ -18,29 +53,8 @@
     EPAPER.init_io();
     GT20L16.begin(PINCSGT);

-    int dtaLen = GT20L16.getMatrixUnicode('S', matrix);
-
-    cout << "dtaLen = " << dtaLen << endl;
-
-    for(int k = 0; k<2; k++)
-    {
-        for(int i=0; i<8; i++)
-        {
-            for(int j=0; j<(dtaLen/2); j++)
-            {
-
-                if(matrix[j+(dtaLen/2)*k] & (0x01<<(7-i)))
-                {
-                    cout << "**";
-                }
-                else
-                {
-                    cout << "  ";
-                }
-            }
-            cout << endl;
-        }
-    }
+    unsigned int utest[3] = {'2', 'b', 'k'};
+    dispMatrixs(3, utest);

     cout << endl;


debugged and cleaned u p botwurst_a

debugged and cleaned u p botwurst_a

--- botwurst_a/botwurst_a.ino
+++ botwurst_a/botwurst_a.ino
@@ -1,83 +1,132 @@
-#define LOOP_DELAY 100
-#define TIMEOUT 1000
+//////////////////////////////////////////////////////////////////
+//                                                              //
+//                       -- BOTWURST A --                       //
+//                                                              //
+//                          ALEX COHEN                          //
+//                       DAVE BUCKINGHAM                        //
+//                                                              //
+//       RECIEVES MOTOR COMMANDS OVER USB AND SETS ANALOG       //
+//       AND DIGITLA PINS.                                      //
+//                                                              //
+//////////////////////////////////////////////////////////////////
+
+#define DEBUG
+
+//////////////////////////////////////
+//            CONSTANTS             //
+//////////////////////////////////////
+
+// SERIAL COMMUNICATION
+#define LOOP_DELAY 10  // MILLISECONDS
 #define BAUD 9600
 #define SERIAL_CONFIG SERIAL_8N1
-#define LOWVOLTAGE 0   //the low boundary for output voltage
+
+// PIN IO
+#define LOWVOLTAGE 0    //the low boundary for output voltage
 #define HIGHVOLTAGE 255 //the high boundary for output voltage
-
-//In general, designated output pins send voltage out from the arduino to connected devices
-//For testing, pin 13 has an LED that will turn on with a certain voltage sent out
-//The analog pins on the Mega are A0-A5
-#define OUTPIN0 A0
+#define OUTPIN0 A0      //The analog pins on the Mega are A0-A5
 #define OUTPIN1 A1
 #define OUTPIN2 13
 #define OUTPIN3 12
-//In general, if we ever want to read voltages in from the arduino to get feedback from
-//the robot, it can be done using the input pins
-#define INPIN 7
+#define INPIN 7         // input pin to get feedback from robot

-# IN FACT THESE ARE EACH 8 BITS
+
+//////////////////////////////////////
+//           VARIABLES              //
+//////////////////////////////////////
+
+// COMMAND VALUES
 byte wave_speed;
 byte wavelength;
-boolean motor_0;
-boolean motor_1;
+byte motor_0;
+byte motor_1;

-byte read_integer
-unsigned long timer;
-char read_char
+// TO HOLD PACKET HEADDER
+char flag;
+
+// FOR ITERATING OVER THE FOUR COMMAND VALUES
+#define NUM_COMMANDS 4
+byte* command_pointers[NUM_COMMANDS];
+int i;

-# LISTEN FOR 4 BYTES
-# STORE IN GLOBAL VARIABLES
-# RETURN FALSE IF IT TAKES TOO LONG
-# OTHERWISE RETURN TRUE
+//////////////////////////////////////
+//        GET MOTOR COMMAND         //
+//////////////////////////////////////
+
+// READ 4 BYTES AND STORE IN GLOBAL VARIABLES
+// RETURN TRUE IF 4 VALUES READ, ELSE FALSE
 boolean get_motor_command () {
-    timer = millis();

-    # IF THERE ARE INCOMMING BYTES
-    # WAIT SO ALL THE DATA CAN ARRIVE
-    # CHECK FOR START FLAG ':'
+    // IF THERE ARE INCOMMING BYTES
+    // CHECK FOR START FLAG ':'
     if (! Serial.available()) {
         return false;
     }
-    read_char = Serial.read();
-    delay(100);  // Wait for all data
-    while (read_char != ':' && Serial.available()) {
-        read_char = Serial.read();
+    flag = Serial.read();
+    delay(100);  // WAIT FOR ALL DATA
+    while (flag != ':' && Serial.available()) {
+        flag = Serial.read();
     }
-    if (read_char != ':') {
+    if (flag != ':') {
         return false;
     }

+    // ITERATE OVER COMMANDS
+    // STORING VALUES READ FROM SERIAL
+    for (i= 0; i < NUM_COMMANDS; i++) {
+        if (Serial.available()) {
+            *command_pointers[i] = Serial.read();
+        }
+        else {
+            return false;
+        }
+    }

-    if ((millis() - timer) > TIMEOUT) { return false; }
-
-    wave_speed = Serial.parseInt();
-    if ((millis() - timer) > TIMEOUT) { return false; }
-
-    wavelength = Serial.parseInt();
-    if ((millis() - timer) > TIMEOUT) { return false; }
-
-    motor_0 = Serial.parseInt();
-    if ((millis() - timer) > TIMEOUT) { return false; }
-
-    motor_1 = Serial.parseInt();
-    if ((millis() - timer) > TIMEOUT) { return false; }
+#ifdef DEBUG
+    // ECHO THE COMMANDS
+    char buffer[20];
+    sprintf(buffer, "%u %u %u %u\n", wave_speed, wavelength, motor_0, motor_1);
+    Serial.print(buffer);
+#endif

     return true;
 }

+//////////////////////////////////////
+//           INTIIALIZE             //
+//////////////////////////////////////
+
 void setup() {
+    // SET UP INPUT
     Serial.begin(BAUD);
-    Serial.println("Ready");  // we might want to read this
+    command_pointers[0] = &wave_speed;
+    command_pointers[1] = &wavelength;
+    command_pointers[2] = &motor_0;
+    command_pointers[3] = &motor_1;
+    for (i= 0; i < NUM_COMMANDS; i++) {
+        *command_pointers[i] = 0;
+    }
+
+    // SET UP OUTPUT
     pinMode(OUTPIN0, OUTPUT); //designates OUTPIN0 pin to be an output
     pinMode(OUTPIN1, OUTPUT); //designates OUTPIN1 pin to be an input
     pinMode(OUTPIN2, OUTPUT);
     pinMode(OUTPIN3, OUTPUT);
     pinMode(INPIN, INPUT);    //designates INPIN pin to be an input
+
+#ifdef DEBUG
+    // REPORT
+    Serial.println("botwurst_a ready...");
+#endif
+
 }

+
+//////////////////////////////////////
+//        WRITE TO PINS             //
+//////////////////////////////////////

 boolean set_pins() {
     boolean speedValid = 0;
@@ -105,21 +154,13 @@
 }

+//////////////////////////////////////
+//           MAIN LOOP              //
+//////////////////////////////////////
+
 void loop() {
-    if (get_motor_command) {
-        set_pins();
-
-        // FOR TESTING
-        //delay(LOOP_DELAY);
-        //Serial.print(wave_speed);
-        //Serial.print("\t");
-        //Serial.print(wavelength);
-        //Serial.print("\t");
-        //Serial.print(motor_0);
-        //Serial.print("\t");
-        //Serial.print(motor_1);
-        //Serial.println("\t");
-
+    if (get_motor_command()) {
+        //set_pins();
     }
-    delay(LOOP_DELAY)
+    delay(LOOP_DELAY);
 }


Update ArduCAM_Mini_4CAM_VideoStreaming.ino

--- ArduCAM/examples/mini/ArduCAM_Mini_4CAM_VideoStreaming/ArduCAM_Mini_4CAM_VideoStreaming.ino
+++ ArduCAM/examples/mini/ArduCAM_Mini_4CAM_VideoStreaming/ArduCAM_Mini_4CAM_VideoStreaming.ino
@@ -386,7 +386,7 @@
   }
   else if((temp == 0xD8) & (temp_last == 0xFF))
   {
-    Serial.println(F("ACK IMG"));
+    Serial.println(F("ACK IMG END"));
     is_header = true;
     Serial.write(temp_last);
     Serial.write(temp);


Clean up

Clean up

--- Pan_Tilt_laser/Pan_Tilt_laser.ino
+++ Pan_Tilt_laser/Pan_Tilt_laser.ino
@@ -75,10 +75,11 @@
 void setNextPauseTime(unsigned long avg_sec_to_pause=15, double variance=12){

   unsigned long temp = gauss.gRandom(avg_sec_to_pause, variance)*1000;
-
+  /*
   Serial.print(F("Next pause in "));
   Serial.print(temp/1000);
   Serial.println(F(" seconds.\n"));
+  */
   pauseTask.setInterval(temp);

 }
@@ -86,10 +87,11 @@
 //turn off laser for a few moments at this time
 void setNextRestTime(unsigned long avg_sec_to_rest=120, double variance=60){
   unsigned long temp = gauss.gRandom(avg_sec_to_rest, variance)*1000;
-
+  /*
   Serial.print(F("Next rest in "));
   Serial.print(temp/1000);
   Serial.println(F(" seconds.\n"));
+  */
   restTask.setInterval(temp);
 }

@@ -97,21 +99,23 @@
 //turn of laser for a minutes to hours at this time
 void setNextSleepTime(unsigned long avg_sec_to_sleep=360, double variance = 100){
   unsigned long temp = gauss.gRandom(avg_sec_to_sleep, variance)*10000;
+  /*
   Serial.print(F("Next sleep in "));
   Serial.print(temp/1000);
   Serial.println(F(" seconds.\n"));
+  */
   sleepTask.setInterval(temp);

 }

 void pauseCB(){
-  Serial.println(F("Pause Callback!"));
+//  Serial.println(F("Pause Callback!"));
   delay(markovPause());
   setNextPauseTime();
 }

 void restCB(){
-  Serial.println(F("Rest Callback!"));
+//  Serial.println(F("Rest Callback!"));
   mSwitch.ledState(0);
   sleep(5, 10);
   mSwitch.ledState(1);
@@ -120,7 +124,7 @@
 }

 void sleepCB(){
-  Serial.println(F("Sleep Callback!"));
+//  Serial.println(F("Sleep Callback!"));
   mSwitch.ledState(0);
   sleep(1800, 2400); //sleep between 30 and 40 minutes
   mSwitch.ledState(1);


now rendering LED status

now rendering LED status

--- hardware/cc3200/libraries/WiFi/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino
+++ hardware/cc3200/libraries/WiFi/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino
@@ -80,6 +80,10 @@
             client.println("
Welcome to the CC3200 WiFi Web Server
");
             client.print("RED LED <button onclick=\"location.href='/H'\">HIGH</button>");
             client.println(" <button onclick=\"location.href='/L'\">LOW</button>
");
+            client.print("
LED=");
+            client.print(digitalRead(RED_LED)==1?"On":"Off");
+            client.print("
");
+

             // The HTTP response ends with another blank line:
             client.println();


Updated sketch file.

Updated sketch file.

--- arduino/multiplayer_joystick.ino
+++ arduino/multiplayer_joystick.ino
@@ -222,8 +222,8 @@
    * Send report.
    */
   if (force_send ||
-      memcmp(&joy_state, &prev_joy_state,
-             sizeof(joystick_state_t)*IF_NUM)) {
+    memcmp(&joy_state, &prev_joy_state,
+           sizeof(joystick_state_t)*IF_NUM)) {
     for (if_ix = IF_FIRST; if_ix < IF_NUM; if_ix++) {
       send_joystick_state(if_ix);
     }


rotarty encoders working

rotarty encoders working

--- SDPArduinoCode/SDPArduinoCode.ino
+++ SDPArduinoCode/SDPArduinoCode.ino
@@ -31,12 +31,14 @@

 // Initial motor position is 0.
 int positions[ROTARY_COUNT] = {0};
+int UO[ROTARY_COUNT] = {0};
+int rotations[ROTARY_COUNT] = {0};

 void setup(){

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

   // setup communication channel to our designated group channel = 0x20
 //  Serial.write("+++");
@@ -122,8 +124,9 @@

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

-  motorForward(FRONT_LEFT_MOTOR,power);
-  motorForward(FRONT_RIGHT_MOTOR,power);
+  motorBackward(FRONT_LEFT_MOTOR,power-2); // left motor is more powerful than right. This will make sure they have the same roatations +- 1
+                                          // could be more acurate if we use 0-255 instead of 0-100 for power rating.
+  motorBackward(FRONT_RIGHT_MOTOR,power);

   // need to create a reply message to let the PC acknowledge the accepted request and execution
   Serial.println("Robot forward");
@@ -139,21 +142,21 @@
   motorStop(FRONT_RIGHT_MOTOR);

   // set motors to move backwards
-  motorBackward(FRONT_LEFT_MOTOR, power);
+  motorForward(FRONT_LEFT_MOTOR, power);
+  motorForward(FRONT_RIGHT_MOTOR,power);
+
+  // send reply message
+  Serial.println("Robot back");
+
+}
+
+void rotateRobotLeft(int power){
+
+  motorAllStop(); // use this for now, can change later on
+
+  // set motors for left rotation
   motorBackward(FRONT_RIGHT_MOTOR,power);
-
-  // send reply message
-  Serial.println("Robot back");
-
-}
-
-void rotateRobotLeft(int power){
-
-  motorAllStop(); // use this for now, can change later on
-
-  // set motors for left rotation
-  motorForward(FRONT_RIGHT_MOTOR,power);
-  motorForward(TURNING_MOTOR,power);
+  motorBackward(TURNING_MOTOR,power);

   // send reply message
   Serial.println("Robot left");
@@ -165,8 +168,8 @@
   motorAllStop(); // use this for now, can change later

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

   // send reply message
   Serial.println("Robot right");
@@ -211,7 +214,27 @@

   // Update the recorded motor positions
   for (int i = 0; i < ROTARY_COUNT; i++) {
-    positions[i] += (int8_t) Wire.read();  // Must cast to signed 8-bit type
+
+    // another integer array OU (over/uder 0-30000)
+    if(positions[i] > 30000){
+      int temp = positions[i];
+      int remendier = temp - 30000;
+      positions[i] = remendier;
+      UO[i] += 1;
+    }
+
+    if(positions[i] < -30000 && positions[i] < 0){
+      int temp = positions[i];
+      int remendier = temp + 30000;
+      positions[i] = remendier;
+      UO[i] -= 1;
+    }
+
+    int r = (int) ((int8_t) Wire.read());  // Must cast to signed 8-bit type
+    positions[i] += (r*-1);
+    rotations[i] = (r*-1);
+
+
   }
 }

@@ -221,6 +244,18 @@
     Serial.print(positions[i]);
     Serial.print(' ');
   }
+  Serial.print("                      ");
+  Serial.print("UO: ");
+  for (int i = 0; i < ROTARY_COUNT; i++) {
+    Serial.print(UO[i]);
+    Serial.print(' ');
+  }
+  Serial.print("                       ");
+  Serial.print("rotations: ");
+  for (int i = 0; i < ROTARY_COUNT; i++) {
+    Serial.print(rotations[i]);
+    Serial.print(' ');
+  }
   Serial.println();
   delay(PRINT_DELAY);  // Delay to avoid flooding serial out
 }
@@ -243,8 +278,9 @@
   // Change this if 1st or 2nd bit is relevant, etc.
   for (int i = 1; i <= 250; i++) {
       Wire.beginTransmission(register_address); // open I2C communication to intended receiver
-      Wire.setclock(freq);
+      //Wire.setClock(freq);
       Wire.write( (byte) (file.charAt(i)) );   // sends the string (which is the file contents)
+      // sleep 1/frequency
       Wire.endTransmission(); // end I2C communcation.
   }
 }


arduino name convention

arduino name convention

--- examples/fade/fade.ino
+++ examples/fade/fade.ino
@@ -1,4 +1,4 @@
-#include <soft_table_pwm.h>
+#include <SoftTablePWM.h>

 int pwm_channel;


Simplify html page creation by using R() - a raw string.

--- software/firmware/LogoBotEsp8266/LogoBotEsp8266.ino
+++ software/firmware/LogoBotEsp8266/LogoBotEsp8266.ino
@@ -6,57 +6,60 @@
 ESP8266WebServer server(80);
 const int led = 2;

+const char page[] PROGMEM = R"~(
+
+<!DOCTYPE html>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+
+<title>Logobot Blue</title>
+
+
+Distance: <input type="text" id="dist" value="1000" />

+Backward :
+Forward

+
+

+
+Angle: <input type="text" id="angle" value="90" />

+Left :
+Right

+
+

+
+<button onclick="l('PU', null);">Pen Up</button>
+<button onclick="l('PD', null);">Pen Down</button>
+
+

+
+<button onclick="l('ST', null);">Stop</button>
+<button onclick="l('BZ', 500);">Horn</button>
+
+

+
+
:<span id="lastResp"

+
+
+
+
+
+
+)~";
+
 void handleRoot() {
   digitalWrite(led, 1);
-
-  String page = "<!DOCTYPE html>";
-  page += "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";
-  page += "";
-  page += "<title>Logobot Blue</title>";
-  page += "";
-
-  page += "Distance: <input type=\"text\" id=\"dist\" value=\"1000\" />
";
-  page += "Backward : ";
-  page += "Forward
";
-
-  page += "
";
-
-  page += "Angle: <input type=\"text\" id=\"angle\" value=\"90\" />
";
-  page += "Left: ";
-  page += "Right
";
-
-  page += "
";
-
-  page += "<button onclick=\"l('PU', null);\">Pen Up</button>";
-  page += "<button onclick=\"l('PD', null);\">Pen Down</button>";
-
-  page += "
";
-
-  page += "<button onclick=\"l('ST', null);\">Stop</button>";
-  page += "<button onclick=\"l('BZ', 500);\">Horn</button>";
-
-  page += "
";
-
-  page += "
:<span id=\"lastResp\"
";
-
-  page += "";
-
-  page += "";
-  page += "";
-
-  server.send(200, "text/html", page);
+  server.send(200, F("text/html"), page);
   digitalWrite(led, 0);
 }

@@ -69,7 +72,7 @@
   else if (server.hasArg("action"))
     Serial.println(server.arg("action"));

-  server.send(200, "text/plain", "ok");
+  server.send(200, F("text/plain"), "ok");

   digitalWrite(led, 0);
 }
@@ -87,14 +90,14 @@
   for (uint8_t i=0; i<server.args(); i++){
     message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
   }
-  server.send(404, "text/plain", message);
+  server.send(404, F("text/plain"), message);
   digitalWrite(led, 0);
 }

 void setup(void){
   Serial.begin(9600);
   Serial.println();
-  Serial.println("Logobot Wifi Interface");
+  Serial.println(F("Logobot Wifi Interface"));

   pinMode(led, OUTPUT);
   digitalWrite(led, 0);


Up to date Arbotix Sketch.

Up to date Arbotix Sketch.

--- sketch_jan30a/sketch_jan30a.ino
+++ sketch_jan30a/sketch_jan30a.ino
@@ -8,31 +8,64 @@
 void setup(){
    Serial.begin(38400);

-
-//Conor claims thrusters work this simply
     //thrustOne.attach(1);//arbitrary pin#
     //thrustTwo.attach(2);//arbitrary pin#
     //thrustThree.attach(3);//arbitrary pin#
 }
 void loop(){
     int i;
-    int input[5];
-    while(Serial.available()<5){
-      for (int i=0;i<5;i++){
-       input[i]=Serial.read();
+    int input[7];
+    int temp;
+    delay(500);
+    int characters[15];
+    Serial.print(Serial.available()+" ");
+    if(Serial.peek()==45){
+      Serial.read();
+      while(1){
+        if(Serial.available()==20){//will change to accomadate \n
+           Serial.print("In the if");
+           for (int i=0;i<15;i++){
+             int temp=(int)Serial.read();
+             if(temp!=42 && temp!=38){
+               characters[i]=temp;
+             }
+             else{
+              characters[i]=(int)Serial.read();
+             }
+           }
+           break;
+        }
       }
-      //implement delay later on with the math
-      SetPosition(servoNumOne,input[0]);
-      SetPosition(servoNumTwo,input[1]);
+    }
+    else{
+     Serial.println(Serial.read());
+    }
+      int* inputs = arrayToInt(characters);
+      SetPosition(servoNumOne,inputs[0]);
+      SetPosition(servoNumTwo,inputs[1]);

-      thrustOne.write(input[2]);
-      thrustTwo.write(input[3]);
-      thrustThree.write(input[4]);
+      thrustOne.write(inputs[2]);
+      thrustTwo.write(inputs[3]);
+      thrustThree.write(inputs[4]);
+    }

-    }

-    //Something nifty to think about:
-    //Arbotix cant support 2 traditional PWM servos,
-    //meaning our three thrusters might run into a problem with that
-
-}
+   int* arrayToInt(int list[]){
+     String int1 = (String)list[0]+(String)list[1]+(String)list[2];
+     int servoOne=int1.toInt();
+
+     String int2 = (String)list[3]+(String)list[4]+(String)list[5];
+     int servoTwo=int1.toInt();
+
+     String int3 = (String)list[6]+(String)list[7]+(String)list[8];
+     int thrustOne=int1.toInt();
+
+     String int4 = (String)list[9]+list[10]+list[11];
+     int thrustTwo=int1.toInt();
+
+     String int5 = (String)list[12]+list[13]+list[14];
+     int thrustThree=int1.toInt();
+
+     int returnVal[5] = {servoOne, servoTwo, thrustOne, thrustTwo, thrustThree};
+     return returnVal;
+   }


Can you hear Woodi? Cuz I can't

Can you hear Woodi? Cuz I can't

--- discont/Motor_Shield/MotorShield/MotorShield.ino
+++ discont/Motor_Shield/MotorShield/MotorShield.ino
@@ -92,6 +92,9 @@
   Serial.println();
   Serial.flush();
   Serial.println("Ready");
+
+  setPwmFrequency(6, 1);
+  setPwmFrequency(9, 1);
 }

 boolean gotCommand = false;
@@ -119,7 +122,7 @@
     Serial.print(dT_sec);
     Serial.print('\n');
   }
-
+  /*
   //Serial.println(tickDataLeft);
   if( millis() - lastCmdTime > 500)
   {
@@ -129,7 +132,7 @@
     PWM_L = 0;
     PWM_R = 0;
   }
-
+  `*/
   dT_sec = (float)( millis() - lastLoopTime ) / 1000.0;
   lastLoopTime = millis();
   //actualSpeedL = ( metersPerTick * tickDataLeft ) / dT_sec;
@@ -223,3 +226,65 @@
   }
 }

+/**
+ * Divides a given PWM pin frequency by a divisor.
+ *
+ * The resulting frequency is equal to the base frequency divided by
+ * the given divisor:
+ *   - Base frequencies:
+ *      o The base frequency for pins 3, 9, 10, and 11 is 31250 Hz.
+ *      o The base frequency for pins 5 and 6 is 62500 Hz.
+ *   - Divisors:
+ *      o The divisors available on pins 5, 6, 9 and 10 are: 1, 8, 64,
+ *        256, and 1024.
+ *      o The divisors available on pins 3 and 11 are: 1, 8, 32, 64,
+ *        128, 256, and 1024.
+ *
+ * PWM frequencies are tied together in pairs of pins. If one in a
+ * pair is changed, the other is also changed to match:
+ *   - Pins 5 and 6 are paired on timer0
+ *   - Pins 9 and 10 are paired on timer1
+ *   - Pins 3 and 11 are paired on timer2
+ *
+ * Note that this function will have side effects on anything else
+ * that uses timers:
+ *   - Changes on pins 3, 5, 6, or 11 may cause the delay() and
+ *     millis() functions to stop working. Other timing-related
+ *     functions may also be affected.
+ *   - Changes on pins 9 or 10 will cause the Servo library to function
+ *     incorrectly.
+ *
+ * Thanks to macegr of the Arduino forums for his documentation of the
+ * PWM frequency divisors. His post can be viewed at:
+ *   http://forum.arduino.cc/index.php?topic=16612#msg121031
+ */
+void setPwmFrequency(int pin, int divisor) {
+  byte mode;
+  if(pin == 5 || pin == 6 || pin == 9 || pin == 10) {
+    switch(divisor) {
+      case 1: mode = 0x01; break;
+      case 8: mode = 0x02; break;
+      case 64: mode = 0x03; break;
+      case 256: mode = 0x04; break;
+      case 1024: mode = 0x05; break;
+      default: return;
+    }
+    if(pin == 5 || pin == 6) {
+      TCCR0B = TCCR0B & 0b11111000 | mode;
+    } else {
+      TCCR1B = TCCR1B & 0b11111000 | mode;
+    }
+  } else if(pin == 3 || pin == 11) {
+    switch(divisor) {
+      case 1: mode = 0x01; break;
+      case 8: mode = 0x02; break;
+      case 32: mode = 0x03; break;
+      case 64: mode = 0x04; break;
+      case 128: mode = 0x05; break;
+      case 256: mode = 0x06; break;
+      case 1024: mode = 0x07; break;
+      default: return;
+    }
+    TCCR2B = TCCR2B & 0b11111000 | mode;
+  }
+}


play melody when sensor is wet (WIP)

play melody when sensor is wet (WIP)

--- arduino-singing-rain-detector.ino
+++ arduino-singing-rain-detector.ino
@@ -1,33 +1,44 @@
-/*
-  Melody
-
- Plays a melody
-
- circuit:
- * 8-ohm speaker on digital pin 8
-
- http://arduino.cc/en/Tutorial/Tone
-
- */
 #include "pitches.h"
 #include "melody.h"

+const int sensorMin = 0;     // sensor minimum
+const int sensorMax = 1024;  // sensor maximum
+
 void setup() {
   Serial.begin(9600);
-  buzzerSound();
 }

 void loop() {
-  // no need to repeat the melody.
+  // read the sensor on analog A0:
+  int sensorReading = analogRead(A0);
+  // map the sensor range (four options):
+  // ex: 'long int map(long int, long int, long int, long int, long int)'
+  int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
+
+  // range value:
+  switch (range) {
+    case 0:    // Sensor getting wet
+      Serial.println("Flood");
+      buzzerSound();
+      break;
+    case 1:    // Sensor getting wet
+      Serial.println("Rain Warning");
+      buzzerSound();
+      break;
+    case 2:    // Sensor dry - To shut this up delete the " Serial.println("Not Raining"); " below.
+      Serial.println("Not Raining");
+      break;
+  }
+  delay(1);  // delay between reads
 }

 void buzzerSound() {
   Serial.println(sizeof(melody));
   Serial.println(sizeof(melody[0]));
-  for (int thisNote = 0; thisNote < sizeof(melody)/sizeof(melody[0]); thisNote++) {
+  for (int thisNote = 0; thisNote < sizeof(melody) / sizeof(melody[0]); thisNote++) {
     int noteDuration = 1000 * melody[thisNote].duration;
     Serial.println(melody[thisNote].duration);
-    Serial.println(melody[thisNote].duration);
+    Serial.println(melody[thisNote].duration);
     tone(2, melody[thisNote].pitch, noteDuration);

     // to distinguish the notes, set a minimum time between them.
@@ -36,5 +47,5 @@
     delay(pauseBetweenNotes);
     // stop the tone playing:
     // noTone(2);
-  }
+  }
 }


Fix merge issue

Fix merge issue

--- arduino/car_system/car_system.ino
+++ arduino/car_system/car_system.ino
@@ -38,6 +38,9 @@

 // This method returns whether the proximity sensor reads within
 // the proximity threshold.
+//
+// Configured for the SRF05 Ultrasonic Sensor:
+// http://www.robot-electronics.co.uk/htm/srf05tech.htm
 bool ProximityActivated() {
   digitalWrite(pinProximityTrigger, LOW);
   delay(2);
@@ -46,9 +49,11 @@
   digitalWrite(pinProximityTrigger, LOW);

   unsigned long distance = pulseIn(pinProximityEcho, HIGH);
-  // Divided by 2 because the sound travels twice the distance
-  // Speed of sound is 343m/sec = 0.0343cm/μs = [1/29.1] cm/μs
-  distance = (distance/2) / 29;
+
+  // Divided by 29 because the speed of sound is
+  //   343m/sec = 0.0343cm/μs = [1/29.1] cm/μs
+  distance = distance / 2 / 29;
+
   return distance < thresholdProximity;
 }


dht11 for ext

dht11 for ext

--- sketches/monitor_nodown/monitor_nodown.ino
+++ sketches/monitor_nodown/monitor_nodown.ino
@@ -15,7 +15,8 @@
 #define DHT_EXTERNAL_PIN A1
 #define VOLTS_PIN A2
 #define AMPS_PIN A3
-#define DHT_TYPE DHT22
+#define DHT_INTERNAL_TYPE DHT22
+#define DHT_EXTERNAL_TYPE DHT11

 /* --- Constants --- */
 const unsigned int BAUD = 9600;
@@ -38,8 +39,8 @@
 float get_pressure(void);

 /* --- Objects --- */
-DHT int_dht(DHT_INTERNAL_PIN, DHT_TYPE);
-DHT ext_dht(DHT_EXTERNAL_PIN, DHT_TYPE);
+DHT int_dht(DHT_INTERNAL_PIN, DHT_INTERNAL_TYPE);
+DHT ext_dht(DHT_EXTERNAL_PIN, DHT_EXTERNAL_TYPE);
 Adafruit_BMP085 bmp;

 /* --- Variables --- */


Set ENABLE_SENSOR_PIN as OUTPUT.

Set ENABLE_SENSOR_PIN as OUTPUT.

--- wifi-feather/wifi-feather.ino
+++ wifi-feather/wifi-feather.ino
@@ -46,6 +46,9 @@
   delay(100);

   Serial.println("\nStarting");
+
+  pinMode(ENABLE_SENSOR_PIN, OUTPUT);
+  digitalWrite(ENABLE_SENSOR_PIN, LOW);

   EEPROM.begin(pending_messages_queue::storage_size(MAX_PENDING_MESSAGES));
 //  delete_messages();