Add Documentation to Arduino code, no significant changes yet

--- Arduino_Code/Arduino_Code.ino
+++ Arduino_Code/Arduino_Code.ino
@@ -42,27 +42,20 @@
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  recString.reserve(200);
- //seqSize = 0;
  seqIndex = 0;
 }

 void loop() {
-
-  // put your main code here, to run repeatedly:
+
   if (playerCreating || playerRepeating)
   {
+    'if button is pressed, turn on LED
     for (int i = 0; i < 4; i ++) {
       if (digitalRead(btn[i]) == 1) {
         digitalWrite(led[i], HIGH);
-        //Serial.print("LED ");
-        //Serial.print(i);
-        //Serial.print(" on    ");
       }
       else {
         digitalWrite(led[i], LOW);
-        //Serial.print("LED ");
-        //Serial.print(i);
-        //Serial.print(" off    ");
       }
     }
   }
@@ -78,7 +71,8 @@

     //If sequence index is less than the length, we are still outputting the sequence
-    if((seqIndex < seqSize) && playerRepeating == false && playerCreating == false){
+    if((seqIndex < seqSize) && playerRepeating == false && playerCreating == false)
+    {
       //If an LED was on and change must be made
       if (LEDon && (millis() - timeOfLastChange >= 1000))
       {
@@ -109,17 +103,18 @@
       //Check each button for change
       for (int i = 0; i < 4; i ++)
       {
+        'if the button wasn't pressed previously and is now
         if (!prevBtns[i] && digitalRead(btn[i]))
         {
           prevBtns[i] = true;
           delay(150);
         }
-        else if(prevBtns[i] && (digitalRead(btn[i]) == false))
+        else if(prevBtns[i] && !digitalRead(btn[i]))
         {
           prevBtns[i] = false;
           repeatArr[seqIndex] = i;
           seqIndex += 1;
-          //Check user for correctness
+          //Check user for correctness once the entire sequence has been entered
           if (seqIndex == seqSize)
           {
             boolean correct = true;


* adicionado prova de conceito

* adicionado prova de conceito

--- arduino/carro_microcontrolado/carro_algoritmo/carro_algoritmo.ino
+++ arduino/carro_microcontrolado/carro_algoritmo/carro_algoritmo.ino
@@ -206,11 +206,53 @@
   delay(random_time);
 }

-
-
-
-
-
-
-
-
+//rota de apoio para calculo da velocidade
+void rota_aux_4(){
+  delay(t_m * 2);
+  digitalWrite(tra_en, HIGH);
+  digitalWrite(tra_fr, HIGH); //frente
+  delay(1000);
+  digitalWrite(tra_en, LOW); //desliga
+  delay(3000); //aguarda 3s para medir
+}
+
+//prova de conceito - trajetoria 1
+void rota_5(){
+  delay(t_m * 2);
+  digitalWrite(tra_en, HIGH);
+  if(estado==0){
+    estado = 1;
+    digitalWrite(tra_fr, HIGH); //frente
+  }else{
+    estado = 0;
+    digitalWrite(tra_tr, HIGH); //ré
+  }
+  delay(2500); //tempo para percorrer 3m
+}
+
+//prova de conceito - trajetoria 2
+void rota_6(){
+  delay(t_m * 2);
+  digitalWrite(tra_en, HIGH);
+  digitalWrite(dir_en, HIGH);
+  digitalWrite(dir_di, HIGH); //roda sempre para direita
+  delay(t_m);
+  if(estado==0){
+    estado = 1;
+    digitalWrite(tra_fr, HIGH); //frente
+  }else{
+    estado = 0;
+    digitalWrite(tra_tr, HIGH); //ré
+  }
+  delay(4580); //tempo para percorrer o perimetro com 5,49m
+}
+
+
+
+
+
+
+
+
+
+


updated comments

updated comments

--- KISS_OSD/KISS_OSD.ino
+++ KISS_OSD/KISS_OSD.ino
@@ -14,6 +14,7 @@

 KISS FC OSD v1.4
 by Alexander Wolf (awolf78@gmx.de)
+Donate: www.paypal.me/awolf78

 Anyone is free to copy, modify, publish, use, compile, sell, or
 distribute this software, either in source code form or as a compiled


Fixed formatting of output.

Fixed formatting of output.

--- examples/Sandbox/CosaMPEreceiver/CosaMPEreceiver.ino
+++ examples/Sandbox/CosaMPEreceiver/CosaMPEreceiver.ino
@@ -68,7 +68,7 @@
     trace << PSTR("Packages received:") << count
 	  << endl
 	  << PSTR("Packages per second:") << pps
-	  << PSTR("(") << n << PSTR(" bytes)")
+	  << PSTR(" (") << n << PSTR(" bytes)")
 	  << endl
 	  << PSTR("Bytes per second:") << pps * n
 	  << endl


Update BB-UNIT.ino

Update BB-UNIT.ino

--- Firmware/BB-UNIT/BB-UNIT.ino
+++ Firmware/BB-UNIT/BB-UNIT.ino
@@ -292,7 +292,7 @@
     remote.begin(9600);

     // Start remote connexion
-    if(ifhead)
+    if(ifHead)
     {
 	Serial.println("[5]-Initializing HC-12 devices [ HEAD ] ");
         remote.begin(9600);


2017 update

2017 update

--- EverythingOn/EverythingOn.ino
+++ EverythingOn/EverythingOn.ino
@@ -1,10 +1,23 @@
 #include "Constants.h"

 void setup() {
-    for (int i = 0; i < sizeof(Lights); i++) {
-        pinMode(Lights[i], PATTERN_INITIALIZE);
-    }
-}
+      pinMode(Lights[0], PATTERN_INITIALIZE);
+      pinMode(Lights[1], PATTERN_INITIALIZE);
+      pinMode(Lights[2], PATTERN_INITIALIZE);
+      pinMode(Lights[3], PATTERN_INITIALIZE);
+      pinMode(Lights[4], PATTERN_INITIALIZE);
+      pinMode(Lights[5], PATTERN_INITIALIZE);
+      pinMode(Lights[6], PATTERN_INITIALIZE);
+      pinMode(Lights[7], PATTERN_INITIALIZE);
+      pinMode(Lights[8], PATTERN_INITIALIZE);
+      pinMode(Lights[9], PATTERN_INITIALIZE);
+      pinMode(Lights[10], PATTERN_INITIALIZE);
+      pinMode(Lights[11], PATTERN_INITIALIZE);
+      pinMode(Lights[12], PATTERN_INITIALIZE);
+      pinMode(Lights[13], PATTERN_INITIALIZE);
+      pinMode(Lights[14], PATTERN_INITIALIZE);
+      pinMode(Lights[15], PATTERN_INITIALIZE);
+ }

 // code above the man is ignored by the emulator
 // code below it is transpiled into js and run by the emulator
@@ -14,7 +27,20 @@
 // roughly: anything that calls `digitalWrite();` is a scene

 void loop() {
-    for (int i = 0; i < sizeof(Lights); i++) {
-      digitalWrite(Lights[i], PATTERN_ON);
-    }
+      digitalWrite(Lights[0], PATTERN_ON);
+      digitalWrite(Lights[1], PATTERN_ON);
+      digitalWrite(Lights[2], PATTERN_ON);
+      digitalWrite(Lights[3], PATTERN_ON);
+      digitalWrite(Lights[4], PATTERN_ON);
+      digitalWrite(Lights[5], PATTERN_ON);
+      digitalWrite(Lights[6], PATTERN_ON);
+      digitalWrite(Lights[7], PATTERN_ON);
+      digitalWrite(Lights[8], PATTERN_ON);
+      digitalWrite(Lights[9], PATTERN_ON);
+      digitalWrite(Lights[10], PATTERN_ON);
+      digitalWrite(Lights[11], PATTERN_ON);
+      digitalWrite(Lights[12], PATTERN_ON);
+      digitalWrite(Lights[13], PATTERN_ON);
+      digitalWrite(Lights[14], PATTERN_ON);
+      digitalWrite(Lights[15], PATTERN_ON);
 }


Display welcome message.

Display welcome message.

--- src/main.ino
+++ src/main.ino
@@ -45,9 +45,9 @@
   setupMQTT();

 #ifdef DEBUG
-  DEBUGLOG("%s - %s\n", APP_NAME, APP_VERSION);
-  DEBUGLOG("%s\n", getDeviceID());
-  DEBUGLOG("\n")
+  Serial.printf("%s - %s\n", APP_NAME, APP_VERSION);
+  Serial.printf("%s\n", getDeviceID());
+  Serial.println();
   wifiStatus();
 #endif


Examples: Full WDRC_8BandIIR trying to get Travis to say OK

--- examples/05-FullSystems/WDRC_8BandIIR_wAFC/WDRC_8BandIIR_wAFC.ino
+++ examples/05-FullSystems/WDRC_8BandIIR_wAFC/WDRC_8BandIIR_wAFC.ino
@@ -208,7 +208,7 @@
   configurePerBandWDRCs(N_CHAN, settings.sample_rate_Hz, this_dsl, this_gha, expCompLim);

   //setup the broad band compressor (limiter)
-  configureBroadbandWDRCs(settings.sample_rate_Hz, this_gha, vol_knob_gain_dB, compBroadband);
+  configureBroadbandWDRC(settings.sample_rate_Hz, this_gha, vol_knob_gain_dB, &compBroadband);

   //overwrite the one-point calibration based on the dsl data structure
   overall_cal_dBSPL_at0dBFS = this_dsl.maxdB;
@@ -228,8 +228,8 @@
   }
 }

-void configureBroadbandWDRCs(float fs_Hz, const BTNRH_WDRC::CHA_WDRC &this_gha,
-      float vol_knob_gain_dB, AudioEffectCompWDRC_F32 &WDRC)
+void configureBroadbandWDRC(float fs_Hz, const BTNRH_WDRC::CHA_WDRC &this_gha,
+      float vol_knob_gain_dB, AudioEffectCompWDRC_F32 *WDRC)
 {
   //assume all broadband compressors are the same
   //for (int i=0; i< ncompressors; i++) {
@@ -251,14 +251,14 @@
     //set the compressor's parameters
     //WDRCs[i].setSampleRate_Hz(fs);
     //WDRCs[i].setParams(atk, rel, maxdB, exp_cr, exp_end_knee, tkgain, comp_ratio, tk, bolt);
-    WDRC.setSampleRate_Hz(fs);
-    WDRC.setParams(atk, rel, maxdB, exp_cr, exp_end_knee, tkgain + vol_knob_gain_dB, comp_ratio, tk, bolt);
+    WDRC->setSampleRate_Hz(fs);
+    WDRC->setParams(atk, rel, maxdB, exp_cr, exp_end_knee, tkgain + vol_knob_gain_dB, comp_ratio, tk, bolt);
  // }
 }

 void configurePerBandWDRCs(int nchan, float fs_Hz,
     const BTNRH_WDRC::CHA_DSL &this_dsl, const BTNRH_WDRC::CHA_WDRC &this_gha,
-    AudioEffectCompWDRC_F32 *WDRCs)
+    AudioEffectCompWDRC_F32 WDRCs[])
 {
   if (nchan > this_dsl.nchannel) {
     myTympan.println(F("configureWDRC.configure: *** ERROR ***: nchan > dsl.nchannel"));


Show the mA charge on the led panel

Show the mA charge on the led panel

--- Receiver/LoRa_RX/LoRa_RX.ino
+++ Receiver/LoRa_RX/LoRa_RX.ino
@@ -59,8 +59,8 @@
   Serial.begin(115200);

   // Show the led panel is working.
-  //garden_payload.setMsgId(0b10101010);
-  garden_payload.setMsgId(0);
+  garden_payload.setMsgId(0b10101010);
+  //garden_payload.setMsgId(0);
   updateLedPanel();

   Serial.println("LoRa RX");
@@ -130,27 +130,7 @@
       Serial.write('\t'); // Payload start byte
       Serial.write(signal_payload_buf, signal_payload.size());

-      //updateLedPanel();
-
-//      // There needs to be a small delay before sending the reply.
-//      // YUK
-//      delay(100);
-//
-//      // Send a reply
-//      ack_payload.setMsgId(garden_payload.getMsgId());
-//      //ack_payload.setValue(1234);
-//      uint8_t ack_payload_buf[ack_payload.size()];
-//      ack_payload.serialize(ack_payload_buf);
-//      rf95.send(ack_payload_buf, ack_payload.size());
-//      //uint8_t encrypted_ack_buffer[16];
-//      //cipher.encryptBlock(encrypted_ack_buffer, ack_payload_buf);
-//      //rf95.setHeaderTo(garden_node_id);
-//      //rf95.setHeaderFrom(rx_node_id);
-//      //rf95.send(encrypted_ack_buffer, 16);
-//      rf95.waitPacketSent();
-
-
-      //digitalWrite(LED, LOW);
+      updateLedPanel();

     } else {
       Serial.println("Receive failed");
@@ -160,7 +140,7 @@

 void updateLedPanel() {
-  byte d = garden_payload.getMsgId();
+  byte d = garden_payload.getChargeMa();

   digitalWrite(SR_LATCH, LOW);
   // Bit shift left as there is no 8th led.


Sync clock with cloud every day

Sync clock with cloud every day

--- src/IoTBox.ino
+++ src/IoTBox.ino
@@ -5,7 +5,13 @@
  * Date: 17.09.2017
  */

+ STARTUP(WiFi.selectAntenna(ANT_EXTERNAL));
+ SYSTEM_MODE(AUTOMATIC)
+ SYSTEM_THREAD(ENABLED);
+
 #include "Grove_LCD_RGB_Backlight.h"
+
+#define ONE_DAY_MILLIS (24 * 60 * 60 * 1000)

 #define BUTTONPIN D2 // Button reserved for further usage
 #define BUZZERPIN D3 // Buzzer reserved for further usage
@@ -13,51 +19,56 @@
 #define SWITCHPIN D6 // Switch for "LOCKED" or "OPEN" status.
 #define LEDPIN D7 // Status LED.

+unsigned long lastSync = millis();
+
 rgb_lcd lcd;

-class OpenOperation {
-  public:
-
-    OpenOperation() {
-        _timer = new Timer(3000, (void (*)())&OpenOperation::callback, true);
-    }
-
-    void start() {
-        // TODO: Check if box is arelady open
-        // TODO: Delay 2 seconds after 2 consecutive open operations
-        if (!isRunning()) {
-            lcd.setCursor(0,1);
-            lcd.print("               ");
-            lcd.setCursor(0,1);
-            lcd.print("opening....");
-            digitalWrite(RELAYPIN, HIGH);
-            _timer->reset();
-        }
-    }
-
-    void stop() {
-        digitalWrite(RELAYPIN, LOW);
-        _timer->dispose();
-    }
-
-    bool isRunning() {
-        return _timer->isActive();
-    }
-
-  private:
-    Timer* _timer;
-    void callback(void) {
-        digitalWrite(RELAYPIN, LOW);
-    }
-};
-
-volatile int switchState = LOW;
+int switchState = LOW; // HIGH = locked, LOW = open
 volatile bool requestDisplayStatus = true;
 volatile bool requestDisplayTime = false;
 volatile bool requestDisplayConfigurationTime = true;
 volatile bool requestOpeningOperation = false;
 volatile bool isLCDBusy = false;

+class OpenOperation {
+  public:
+
+    OpenOperation() {
+        _timer = new Timer(2000, (void (*)())&OpenOperation::callback, true);
+    }
+
+    void start() {
+        // TODO: Check if box is arelady open
+        // TODO: Delay 2 seconds after 2 consecutive open operations
+        if (!isRunning()) {
+            // Only open the box when it is closed
+            if (switchState == HIGH) {
+                lcd.setCursor(0,1);
+                lcd.print("               ");
+                lcd.setCursor(0,1);
+                lcd.print("opening....");
+                digitalWrite(RELAYPIN, HIGH);
+                _timer->reset();
+            }
+        }
+    }
+
+    void stop() {
+        digitalWrite(RELAYPIN, LOW);
+        _timer->dispose();
+    }
+
+    bool isRunning() {
+        return _timer->isActive();
+    }
+
+  private:
+    Timer* _timer;
+    void callback(void) {
+        digitalWrite(RELAYPIN, LOW);
+    }
+};
+
 Timer clockTimer(1000, updateTime); // timer used to display the clock on the lcd display

 OpenOperation openOperation;
@@ -67,6 +78,7 @@
 volatile int second;

 int configureTime(String time);
+void syncTimeWithCloudIfNeeded();

 struct ConfigurationTime {
     uint8_t version;
@@ -76,8 +88,6 @@

 ConfigurationTime configurationTime;

-STARTUP(WiFi.selectAntenna(ANT_EXTERNAL));
-
 void setup() {
     // Ouput pins
     pinMode(LEDPIN, OUTPUT);
@@ -100,7 +110,7 @@
     Time.zone(+2.00);

     // Register the status of the box to Particle Cloud
-    Particle.variable("switchState", (int32_t)switchState);
+    Particle.variable("switchState", switchState);

     // Register the configureTime as a cloud function
     Particle.function("time", configureTime);
@@ -116,6 +126,8 @@
 }

 void loop() {
+    syncTimeWithCloudIfNeeded();
+
     if (requestOpeningOperation) {
         digitalWrite(LEDPIN, HIGH);
         openOperation.start();
@@ -126,6 +138,15 @@
     }

     displayInformation();
+}
+
+void syncTimeWithCloudIfNeeded() {
+    if (millis() - lastSync > ONE_DAY_MILLIS) {
+      // Request time synchronization from the Particle Cloud
+      Particle.syncTime();
+      waitUntil(Particle.syncTimeDone);
+      lastSync = millis();
+    }
 }

 void displayStatus() {


only listen if ss is low

only listen if ss is low

--- transmitter/Monitor/Monitor.ino
+++ transmitter/Monitor/Monitor.ino
@@ -43,7 +43,7 @@

   // only listen if ss is low (arunino pin 8)
   uint8_t port_b = PINB;
-  if (!bitRead(port_b, PINB0)) {
+  if (bitRead(port_b, PINB0)) {
     return;
   }


Added some validation to '/api/pwmdepth' input.

--- webserver.ino
+++ webserver.ino
@@ -142,7 +142,12 @@

   webServer.on( "/api/pwmdepth", []() {
     if ( webServer.arg( "newpwmdepth" ) != "" ) {
-      PWMdepth = webServer.arg( "newpwmdepth" ).toInt();
+      unsigned int newPWMdepth = webServer.arg( "newpwmdepth" ).toInt();
+      if ( newPWMdepth < 1023 || newPWMdepth > 10230 ) {
+        webServer.send( 200, "text/plain", "ERROR - Invalid PWM depth" );
+        return;
+      }
+      PWMdepth = newPWMdepth;
     }
     webServer.send( 200, "text/plain", "PWM depth is " + String( PWMdepth ) );
   });


some terribad stuff

some terribad stuff

--- src/ExcavatorDriverROS/ExcavatorDriverROS.ino
+++ src/ExcavatorDriverROS/ExcavatorDriverROS.ino
@@ -36,7 +36,7 @@
   excavatorStatus.drive_duration = 0;
   excavatorStatus.excavate_speed = 0;
   excavatorStatus.excavate_duration = 0;
-  excavatorStatus.excavation_height = 50;
+  excavatorStatus.excavation_height = 100;
   excavatorStatus.e_stop = false;
 }

@@ -54,7 +54,7 @@
 int desiredPercent = 0;

 int DELAY = 10;
-int currentSteps = FULL_STEPS / 2; //TODO
+int currentSteps = FULL_STEPS; //TODO

 //variable which disables all motor movement when set to TRUE.
 boolean e_stop = false;
@@ -75,7 +75,7 @@

 const int DRIVE_SPEED = 20;
 const char ROTATION_SPEED = 20;
-const char BUCKET_SPEED = 20;
+const char BUCKET_SPEED = 40;
 const char CONVEYOR_SPEED = 60;

 int currentStatus = STOPPED;
@@ -122,6 +122,7 @@
   currentExcavatorCommand.drive_speed = newManualCommand.drive_speed;
   currentExcavatorCommand.drive_duration = newManualCommand.drive_duration;
   currentExcavatorCommand.excavate_speed = newManualCommand.excavate_speed;
+  currentExcavatorCommand.excavate_duration = newManualCommand.excavate_duration;
   currentExcavatorCommand.excavation_height = newManualCommand.excavation_height;
   currentExcavatorCommand.e_stop = newManualCommand.e_stop;
   if(currentExcavatorCommand.e_stop)
@@ -149,10 +150,11 @@
 ros::Subscriber<std_msgs::Int16> conveyorSubscriber("ExcavatorConveyorCommand", &newConveyorCommandCallback);

 // Reset the current position of the bucketwheel
-void setActualStepCountCallback(const std_msgs::Int16& newConveyorCommand){
-  currentSteps = newConveyorCommand.data;
-}
-ros::Subscriber<std_msgs::Int16> setActualStepCount("SetActualStepCount", &setActualStepCountCallback);
+void setActualStepCountCallback(const std_msgs::Int16& actualPercent){
+  currentSteps = toSteps(actualPercent.data);
+  excavatorStatus.excavation_height = actualPercent.data;
+}
+ros::Subscriber<std_msgs::Int16> setActualStepCount("SetActualPercentage", &setActualStepCountCallback);

@@ -312,13 +314,16 @@
   delayMicroseconds(1000);
 }

-
 //<---------------CODE TO ACTUATE BUCKET WHEEL---------------->
+int toSteps(int percent){
+  return (percent / 100.0) * FULL_STEPS;
+}
+
 // checks whether we need to actuate the bucket wheel
 // returns false if we are within +/- 3 steps
 bool needsToActuate(int percent){
   int stepsToMove = int(-(toPercent(currentSteps) - percent) / 100.0 * FULL_STEPS);
-  if(stepsToMove <= 3 || stepsToMove >= -3){
+  if(stepsToMove <= 3 && stepsToMove >= -3){
     return false;
   }
   return true;
@@ -379,6 +384,7 @@

 //used to read any commands that have been recieved
 void interrupt() {
+  /*
   if (Serial.available()) {
     char command = Serial.read();
     switch (command) {
@@ -390,6 +396,7 @@
       break;
     }
   }
+  */
 }

@@ -452,32 +459,25 @@

 // Spins the buketwheel clockwise, then counterclockwise
 void unitTestBucketWheelSpin() {
+  delay(4000);
   for (int i = 0; i < 4; ++i)
   {
-    driveClockwise(i, BUCKET_SPEED);
+    driveCounterclockwise(i, BUCKET_SPEED);
   }
   delay(4000);

-  for (int i = 0; i < 4; ++i)
-  {
-    driveCounterclockwise(i, BUCKET_SPEED);
-  }
-
-  delay(4000);
-
-  for (int i = 0; i < 4; ++i)
-  {
-    driveClockwise(i, 0);
-  }
+
   delay(600);
 }

 // Moves the bucket wheel up and down
 void unitTestBucketWheelActuate() {
-  moveToPercent(40);
   delay(4000);
-  moveToPercent(50);
-  delay(600);
+  delay(4000);
+  moveToPercent(27);
+  //delay(4000);
+  //moveToPercent(97);
+  delay(6000);
 }

 // Moves the conveyor forwards and backwards
@@ -528,7 +528,7 @@
   //unitTestBucketWheelSpin();
   //unitTestBucketWheelActuate();
   //unitTestConveyor();
-  //stopAllMotors();
+  //stopMovementMotors();
 }

 void loop()
@@ -573,44 +573,52 @@
     if (millis() >= driveStopTime) {
       print("over time limit: stop driving");
       stopMovementMotors();
-      currentStatus = ACTUATING;
-    }
-  }
-
-  if (currentStatus == ACTUATING) {
+      currentStatus = START_ACTUATING;
+    }
+  }
+
+  if (currentStatus == START_ACTUATING) {
+    print("Start actuating");
     if(needsToActuate(currentExcavatorCommand.excavation_height)){
+      print("Needs to actuate");
       moveToPercent(currentExcavatorCommand.excavation_height);
-      excavatorStatus.excavate_speed = toPercent(currentSteps);
+      excavatorStatus.excavation_height = toPercent(currentSteps);
     }
     else{
+      print("don't need to actuate, proceed to digging");
       currentStatus = START_DIGGING;
     }
   }

   if (currentStatus == START_DIGGING) {
+    print("Start digging");
     if(currentExcavatorCommand.excavate_speed == 0){
       stopBucketWheel();
+      currentStatus = STOPPED;
     }
     else if(currentExcavatorCommand.excavate_speed < 0){
-      bucketStopTime = millis() + (long)(currentExcavatorCommand.excavate_duration);
+      bucketStopTime = millis() + (long)currentExcavatorCommand.excavate_duration * 1000;
       rotateBucketCounterclockwise(-currentExcavatorCommand.excavate_speed);
       excavatorStatus.excavate_speed = currentExcavatorCommand.excavate_speed;
+      currentStatus = IS_DIGGING;
     }
     else if(currentExcavatorCommand.excavate_speed > 0){
-      bucketStopTime = millis() + (long)(currentExcavatorCommand.excavate_duration);
+      bucketStopTime = millis() + (long)currentExcavatorCommand.excavate_duration * 1000;
       rotateBucketClockwise(currentExcavatorCommand.excavate_speed);
       excavatorStatus.excavate_speed = currentExcavatorCommand.excavate_speed;
+      currentStatus = IS_DIGGING;
     }
   }

   if (currentStatus == IS_DIGGING) {
     if(millis() >= bucketStopTime){
+      print("stop digging");
       stopBucketWheel();
+      currentStatus = STOPPED;
     }
   }

   pubexcavatorStatus.publish(&excavatorStatus);// current rotation data for each wheel.
-
   //Sync with ROS
   excavatorNode.spinOnce(); // Check for subscriber update/update timestamp


Added file.close()

Added file.close()

--- arduino-ide/filesystem-example/filesystem-example.ino
+++ arduino-ide/filesystem-example/filesystem-example.ino
@@ -28,7 +28,9 @@
       String line = f.readStringUntil('\n');
       Serial.println(line);
     }
+
   }
+  file.close();
 }

 void loop() {


OCD Pt II

OCD Pt II

--- arduino-devlogger.ino
+++ arduino-devlogger.ino
@@ -19,7 +19,6 @@
 char alarm_notes[] = "iFbFiFbFiFbFiFbFiGbGiGbGiGbGiGbGlbjblbjblbjblbjbjaHajaHajaHajaHa"; // aerodynamic - daft punk
 const int alarm_frequency = 900 /* test: 15 */, alarm_set_max = 4, alarm_tempo = 125;
 int alarm_set = 0;
-

 // dial
 bool dial_state = 1;


Reverted to previous version

Reverted to previous version

--- AL5D/al5d.ino
+++ AL5D/al5d.ino
@@ -32,11 +32,11 @@
 /***************************/
 // Servo models taken from http://www.lynxmotion.com/images/html/build143b.htm
 //
-// Base Servo =        HS-485HB <-- Unsure if this is correct    -Matt: seems correct
+// Base Servo =        HS-485HB <-- Unsure if this is correct
 // Shoulder Servo =    HS-805BB
 // Elbow Servo =       HS-755HB
-// Wrist Servo =       HS-645MG                                  -Matt: Actually servo says HS-422
-// Gripper Servo =     HS-485HB <-- Unsure if this is correct    -Matt: pretty sure it's the HS-422
+// Wrist Servo =       HS-422
+// Gripper Servo =     HS-422 <-- Unsure if this is correct

 // Servo pins
 #define BAS_PIN  2
@@ -46,20 +46,18 @@
 #define GRI_PIN  5

 // Analog pins used for accelerometers
-#define BAS_R_PIN 0                    // There is currently no accelerometer on the base, and I see no need for them but I will leave this redudancy here as it causes no issues
-#define BAS_H_PIN 1
-#define SHL_R_PIN 0
+#define BAS_R_PIN 0
+#define BAS_H_PIN 1
+#define SHL_R_PIN 0
 #define SHL_H_PIN 1
 #define ELB_R_PIN 2
 #define ELB_H_PIN 3
-#define WRI_R_PIN 4                    // Currently not used
+#define WRI_R_PIN 4
 #define WRI_H_PIN 5

 // Slider pins
 #define STEP_PIN       8
 #define DIR_PIN        9
-
-
 #define LSWITCH_PIN    11
 #define RSWITCH_PIN    12

@@ -70,15 +68,15 @@
 /*************/
 #define MAX_BUFFER     100
 #define MAX_STEPS      2354 // Maximum number of steps slider can move
-#define MAX_COUNT 20   // Used for stall detection in levelGripper function  Was 20
-#define THRESHOLD1 50   // Threshold for levelling gripper  Was 3
-#define THRESHOLD2 55   // Maximum range of fluctuations from accelerometer while stationary
-#define THRESHOLD3 65 // Threshold used for error detection in shoulder and elbow movements Was 11
-
-#define BASE_HEIGHT 169.1   // base height (all mm)
+#define MAX_COUNT 20   // Used for stall detection in levelGripper function
+#define THRESHOLD1 3   // Threshold for levelling gripper
+#define THRESHOLD2 6   // Maximum range of fluctuations from accelerometer while stationary
+#define THRESHOLD3 20  // Threshold used for error detection in shoulder and elbow movements
+
+#define BASE_HEIGHT 169.0   // base height (all mm)
 #define HUMERUS 146.05      // shoulder to elbow
-#define ULNA 157.9        // elbow to wrist
-#define HAND 108.0           // wrist to gripper tip
+#define ULNA 187.325        // elbow to wrist
+#define HAND 90.0           // wrist to gripper tip

 // Gradients and offsets used to adjust servo angles so that measured angles are closer to input
 // See C:\Users\loam\Documents\Darren\Servo Angles v2.ods for derivation
@@ -96,21 +94,20 @@

 // Analog references for the centre voltage from accelerometers
 #define BAS_R_REF 0
-#define SHL_R_REF 484.848
-#define ELB_R_REF 460  // Was 478.788
+#define SHL_R_REF 320
+#define ELB_R_REF 316
 #define WRI_R_REF 0

 #define BAS_H_REF 0
-#define SHL_H_REF 520 // Was 548.485
-#define ELB_H_REF 530  // Was 543.939
-#define WRI_H_REF 511.5
+#define SHL_H_REF 362
+#define ELB_H_REF 359
+#define WRI_H_REF 362

 // Gripper positions
 #define GRI_OPEN 100
 #define GRI_MICROPLATE 160
 #define GRI_MICROSLIDE 110
 #define GRI_CLOSED 180
-#define GRI_TUBE 150

 // Directional definitions for controlling slider
 #define LEFT           LOW
@@ -179,10 +176,7 @@
    if ( ( ret_val = servoWrite( ELB, adjust(ELB, elb_angle_d) ) ) != 0 ) return ret_val;
    if ( ( ret_val = servoWrite( WRI, adjust(WRI, wri_angle_d) ) ) != 0 ) return ret_val;

-
    delay(move_delay);
-   //Serial.print(getAngle(SHL));  Serial.print(","); Serial.print(getAngle(ELB)); Serial.print(",");  Serial.print(getAngle(WRI)); Serial.print(","); Serial.println();
-   Serial.print(analogRead(R_PIN[SHL])); Serial.print(","); Serial.print(analogRead(H_PIN[SHL])); Serial.print(","); Serial.print(analogRead(R_PIN[ELB])); Serial.print(","); Serial.print(analogRead(H_PIN[ELB]));  Serial.print(","); Serial.println(analogRead(H_PIN[WRI]));

    return ret_val;
 }
@@ -191,9 +185,9 @@
 // If the last input angle is negative, the function will determine the wrist angle required to achieve horizontal position
 int slowMoveArm( float bas_angle_d, float shl_angle_d, float elb_angle_d, float wri_angle_d )
 {
-   if ( wri_angle_d < 0 ) wri_angle_d = current[WRI] - current[SHL] + shl_angle_d - current[ELB] + elb_angle_d;             //Matt: I believe this calculates the required angle of the wrist in order for it to be horizontal. This relies on the sum of the current angles being a constant and so is equal to the sum of the destination angles. I think this is geometrically correct if the wrist is always to be pointed in the same direction.
-
-   if ( wri_angle_d < 0 ) wri_angle_d = 0;                           // If the desired wrist angle is out of bounds, take it as far as it can go
+   if ( wri_angle_d < 0 ) wri_angle_d = current[WRI] + current[SHL] - shl_angle_d + current[ELB] - elb_angle_d;
+
+   if ( wri_angle_d < 0 ) wri_angle_d = 0;
    else if ( wri_angle_d > 180 ) wri_angle_d = 180;

    DEBUG("slowMoveArm("); DEBUG(bas_angle_d); DEBUG(","); DEBUG(shl_angle_d); DEBUG(","); DEBUG(elb_angle_d); DEBUG(","); DEBUG(wri_angle_d); DEBUGln(")");
@@ -237,7 +231,7 @@
 }

 // Arm positioning routine utilizing inverse kinematics in cylindrical coordinates
-// (r = radius, h = height, b = azimuth = base servo angle)
+// (r = radius, h = height, b = azimuth = base servo angle
 int moveArmCoord( float radius_mm, float height_mm, float bas_angle_d )
 {
    DEBUG("moveArmCoord("); DEBUG(radius_mm); DEBUG(","); DEBUG(height_mm); DEBUG(","); DEBUG(bas_angle_d); DEBUGln(")");
@@ -250,7 +244,7 @@
    /* s_w angle to ground */
    float a1 = atan2( wri_h, wri_r ); // Angle between S-W line and ground
    /* s_w angle to humerus */
-   float a2 = acos((( hum_sq - uln_sq ) + s_w ) / ( 2 * HUMERUS * s_w_sqrt )); // Angle between S-W line and humerus - found using the cosine law
+   float a2 = acos((( hum_sq - uln_sq ) + s_w ) / ( 2 * HUMERUS * s_w_sqrt )); // Angle between S-W line and humerus
    /* shoulder angle */
    float shl_angle_r = a1 + a2;
    float shl_angle_d = degrees( shl_angle_r );
@@ -267,7 +261,7 @@
 {
    DEBUG("slowMoveArmCoord("); DEBUG(radius_mm); DEBUG(","); DEBUG(height_mm); DEBUG(","); DEBUG(bas_angle_d); DEBUGln(")");

-  calcPosition();
+   calcPosition();

    old_r = current_r; old_h = current_h; old_b = current[BAS]; // Use with feedback to allow reversing after a collision

@@ -294,15 +288,14 @@
      r_move += r_step; h_move += h_step; b_move += b_step;
    }

-
    delay(100); // Wait for arm to stop moving

    levelGripper();
-
+
    delay(100); // Wait for arm to stop moving

-   //check position
    if ( checkPosition() != 0 ) return -4; // Stall detection
+
    return 0;
 }

@@ -390,17 +383,16 @@
 {
    int ret_val, stall_count = 0;
    float h, h_old, servo_angle = actual[WRI], servo_angle_old = servo_angle;
-   h = H_REF[WRI]- getFeedback(H_PIN[WRI]) ;
+   h = getFeedback(H_PIN[WRI]) - H_REF[WRI];
    h_old = h;
    DEBUG("servo_angle: "); DEBUG(servo_angle); DEBUG(", h: "); DEBUGln(h);
    if ( abs(h) <= THRESHOLD1 ) return 0;
    boolean condition = h > 0;
    while ( ( abs(h) > THRESHOLD1 ) && ( condition ? h > 0 : h < 0 ) )
    {
-      //Serial.println(h-h_old);
       if ( ( ret_val = servoWrite( WRI, condition ? --servo_angle : ++servo_angle ) ) != 0 ) return ret_val;
       delay(20);
-      h = H_REF[WRI]- getFeedback(H_PIN[WRI]);
+      h = getFeedback(H_PIN[WRI]) - H_REF[WRI];
       DEBUG("servo_angle: "); DEBUG(servo_angle); DEBUG(", h: "); DEBUGln(h);
       if ( abs( h - h_old ) < THRESHOLD2 ) stall_count++;
       else
@@ -422,14 +414,11 @@
 int checkPosition()
 {
    float angle_d = getAngle(SHL);
-   //Serial.print( angle_d - current[SHL]);
    if ( abs( angle_d - current[SHL] ) > THRESHOLD3 ) return 1;
    DEBUG("Check1: "); DEBUGln(angle_d - current[SHL]);
    angle_d = getAngle(ELB) - angle_d;
-   //Serial.print(","); Serial.println(angle_d - current[ELB] + 180);
    DEBUG("Check2: "); DEBUGln(angle_d - current[ELB] + 180);
    return ( abs( angle_d - current[ELB] + 180 ) > THRESHOLD3 );
-
 }

 // Read from accelerometers and determine angle from horizontal
@@ -485,14 +474,6 @@
    Serial.begin(57600);
    DEBUGln("Serial connection started\n");

-   analogReference(EXTERNAL);      // Sets the analog reference voltage to the voltage supplied to the AREF pin on the board - here this is recieving the 3.3V output from one of the accelerometers.  This sets the upper limit of values read by analogRead(). Since the accelerometers output 0-3.3V, the default upper limit of 5V wastes the top output of analogRead.
-
-   for(int pinTest = 0; pinTest < 6; pinTest++){
-      for(int testNum = 0; testNum < 3; testNum++){
-          analogRead(pinTest);                          // Upon changing the reference voltage the first few readings may be incorrect so they are done here.
-      }
-   }
-
    pinMode(STEP_PIN, OUTPUT);
    pinMode(DIR_PIN, OUTPUT);
    pinMode(LSWITCH_PIN, INPUT);
@@ -507,9 +488,9 @@

    // Move arm to rest position and calculate position
    servoWrite(BAS,adjust(BAS,90));
-   servoWrite(SHL,adjust(SHL,135));
-   servoWrite(ELB,adjust(ELB,45));
-   servoWrite(WRI,adjust(WRI,90));
+   servoWrite(SHL,adjust(SHL,90));
+   servoWrite(ELB,adjust(ELB,180));
+   servoWrite(WRI,adjust(WRI,0));
    servoWrite(GRI,GRI_OPEN);
    calcPosition();
    slide(LEFT,MAX_STEPS);
@@ -525,7 +506,7 @@
 /* LOOP */
 /********/
 void loop()
-{
+{
    if(Serial.available() > 0)
    {
       i=0;
@@ -540,11 +521,9 @@
             servoWrite(GRI,GRI_MICROSLIDE); Serial.println("Gripped Microscope Slide"); break;
          case 'p':
             servoWrite(GRI,GRI_MICROPLATE); Serial.println("Gripped Microplate"); break;
-         case 't':
-            servoWrite(GRI,GRI_TUBE); Serial.println("Gripped Tube"); break;
          case 'r':
             move_delay = 20;
-            if( ( ret_val = slowMoveArm(90,135,45,90) ) == 0 ) Serial.println("Arm moved to rest position");
+            if( ( ret_val = slowMoveArm(90,90,180,0) ) == 0 ) Serial.println("Arm moved to rest position");
             else Serial.println(ret_val);
             break;
          case 'R':
@@ -600,11 +579,11 @@
             buf[i] = '\0';
             number[0] = atof(buf);
             move_delay = 50;
-            Serial.println(slowMoveArm(current[BAS],current[SHL],current[ELB],number[0]));
+            Serial.println(slowMoveArm(current[BAS],current[SHL],number[0],-1));
             break;

          case '<': // start of coordinate move packet
-            for(j=0; j<3; j++) // capture first 3 arguments: depth, height, base angle
+            for(j=0; j<3; j++) // capture first 4 arguments: depth, height, base angle, hand angle
             {
                i=0;
                buf[i] = Serial.read(); delay(1);
@@ -678,5 +657,4 @@
             break;
       }
    }
-}
-
+}


fixed xtal check

fixed xtal check

--- Arduino/V0p2_Main/V0p2_Main.ino
+++ Arduino/V0p2_Main/V0p2_Main.ino
@@ -215,8 +215,8 @@
 #if defined(ENABLE_WAKEUP_32768HZ_XTAL)
 #ifdef ENABLE_TUNE_FAST_OSC_TO_RTC_SOURCE
   // Check that the slow clock is running reasonably OK, and tune the fast one to it.
-  //if(!::OTV0P2BASE::HWTEST::calibrateInternalOscWithExtOsc()) { panic(F("Xtal")); } // Async clock not running or can't tune.
-    if(!::OTV0P2BASE::HWTEST::check32768HzOsc()) { panic(F("xtal")); } // Async clock not running correctly.
+  if(!::OTV0P2BASE::HWTEST::calibrateInternalOscWithExtOsc()) { panic(F("Xtal")); } // Async clock not running or can't tune.
+//    if(!::OTV0P2BASE::HWTEST::check32768HzOsc()) { panic(F("xtal")); } // Async clock not running correctly.
 #else
   // Just check that the slow clock is running reasonably OK.
   if(!::OTV0P2BASE::HWTEST::check32768HzOsc()) { panic(F("xtal")); } // Async clock not running correctly.


re-added comment

re-added comment

comment back in

--- WordClock_NeoMatrix8x8/calculateTime.ino
+++ WordClock_NeoMatrix8x8/calculateTime.ino
@@ -21,6 +21,7 @@

   if (OBSERVE_DST == 1) {

+    //Get the day of the week. 0 = Sunday, 6 = Saturday
     int previousSunday = RTCTime.day() - RTCTime.dayOfTheWeek();

     boolean dst = false; //Assume we're not in DST


Update ArduCAM_Mini_4CAM_VideoStreaming.ino

--- ArduCAM/examples/mini/ArduCAM_Mini_4CAM_VideoStreaming/ArduCAM_Mini_4CAM_VideoStreaming.ino
+++ ArduCAM/examples/mini/ArduCAM_Mini_4CAM_VideoStreaming/ArduCAM_Mini_4CAM_VideoStreaming.ino
@@ -59,7 +59,7 @@
 uint8_t temp;
 Wire.begin();
 Serial.begin(921600);
-Serial.println("ArduCAM Start!");
+Serial.println("ACK CMD ArduCAM Start! END");
 // set the CS output:
 pinMode(CS1, OUTPUT);
 pinMode(CS2, OUTPUT);
@@ -74,14 +74,14 @@
   temp = myCAM1.read_reg(ARDUCHIP_TEST1);
   if(temp != 0x55)
   {
-    Serial.println(F("ACK CMD SPI1 interface Error!"));
+    Serial.println(F("ACK CMD SPI1 interface Error! END"));
     cam1 = false;
   }
   myCAM2.write_reg(ARDUCHIP_TEST1, 0x55);
   temp = myCAM2.read_reg(ARDUCHIP_TEST1);
   if(temp != 0x55)
   {
-    Serial.println(F("ACK CMD SPI2 interface Error!"));
+    Serial.println(F("ACK CMD SPI2 interface Error! END"));
     cam2 = false;
   }

@@ -89,7 +89,7 @@
   temp = myCAM3.read_reg(ARDUCHIP_TEST1);
   if(temp != 0x55)
   {
-    Serial.println(F("ACK CMD SPI3 interface Error!"));
+    Serial.println(F("ACK CMD SPI3 interface Error! END"));
     cam3 = false;
   }

@@ -97,7 +97,7 @@
   temp = myCAM4.read_reg(ARDUCHIP_TEST1);
   if(temp != 0x55)
   {
-    Serial.println(F("ACK CMD SPI4 interface Error!"));
+    Serial.println(F("ACK CMD SPI4 interface Error! END"));
     cam4 = false;
   }
   if(!(cam1||cam2||cam3||cam4)){
@@ -112,10 +112,10 @@
   myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid);
   myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid);
   if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){
-    Serial.println(F("ACK CMD Can't find OV2640 module!"));
+    Serial.println(F("ACK CMD Can't find OV2640 module! END"));
     delay(1000);continue;
   }else{
-    Serial.println(F("ACK CMD OV2640 detected."));break;
+    Serial.println(F("ACK CMD OV2640 detected. END"));break;
    }
 }
 #elif defined (OV3640_MINI_3MP)
@@ -124,10 +124,10 @@
     myCAM1.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid);
     myCAM1.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid);
     if ((vid != 0x36) || (pid != 0x4C)){
-      Serial.println(F("Can't find OV3640 module!"));
+      Serial.println(F("Can't find OV3640 module! END"));
       delay(1000);continue;
     }else{
-      Serial.println(F("OV3640 detected."));break;
+      Serial.println(F("ACK CMD OV3640 detected. END"));break;
     }
  }
 #else
@@ -137,10 +137,10 @@
     myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid);
     myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid);
     if((vid != 0x56) || (pid != 0x42)){
-    Serial.println(F("ACK CMD Can't find OV5642 module!"));
+    Serial.println(F("ACK CMD Can't find OV5642 module! END"));
     delay(1000);continue;
     }else{
-    Serial.println(F("ACK CMD OV5642 detected."));break;
+    Serial.println(F("ACK CMD OV5642 detected. END"));break;
     }
   }
 #endif
@@ -175,40 +175,40 @@
 {
  case 0:
     #if defined (OV2640_MINI_2MP)
-      myCAM.OV2640_set_JPEG_size(OV2640_160x120);delay(1000);
-      Serial.println(F("ACK CMD switch to OV2640_160x120"));
+      myCAM1.OV2640_set_JPEG_size(OV2640_160x120);delay(1000);
+      Serial.println(F("ACK CMD switch to OV2640_160x120 END"));
     #elif defined (OV3640_MINI_3MP)
       myCAM1.OV3640_set_JPEG_size(OV3640_176x144);delay(1000);
-      Serial.println(F("ACK CMD switch to OV2640_160x120"));
+      Serial.println(F("ACK CMD switch to OV2640_160x120 END"));
     #else
       myCAM1.OV5642_set_JPEG_size(OV5642_320x240);delay(1000);
-      Serial.println(F("ACK CMD switch to OV5642_320x240"));
+      Serial.println(F("ACK CMD switch to OV5642_320x240 END"));
     #endif
     temp = 0xff;
     break;
     case 1:
     #if defined (OV2640_MINI_2MP)
       myCAM1.OV2640_set_JPEG_size(OV2640_176x144);delay(1000);
-      Serial.println(F("ACK CMD switch to OV2640_176x144"));
+      Serial.println(F("ACK CMD switch to OV2640_176x144 END"));
     #elif defined (OV3640_MINI_3MP)
       myCAM1.OV3640_set_JPEG_size(OV3640_320x240);delay(1000);
-      Serial.println(F("ACK CMD switch to OV3640_320x240"));
+      Serial.println(F("ACK CMD switch to OV3640_320x240 END"));
     #else
       myCAM1.OV5642_set_JPEG_size(OV5642_640x480);delay(1000);
-      Serial.println(F("ACK CMD switch to OV5642_640x480"));
+      Serial.println(F("ACK CMD switch to OV5642_640x480 END"));
     #endif
     temp = 0xff;
     break;
     case 2:
     #if defined (OV2640_MINI_2MP)
       myCAM1.OV2640_set_JPEG_size(OV2640_320x240);delay(1000);
-      Serial.println(F("ACK CMD switch to OV2640_320x240"));
+      Serial.println(F("ACK CMD switch to OV2640_320x240 END"));
      #elif defined (OV3640_MINI_3MP)
       myCAM1.OV3640_set_JPEG_size(OV3640_352x288);delay(1000);
-      Serial.println(F("ACK CMD switch to OV3640_352x288"));
+      Serial.println(F("ACK CMD switch to OV3640_352x288 END"));
     #else
       myCAM1.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000);
-      Serial.println(F("ACK CMD switch to OV5642_1024x768"));
+      Serial.println(F("ACK CMD switch to OV5642_1024x768 END"));
     #endif
     temp = 0xff;
     break;
@@ -216,72 +216,72 @@
     temp = 0xff;
     #if defined (OV2640_MINI_2MP)
       myCAM1.OV2640_set_JPEG_size(OV2640_352x288);delay(1000);
-      Serial.println(F("ACK CMD switch to OV2640_352x288"));
+      Serial.println(F("ACK CMD switch to OV2640_352x288 END"));
     #elif defined (OV3640_MINI_3MP)
       myCAM1.OV3640_set_JPEG_size(OV3640_640x480);delay(1000);
-      Serial.println(F("ACK CMD switch to OV3640_640x480"));
+      Serial.println(F("ACK CMD switch to OV3640_640x480 END"));
     #else
       myCAM1.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000);
-      Serial.println(F("ACK CMD switch to OV5642_1280x960"));
+      Serial.println(F("ACK CMD switch to OV5642_1280x960 END"));
     #endif
     break;
     case 4:
     temp = 0xff;
     #if defined (OV2640_MINI_2MP)
       myCAM1.OV2640_set_JPEG_size(OV2640_640x480);delay(1000);
-      Serial.println(F("ACK CMD switch to OV2640_640x480"));
+      Serial.println(F("ACK CMD switch to OV2640_640x480 END"));
    #elif defined (OV3640_MINI_3MP)
       myCAM1.OV3640_set_JPEG_size(OV3640_800x600);delay(1000);
-      Serial.println(F("ACK CMD switch to OV3640_800x600"));
+      Serial.println(F("ACK CMD switch to OV3640_800x600 END"));
     #else
       myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000);
-      Serial.println(F("ACK CMD switch to OV5642_1600x1200"));
+      Serial.println(F("ACK CMD switch to OV5642_1600x1200 END"));
     #endif
     break;
     case 5:
     temp = 0xff;
     #if defined (OV2640_MINI_2MP)
       myCAM1.OV2640_set_JPEG_size(OV2640_800x600);delay(1000);
-      Serial.println(F("ACK CMD switch to OV2640_800x600"));
+      Serial.println(F("ACK CMD switch to OV2640_800x600 END"));
     #elif defined (OV3640_MINI_3MP)
       myCAM1.OV3640_set_JPEG_size(OV3640_1024x768);delay(1000);
-      Serial.println(F("ACK CMD switch to OV3640_1024x768"));
+      Serial.println(F("ACK CMD switch to OV3640_1024x768 END"));
     #else
       myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000);
-      Serial.println(F("ACK CMD switch to OV5642_2048x1536"));
+      Serial.println(F("ACK CMD switch to OV5642_2048x1536 END"));
     #endif
     break;
     case 6:
     temp = 0xff;
     #if defined (OV2640_MINI_2MP)
       myCAM1.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000);
-      Serial.println(F("ACK CMD switch to OV2640_1024x768"));
+      Serial.println(F("ACK CMD switch to OV2640_1024x768 END"));
    #elif defined (OV3640_MINI_3MP)
       myCAM1.OV3640_set_JPEG_size(OV3640_1280x960);delay(1000);
-      Serial.println(F("ACK CMD switch to OV3640_1280x960"));
+      Serial.println(F("ACK CMD switch to OV3640_1280x960 END"));
     #else
       myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000);
-      Serial.println(F("ACK CMD switch to OV5642_2592x1944"));
+      Serial.println(F("ACK CMD switch to OV5642_2592x1944 END"));
     #endif
     break;
     case 7:
     temp = 0xff;
    #if defined (OV2640_MINI_2MP)
     myCAM1.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000);
-    Serial.println(F("ACK CMD switch to OV2640_1280x1024"));
+    Serial.println(F("ACK CMD switch to OV2640_1280x1024 END"));
    #else
       myCAM1.OV3640_set_JPEG_size(OV3640_1600x1200);delay(1000);
-      Serial.println(F("ACK CMD switch to OV3640_1600x1200"));
+      Serial.println(F("ACK CMD switch to OV3640_1600x1200 END"));
    #endif
     break;
     case 8:
     temp = 0xff;
    #if defined (OV2640_MINI_2MP)
      myCAM1.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000);
-     Serial.println(F("ACK CMD switch to OV2640_1600x1200"));
+     Serial.println(F("ACK CMD switch to OV2640_1600x1200 END"));
    #else
      myCAM1.OV3640_set_JPEG_size(OV3640_2048x1536);delay(1000);
-     Serial.println(F("ACK CMD switch to OV3640_2048x1536"));
+     Serial.println(F("ACK CMD switch to OV3640_2048x1536 END"));
    #endif
     break;
   case 0x10:


Update shapes.ino

Update shapes.ino

--- examples/shapes/shapes.ino
+++ examples/shapes/shapes.ino
@@ -14,7 +14,7 @@
 //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <stdint.h>
 #include <TouchScreen.h>
-#include <TFT.h>
+#include <TFT_T.h>

 #ifdef SEEEDUINO
   #define YP A2   // must be an analog pin, use "An" notation!


-added two channel freq reading to write up to 4 anaolg channels -formating

--- arduino/fasnacht/fasnacht.ino
+++ arduino/fasnacht/fasnacht.ino
@@ -24,55 +24,107 @@

 void loop()
 {
-    unsigned long start, count, finish, time, frq;
-    unsigned int x, b, last, value, avg, highest = 0, lowest = 1023;
-    int brightness;
+    unsigned long start,        //time when sampling started
+                  finish,       //time when sampling ended
+                  time,         //sampling time
+                  ValueCount,   //counts Value average crossings
+                  ChannelCount, //counts Channel average crossings
+                  ValueFrq,     //Final Input freq of Value data
+                  ChannelFrq;   //Final Input freq of Channel data
+
+    unsigned int Ctr,           //counter
+                 ValueState,    //set if Value is bigger than its Average
+                 ChannelState,  //set if Channel is bigger than its Average
+                 ValueLast,     //last state of ValuePassed
+                 ChannelLast,   //last state of ChannelPassed
+                 Value,         //analog input of data
+                 Channel,       //analog input of channel
+                 ValueAvg,      //voltage average
+                 ChannelAvg,    //voltage average
+                 ValueHighest = 0,     //peak value
+                 ChannelHighest = 0,   //peak value
+                 ValueLowest = 1023,   //peak value
+                 ChannelLowest = 1023, //peak value
+                 Channel = 0;  //output channel to write
+
+    int brightness; //brighness data

     digitalWrite(13, 1);

-    start = millis();
-    count = 0;
+    start = millis();  //get arduino uptimes (unsigned long): max 50days :P
+    ValueCount = 0;
+    ChannelCount = 0;

-    for (x = 0; x < 500; x++) {
-        value = analogRead(2); // 2 = Audio links, 3 = Audio rechts
-        if (value > highest) {
-            highest = value;
-        }
-        if (value < lowest) {
-            lowest = value;
-        }
-        avg = (highest + lowest) / 2;
+    for (Ctr = 0; Ctr < 500; Ctr++) {
+        //get input voltage
+        Value = analogRead(2);   // 2 = Audio left -> data
+        Channel = analogRead(3); // 2 = Audio right -> channel
+
+        //save peak values
+        if (Value > ValueHighest) ValueHighest = Value;
+        if (Value < ValueLowest)  ValueLowest = Value;
+        if (Channel > ChannelHighest) ChannelHighest = Channel;
+        if (Channel < ChannelLowest)  ChannelLowest = Channel;
+
+        //calculate voltage average
+        ValueAvg = (ValueHighest + ValueLowest) / 2;
+        ChannelAvg = (ChannelHighest + ChannelLowest) / 2;

-        if (value > avg) {
-          b = 1;
-        } else {
-          b = 0;
-        }
-        if (b != last) {
-            count++;
-        }
-        last = b;
+        //check if input is higher or lower than its average
+        if (Value > ValueAvg) ValueState = 1;
+        else ValueState = 0;
+        if (Channel > ChannelAvg) ChannelState = 1;
+        else ChannelState = 0;
+
+        //count number of average crossings
+        if (ValueState != ValueLast) ValueCount++;
+        if (ChannelState != ChannelLast) ChannelCount++;
+
+        //save state
+        ValueLast = ValueState;
+        ChannelLast = ChannelState;
     }

+    //get sampling time
     finish = millis();
     time = finish - start;
-    frq = count * 100 / time / 2 * 10;
-    brightness = (int) (frq - 100) / 2;
+
+    //calculate freq
+    ValueFrq = ValueCount * 100 / time / 2 * 10;
+    ChannelFrq = ChannelCount * 100 / time / 2 * 10;
+
+    //get brighteness data
+    brightness = (int) (ValueFrq - 100) / 2;
+    //margins
+    if (brightness >= 255)  brightness = 255;
+    if (brightness < 0)     brightness = 0;

-    if (brightness >= 255) {
-        brightness = 255;
+    //get channel data and write output
+    if( (ChannelFrq > 100) && (ChannelFrq < 200) ) {
+      analogWrite(3, brightness);
+      Serial.print("Refresh Channel 3");
     }
-    if (brightness < 0) {
-        brightness = 0;
+    if( (ChannelFrq > 100) && (ChannelFrq < 200) ) {
+      analogWrite(5, brightness);
+      Serial.print("Refresh Channel 5");
+    }
+    if( (ChannelFrq > 100) && (ChannelFrq < 200) ) {
+      analogWrite(6, brightness);
+      Serial.print("Refresh Channel 6");
+    }
+    if( (ChannelFrq > 100) && (ChannelFrq < 200) ) {
+      analogWrite(9, brightness);
+      Serial.print("Refresh Channel 9");
     }

+    //debug
     Serial.print("Frequency: ");
-    Serial.println(frq);
+    Serial.println(ValueFrq);
     Serial.print("Brightness: ");
     Serial.println(brightness);

-    analogWrite(3, brightness);
-    analogWrite(5, brightness);
+//    analogWrite(3, brightness);
+//    analogWrite(5, brightness);

     digitalWrite(13, 0);
 }


1a versão com a lógica inicial

1a versão com a lógica inicial

--- arduino/mazeball/mazeball.ino
+++ arduino/mazeball/mazeball.ino
@@ -5,36 +5,119 @@
  * e Serial (0 e 1) para monitoraçao/depuraçao
  */

+int stpXPins[] = {8,9,10,11};
+int stpYPins[] = {2,3,4,5};
+
 void setup() {
-  Serial.begin(115200); // Pins 0 (RX) and 1 (TX)
   Serial1.begin(9600); // Pins 19 (RX) and 18 (TX), Serial2 on 17 and 16, Serial3 on 15 and 14
+
+  pinMode(stpXPins[0], OUTPUT);
+  pinMode(stpXPins[1], OUTPUT);
+  pinMode(stpXPins[2], OUTPUT);
+  pinMode(stpXPins[3], OUTPUT);
+
+  pinMode(stpYPins[0], OUTPUT);
+  pinMode(stpYPins[1], OUTPUT);
+  pinMode(stpYPins[2], OUTPUT);
+  pinMode(stpYPins[3], OUTPUT);
+
 }

 void loop() {
+
+  int xPhase = 0;
+  int yPhase = 0;
+
   if (Serial1.available() > 0) {
     char c = Serial1.read();
+    // Detect Y axis movement
     if (c == 't') { // Move top
-      // Do something
-      Serial.println("Veio t");
+      phaseSelect(stpYPins, yPhase);
+      ++yPhase %= 8;
       goto skip;
     }
     if (c == 'b') { // Move bottom
-      // Do something
-      Serial.println("Veio b");
+      phaseSelect(stpYPins, 7 - yPhase);
+      ++yPhase %= 8;
       goto skip;
     }
+
+    // Detect X axis movement
     if (c == 'l') { // Move left
-      // Do something
-      Serial.println("Veio l");
+      phaseSelect(stpXPins, 7 - xPhase);
+      ++xPhase %= 8;
       goto skip;
     }
     if (c == 'r') { // Move right
-      // Do something
-      Serial.println("Veio r");
+      phaseSelect(stpXPins, xPhase);
+      ++xPhase %= 8;
       goto skip;
     }
   }
-
+  phaseSelect(stpXPins, 8); // Stop X movement
+  phaseSelect(stpYPins, 8); // Stop Y movement
+
 skip:
   delay(DELAY);
 }
+
+void phaseSelect(int *pins, int phase) {
+  switch(phase) {
+     case 0:
+       digitalWrite(pins[0], LOW);
+       digitalWrite(pins[1], LOW);
+       digitalWrite(pins[2], LOW);
+       digitalWrite(pins[3], HIGH);
+       break;
+     case 1:
+       digitalWrite(pins[0], LOW);
+       digitalWrite(pins[1], LOW);
+       digitalWrite(pins[2], HIGH);
+       digitalWrite(pins[3], HIGH);
+       break;
+     case 2:
+       digitalWrite(pins[0], LOW);
+       digitalWrite(pins[1], LOW);
+       digitalWrite(pins[2], HIGH);
+       digitalWrite(pins[3], LOW);
+       break;
+     case 3:
+       digitalWrite(pins[0], LOW);
+       digitalWrite(pins[1], HIGH);
+       digitalWrite(pins[2], HIGH);
+       digitalWrite(pins[3], LOW);
+       break;
+     case 4:
+       digitalWrite(pins[0], LOW);
+       digitalWrite(pins[1], HIGH);
+       digitalWrite(pins[2], LOW);
+       digitalWrite(pins[3], LOW);
+       break;
+     case 5:
+       digitalWrite(pins[0], HIGH);
+       digitalWrite(pins[1], HIGH);
+       digitalWrite(pins[2], LOW);
+       digitalWrite(pins[3], LOW);
+       break;
+     case 6:
+       digitalWrite(pins[0], HIGH);
+       digitalWrite(pins[1], LOW);
+       digitalWrite(pins[2], LOW);
+       digitalWrite(pins[3], LOW);
+       break;
+     case 7:
+       digitalWrite(pins[0], HIGH);
+       digitalWrite(pins[1], LOW);
+       digitalWrite(pins[2], LOW);
+       digitalWrite(pins[3], HIGH);
+       break;
+     default:
+       digitalWrite(pins[0], LOW);
+       digitalWrite(pins[1], LOW);
+       digitalWrite(pins[2], LOW);
+       digitalWrite(pins[3], LOW);
+       break;
+  }
+  delay(1);
+}
+


ajout des logs

ajout des logs

--- bp_led.ino
+++ bp_led.ino
@@ -7,7 +7,6 @@
 // variables will change:
 int buttonState = 0;         // variable for reading the pushbutton status
 int ledState = 0;
-int currenteState = 0;

 void setup() {
   // initialize the LED pin as an output:
@@ -27,15 +26,20 @@

   if(ledState == HIGH){
     if (buttonState == LOW) {
-      // turn LED on:
-      digitalWrite(ledPin, LOW);
+      turnOn();
+     }
+  }
+  else{
+      turnOff();
     }
   }
-  else{
-    if (buttonState == LOW) {
-      // turn LED on:
-      digitalWrite(ledPin, HIGH);
-    }
-  }
+}7
+
+void turnOn(){
+  digitalWrite(ledPin, HIGH);
 }

+
+void turnOff(){
+  digitalWrite(ledPin, LOW);
+}


Removed unnecessary negative if statement

--- code/oakpowerboard/oakpowerboard.ino
+++ code/oakpowerboard/oakpowerboard.ino
@@ -133,9 +133,7 @@
     // time budget.
     bool curr_btn_state = (digitalRead(6) == LOW) ? false : true;
     if(curr_btn_state != btn_state) {
-      if(curr_btn_state == true) { //PULSE
-
-      } else {//PULSE FINISHED
+      if(curr_btn_state == false) {//PULSE FINISHED
         pulse_count_current_kwh++;
         if(pulse_count_current_kwh == PULSES_PER_KWH) {
           consumption_total++;


updated SNR scaling

updated SNR scaling

--- crossbow.ino
+++ crossbow.ino
@@ -66,7 +66,7 @@

 float getRadioSnr(void)
 {
-    return (uint8_t) constrain(LoRa.packetSnr() * 10, 0, 255);
+    return (uint8_t) constrain(LoRa.packetSnr(), 0, 255);
 }

 void radioPacketStart(void)


Added SPI ssd1306 support for mono_canvas demo

--- examples/double_buffering/mono_canvas/mono_canvas.ino
+++ examples/double_buffering/mono_canvas/mono_canvas.ino
@@ -35,7 +35,7 @@
 #include "ssd1306.h"
 #include "nano_engine.h"

-/*
+/*
  * Heart image below is defined directly in flash memory.
  * This reduces SRAM consumption.
  * The image is define from bottom to top (bits), from left to
@@ -87,7 +87,7 @@
 {
     /* Initialize and clear display */
     ssd1306_128x64_i2c_init();
-//    ssd1306_128x64_i2c_init();
+//    ssd1306_128x64_spi_init(3, 4, 5);
 //    pcd8544_84x48_spi_init(3, 4, 5); // 3 RST, 4 CES, 5 DS
 //    ssd1331_96x64_spi_init(3, 4, 5);
 //    ssd1351_128x128_spi_init(3, 4, 5);


バグ修正（プログラム転送機能関連）

バグ修正（プログラム転送機能関連）

--- 2_example/example15_jam/example15_jam.ino
+++ 2_example/example15_jam/example15_jam.ino
@@ -6,9 +6,6 @@
 *******************************************************************************/

 #include <ESP8266WiFi.h>                        // Wi-Fi機能を利用するために必要
-extern "C" {
-#include "user_interface.h"                     // ESP8266用の拡張IFライブラリ
-}
 #include <WiFiUdp.h>                            // UDP通信を行うライブラリ
 #define TIMEOUT 20000                           // タイムアウト 20秒
 #define SSID "1234ABCD"                         // 無線LANアクセスポイントのSSID
@@ -22,7 +19,6 @@
 void setup(){                                   // 起動時に一度だけ実行する関数
     Serial.begin(115200);                       // IchigoJamとの通信ポート
     delay(5000);                                // IchigoJamの起動・通信処理待ち
-    wifi_set_sleep_type(NONE_SLEEP_T);          // スリープ禁止
     WiFi.mode(WIFI_STA);                        // 無線LANをSTAモードに設定
     WiFi.begin(SSID,PASS);                      // 無線LANアクセスポイントへ接続
     Serial.write(25); Serial.write(16);         // 停止コマンドとDLEコードの送信
@@ -31,12 +27,12 @@
     Serial.println("\":'");                     // コマンドとして実行する
     while(WiFi.status() != WL_CONNECTED){       // 接続に成功するまで待つ
         delay(500);                             // 待ち時間処理
-        Serial.print("'");
+        Serial.print("'");                      // 無線APへの接続プログレス表示
     }
-    server.begin();                             // サーバを起動する
+    server.begin();                             // TCPサーバを起動する
     udp.begin(PORT);                            // UDP通信御開始
-    Serial.println();delay(1000);
-    Serial.print("' ");                         // 改行を出力
+    Serial.println();delay(1000);               // 改行を出力
+    Serial.print("' ");                         // コメント命令を送信
     Serial.println(WiFi.localIP());             // IPアドレスを出力する
 }

@@ -56,16 +52,16 @@
     client = server.available();                // TCPクライアントを生成
     if(client==0){                              // TCPクライアントが無かった場合
         if(tx[0]){                              // 変数txに代入されていた場合
-            c=trUri2c(tx[0]);
-            if(c=='%'){
-                c=trUri2s(tx);
+            c=trUri2c(tx[0]);                   // URIエンコード空白文字の変換
+            if(c=='%'){                         // URIエンコード文字の検出
+                c=trUri2s(tx);                  // アスキー文字へ変換して変数Cへ
             }
             Serial.write(c); delay(18);         // IchigoJamへ出力
             if(c=='\n') delay(100);             // IchigoJamの処理待ち
-            trShift(tx,1);
+            trShift(tx,1);                      // FIFOバッファのシフト処理
         }else{
             len = udp.parsePacket();            // UDP受信パケット長をlenに代入
-            if(len){
+            if(len){                            // 受信データがあった場合、
                 Serial.print("' ");             // コメント命令を送信
                 memset(s, 0, 65);               // 文字列変数sの初期化(65バイト)
                 udp.read(s, 64);                // UDP受信データを変数sへ代入
@@ -89,7 +85,7 @@
                     }else if(len>6 && strncmp(s,"POST /",6)==0){
                         postF=1;                // POSTのBODY待ち状態へ
                     }
-                }else if(postF==1){
+                }else if(postF==1){             // POSTのHEAD処理中のとき、
                     if(len>16 && strncmp(s,"Content-Length: ",16)==0){
                         postL=atoi(&s[16]);     // 変数postLにデータ値を代入
                     }
@@ -111,9 +107,9 @@
     while(Serial.available())Serial.read();     // シリアル受信バッファのクリア
     if(com[0]){                                 // コマンドあり
         trUri2txt(com);                         // URLエンコードの変換処理
-        utf_del_uni(tx);                        // UTF8の制御コードの除去
+        utf_del_uni(com);                       // UTF8の制御コードの除去
         Serial.write(16);                       // DLEコードの送信
-        Serial.println(com);                    // 受信文字データを音声出力
+        Serial.println(com);                    // 文字データを出力
         delay(200);
         rx[0]='\0';
         while(Serial.available() && rxi<64){


updated the timer variables to all be unsigned long. Fixes an animation hiccup that could occur

--- Arduino/SpiritMinimial/SpiritMinimial.ino
+++ Arduino/SpiritMinimial/SpiritMinimial.ino
@@ -13,21 +13,21 @@
 // available options
 // ##############################
 const bool useGameCyclotronEffect = true;     // set this to true to get the fading previous cyclotron light in the idle sequence
-const bool useCyclotronFadeInEffect = true;   // Instead of the yellow alternate flashing on boot this fades the cyclotron in from off to red
+const bool useCyclotronFadeInEffect = false;   // Instead of the yellow alternate flashing on boot this fades the cyclotron in from off to red

 // ##############################
 // bootup animation speeds
 // ##############################
-const int pwr_boot_interval = 30;       // How fast to do the powercell drop animation on bootup
-const int cyc_boot_interval = 400;      // If useCyclotronFadeInEffect is false this alternates the cycltron lights yellow
-const int cyc_boot_alt_interval = 100;  // How fast to fade in the cyclotron lights from black to red on bootup
+const unsigned long pwr_boot_interval = 40;       // How fast to do the powercell drop animation on bootup
+const unsigned long cyc_boot_interval = 400;      // If useCyclotronFadeInEffect is false this alternates the cycltron lights yellow
+const unsigned long cyc_boot_alt_interval = 100;  // How fast to fade in the cyclotron lights from black to red on bootup

 // ##############################
 // idle animation speeds
 // ##############################
-const int pwr_interval = 50;            // how fast the powercell cycles
-const int cyc_interval = 750;           // how fast the cycltron cycles from one cell to the next
-const int cyc_fade_interval = 1;        // if useGameCyclotronEffect is true this is how fast to fade the previous cyclotron to light to nothing
+const unsigned long pwr_interval = 50;            // how fast the powercell cycles
+const unsigned long cyc_interval = 750;           // how fast the cycltron cycles from one cell to the next
+const unsigned long cyc_fade_interval = 1;        // if useGameCyclotronEffect is true this is how fast to fade the previous cyclotron to light to nothing

 void setup() {
   // configure powercell/cyclotron
@@ -42,7 +42,7 @@

 void loop() {
   // get the current time
-  int currentMillis = millis();
+  unsigned long currentMillis = millis();
   if( powerBooted == false ){
     powerSequenceBoot(currentMillis);
   } else {
@@ -122,13 +122,13 @@

 // boot animation on the powercell/cyclotron
 bool reverseBootCyclotron = false;
-void powerSequenceBoot(int currentMillis) {
+void powerSequenceBoot(unsigned long currentMillis) {
   bool doUpdate = false;
   bool doCycUpdate = false;

   // START CYCLOTRON
   if( useCyclotronFadeInEffect == false ){
-    if (currentMillis - prevCycBootMillis > cyc_boot_interval) {
+    if ((unsigned long)(currentMillis - prevCycBootMillis) >= cyc_boot_interval) {
       prevCycBootMillis = currentMillis;

       if( reverseBootCyclotron == false ){
@@ -150,7 +150,7 @@
       }
     }
   }else{
-    if (currentMillis - prevCycBootMillis > cyc_boot_alt_interval) {
+    if ((unsigned long)(currentMillis - prevCycBootMillis) >= cyc_boot_alt_interval) {
       prevCycBootMillis = currentMillis;
       setCyclotronLightState(c1Start, c4End, 4);
       doCycUpdate = true;
@@ -162,7 +162,7 @@
   }
   // END CYCLOTRON

-  if (currentMillis - prevPwrBootMillis > pwr_boot_interval) {
+  if ((unsigned long)(currentMillis - prevPwrBootMillis) >= pwr_boot_interval) {
     // save the last time you blinked the LED
     prevPwrBootMillis = currentMillis;

@@ -201,14 +201,14 @@
 int cycFading = -1;

 // normal animation on the bar graph
-void powerSequenceOne(int currentMillis, int anispeed, int cycspeed, int cycfadespeed) {
+void powerSequenceOne(unsigned long currentMillis, unsigned long anispeed, unsigned long cycspeed, unsigned long cycfadespeed) {
   bool doUpdate = false;
   bool doCycUpdate = false;

   // START CYCLOTRON
   if( useGameCyclotronEffect == true ){
     // figure out main light
-    if (currentMillis - prevCycMillis > cycspeed) {
+    if ((unsigned long)(currentMillis - prevCycMillis) >= cycspeed) {
       prevCycMillis = currentMillis;

       switch ( cycOrder ) {
@@ -254,7 +254,7 @@
     }

     // now figure out the fading light
-    if( currentMillis - prevFadeCycMillis > cycfadespeed ){
+    if( (unsigned long)(currentMillis - prevFadeCycMillis) >= cycfadespeed ){
       prevFadeCycMillis = currentMillis;
       if( cycFading != -1 ){
         switch ( cycFading ) {
@@ -276,7 +276,7 @@
     }
   }else{
     // figure out main light
-    if (currentMillis - prevCycMillis > cycspeed) {
+    if ((unsigned long)(currentMillis - prevCycMillis) >= cycspeed) {
       prevCycMillis = currentMillis;

       switch ( cycOrder ) {
@@ -320,7 +320,7 @@
   // END CYCLOTRON

   // START POWERCELL
-  if (currentMillis - prevPwrMillis > anispeed) {
+  if ((unsigned long)(currentMillis - prevPwrMillis) >= anispeed) {
     // save the last time you blinked the LED
     prevPwrMillis = currentMillis;


Changed comment

Changed comment

--- examples/led_fuel_gauge/led_fuel_gauge.ino
+++ examples/led_fuel_gauge/led_fuel_gauge.ino
@@ -1,6 +1,6 @@
 #include <Automaton.h>

-// six leds on 4, 5, 6, 7, 8, 9 and a pot on A0
+// Turning a pot on A0 will change a led gauge on pins 4, 5, 6, 7, 8, 9

 Atm_comparator cmp;
 Atm_led led[6];


Update feather_code.ino

Update feather_code.ino

--- code/feather_code.ino
+++ code/feather_code.ino
@@ -176,12 +176,12 @@
   mydata[0] = hightemp;
   mydata[1] = lowtemp;

-  float alt = bme.readAltitude(SEALEVELPRESSURE_HPA);
-  uint16_t altitude = (uint16_t) (alt / 1013.25 * 100);
-  uint8_t alti = (uint8_t) altitude;
-
-  mydata[2] = alti;
-  Serial.println(alti);
+  float pre = bme.readPressure() / 100.0F;
+  uint16_t pressure = (uint16_t ) ((pre / 1013.25) * 100);
+  uint8_t pres = (uint8_t) pressure;
+
+  mydata[2] = pres;
+  Serial.println(pressure);
   Serial.println();

   float hum = bme.readHumidity() * 100;


Add SIM808 AT commands test/Adafruit Test and Updated whereselaiza.ino

--- whereselaiza.ino
+++ whereselaiza.ino
@@ -1,17 +1,27 @@
-*/ WheresElaiza - IoT Dog Tracker
+/*
+	WheresElaiza
+
+		SIM 808 based GSM/GPS Dog Tracker
+
 	By Marco Longoria

 */

+#include "Adafruit_FONA.h"
+#include <SoftwareSerial.h>

+#define
+char replybuffer[255];
+SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
+SoftwareSerial *fonaSerial = &fonaSS;
+//	HardwareSerial *fonaSerial = &Serial1;
+Adafruit_FONA fona = Adafruit_FONA(FONA_RST);

-void setup();
+void setup(){
+	while (!Serial);
+	Serial.begin(115200);
+	Serial.println(F("WheresElaiza!"));
+	Serial.println(F("Initializing SIM808..."));

-	Serial.begin(115200);
-
-
-
-void loop();
-
-	Serial.print("Hello World my name is Elaiza");
-	+	fonaSerial->begin
+}


Start adding code for DDS-60

Start adding code for DDS-60

--- DigitalVFO.ino
+++ DigitalVFO.ino
@@ -48,6 +48,12 @@
 // define pin controlling contrast
 const byte mc_Brightness = 5;
 const byte mc_Contrast = 6;
+
+// define pins that control the DDS-60
+const byte FQ_UD = 14;    // connected to AD9851 device select pin
+const byte W_CLK = 15;    // connected to AD9851 clock pin
+const byte DATA = 16;     // connected to AD9851 D7 (serial data) pin
+

 // max and min frequency showable
 #define MAX_FREQ        30000000L
@@ -744,11 +750,57 @@

 ////////////////////////////////////////////////////////////////////////////////
 // Code to handle the DDS-60
-////////////////////////////////////////////////////////////////////////////////
-
-void update_dds60(Frequency freq)
-{
-
+//
+// From: http://www.rocketnumbernine.com/2011/10/25/programming-the-ad9851-dds-synthesizer
+// Andrew Smallbone <andrew@rocketnumbernine.com>
+////////////////////////////////////////////////////////////////////////////////
+
+void dds_pulse_high(byte pin)
+{
+  digitalWrite(pin, HIGH);
+  digitalWrite(pin, LOW);
+}
+
+// transfer a byte a bit at a time LSB first to DATA
+void dds_tfr_byte(byte data)
+{
+  for (int i = 0; i < 8; ++i, data >>= 1)
+  {
+    digitalWrite(DATA, data & 0x01);
+    dds_pulse_high(W_CLK);
+  }
+}
+
+// frequency of signwave (datasheet page 12) will be <sys clock> * <frequency tuning word> / 2^32
+void update_dds60(Frequency frequency)
+{
+  int32_t freq = frequency * 4294967296.0 / 180.0e6;
+
+  Serial.print("update_dds60: frequency="); Serial.println(frequency);
+  Serial.print("                   fred="); Serial.println(freq);
+
+  for (int b = 0; b < 4; ++b, freq >>= 8)
+  {
+    dds_tfr_byte(freq & 0xFF);
+  }
+
+  dds_tfr_byte(0x001);
+  dds_pulse_high(FQ_UD);
+}
+
+void dds_setup()
+{
+  // all pins to outputs
+  pinMode(FQ_UD, OUTPUT);
+  pinMode(W_CLK, OUTPUT);
+  pinMode(DATA, OUTPUT);
+
+  // if your board needs it, connect RESET pin and pulse it to reset AD9851
+  // dds_pulse_high(RESET)
+
+  // set serial load enable (Datasheet page 15 Fig. 17)
+  dds_pulse_high(W_CLK);
+  dds_pulse_high(FQ_UD);
 }


minor comment change

minor comment change

--- OpenStage.ino
+++ OpenStage.ino
@@ -81,7 +81,7 @@
         head and stepper motor shaft (if shaft is not 1/4").

   - Misc: You will also need a power supply for the motors (24V), a power supply for the
-   Arduino and associated electronics, a 20x4 character LCD display, LEDs, push-buttons,
+   Arduino and associated electronics, a 20x4 character LCD display, LEDs,
    power switches, etc. If you don't want to bother with the display, then you
    can just skip those items and comment out those code lines. Finally, a Sparkfun
    RS232 Serial Shifter is needed if you want to interface the controller with a PC


Convert to work with active-low relays

Convert to work with active-low relays

--- PushStart.ino
+++ PushStart.ino
@@ -41,10 +41,10 @@
 void setup() {

   // Bring relay pins low as soon as possible
-  digitalWrite(pinACC, LOW);
-  digitalWrite(pinIG1, LOW);
-  digitalWrite(pinIG2, LOW);
-  digitalWrite(pinST2, LOW);
+  digitalWrite(pinACC, HIGH);
+  digitalWrite(pinIG1, HIGH);
+  digitalWrite(pinIG2, HIGH);
+  digitalWrite(pinST2, HIGH);
   pinMode(pinACC, OUTPUT);
   pinMode(pinIG1, OUTPUT);
   pinMode(pinIG2, OUTPUT);
@@ -66,20 +66,20 @@

 void OFF() {
   mode = 0;
-  digitalWrite(pinACC, LOW);  // 2-3
-  digitalWrite(pinIG1, LOW);  // 2-4
-  digitalWrite(pinIG2, LOW);  // 7-6
-  digitalWrite(pinST2, LOW);  // 7-8
+  digitalWrite(pinACC, HIGH); // 2-3
+  digitalWrite(pinIG1, HIGH); // 2-4
+  digitalWrite(pinIG2, HIGH); // 7-6
+  digitalWrite(pinST2, HIGH); // 7-8
   ledShift = 0; ledAmp = 0;
   Serial.println("Mode: off"); Serial.flush();
 }

 void ACC() {
   mode = 1;
-  digitalWrite(pinACC, HIGH); // 2-3
-  digitalWrite(pinIG1, LOW);  // 2-4
-  digitalWrite(pinIG2, LOW);  // 7-6
-  digitalWrite(pinST2, LOW);  // 7-8
+  digitalWrite(pinACC, LOW);  // 2-3
+  digitalWrite(pinIG1, HIGH); // 2-4
+  digitalWrite(pinIG2, HIGH); // 7-6
+  digitalWrite(pinST2, HIGH); // 7-8
   ledShift = 64; ledAmp = 64;
   ledPeriod = 2000; fadeStart = millis();
   Serial.println("Mode: accessory"); Serial.flush();
@@ -87,20 +87,20 @@

 void ON() {
   mode = 2;
-  digitalWrite(pinACC, HIGH); // 2-3
-  digitalWrite(pinIG1, HIGH); // 2-4
-  digitalWrite(pinIG2, HIGH); // 7-6
-  digitalWrite(pinST2, LOW);  // 7-8
+  digitalWrite(pinACC, LOW);  // 2-3
+  digitalWrite(pinIG1, LOW);  // 2-4
+  digitalWrite(pinIG2, LOW);  // 7-6
+  digitalWrite(pinST2, HIGH); // 7-8
   ledShift = 32; ledAmp = 0;
   Serial.println("Mode: ignition on"); Serial.flush();
 }

 void ST() {
   mode = 3;
-  digitalWrite(pinACC, LOW);  // 2-3
-  digitalWrite(pinIG1, HIGH); // 2-4
-  digitalWrite(pinIG2, HIGH); // 7-6
-  digitalWrite(pinST2, HIGH); // 7-8
+  digitalWrite(pinACC, HIGH); // 2-3
+  digitalWrite(pinIG1, LOW);  // 2-4
+  digitalWrite(pinIG2, LOW);  // 7-6
+  digitalWrite(pinST2, LOW);  // 7-8
   ledShift = 128; ledAmp = 127;
   ledPeriod = 500; fadeStart = millis();
   Serial.println("Mode: engine start"); Serial.flush();


Make green indicator LED work with new Wifi shield.

--- device.ino
+++ device.ino
@@ -3482,8 +3482,7 @@
   }

   #ifdef WIFI_NOT_CELL
-/*
-  if(WiFi.status() == WL_CONNECTED)
+  if(cc3000.getStatus() == STATUS_CONNECTED)
   {
     if(wifi_communication_state == idle)
     {
@@ -3507,7 +3506,6 @@
   {
     digitalWrite(GREEN_LED, LOW);
   }
-*/
   #else

   //


Changed timings.

Changed timings.

--- Robot_Lights_Display/Robot_Lights_Display.ino
+++ Robot_Lights_Display/Robot_Lights_Display.ino
@@ -12,7 +12,7 @@
 #define YELLOW CRGB(255, 90, 0)
 #define BLUE CRGB(0, 50, 170)

-#define COG_SIZE 4 //MUST BE FOUR
+#define COG_SIZE 4

 /*
 Ronnie: I won't be able to come to Robotics today. If you read this message, you should test each method.
@@ -40,7 +40,7 @@
   for (int c = 4; c > 0; c--) {
     cylon(YELLOW, BLUE);
   }
-  for (int c = 50; c > 0; c--) {
+  for (int c = 25; c > 0; c--) {
     alternate(YELLOW, BLUE);
   }
   expandMiddle(YELLOW, BLUE);


Add Link TimeOut + power on/off

Add Link TimeOut + power on/off

--- TeleInfo/Tx_Node_TeleInfo/Tx_Node_TeleInfo.ino
+++ TeleInfo/Tx_Node_TeleInfo/Tx_Node_TeleInfo.ino
@@ -19,7 +19,7 @@
 #define ECO // Low Power Mode

 #define rxSerialPin 2  // RX PIN for Software Serial
-#define txSerialPin 3  // TX PIN for Software Serial
+#define txSerialPin -1  // TX PIN for Software Serial (unused)

 #define txLed 3  // TX LED
 #define txPin 1  // TX Out
@@ -29,16 +29,17 @@
 #define DEBUG  // Is serial debug active ?

 #define rxSerialPin 2  // RX PIN for Software Serial
-#define txSerialPin 3  // TX PIN for Software Serial
+#define txSerialPin -1  // TX PIN for Software Serial (unused)

 #define txLed 13  // TX LED
 #define txPin 12  // TX Out
-#define powerPin 14 // Power line for Tx module and sensor
+#define powerPin 8 // Power line for Tx module and sensor

 #endif

 #define WATCHDOG_TIMER WDTO_8S // 8 sec
 #define SLEEP_LOOP  2 // Deep Sleep total time = WATCHDOG_TIMER * SLEEP_LOOP
+#define LINK_TIMEOUT 10000 // Link TimeOut

 #define sensID 5  // Sensor ID

@@ -58,7 +59,7 @@
 sensorData_union_t _message;

 // EDF Link
-SoftwareSerial _edfLine(rxSerialPin, txSerialPin); // rx, tx pins
+SoftwareSerial _edfLink(rxSerialPin, txSerialPin); // rx, tx pins

 // WatchDof Counter
 volatile byte _watchdogCounter;
@@ -70,15 +71,12 @@

 void setup() {

-    // Debug
+  // Debug
 #ifdef DEBUG
   Serial.begin(57600);
   Serial.println("--- SETUP ---");
 #endif

-  // Start Serial with EDF box
-  _edfLine.begin(1200);
-
   // Write Sensor ID
   _message.data.id = sensID;
 }
@@ -95,11 +93,11 @@
     digitalWrite(txLed, HIGH);

 #ifdef DEBUG
-    Serial.print("Sensor=");
-    Serial.print(_message.data.id);
-    Serial.print(", Value=");
-    Serial.println(_message.data.value);
-#endif
+    Serial.print("Sensor="); Serial.print(_message.data.id); Serial.print(", Value="); Serial.println(_message.data.value);
+#endif
+
+    // End Serial
+    _edfLink.end();

     // Send
     vw_send(_message.raw, 5); // Send Raw message (size = 5 bytes)
@@ -129,16 +127,20 @@
   char current;
   char buffer[40];

+  // Get Current Date
+  unsigned long start = millis();
+
   // Clear buffer
   buffer[0] = '\0';
-
-  while(!exit)
+
+  // Loop
+  while (millis() - start < LINK_TIMEOUT && !exit)
   {
-    // Wait a Char
-    if(_edfLine.available())
+    // OK to read ?
+    if(_edfLink.available())
     {
       // Read
-      current = _edfLine.read();
+      current = _edfLink.read();

       // Clean Value
       current &=0x7F;
@@ -167,7 +169,8 @@
 #ifdef DEBUG
         //Serial.print("Data : <"); Serial.print(buffer); Serial.println(">");
 #endif
-
+
+        // Find PAPP value in line : ex PAPP 00450 *
         char * papp;
         papp = strstr(buffer,"PAPP");

@@ -181,7 +184,6 @@

 #ifdef DEBUG
           Serial.print("PAPP = <"); Serial.print(papp); Serial.println(">");
-          Serial.print("PAPP = <"); Serial.print(value); Serial.println(">");
 #endif

             // Save Power
@@ -204,6 +206,10 @@
     }
   }

+#ifdef DEBUG
+  Serial.println("Link TimeOut");
+#endif
+
   return false;
 }

@@ -220,6 +226,9 @@

   // Led Setup
   pinMode(txLed, OUTPUT);
+
+  // Start Serial with EDF box
+  _edfLink.begin(1200);

   // TX Setup
   vw_set_tx_pin(txPin);


add:modeA/B

add:modeA/B

--- RGB_matrix.ino
+++ RGB_matrix.ino
@@ -11,13 +11,34 @@
 void setup(){
     pinMode( SWITCH_PIN, INPUT_PULLUP);
     analogReference(INTERNAL);
+
     Led::init();
+    Led::setInterval(20);
+
     song1.setMelody(melody1,noteDurations1,82);
     song2.setMelody(melody2,noteDurations2,68);
 }

 void loop(){
+
+    //スイッチが押されるまでmodeA
+    while( digitalRead(SWITCH_PIN) ) modeA();

+    //スイッチが離されるまで待つ
+    delay(100);
+    while( !digitalRead(SWITCH_PIN) );
+
+    //スイッチが押されるまでmodeB
+    while( digitalRead(SWITCH_PIN) ) modeB();
+
+    //スイッチが離されるまで待つ
+    delay(100);
+    while( !digitalRead(SWITCH_PIN) );
+
+}
+
+
+void modeA(){
     //音が変わるたびに発光箇所が変わる
     song1.play();
     while( song1.isPlaying() ){
@@ -28,8 +49,10 @@
         Led::lighting();
     }
     song1.stop();
-    delay(1000);
-
+    delay(500);
+}
+
+void modeB(){
     //音の高さによって色が変わる
     song2.play();
     while( song2.isPlaying() ){
@@ -39,10 +62,8 @@
         Led::lighting();
     }
     song2.stop();
-    delay(1000);
-
+    delay(500);
 }
-

 void tutorial(){


Fixed quick reverse anomoly

Fixed quick reverse anomoly

--- THC4/THC4.ino
+++ THC4/THC4.ino
@@ -1,6 +1,4 @@
 /*
- * Sketch1.ino
- *
  * Timer 3 counts the 1Mhz reference from the THCAD (Port E bit 6)
  * Timer 4 counts the signal from the THCAD (Port H bit 7)
  * Timer 5 controls the output to the stepper driver (pins 45-46)
@@ -32,9 +30,9 @@
 long thcCorrectInc = 1;
 int FreqZero = 1212;
 int incomingByte = 0;
-long currPosACT = 0;
-long currPosIN = 0;
-long currPosSP = 0;
+long currPosACT = 1000000;
+long currPosIN = 1000000;
+long currPosSP = 1000000;
 long thcOffset = 0;
 boolean timer5ON = false;
 int temp = 0;
@@ -132,9 +130,9 @@
 	TCNT4 = 0;
 	TCNT5 = 0;

-	currPosACT = 0;
-	currPosIN = 0;
-	currPosSP = 0;
+	currPosACT = 1000000;
+	currPosIN = 1000000;
+	currPosSP = 1000000;
 	timer5ON = 0;

 //NEED TO INITIALIZE THE PINS THAT ARE INTERRUPT DRIVEN
@@ -222,7 +220,7 @@
 		currPosACT++;

        // check if we have arrived at the SP and if we are going slow enough to stop
-       if( currPosACT == currPosSP && stepIndex <= 1)
+       if( currPosACT == currPosSP ) //&& stepIndex <= 1)
         {
             //no pulses are needed, stop the timer
  	    TCCR5B &= 0xF8;
@@ -230,7 +228,7 @@
             stepIndex = 0;

         }
-        else if( temp == 0 ) //are we moving up?
+        else if( temp == 0 && currPosSP > currPosACT ) // if we are moving up and we should be
         {
            if( currPosSP > ( currPosACT + stepIndex )) //See if we have time to continue to speed up
            {
@@ -247,7 +245,8 @@
            }
            else if( currPosSP <= ( currPosACT + stepIndex  )) //Do we have to start slowing down
            {
-              stepIndex--; //Slow down
+              if (stepIndex>0)
+                  stepIndex--; //Slow down

               newOCR = pgm_read_word_near(stepToOCR + stepIndex); //newOCR = stepToOCR[stepIndex];

@@ -255,7 +254,7 @@
               OCR5B = newOCR/2;
            }
         }
-        else if( temp != 0 ) //are we moving down?
+        else if( temp != 0 && currPosSP < currPosACT) //if we are moving down and we should be
         {
            if( currPosSP < ( currPosACT - stepIndex  )) //See if we have time to continue to speed up
            {
@@ -271,7 +270,8 @@
            }
            else if( currPosSP >= ( currPosACT - stepIndex  )) //Do we have to start slowing down
            {
-              stepIndex--; //Slow down
+              if (stepIndex>0)
+                  stepIndex--; //Slow down

               newOCR = pgm_read_word_near(stepToOCR + stepIndex); //newOCR = stepToOCR[stepIndex];

@@ -279,6 +279,21 @@
               OCR5B = newOCR/2;
            }
         }
+        else
+        {
+          if (stepIndex>0) //are we ready to stop?
+          {
+                stepIndex--; //Slow down
+          }
+          else if (stepIndex == 0 )
+          {
+            TCCR5B &= 0xF8;
+ 	    timer5ON = 0;
+            stepIndex = 0;
+          }
+        }
+
+

@@ -478,11 +493,14 @@
           PORTB &= ~_BV(7);

-        //Serial.print(currPosSP);
-	//Serial.print(" ");
-	//Serial.print(currPosACT);
-        //Serial.print(" ");
-        //Serial.println(stepIndex);
+      /*  Serial.print(currPosSP);
+	Serial.print(" ");
+	Serial.print(currPosACT);
+        Serial.print(" ");
+        Serial.print(timer5ON);
+        Serial.print(" ");
+        Serial.println(stepIndex);
+        */

 	//debugJunk();	  //*************************************************** for troubleshooting ***********************************************
 }


name of motors

name of motors


add support for JN Micro

add support for JN Micro

--- examples/RF12/radioBlip/radioBlip.ino
+++ examples/RF12/radioBlip/radioBlip.ino
@@ -9,12 +9,14 @@
 ISR(WDT_vect) { Sleepy::watchdogEvent(); }

 void setup() {
-    rf12_initialize(4, RF12_868MHZ, 5);
+#if defined(__AVR_ATtiny84__)
+    cli();
+    CLKPR = bit(CLKPCE);
+    CLKPR = 0; // div 1, i.e. speed up to 8 MHz
+    sei();
+#endif
+    rf12_initialize(18, RF12_868MHZ, 5);
     rf12_sleep(RF12_SLEEP);
-
-    // stay off  3 minutes after reset, to make sure that power is stable
-    for (byte i = 0; i < 3; ++i)
-        Sleepy::loseSomeTime(60000);
 }

 void loop() {


Add pickNextWaypoint function and introduce twoInts struct

--- OpenCM/GoalieCode/GoalieCode.ino
+++ OpenCM/GoalieCode/GoalieCode.ino
@@ -6,6 +6,12 @@
 {
   double first;
   double second;
+};
+
+struct twoInts
+{
+  int first;
+  int second;
 };

 struct fourtuple
@@ -202,6 +208,42 @@

   return CurrPosition;
 }
+
+struct twoInts pickNextWaypoint()
+{
+  /* This function chooses the next waypoint. Returns twoInts nextWaypoint = {nextWaypoint_left, nextWaypoint_right}
+     Idea: Check which waypoint we are closest to and choose the next.
+  */
+  fourtuple CurrPos = getCurrPosition();
+  twoInts nextWaypoint;
+
+  float distance2_left = 1000; //initialize squared distances to large value
+  float distance2_right = 1000;
+
+  for (int i=0; i<=noOfWaypoints; i++)
+  {
+    if ( (CurrPos.first-trajectory[i].yleft)*(CurrPos.first-trajectory[i].yleft)+(CurrPos.second-trajectory[i].zleft)*(CurrPos.second-trajectory[i].zleft) < distance2_left ) //check if i th waypoint is closer than any previous ones
+    {
+      nextWaypoint.first = i;
+      distance2_left = (CurrPos.first-trajectory[i].yleft)*(CurrPos.first-trajectory[i].yleft)+(CurrPos.second-trajectory[i].zleft)*(CurrPos.second-trajectory[i].zleft);
+    }
+
+    if ( (CurrPos.third-trajectory[i].yright)*(CurrPos.third-trajectory[i].yright)+(CurrPos.fourth-trajectory[i].zright)*(CurrPos.fourth-trajectory[i].zright) < distance2_right )
+    {
+      nextWaypoint.second = i;
+      distance2_left = (CurrPos.third-trajectory[i].yright)*(CurrPos.third-trajectory[i].yright)+(CurrPos.fourth-trajectory[i].zright)*(CurrPos.fourth-trajectory[i].zright);
+    }
+  }
+
+  /* increment next waypoint unless we are already at the last one */
+  if (nextWaypoint.first != noOfWaypoints)
+    nextWaypoint.first++;
+  if (nextWaypoint.second != noOfWaypoints)
+    nextWaypoint.second++;
+
+  return nextWaypoint;
+}
+

 void setup() //this runs once after startup or reset


reset to current conditions on fade out

reset to current conditions on fade out

--- WifiWeatherGuy.ino
+++ WifiWeatherGuy.ino
@@ -424,6 +424,9 @@
       display_on = now;
       fade = cfg.bright;
       analogWrite(TFT_LED, fade);
+    } else if (screen > 0) {
+      screen = 0;
+      update_display(screen);
     }
   } else if (now - display_on > cfg.on_time) {
     analogWrite(TFT_LED, --fade);


modified:   mcu_main/mcu_main.ino

modified:   mcu_main/mcu_main.ino

--- mcu_main/mcu_main.ino
+++ mcu_main/mcu_main.ino
@@ -13,9 +13,6 @@
   pinMode(B, OUTPUT);
   pinMode(C, OUTPUT);
   pinMode(D, OUTPUT);
-
-  //pinMode(trigger, OUTPUT);
-
 }

 void one(){
@@ -78,66 +75,127 @@

 // main routine to microstep
 void doStep(int st){
-
+
   long dt1 = waitMicroSeconds * duty / 100;
   long dt2 = waitMicroSeconds * (100-duty) / 100;

   for (int j = 0; j < pulseCount; j++){
     switch (st){
-    case 1: one();break;
-    case 2: two();break;
-    case 3: three();break;
-    case 4: four();break;
-    case 11: oneB();break;
-    case 12: twoB();break;
-    case 13: threeB();break;
-    case 14: fourB();break;
-
-    case 21: one();break;
-    case 22: two();break;
-    case 23: three();break;
-    case 24: four();break;
-    case 31: oneB();break;
-    case 32: twoB();break;
-    case 33: threeB();break;
-    case 34: fourB();break;
-
+    case 1:
+      one();
+      break;
+    case 2:
+      two();
+      break;
+    case 3:
+      three();
+      break;
+    case 4:
+      four();
+      break;
+    case 11:
+      oneB();
+      break;
+    case 12:
+      twoB();
+      break;
+    case 13:
+      threeB();
+      break;
+    case 14:
+      fourB();
+      break;
+
+    case 21:
+      one();
+      break;
+    case 22:
+      two();
+      break;
+    case 23:
+      three();
+      break;
+    case 24:
+      four();
+      break;
+    case 31:
+      oneB();
+      break;
+    case 32:
+      twoB();
+      break;
+    case 33:
+      threeB();
+      break;
+    case 34:
+      fourB();
+      break;
+    }
+    delayMicroseconds(dt1);
+
+    switch (st){
+    case 1:
+      one();
+      break;
+    case 2:
+      two();
+      break;
+    case 3:
+      three();
+      break;
+    case 4:
+      four();
+      break;
+    case 11:
+      oneB();
+      break;
+    case 12:
+      twoB();
+      break;
+    case 13:
+      threeB();
+      break;
+    case 14:
+      fourB();
+      break;
+
+    case 21:
+      oneB();
+      break;
+    case 22:
+      twoB();
+      break;
+    case 23:
+      threeB();
+      break;
+    case 24:
+      fourB();
+      break;
+    case 31:
+      two();
+      break;
+    case 32:
+      three();
+      break;
+    case 33:
+      four();
+      break;
+    case 34:
+      one();
+      break;
     }
-
-    delayMicroseconds(dt1);
-
-    switch (st){
-    case 1: one();break;
-    case 2: two();break;
-    case 3: three();break;
-    case 4: four();break;
-    case 11: oneB();break;
-    case 12: twoB();break;
-    case 13: threeB();break;
-    case 14: fourB();break;
-
-    case 21: oneB();break;
-    case 22: twoB();break;
-    case 23: threeB();break;
-    case 24: fourB();break;
-    case 31: two();break;
-    case 32: three();break;
-    case 33: four();break;
-    case 34: one();break;
-    }
-    delayMicroseconds(dt2);
-
+    delayMicroseconds(dt2);
   }
 }

 // disable motor
 void motorOff(){
   /* Important note:
-       Turning off the motor will make it go into a 'rest' state.
-       When using microsteps (or even full steps), this may not be the last active step.
-       So using this routine may change the position of the motor a bit.
-  */
-
+   Turning off the motor will make it go into a 'rest' state.
+   When using microsteps (or even full steps), this may not be the last active step.
+   So using this routine may change the position of the motor a bit.
+   */
+
   digitalWrite(A, LOW);
   digitalWrite(B, LOW);
   digitalWrite(C, LOW);
@@ -145,34 +203,57 @@
 }

 // full stepping 4 steps :
-void do4Steps(int cnt, boolean forwards){
-  //for (int i = 0; i < cnt; i++)
-    duty = 50;
-
-    if (forwards)
-      {//for (int j = 1; j <= 4; j++){doStep(j);}
-         int j=1;
-         int i=1;
-          while (j<=4 && i<=cnt) {
-          doStep(j);
-          i++;
-           j++;}
-      }
-    else
-      {for (int j = 4; j >= 1; j--){doStep(j);}}
-
-  //}
+void do4Steps(int cnt, boolean forwards)
+{
+  duty = 50;
+  unsigned count = 0;
+  const int list[] = {1,2,3,4};
+  if(forwards)
+  {
+    while(count<cnt)
+      doStep(list[count++ %4]);
+  }
+  else
+  {
+    int index = 3;
+    while(count<cnt)
+    {
+      doStep(list[index--]);
+      if(index<0)
+        index=3;
+      ++count;
+    }
+  }
 }

 // half stepping 8 steps :
 void do8Steps(int cnt, boolean forwards){
-  const int list[] = {1,11,2,12,3,13,4,14};
-  for (int i = 0; i < cnt; i++){
-    duty = 50;
-    if (forwards)
-      {for (int j = 0; j <= 7; j++){doStep(list[j]);}}
-    else
-      {for (int j = 7; j >= 0; j--){doStep(list[j]);}}
+  //const int list[] = {1,11,2,12,3,13,4,14};
+  //for (int i = 0; i < cnt; i++){
+  //duty = 50;
+  //if (forwards)
+  //{for (int j = 0; j <= 7; j++)
+  // {doStep(list[j]);}}
+
+
+  //else
+  // {for (int j = 7; j >= 0; j--){doStep(list[j]);}}
+  //
+  unsigned count = 0;
+  const int list[] = {
+    1,11,2,12,3,13,4,14  };
+  if(forwards){
+    while(count<cnt)
+      doStep(list[count++ %8]);
+  }
+  else{
+    int index = 7;
+    while(count<cnt){
+      doStep(list[index--]);
+      if(index<0)
+        index=7;
+      ++count;
+    }
   }
 }

@@ -180,147 +261,180 @@
 // microstepping 16 steps :
 void do16Steps(int cnt, boolean forwards){

-  const int list[] = {1,21,11,31,2,22,12,32,3,23,13,33,4,24,14,34};
-  for (int i = 0; i < cnt; i++){
-    duty = 50;
-    if (forwards)
-      {for (int j = 0; j <= 15; j++)
-    {doStep(list[j]);}}
-    else
-      {for (int j = 15; j >= 0; j--){doStep(list[j]);}}
-  }
-}
-
+  //const int list[] = {1,21,11,31,2,22,12,32,3,23,13,33,4,24,14,34};
+  /* for (int i = 0; i < cnt; i++){
+   duty = 50;
+   if (forwards)
+   {for (int j = 0; j <= 15; j++)
+   {doStep(list[j]);}}
+   else
+   {for (int j = 15; j >= 0; j--){doStep(list[j]);}}
+   }
+
+
+   }*/
+  unsigned count = 0;
+  const int list[] = {
+    1,21,11,31,2,22,12,32,3,23,13,33,4,24,14,34  };
+  duty = 50;
+  if(forwards){
+    while(count<cnt){
+      doStep(list[count++ %16]);
+
+    }
+  }
+  else{
+    int index = 15;
+    while(count<cnt){
+      doStep(list[index--]);
+      if(index<0)
+        index=15;
+      ++count;
+    }
+  }
+}
+
 // microstepping >16 steps :
-void doMoreSteps(int cnt, boolean forwards){
-  const int list1[] = {1,11,2,12,3,13,4,14};
-  const int list2[] = {21,31,22,32,23,33,24,34};
-
-  for (int i = 0; i < cnt; i++){
-
-    duty = 50;
-    if (forwards)
-      {for (int j = 0; j <= 7; j++){doStep(list1[j]); doSteps(list2[j], forwards);}}
-    else
-      {for (int j = 7; j >= 0; j--){doSteps(list2[j], forwards); doStep(list1[j]);}}
-
-  }
-}
-
-// this routine handles >16 microsteps
-// uncomment sections to choose # steps
-void doSteps(int st, boolean forwards){
-
-// *********************** 24 steps
+/*void doMoreSteps(int cnt, boolean forwards){
+ const int list1[] = {1,11,2,12,3,13,4,14};
+ const int list2[] = {21,31,22,32,23,33,24,34};
+ unsigned count = 0;
+ // for (int i = 0; i < cnt; i++){
+
+ duty = 50;
+ if (forwards)
+ {
+ while(count<cnt)
+ {
+ doStep(list1[count %8]);
+ doSteps(list2[count %8]);
+
+ count++;
+
+ //  for (int j = 0; j <= 7; j++){doStep(list1[j]); doSteps(list2[j], forwards);}
+ }
+ }
+ else
+ {//for (int j = 7; j >= 0; j--){doSteps(list2[j], forwards); doStep(list1[j]);}}
+
+ }
+ }
+
+ // this routine handles >16 microsteps
+ // uncomment sections to choose # steps
+ void doSteps(int st){
+
+ // *********************** 24 steps
+
+ // if(forwards){
+ duty = 66;    doStep(st);
+ duty = 33;    doStep(st);
+ //}
+ //else{
+ //duty = 33;    doStep(st);
+ // duty = 66;    doStep(st);
+ //}
+
+
+
+ // *********************** 32 steps
 /*
-  if (forwards){
-    duty = 66;    doStep(st);
-    duty = 33;    doStep(st);
-  }
-  else{
-    duty = 33;    doStep(st);
-    duty = 66;    doStep(st);
-  }
-*/
-
-
-// *********************** 32 steps
-/*
-  if (forwards){
-    duty = 75;    doStep(st);
-    duty = 50;    doStep(st);
-    duty = 25;    doStep(st);
-  }
-  else{
-    duty = 25;    doStep(st);
-    duty = 50;    doStep(st);
-    duty = 75;    doStep(st);
-  }
-*/
+ if (forwards){
+ duty = 75;    doStep(st);
+ duty = 50;    doStep(st);
+ duty = 25;    doStep(st);
+ }
+ else{
+ duty = 25;    doStep(st);
+ duty = 50;    doStep(st);
+ duty = 75;    doStep(st);
+ }
+ */

 // *********************** 48 steps

 /*  if (forwards){
-    for (int i = 5; i >= 1; i--){duty = 17 * i; doStep(st);}
-  }
-  else{
-    for (int i = 1; i <= 5; i++){duty = 17 * i; doStep(st);}
-  }
-*/
+ for (int i = 5; i >= 1; i--){duty = 17 * i; doStep(st);}
+ }
+ else{
+ for (int i = 1; i <= 5; i++){duty = 17 * i; doStep(st);}
+ }
+ */

 // *********************** 64 steps
 /*
   if (forwards){
-    for (int i = 7; i >= 1; i--){duty = 12 * i; doStep(st);}
-  }
-  else{
-    for (int i = 1; i <= 7; i++){duty = 12 * i; doStep(st);}
-  }
-*/
-
+ for (int i = 7; i >= 1; i--){duty = 12 * i; doStep(st);}
+ }
+ else{
+ for (int i = 1; i <= 7; i++){duty = 12 * i; doStep(st);}
+ }
+ */
+
 // *********************** 96 steps
-  if (forwards){
-    for (int i = 9; i >= 1; i--){duty = 10 * i; doStep(st);}
-  }
-  else{
-    for (int i = 1; i <= 9; i++){duty = 10 * i; doStep(st);}
-  }
-
-}
+// if (forwards){
+//  for (int i = 9; i >= 1; i--){duty = 10 * i; doStep(st);}
+// }
+//else{
+//  for (int i = 1; i <= 9; i++){duty = 10 * i; doStep(st);}
+// }
+
+

 // the loop routine runs over and over again forever:
 void loop() {
-
-// uncomment this to disable motor
-//  motorOff();return;
-
-
-/* control the speed of the motor with a waitMicroseconds/pulseCount pair
+
+  // uncomment this to disable motor
+  //  motorOff();return;
+
+
+  /* control the speed of the motor with a waitMicroseconds/pulseCount pair
    e.g. waitMicroSeconds / pulseCount
-        500 / 5 --> one step takes 2500 microseconds
-        50 / 50 --> one step also takes 2500 microseconds
-        but in second pair the fequency of the wave is 20kHz, not audible..
-        in 500 / 5 you may hear a high tone in the motor in microsteps
-        some motors may not respond well on higher frequencies
+   500 / 5 --> one step takes 2500 microseconds
+   50 / 50 --> one step also takes 2500 microseconds
+   but in second pair the fequency of the wave is 20kHz, not audible..
+   in 500 / 5 you may hear a high tone in the motor in microsteps
+   some motors may not respond well on higher frequencies
    note: these parameters also control speed in normal stepping (full or half) although there's no pulses in those cases,
-            setting pulseCount = 1 might be more readable
-*/
-  waitMicroSeconds = 10000;
-  pulseCount = 1;
-
-/*  uncomment one of the next routines to choose stepping mode
-  do4Steps : full stepping
-  do8Steps : half stepping
-  do16Steps : microstepping with 16 steps
-  doMoreSteps : microstepping with more than 16 steps
-     --> check routine 'doSteps' for extra uncomments
-
-  two parameters:
-    1. number of steps
-    2. forwards = true --> move forwards   /  forwards = false --> move backwards
-
-  note: there's no speed correction for different modes, so do4Steps makes the motor go twice as fast as do8Steps and so on...
-        use waitMicroseconds and pulseCount to adapt speed when changing modes
-
-*/
-
-   do4Steps(24, true);
-// do8Steps(24, true);
+   setting pulseCount = 1 might be more readable
+   */
+  //  waitMicroSeconds = 10000;
+  //  pulseCount = 1;
+
+  /*  uncomment one of the next routines to choose stepping mode
+   do4Steps : full stepping
+   do8Steps : half stepping
+   do16Steps : microstepping with 16 steps
+   doMoreSteps : microstepping with more than 16 steps
+   --> check routine 'doSteps' for extra uncomments
+
+   two parameters:
+   1. number of steps
+   2. forwards = true --> move forwards   /  forwards = false --> move backwards
+
+   note: there's no speed correction for different modes, so do4Steps makes the motor go twice as fast as do8Steps and so on...
+   use waitMicroseconds and pulseCount to adapt speed when changing modes
+
+   */
+
+  // do4Steps(24, true);
+  do4Steps(24, true);
   //do16Steps(24, true);
-//  doMoreSteps(24, true);
-
-  motorOff(); // give it a rest (see note in motorOff about losing steps)
+  //doMoreSteps(24, true);
+
+  //motorOff(); // give it a rest (see note in motorOff about losing steps)
   delay(1000);

-//  do4Steps(24, false);
-//  do8Steps(24, false);
+  //  do4Steps(24, false);
+  //do8Steps(24, false);
   //do16Steps(24, false);
-//  doMoreSteps(24, false);
-
-  motorOff(); // give it a rest (see note in motorOff about losing steps)
+  //  doMoreSteps(24, false);
+
+  //motorOff(); // give it a rest (see note in motorOff about losing steps)
   delay(1000);

-}
+}
+


Increased Simula volume setting on boot

Increased Simula volume setting on boot

--- examples/Simula_BehaviorTree/Simula_BehaviorTree.ino
+++ examples/Simula_BehaviorTree/Simula_BehaviorTree.ino
@@ -68,12 +68,12 @@

 	crcLights.setRandomColor();
 	crcLights.showRunwayWithDelay();
-	//MP3 Player & Amplifier
-	crcAudio.setAmpGain(1); //0 = low, 3 = high
-	crcAudio.setVolume(40, 40); //0 = loudest, 60 = softest ?
+
+	//Amplifier gain and VS1053 volume
+	crcAudio.setAmpGain(2); //0 = low, 3 = high
+	crcAudio.setVolume(20, 20); //0 = loudest, 60 = softest ?

 	if (hardware.sdInitialized) {
-		//crcAudio.playRandomAudio(F("effects/PwrDn_"), 10, F(".mp3"));
 		crcAudio.playRandomAudio(F("effects/PwrUp_"), 10, F(".mp3"));
 	}
 	Serial.println(F("Setup complete."));


added example for heartbeat

added example for heartbeat

--- examples/esp8266/WebSocketClient/WebSocketClient.ino
+++ examples/esp8266/WebSocketClient/WebSocketClient.ino
@@ -84,6 +84,12 @@

 	// try ever 5000 again if connection has failed
 	webSocket.setReconnectInterval(5000);
+
+  // start heartbeat (optional)
+  // ping server every 15000 ms
+  // expect pong from server within 3000 ms
+  // consider connection disconnected if pong is not received 2 times
+  webSocket.enableHeartbeat(15000, 3000, 2);

 }


fixed #64

fixed #64

--- Modules/Modifier/SquareGenerator/ArduinoCodes/SquareGeneratorATtiny/SquareGeneratorATtiny.ino
+++ Modules/Modifier/SquareGenerator/ArduinoCodes/SquareGeneratorATtiny/SquareGeneratorATtiny.ino
@@ -51,7 +51,7 @@
   int input_val = cutAndMap(input.filteredAnalogRead(AVERAGE), 50, 975, 0, 1023);
   int pot_val = analogRead(pot_pin);

-  interval = map(pot_val, 0, 1023, max_period, min_period);   //need second map because input_val is used below
+  interval = map(pot_val, 0, 1023, min_period, max_period);   //need second map because input_val is used below
   unsigned long currentMillis = millis();

   if (currentMillis - previousMillis >= interval) {


Make simple test more simple.

Make simple test more simple.

--- examples/mqtt_simple_test/mqtt_simple_test.ino
+++ examples/mqtt_simple_test/mqtt_simple_test.ino
@@ -47,9 +47,8 @@
     mqtt->connect(callback);
     mqtt->set_prepare_data_hook([](JsonObject** root)
     {
-        JsonObject& data = (*(*root))["d"];
+        JsonObject& data = (*root)->at("d");
         data["myName"] = "SIMPLE-TEST";
-        data["adc"] = analogRead(A0);;
     });
 }


Added PIR tracking

Added PIR tracking

--- base/base.ino
+++ base/base.ino
@@ -19,6 +19,7 @@
   unsigned humi;
   unsigned light;
   unsigned door;
+  unsigned pir;
   unsigned long hkey;
 };

@@ -102,6 +103,7 @@
                        + "[humi: "  + String((float)payload.humi,2) + "%] "
                        + "[light: " + String((float)payload.light,2) + "%] "
                        + "[door: "  + String(payload.door) + "] "
+                       + "[pir: "  + String(payload.pir) + "] "
                        + "[hkey: "  + String(payload.hkey) + "] ";
       Serial.println(dataPrint);

@@ -158,7 +160,11 @@
          String node_str;
          if (payload.door){
            digitalWrite(ledPin, HIGH);
-           node_str = String("NODE #")+payload.node+String("     SOFT ALARM!");
+           node_str = String("NODE #")+payload.node+String("     REED ALARM!");
+         }
+         else if (payload.pir){
+           digitalWrite(ledPin, HIGH);
+           node_str = String("NODE #")+payload.node+String("     PIR ALARM!");
          }
          else{
            digitalWrite(ledPin, LOW);


Reset default neopixels

Reset default neopixels

--- Arduino/Mimic_LED_Controller/Mimic_LED_Controller.ino
+++ Arduino/Mimic_LED_Controller/Mimic_LED_Controller.ino
@@ -111,7 +111,7 @@
   }
   else
   {
-    allSet_module(module_strip.Color(0,0,50),0);
+    allSet_module(module_strip.Color(0,0,0),0);
     module_strip.show();
   }


Fix esp32 mdns

Fix esp32 mdns

--- examples/NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino
+++ examples/NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino
@@ -41,7 +41,9 @@
 }

 void loop() {
+  #ifdef ESP8266
   MDNS.update();
+  #endif
   doWiFiManager();
   // put your main code here, to run repeatedly:
 }