Refactored the code, and added UTC timestamps to the logged data (untested)

--- Balloon/Balloon.ino
+++ Balloon/Balloon.ino
@@ -50,11 +50,12 @@

 // *********************************************************************
 // GPS receiver settings/variables
-SoftwareSerial gpsSerial(10, 9); // RX, TX (TX not used)
+SoftwareSerial GPSReceiver(10, 9); // RX, TX (TX not used)
 const int sentenceSize = 80;
-char sentence[sentenceSize];
+char GPSRawData[sentenceSize];
 float CurrentLatitude;
 float CurrentLongitude;
+int CurrentTimeStamp;

 void setup(void) {
@@ -70,9 +71,10 @@

   DataLogger.begin(9600);

-  gpsSerial.begin(9600);
+  GPSReceiver.begin(9600);
   CurrentLatitude = 0.0;
   CurrentLongitude = 0.0;
+  CurrentTimeStamp = 0;

   HasGoodGPSReading = false;
   HasGoodTempReading = false;
@@ -84,31 +86,33 @@
   if(!HasGoodGPSReading)
   {
     static int i = 0;
-    if(!gpsSerial.isListening()) { gpsSerial.listen(); }
-    if (gpsSerial.available())
+    if(!GPSReceiver.isListening()) { GPSReceiver.listen(); }
+    if (GPSReceiver.available())
     {
-      char ch = gpsSerial.read();
+      char ch = GPSReceiver.read();

       if(ch == '$') { i = 0; }

       if (ch != '\n' && i < sentenceSize)
       {
-        sentence[i] = ch;
+        GPSRawData[i] = ch;
         i++;
       }
       else
       {
-        sentence[i] = '\0';
+        GPSRawData[i] = '\0';
         i = 0;

-        char field[20];
-        getField(field, 0);
-        if(strcmp(field, "$GPRMC") == 0)
+        char GPSComponent[20];
+        ExtractGPSComponent(GPSComponent, 0);
+        if(strcmp(GPSComponent, "$GPRMC") == 0)
         {
-          getField(field, 3);
-          CurrentLatitude = atof(field);
-          getField(field, 5);
-          CurrentLongitude = atof(field);
+          ExtractGPSComponent(GPSComponent, 1);
+          CurrentTimeStamp = atoi(GPSComponent);
+          ExtractGPSComponent(GPSComponent, 3);
+          CurrentLatitude = atof(GPSComponent);
+          ExtractGPSComponent(GPSComponent, 5);
+          CurrentLongitude = atof(GPSComponent);

           HasGoodGPSReading = true;
         }
@@ -136,8 +140,8 @@
     CurrentPressure = GetPressure(bmp085ReadUT(), bmp085ReadUP());
     CurrentAltitude = CalculateAltitude(CurrentPressure);

-    PrintToSerialOutput(CurrentTemp, CurrentPressure, CurrentAltitude, CurrentLatitude, CurrentLongitude);
-    WriteDataToLogger(CurrentTemp, CurrentPressure, CurrentAltitude, CurrentLatitude, CurrentLongitude);
+    PrintToSerialOutput(CurrentTimeStamp, CurrentTemp, CurrentPressure, CurrentAltitude, CurrentLatitude, CurrentLongitude);
+    WriteDataToLogger(CurrentTimeStamp, CurrentTemp, CurrentPressure, CurrentAltitude, CurrentLatitude, CurrentLongitude);

     // TODO: What data do we write to the radio?
     // TODO: How frequently should we write data to the radio?
@@ -152,12 +156,14 @@

-void PrintToSerialOutput(float Temperature, float Pressure, float Altitude, float Latitude, float Longitude) {
+void PrintToSerialOutput(int TimeStamp, float Temperature, float Pressure, float Altitude, float Latitude, float Longitude) {

   // We print each component of the data line using separate calls instead of using something like sprintf to
   // format a single string.  This is done because the version of sprintf available to us for the Arduino does
   // not support floats.  This was the simplest Plan B we could come up with.

+  Serial.print(TimeStamp);
+  Serial.print(",");
   Serial.print(Temperature, 2);
   Serial.print(",");
   Serial.print(Pressure, 0);
@@ -171,9 +177,11 @@
 }

-void WriteDataToLogger(float Temperature, float Pressure, float Altitude, float Latitude, float Longitude) {
+void WriteDataToLogger(int TimeStamp, float Temperature, float Pressure, float Altitude, float Latitude, float Longitude) {
   if(!DataLogger.isListening()) { DataLogger.listen(); }

+  DataLogger.print(TimeStamp);
+  DataLogger.print(",");
   DataLogger.print(Temperature, 2);
   DataLogger.print(",");
   DataLogger.print(Pressure, 0);
@@ -415,21 +423,21 @@

 // *********************************************************************
 // GPS Receiver subroutines
-void getField(char* buffer, int index)
+void ExtractGPSComponent(char* buffer, int index)
 {
   int sentencePos = 0;
   int fieldPos = 0;
   int commaCount = 0;
   while (sentencePos < sentenceSize)
   {
-    if (sentence[sentencePos] == ',')
+    if (GPSRawData[sentencePos] == ',')
     {
       commaCount ++;
       sentencePos ++;
     }
     if (commaCount == index)
     {
-      buffer[fieldPos] = sentence[sentencePos];
+      buffer[fieldPos] = GPSRawData[sentencePos];
       fieldPos ++;
     }
     sentencePos ++;


Delete map_code.ino

Delete map_code.ino

--- map_code/map_code.ino
+++ map_code/map_code.ino
@@ -1,16 +0,0 @@
-void setup() {
-  // list all the pins needed
-  // do I have to reference the shield here?
-
-}
-
-void loop() {
-  // when clock is at 6 am or 6pm:
-  //  connect to the internet
-  //  location =  gps data
-
-  // if latitude > location > latitude:
-  //  light up LED
-  // elf latitude >location > latitude:
-  // light up other LED
-}


Minor ethernet sketch changes

Minor ethernet sketch changes

--- src/du_ethernet.ino
+++ src/du_ethernet.ino
@@ -3,7 +3,7 @@
 #include <Ethernet.h>

 // Configure your MAC address, IP address, and HTTP port here.
-byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
+byte mac[] = { 0xDE, 0xAD, 0xBE, 0x30, 0x31, 0x32 };
 IPAddress ip(192,168,0,77);
 int port = 80;

@@ -40,12 +40,10 @@
   client = server.available();

   // Handle a connection.
-  if (client) {
-    while (client.connected()) {
-      while (client.available()) dino.parse(client.read());
-      dino.updateListeners();
-    }
-    client.stop();
+  while (client.connected()) {
+    while (client.available()) dino.parse(client.read());
+    dino.updateListeners();
   }
+  client.stop();
 }


Delay reads a bit and get status

Delay reads a bit and get status

--- ATM90E26.ino
+++ ATM90E26.ino
@@ -24,6 +24,8 @@

 void loop() {
   /*Repeatedly fetch some values from the ATM90E26 */
+  Serial.print("Status:");
+  Serial.println(GetSysStatus());
   Serial.print("Voltage:");
   Serial.println(GetLineVoltage());
   Serial.print("Current:");
@@ -32,4 +34,5 @@
   Serial.println(GetActivePower());
   Serial.print("p.f.:");
   Serial.println(GetPowerFactor());
+  delay(1000);
 }


After a reset, start with the yellow light on

--- traffic.ino
+++ traffic.ino
@@ -39,7 +39,7 @@
   pinMode(yellow, OUTPUT);
   pinMode(green, OUTPUT);
   digitalWrite(red, LOW);
-  digitalWrite(yellow, LOW);
+  digitalWrite(yellow, HIGH);
   digitalWrite(green, LOW);
   Spark.function("build", build);
 }


Save tftbrightness if it is changed on the touch screen.

--- tfttask.ino
+++ tfttask.ino
@@ -202,9 +202,10 @@
     else if ( button.pressed( BL_SLIDER_AREA , clickedLocation ) )
     {
       static uint16_t oldLocation;
-      if ( !( clickedLocation.y == oldLocation ) )
+      if (  clickedLocation.y != oldLocation )
       {
         tftBrightness = map( clickedLocation.y , BL_SLIDER_YPOS, BL_SLIDER_HEIGHT + BL_SLIDER_YPOS, 100, 0 );
+        preferences.putFloat( "tftbrightness", tftBrightness );
         oldLocation = clickedLocation.y;
       }
     }


COH-66: sleep seems longer than REV2 board.

However no lockup/crash and total of ~4.5s (100 x 15+15_15ms)
about what is to be expected.

--- test/test.ino
+++ test/test.ino
@@ -464,8 +464,8 @@
   const uint8_t eaTestPattern = 0xa5; // Test pattern for masking (selective bit clearing).
   if(0 != ((~eaTestPattern) & eeprom_read_byte((uint8_t*)V0P2BASE_EE_START_TEST_LOC2))) // Will need to clear some bits.
     {
-      AssertIsTrue(OTV0P2BASE::eeprom_smart_clear_bits((uint8_t*)V0P2BASE_EE_START_TEST_LOC2, eaTestPattern)); // Should have attempted write.
-      AssertIsEqual(0, ((~eaTestPattern) & eeprom_read_byte((uint8_t*)V0P2BASE_EE_START_TEST_LOC2))); // Should have written.
+    AssertIsTrue(OTV0P2BASE::eeprom_smart_clear_bits((uint8_t*)V0P2BASE_EE_START_TEST_LOC2, eaTestPattern)); // Should have attempted write.
+    AssertIsEqual(0, ((~eaTestPattern) & eeprom_read_byte((uint8_t*)V0P2BASE_EE_START_TEST_LOC2))); // Should have written.
     }
   AssertIsTrue(!OTV0P2BASE::eeprom_smart_clear_bits((uint8_t*)V0P2BASE_EE_START_TEST_LOC2, eaTestPattern)); // Should not need write nor attempt one.
   }


fix log output

fix log output

--- KomaRoof.ino
+++ KomaRoof.ino
@@ -143,7 +143,7 @@
     logMessage += ",";
     logMessage += msg;

-    Serial.print(logMessage);
+    serial.print(logMessage);
 }

 void loop() {


added randomColor function, runallAnimations

--- wip/wip.ino
+++ wip/wip.ino
@@ -12,74 +12,7 @@
 }

 void loop() {
-  // int randred = random8(100);
-  // int randgreen = random8(100);
-  // int randblue = random8(100);
-  // progressbar(leds, NUM_LEDS, randred,randgreen,randblue, 30);
-  // randred = random8(100);
-  // randgreen = random8(100);
-  // randblue = random8(100);
-  // runner(leds, NUM_LEDS, randred,randgreen,randblue, 30);
-  // randred = random8(100);
-  // randgreen = random8(100);
-  // randblue = random8(100);
-  // blinking(leds, NUM_LEDS, randred,randgreen,randblue, 800);
-  // randred = random8(100);
-  // randgreen = random8(100);
-  // randblue = random8(100);
-  // blinking(leds, NUM_LEDS, randred,randgreen,randblue, 800);
-  // randred = random8(100);
-  // randgreen = random8(100);
-  // randblue = random8(100);
-  // blinking(leds, NUM_LEDS, randred,randgreen,randblue, 800);
-  // randred = random8(100);
-  // randgreen = random8(100);
-  // randblue = random8(100);
-  // progressbarCentered(leds, NUM_LEDS, randred,randgreen,randblue, 30);
-  // randred = random8(100);
-  // randgreen = random8(100);
-  // randblue = random8(100);
-  // runner(leds, NUM_LEDS, randred,randgreen,randblue, 30);
-
-//  sparkleAt(10, leds, NUM_LEDS, 25, 0, 0, 1000);
-//  sparkleAtRandomIndex(leds, NUM_LEDS, 25, 0, 0, 500);
-
-
-//  for (int i = 0; i < NUM_LEDS; i++){
-//    sparkleAt(i, leds, NUM_LEDS, 0, 0, 25, 350);
-//  }
-//
-//  for (int i = (NUM_LEDS - 1); i >=0; i--){
-//    sparkleAt(i, leds, NUM_LEDS, 0, 0, 25, 350);
-//  }
-
-//  flashyShit(leds, NUM_LEDS, 2000);
-//  int randred = random8(50);
-//  int randgreen = random8(50);
-//  int randblue = random8(50);
-//  randomIndexFill(leds, NUM_LEDS, 0, 30, 10, 2600);
-
-//  void sparkleAt(int index, CRGB *leds, int numOfLeds, int red, int green, int blue, int ms){
-
-
-//  for (int i = 0; i < NUM_LEDS; i++){
-//    sparkleAt(i, leds, NUM_LEDS, 0, 0, 25, 350);
-//  }
-//
-//  for (int i = (NUM_LEDS - 1); i >=0; i--){
-//  sparkleAt(i, leds, NUM_LEDS, 0, 0, 25, 350);
-//  }
-
-//  CRGB test = CRGB(10,10,10);
-//
-//  for (int i = 0; i < NUM_LEDS; i++){
-//    leds[i] = test;
-//    FastLED.show();
-//    delay(500);
-//  }
-//
-//  clearAll(leds, NUM_LEDS);
-  runner(leds, NUM_LEDS, CRGB(10,0,20), 3000);
+  runAllAnimations(leds, NUM_LEDS, 40, 3500);
 }

 void runner(CRGB *leds, int numOfLeds, CRGB color, int duration) {
@@ -285,7 +218,7 @@
   sparkleAt(randomIndex, leds, numOfLeds, color, ms);
 }

-void flashyShit(CRGB *leds, int numOfLeds, int ms, int maxIntensity){
+void flashyShit(CRGB *leds, int numOfLeds, int maxIntensity, int ms){
   int middle = numOfLeds / 2;
   int randred,randgreen,randblue;

@@ -351,3 +284,32 @@
   }
   FastLED.show();
 }
+
+CRGB randomColor(int maxIntensity){
+  if (maxIntensity <= 255){
+    int randred = random8(maxIntensity);
+    int randgreen = random8(maxIntensity);
+    int randblue = random8(maxIntensity);
+
+    return CRGB(randred, randgreen, randblue);
+  }else{
+    // u stupid
+    return CRGB::Black;
+  }
+
+}
+
+void runAllAnimations(CRGB *leds, int numOfLeds, int maxIntensity, int durationEach){
+
+  runner(leds, numOfLeds, randomColor(maxIntensity), durationEach);
+  progressbar(leds, numOfLeds, randomColor(maxIntensity), durationEach);
+  progressbarCentered(leds, numOfLeds, randomColor(maxIntensity), durationEach);
+  blinking(leds, numOfLeds, randomColor(maxIntensity), durationEach);
+  blinkingParts(leds, numOfLeds,5, randomColor(maxIntensity), durationEach);
+  pulse(leds, numOfLeds, randomColor(maxIntensity), durationEach);
+  sparkleAtRandomIndex(leds, numOfLeds, randomColor(maxIntensity), durationEach);
+  flashyShit(leds, numOfLeds,maxIntensity, durationEach);
+  randomIndexFill(leds, numOfLeds, randomColor(maxIntensity), durationEach);
+  clearAll(leds, numOfLeds);
+
+}


Data transfer to server corrected

Data transfer to server corrected

--- test_configSIM808.ino
+++ test_configSIM808.ino
@@ -5,6 +5,8 @@
 #include <SimpleTimer.h>
 #define rxPin 2
 #define txPin 3
+#define CTRL(x) (#x[0]-'a'+1)
+
 SoftwareSerial GPRS(rxPin, txPin); // RX, TX
 //DFRobot_SIM808 sim808(&GPRS);
 SimpleTimer timer;
@@ -27,6 +29,7 @@
 String tiff;
 String Speed;
 String course;
+//char data2db[]="410.869,111.222\032\032";
 char data2db[]="410.869,111.222";
 byte pos = 0;  //WHAT POSITION WE ARE AT IN THAT BUFFER
 //my variables MKY
@@ -36,8 +39,8 @@
 String content = "";
 char character;
 char bufferTCP[10];
-char bufferSerial[BUFFER_SIZE];  // CREATE THIS BUFFER IN ORDER TO READ SERIAL AT ONCE
-char infoLocation[BUFFER_SIZE];
+//T char bufferSerial[BUFFER_SIZE];  // CREATE THIS BUFFER IN ORDER TO READ SERIAL AT ONCE
+//T1 char infoLocation[BUFFER_SIZE];
 char buffer[20];                 // WHAT WE ARE READING INTO
 int posTemp;
 int posBuf;
@@ -103,8 +106,8 @@
   power();                     // power on the sim808 or power down the sim808

   Serial.println("reseting");
-  delay(60000);
-
+  //T delay(60000);
+  delay(10000);
   /******************************************************
    * GPS Configuration
    ******************************************************/
@@ -222,6 +225,8 @@
  * variables and finally print the information at Serial interface for debugging.
  ****************************************************************************************/
 void GetGPSLocation(){
+char infoLocation[BUFFER_SIZE];
+
   while(GPRS.available()){
     GPRS.read();
   }
@@ -247,12 +252,10 @@
    //Serial.println(i);

    //Copy buffered information in GPRS serial port and the last position of array.
-   strcpy(bufferSerial,infoLocation);
+   //T strcpy(bufferSerial,infoLocation);
    posTemp = posBuf;
-   resetInfoLocationBuffer(); //clean the just received data in the GPRS buffer
-
-   //Serial.print("Buffer state after CGPSINF=0 : ");
-   //Serial.println(bufferSerial);
+   //T resetInfoLocationBuffer(); //clean the just received data in the GPRS buffer
+

    //exit condition for parse the GPS location
    matchLocationMessage = true;
@@ -260,7 +263,8 @@
    //parse each character of buffer to extract GPS information
    for(int i =0; i<posTemp; i++){
     if(matchLocationMessage==true){
-      GPSAnalyzer(bufferSerial[i]);
+      //T GPSAnalyzer(bufferSerial[i]);
+      GPSAnalyzer(infoLocation[i]);
     }
    }

@@ -276,11 +280,11 @@
   pos = 0;
 }//BASICALLY TO RESET THE BUFFER

-void resetInfoLocationBuffer()
+/*void resetInfoLocationBuffer()
 {
   memset(infoLocation, 0, sizeof(buffer));
   posBuf = 0;
-}//BASICALLY TO RESET THE BUFFER
+}//BASICALLY TO RESET THE BUFFER*/

 void PrintSecondsElapsed(){
   Serial.print("******************Seconds : ");
@@ -300,35 +304,60 @@

   //Get the remote IP address
   //GPRS.println("AT+CDNSGIP=\"ardugps.hopto.org\"");
-  if(!sim808_check_with_cmd("AT+CDNSGIP=\"ardugps.hopto.org\"\r\n","OK\r\n",CMD)){
+/*  if(!sim808_check_with_cmd("AT+CDNSGIP=\"ardugps.hopto.org\"\r\n","OK\r\n",CMD)){
     Serial.println("AT+CDNSGIP => FAIL");
-  }else Serial.println("AT+CDNSGIP => OK");
-
+  }else Serial.println("AT+CDNSGIP => OK"); */
+  delay(3000);
   //GPRS.println("AT+CIPSTART=\"TCP\",\"ardugps.hopto.org\",6789");
   if(!sim808_check_with_cmd("AT+CIPSTART=\"TCP\",\"ardugps.hopto.org\",6789\r\n","OK\r\n",CMD)){
     Serial.println("AT+CIPSTART => FAIL");
   }else Serial.println("AT+CIPSTART => OK");
+
+  delay(3000);

   //Send data to remote connection
   //GPRS.println("AT+CIPSEND");
-  if(!sim808_check_with_cmd("AT+CIPSEND\r\n","\>\r\n",CMD)){
+  /*if(!sim808_check_with_cmd("AT+CIPSEND\r\n","\>",CMD)){
     Serial.println("AT+CIPSEND => FAIL");
   }else Serial.println("AT+CIPSEND => OK");

-  GPRS.write(data2db);
+  delay(1000);
+  GPRS.write(data2db);
   //sim808_send_cmd(data2db);
   //Equivalent to sending Ctrl+Z
   //GPRS.write(char(26));
   //delay(3000);
-  delay(500);
-  sim808_send_End_Mark();
+  //delay(500);
+  sim808_send_End_Mark(); */
   /*if(!sim808_wait_for_resp("OK\r\n", CMD)){
     Serial.println("AT+CIPSEND EndMark => FAIL");
   }else Serial.println("AT+CIPSEND EndMark => OK");  */
+
+  if(!SendDataCIPSEND(data2db,sizeof(data2db))){
+    Serial.println("CIPSEND => FAIL");
+  }
+  else{
+    Serial.println("CIPSEND => OK");
+  }
+
+  delay(3000);
+
+
+  if (!CheckConnectionStatus()) {
+    Serial.println("Uno was not connected to Server");
+  }
+  else{
+    sim808_check_with_cmd("AT+CIPCLOSE\r\n", "CLOSE OK\r\n", CMD);
+    Serial.println("Uno was disconnected from Server");
+  }
+  delay(1000);

   //Close remote connection
-  /*GPRS.println("AT+CIPCLOSE");
-  if(!sim808_check_with_cmd("AT+CIPCLOSE\r\n","\>\r\n",CMD)){
+  //GPRS.println("AT+CIPCLOSE\r\n");
+
+
+
+  /*if(!sim808_check_with_cmd("AT+CIPCLOSE\r\n","\OK\r\n",CMD)){
     Serial.println("AT+CIPCLOSE => FAIL");
   }else Serial.print("AT+CIPCLOSE => OK");    */

@@ -379,9 +408,44 @@

 }

-
-
-
+int SendDataCIPSEND(const char * str, int len)
+{
+char num[4];
+if(len > 0){
+  sim808_send_cmd("AT+CIPSEND=");
+  itoa(len, num, 10);
+  sim808_send_cmd(num);
+  if(!sim808_check_with_cmd("\r\n","\>",CMD)) {
+    return 0;
+  }
+  /*if(0 != sim808_check_with_cmd(str,"SEND OK\r\n", DEFAULT_TIMEOUT * 10 ,DATA)) {
+        return 0;
+  }*/
+  delay(500);
+  sim808_send_cmd(str);
+  delay(500);
+  sim808_send_End_Mark();
+  if(!sim808_wait_for_resp("SEND OK\r\n", DATA, DEFAULT_TIMEOUT * 10, DEFAULT_INTERCHAR_TIMEOUT * 10)) {
+      return 0;
+  }
+}
+return len;
+}
+
+bool CheckConnectionStatus(void)
+{
+    char resp[96];
+    sim808_send_cmd("AT+CIPSTATUS\r\n");
+    sim808_read_buffer(resp,sizeof(resp),DEFAULT_TIMEOUT);
+    if(NULL != strstr(resp,"CONNECTED")) {
+        //+CIPSTATUS: 1,0,"TCP","216.52.233.120","80","CONNECTED"
+        return true;
+    } else {
+        //+CIPSTATUS: 1,0,"TCP","216.52.233.120","80","CLOSED"
+        //+CIPSTATUS: 0,,"","","","INITIAL"
+        return false;
+    }
+}

 // =====================================================================
 // Analyze the Serial information received after request the information


UI changed

UI changed

--- hal100/hal100.ino
+++ hal100/hal100.ino
@@ -125,18 +125,6 @@
 }

 void displayInitialScreen() {                      // displays "Wait Calibrating at start. To be linked to Motors "L" and "C" calibration process
-  for (i = 0; i < 1; i++) {                        // repeats following process for i-times
-    TFTscreen.stroke(255, 255, 0);
-    TFTscreen.setTextSize(2);
-    TFTscreen.text("WAIT", 50, 20);
-    TFTscreen.text("CALIBRATING", 0, 40);
-    delay(1000);
-    TFTscreen.stroke(0, 20, 30);
-    TFTscreen.text("WAIT", 50, 20);
-    TFTscreen.text("CALIBRATING", 0, 40);
-    delay(500);
-  }
-
   // Displays "Set F:" at the bottom of the screen
   TFTscreen.stroke(0, 255, 0);                      // set the font color
   TFTscreen.setTextSize(1);                         // set the font size 2
@@ -146,11 +134,11 @@
   // Displays L
   TFTscreen.stroke(0, 255, 0);                      // set the font color
   TFTscreen.setTextSize(2);                         // set the font size 2
-  TFTscreen.text("uH", 30, 55);                     // write the text to coordinates
+  TFTscreen.text("Ln", 5, 40);                     // write the text to coordinates
   // Displays C
-  TFTscreen.stroke(0, 255, 0);                      // set the font color
+  TFTscreen.stroke(0, 255, 0);                      // set the font color
   TFTscreen.setTextSize(2);                         // set the font size 2
-  TFTscreen.text("pF", 90, 55);                     // write the text to coordinates
+  TFTscreen.text("Cn", 5, 60);                     // write the text to coordinates

   keypad.addEventListener(keypadEvent);             //add an event listener for this keypad
 }
@@ -232,29 +220,29 @@
 }

 void displayL() {                                         // display L values
-  dtostrf(valueL, 5, 2, DisplayValueL);
+  dtostrf(valueRotateL, 5, 2, DisplayValueL);
   TFTscreen.stroke(0, 255, 0);
   TFTscreen.setTextSize(2);
-  TFTscreen.text(DisplayValueL, 5, 75);
+  TFTscreen.text(DisplayValueL, 40, 40);
 }

 void EraseDisplayL() {                                   // erase display L values
   TFTscreen.stroke(0, 20, 30);
   TFTscreen.setTextSize(2);
-  TFTscreen.text(DisplayValueL, 5, 75);
+  TFTscreen.text(DisplayValueL, 40, 40);
 }

 void displayC() {                                       // display C values
-  dtostrf(valueC, 5, 0, DisplayValueC);
+  dtostrf(valueRotateC1, 5, 0, DisplayValueC);
   TFTscreen.stroke(0, 255, 0);
   TFTscreen.setTextSize(2);
-  TFTscreen.text(DisplayValueC, 60, 75);
+  TFTscreen.text(DisplayValueC, 40, 60);
 }

 void EraseDisplayC() {                                   // erase display C values
   TFTscreen.stroke(0, 20, 20);
   TFTscreen.setTextSize(2);
-  TFTscreen.text(DisplayValueC, 60, 75);
+  TFTscreen.text(DisplayValueC, 40, 60);
 }

 void eraseFrequency() {                         // when * pressed - erases entered frequency bottom of the screen


Notes

Notes

--- AudioLed.ino
+++ AudioLed.ino
@@ -1,6 +1,6 @@
 #include <Adafruit_WS2801.h>
-#include <IRremote.h>
-//#define DEBUG
+#include <IRremote.h>        /*DON'T FORGET TO SET SEND_NEC 1*/
+#define USE_RAW_VOLUME 0
 #undef DEBUG

 #include <AudioLed.h>


adjust application title

adjust application title

--- uie-05-arduino-pet-feed.ino
+++ uie-05-arduino-pet-feed.ino
@@ -23,7 +23,7 @@
 void setup() {
   Serial.begin(19200);
   lcd.begin(16, 2);
-  lcd.print(" UIE Pet-Feeder");
+  lcd.print(" UIE Pet-Feed");
   servo.attach(servoPin);

   attachInterrupt(digitalPinToInterrupt(incButtonPin), inc, RISING);


Implementing motor control

Implementing motor control

--- src/motor_drive/motor_drive.ino
+++ src/motor_drive/motor_drive.ino
@@ -1,4 +1,5 @@

+#include <math.h>
 #include "MotorCommand.h"
 #include "VirtualMotor.h"

@@ -24,19 +25,69 @@
 void loop() {
 }

-void doSteps(int pin, int steps, int delayInterval) {
+// A function with continuous 1st derivative
+// in the domain (0,1), with range (0,1)
+double smoothMapping(double x) {
+  return 0.5*(1 - cos(x));
+}
+
+// delayInterval in microseconds
+void doSteps(int pin, int steps, long delayInterval) {
   for (int i = 0; i < steps; ++i) {
     digitalWrite(pin, HIGH);
-    delay(delayInterval);
+    delayMicroseconds(delayInterval);
     digitalWrite(pin, LOW);
-    delay(delayInterval);
+    delayMicroseconds(delayInterval);
   }
 }
+
+// The factor f is choosen such that for a given number
+// of sections n,
+//
+//   sum(f * 1/n * sin(pi * ((0.5/n):(1/n):(1-0.5/n)))) == 1.000
+//
+// This is to ensure that the smooth and linear
+// version both have the same duration for
+// a given number of steps.
+const double integralFactor = 1.5643;
+
+double continuousDerivativeAdjustment(double in) {
+  return integralFactor * sin(PI * in);
+}
+
+void doSmoothSteps(int pin, int steps, long delayInterval) {
+  int section = 10;
+  if (steps <= section) {
+    doSteps(pin, steps, delayInterval);
+    return;
+  }

+  int sectionSteps = steps / section;
+  int remainder = steps % section;
+
+  for (int i = 0; i < section; ++i) {
+    if (remainder == 0) {
+      doSteps(pin, sectionSteps, delayInterval * continuousDerivativeAdjustment(double(i)/section));
+    } else {
+      doSteps(pin, sectionSteps + 1, delayInterval * continuousDerivativeAdjustment(double(i)/section));
+      remainder -= 1;
+    }
+  }
+
+}
+
 void doCommand(CmdPtr c) {
-  int steps = c->steps;
-  int pin = (c->dir == DIR_CW) ? CW_PIN : CCW_PIN;
-  doSteps(pin, steps, (c->motorSpeed)/2);
+  switch(c->dir) {
+    case DIR_STATIONARY:
+      delay(c->steps*1000);
+      break;
+    case DIR_CW:
+      doSteps(CW_PIN, c->steps, 1000000.0/(c->motorSpeed)/2);
+      break;
+    case DIR_CCW:
+      doSteps(CCW_PIN, c->steps, 1000000.0/(c->motorSpeed)/2);
+      break;
+  }
 }

 void printSingleCommand(CmdPtr c) {


AD7173-8.ino updated adc_data_mode

AD7173-8.ino updated adc_data_mode

--- AD7173-8.ino
+++ AD7173-8.ino
@@ -306,11 +306,10 @@

     /* when continuous read mode */
     if (mode == CONTINUOUS_READ_MODE) {
+        /* set the adc to continuous read mode, the data register can be read directly when DATA_READY */
+        if_mode_value[1] |= 0x08;
         /* enable continuouse conversion mode */
         adc_mode_value[1] &= 0x8F;
-        /* set the adc to continuous read mode, the data register can be read directly when DATA_READY */
-        if_mode_value[1] |= 0x08;
-        adc_data_mode = CONTINUOUS_READ_MODE;
     /* when single conversion mode */
     } else if (mode == SINGLE_CONVERSION_MODE) {
         /* diable continuous read mode */
@@ -318,19 +317,18 @@
         /* set the adc to single conversion mode, the ADC conversion has to be triggered manually */
         adc_mode_value[1] &= 0x8F;
         adc_mode_value[1] |= 0x10;
-        adc_data_mode = SINGLE_CONVERSION_MODE;
     /* when continuous conversion mode */
     } else if (mode == CONTINUOUS_CONVERSION_MODE) {
         /* diable continuous read mode */
         if_mode_value[1] &= 0xF7;
         /* set the adc to continuous conversion mode, the communication register has to be notified for a ADC read */
         adc_mode_value[1] &= 0x8F;
-        adc_data_mode = CONTINUOUS_CONVERSION_MODE;
     /* unknown data conversion mode */
     } else {
         /* return error code */
         return 1;
     }
+    adc_data_mode = mode;
     /* write the specified value */
     write_adc_register(IFMODE_REG, if_mode_value, 2);
     write_adc_register(ADCMODE_REG, adc_mode_value, 2);
@@ -345,7 +343,7 @@
 ==========================================
 */
 int read_adc_data(byte *value) {
-    if (adc_data_mode == CONTINUOUS_CONVERSION_MODE) {
+    if (adc_data_mode != CONTINUOUS_READ_MODE) {
         /* send communication register id 0x00 */
         SPI.transfer(0x00);
         /* send read command 0x40 to the data register 0x04 */


remove fastLED option

remove fastLED option

--- BlackLED.ino
+++ BlackLED.ino
@@ -5,10 +5,7 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 #define NUM_OF_OUTPUTS 6
 #define MAX_NUM_LED_PER_OUTPUT 360
-#define NUM_CHANNEL_PER_LED 4
-
-//#define _use_FastLED  //for all types of chips but only 3 channel !!only LPD8806 implemented in code
-#define _use_octoWS2811 //for all WS2811 type chips
+#define NUM_CHANNEL_PER_LED 4 // do not change this

 //#define blackOnOpSyncTimeOut //recoment more than 20000 ms
 //#define blackOnOpPollTimeOut //recoment more than 20000 ms
@@ -40,15 +37,7 @@
 #include <ArtNode.h>
 #include "ArtNetFrameExtension.h"

-#ifdef _use_octoWS2811
 #include <OctoWS2811.h>
-#endif
-#ifdef _use_FastLED
-uint32_t portSyncFlag;
-uint32_t portSyncFlagCheck = 0;
-uint8_t syncFlag;
-#include <FastLED.h>
-#endif

 #include "TeensyMAC.h"
 #include <EEPROM.h>
@@ -58,38 +47,6 @@
 // settings error check
 //
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-#ifdef _use_FastLED
-#if NUM_OF_OUTPUTS > 2
-#error  "max 2 outputs for FastLED. if you want more it is easy to implement"
-#endif
-#ifdef _use_octoWS2811
-#error "only use one led controlle type"
-#endif
-#endif
-
-#ifdef _use_octoWS2811
-#warning "using less than 8 outputs, octoWS2811 will stil runs 8 outputs"
-#if NUM_OF_OUTPUTS > 8
-#error "octoWS2811 only runs 8 outputs"
-#endif
-#endif
-
-#if NUM_CHANNEL_PER_LED > 4
-#error "max 4 channels per LED"
-#elif NUM_CHANNEL_PER_LED > 3
-#ifndef octo_has_4_channel
-#error "use OctoWS2811 version 1.2.1 from https://github.com/alex-Arc/OctoWS2811.git"
-#endif
-#ifndef _use_octoWS2811
-#error "only octoWS2811 has 4 channel support"
-#endif
-#elif NUM_CHANNEL_PER_LED < 3
-#error "only 3 or 4 channel support"
-#endif
-
-#if num_artnet_ports > 18
-#error "can't handle more than 18"
-#endif

 #if F_BUS < 60000000
 #error "Teensy needs to run at 120MHz to read all packets in time"
@@ -128,7 +85,6 @@
 //
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

-#ifdef _use_octoWS2811
 uint32_t dmxMemory[num_led_per_output * 8];
 DMAMEM uint32_t displayMemory[num_led_per_output * 8];
 uint32_t drawingMemory[num_led_per_output * 8];
@@ -136,11 +92,6 @@
 const int LEDconfig = WS2811_RGBW | WS2811_800kHz;

 OctoWS2811 LEDS(num_led_per_output, displayMemory, drawingMemory, LEDconfig);
-#endif
-
-#ifdef _use_FastLED
-CRGB leds[num_led_per_output * NUM_OF_OUTPUTS];
-#endif

 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //
@@ -309,16 +260,8 @@
   // Open ArtNet
   node = ArtNodeExtended(config, sizeof(udp_buffer), udp_buffer);

-  #ifdef _use_octoWS2811
   LEDS.begin();
   LEDS.show();
-  #endif
-  #ifdef _use_FastLED
-  FastLED.addLeds<LPD8806, 2, 6, RGB, DATA_RATE_KHZ(12)>(leds, num_led_per_output).setCorrection( UncorrectedColor );
-  #if NUM_OF_OUTPUTS > 1
-  FastLED.addLeds<LPD8806, 14, 20, RGB, DATA_RATE_KHZ(12)>(leds, num_led_per_output, num_led_per_output).setCorrection( UncorrectedColor );
-  #endif
-  #endif

   blink();

@@ -370,19 +313,12 @@
               int port = node.getAddress(dmx->SubUni, dmx->Net) - node.getStartAddress();
               if (port >= 0 && port < config.numPorts) {
                 uint16_t portOffset = port * 512/NUM_CHANNEL_PER_LED;
+
                 //write the dmx data to the Octo frame buffer
-                #ifdef _use_octoWS2811
                 uint32_t* dmxData = (uint32_t*) dmx->Data;
                 for (int i = 0; i < 128; i++) {
                   LEDS.setPixel(i + portOffset, dmxData[i]);
                 }
-                #endif
-
-                #ifdef _use_FastLED
-                for (int i = 0; i < 128; i++) {
-                  leds[i + portOffset] = CRGB(dmx->Data[i*3], dmx->Data[i*3+1], dmx->Data[i*3+2]);
-                }
-                #endif
                 numUniUpdated++;
               }
               break;
@@ -390,12 +326,6 @@

           // OpSync
           case 0x5200: {
-              #ifdef _use_octoWS2811
-              LEDS.show();
-              #endif
-              #ifdef _use_FastLED
-              FastLED.show();
-              #endif

               #ifdef blackOnOpSyncTimeOut
                 lastSync = millis();
@@ -486,12 +416,7 @@
             }
         }
       }else if(memcmp(header->ID, "MadrixN", 8) == 0){
-        #ifdef _use_octoWS2811
         LEDS.show();
-        #endif
-        #ifdef _use_FastLED
-        FastLED.show();
-        #endif

         #ifdef blackOnOpSyncTimeOut
           lastSync = millis();


fixed readdressing problem by adding Art-Net correct 0x80 add when changing address

--- BlackLED.ino
+++ BlackLED.ino
@@ -241,8 +241,9 @@

             // OpAddress
             case OpAddress: {
-             // config.net = 0; // Strange Bugfix;
-            //  config.subnet = 0;
+
+//              config.net = 0;
+//              config.subnet = 0;

               T_ArtAddress * address = (T_ArtAddress*)udp_buffer;
               if (address->LongName[0] != 0) {
@@ -252,36 +253,34 @@
                 memcpy(config.shortName, address->ShortName, 18);
               }
               if (address->NetSwitch != 0x7F) {               // Use value 0x7f for no change.
-//                if ((address->NetSwitch & 0x80) == 0x80) { // This value is ignored unless bit 7 is high. i.e. to program a  value 0x07, send the value as 0x87.
+                if ((address->NetSwitch & 0x80) == 0x80) { // This value is ignored unless bit 7 is high. i.e. to program a  value 0x07, send the value as 0x87.
                   config.net = address->NetSwitch & 0x7F;
-//                }
+                }
               }
               if (address->SubSwitch != 0x7F) {               // Use value 0x7f for no change.
-//                if ((address->SubSwitch & 0x80) == 0x80) { // This value is ignored unless bit 7 is high. i.e. to program a  value 0x07, send the value as 0x87.
+                if ((address->SubSwitch & 0x80) == 0x80) { // This value is ignored unless bit 7 is high. i.e. to program a  value 0x07, send the value as 0x87.
                   config.subnet = address->SubSwitch & 0x7F;
-//                }
+                }
               }
               for (int i = 0; i < 4; i++) {
                 if (address->SwIn[i] != 0x7F) {
                   config.portAddrIn[i] = address->SwIn[i] & 0x7F;
                 }
                 if (address->SwOut[i] != 0x7F) {
-//                  if ((address->SwOut[i] & 0x80) == 0x80) {
-                    config.portAddrOut[i] = address->SwOut[i]  & 0x7F;
-//                  }
-                }
-              }
-            /*  for (int i = 1; i < config.numPorts; i++) { //for now we only do sequential port addr.
-                config.portAddrOut[i] = config.portAddrOut[0]+i;
-              }*/
+                  if ((address->SwOut[i] & 0x80) == 0x80) {
+                    config.portAddrOut[i] = address->SwOut[i] & 0x7F;
+                  }
+                }
+              }
+
               if (address->Command == 0x04) {
                 locateMode = true;
               } else {
                 locateMode = false;
               }
-              node = ArtNodeExtended(config, sizeof(udp_buffer), udp_buffer);
-              //saveConfig();
-              //loadConfig();
+             // node = ArtNodeExtended(config, sizeof(udp_buffer), udp_buffer);
+              saveConfig();
+              loadConfig();
               node.createPollReply();
               artnetSend(udp_buffer, sizeof(ArtPollReply));
               node.createExtendedPollReply();


fixed max and min distance

fixed max and min distance

--- ultrasonic_sensor.ino
+++ ultrasonic_sensor.ino
@@ -18,7 +18,7 @@

   distance = (calculateDuration()/2) * 0.0344;
   distance = distance - R;
-  if(distance >= 27){distance = 27;}
+  if(distance >= L){distance = L;}
   if(distance <= 0){distance = 0;}

   Serial.print("Adjusted Distance = ");


Imprived the contrast settings handling

Imprived the contrast settings handling

--- DigitalVFO.ino
+++ DigitalVFO.ino
@@ -271,7 +271,12 @@

 void banner(void)
 {
-  Serial.printf(F("%s %s%s (%s)\n"), ProgramName, Version, MinorVersion, Callsign);
+  Serial.printf(F("\n"));
+  Serial.printf(F("*************************************************\n"));
+  Serial.printf(F("*           %s %s%s (%s)          *\n"),
+                ProgramName, Version, MinorVersion, Callsign);
+  Serial.printf(F("*************************************************\n"));
+  Serial.printf(F("\n"));

   show_credits();
   delay(900);    // wait a bit
@@ -1609,10 +1614,15 @@
 // Set the current contrast and save to EEPROM if 'actioned'.
 //   menu      address of 'calling' menu
 //   item_num  index of MenuItem we were actioned from
+// We show immediately what the changes mean, but only update the
+// actual brightness if we do a vfo_Click action.
 //----------------------------------------

 void brightness_action(struct Menu *menu, int item_num)
 {
+  // save original brightness in case we don't update
+  int old_brightness = LcdBrightness;
+
   // convert brighness value to a display value in [1, 16]
   int index = (LcdBrightness + 1) / 16;

@@ -1645,10 +1655,12 @@
             index = 16;
           break;
         case vfo_Click:
+          old_brightness = LcdBrightness;
           save_to_eeprom();
           display_flash();
           break;
         case vfo_HoldClick:
+          LcdBrightness = old_brightness;
           event_flush();
           return;
         default:
@@ -1670,12 +1682,24 @@
 // Set the current contrast and save to EEPROM if 'actioned'.
 //   menu      address of 'calling' menu
 //   item_num  index of MenuItem we were actioned from
+// We show immediately what the changes mean, but only update the
+// actual contrast if we do a vfo_Click action.
+//
+// We limit the allowed range for LcdContrast to [0, 128].
 //----------------------------------------

 void contrast_action(struct Menu *menu, int item_num)
 {
-  // convert contrast value to a display value in [1, 16]
-  int index = 16 - LcdContrast / 8;
+  // save old contrast just in case we don't set it here
+  int old_contrast = LcdContrast;
+
+  // convert contrast value to a display value in [0, 16]
+  int index = LcdContrast / 8;
+
+  if (index > 16)   // ensure in range
+    index = 16;
+  if (index < 1)
+    index = 1;

   // get rid of any stray events to this point
   event_flush();
@@ -1685,7 +1709,8 @@
   lcd.print(menu->items[item_num]->title);

   // show row slot info on row 1
-  draw_row1_bar(index);
+  // Contrast voltage works opposite to brightness
+  draw_row1_bar(17 - index);

   // handle events in our own little event loop
   while (true)
@@ -1698,18 +1723,22 @@
       switch (event)
       {
         case vfo_RLeft:
+          if (++index > 16)
+            index = 16;
+          break;
+        case vfo_RRight:
           if (--index < 1)
             index = 1;
           break;
-        case vfo_RRight:
-          if (++index > 16)
-            index = 16;
-          break;
         case vfo_Click:
+          old_contrast = LcdContrast;  // for when we exit
           save_to_eeprom();
           display_flash();
           break;
         case vfo_HoldClick:
+          // not saving, restoe original contrast setting
+          LcdContrast = old_contrast;
+          analogWrite(mc_Contrast, LcdContrast);
           event_flush();
           return;
         default:
@@ -1718,11 +1747,12 @@
       }

       // adjust display contrast so we can see the results
-      LcdContrast = (16 - index) * 8;
+      LcdContrast = index * 8;
       analogWrite(mc_Contrast, LcdContrast);

       // show brightness value in row 1
-      draw_row1_bar(index);
+      // Contrast voltage works opposite to brightness
+      draw_row1_bar(17 - index);
     }
   }
 }


Improving networking, implementing full XS1 pushing, fixing  pointer bug

--- arduino/arduino.ino
+++ arduino/arduino.ino
@@ -3,24 +3,25 @@
 // *************************************
 // Configuration

-// Uncomment these liness if you use an Ethernet Shield
-//#define USE_ETHERNET_SHIELD
-#define ETHERNET_MAC { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
-
-// Uncomment these lines if you use a WiFi Shield
-#define USE_WIFI_SHIELD
+// Uncomment this line if you use an Ethernet Shield
+#define USE_ETHERNET_SHIELD
+#define ETHERNET_MAC { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc }
+
+// Uncomment this line if you use a WiFi Shield
+//#define USE_WIFI_SHIELD
 #define WIFI_SSID "ssid"
 #define WIFI_KEY "wpakey"

 // TODO: Fix IP/net config for both possible shields

-// Uncomment these lines if you use NeoPixel for status visualization
+// Uncomment this line if you would like to use a NeoPixel for status indication
 //#define USE_NEOPIXEL
-#define NEOPIXEL_PIN 6
-
-#define USE_XS1_SERVER
+#define NEOPIXEL_PIN 9
+
+//#define USE_XS1_SERVER
 #define XS1_IP (10, 11, 10, 18)
 #define XS1_URL "/control?callback=cname&cmd=set_state_sensor&number=9&value="
+#define XS1_TIMEFRAME 3

 // Uncomment these lines if you wish to use the the free strombewusstsein Web Service!
 //#define USE_STROMBEWUSST_SERVER
@@ -35,7 +36,7 @@
 #define TIMEFRAME 15

 // STORAGE_HOURS defines how many hours of detailed information are stored in RAM
-#define STORAGE_HOURS 3
+#define STORAGE_HOURS 2

 #define SERVER_PORT 80
 // *************************************
@@ -43,10 +44,10 @@
 // Enable as needed, depending on either USE_ETHERNET_SHIELD, USE_WIFI_SHIELD and USE_NEOPIXEL
 //#include <Adafruit_NeoPixel.h>
 #include <SPI.h>
-//#include <Ethernet.h>
-//#include <EthernetUdp.h>
-#include <WiFi.h>
-#include <WiFiUdp.h>
+#include <Ethernet.h>
+#include <EthernetUdp.h>
+//#include <WiFi.h>
+//#include <WiFiUdp.h>

 // Our prototypes!
 void setup();
@@ -108,6 +109,7 @@

 void setup() {
   Serial.begin(9600);
+  Serial.println("*** StromBewusst - Arduino FW ***");

   pinMode(TRIGGER_PIN, INPUT);

@@ -208,11 +210,12 @@
 #ifdef USE_ETHERNET_SHIELD
 void ethernetConnect()
 {
+  Serial.println("[network] connecting via Ethernet shield");
   Ethernet.begin(ethernetMac);

   // print our Ethernet shield's IP address
-  IPAddress ip = Ethernet.localIP();
-  Serial.println(ip);
+  Serial.print("[network] IP address received: ");
+  Serial.println(Ethernet.localIP());
 }
 #endif USE_ETHERNET_SHIELD

@@ -220,16 +223,19 @@
 #ifdef USE_WIFI_SHIELD
 void wifiConnect()
 {
+  Serial.println("[network] Connecting via WiFi shield");
+
   // check for the presence of the shield
   if (WiFi.status() == WL_NO_SHIELD) {
-    Serial.println("WiFi shield not present");
+    Serial.println("[network] WiFi shield not present");
     while(1);
-  }
+  }

   // connect to our network
   while ( connectionStatus != WL_CONNECTED) {
-    Serial.print("Connecting to SSID: ");
+    Serial.print("[network] Joining network ");
     Serial.println(WIFI_SSID);
+
     connectionStatus = WiFi.begin(WIFI_SSID, WIFI_KEY);

     // wait 10 seconds for connection
@@ -237,9 +243,8 @@
   }

   // print our WiFi shield's IP address
-  IPAddress ip = WiFi.localIP();
-  Serial.print("IP Address: ");
-  Serial.println(ip);
+  Serial.print("[network] IP address received: ");
+  Serial.println(WiFi.localIP());
 }
 #endif

@@ -263,9 +268,10 @@

 void pointerLoop()
 {
-  int pointer = millis() / 1000 / TIMEFRAME % STORAGE_HOURS;
+  int pointer = millis() / 1000 / TIMEFRAME % timeStorage;
   if (pointer != storagePointer)
   {
+    storage[storagePointer] = 1;
     #ifdef USE_NETWORK
       // Only push if this is not the first iteration
       if (storagePointer != -1)
@@ -282,13 +288,13 @@
 void pointerChanged()
 {
   storage[storagePointer] = 0;
+
+  Serial.println("*** Time frame changed ***");
   Serial.println("Last 15 seconds: "+String(storageSum(1)));
   Serial.println("Last 30 seconds: "+String(storageSum(2)));
   Serial.println("Last minute: "+String(storageSum(4)));
-  Serial.println("Pointer changed to "+String(storagePointer));
-}
-
-
+  Serial.println();
+}

 void push()
 {
@@ -304,8 +310,10 @@
 void xs1Push()
 {
   IPAddress ip XS1_IP;
-  String url = XS1_URL+String(storageSum(60/TIMEFRAME*5)/5*1.25*60);
-  Serial.println("[XS1] Update URL: "+url);
+  String url = XS1_URL;
+  url += (int)(storageSum(60*XS1_TIMEFRAME/TIMEFRAME)*1.25*60/XS1_TIMEFRAME);
+  Serial.println("[XS1] Update URL: "+url);
+  return;
   if (networkRequestIP(ip, url) == true)
   {
     Serial.println("[XS1] updated");
@@ -332,7 +340,7 @@

 String requestHeader(String url)
 {
-  return "GET "+url+"HTTP/1.1\r\nConnection: close\r\n\r\n";
+  return "GET "+url+" HTTP/1.1\r\nConnection: close\r\n\r\n";
 }
 #endif

@@ -363,7 +371,8 @@
   int pos = storagePointer;
   for (int i=0; i<frames; i++)
   {
-    if (--pos == -1)
+    pos--;
+    if (pos == -1)
     {
       pos = timeStorage-1;
     }


Fixed program not compiling

Fixed program not compiling

--- arduino/src/src.ino
+++ arduino/src/src.ino
@@ -447,9 +447,9 @@
         // We construct the sphere by extending the line from the center
         // of the sphere to the outside point by the radius of the sphere.
         // NOTE: http://math.stackexchange.com/questions/352828/increase-length-of-line
-        float delta_red = ((float)result->rgb.red - outside_point->red) / distance;
-        float delta_green = ((float)result->rgb.green - outside_point->green) / distance;
-        float delta_blue = ((float)result->rgb.blue - outside_point->blue) / distance;
+        float delta_red = ((float)result->rgb.red - outside_point->red) / distance_to_outside_point;
+        float delta_green = ((float)result->rgb.green - outside_point->green) / distance_to_outside_point;
+        float delta_blue = ((float)result->rgb.blue - outside_point->blue) / distance_to_outside_point;

         // The moved_point, will be the new point that is created from extending
         // that line.
@@ -466,7 +466,7 @@

         uint16_t prev_delta = result->delta;
         float distance_to_moved_result = euclidean_distance_3d(&result->rgb, &moved_result);
-        float distance_to_outside_point = euclidean_distance_3d(&result->rgb, &moved_result);
+        distance_to_outside_point = euclidean_distance_3d(&result->rgb, &moved_result);

         if (distance_to_moved_result > distance_to_outside_point)
             result->delta = (uint16_t)ceil(distance_to_moved_result);


Update Keypad.ino

Update Keypad.ino

--- ComboKeypad/Keypad.ino
+++ ComboKeypad/Keypad.ino
@@ -8,16 +8,13 @@

 const bool useFiveVoltpin = false;   //Change this if you want to use the
 ///////////////////////////////////////5Volt PIN instead of PIN 2(IN MY CASE)
-
 //USER VARIABLES END

+///
 const int numOfCombos = sizeof(combination) / sizeof(combination[0]);   //How many combinations

 const int numOfButtons = sizeof(buttons) / sizeof(buttons[0]);   //How many buttons you have

-
-
-///
 bool doonce = false;   //Button stopper
 int count = 0;   //How many buttens that have been pressed
 int input[numOfCombos]; //Saves what the user has clicked


Re-added write function

Re-added write function

--- module/module.ino
+++ module/module.ino
@@ -185,7 +185,7 @@

 */

-/*void MF_WRITE(unsigned char numBlocks, unsigned char startAddress, unsigned long time) {
+void MF_WRITE(unsigned char numBlocks, unsigned char startAddress, unsigned long time) {
 	int i = 0;

 	// prepare data to be written
@@ -209,7 +209,7 @@
 	Serial.println(startAddress);

 	RDM880.write( CMD, sizeof(CMD)/sizeof(CMD[0]) );
-}*/
+}

 /*
 	Reads the selected RFID tag.


Add better RNG

Add better RNG

--- UselessBox.ino
+++ UselessBox.ino
@@ -1,10 +1,10 @@
 // Based on code at http://www.lamja.com/?p=451

 // Fuses to wipe EEPROM on upload:
-//avrdude -c usbtiny -p atmega328p -U lfuse:w:0xff:m -U hfuse:w:0xde:m -U efuse:w:0x05:m
+// avrdude -c usbtiny -p atmega328p -U lfuse:w:0xff:m -U hfuse:w:0xde:m -U efuse:w:0x05:m

 // Fuses to prevent loss of EEPROM on upload:
-//avrdude -c usbtiny -p atmega328p -U lfuse:w:0xff:m -U hfuse:w:0xd6:m -U efuse:w:0x05:m
+// avrdude -c usbtiny -p atmega328p -U lfuse:w:0xff:m -U hfuse:w:0xd6:m -U efuse:w:0x05:m

 #include <Servo.h>
 #include <EEPROM.h>
@@ -71,12 +71,21 @@
   pinMode(buttonPin, INPUT_PULLUP);
   modeButton.attach(buttonPin);
   modeButton.interval(100);
-
+
+  randomSeed(getSeedFromAnalogPin(A5));
+
   digitalWrite(6, HIGH);  // turn on motor power
-
-  randomSeed(analogRead(A5));
 }
-
+
+unsigned long getSeedFromAnalogPin(int pin)
+{
+  // From http://www.utopiamechanicus.com/article/better-arduino-random-numbers/
+  unsigned long seed=0, count=32;
+  while (--count)
+    seed = (seed<<1) | (analogRead(pin)&1);
+  return seed;
+}
+
 void loop()
 {
   if (modeButton.update() && modeButton.read() == LOW)
@@ -139,6 +148,7 @@
   if (sequence == 6) Sequence6();
   if (sequence == 7) Sequence7();
   if (sequence == 8) Sequence8();
+  if (sequence == 9) Sequence9();
   if (sequence == 10) Sequence10();
   if (sequence > 10) DefaultSequence();


Added latest behaviours.

Added latest behaviours.

--- src/MonsterSketch/MonsterSketch.ino
+++ src/MonsterSketch/MonsterSketch.ino
@@ -70,6 +70,8 @@
 float force[5];
 float magnitude[5];
 float location[5];
+int monsterTimer;
+

 float dampening;
 float springValue;
@@ -93,6 +95,8 @@
   ////////////////////////////dampening value (1= no dampening, 0 = full dampening (no movement)) Usually .9 or so.
   dampening = 0.9;
   //////////////////////////////////////////////////////////////////////
+
+  monsterTimer=0;

   for (int i=0; i<5; i++){
     target[i] = 0.1;
@@ -134,7 +138,7 @@

 }

-void loop() {
+void loop(){

   // RUN JOINT CALIBRATION ROUTINE
 #ifdef CALIBRATING
@@ -169,67 +173,111 @@
   /////////////////////////////////////////////
   // Set Robot
   /////////////////////////////////////////////
+  monsterTimer = monsterTimer + 1;
+
   //////////////////HARDCODING VALUES TO JOINTS BASED ON COMMON SENSOR VALUES BELOW////////////////////////
   // X maps to joint 0
-  if(g_fX < -.1){
-    iPwmValue = mapfloat(g_fX, -.1, -0.6, g_poDataMonster->m_apJoinArray[0]->m_fPwmMin, g_poDataMonster->m_apJoinArray[0]->m_fPwmMin + 50);  ///////<-hardcoded!
+  if(g_fX > -.1){
+    iPwmValue = mapfloat(g_fX, -.1, -0.6, g_poDataMonster->m_apJoinArray[0]->m_fPwmMin, g_poDataMonster->m_apJoinArray[0]->m_fPwmMin + 5);  ///////<-hardcoded!

   }
-  else if(g_fX > 0.1){
-    iPwmValue = mapfloat(g_fX, 0.1, 0.6, g_poDataMonster->m_apJoinArray[0]->m_fPwmMax , g_poDataMonster->m_apJoinArray[0]->m_fPwmMax - 50); ///////<-hardcoded!
+  else if(g_fX < 0.1){
+    iPwmValue = mapfloat(g_fX, 0.1, 0.6, g_poDataMonster->m_apJoinArray[0]->m_fPwmMax , g_poDataMonster->m_apJoinArray[0]->m_fPwmMax - 5); ///////<-hardcoded!
   }
   else{
     iPwmValue = mapfloat(g_fX, SENSOR_X_MIN, SENSOR_X_MAX, g_poDataMonster->m_apJoinArray[0]->m_fPwmMin, g_poDataMonster->m_apJoinArray[0]->m_fPwmMax);
   }
+ ///////////////////////////////////////////////////
+  ////what to do
+  if (monsterTimer <= 160){
   target[0]= iPwmValue;
+ // Serial.println(monsterTimer);
+  }
+    if ((target[0] - iPwmValue > 2.5) || (target[0] - iPwmValue < -2.5 )){
+ monsterTimer =0;
+    }
+// Serial.println(monsterTimer);
+
+  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

   // Z maps to joint 1
   if(g_fZ >= 0 && g_fZ < 0.1){
-    iPwmValue = mapfloat(g_fX, 0, (.1), g_poDataMonster->m_apJoinArray[1]->m_fPwmMin, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax-50);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fX, 0, (.1), g_poDataMonster->m_apJoinArray[1]->m_fPwmMin, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax-10);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.1 && g_fZ< 0.2){
-    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[1]->m_fPwmMin + 50, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[1]->m_fPwmMin, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax-10);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.2 && g_fZ< 0.3){
-    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[1]->m_fPwmMin + 30, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[1]->m_fPwmMin, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax-5);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.3 && g_fZ< 0.6){
-    iPwmValue = mapfloat(g_fZ, 0.3, 0.6, g_poDataMonster->m_apJoinArray[1]->m_fPwmMin, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0.3, 0.6, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax-10, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax);  ///////<-hardcoded!
   }
   else{
     iPwmValue = mapfloat(g_fZ, SENSOR_Z_MIN, SENSOR_Z_MAX, g_poDataMonster->m_apJoinArray[1]->m_fPwmMin, g_poDataMonster->m_apJoinArray[1]->m_fPwmMax);
   }
+
+  //////////////////what to do
+   if (monsterTimer <= 105){
   target[1]= iPwmValue;
-
-  // Z maps to joint 2
+  }
+  else if (monsterTimer <= 165){
+    target[1] = g_poDataMonster->m_apJoinArray[1]->m_fPwmMin;
+  }
+else{
+ target[1] = g_poDataMonster->m_apJoinArray[1]->m_fPwmMax;
+}
+
+
+
+
+
+
+
+
+
+  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+//  // Z maps to joint 2
   if(g_fZ >= 0 && g_fZ < 0.1){
-    iPwmValue = mapfloat(g_fZ, 0, (.1), g_poDataMonster->m_apJoinArray[2]->m_fPwmMin, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax-50);  ///////<-hardcoded!
-  }
-  else if(g_fZ >= 0.1 && g_fZ< 0.2){
-    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin + 50, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax);  ///////<-hardcoded!
-  }
-  else if(g_fZ >= 0.2 && g_fZ< 0.3){
-    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin + 30, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0, (.1), g_poDataMonster->m_apJoinArray[2]->m_fPwmMax-10, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin);  ///////<-hardcoded!
+  }
+  else if(g_fZ >= 0.1 && g_fZ< 0.3){
+    iPwmValue = mapfloat(g_fZ, 0.1, 0.3, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax-5, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.3 && g_fZ< 0.6){
-    iPwmValue = mapfloat(g_fZ, 0.3, 0.6, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0.3, 0.6, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin);  ///////<-hardcoded!
   }
   else{
-    iPwmValue = mapfloat(g_fZ, SENSOR_Z_MIN, SENSOR_Z_MAX, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax);
-
-  }
+    iPwmValue = mapfloat(g_fZ, SENSOR_Z_MIN, SENSOR_Z_MAX, g_poDataMonster->m_apJoinArray[2]->m_fPwmMax, g_poDataMonster->m_apJoinArray[2]->m_fPwmMin+5);
+  }
+  if (target[1] < g_poDataMonster->m_apJoinArray[1]->m_fPwmMax-10)
+  target[2] = target[1];
+
+
+   if (monsterTimer <= 120){
   target[2]= iPwmValue;
+  }
+  else {
+    target[2] = g_poDataMonster->m_apJoinArray[1]->m_fPwmMin;
+  }
+
+
+
+
+
+  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

   // Z maps to joint 3
   if(g_fZ >= 0 && g_fZ < 0.1){
-    iPwmValue = mapfloat(g_fZ, 0, (.1), g_poDataMonster->m_apJoinArray[3]->m_fPwmMin, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0, (.1), g_poDataMonster->m_apJoinArray[3]->m_fPwmMax, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax-10);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.1 && g_fZ< 0.2){
-    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[3]->m_fPwmMin, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax, g_poDataMonster->m_apJoinArray[3]->m_fPwmMin+10);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.2 && g_fZ< 0.3){
-    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[3]->m_fPwmMin, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax);  ///////<-hardcoded!
+    iPwmValue = mapfloat(g_fZ, 0.1, 0.2, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax-10);  ///////<-hardcoded!
   }
   else if(g_fZ >= 0.3 && g_fZ< 0.6){
     iPwmValue = mapfloat(g_fZ, 0.3, 0.6, g_poDataMonster->m_apJoinArray[3]->m_fPwmMin, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax);  ///////<-hardcoded!
@@ -237,26 +285,62 @@
   else{
     iPwmValue = mapfloat(g_fZ, SENSOR_Z_MIN, SENSOR_Z_MAX, g_poDataMonster->m_apJoinArray[3]->m_fPwmMin, g_poDataMonster->m_apJoinArray[3]->m_fPwmMax);
   }
+     if (monsterTimer <= 110){
   target[3]= iPwmValue;
+  }
+  else if (monsterTimer <= 130){
+  target[3]= 25;
+  }
+    else if (monsterTimer <= 150){
+  target[3]= 10;
+  }
+     else if (monsterTimer <= 160){
+  target[3]= g_poDataMonster->m_apJoinArray[3]->m_fPwmMax;
+  }
+     else if (monsterTimer <= 175){
+  target[3]= g_poDataMonster->m_apJoinArray[3]->m_fPwmMin;
+  }
+  else{
+    target[3]= iPwmValue;
+  }
+  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

   // Y maps to joint 4
-  if(g_fZ >= 0 && g_fZ < 0.1){
-    iPwmValue = mapfloat(g_fY, 0, (.1), g_poDataMonster->m_apJoinArray[4]->m_fPwmMin, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax-50);  ///////<-hardcoded!
-  }
-  else if(g_fZ >= 0.1 && g_fZ< 0.2){
-    iPwmValue = mapfloat(g_fY, 0.1, 0.2, g_poDataMonster->m_apJoinArray[4]->m_fPwmMin + 50, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax);  ///////<-hardcoded!
-  }
-  else if(g_fZ >= 0.2 && g_fZ< 0.3){
-    iPwmValue = mapfloat(g_fY, 0.1, 0.2, g_poDataMonster->m_apJoinArray[4]->m_fPwmMin + 30, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax);  ///////<-hardcoded!
-  }
-  else if(g_fZ >= 0.3 && g_fZ< 0.6){
-    iPwmValue = mapfloat(g_fY, 0.3, 0.6, g_poDataMonster->m_apJoinArray[4]->m_fPwmMin, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax);  ///////<-hardcoded!
+  if(g_fY >= 0 && g_fY < 0.1){
+    iPwmValue = mapfloat(g_fY, 0, (.1), g_poDataMonster->m_apJoinArray[4]->m_fPwmMax, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax-5);  ///////<-hardcoded!
+  }
+  else if(g_fY >= 0.1 && g_fY< 0.2){
+    iPwmValue = mapfloat(g_fY, 0.1, 0.2, g_poDataMonster->m_apJoinArray[4]->m_fPwmMin , g_poDataMonster->m_apJoinArray[4]->m_fPwmMax-5);  ///////<-hardcoded!
+  }
+  else if(g_fY >= 0.2 && g_fY< 0.3){
+    iPwmValue = mapfloat(g_fY, 0.1, 0.2, g_poDataMonster->m_apJoinArray[4]->m_fPwmMin + 8, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax);  ///////<-hardcoded!
+  }
+  else if(g_fY >= 0.3 && g_fY< 0.6){
+    iPwmValue = mapfloat(g_fY, 0.3, 0.6, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax-5, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax);  ///////<-hardcoded!
   }
   else{
     iPwmValue = mapfloat(g_fY, SENSOR_X_MIN, SENSOR_X_MAX, g_poDataMonster->m_apJoinArray[4]->m_fPwmMin, g_poDataMonster->m_apJoinArray[4]->m_fPwmMax);
-
-  }
+  }
+
+  //target[4]= iPwmValue;
+  // target[4]= 15;
+
+     if (monsterTimer <= 90){
   target[4]= iPwmValue;
+  }
+  else if(monsterTimer <= 105){
+target[4] = g_poDataMonster->m_apJoinArray[4]->m_fPwmMax-2;
+  }
+    else if(monsterTimer <=160){
+target[4] = g_poDataMonster->m_apJoinArray[4]->m_fPwmMin+10;
+    }
+   else {
+     target[4]= g_poDataMonster->m_apJoinArray[4]->m_fPwmMax-2;
+   }
+
+  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ //Dampening code

   for (int i=0; i<5; i++){
     magnitude[i] = target[i] - location[i];
@@ -273,17 +357,19 @@

  ///// Set Dampening couter/reset
 dampening = (dampening - 0.0005);
-if (dampening < 0.6){
-  dampening = 0.6;
+if (dampening < 0.8){
+  dampening = 0.8;
 }
 if (g_bGotTweet == true){
- dampening = 1.0;
+ dampening = .95;
 }

   // Orient the robot towards the object
+  if(monsterTimer <=190){
   g_poDataMonster->setPosture(location[0],  location[1],  location[2], location[3], location [4], g_bGotTweet);
-
+  }
+
 #endif

 }


Fix for boss explosion should complete before you win screen.

--- arduboy-game/arduboy-game.ino
+++ arduboy-game/arduboy-game.ino
@@ -557,6 +557,7 @@
   isBossAlive = false;
   byte spawnedBoss = 0;
   byte currentIteration = 0;
+  boolean iterationEnding = false;

   resetEnemies();
   resetBoss();
@@ -653,6 +654,13 @@
     updateStarFieldVals();

     if (handlePlayerBullets()) {
+      iterationEnding = true;
+      stopSpawningEnemies = true;
+      stopMusic();
+    }
+
+    if (iterationEnding && boss.dying == 0) {
+      delay(100);
       playerWinsScreen();

       // Reset which boss spawns for next iteration
@@ -667,13 +675,16 @@
       // Set them on the next iteration
       currentIteration = (currentIteration == 254 ? 0 : currentIteration + 1);
       currentKills = 0;
+      iterationEnding = false;
+      stopSpawningEnemies = false;
     }

     handleEnemyBullets();
     handleBossBullets();
-
-    playMusic(isBossAlive ? 3 : 2);
-
+
+    if (! iterationEnding) {
+      playMusic(isBossAlive ? 3 : 2);
+    }
   }

   stopMusic();


`HI SCORES -> HIGH SCORES`

`HI SCORES -> HIGH SCORES`

--- arduboy-game/arduboy-game.ino
+++ arduboy-game/arduboy-game.ino
@@ -271,8 +271,10 @@
   char hiScore[7];

   arduboy.clear();
-  printText("HI SCORES", 8, 1, 2);
-
+
+  printText("HIGH", 0, 1, 2);
+  printText("SCORES", 58, 1, 2);
+
   for (byte i = 0; i < NUM_HIGH_SCORES; i++) {
     strncpy(hiInitials, highScoreTable + ((9 * i) * sizeof(char)), 3);
     hiInitials[3] = '\0';


Add duration to opened log message

Add duration to opened log message

--- KomaRoof.ino
+++ KomaRoof.ino
@@ -304,7 +304,7 @@
                 }
                 else if (roofState == OPENING)
                 {
-                    logger("OPENED");
+                    logger(String("OPENED,DURATION=") + (millis()-moveStartTime));
                     roofState = OPEN;
                 }
                 else if (roofState == CLOSING)


Adjust constants with measured values; stop roof before we hit the end stop when opening

--- KomaRoof.ino
+++ KomaRoof.ino
@@ -46,10 +46,11 @@
 #define BATTERY_RESISTOR_DIVISOR 3.2473
 #define MOTOR_CURRENT_LIMIT_MILLIAMPS 2500
 #define MOTOR_CLOSING_CURRENT_LIMIT_MILLIAMPS 1000
-#define MOTOR_POLARITY 1    // Change to -1 to invert movement direction
+#define MOTOR_POLARITY -1    // Change to -1 to invert movement direction
 #define FULL_SPEED 400
 #define CLOSING_SPEED 50
 #define RAMP_LENGTH 20      // two seconds
+#define ENCODER_MAX_POSITION 715  // stop opening at this encoder position

 void currentMeasurementTick();
 void motorTick();
@@ -236,6 +237,13 @@
         limitSwitchOpenActive = false;
     }

+    if (encoderPosition >= ENCODER_MAX_POSITION) {
+        if (phase != IDLE && roofState == OPENING) {
+            phase = RAMP_DOWN;
+            countSincePhase = 0;
+        }
+    }
+
     if (limitSwitchCloseActive) {
         if (phase != IDLE && roofState == CLOSING) {
             phase = RAMP_DOWN;


Arduino aanpassing presentatie

Arduino aanpassing presentatie

--- Arduino/LEDRouting.ino
+++ Arduino/LEDRouting.ino
@@ -6,10 +6,16 @@
   {22, 24, 30, 32, 34, 42},
   {22, 22, 30, 32, 34, 36, 44}
 };
+int parkingrouteMAX[4] =
+{
+   4,
+  4,
+  6,
+  7
+};

 void LEDRouting(int parkingSpot, int enable)
 {
-  Serial.println("BEGIN");
   int value = 1;
   if (enable < 1)
   {
@@ -18,9 +24,8 @@

   if (parkingSpot < sizeof(parkingRoute) && parkingSpot > -1)
   {
-    for (int i = 0; i < sizeof(parkingRoute[parkingSpot]); i++) //parkingRoute[1][0]
+    for (int i = 0; i < sizeof(parkingrouteMAX[parkingSpot]); i++) //parkingRoute[1][0]
     { //
-
       int rgbID = parkingRoute[parkingSpot][i];
       digitalWrite(rgbID, value);
     }


Fixed bug in populating frequency char buffer

--- PixelVFO.ino
+++ PixelVFO.ino
@@ -117,13 +117,13 @@
   // get the display ready
   tft.begin();
   tft.setFont(&ArialBold24pt7b);
+  tft.setRotation(1);

   // initialize the touch stuff
   touch_setup(T_CS, T_IRQ);

   // start drawing things that don't change
-  tft.fillScreen(SCREEN_BG);
-  tft.setRotation(1);
+  tft.fillScreen(SCREEN_BG2);
   tft.setTextWrap(false);
   tft.fillRect(0, 0, tft.width(), DEPTH_FREQ_DISPLAY, FREQ_BG);
   tft.drawRect(0, 0, tft.width(), DEPTH_FREQ_DISPLAY, SCREEN_BG1);
@@ -136,12 +136,7 @@
   tft.fillRect(FREQ_OFFSET_X+CHAR_WIDTH*2, 44, 2, 6, FREQ_FG);
   tft.fillRect(FREQ_OFFSET_X+CHAR_WIDTH*5, 44, 2, 6, FREQ_FG);

-  // fill in the remainder of the display
-  tft.fillRect(0, DEPTH_FREQ_DISPLAY,
-               tft.width(), tft.height() - DEPTH_FREQ_DISPLAY, SCREEN_BG2);
-  // draw dividing line
-//  tft.drawFastHLine(0, DEPTH_FREQ_DISPLAY, tft.width(), ILI9341_RED);
-
+  // show the frequency
   display_frequency();
 }

@@ -158,7 +153,7 @@
 {
   int rem;

-  for (int i = NUM_F_CHAR - 1; i; --i)
+  for (int i = NUM_F_CHAR - 1; i >= 0; --i)
   {
     rem = freq % 10;
     freq = freq / 10;


Change the startup message, nothing more.

--- firmware/node/node.ino
+++ firmware/node/node.ino
@@ -266,7 +266,7 @@
                     g_next_pattern = NULL;
                     return;
                 }
-
+
                 // we parsed a valid pattern, increase the index
                 g_load_pattern= (g_load_pattern + 1) % 2;

@@ -332,7 +332,6 @@
                 for(i = 0; i < len - 2; i++)
                     g_classes[i] = data[i];

-
                 break;
             }
         case PACKET_CALIBRATE:
@@ -460,7 +459,7 @@

     if (!g_cur_pattern)
         return;
-
+
     if (g_target && ticks() >= g_target)
     {
         g_target += g_ticks_per_frame;
@@ -540,7 +539,7 @@
     if (timer_cal > 1 && timer_cal != 0xFFFF)
     {
         g_ticks_per_sec = timer_cal;
-        Serial.print("calibrated ");
+        Serial.print("calibrated " + String(timer_cal) + " ");
         col.c[0] = 0;
         col.c[1] = 128;
         col.c[2] = 0;


I2C speed bumped to 400kHz

I2C speed bumped to 400kHz

--- crossbow.ino
+++ crossbow.ino
@@ -180,6 +180,9 @@
     TCCR1B |= (1 << CS11);  //set timer1 to increment every 0,5 us or 1us on 8MHz

 #ifdef FEATURE_TX_OLED
+
+    Wire.setClock(400000);
+
     display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
     display.setTextSize(1);
     display.setTextColor(WHITE);


Add code for led column indicators

Add code for led column indicators

--- connect4.ino
+++ connect4.ino
@@ -2,32 +2,34 @@
 // P Beard
 // Jan 2015

-#include "U8glib.h"
-
 #define LED 13
 #define NO_BUTTONS 0b11111111111111

+#include "U8glib.h"
+U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST); // Fast I2C / TWI
+
+#include <Adafruit_NeoPixel.h>
+#define NEOPIXELPIN A3
+Adafruit_NeoPixel strip = Adafruit_NeoPixel(7, NEOPIXELPIN, NEO_GRB + NEO_KHZ800);
+
 const byte btnRow[2] = {2, 3};
 const byte btnCol[7] = {4, 5, 6, 7, 8, 9, 10};
-
 unsigned int btns = NO_BUTTONS;
 unsigned int lastBtns = NO_BUTTONS;
 unsigned int stableBtns = NO_BUTTONS;
 unsigned long debounce;
 char human = '-';
 char robot = '-';
-
-U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST);	// Fast I2C / TWI
-
+uint32_t humanColour = 0;
+uint32_t robotColour = 0;
 char board[42];
 char screen[7][22];
-
 // Array containing start position of each "win line"
-byte lineStart[] = { 0,  7, 14, 21, 28, 35,  0,  1,  2,  3,  4,  5,  6, 14,  7,  0,  1,  2,  3,  3,  4,  5,  6, 13, 20};
+byte lineStart[] = { 0, 7, 14, 21, 28, 35, 0, 1, 2, 3, 4, 5, 6, 14, 7, 0, 1, 2, 3, 3, 4, 5, 6, 13, 20};
 // Array containing number of groups of 4 positions on each "win line"
-byte lineReps[] =  { 4,  4,  4,  4,  4,  4,  3,  3,  3,  3,  3,  3,  3,  1,  2,  3,  3,  2,  1,  1,  2,  3,  3,  2,  1};
+byte lineReps[] = { 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1};
 // Array containing direction offset for each "win line"
-byte lineSteps[] = { 1,  1,  1,  1,  1,  1,  7,  7,  7,  7,  7,  7,  7,  8,  8,  8,  8,  8,  8,  6,  6,  6,  6,  6,  6};
+byte lineSteps[] = { 1, 1, 1, 1, 1, 1, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6};

 void setup() {
   pinMode(LED, OUTPUT);
@@ -43,23 +45,21 @@
   strcpy(screen[0], "Your go:");
   displayBoard(board);
   updateScreen();
-
   pinMode(btnRow[0], INPUT_PULLUP);
   pinMode(btnRow[1], INPUT_PULLUP);
-
   for (byte col=0; col<=6; col++) {
     pinMode(btnCol[col], OUTPUT);
     digitalWrite(btnCol[col], LOW);
   }
+  strip.begin();
+  strip.show();
 }

 void loop() {
-
   char c;
   byte best;
   int currentScore;
   unsigned int btnsNow = 0;
-
   // Read all buttons in the 7 cols x 2 rows matrix
   for (byte row=0; row<=1; row++) {
     for (byte col=0; col<=6; col++) {
@@ -69,41 +69,45 @@
       digitalWrite(btnCol[col], LOW);
     }
   }
-
   // Has there been any change in the buttons?
   if (btnsNow != lastBtns) {
     // Note the new button values and the time of the change
     lastBtns = btnsNow;
     debounce = millis();
   }
-
   // Do we have a new, stable reading?
   if ((millis() - debounce) > 50 && btnsNow != stableBtns) {
     stableBtns = btnsNow;
     btns &= btnsNow;
   }
-
   // Have we detected some button presses and the timeout period for further changes has expired?
   if ((millis() - debounce) > 500 && btns != NO_BUTTONS) {
-    // Work out which column the counter was placed in. Zero indicates cheating!
+    // Work out which column the counter was placed in. Zero indicates cheating!
     unsigned int col = btns & btns >> 7;
     if (col == 0) {
       strcpy(screen[0], "Cheat!");
       updateScreen();
     }
     else {
-
       // Figure out which colour counter has been dropped
       char counter;
-      if ((btns & 0b1111111) == col) counter = 'O'; else counter = 'X';
-
+      if ((btns & 0b1111111) == col) counter = 'O';
+      else counter = 'X';
       // Has human chosen a colour yet?
       if (human == '-') {
         // Human has now chosen a colour and robot chooses the other
         human = counter;
-        if (human == 'X') robot = 'O'; else robot = 'X';
-      }
-
+        if (human == 'X') {
+          humanColour = strip.Color(32, 32, 0);
+          robot = 'O';
+          robotColour = strip.Color(0, 0, 64);
+        }
+        else {
+          humanColour = strip.Color(0, 0, 64);
+          robot = 'X';
+          robotColour = strip.Color(32, 32, 0);
+        }
+      }
       // Has human played with robot's colour?
       if (counter != human) {
         strcpy(screen[0], "Cheat!");
@@ -112,52 +116,55 @@
       else {
         // Human has played correct colour. Figure out which column
         for (byte i=0; i<=6; i++) {
+          strip.setPixelColor(i, 0);
           if (bit(i) == col) {
             c = 6-i;
           }
         }
         // Drop the counter
+        strip.setPixelColor(c, humanColour);
+        strip.show();
         dropCounter(board, human, c);
         displayBoard(board);
         updateScreen();
-
         if (score(board, human, robot) == 1000) {
           strcpy(screen[0], "You Won!");
           updateScreen();
-          while (true) {}
+          while (true) {
+          }
         }
         else {
-
           //unsigned long t = millis();
           strcpy(screen[0], "My go:");
           updateScreen();
           currentScore = bestMove(board, robot, human, best, 4);
           digitalWrite(LED, LOW);
           //Serial.println(millis() - t);
+          for (byte i=0; i<=6; i++) {
+            strip.setPixelColor(i, 0);
+          }
+          strip.setPixelColor(best, robotColour);
+          strip.show();
           dropCounter(board, robot, best);
           displayBoard(board);
-
           if (score(board, robot, human) == 1000) {
             strcpy(screen[0], "You Lost!");
             updateScreen();
-            while (true) {}
-          }
-
+            while (true) {
+            }
+          }
           strcpy(screen[0], "Your go:");
           updateScreen();
         }
-      }
+      }
     }
     btns = NO_BUTTONS;
   }
 }

 void displayBoard(char board[]) {
-
   Serial.println("0123456");
-
   byte i = 0;
-
   for(byte row = 0; row <= 5; row++) {
     for(byte col = 0; col <= 6; col++) {
       screen[row+1][col] = board[i++];
@@ -168,23 +175,21 @@

 void updateScreen() {
   // U8GLIB picture loop
-  u8g.firstPage();
+  u8g.firstPage();
   do {
     uint8_t i, y;
-
-    y = 0;       // reference is the top left -1 position of the string
-    y--;           // correct the -1 position of the drawStr
+    y = 0; // reference is the top left -1 position of the string
+    y--; // correct the -1 position of the drawStr
     for( i = 0; i < 7; i++ ) {
       u8g.drawStr( 0, y, (char *)(screen[i]));
       y += u8g.getFontLineSpacing();
     }
-  } while( u8g.nextPage() );
+  }
+  while( u8g.nextPage() );
 }

 byte dropCounter(char board[], char token, byte col) {
-
   byte i = col;
-
   // Test if the position one row down is empty
   while (i < 35 && board[i+7] == '.') {
     // Move down a row
@@ -196,25 +201,18 @@
 }

 int score(char board[], char token, char oppToken) {
-
   int totalScore = 0;
-
   // Scan each "win" line on the board
   for (byte line = 0; line < 25; line++) {
-
     byte i = lineStart[line];
     byte lineStep = lineSteps[line];
     byte reps = lineReps[line];
-
     // Scan each group of 4 positions on the "win" line
     for (byte rep = 0; rep < reps; rep++) {
-
       byte j = i;
       int addScore = 0;
-
       // Check this group of 4 positions
       for (byte pos = 0; pos < 4; pos++) {
-
         if (board[j] == token) {
           if (addScore < 0) {
             // A mix of "O" and "X" - no-one can win here
@@ -254,33 +252,27 @@
       totalScore += addScore;
     }
   }
-  gameWon: return totalScore;
+gameWon:
+  return totalScore;
 }

 int bestMove(char board[], char token, char oppToken, byte &bestCol, byte lookAhead) {
-
   int bestScore = -9999;
-
   // Make a copy of the board
   char boardCopy[43];
   for (byte i = 0; i < 43; i++) boardCopy[i] = board[i];
-
   if (lookAhead > 1) digitalWrite(LED, !digitalRead(LED));
-
   // Evaluate each choice of column
   for (byte col = 0; col < 7; col++) {
     if (board[col] == '.') {
-
-      // Drop token onto the copy of the board
+      // Drop token onto the copy of the board
       byte counterPosition = dropCounter(boardCopy, token, col);
       int thisScore = score(boardCopy, token, oppToken);
-
       if (thisScore > -1000 && thisScore < 1000 && lookAhead > 0) {
         // Look more moves ahead, but swap places with opponent since it will be their turn next
         byte oppBestCol;
         thisScore = -bestMove(boardCopy, oppToken, token, oppBestCol, lookAhead - 1);
       }
-
       // Check this choice of column - best so far?
       if (thisScore > bestScore) {
         // Yes, a new best choice found
@@ -289,7 +281,6 @@
       }
       // remove the counter again
       boardCopy[counterPosition] = '.';
-
       // check for any button presses = cheating
       if (digitalRead(btnRow[0]) == LOW || digitalRead(btnRow[1]) == LOW) {
         strcpy(screen[0], "Cheat!");


Update twirl.ino

Update twirl.ino

--- examples/twirl/twirl.ino
+++ examples/twirl/twirl.ino
@@ -1,7 +1,7 @@
 /*
   twirl.ino
-  Example of LEGOPowerFunctions library
-    modified by Mateusz Jaros / The JarOS.
+  Example of LEGOPowerFunctions library,
+    created by Mateusz Jaros / The JarOS.

   CONNECTIONS:
     *Arduino


heartbeat every 5 min with loopcounter (in minutes) and errorcounter to lg server

--- sketch_lg_heartbeat/sketch_lg_heartbeat.ino
+++ sketch_lg_heartbeat/sketch_lg_heartbeat.ino
@@ -5,6 +5,9 @@

 #include <wino.h>
 #include "config.h"
+
+int loopcnt = 0;
+int errcnt = 0;

 void setup() {
   SerialUSB.begin(9600); //Opens USB-Serial connection for terminal
@@ -15,7 +18,8 @@
   if(wifi.kick()) {
     SerialUSB.print("ESP8266 turned on \r\n");
   } else {
-    SerialUSB.print("ESP8266 still offline\r\n");
+    SerialUSB.print("ESP8266 still offline\r\n");
+    errcnt++;
   }

   SerialUSB.print("FW version: ");
@@ -26,35 +30,35 @@
     SerialUSB.print("to station + soft AP ok\r\n");
   } else {
     SerialUSB.print("to station + soft ap error\r\n");
+    errcnt++;
   }

   if (wifi.joinAP(WIFI_SSID, WIFI_PASSWORD)) {
     SerialUSB.print("Join AP success\r\n");
     SerialUSB.print("IP: ");
-    SerialUSB.println(getIP(true)); // short version of output, cached
+    SerialUSB.println(getIP(true)); // short version of IP, cached
+    SerialUSB.print("MAC: ");
+    SerialUSB.println(gethostname(true)); // short version of hostname, cached
   } else {
     SerialUSB.println("Join AP error");
+    errcnt++;
   }

   if (wifi.disableMUX()) {
     SerialUSB.println("MUX disabled");
   } else {
     SerialUSB.println("MUX disabling failed");
+    errcnt++;
   }
-
 }

-int counter = 0;
-
 void loop() {
+  static int counter = 0;
+
   counter++;
-  SerialUSB.println("--");
-  SerialUSB.println(counter);
-  SerialUSB.print("IP: ");
-  SerialUSB.println(getIP(true)); // short version of output, cached
-  lg_heartbeat();
+  if ((counter % 5) == 0) lg_heartbeat(); // every 5 loops

-  delay(5000);
+  delay(60000); // one loop per minute
 }

 /* get local IP address. The wifi library gives a strig result like this:
@@ -83,6 +87,23 @@
 }

 /*
+ * build hostname from MAC address
+ */
+String gethostname(bool cache) {
+  static String mac = "";
+  if (mac.length() && cache) {
+     return mac;
+  }
+  String pattern = "STAMAC,\"";
+  String answer = wifi.getLocalIP().c_str();
+  int starti = answer.indexOf(pattern) + pattern.length();
+  mac = answer.substring(starti, answer.length() -1);
+  int stopi = mac.indexOf("\"");
+  mac = String("wino-") + mac.substring(0,stopi);
+  mac.replace(":", "");
+  return mac;
+}
+/*
  * lg_heartbeat - send a json message with some data to lg server
  */

@@ -100,7 +121,7 @@
     SerialUSB.println("tcp connection failed");
   }

-  String payload = "{ \"host\": \"wino\" }";
+  String payload = "{ \"host\": \"" + gethostname(true) + "\", \"loopcount\": " + loopcnt + ", \"errcount\": " + errcnt + " }";
   String request = "POST /api/collections/heartbeat?user_key=" + String(LG_API_KEY) + " HTTP/1.1\r\n"
     + "Host: " + LG_HOST + "\r\n"
     + "User-Agent: arduino-wino/1.0 \r\n"


Update BB-UNIT.ino

Update BB-UNIT.ino

--- Firmware/BB-UNIT/BB-UNIT.ino
+++ Firmware/BB-UNIT/BB-UNIT.ino
@@ -635,9 +635,9 @@
   	else runX = false;

   	// Calcul du PID X
-  	if(x < 90) vx = (90 - x);
+  	if(x < setpointX) vx = (setpointX - x);
   	if(x == 0) vx = 0;
-  	if(x > 90) vx = (x - 90);
+  	if(x > setpointX) vx = (x - setpointX);

   	speedX = 1000 / (vx);
   	speedX = speedX * multiplier; // DEL
@@ -689,9 +689,9 @@
   	else runY = false;

   	// Calcul du PID Y
-  	if(y < 90) vy = (90 - y);
+  	if(y < setpointY) vy = (setpointY - y);
   	if(y == 0) vy = 0;
-  	if(y > 90) vy = (y - 90);
+  	if(y > setpointY) vy = (y - setpointY);

   	speedY = 1000 / (vy);
   	speedY = speedY * multiplier; // DEL


more documentation changes

more documentation changes

--- v2/06oct/06oct/06oct.ino
+++ v2/06oct/06oct/06oct.ino
@@ -1,8 +1,7 @@
 /*
-SharpDistSensorBasic.ino
-Source: https://github.com/DrGFreeman/SharpDistSensor
-MIT License
-Copyright (c) 2017 Julien de la Bruere-Terreault <drgfreeman@tuta.io>
+Robojackets Robot Sumo Team Pushiv
+Source: https://github.com/simplyellow/auto-sumo.git
+Copyright (c) 2017 Georgia Tech Robojackets
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
@@ -18,16 +17,6 @@
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
-*/
-
-/*
-This example shows how to use the SharpDistSensor library to continuously
-read the sensor and display the analog value and the corrseponding distance
-in mm.
-The library default values corresponding to the Sharp GP2Y0A60SZLF 5V sensor
-are used.
-See the library README for how to use pre-defined sensor models or custom
-fit functions.
 */

 #include <SharpDistSensor.h>


start on hostcm support

start on hostcm support

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

--- zimodem/proto_hostcm.ino
+++ zimodem/proto_hostcm.ino
@@ -79,6 +79,19 @@
   if((pkti==0)
   ||(inbuf[pkti-1]!=opt.lineend))
     return;
-  //TODO: don't forget to reset pkti before you go!
+  pkti--;
+  if((pkti>1)&&(inbuf[pkti-1]!=checksum(inbuf,pkti-1)))
+  {
+    //TODO: compose a NAK
+  }
+
   //TODO: process our command!
+  switch(inbuf[0])
+  {
+    default:
+      //TODO: compose another NAK!
+      break;
+  }
+  pkti=0; // we are ready for the next packet!
+  serialOutDeque();
 }


added a bunch of random words

added a bunch of random words

--- buzzword.ino
+++ buzzword.ino
@@ -32,7 +32,7 @@
 volatile boolean timeFlag = false;

 //List of 'buzzwords' and the current 'buzzword'
-char* listOfWords[]={"test", "puzzle", "watermelon", "tree", "boat", "squirrel"};
+char* listOfWords[]={"test", "puzzle", "watermelon", "tree", "boat", "squirrel", "Miley Cyrus", "America", "Facebook", "twerk", "hashtag", "Bye Felicia", "swerve", "on point", "Rihanna", "North West", "Donald Trump", "Lil' Wayne", "Hellen Keller", "wrecking ball", "Einstein", "Tech Nine", "Queen", "Bohemian", "Rwanda", "Iraq", "Selma", "76ers", "Knicks", "scrub", "Cardinals", "Mariners", "Brewers", "Orioles", "Iggy Azalea", "The Clash", "Katy Perry", "John Legend", "Las Vegas", "Portland", "Milwaukee", "cookie jar", "Goldschlager", "Fireball", "Jagermeister", "bench press", "hangover", "munchies"};
 int listOfWordsLength = sizeof(listOfWords) / sizeof(int);
 char* currentWord = "";
 int currentWordIndex = 0;
@@ -143,7 +143,7 @@
   int currentWordLength = strlen(currentWord);

   // calculate ideal x-axis positioning based on size of word
-  int xAxisPlacement = (160 - ((currentWordLength * 20) / 2));
+  int xAxisPlacement = (160 - ((currentWordLength * 23) / 2));

   // Note: Since we are using the TFT shield in the "landscape" orientation,
   // the x and y values (as humans understand them) have been transposed;


Update connect4.ino

Update connect4.ino

// Connect 4
// P Beard
// Jan 2015

char board[43];

// Array containing start position of each "win line"
byte lineStart[] = { 0,  7, 14, 21, 28, 35,  0,  1,  2,  3,  4,  5,  6, 14,  7,  0,  1,  2,  3,  3,  4,  5,  6, 13, 20};
// Array containing number of groups of 4 positions on each "win line"
byte lineReps[] =  { 4,  4,  4,  4,  4,  4,  3,  3,  3,  3,  3,  3,  3,  1,  2,  3,  3,  2,  1,  1,  2,  3,  3,  2,  1};
// Array containing direction offset for each "win line"
byte lineSteps[] = { 1,  1,  1,  1,  1,  1,  7,  7,  7,  7,  7,  7,  7,  8,  8,  8,  8,  8,  8,  6,  6,  6,  6,  6,  6};

void setup() {
  Serial.begin(9600);
  Serial.println();
  Serial.println("~~~~~~Connect 4~~~~~~");
  Serial.println();
  for (byte i = 0; i < 43; i++) board[i] = '.';
  displayBoard(board);
}

void loop() {
  char c;
  byte best;
  int currentScore;

  Serial.println();
  Serial.print("Your go:");
  while (Serial.available() < 1) {} // wait for key code
  c = Serial.read();
  Serial.println(c);
  Serial.println();
  while (Serial.available() < 1) {} // wait for CR code
  Serial.read(); // discard CR code
  dropCounter(board, 'O', c - '0');
  displayBoard(board);

  if (score(board, 'X', 'O') == -1000) {
    Serial.println();
    Serial.println ("****CONGRATULATIONS YOU WIN**** ");
    Serial.println();
    Serial.println("Press reset for new game");
    while (true) {}
  }
  else {

    Serial.println();
    Serial.print("My go:");
    //unsigned long t = millis();
    currentScore = bestMove(board, 'X', 'O', best, 4);
    //Serial.println(millis() - t);
    Serial.println(best);
    Serial.println();
    dropCounter(board, 'X', best);
    displayBoard(board);

    if (score(board, 'X', 'O') == 1000) {
      Serial.println();
      Serial.println ("****COMISERATIONS YOU LOST****");
      Serial.println();
      Serial.println("Press reset for new game");
      while (true) {}
    }
  }
}

void displayBoard(char board[]) {

  Serial.println("0123456");

  byte i = 0;

  for(byte row = 0; row <= 5; row++) {
    for(byte col = 0; col <= 6; col++) {
      Serial.print(board[i++]);
    }
    Serial.println();
  }
}

byte dropCounter(char board[], char token, byte col) {

  byte i = col;

  // Test if the position one row down is empty
  while (i < 35 && board[i+7] == '.') {
    // Move down a row
    i += 7;
  }
  // Place the token here
  board[i] = token;
  return i;
}

int score(char board[], char token, char oppToken) {

  int totalScore = 0;

  // Scan each "win" line on the board
  for (byte line = 0; line < 25; line++) {

    byte i = lineStart[line];
    byte lineStep = lineSteps[line];
    byte reps = lineReps[line];

    // Scan each group of 4 positions on the "win" line
    for (byte rep = 0; rep < reps; rep++) {

      byte j = i;
      int addScore = 0;

      // Check this group of 4 positions
      for (byte pos = 0; pos < 4; pos++) {

        if (board[j] == token) {
          if (addScore < 0) {
            // A mix of "O" and "X" - no-one can win here
            addScore = 0;
            break;
          }
          else if (addScore == 0) addScore = 1;
          else if (addScore == 1) addScore = 10;
          else if (addScore == 10) addScore = 100;
          else if (addScore == 100) {
            // The game has been won
            totalScore = 1000;
            goto gameWon;
          }
        }
        else if (board[j] == oppToken) {
          if (addScore > 0) {
            // A mix of "O" and "X" - no-one can win here
            addScore = 0;
            break;
          }
          else if (addScore == 0) addScore = -1;
          else if (addScore == -1) addScore = -10;
          else if (addScore == -10) addScore = -100;
          else if (addScore == -100) {
            // The game has been won
            totalScore = -1000;
            goto gameWon;
          }
        }
        // Move to next position in group of 4
        j += lineStep;
      }
      // Move to next start position of next group-of-4 on the win line
      i += lineStep;
      // Add any score to the total score for the board
      totalScore += addScore;
    }
  }
  gameWon: return totalScore;
}

int bestMove(char board[], char token, char oppToken, byte &bestCol, byte lookAhead) {

  int bestScore = -9999;

  // Make a copy of the board
  char boardCopy[43];
  for (byte i = 0; i < 43; i++) boardCopy[i] = board[i];

  // Evaluate each choice of column
  for (byte col = 0; col < 7; col++) {
    if (board[col] == '.') {

      // Drop token onto the copy of the board
      byte counterPosition = dropCounter(boardCopy, token, col);
      int thisScore = score(boardCopy, token, oppToken);

      if (thisScore > -1000 && thisScore < 1000 && lookAhead > 0) {
        // Look more moves ahead, but swap places with opponent since it will be their turn next
        byte oppBestCol;
        thisScore = -bestMove(boardCopy, oppToken, token, oppBestCol, lookAhead - 1);
      }

      // Check this choice of column - best so far?
      if (thisScore > bestScore) {
        // Yes, a new best choice found
        bestScore = thisScore;
        bestCol = col;
      }
      // remove the counter again
      boardCopy[counterPosition] = '.';
    }
  }
  return bestScore;
}

Remove timing functions

--- connect4.ino
+++ connect4.ino
@@ -47,9 +47,9 @@

     Serial.println();
     Serial.print("My go:");
-    unsigned long t = millis();
+    //unsigned long t = millis();
     currentScore = bestMove(board, 'X', 'O', best, 4);
-    Serial.println(millis() - t);
+    //Serial.println(millis() - t);
     Serial.println(best);
     Serial.println();
     dropCounter(board, 'X', best);


Test the 'invert' operation

Test the 'invert' operation

--- TJCTM24024-SPI/graphics_test/graphics_test.ino
+++ TJCTM24024-SPI/graphics_test/graphics_test.ino
@@ -53,12 +53,16 @@
 void loop(void)
 {
   benchmarks();
-
+
   for (uint8_t rotation=0; rotation<4; rotation++)
   {
     tft.setRotation(rotation);
     testText();
-    delay(1000);
+    delay(500);
+    tft.invertDisplay(1);
+    delay(500);
+    tft.invertDisplay(0);
+//    delay(1000);
   }
   tft.setRotation(0);
 }


stairs: fix watchdog reboots, but try reducing flickering

--- stairs/src/main.ino
+++ stairs/src/main.ino
@@ -1,8 +1,11 @@
 // Configuration
 #include "config.h"

+// see https://github.com/FastLED/FastLED/issues/306
+#define FASTLED_INTERRUPT_RETRY_COUNT 0
+//#define FASTLED_ALLOW_INTERRUPTS 0
+
 // Use the FastLED library.
-#define FASTLED_ALLOW_INTERRUPTS 0
 #include <FastLED.h>

 // Wifi and MQTT
@@ -259,6 +262,7 @@
     mqtt_handle_temperature("300");

     WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
+    WiFi.setSleepMode(WIFI_NONE_SLEEP);

     mqtt_client.setServer(MQTT_SERVER_IP, MQTT_SERVER_PORT);
     mqtt_client.setCallback(mqtt_callback);


Analog sensor

Analog sensor

--- Hall_Sense/Hall_Sense.ino
+++ Hall_Sense/Hall_Sense.ino
@@ -1,20 +1,33 @@
 #define LINE_COUNT 50
-#include <PinChangeInt.h>
+#define HALL_SENSOR A4
+
+int oldPinValue;
+int nowPinValue;
+long oldTimeStamp;
+long nowTimeStamp;

 void setup()
 {
   Serial.begin(115200);
-
+  oldTimeStamp = millis();
+  oldPinValue = returnLineCount(analogRead(HALL_SENSOR));
 }

 void loop()
 {
-  printLines(returnLineCount(analogRead(A4)));
+  nowPinValue = returnLineCount(analogRead(HALL_SENSOR));
+  if (nowPinValue - oldPinValue >= 2)
+  {
+    nowTimeStamp = millis();
+    Serial.println(nowTimeStamp - oldTimeStamp);
+    oldTimeStamp = nowTimeStamp;
+  }
+  oldPinValue = nowPinValue;
 }

 int returnLineCount(int value)
 {
-  return (float)value / 1024 * LINE_COUNT;
+  return (float)value / 255 * LINE_COUNT;
 }

 void printLines(int value)


Did everything wrong now fixed

Did everything wrong now fixed

--- MazeSolver/MazeSolver.ino
+++ MazeSolver/MazeSolver.ino
@@ -140,7 +140,6 @@
 	int motorSpeed;
 	int posPropotionalToMid;

-  int ;
 	//direction = forward;

 	turnOffAllLeds();
@@ -164,7 +163,7 @@

 		moveBothMotors(maxMotorSpeed, forward, maxMotorSpeed, backward);
 		checkForNewLineOnSide(right);
-    path[pathLength]= back;
+    path[pathLength]= backward;
     simplifyMaze();
 		break;

@@ -331,7 +330,7 @@
 {
   pathLength++;

-  if(pathLength < 3 || path[pathLength-2] != back)
+  if(pathLength < 3 || path[pathLength-2] != backward)
     return;

   int totalAngle = 0;
@@ -359,16 +358,16 @@
   switch(totalAngle)
   {
     case 0:
-  path[pathLength - 3] = 'S';
+  path[pathLength - 3] = forward;
   break;
     case 90:
-  path[pathLength - 3] = 'R';
+  path[pathLength - 3] = right;
   break;
     case 180:
-  path[pathLength - 3] = 'B';
+  path[pathLength - 3] = backward;
   break;
     case 270:
-  path[pathLength - 3] = 'L';
+  path[pathLength - 3] = left;
   break;
   }


fast frequency control

fast frequency control


Fix arduino test

Fix arduino test

--- example/shadow.ino
+++ example/shadow.ino
@@ -1,4 +1,4 @@
-#include "mjson.h"  // Sketch -> Add File -> Add mjson.h
+#include "mjson.c"  // Sketch -> Add File -> Add mjson.c

 static int ledOn = 0;  // Current LED status


Update FirstArd.ino

Update FirstArd.ino

Removed duplicate functions

--- FirstArd.ino
+++ FirstArd.ino
@@ -301,52 +301,3 @@
     Stop();
   }
 }
-
-//********************************************
-//Defining Robot's Potential Actions as functions
-//Stop, move forward, turn left, turn right
-//Call different order of functions depending on the potential
-//situations in the maze (3-way fork, left only, etc.)
-//********************************************
-
-void Stop()
-  {
-  analogWrite(motor1Pin1, LOW);
-  analogWrite(motor1Pin2, LOW);
-  analogWrite(motor2Pin1, LOW);
-  analogWrite(motor2Pin2, LOW);
-  }
-
-void goForward()
-  {
-  analogWrite(motor1Pin1, LOW);
-  analogWrite(motor1Pin2, 255);
-  analogWrite(motor2Pin1, LOW);
-  analogWrite(motor2Pin2, 255);
-  }
-
-void turnRight()
-  {
-  analogWrite(motor1Pin1, 200);
-  analogWrite(motor1Pin2, LOW);
-  analogWrite(motor2Pin1, LOW);
-  analogWrite(motor2Pin2, 200);
-  }
-
-void turnLeft()
-  {
-  analogWrite(motor1Pin1, LOW);
-  analogWrite(motor1Pin2, 200);
-  analogWrite(motor2Pin1, 200);
-  analogWrite(motor2Pin2, LOW);
-  }
-
-/*
-void tiltLeft()
-{
-  analogWrite(motor1Pin1, 100);
-  analogWrite(motor1Pin2, LOW);
-  analogWrite(motor2Pin1, 150);
-  analogWrite(motor2Pin2, LOW);
-}
-*/


Update EditorBridge.ino

Update EditorBridge.ino

updated to the latest version from http://www.fredslab.net/opa/

--- Sketches/EditorBridge.ino
+++ Sketches/EditorBridge.ino
@@ -1,31 +1,37 @@
 /*
- * OPA Shield
- * fredslab.net
- * Editor bridge sketch
- * 11/02/2016
- */
-
+
+    OPA Shield
+    fredslab.net
+    Editor bridge sketch
+    30/06/2016 */
+
 /** OPA shield pin mapping */
-#define OPA_TX     0
-#define OPA_RX     1
-#define OPA_CS1    2
-#define OPA_CS2    3
-#define OPA_SWAP   4
-#define OPA_RESET  7
+#define OPA_TX 0
+#define OPA_RX 1
+#define OPA_CS1 2
+#define OPA_CS2 3
+#define OPA_SWAP 4
+#define OPA_RESET 7

 /** Hardware setup */
 void setup()
 {
-  pinMode(OPA_TX, INPUT);
-  pinMode(OPA_RX, INPUT);
-  pinMode(OPA_CS, OUTPUT);
-  pinMode(OPA_SWAP, OUTPUT);
+pinMode(OPA_TX, INPUT);
+pinMode(OPA_RX, INPUT);
+pinMode(OPA_CS1, OUTPUT);
+pinMode(OPA_CS2, OUTPUT);
+pinMode(OPA_SWAP, OUTPUT);
+pinMode(OPA_RESET, OUTPUT);

-  digitalWrite(OPA_CS, 0);
-  digitalWrite(OPA_SWAP, 1);
+digitalWrite(OPA_CS1, 0);
+digitalWrite(OPA_CS2, 0);
+digitalWrite(OPA_SWAP, 1);
+digitalWrite(OPA_RESET, 0);
+
 }

 /** Main program */
 void loop()
 {
+// Do nothing
 }


comments

comments

--- SmartMatrix_Fadecandy.ino
+++ SmartMatrix_Fadecandy.ino
@@ -22,8 +22,10 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */

-// Requires SmartMatrix 3.0
+// Requires SmartMatrix Library 3.0
 // Compile with Teensy USB Type: "No USB" - error "multiple definition of `usb_isr'" means you forgot to set USB Type to "No USB"
+// adjust FRAME_WIDTH and FRAME_HEIGHT in fc_defs.h to match kMatrixWidth/Height
+// If green artifacts are seen, adjust NUM_USB_BUFFERS in fc_defs.h

 #include <SmartMatrix3.h>
 #include "Layer_Fadecandy.h"
@@ -31,7 +33,7 @@
 static fcBuffers buffers;
 fcLinearLUT fcBuffers::lutCurrent;

-#define COLOR_DEPTH 24                  // This sketch and FastLED uses type `rgb24` directly, COLOR_DEPTH must be 24
+#define COLOR_DEPTH 24                  // In this sketch, COLOR_DEPTH only applies to scrollingLayer
 const uint8_t kMatrixWidth = 32;        // known working: 32, 64, 96, 128
 const uint8_t kMatrixHeight = 32;       // known working: 16, 32, 48, 64
 const uint8_t kRefreshDepth = 36;       // known working: 24, 36, 48
@@ -55,6 +57,8 @@
     matrix.addLayer(&fadecandyLayer);
     matrix.addLayer(&scrollingLayer);
     matrix.begin();
+
+    // print something so we aren't just greeted with a blank screen on start
     scrollingLayer.start("fadecandy",1);
 }


melhorado mensagens e liga/desliga

melhorado mensagens e liga/desliga

--- EMP-B-Due.ino
+++ EMP-B-Due.ino
@@ -122,8 +122,10 @@
       reiniciaSaidas();
     }
   } else if (!alarme_ativo) {
+    escreveSerial("Preparando para iniciar trabalho.");
     delay(3000); // Espera 3 segundos após energização
     stand_by = VERDADEIRO; // Libera funcionamento
+    escreveSerial("Tudo pronto!");
   }
 }

@@ -164,14 +166,14 @@
   unsigned long inativo = ciclo_PWM - ativo;
   if (maquina_ligada and !alarme_ativo){
     if (millis() > *inicio && millis() <= (*inicio + ativo)){
-      liga(saida, nome);
+      liga(saida);
     } else if (millis() > (*inicio + ativo) && millis() < (*inicio + ciclo_PWM)){
-      desliga(saida, nome);
+      desliga(saida);
     } else if (millis() >= (*inicio + ciclo_PWM)) {
       *inicio = millis();
     }
   } else {
-    desliga(saida, nome);
+    desliga(saida);
   }
 }

@@ -180,7 +182,7 @@
   stand_by = FALSO;
   escreveSerial("\n<< Alarme! >>\n");
   reiniciaSaidas();
-  escreveSerial(texto + " detectou uma falha de segurança.");
+  escreveSerial(texto + " detectou uma falha!");
 }

 void btUmClique(byte botao, int *estado, int *est_ant, unsigned long *atr_ant, boolean *funcao){
@@ -206,16 +208,24 @@
   return digitalRead(pino);
 }

-void liga(byte saida, String texto){
+void liga(byte saida){
+  digitalWrite(saida, LIGA);
+}
+
+void ligaFuncao(byte saida, String texto){
   if (desligado(saida)){
-    digitalWrite(saida, LIGA);
+    liga(saida);
     escreveSerial(texto + " Ligado.");
   }
 }

-void desliga(byte saida, String texto){
+void desliga(byte saida){
+  digitalWrite(saida, DESLIGA);
+}
+
+void desligaFuncao(byte saida, String texto){
   if (ligado(saida)){
-    digitalWrite(saida, DESLIGA);
+    desliga(saida);
     escreveSerial(texto + " Desligado.");
   }
 }
@@ -262,36 +272,36 @@
   dosador_ligado = FALSO;
   datador_ligado = FALSO;

-  desliga(geral, NomeGeral);
-  desliga(dosador, NomeDosador);
-  desliga(datador, NomeDatador);
+  desligaFuncao(geral, NomeGeral);
+  desligaFuncao(dosador, NomeDosador);
+  desligaFuncao(datador, NomeDatador);
 }

 void resetCompleto(){
-  digitalWrite(geral, DESLIGA);
-  digitalWrite(dosador, DESLIGA);
-  digitalWrite(datador, DESLIGA);
-
-  digitalWrite(solda_vertical, DESLIGA);
-  digitalWrite(solda_horizontal, DESLIGA);
-  digitalWrite(solda_datador, DESLIGA);
+  desliga(geral);
+  desliga(dosador);
+  desliga(datador);
+
+  desliga(solda_vertical);
+  desliga(solda_horizontal);
+  desliga(solda_datador);
 }

 void modoTeste(){
   if (maquina_ligada){
-    liga(geral, NomeGeral);
-  } else {
-    desliga(geral, NomeGeral);
+    ligaFuncao(geral, NomeGeral);
+  } else {
+    desligaFuncao(geral, NomeGeral);
   }
   if (dosador_ligado){
-    liga(dosador, NomeDosador);
-  } else {
-    desliga(dosador, NomeDosador);
+    ligaFuncao(dosador, NomeDosador);
+  } else {
+    desligaFuncao(dosador, NomeDosador);
   }
   if (datador_ligado){
-    liga(datador, NomeDatador);
-  } else {
-    desliga(datador, NomeDatador);
-  }
-}
+    ligaFuncao(datador, NomeDatador);
+  } else {
+    desligaFuncao(datador, NomeDatador);
+  }
+}


Fix EEPROM data readback

Fix EEPROM data readback

--- libraries/BLE/examples/ble_uart_project_with_dfu_template/bootloader_setup.ino
+++ libraries/BLE/examples/ble_uart_project_with_dfu_template/bootloader_setup.ino
@@ -89,7 +89,7 @@
 {
   const uint16_t eeprom_base_addr = E2END - BOOTLOADER_EEPROM_SIZE;

-  uint8_t readback_buff[BOOTLOADER_EEPROM_SIZE];
+  uint8_t readback_buf;
   uint16_t addr;
   uint16_t crc_eeprom;
   uint16_t crc_readback;
@@ -165,15 +165,18 @@
      * compute a CRC16 for the data actually in EEPROM to compare with
      * the CRC already in EEPROM.
      */
-    for (addr = eeprom_base_addr; addr < eeprom_base_addr + len; addr++)
+    addr = eeprom_base_addr;
+    readback_buf = EEPROM.read(addr++);
+    crc_readback = crc_16_ccitt(0xFFFF, &readback_buf, 1);
+    for (; addr < eeprom_base_addr + len; addr++)
     {
-      readback_buff[addr] = EEPROM.read(addr);
+      readback_buf = EEPROM.read(addr);
+      crc_readback = crc_16_ccitt(crc_readback, &readback_buf, 1);
     }

     crc_eeprom = (uint16_t) EEPROM.read(addr++);
     crc_eeprom |= (uint16_t) (EEPROM.read(addr) << 8);

-    crc_readback = crc_16_ccitt(0xFFFF, readback_buff, len);

     return crc_eeprom == crc_readback;
   }