arrange fuzzy logic

arrange fuzzy logic

--- fuzzy_logic.ino
+++ fuzzy_logic.ino
@@ -53,127 +53,129 @@
   then_thetaZO->addOutput(theta_zo);

   // Rules Antecedents
-
+
+  // Position NM
   FuzzyRuleAntecedent* positionNM_setPointNM = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionNS_setPointNS = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionZO_setPointZO = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionPS_setPointPS = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionPM_setPointPM = new FuzzyRuleAntecedent();
-
-  positionNM_setPointNM->joinWithAND(position_nm, setpoint_nm);
-  positionNS_setPointNS->joinWithAND(position_ns, setpoint_ns);
-  positionZO_setPointZO->joinWithAND(position_zo, setpoint_zo);
-  positionPS_setPointPS->joinWithAND(position_ps, setpoint_ps);
-  positionPM_setPointPM->joinWithAND(position_pm, setpoint_pm);
-
-  FuzzyRule* Rule1 = new FuzzyRule(1, positionNM_setPointNM, then_thetaZO);
-  FuzzyRule* Rule2 = new FuzzyRule(2, positionNS_setPointNS, then_thetaZO);
-  FuzzyRule* Rule3 = new FuzzyRule(3, positionZO_setPointZO, then_thetaZO);
-  FuzzyRule* Rule4 = new FuzzyRule(4, positionPS_setPointPS, then_thetaZO);
-  FuzzyRule* Rule5 = new FuzzyRule(5, positionPM_setPointPM, then_thetaZO);
-
   FuzzyRuleAntecedent* positionNM_setPointNS = new FuzzyRuleAntecedent();
   FuzzyRuleAntecedent* positionNM_setPointZO = new FuzzyRuleAntecedent();
   FuzzyRuleAntecedent* positionNM_setPointPS = new FuzzyRuleAntecedent();
   FuzzyRuleAntecedent* positionNM_setPointPM = new FuzzyRuleAntecedent();

+  positionNM_setPointNM->joinWithAND(position_nm, setpoint_nm);
   positionNM_setPointNS->joinWithAND(position_nm, setpoint_ns);
   positionNM_setPointZO->joinWithAND(position_nm, setpoint_zo);
   positionNM_setPointPS->joinWithAND(position_nm, setpoint_ps);
   positionNM_setPointPM->joinWithAND(position_nm, setpoint_pm);

-  FuzzyRule* Rule6 = new FuzzyRule(6, positionNM_setPointNS, then_thetaZO);
-  FuzzyRule* Rule7 = new FuzzyRule(7, positionNM_setPointZO, then_thetaNS);
-  FuzzyRule* Rule8 = new FuzzyRule(8, positionNM_setPointPS, then_thetaNS);
-  FuzzyRule* Rule9 = new FuzzyRule(9, positionNM_setPointPM, then_thetaNM);
-
+  FuzzyRule* Rule1 = new FuzzyRule(1, positionNM_setPointNM, then_thetaZO);
+  FuzzyRule* Rule2 = new FuzzyRule(2, positionNM_setPointNS, then_thetaZO);
+  FuzzyRule* Rule3 = new FuzzyRule(3, positionNM_setPointZO, then_thetaNS);
+  FuzzyRule* Rule4 = new FuzzyRule(4, positionNM_setPointPS, then_thetaNS);
+  FuzzyRule* Rule5 = new FuzzyRule(5, positionNM_setPointPM, then_thetaNM);
+
+  fuzzyObj->addFuzzyRule(Rule1);
+  fuzzyObj->addFuzzyRule(Rule2);
+  fuzzyObj->addFuzzyRule(Rule3);
+  fuzzyObj->addFuzzyRule(Rule4);
+  fuzzyObj->addFuzzyRule(Rule5);
+
+  // Position NS
+  FuzzyRuleAntecedent* positionNS_setPointNS = new FuzzyRuleAntecedent();
   FuzzyRuleAntecedent* positionNS_setPointNM = new FuzzyRuleAntecedent();
   FuzzyRuleAntecedent* positionNS_setPointZO = new FuzzyRuleAntecedent();
   FuzzyRuleAntecedent* positionNS_setPointPS = new FuzzyRuleAntecedent();
   FuzzyRuleAntecedent* positionNS_setPointPM = new FuzzyRuleAntecedent();

+  positionNS_setPointNS->joinWithAND(position_ns, setpoint_ns);
   positionNS_setPointNM->joinWithAND(position_ns, setpoint_nm);
   positionNS_setPointZO->joinWithAND(position_ns, setpoint_zo);
   positionNS_setPointPS->joinWithAND(position_ns, setpoint_ps);
   positionNS_setPointPM->joinWithAND(position_ns, setpoint_pm);

-  FuzzyRule* Rule10 = new FuzzyRule(10, positionNS_setPointNM, then_thetaZO);
-  FuzzyRule* Rule11 = new FuzzyRule(11, positionNS_setPointZO, then_thetaNS);
-  FuzzyRule* Rule12 = new FuzzyRule(12, positionNS_setPointPS, then_thetaZO);
-  FuzzyRule* Rule13 = new FuzzyRule(13, positionNS_setPointPM, then_thetaNS);
-
-  FuzzyRuleAntecedent* positionZO_setPointNM = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionZO_setPointNS = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionZO_setPointPS = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionZO_setPointPM = new FuzzyRuleAntecedent();
-
-  positionZO_setPointNM->joinWithAND(position_zo, setpoint_nm);
-  positionZO_setPointNS->joinWithAND(position_zo, setpoint_ns);
-  positionZO_setPointPS->joinWithAND(position_zo, setpoint_ps);
-  positionZO_setPointPM->joinWithAND(position_zo, setpoint_pm);
-
-  FuzzyRule* Rule14 = new FuzzyRule(14, positionZO_setPointNM, then_thetaPS);
-  FuzzyRule* Rule15 = new FuzzyRule(15, positionZO_setPointNS, then_thetaPS);//PM
-  FuzzyRule* Rule16 = new FuzzyRule(16, positionZO_setPointPS, then_thetaNS);
-  FuzzyRule* Rule17 = new FuzzyRule(17, positionZO_setPointPM, then_thetaZO);
-
-  FuzzyRuleAntecedent* positionPS_setPointNM = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionPS_setPointNS = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionPS_setPointZO = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionPS_setPointPM = new FuzzyRuleAntecedent();
-
-  positionPS_setPointNM->joinWithAND(position_ps, setpoint_nm);
-  positionPS_setPointNS->joinWithAND(position_ps, setpoint_ns);
-  positionPS_setPointZO->joinWithAND(position_ps, setpoint_zo);
-  positionPS_setPointPM->joinWithAND(position_ps, setpoint_pm);
-
-  FuzzyRule* Rule18 = new FuzzyRule(18, positionPS_setPointNM, then_thetaPM);
-  FuzzyRule* Rule19 = new FuzzyRule(19, positionPS_setPointNS, then_thetaPS);
-  FuzzyRule* Rule20 = new FuzzyRule(20, positionPS_setPointZO, then_thetaPS);
-  FuzzyRule* Rule21 = new FuzzyRule(21, positionPS_setPointPM, then_thetaZO);
-
-  FuzzyRuleAntecedent* positionPM_setPointNM = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionPM_setPointNS = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionPM_setPointZO = new FuzzyRuleAntecedent();
-  FuzzyRuleAntecedent* positionPM_setPointPS = new FuzzyRuleAntecedent();
+  FuzzyRule* Rule6 = new FuzzyRule(6, positionNS_setPointNS, then_thetaZO);
+  FuzzyRule* Rule7 = new FuzzyRule(7, positionNS_setPointNM, then_thetaZO);
+  FuzzyRule* Rule8 = new FuzzyRule(8, positionNS_setPointZO, then_thetaNS);
+  FuzzyRule* Rule9 = new FuzzyRule(9, positionNS_setPointPS, then_thetaZO);
+  FuzzyRule* Rule10 = new FuzzyRule(10, positionNS_setPointPM, then_thetaNS);

-  positionPM_setPointNM->joinWithAND(position_pm, setpoint_nm);
-  positionPM_setPointNS->joinWithAND(position_pm, setpoint_ns);
-  positionPM_setPointZO->joinWithAND(position_pm, setpoint_zo);
-  positionPM_setPointPS->joinWithAND(position_pm, setpoint_ps);
-
-  FuzzyRule* Rule22 = new FuzzyRule(22, positionPM_setPointNM, then_thetaPM);
-  FuzzyRule* Rule23 = new FuzzyRule(23, positionPM_setPointNS, then_thetaPM);
-  FuzzyRule* Rule24 = new FuzzyRule(24, positionPM_setPointZO, then_thetaPS);
-  FuzzyRule* Rule25 = new FuzzyRule(25, positionPM_setPointPS, then_thetaZO);
-
-  fuzzyObj->addFuzzyRule(Rule1);
-  fuzzyObj->addFuzzyRule(Rule2);
-  fuzzyObj->addFuzzyRule(Rule3);
-  fuzzyObj->addFuzzyRule(Rule4);
-  fuzzyObj->addFuzzyRule(Rule5);
   fuzzyObj->addFuzzyRule(Rule6);
   fuzzyObj->addFuzzyRule(Rule7);
   fuzzyObj->addFuzzyRule(Rule8);
   fuzzyObj->addFuzzyRule(Rule9);
   fuzzyObj->addFuzzyRule(Rule10);

+  // Position ZO
+  FuzzyRuleAntecedent* positionZO_setPointZO = new FuzzyRuleAntecedent();
+  FuzzyRuleAntecedent* positionZO_setPointNM = new FuzzyRuleAntecedent();
+  FuzzyRuleAntecedent* positionZO_setPointNS = new FuzzyRuleAntecedent();
+  FuzzyRuleAntecedent* positionZO_setPointPS = new FuzzyRuleAntecedent();
+  FuzzyRuleAntecedent* positionZO_setPointPM = new FuzzyRuleAntecedent();
+
+  positionZO_setPointZO->joinWithAND(position_zo, setpoint_zo);
+  positionZO_setPointNM->joinWithAND(position_zo, setpoint_nm);
+  positionZO_setPointNS->joinWithAND(position_zo, setpoint_ns);
+  positionZO_setPointPS->joinWithAND(position_zo, setpoint_ps);
+  positionZO_setPointPM->joinWithAND(position_zo, setpoint_pm);
+
+  FuzzyRule* Rule11 = new FuzzyRule(11, positionZO_setPointZO, then_thetaZO);
+  FuzzyRule* Rule12 = new FuzzyRule(12, positionZO_setPointNM, then_thetaPS);
+  FuzzyRule* Rule13 = new FuzzyRule(13, positionZO_setPointNS, then_thetaPS);//PM
+  FuzzyRule* Rule14 = new FuzzyRule(14, positionZO_setPointPS, then_thetaNS);
+  FuzzyRule* Rule15 = new FuzzyRule(15, positionZO_setPointPM, then_thetaZO);
+
   fuzzyObj->addFuzzyRule(Rule11);
   fuzzyObj->addFuzzyRule(Rule12);
   fuzzyObj->addFuzzyRule(Rule13);
   fuzzyObj->addFuzzyRule(Rule14);
   fuzzyObj->addFuzzyRule(Rule15);
+
+  // Position PS
+  FuzzyRuleAntecedent* positionPS_setPointPS = new FuzzyRuleAntecedent();
+  FuzzyRuleAntecedent* positionPS_setPointNM = new FuzzyRuleAntecedent();
+  FuzzyRuleAntecedent* positionPS_setPointNS = new FuzzyRuleAntecedent();
+  FuzzyRuleAntecedent* positionPS_setPointZO = new FuzzyRuleAntecedent();
+  FuzzyRuleAntecedent* positionPS_setPointPM = new FuzzyRuleAntecedent();
+
+  positionPS_setPointPS->joinWithAND(position_ps, setpoint_ps);
+  positionPS_setPointNM->joinWithAND(position_ps, setpoint_nm);
+  positionPS_setPointNS->joinWithAND(position_ps, setpoint_ns);
+  positionPS_setPointZO->joinWithAND(position_ps, setpoint_zo);
+  positionPS_setPointPM->joinWithAND(position_ps, setpoint_pm);
+
+  FuzzyRule* Rule16 = new FuzzyRule(16, positionPS_setPointPS, then_thetaZO);
+  FuzzyRule* Rule17 = new FuzzyRule(17, positionPS_setPointNM, then_thetaPM);
+  FuzzyRule* Rule18 = new FuzzyRule(18, positionPS_setPointNS, then_thetaPS);
+  FuzzyRule* Rule19 = new FuzzyRule(19, positionPS_setPointZO, then_thetaPS);
+  FuzzyRule* Rule20 = new FuzzyRule(20, positionPS_setPointPM, then_thetaZO);
+
   fuzzyObj->addFuzzyRule(Rule16);
   fuzzyObj->addFuzzyRule(Rule17);
   fuzzyObj->addFuzzyRule(Rule18);
   fuzzyObj->addFuzzyRule(Rule19);
   fuzzyObj->addFuzzyRule(Rule20);

+  // Position PM
+  FuzzyRuleAntecedent* positionPM_setPointPM = new FuzzyRuleAntecedent();
+  FuzzyRuleAntecedent* positionPM_setPointNM = new FuzzyRuleAntecedent();
+  FuzzyRuleAntecedent* positionPM_setPointNS = new FuzzyRuleAntecedent();
+  FuzzyRuleAntecedent* positionPM_setPointZO = new FuzzyRuleAntecedent();
+  FuzzyRuleAntecedent* positionPM_setPointPS = new FuzzyRuleAntecedent();
+
+  positionPM_setPointPM->joinWithAND(position_pm, setpoint_pm);
+  positionPM_setPointNM->joinWithAND(position_pm, setpoint_nm);
+  positionPM_setPointNS->joinWithAND(position_pm, setpoint_ns);
+  positionPM_setPointZO->joinWithAND(position_pm, setpoint_zo);
+  positionPM_setPointPS->joinWithAND(position_pm, setpoint_ps);
+
+  FuzzyRule* Rule21 = new FuzzyRule(21, positionPM_setPointPM, then_thetaZO);
+  FuzzyRule* Rule22 = new FuzzyRule(22, positionPM_setPointNM, then_thetaPM);
+  FuzzyRule* Rule23 = new FuzzyRule(23, positionPM_setPointNS, then_thetaPM);
+  FuzzyRule* Rule24 = new FuzzyRule(24, positionPM_setPointZO, then_thetaPS);
+  FuzzyRule* Rule25 = new FuzzyRule(25, positionPM_setPointPS, then_thetaZO);
+
   fuzzyObj->addFuzzyRule(Rule21);
   fuzzyObj->addFuzzyRule(Rule22);
   fuzzyObj->addFuzzyRule(Rule23);
   fuzzyObj->addFuzzyRule(Rule24);
   fuzzyObj->addFuzzyRule(Rule25);
-
 }
-


Do not touch onboard flash

Do not touch onboard flash


added rest, no click

added rest, no click

added level array and level counter
added rest(no clicking of either) and it works!
now to implement level incrementing

--- game_one/game_one.ino
+++ game_one/game_one.ino
@@ -13,7 +13,8 @@
 const int touch_pin = 4;
 const int buzz_pin = 8;
 const char blank_writer[17] = "                ";
-int rxn_time = 30;//time to react, decreases as levels go up
+int level = 0;
+const int rxn_time[6] = {30, 29, 27, 24, 19};//time to react, decreases as levels go up

 int button_state = 0;
 int touch_state = 0;
@@ -21,8 +22,8 @@
 int button_count = 0;
 int hold_time = 0;

-const unsigned int map_0[] = {0,1,0,0,1,0,1,1,1,0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-const unsigned int map_1[] = {1,0,1,1,0,1,1,1,0,1,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+const unsigned int map_0[] = {0,0,1,0,0,1,0,1,1,1,0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+const unsigned int map_1[] = {1,0,0,1,1,0,1,1,1,0,1,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
 unsigned int ptr0 = 0;
 unsigned int ptr1 = 0;
 unsigned int ptr_max = 16; //when pointer gets to index 15 we know that is the last part of map
@@ -157,7 +158,7 @@
     lcd.print(blank_writer);
     while(true){}
   }
-  if(loop_count>=rxn_time && !good)//lost
+  if(loop_count>=rxn_time[level] && !good)//lost
   {
     lcd.setCursor(0,0);
     lcd.print(blank_writer);
@@ -170,7 +171,7 @@
     lcd.print("TRY AGAIN");
     while(true){}
   }
-  else if(loop_count>=rxn_time && good)//continue
+  else if(loop_count>=rxn_time[level] && good)//continue
   {
     ++ptr0;
     ++ptr1;


custom bar range

custom bar range

--- display_afr/display_afr.ino
+++ display_afr/display_afr.ino
@@ -82,7 +82,7 @@
 }

 void loop() {
-  double afr = 13.5;
+  double afr = 12.5;
   double tgt = 14.7;

   lcd.setCursor(4, 0);
@@ -92,13 +92,16 @@

   //lcd.setCursor(16,0);
   //lcd.print("Rich");
-  draw_afr_bar(afr, 1);
-  draw_afr_bar(tgt, 3);
+  draw_bar(afr, 1, 10, 20);
+  draw_bar(tgt, 3, 10, 20);
 }

-void draw_afr_bar(double value, int row) {
+void draw_bar(double value, int row, double minimum, double maximum) {
   lcd.setCursor(0, row);
-  int bars = round((value - 10.0) / 10.0 * 100);
+  //int bars = round((value - 10.0) / 10.0 * 100);
+
+  int bars = ((value - minimum) * 100) / (maximum - minimum);
+
   int fullBars = bars/5;

   int partialBars = bars % 5;


Refactored duplicate handling of errors in climate sensors for water meter module

--- projects/WaterMain/Arduino/Arduino.ino
+++ projects/WaterMain/Arduino/Arduino.ino
@@ -33,24 +33,9 @@
       sprintf(buf, "%lu", meter.getCounter());
       net.sendResponse(buf);
     } else if (net.assertCommand("getTemp")) {
-//      int chk = tempSensor.read(9);
-//      sprintf(buf, "%d, %d, %d", chk, tempSensor.temperature, tempSensor.humidity);
-//      net.sendResponse(buf);
-      if (dhtData.chk == DHTLIB_OK) {
-        sprintf(buf, "%d", dhtData.temp);
-        net.sendResponse(buf);
-      } else{
-        sprintf(buf, "ERROR: %d", dhtData.chk);
-        net.sendResponse(buf);
-      }
+      sendClimateResponse(dhtData.temp);
     } else if (net.assertCommand("getHumidity")) {
-      if (dhtData.chk == DHTLIB_OK) {
-        sprintf(buf, "%d", dhtData.humidity);
-        net.sendResponse(buf);
-      } else{
-        sprintf(buf, "ERROR: %d", dhtData.chk);
-        net.sendResponse(buf);
-      }
+      sendClimateResponse(dhtData.humidity);
     }  else if (net.assertCommand("valveClose")) {
       valveClose();
       net.sendResponse("OK");
@@ -65,6 +50,17 @@
   meter.reading(analogRead(METER_SENSOR_PIN));
   if (millis() - dhtData.lastReadTime > TEMP_READ_INTERVAL) {
     readTemp();
+  }
+}
+
+void sendClimateResponse(int data)
+{
+  if (dhtData.chk == DHTLIB_OK) {
+    sprintf(buf, "%d", data);
+    net.sendResponse(buf);
+  } else{
+    sprintf(buf, "ERROR: %d", dhtData.chk);
+    net.sendResponse(buf);
   }
 }


New pattern allAtOnce

New pattern allAtOnce

--- Patterns.ino
+++ Patterns.ino
@@ -91,7 +91,6 @@
     delay(milli);
   }
 }
-

 /**
 * @author Touzard Loïc loic.touzard@gmail.com
@@ -158,6 +157,23 @@
   }
 }

+/**
+* Display all leds at once
+*/
+void allAtOnce() {
+  // The total quantity of LEDS
+  int LEDSnum = LEDS_PER_ROW * LEDS_PER_ROW * LEDS_PER_ROW;
+  // The number of fps required "frame per second"
+  int fps = 30;
+  // The delta between 2 LED display to fit the fps requirements (in micro-second)
+  int deltaLED = 1000000. * LEDSnum / fps;
+  for (int i = 0; i < (LEDSnum); ++i)
+  {
+    displayNum(i);
+    delayMicroseconds(deltaLED);
+  }
+}
+
 void LeapDraw()  {
     for(int i=0;i<20; i++)  {
     if(coloring[i]==0)


Updated node ID variable

Updated node ID variable

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -214,7 +214,7 @@

   // create datapacket by combining all character arrays into a large character array
   strcat(dataPacket, "i:");
-  strcat(dataPacket, node);
+  strcat(dataPacket, NODEID);
   strcat(dataPacket, ",t:");
   strcat(dataPacket, _t);
   strcat(dataPacket, ",h:");


scr_arduino update

scr_arduino update

--- sketchbook/scr_arduino/scr_arduino.ino
+++ sketchbook/scr_arduino/scr_arduino.ino
@@ -1,40 +1,51 @@
 /*
- * ros
- * Prints "hello world!"
+ * Squad Collaborative Robotics
+ * Prototype Embedded Collector Bot Code
  */

 #include <ros.h>
 #include <std_msgs/Int32.h>
-#include <scr_proto/DiffCommand.h>
+//#include <PololuQik.h>
+//#include <SoftwareSerial.h>

-// Placeholders for
+// Placeholders for motor commands
 int lm_cmd = 0;
 int rm_cmd = 0;

-void (const std_msgs::Int32& diff_msg){
-  lm = diff_msg.data;
+// Motor Callbacks
+void leftMotorCallback(const std_msgs::Int32& lm_msg){
+  lm_cmd = lm_msg.data;
+}
+
+void rightMotorCallback(const std_msgs::Int32& rm_msg){
+  rm_cmd = rm_msg.data;
 }

 ros::NodeHandle  nh;
+std_msgs::Int32 int_msg;
+ros::Subscriber<std_msgs::Int32> leftMotorSub("left_motor", leftMotorCallback);
+ros::Subscriber<std_msgs::Int32> rightMotorSub("right_motor", rightMotorCallback);

-std_msgs::Int32 int_msg;
-ros::Publisher chatter("chatter", &int_msg);
-ros::Subscriber<std_msgs::Int32> DiffSub("motor_com", diffCb);
-
-
+// Rx, Tx, Reset Pins
+//PololuQik2s12v10 pmd(2, 3, 4);

 void setup()
 {
+  // ROS Stuff
   nh.initNode();
-  nh.advertise(chatter);
-  nh.subscribe(DiffSub);
+  nh.subscribe(leftMotorSub);
+  nh.subscribe(rightMotorSub);
+
+  // Motor Driver Init
+  //pmd.init();
 }

 void loop()
 {
-  int_msg.data = lm;
+  int_msg.data = lm_cmd;
   chatter.publish( &int_msg );
   nh.spinOnce();
-  delay(10);
+  //pmd.setSpeeds(lm_cmd, rm_cmd);
+  delay(5);
 }


start work on handling simultaneous animations

--- tests/Light/ButtonTest/ButtonTest.ino
+++ tests/Light/ButtonTest/ButtonTest.ino
@@ -1,4 +1,3 @@
-
 #include <Adafruit_GFX.h>
 #include <Adafruit_NeoPixel.h>
 #include <Adafruit_NeoMatrix.h>
@@ -41,59 +40,114 @@
     //strip.show(); // Initialize all pixels to 'off'
     redL.begin();
     redL.show();
-    grnL.begin();
+    /*grnL.begin();
     grnL.show();
     bluL.begin();
     bluL.show();
     yelL.begin();
     yelL.show();
-
+    */
+
+    setStripColor(redL, RED_MAX, GRN_MAX, BLU_MAX);
+}
+
+void setStripColor(Adafruit_NeoPixel &strip, int r, int g, int b) {
+    for (int i = 0; i < strip.numPixels(); i++) {
+        strip.setPixelColor(i, strip.Color(r, g, b));
+        strip.show();
+    }
 }

 void loop() {
-
-    colorWipe(redL, redL.Color(127, 0, 0), 20);
-    colorWipe(redL, redL.Color(127, 127, 0), 20);
-    colorWipe(grnL, Blu, 20);
-    colorWipe(grnL, Yel, 20);
-    colorWipe(yelL, Red, 20);
-    colorWipe(yelL, Grn, 20);
-    colorWipe(bluL, Blu, 20);
-    colorWipe(bluL, Yel, 20);
-    // Some example procedures showing how to display to the pixels:
-    colorWipeMatrix(rimJob, Yel, 1); // Blue
-    colorWipeMatrix(rimJob, Grn, 1); // Green
-    /*colorWipeMatrix(rimJob, Red, 1); // Red
-    colorWipeMatrix(rimJob, Blu, 1); // Blue
-    */
-
-    // Send a theater pixel chase in...
+    bool rimReady = true;
+    bool btnReady = true;
+    if (stripUpdateInterval.check()) {
+
     /*
-    theaterChase(strip.Color(127, 127, 127), 50); // White
-    theaterChase(strip.Color(127,   0,   0), 50); // Red
-    theaterChase(strip.Color(  0,   0, 127), 50); // Blue
-
-    rainbow(20);
-    rainbowCycle(20);
-    theaterChaseRainbow(50);
-    */
-}
+        colorWipe(redL, RED_MAX, GRN_MAX, LED_OFF, 10);
+        setStripColor(redL, RED_MAX, LED_OFF, LED_OFF);
+        colorWipe(redL, redL.Color(127, 127, 0), 20);
+        */
+    /*    colorWipe(grnL, Blu, 20);
+        colorWipe(grnL, Yel, 20);
+        colorWipe(yelL, Red, 20);
+        colorWipe(yelL, Grn, 20);
+        colorWipe(bluL, Blu, 20);
+        colorWipe(bluL, Yel, 20);
+        */
+        // Some example procedures showing how to display to the pixels:
+        /*colorWipeMatrix(rimJob, Grn, 1); // Green
+        colorWipeMatrix(rimJob, Yel, 1); // Blue
+        colorWipeMatrix(rimJob, Red, 1); // Red
+        colorWipeMatrix(rimJob, Blu, 1); // Blue
+        */
+
+        // Send a theater pixel chase in...
+        /*
+        theaterChase(strip.Color(127, 127, 127), 50); // White
+        theaterChase(strip.Color(127,   0,   0), 50); // Red
+        theaterChase(strip.Color(  0,   0, 127), 50); // Blue
+
+        rainbow(20);
+        rainbowCycle(20);
+        theaterChaseRainbow(50);
+        */
+
+        calculateAnimation();
+        push(strip, rimReady);
+        push(strip,
+        stripUpdateInterval.reset();
+    }
+}
+
+void push(Adafruit_NeoPixel &strip, bool &ready) {
+    static Metro timer(wait);
+    if (!timer.check()) return;
+    strip.show();
+    ready = true;
+}
+
+void calculateAnimation(void (*animate)(&strip, int r, int g, int b, uint8_t wait), bool &ready) {
+    if (!ready) return;
+    animate(strip, r, g, b, wait);
+    ready = false;
+}
+
 void colorWipeMatrix(Adafruit_NeoMatrix &matrix, uint32_t c, uint8_t wait) {
     for (uint16_t x = 0; x < matrix.width(); x++) {
-        matrix.drawPixel(x, 0, c);
-        matrix.drawPixel(x, 1, c);
-        matrix.drawPixel(x, 2, c);
-        matrix.show();
-        delay(wait);
+        if (timer.check()) {
+            matrix.drawPixel(x, 0, c);
+            matrix.drawPixel(x, 1, c);
+            matrix.drawPixel(x, 2, c);
+            matrix.show();
+            timer.reset();
+        }
     }
 }

 // Fill the dots one after the other with a color
-void colorWipe(Adafruit_NeoPixel &button, uint8_t c, uint8_t wait) {
+void colorWipe(Adafruit_NeoPixel &button, int r, int g, int b, uint8_t wait) {
+    Metro timer(wait);
     for (uint16_t i = 0; i < button.numPixels(); i++) {
-        button.setPixelColor(i, c);
-        button.show();
-        delay(wait);
+        if (timer.check()) {
+            button.setPixelColor(i, button.Color(r, g, b));
+            button.show();
+            timer.reset();
+        }
+    }
+}
+
+// color wipes the last 8 pixels
+void laserWipe(Adafruit_NeoPixel &button, int r, int g, int b, uint8_t wait, int times = 3) {
+    int currTimes = 0;
+
+    while (currTimes < times) {
+        for (uint16_t i = 0; i < button.numPixels(); i++) {
+            button.setPixelColor(i, button.Color(r, g, b));
+            button.show();
+            delay(wait);
+        }
+        times++;
     }
 }


Finish setup logic for sdcard

Finish setup logic for sdcard

--- payload/payload.ino
+++ payload/payload.ino
@@ -1,28 +1,32 @@
 #include <Wire.h>
-
-// SD card libraries
-#include <BlockDriver.h>
-//#include <FreeStack.h>
-#include <MinimumSerial.h>
-#include <SdFat.h>
-#include <SdFatConfig.h>
-#include <SysCall.h>

 // RCR headers
 #include "Setupable.h"
 #include "Bmp180.h"
+#include "sdcard.h"
+
+SdFatSdio sd_card; // SD card manager
+File file; // file manager

 // To shorten RCR namespace, use namespace alias "custom".
 namespace custom = rcr::level1payload;

 custom::Bmp180 bmp;
-File file; // file object
-SdFatSdio sd_card; // MicroSD card

 // Array of pointers to Setupable-implementing objects which require
 // initialization logic to take place in setup() function.
 // For more info, see "setupable.h".
 custom::Setupable* setupables[] = { &bmp };
+
+// Setup MicroSD card I/O. Trap the thread if no card is found.
+void setup_sd_card(void) {
+  if (!sd_card.begin()) {
+    Serial.println("ERROR: SD card could not be found.");
+    while (1) { /* Trap the thread. */ }
+  }
+  Serial.println("SdCard successfully setup.");
+  Serial.println();
+}

 void setup() {
   // Illuminate LED.
@@ -44,13 +48,8 @@
   Serial.println();
   delay(512);

-  // Setup MicroSD card I/O.
-  if(!sd_card.begin()) {
-    Serial.println("ERROR: SD card could not be found.");
-  }
-  else {
-    Serial.println("SD card ready.");
-  }
+  // Setup objects and verify working condition.
+  setup_sd_card();

   // Setup() the custom data structures.
   for (custom::Setupable* obj : setupables) {
@@ -63,7 +62,7 @@
 }

 void write_to_sd(void) {
-  auto log_path = "nolan-tests\\nolan-test.log";
+  auto log_path = "nolan-test.log";
   sd_card.remove(log_path); // remove file from last time.

   File file = sd_card.open(log_path, FILE_WRITE); // Open a new file for writing.


Updates millis_adjust to apply per-million instead of per-thousand (watch)

--- watch.ino
+++ watch.ino
@@ -16,16 +16,21 @@
   // watch_tick returns.
   uint8_t needs_redraw;

-  // this is the number of milliseconds to add to
-  // the standard 1000 when calculating when to increment
-  // seconds. If the watch keeps perfect time, this value would be 0.
+  // This is a milli-second correction that is applied every 1000
+  // seconds, which means it is a part-per-million correction.
   //
-  // If the watch is running too quick, then make this value positive to slow it
-  // down.
+  // If the watch is running fast, then we want to make this positive.
   //
-  // If the watch is running too slow, then make this value negative to speed it
-  // up.
+  // If the watch is running slow, then we want to make this negative.
+  //
+  // If the watch is exactly on time, then it shuold be 0.
   millis_delta_t millis_adjust;
+
+  // number of seconds since we last applied millis_adjust.
+  uint16_t seconds_since_last_adjust;
+
+  uint8_t color;
+
 } Watch_t;

 uint8_t _watch_days_per_month[] = {
@@ -48,6 +53,7 @@
 void watch_init(millis_t now) {
   Watch.next_second_millis = now;
   Watch.needs_redraw = 1;
+  Watch.color = WATCH_COLOR;
 }

 /**
@@ -135,7 +141,17 @@
   millis_delta_t elapsed = now - W.next_second_millis;

   if (elapsed > 0) {
-    W.next_second_millis += 1000 + W.millis_adjust;
+    W.next_second_millis += 1000;
+    W.seconds_since_last_adjust += 1;
+
+    // apply millis_adjust every 1,000,000 milliseconds
+    if (W.seconds_since_last_adjust >= 1000) {
+      W.next_second_millis += W.millis_adjust;
+      W.seconds_since_last_adjust = 0;
+
+      if (W.color == COLOR_BLUE) W.color = COLOR_RED;
+      else W.color = COLOR_BLUE;
+    }

     uint8_t changes = 1;

@@ -181,6 +197,7 @@
   Watch.minutes = minutes;
   Watch.hours = hours;
   Watch.millis_adjust = millis_adjust;
+  Watch.seconds_since_last_adjust = 0;
   Watch.needs_redraw = 1;
 }


Correcao de bug na tempestade

Correcao de bug na tempestade


Sket modificado

Sket modificado

fix

--- Arduino/MQTT_Test_Panel.ino
+++ Arduino/MQTT_Test_Panel.ino
@@ -24,7 +24,7 @@
   byte* p = (byte*)malloc(length);
   // Copy the payload to the new buffer
   memcpy(p,payload,length);
-  Serial.println("tu vieja");
+  Serial.println("Mensaje Recibido");
   // Free the memory
   free(p);
 }


Minor variable rename.

Minor variable rename.

--- project/project.ino
+++ project/project.ino
@@ -89,13 +89,13 @@

 // The program is modeled as a finite state machine. This timer tracks the time in
 //  millis the program is in the current state.
-static PassiveTimer time_in_state;
+static PassiveTimer time_in_current_state;

 // Utility function to initialize a new state.
 // TODO: why making the arg State instead of int does not compile?
 void enterState(int state) {
   current_state = (State) state;
-  time_in_state.restart();
+  time_in_current_state.restart();
   led_pattern = 0x00000000;
 }

@@ -138,7 +138,7 @@
 }

 void StateIsLongPress::handle() {
-  const int t = time_in_state.time_millis();
+  const int t = time_in_current_state.time_millis();

   // Handle the case were decouncing has not stabalized yet.
   if (!io_button.hasStableValue()) {
@@ -191,7 +191,7 @@
 }

 void StatePressTargetButton::handle() {
-  const int t = time_in_state.time_millis();
+  const int t = time_in_current_state.time_millis();

   // TODO: make these numbers consts.
   //
@@ -251,7 +251,7 @@
   io_button.updateDebouncer();

   // Update diagnostic based on pattern and time in state.
-  diagnostics_led.setForPattern(time_in_state.time_millis(), led_pattern);
+  diagnostics_led.setForPattern(time_in_current_state.time_millis(), led_pattern);

   // Service current state.
   switch (current_state) {


allows us to jumper

allows us to jumper

--- src/sketch.ino
+++ src/sketch.ino
@@ -11,6 +11,8 @@
   pinMode(PINA, INPUT);
   pinMode(PINB, INPUT);
   pinMode(ADDRESS_PIN, INPUT);
+  pinMode(12,OUTPUT);
+  digitalWrite(12,HIGH); //so we can jumper over to pin 12
   pinMode(VICTOR_PIN, OUTPUT);
   victor.attach(VICTOR_PIN);
   victor.writeMicroseconds(1510);


offset is not unsigned int anymore

offset is not unsigned int anymore

--- examples/sensors/gyroscope/gyroscopeCalibration/gyroscopeCalibration.ino
+++ examples/sensors/gyroscope/gyroscopeCalibration/gyroscopeCalibration.ino
@@ -10,7 +10,7 @@
   delay(1500);
   gyro.begin();
   Serial.println("Calibrating gyroscope, this might take some seconds");
-  unsigned int offset = gyro.calibrate();
+  int offset = gyro.calibrate();
   Serial.print("This gyro's offset value is: ");
   Serial.println(offset);
   Serial.print("Please initialize Gyroscope with the above value as: Gyroscope gyro(");


added basic wifi connection to orchard to the LO_mpr121_and_fastLED_test_cz.ino

--- firmware/LO_mpr121_and_fastLED_test_cz/LO_mpr121_and_fastLED_test_cz.ino
+++ firmware/LO_mpr121_and_fastLED_test_cz/LO_mpr121_and_fastLED_test_cz.ino
@@ -1,9 +1,10 @@
 #include <FastLED.h>
 #include <MPR121.h>
 #include <Wire.h>
+#include <ESP8266WiFi.h>

 #define LED_DATA_PIN 4
-#define baudRate 57600
+#define baudRate 115200
 #define LED_TYPE    WS2811
 #define LED_COLOR_ORDER GRB
 #define LED_COUNT    45
@@ -33,7 +34,9 @@
 int cap_threshold = 2;
 int cap_sum = 0;

-
+const char* wifi_ssid     = "Orchard";
+const char* wifi_pass = "";
+const char* server_ip = "192.168.0.100";

 void capSenseLEDUpdate() {
   for (int i = 0; i < LED_SEGMENT_COUNT; i++) {
@@ -111,6 +114,16 @@

 void setup() {
   Serial.begin(baudRate);
+  Serial.setDebugOutput(true);
+  Serial.println("Booting up");
+
+  WiFi.mode(WIFI_OFF);
+  WiFi.disconnect(); //in version 2.3.0 of ESP8266 library, can't WiFi.begin if already connected or more than 1 second of delay
+  delay(100);
+  WiFi.mode(WIFI_STA);
+  WiFi.setAutoConnect(true);
+  WiFi.setAutoReconnect(true);
+  WiFi.begin(wifi_ssid, wifi_pass);

   pinMode(PIN_SDA, OUTPUT);
   pinMode(PIN_SCL, OUTPUT);


Fix compile error

Fix compile error

--- examples/WeatherStationDemoExtendedDST/WeatherStationDemoExtendedDST.ino
+++ examples/WeatherStationDemoExtendedDST/WeatherStationDemoExtendedDST.ino
@@ -53,6 +53,7 @@
 #include <DNSServer.h>
 #include <ESP8266WebServer.h>
 #include <WiFiManager.h>
+#include <Adafruit_Sensor.h>

 #include "WundergroundClient.h"
 #include "WeatherStationFonts.h"


Uncommented, removed comments

Uncommented, removed comments

--- Hello_arm/Hello_arm.ino
+++ Hello_arm/Hello_arm.ino
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // How to run it: upload to arduino with the dynamixel_serial library installed in your arduino libraries folder.             //
 //                After upload, disconnect usb from arduino and add power to CrustCrawler and the arduino board.              //
-//                The program should start by it self. :)                                                                     //
+//                The program should start by it self. :)
 //                                                                                //
 //                PIN Setup:  Green wire to PIN 10,                                                                           //
 //                            Yellow wire to PIN 11,                                                                          //
@@ -45,24 +45,19 @@

   // Set the Profile acceleration.
   Dynamixel.setProfileAcceleration(0x01, 10);  //Set the Profile Acceleration for each servo. (max. is 32767)
-  Dynamixel.setProfileAcceleration(0x02, 10);  //Set the Profile Acceleration for each servo. (max. is 32767)
-  Dynamixel.setProfileAcceleration(0x03, 10);  //Set the Profile Acceleration for each servo. (max. is 32767)
-  /*
-  Dynamixel.setProfileAcceleration(0x04, 300);  //Set the Profile Acceleration for each servo. (max. is 32767)
-  Dynamixel.setProfileAcceleration(0x05, 300);  //Set the Profile Acceleration for each servo. (max. is 32767)
-  */
+  Dynamixel.setProfileAcceleration(0x02, 10);
+  Dynamixel.setProfileAcceleration(0x03, 10);
+  Dynamixel.setProfileAcceleration(0x04, 300);
+  Dynamixel.setProfileAcceleration(0x05, 300);

   // Set the Profile velocity.
   Dynamixel.setProfileVelocity(0x01, 100);  //Set the Profile Velocity for each servo. (max. is 1023)
   Dynamixel.setProfileVelocity(0x02, 100);  //Set the Profile Velocity for each servo. (max. is 1023)
   Dynamixel.setProfileVelocity(0x03, 100);  //Set the Profile Velocity for each servo. (max. is 1023)
-  /*
   Dynamixel.setProfileVelocity(0x04, 200);  //Set the Profile Velocity for each servo. (max. is 1023)
   Dynamixel.setProfileVelocity(0x05, 200);  //Set the Profile Velocity for each servo. (max. is 1023)
-  */

-  /*
   //Get position for servos in steps
   Dynamixel.getPosition(0x01);
   Dynamixel.getPosition(0x02);
@@ -87,7 +82,7 @@
     Serial.println(data[i]);
   }

-  */
+
 }

@@ -96,8 +91,8 @@
   int id1 = 2071; //Servo 1 goal position
   int id2 = 2048; //Servo 2 goal position
   int id3 = 2048; //Servo 3 goal position
-  //int id4 = 2548; //Servo 4 goal position
-  //int id5 = 1548; //Servo 5 goal position
+  int id4 = 2548; //Servo 4 goal position
+  int id5 = 1548; //Servo 5 goal position

  Dynamixel.setNGoalPositions(-1, id2, id3, -1, -1);  //Set goal position of all the servos


Moved pano status into displayPanoStatus()

--- gigapanplus.ino
+++ gigapanplus.ino
@@ -70,6 +70,36 @@
     display.display();
 }

+void displayPanoStatus(void){
+    display.clearDisplay();
+    display.setCursor(0,0);
+    display.print(F("Focal Length "));
+    display.print(focal);
+    display.println(F("mm"));
+    display.print(F("Lens FOV "));
+    display.print(camera.getHorizFOV());
+    display.print(F(" x "));
+    display.println(camera.getVertFOV());
+    display.print(F("Pano FOV "));
+    display.print(horiz);
+    display.print(F(" x "));
+    display.println(vert);
+    display.print(F("Grid "));
+    display.print(pano.getHorizShots());
+    display.print(F(" x "));
+    display.println(pano.getVertShots());
+    display.println();
+    display.print(F("Position = "));
+    display.print(pano.position+1);
+    display.print(F(" / "));
+    display.println(pano.getHorizShots()*pano.getVertShots());
+    display.print(F("Bearing "));
+    display.print(pano.horiz_position);
+    display.print(F(" x "));
+    display.println(pano.vert_position);
+    display.display();
+}
+
 void handleEvent(int event) {

     if (Joystick::isEventLeft(event)) menu.cancel();
@@ -103,20 +133,10 @@
                 motors_enable = true;
                 menu.sync();

-                display.clearDisplay();
-                display.setCursor(0,0);
-                display.print(F("Start "));
-                display.display();
-
                 pano.setFocalLength(focal);
                 pano.setFOV(horiz, vert);
                 pano.setShutter(shutter, pre_shutter);
                 pano.setShots(shots);
-
-                display.clearDisplay();
-                display.setCursor(0,0);
-
-                display.display();

                 stop_running = false;
                 attachInterrupt(digitalPinToInterrupt(JOYSTICK_SW), button_click, FALLING);
@@ -125,34 +145,7 @@
             }
         }
     } else {   // pano is in progress
-        display.clearDisplay();
-        display.setCursor(0,0);
-        display.print(F("Focal Length "));
-        display.print(focal);
-        display.println(F("mm"));
-        display.print(F("Lens FOV "));
-        display.print(camera.getHorizFOV());
-        display.print(F(" x "));
-        display.println(camera.getVertFOV());
-        display.print(F("Pano FOV "));
-        display.print(horiz);
-        display.print(F(" x "));
-        display.println(vert);
-        display.print(F("Grid "));
-        display.print(pano.getHorizShots());
-        display.print(F(" x "));
-        display.println(pano.getVertShots());
-        display.println();
-        display.print(F("Position = "));
-        display.print(pano.position+1);
-        display.print(F(" / "));
-        display.println(pano.getHorizShots()*pano.getVertShots());
-        display.print(F("Bearing "));
-        display.print(pano.horiz_position);
-        display.print(F(" x "));
-        display.println(pano.vert_position);
-        display.display();
-
+        displayPanoStatus();
         running = pano.next();
         if (stop_running || !running){
             detachInterrupt(digitalPinToInterrupt(JOYSTICK_SW));


Update ILI9341_T3_DMALIB_VIDEODEMO.ino

Update ILI9341_T3_DMALIB_VIDEODEMO.ino

--- old/examples/ILI9341_T3_DMALIB_VIDEODEMO/ILI9341_T3_DMALIB_VIDEODEMO.ino
+++ old/examples/ILI9341_T3_DMALIB_VIDEODEMO/ILI9341_T3_DMALIB_VIDEODEMO.ino
@@ -6,8 +6,10 @@
 //
 // This sketch works with std 180MHz and less, but better with 240MHZ, or 144MHz and overclocked F_BUS to the max.
 //
+//For Audio, Edit the Audio-library and remove all files which #include "SD.h" - sorry, no other way.
+//

-#define USE_AUDIO 1
+#define USE_AUDIO 0
 #include <SPI.h>
 #include <ILI9341_t3DMA.h>
 #include <SdFat.h>


REV2SecureTempSensor201912 more comment / intent

--- Arduino/hardware/REV2/REV2SecureTempSensor201912/REV2SecureTempSensor201912.ino
+++ Arduino/hardware/REV2/REV2SecureTempSensor201912/REV2SecureTempSensor201912.ino
@@ -26,6 +26,23 @@
  * Used at 16WW to collect outside temperatures from REV2 device in porch,
  * replacing earlier REV2 of which the radio TX apparently failed 2019-12.
  *
+ * Will probably spit out all readings on serial somehow as well as TXing them.
+ *
+ *
+ *
+ *
+ * WILL LIKELY HAVE...
+ *
+ * A simple compile-time toggle at the top to switch the device between RX and TX
+ * to allow a basic radio comms sanity check.
+ *
+ *
+ *
+ *
+ *
+ * DEPENDENCIES:
+ *   * OTRadioLink 2019-12-30 or newer and matching OTAESGCM
+ *   * A shared building key to communicate with other devices on the network.
  */


Comments

Comments

--- MARC_y_MARC/MARC_y_MARC.ino
+++ MARC_y_MARC/MARC_y_MARC.ino
@@ -1,5 +1,9 @@
 /*
-Benjamin Matase
+Benjamin Matase, AC Li, Mark (Rick) Moyer
+20 February, 2016
+
+An arduino C program used to control a robot to navigate a simulated Mars
+evironment.

 */


extracted Update Method

extracted Update Method

--- IoTSolution/app/app.ino
+++ IoTSolution/app/app.ino
@@ -62,7 +62,8 @@
         digitalWrite(LED_SIGNAL, HIGH);
         SaveUpdateFlag(false);
         UpdateIt();
-    }else
+    }
+    else
     {
         digitalWrite(LED_SIGNAL, LOW);
     }
@@ -80,6 +81,24 @@
     Serial.println("Free heap memory: " + String(ESP.getFreeHeap()) + " Bytes.");
     Serial.println("Chip speed:       " + String(ESP.getFlashChipSpeed()) + " Hz.");

+    HandleUpdate();
+
+    char deviceId[21];
+    strcpy(deviceId, "ESP");
+    strcat(deviceId, MAC_char);
+
+    simplesample_http_run(A0, connectionString, deviceId);
+
+    updateUrl = simplesample_http_getUrl();
+    if (updateUrl != 0)
+    {
+        SaveUpdateFlag(true);
+        ESP.restart();
+    }
+}
+
+void HandleUpdate()
+{
     if (updateUrl != 0)
     {
         t_httpUpdate_return ret = ESPhttpUpdate.update(updateUrl);
@@ -98,18 +117,6 @@
             Serial.println("HTTP_UPDATE_OK");
             break;
         }
-    }
-
-    char deviceId[21];
-    strcpy(deviceId,"ESP");
-    strcat(deviceId, MAC_char);
-
-    simplesample_http_run(A0, connectionString, deviceId);
-    updateUrl = simplesample_http_getUrl();
-    if (updateUrl != 0)
-    {
-        SaveUpdateFlag(true);
-        ESP.restart();
     }
 }


Implement bitbang SPI for slow clock devices. (Sylvan Butler).

--- build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino
+++ build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino
@@ -43,7 +43,6 @@
 // - The SPI functions herein were developed for the AVR910_ARD programmer
 // - More information at http://code.google.com/p/mega-isp

-#include "SPI.h"
 #include "pins_arduino.h"
 // Use pin 10 to reset the target
 #define RESET     10
@@ -52,6 +51,17 @@
 #define LED_ERR   8
 #define LED_PMODE 7
 #define PROG_FLICKER true
+
+#if defined(ARDUINO_ARCH_SAM) or defined(ARDUINO_ARCH_SAMD)
+
+#define SPI_CLOCK_DIV_MAX	255
+
+#else
+
+#define USE_HARDWARE_SPI
+#define SPI_CLOCK_DIV_MAX	SPI_CLOCK_DIV_128
+
+#endif

 #define HWVER 2
 #define SWMAJ 1
@@ -67,12 +77,52 @@

 void pulse(int pin, int times);

+#ifdef USE_HARDWARE_SPI
+#include "SPI.h"
+#else
+
+class BitBangedSPI {
+  public:
+    void setDataMode(uint8_t dataMode) {
+      (void) dataMode;
+    }
+    void setBitOrder(uint8_t bitOrder) {
+      (void) bitOrder;
+    }
+    void setClockDivider(uint8_t clockDiv) {
+      (void) clockDiv;
+    }
+
+    void begin() {
+      pinMode(MISO, INPUT);
+      pinMode(RESET, OUTPUT);
+      pinMode(SCK, OUTPUT);
+      pinMode(MOSI, OUTPUT);
+    }
+
+    void end() {}
+
+    uint8_t transfer (uint8_t b) {
+      for (unsigned int i = 0; i < 8; ++i) {
+        digitalWrite(MOSI, b & 0x80);
+        digitalWrite(SCK, HIGH);
+        b = (b << 1) | digitalRead(MISO);
+        digitalWrite(SCK, LOW); // slow pulse
+      }
+      return b;
+    }
+};
+
+static BitBangedSPI SPI;
+
+#endif
+
 void setup() {
   Serial.begin(19200);
   SPI.setDataMode(0);
   SPI.setBitOrder(MSBFIRST);
-  // Clock Div can be 2,4,8,16,32,64, or 128
-  SPI.setClockDivider(SPI_CLOCK_DIV128);
+  // Select the slowest possible clock
+  SPI.setClockDivider(SPI_CLOCK_DIV_MAX);
   pinMode(LED_PMODE, OUTPUT);
   pulse(LED_PMODE, 2);
   pinMode(LED_ERR, OUTPUT);


Disable debugging again.

Disable debugging again.

Sketch size without debugging is 27444 bytes.

--- printer.ino
+++ printer.ino
@@ -35,7 +35,7 @@
 const byte buttonPin = 3;      // the print button
 const byte SD_Pin = 4;         // the SD Card SPI pin

-#define DEBUG // When debug is enabled, log a bunch of stuff to the hardware Serial
+// #define DEBUG // When debug is enabled, log a bunch of stuff to the hardware Serial

 // -- Everything below here can be left alone


Resend serial messages over RS485 immediately rather than after updating outputs

--- HMTL_Modules/HMTL_MSG_Test/HMTL_MSG_Test.ino
+++ HMTL_Modules/HMTL_MSG_Test/HMTL_MSG_Test.ino
@@ -72,19 +72,20 @@
     DEBUG_PRINTLN(DEBUG_HIGH, "");
     DEBUG_PRINTLN(DEBUG_HIGH, "ok");

+    if ((msg_hdr->address != config.address) ||
+	(msg_hdr->address == RS485_ADDR_ANY)) {
+      /* Forward the message over the rs485 interface */
+      DEBUG_VALUELN(DEBUG_HIGH, "Forwarding serial msg to ", msg_hdr->address);
+      memcpy(send_buffer, msg, offset);
+      rs485.sendMsgTo(msg_hdr->address, send_buffer, offset);
+    }
+
     if ((msg_hdr->address == config.address) ||
 	(msg_hdr->address == RS485_ADDR_ANY)) {
       hmtl_handle_msg((msg_hdr_t *)&msg, &config, outputs);
       for (int i = 0; i < config.num_outputs; i++) {
 	hmtl_update_output(outputs[i], NULL);
       }
-    }
-
-    if ((msg_hdr->address != config.address) ||
-	(msg_hdr->address == RS485_ADDR_ANY)) {
-      DEBUG_VALUELN(DEBUG_HIGH, "Forwarding serial msg to ", msg_hdr->address);
-      memcpy(send_buffer, msg, offset);
-      rs485.sendMsgTo(msg_hdr->address, send_buffer, offset);
     }

     offset = 0;


Make the names for the action masks more clear (ACTION# instead of A#). Also copy switch/case statement for the showing the context we want to try to change to.

--- RoverMain/RoverMain.ino
+++ RoverMain/RoverMain.ino
@@ -32,10 +32,10 @@
 #define UNKNOWN 0b0100

 // limit ourselves to possibly four actions for a given context pair
-#define A0_MASK   0b1111000000000000
-#define A1_MASK   0b0000111100000000
-#define A2_MASK   0b0000000011110000
-#define A3_MASK   0b0000000000001111
+#define ACTION0_MASK   0b1111000000000000
+#define ACTION1_MASK   0b0000111100000000
+#define ACTION2_MASK   0b0000000011110000
+#define ACTION3_MASK   0b0000000000001111

 //int lookups[256];
 //lookups[0b00101010] = 0b0011110111001001;
@@ -78,10 +78,10 @@

 		ActionScore maxScore;

-		db.readRec(records[ctxpair] & (15 << 0), EDB_REC actionScore1 );
-		db.readRec(records[ctxpair] & (15 << 1), EDB_REC actionScore2 );
-		db.readRec(records[ctxpair] & (15 << 2), EDB_REC actionScore3 );
-		db.readRec(records[ctxpair] & (15 << 3), EDB_REC actionScore4 );
+		db.readRec(records[ctxpair] & ACTION0_MASK, EDB_REC actionScore1 );
+		db.readRec(records[ctxpair] & ACTION1_MASK, EDB_REC actionScore2 );
+		db.readRec(records[ctxpair] & ACTION2_MASK, EDB_REC actionScore3 );
+		db.readRec(records[ctxpair] & ACTION3_MASK, EDB_REC actionScore4 );

 		maxScore = actionScore1;
 		if(maxScore > actionScore2.score) {
@@ -219,6 +219,25 @@
 			break;
 	}

+	switch(ctxpair & TO_CTX_MASK) {
+		case SAD:
+			break;
+		case MAD:
+			break;
+		case FEARFUL:
+			break;
+		case DISTRACTED:
+			break;
+		case HAPPY:
+			break;
+		case CALM:
+			break;
+		case FOCUSED:
+			break;
+		default:
+			break;
+	}
+
 	actionScore = epsilon_select(ctxpair, 10);
 	switch(actionScore.action) {
 		case 0: // Drive forward, turn around, drive back


copyrights

copyrights

--- V0p2_Main/V0p2_Main.ino
+++ V0p2_Main/V0p2_Main.ino
@@ -14,7 +14,7 @@
 under the Licence.

 Author(s) / Copyright (s): Damon Hart-Davis 2013--2016
-                           Deniz Erbilgin 2015
+                           Deniz Erbilgin 2015--2016
 */

 /*


update example comment.

update example comment.


arduino pwm

arduino pwm

--- arduino/cherdak/cherdak.ino
+++ arduino/cherdak/cherdak.ino
@@ -1,6 +1,10 @@
 /* Home Automation Script
    based on Webduino library
    Vasily Klenov, 2014 */
+
+   /* надо переписать пины на массивы
+      и digitalWrite делать только при изменении значения
+    */

 #include "SPI.h"
 #include "Ethernet.h"
@@ -29,17 +33,27 @@
 #define PIN_6 46
 #define PIN_7 47

-int pin_1_value = RELAY_OFF;
-int pin_2_value = RELAY_OFF;
-int pin_3_value = RELAY_OFF;
-int pin_4_value = RELAY_OFF;
-int pin_5_value = RELAY_OFF;
-int pin_6_value = RELAY_OFF;
-int pin_7_value = RELAY_OFF;
+#define PWM_PIN_1 8
+
+int pin_1_value = RELAY_OFF;
+int pin_2_value = RELAY_OFF;
+int pin_3_value = RELAY_OFF;
+int pin_4_value = RELAY_OFF;
+int pin_5_value = RELAY_OFF;
+int pin_6_value = RELAY_OFF;
+int pin_7_value = RELAY_OFF;
+
+int pwm_pin_1_value = LOW;

 /* store the HTML in program memory using the P macro */
 P(On) = "<status>ON</status>";
 P(Off) = "<status>OFF</status>";
+
+// переписать тоже на макрос?
+void printPwmStatus(pwm_value){
+  P(pwmMsg) = "<status></status>"; // дописать
+  server.printP(pwmMsg);
+}

 void httpNotFound(WebServer &server){
   P(failMsg) =
@@ -65,7 +79,10 @@
         if(strcmp(url_path[1], "ON") == 0){
          value = RELAY_ON;
         }
-
+
+        // тут надо преобразовать строку к числу, это если в запросе передается значение для пвм пина
+        pwm_value = atol(url_path[1]);
+
         pin_number = atol(url_path[0]);

         switch (pin_number) {
@@ -87,8 +104,11 @@
           case PIN_6:
             pin_6_value = value;
             break;
-         case PIN_7:
+          case PIN_7:
             pin_7_value = value;
+            break;
+          case PWM_PIN_1:
+            pwm_pin_1_value = pwm_value;
             break;
          }

@@ -100,48 +120,57 @@
   {
     boolean is_on = false;
     int pin_number;
+    int pwm_value = -1;

     pin_number = atol(url_path[0]);

-     switch (pin_number) {
-          case PIN_1:
-            if(pin_1_value == RELAY_ON)
-            {is_on = true;}
-            break;
-          case PIN_2:
-            if(pin_2_value == RELAY_ON)
-            {is_on = true;}
-            break;
-           case PIN_3:
-            if(pin_3_value == RELAY_ON)
-            {is_on = true;}
-            break;
-           case PIN_4:
-            if(pin_4_value == RELAY_ON)
-            {is_on = true;}
-            break;
-          case PIN_5:
-            if(pin_5_value == RELAY_ON)
-            {is_on = true;}
-            break;
-          case PIN_6:
-            if(pin_6_value == RELAY_ON)
-            {is_on = true;}
-            break;
-          case PIN_7:
-            if(pin_7_value == RELAY_ON)
-            {is_on = true;}
-            break;
-         }
-
-
-    if(is_on)
-   {
-     server.printP( On );
-   } else
-   {
-     server.printP( Off );
-   }
+    switch (pin_number) {
+      case PIN_1:
+        if(pin_1_value == RELAY_ON)
+        {is_on = true;}
+        break;
+      case PIN_2:
+        if(pin_2_value == RELAY_ON)
+        {is_on = true;}
+        break;
+       case PIN_3:
+        if(pin_3_value == RELAY_ON)
+        {is_on = true;}
+        break;
+       case PIN_4:
+        if(pin_4_value == RELAY_ON)
+        {is_on = true;}
+        break;
+      case PIN_5:
+        if(pin_5_value == RELAY_ON)
+        {is_on = true;}
+        break;
+      case PIN_6:
+        if(pin_6_value == RELAY_ON)
+        {is_on = true;}
+        break;
+      case PIN_7:
+        if(pin_7_value == RELAY_ON)
+        {is_on = true;}
+        break;
+      case PWM_PIN_1:
+        pwm_value = pwm_pin_1_value;
+        break;
+    }
+
+    if (pwm_value >= 0)
+    {
+      printPwmStatus( pwm_value );
+    } else
+    {
+      if(is_on)
+      {
+        server.printP( On );
+      } else
+      {
+        server.printP( Off );
+      }
+    }

   }
 }
@@ -164,6 +193,9 @@
   pinMode(PIN_6, OUTPUT);
   pinMode(PIN_7, OUTPUT);

+  digitalWrite(PWM_PIN_1, LOW);
+  pinMode(PWM_PIN_1, OUTPUT);
+
   //Serial.begin(9600);

   // setup the Ehternet library
@@ -192,6 +224,7 @@
   digitalWrite(PIN_5, pin_5_value);
   digitalWrite(PIN_6, pin_6_value);
   digitalWrite(PIN_7, pin_7_value);
-
-}
-
+
+  analogWrite(PWM_PIN_1, pwm_pin_1_value);
+}
+


change 'byte' to 'uint8_t'

change 'byte' to 'uint8_t'

--- examples/NoisePlusPalette/NoisePlusPalette.ino
+++ examples/NoisePlusPalette/NoisePlusPalette.ino
@@ -93,7 +93,7 @@
     for(int j = 0; j < MAX_DIMENSION; j++) {
       int joffset = scale * j;

-      byte data = inoise8(x + ioffset,y + joffset,z);
+      uint8_t data = inoise8(x + ioffset,y + joffset,z);

       // The range of the inoise8 function is roughly 16-240.
       // These two operations expand those values out to roughly 0..255


Just LF fix

Just LF fix

--- examples/nano_engine/snowflakes/snowflakes.ino
+++ examples/nano_engine/snowflakes/snowflakes.ino
@@ -50,7 +50,7 @@
     bool    falling;
 } SnowFlake;

-/*
+/*
  * Define snowflake images directly in flash memory.
  * This reduces SRAM consumption.
  * The image is defined from bottom to top (bits), from left to right (bytes).


Fixed rotating camera file to properly compile in arduino.

--- src/RotatingCamera/RotatingCamera.ino
+++ src/RotatingCamera/RotatingCamera.ino
@@ -39,6 +39,10 @@
 int CLOCKWISE = HIGH;
 int COUNTERCLOCKWISE = LOW;

+void desiredCameraPosChanged(const std_msgs::Int32& newPos);
+void driveUp(void);
+void driveDown(void);
+
 ros::Subscriber<std_msgs::Int32> cvDegreeReader("camera_angle", &desiredCameraPosChanged);

 void setup(){
@@ -55,7 +59,7 @@
 void loop()
 {
 	nh.spinOnce();
-	delayMicroseconds(100000);
+	delayMicroseconds(1000);
 }

 void desiredCameraPosChanged( const std_msgs::Int32& newPos){
@@ -76,6 +80,7 @@
   {
 	  driveDown();
   }
+}

   // increasing the count means we want to move clockwise (right)
   void driveUp()
@@ -90,7 +95,6 @@
 		digitalWrite(PULSE_PIN, LOW);
 		++stepCount;
 	}
-  digitalWrite(ENABLE, HIGH); //the motor should not make loud screeching
   }

   // Decreasing the step means we want to move counter-clockwise (left).
@@ -106,8 +110,6 @@
 		digitalWrite(PULSE_PIN, LOW);
 		--stepCount;
 	}
-  digitalWrite(ENABLE, HIGH); //the motor should not make loud screeching
   }
-
-}
+


Changed servo times and add initial time to allow for target reset

--- arduino_practice_target.ino
+++ arduino_practice_target.ino
@@ -17,8 +17,8 @@

 const int lenLanes = 6;
 const int targetsPerLane = 3;
-const float visibleTime = 2000;
-const float idleTime = 250;
+const float visibleTime = 5000;
+const float idleTime = 500;

 Lane* lanes[lenLanes];
 bool started = false;
@@ -52,11 +52,13 @@
 	}

 	srand (now());
+
+	//Allow time for the targets to reset to original position
+	delay(1000);
 }

 void loop()
 {
-	delay(1000);
 	while (true)
 	{
 		if (started) {
@@ -74,4 +76,4 @@
 	}

 	delete *lanes;
-}+}


Added a new, manually PID tuning that is less aggressive, and made the output compatible with the Arduino Serial Plotter.

--- examples/AStarPIDTest/AStarPIDTest.ino
+++ examples/AStarPIDTest/AStarPIDTest.ino
@@ -84,9 +84,19 @@
 const float Ku = .15;
 const float Tu = .1142857143;

+#define MANUAL_TUNE 1
 #define LESS_AGGRESSIVE 0

-#if !LESS_AGGRESSIVE
+#if MANUAL_TUNE
+// Found empirically to rapidly converge with little overshoot.
+// There is no integral constant, but not needed when driving
+// on flat ground, and when the heading is otherwise controlled
+// by higher-level software. (I.e., there's no need to catch up
+// for past errors.)
+const float Kp = 0.07;
+const float Ki = 0.0;
+const float Kd = 0.001;
+#elif !LESS_AGGRESSIVE
 const float Kp = 0.6*Ku;
 const float Ki = 2*Kp/Tu;
 const float Kd = Kp*Tu/8;
@@ -116,8 +126,11 @@
   enableInterrupt(M2_A, rightAChange, CHANGE);
   enableInterrupt(M2_B, rightBChange, CHANGE);

-  Serial.print("Time (s)\tLeft Target\tLeft Speed\tLeft Cum Error\tLeft Motor");
-  Serial.print("\tRight Target\tRight Speed\tRight Cum Error\tRight Motor");
+//  Serial.print("Time (s)\t");
+  Serial.print("Left Target\tLeft Speed");
+//  Serial.print("\tLeft Cum Error\tLeft Motor\t");
+  Serial.print("\tRight Target\tRight Speed");
+//  Serial.print("\tRight Cum Error\tRight Motor");
   Serial.println();

   lastLoopTime = micros();
@@ -168,25 +181,25 @@
   setSpeed(leftMotorCmd, rightMotorCmd);

   if (leftSpeedTarget > 0 || leftSpeed > 0 || rightSpeedTarget > 0 || rightSpeed > 0) {
-    Serial.print(loopTime, 3);
-    Serial.print("\t");
+//    Serial.print(loopTime, 3);
+//    Serial.print("\t");
     Serial.print(leftSpeedTarget);
     Serial.print("\t");
     Serial.print(leftSpeed);
     Serial.print("\t");
-    Serial.print(leftController.getCumulativeError());
-    Serial.print("\t");
-    Serial.print(leftMotorCmd);
-    Serial.print("\t");
+//    Serial.print(leftController.getCumulativeError());
+//    Serial.print("\t");
+//    Serial.print(leftMotorCmd);
+//    Serial.print("\t");

     Serial.print(rightSpeedTarget);
     Serial.print("\t");
     Serial.print(rightSpeed);
     Serial.print("\t");
-    Serial.print(rightController.getCumulativeError());
-    Serial.print("\t");
-    Serial.print(rightMotorCmd);
-    Serial.print("\t");
+//    Serial.print(rightController.getCumulativeError());
+//    Serial.print("\t");
+//    Serial.print(rightMotorCmd);
+//    Serial.print("\t");

     Serial.println();


add status LEDs

add status LEDs

--- examples/Ports/uploadJNZ/uploadJNZ.ino
+++ examples/Ports/uploadJNZ/uploadJNZ.ino
@@ -5,8 +5,13 @@

 #define RX_PIN      7   // P4D: digital pin on JeePort #4
 #define TX_PIN      17  // P4A: analog  pin on JeePort #4
+
 #define RESET_PIN   4   // P1D: digital pin on JeePort #1
 #define BOOT0_PIN   14  // P1A: analog  pin on JeePort #1
+
+#define GREEN_PIN   6   // P3D: digital pin on JeePort #3
+#define ERROR_PIN   16  // P3A: analog  pin on JeePort #3
+#define START_PIN   3   // IRQ: interrupt pin on all JeePorts

 #define BOOT_LOADER "l052-mecrisp.h"

@@ -37,7 +42,7 @@
 }

 static uint8_t getReply () {
-    for (long i = 0; i < 100000; ++i)
+    for (long i = 0; i < 50000; ++i)
         if (Target.available())
             return Target.read();
     return 0;
@@ -58,6 +63,7 @@
     }
     Serial.print(" FAILED - got 0x");
     Serial.println(b, HEX);
+    digitalWrite(ERROR_PIN, 1);
     while (true) ; // halt
 }

@@ -85,8 +91,11 @@

     uint8_t b = 0;
     do {
+        digitalWrite(GREEN_PIN, 1);
         Serial.print(".");
+        delay(20);
         Target.write(0x7F);
+        digitalWrite(GREEN_PIN, 0);
         b = getReply();
         //Serial.print(b, HEX);
     } while (b != ACK && b != NAK);
@@ -150,6 +159,10 @@
     Serial.println(sizeof data);
     Serial.println();

+    digitalWrite(ERROR_PIN, 0); pinMode(ERROR_PIN, OUTPUT);
+    digitalWrite(GREEN_PIN, 0); pinMode(GREEN_PIN, OUTPUT);
+    pinMode(START_PIN, INPUT_PULLUP);
+
 if (1) {
     resetTarget(true);

@@ -189,6 +202,7 @@

     Serial.print("     Writing: ");
     for (uint16_t offset = 0; offset < sizeof data; offset += 256) {
+        digitalWrite(ERROR_PIN, 1);
         Serial.print('.');
         sendCmd(WRITE_CMD);
         uint32_t addr = 0x08000000 + offset;
@@ -197,6 +211,7 @@
         sendByte(addr >> 8);
         sendByte(addr);
         sendByte(check);
+        digitalWrite(ERROR_PIN, 0);
         wantAck();
         sendByte(256-1);
         //check = 0;
@@ -210,6 +225,7 @@
     Serial.print("        Done: ");
     Serial.print(sizeof data);
     Serial.println(" bytes uploaded.");
+    digitalWrite(GREEN_PIN, 1);
 }

     Target.begin(115200, false, false); // disable parity


remove unnecessary ping(), delay() & added WDT reset for connection failures

--- examples/mqtt_esp8266/mqtt_esp8266.ino
+++ examples/mqtt_esp8266/mqtt_esp8266.ino
@@ -95,8 +95,10 @@
   MQTT_connect();

   // this is our 'wait for incoming subscription packets' busy subloop
+  // try to spend your time here
+
   Adafruit_MQTT_Subscribe *subscription;
-  while ((subscription = mqtt.readSubscription(1000))) {
+  while ((subscription = mqtt.readSubscription(5000))) {
     if (subscription == &onoffbutton) {
       Serial.print(F("Got: "));
       Serial.println((char *)onoffbutton.lastread);
@@ -114,12 +116,12 @@
   }

   // ping the server to keep the mqtt connection alive
+  // NOT required if you are publishing once every KEEPALIVE seconds
+  /*
   if(! mqtt.ping()) {
     mqtt.disconnect();
   }
-
-  delay(1000);
-
+  */
 }

 // Function to connect and reconnect as necessary to the MQTT server.
@@ -134,11 +136,17 @@

   Serial.print("Connecting to MQTT... ");

+  uint8_t retries = 3;
   while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
        Serial.println(mqtt.connectErrorString(ret));
        Serial.println("Retrying MQTT connection in 5 seconds...");
        mqtt.disconnect();
        delay(5000);  // wait 5 seconds
+       retries--;
+       if (retries == 0) {
+         // basically die and wait for WDT to reset me
+         while (1);
+       }
   }
   Serial.println("MQTT Connected!");
-}
+}


Control code is donish

Control code is donish

--- robot/robot.ino
+++ robot/robot.ino
@@ -10,8 +10,8 @@
 #define SPEED_MASK 0x0f

 // Motor pins
-int motor_y[] = {2, 5};
-int motor_x[] = {6, 9};
+int motor_y[] = {3, 5};
+int motor_x[] = {10, 11};

 void setup() {
   Serial.begin(9600);
@@ -27,15 +27,20 @@
   digitalWrite(motor_x[1], LOW);
   digitalWrite(motor_y[0], LOW);
   digitalWrite(motor_y[1], LOW);
+
+  while (!Serial.available());
+  Serial.println("Starting Serial Communication");
 }

 void loop() {
   if (Serial.available()) {
     uint8_t command;
     Serial.readBytes(&command, 1);
+    Serial.println(command, BIN);

     // Determine whether to full stop motors or not
     if (command & FULL_STOP) {
+      Serial.println("Full stop");
       digitalWrite(motor_x[0], LOW);
       digitalWrite(motor_x[1], LOW);
       digitalWrite(motor_y[0], LOW);
@@ -45,7 +50,6 @@
       if (command & AXIS_Y) {
         axis = 1;
       }
-
       // Determine the direction (neg or pos)
       uint8_t dir = 0;
       if (command & DIRECTION_POS) {
@@ -56,7 +60,11 @@
       //TODO: Should be command & SPEED_MASK?
       uint8_t spd = command & SPEED_MASK;
       //TODO: This line creates a quadratic releationship between what should be linear speed values. It would be better to multiply by a constant.
-      spd = spd * 16;
+      if (spd == 16) {
+        spd = 256;
+      } else {
+        spd = spd * 16;
+      }

       // Write the motor speeds
       switch (axis) {
@@ -65,39 +73,33 @@
           switch (dir) {
             case 0:
               // Negative direction
-              analogWrite(motor_x[0], LOW);
               analogWrite(motor_x[1], spd);
+              digitalWrite(motor_x[1], HIGH);
               break;
-            default:
+            case 1:
               // Positive direction
               analogWrite(motor_x[0], spd);
-              analogWrite(motor_x[1], LOW);
+              digitalWrite(motor_x[1], LOW);
               break;
           }
           break;
-        default:
+        case 1:
           // Y-axis
           switch (dir) {
             case 0:
               // Negative direction
-              analogWrite(motor_y[0], LOW);
               analogWrite(motor_y[1], spd);
+              digitalWrite(motor_y[1], HIGH);
               break;
-            default:
+            case 1:
               // Positive direction
               analogWrite(motor_y[0], spd);
-              analogWrite(motor_y[1], LOW);
+              digitalWrite(motor_y[1], LOW);
               break;
           }
           break;
       }
     }
-  } else {
-    // If serial is not available, shut down to prevent damage.
-    digitalWrite(motor_x[0], LOW);
-    digitalWrite(motor_x[1], LOW);
-    digitalWrite(motor_y[0], LOW);
-    digitalWrite(motor_y[1], LOW);
   }
   // Wait 25 ms to allow settling
   //TODO: If multiple messages are sent within a span of 25 milliseconds, this could be bad.


Changed port to 1337.

Changed port to 1337.

--- arduino/sketch/LeonardoETH.ino
+++ arduino/sketch/LeonardoETH.ino
@@ -2,7 +2,7 @@
 #include <Conceptinetics.h>

 // @TODO: Add a description
-WebUSB WebUSBSerial(1, "localhost:8081");
+WebUSB WebUSBSerial(1, "localhost:1337");
 #define Serial WebUSBSerial

 // Amount of DMX channels


feature(arduino): Send serial status

feature(arduino): Send serial status

--- buttonPress/buttonPress.ino
+++ buttonPress/buttonPress.ino
@@ -92,18 +92,22 @@

 //Function to send a radio signal to turn sockets on
 void turnSocketsOn() {
+  // For RPi parsing
+  Serial.println("status : 1");
   //  delay
   delay(2000);
   Serial.print("Turning sockets on: ");
-  Serial.print(A_Button_On);
+  Serial.println(A_Button_On);
   mySwitch.sendTriState(A_Button_On);
   delay(1000);
   // Send ON signal to PI
 }
 //Function to send a radio signal to turn sockets off
 void turnSocketsOff() {
+  // For RPi parsing
+  Serial.println("status : 0");
   Serial.print("Turning sockets off: ");
-  Serial.print(A_Button_Off);
+  Serial.println(A_Button_Off);
   mySwitch.sendTriState(A_Button_Off);
   delay(1000);
   // Send OFF signal to PI


watchdog

watchdog

--- gamecubecontroller.ino
+++ gamecubecontroller.ino
@@ -9,8 +9,6 @@
 //    If on Windows, run drivers\win\install_drivers.bat
 // Note: You may need to adjust permissions on some of the dll, exe and bat files.

-#include "dwt.h"
-
 // Facing Gamecube socket (as on console), flat on top:
 //    123
 //    ===
@@ -28,11 +26,15 @@
 // Put LEDs + resistors (100-220 ohm) between PA0,PA1,PA2,PA3 and 3.3V
 // Put momentary pushbuttons between PA4,PA5 and 3.3V

+//#include "c:/users/alexander_pruss/Documents/Arduino/hardware/addMidiHID/STM32F1/system/libmaple/include/libmaple/iwdg.h"
+#include <libmaple/iwdg.h>
+#include "dwt.h"
 #include "debounce.h"
 #include "gamecube.h"

 #undef SERIAL_DEBUG

+const uint32_t watchdogSeconds = 10;
 const uint32_t numInjectionModes = sizeof(injectors)/sizeof(*injectors);

 const uint32_t indicatorLEDs[] = { PA0, PA1, PA2, PA3 };
@@ -103,6 +105,8 @@
   updateDisplay();

   lastChangedModeTime = 0;
+
+  iwdg_init(IWDG_PRE_256, watchdogSeconds*156);
 }

 // at most 32 bits can be sent
@@ -211,6 +215,7 @@
 void loop() {
   GameCubeData_t data;

+  iwdg_feed();
   uint32_t t0 = millis();

   while((millis()-t0) < 6) {
@@ -230,18 +235,21 @@
     }
   }

+  iwdg_feed();
   if (savedInjectionMode != injectionMode && (millis()-lastChangedModeTime) >= saveInjectionModeAfterMillis) {
     saveInjectionMode(injectionMode);
     savedInjectionMode = injectionMode;
   }

+  iwdg_feed();
   if (gameCubeReceiveReport(&data, 0)) {
 #ifdef SERIAL_DEBUG
     Serial.println("buttons1 = "+String(data.buttons));
     Serial.println("joystick = "+String(data.joystickX)+","+String(data.joystickY));
     Serial.println("c-stick = "+String(data.cX)+","+String(data.cY));
     Serial.println("shoulders = "+String(data.shoulderLeft)+","+String(data.shoulderRight));
-#else
+#else
+    iwdg_feed();
     inject(injectors + injectionMode, &data);
 #endif
   }


changed servo code

changed servo code

--- servo/servo.ino
+++ servo/servo.ino
@@ -1,32 +1,43 @@
 #include<Servo.h>

-int servoPin=9;
-int servoPin2=10;
+int servoPin=3;
+int servoPin2=9;
 int inputPin=8;
 int angle=0;
+bool isHigh=true;
+bool isLow=true;
 Servo servo;
+Servo servo2;
 void setup() {
  servo.attach(servoPin);
- servo.attach(servoPin2);
+ servo2.attach(servoPin2);
  pinMode(inputPin, INPUT);
 }

 void loop() {
-  if(digitalRead(inputPin)==HIGH)
+ if(digitalRead(inputPin)==HIGH && isHigh)
   {
-    for(angle=0;angle<=180;angle++)
+    for(angle=60;angle<180;angle++)
     {
       servo.write(angle);
+      servo2.write(angle);
+
+      delay(15);
     }
+    isHigh=false;
+    isLow=true;
+}
+    else if (digitalRead(inputPin)==LOW && isLow))
+   {
+   for(angle=180;angle>60;angle--)
+   {
+     servo.write(angle);
+     servo2.write(angle);
+     delay(15);

-  }
-    else
-   {
-    for(angle=180;angle>=0;angle--)
-    {
-      servo.write(angle);
     }
-
+    isHigh=true;
+    isLow=false;
   }

 }


Added title screen. Added option to turn sound on and off.

--- snack/snack.ino
+++ snack/snack.ino
@@ -7,7 +7,8 @@
 byte minX = 0;
 byte maxY = 63;
 byte minY = 10;
-bool gameRunning = true;
+char gameState = 'T';
+bool sound = false;

 struct coords
 {
@@ -60,7 +61,7 @@
   }

-  gameRunning = true;
+  gameState = 'G';
 }

 void LogMove()
@@ -87,12 +88,16 @@

 void EndGame()
 {
+  if(sound == true)
+  {
     arduboy.tunes.tone(200, 200);
     delay(400);
     arduboy.tunes.tone(100, 400);
     delay(600);
     arduboy.tunes.tone(50, 2000);
-    gameRunning = false;
+  }
+
+  gameState = 'E';
 }

 void CollisionDetection()
@@ -124,7 +129,11 @@
     {
       p1.Len += 1;
     }
-    arduboy.tunes.tone(987, 160);
+    if(sound == true)
+    {
+      arduboy.tunes.tone(987, 160);
+    }
+
     score += 1;
     LogMove();
     GenerateFood();
@@ -170,8 +179,6 @@
   // here we set the framerate to 15, we do not need to run at
   // default 60 and it saves us battery life
   arduboy.setFrameRate(30);
-
- StartGame();
 }

@@ -185,8 +192,9 @@
   // first we clear our screen to black
   arduboy.clear();

-  if(gameRunning == true)
-  {
+  if(gameState == 'G')
+  {
+    arduboy.setFrameRate(30);
     DrawFrame();

     if(arduboy.pressed(RIGHT_BUTTON)) {
@@ -267,8 +275,9 @@

     arduboy.print(scoreBuff);
   }
-  else
-  {
+  else if(gameState == 'E')
+  {
+    arduboy.setFrameRate(10);
     arduboy.setCursor(20, 20);
     arduboy.print("Game Over");

@@ -280,11 +289,49 @@

     arduboy.print(scoreBuff);

-    // if the up button or B button is pressed move 1 pixel up every frame
+    if(arduboy.pressed(A_BUTTON) || arduboy.pressed(B_BUTTON)) {
+      gameState = 'T';
+    }
+
+  }
+  else if(gameState == 'T')
+  {
+    arduboy.setFrameRate(10);
+    arduboy.setCursor(50, 1);
+    arduboy.print("Snack");
+
+    arduboy.setCursor(20, 15);
+    arduboy.print("By Shane Powell");
+
+    arduboy.setCursor(50, 55);
+    arduboy.print("Sound");
+
+    arduboy.setCursor(90, 55);
+    arduboy.print("On");
+
+    arduboy.setCursor(109, 55);
+    arduboy.print("Off");
+
     if(arduboy.pressed(A_BUTTON) || arduboy.pressed(B_BUTTON)) {
       StartGame();
     }
-
+    else if(arduboy.pressed(LEFT_BUTTON))
+    {
+      sound = true;
+    }
+    else if(arduboy.pressed(RIGHT_BUTTON))
+    {
+      sound = false;
+    }
+
+    if(sound == true)
+    {
+          arduboy.drawRect(88,53, 18, 11, WHITE);
+    }
+    else
+    {
+          arduboy.drawRect(107,53, 21, 11, WHITE);
+    }
   }


Removing debug code Renaming variable

Removing debug code
Renaming variable

--- examples/LCDKeyPadShieldAndRadioTEA5767Demo/LCDKeyPadShieldAndRadioTEA5767Demo.ino
+++ examples/LCDKeyPadShieldAndRadioTEA5767Demo/LCDKeyPadShieldAndRadioTEA5767Demo.ino
@@ -19,7 +19,6 @@
 #include <Wire.h>
 #include <stdlib.h>
 #include <EEPROM.h>
-#include <Serial.h>

 // Init radio object
 TEA5767N radio = TEA5767N();
@@ -51,7 +50,7 @@
 int incPin = 12;

 // Predefined stations array
-float default_stations[16] = {88.1, 89.1, 89.7, 91.3, 92.5, 93.7, 94.7, 95.3, 96.1, 98.5, 100.1, 100.9, 101.7, 102.1, 102.9, 103.3};
+float defaultStations[16] = {88.1, 89.1, 89.7, 91.3, 92.5, 93.7, 94.7, 95.3, 96.1, 98.5, 100.1, 100.9, 101.7, 102.1, 102.9, 103.3};
 // Initialized station arrays
 float stations[16] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
 // Keep the current station index
@@ -77,7 +76,7 @@
 void loadDefaultStations() {
   for (int i=0 ; i < 16 ; i++) {
      //TODO Do this using pointers
-     stations[i] = default_stations[i];
+     stations[i] = defaultStations[i];
   }
 }

@@ -812,7 +811,6 @@
       break;
     }
     case btnNONE: {
-      //Serial.println("Btn None");
       if (!wasReleased) {
         wasReleased = true;
       }


Added new code - forward/back

Added new code - forward/back

--- motor/motor.ino
+++ motor/motor.ino
@@ -23,3 +23,42 @@
  digitalWrite(motorPin2, LOW);
  delay(200);
 }
+
+
+
+
+
+
+#include <Servo.h>
+Servo myservo;
+
+void setup() {
+  myservo.attach(11);
+  int pos = myservo.read();
+
+  //set servo at 45 degrees to begin with
+  while (pos != 180) {
+    myservo.write(pos);
+    delay(15);
+    pos++;
+  }
+  myservo.write(130);
+  delay(2000);
+}
+
+void loop() {
+}
+
+//opens cage to deliver drink
+void openCage() {
+  myservo.write(85);
+  delay(1500);
+}
+
+//closes cage after delivery
+void closeCage() {
+  myservo.write(-85);
+  delay(1500);
+}
+
+//


temp_NW

--- _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
+++ _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
@@ -228,7 +228,10 @@

   if ( receivedtopic == "esp8266/arduino/s06" ) {
     if (root.containsKey("WeightAvg")) {
-      NW  = root["WeightAvg"];
+      int temp_NW = root["WeightAvg"];
+      if ( temp_NW > 0 ) {
+        NW  = root["WeightAvg"];
+      }
     }
   }


Minor changes

Minor changes

--- Arduino_Code/Arduino_Code.ino
+++ Arduino_Code/Arduino_Code.ino
@@ -20,17 +20,25 @@
 int buttonState[] = {0,0,0,0};
 unsigned long debounceTime = 50;

+int seqIndex;
+int seqSize;
+
+
+boolean displayingSequence = false;
+boolean repeatingSequence = false;
+boolean creatingSequence = false;
+

 /*
  String recString = "";
  boolean arduinoTurn = false;
  String recMessage = "";
  boolean LEDon = false;
- int seqIndex;
+
  unsigned long timeOfLastChange;
  int seqArr[100];
  int repeatArr[100];
- int seqSize;
+
  boolean playerRepeating = false;
  boolean playerCreating = false;
  boolean prevBtns[] = {false, false, false, false};
@@ -101,6 +109,76 @@
   }
   prevButtonState[i] = cur;
 }
+
+//expect morse code to start with . or - and sequences are in the form 12031021, BOTH END WITH |
+void serialEvent()
+{
+  while (Serial.available())
+  {
+    char inChar = (char)Serial.read();
+    recString += inChar;
+
+    if (inChar == '|')
+    {
+      int endIndex = recString.indexOf("|");
+      /*
+      if (endIndex == -1)
+      {
+        endIndex = recString.indexOf("/n");
+      }
+      */
+
+      //PROCESS MESSAGE
+      if (recString.charAt(0) == '.' || recString.charAt(0) == '-' {
+        recMessage= recString.substring(2, endIndex);
+        Serial.print("Received Message:");
+        Serial.println(recMessage);
+
+      //PROCESS SEQUENCE
+      }
+      if (recString.charAt(0) == 's') {
+        seqSize = (recString.length()-1)/2;
+        /*
+        int* seq = new int[(recString.length()-1)/2];
+        Serial.println(sizeof(*seq));
+        for (int i = 2; i < recString.length(); i++)
+        {
+        }
+        */
+        /*
+        for (int i = 2; i <= (seqSize*2); i += 2)
+        {
+          seqArr[i/2 -1] = recString.charAt(i) - '0';
+        }
+        /*
+        Verify that you can actually create arrays of variable size
+        Serial.print("Created array size: ");
+        Serial.println(sizeof(seqArr) / sizeof(int));
+
+        //Test Sequence Array
+        for (int i = 0; i < digits; i ++)
+        {
+          Serial.println(seqArr[i]);
+        }
+        */
+        /*
+        seqIndex = 0;
+        LEDon = false;
+        for (int i = 0; i < 4; i ++)
+          prevBtns[i] = false;
+        arduinoTurn = true;
+      }
+
+
+      //Output sequence to user
+
+
+
+      recString = "";
+    }
+  }
+}
+


updated

updated

--- sandbox/Razor_AHRS/Razor_AHRS.ino
+++ sandbox/Razor_AHRS/Razor_AHRS.ino
@@ -550,7 +550,7 @@

           output_mode = OUTPUT__MODE_BOTH_CALIB;
           if (format_param == 't') // Output values in _t_ext format
-            output_format = OUTPUT__FORMATE_BINARY;
+            output_format = OUTPUT__FORMAT_BINARY;
           else if (format_param == 'b') // Output values in _b_inary format
             output_format = OUTPUT__FORMAT_BINARY;
         }


Fix order of curtains

Fix order of curtains

--- examples/cymatic-curtains-with-triangles/cymatic-curtains-with-triangles.ino
+++ examples/cymatic-curtains-with-triangles/cymatic-curtains-with-triangles.ino
@@ -149,10 +149,10 @@
   anim5->init(1.0);
   anim6->init(0.6, true);

-  FastLED.addLeds<WS2811,  8, RGB>(strip1.leds, 150);
-  FastLED.addLeds<WS2811,  9, RGB>(strip2.leds, 150);
-  FastLED.addLeds<WS2811, 10, RGB>(strip3.leds, 150);
-  FastLED.addLeds<WS2811, 11, RGB>(strip4.leds, 150);
+  FastLED.addLeds<WS2811,  8, RGB>(strip4.leds, 150);
+  FastLED.addLeds<WS2811,  9, RGB>(strip3.leds, 150);
+  FastLED.addLeds<WS2811, 10, RGB>(strip2.leds, 150);
+  FastLED.addLeds<WS2811, 11, RGB>(strip1.leds, 150);

   FastLED.addLeds<WS2811,  4, GRB>(strip5.leds, 165);
   FastLED.addLeds<WS2811,  6, GRB>(strip6.leds, 165);


Updated comments

Updated comments

Added link on "Wake from deep sleep with a keypress demonstration" by Nick Gammon.

--- Launcher/Launcher.ino
+++ Launcher/Launcher.ino
@@ -4,6 +4,8 @@
 #include <Keypad.h>

 /*
+Used "Wake from deep sleep with a keypress demonstration" (Author: Nick Gammon)
+http://www.gammon.com.au/forum/?id=11497&reply=4#reply4

 Pin change interrupts.

@@ -583,4 +585,4 @@

 	// put keypad pins back how they are expected to be
 	reconfigurePins ();
-}  // end of goToSleep+}  // end of goToSleep


Change to russian

Change to russian

--- MStation/MStation.ino
+++ MStation/MStation.ino
@@ -126,19 +126,22 @@
     // Print temp on LCD
     lcd.setCursor(0, 0);
     if (!temp12) {
-      lcd.print("Temp1: ");
+      //lcd.print("Temp1: ");
+      lcd.print("Te""\xBC\xBE""1: ");
       lcd.print((int) DHT.temperature);
       lcd.print(" \x99""C    ");
       temp12 = 1;
     } else {
-      lcd.print("Temp2: ");
+      //lcd.print("Temp2: ");
+      lcd.print("Te""\xBC\xBE""2: ");
       lcd.print(ds18_tempS);
       lcd.print(" \x99""C");
       temp12 = 0;
     }
     // Print humidity on LCD
     lcd.setCursor(0, 1);
-    lcd.print("Humid: ");
+    //lcd.print("Humid: ");
+    lcd.print("\x42\xBB\x61\xB6\xBD"": ");
     lcd.print((int) DHT.humidity);
     lcd.print(" %");
   }


src: add support for clearing before setting range

--- MqttLEDs/MqttLEDs.ino
+++ MqttLEDs/MqttLEDs.ino
@@ -17,6 +17,7 @@

 const char* OFF = "off";
 const char* RANGE = "range";
+const char* CLEAR_AND_RANGE = "clear+range";

 Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, LED_PIN, NEO_GRB + NEO_KHZ800);

@@ -28,7 +29,14 @@
     for(uint16_t i=0; i <strip.numPixels(); i++) {
       strip.setPixelColor(i, strip.Color(0,0,0));
     }
-  } else if (0 == strncmp(RANGE, messageBuffer.c_str(), strlen(RANGE))) {
+  } else if ((0 == strncmp(RANGE, messageBuffer.c_str(), strlen(RANGE))) ||
+             (0 == strncmp(CLEAR_AND_RANGE, messageBuffer.c_str(), strlen(CLEAR_AND_RANGE)))) {
+    if (0 == strncmp(CLEAR_AND_RANGE, messageBuffer.c_str(), strlen(CLEAR_AND_RANGE))) {
+      for(uint16_t i=0; i <strip.numPixels(); i++) {
+        strip.setPixelColor(i, strip.Color(0,0,0));
+      }
+    }
+
     char* next = strtok((char*) messageBuffer.c_str()," ");
     next = strtok(nullptr," ");
     int start = atoi(next);


Better example: Jewelbots Logo & button press

Provide a bit more functionality in the example Arduino sketch

--- jewelbots_nRF51822_board_v100/Examples/JWB_blank/JWB_blank.ino
+++ jewelbots_nRF51822_board_v100/Examples/JWB_blank/JWB_blank.ino
@@ -7,4 +7,12 @@

 void loop() {
   // put your main code here, to run repeatedly:
+  Animation animation;
+  animation.jewelbots_logo();
 }
+
+void button_press() {
+  // put code here to run whenever the Magic Button is pressed:
+  Animation animation;
+  animation.breathe_single_color(BLUE);
+}


Added instrument class; how inherit array's constructor?

--- Synthduino.ino
+++ Synthduino.ino
@@ -1,21 +1,18 @@
+/* Synthduino - the Arduino Synthesizer program
+ * v. 0.1
+ * Milton Stanley, Milte Technologies
+ */
+
 #include <StandardCplusplus.h>
 #include <utility.h>
 #include <unwind-cxx.h>
 #include <system_configuration.h>
 #include <vector>
-/* Synthduino - the Arduino Synthesizer program
- * v. 0.1
- * Milton Stanley, Milte Technologies
- *
- */
-
-// TODO now only in README

 #include "note.h"
 #include "pitches.h"
 #include "durations.h"
-
-std::vector<int> test;
+#include "instrument.h"

 /* HEADER SECTION
  * Declare your tempo and parts/pins (note parts/pins are recommended in the format below
@@ -29,7 +26,8 @@
 #define BASS 12  		// Bass will be output on pin 12
 #define MELODY 13

-//Note a440(nA4, 8);
+// Note a440(nA4, 8);
+
 /*  The below line doesn't work on Windows, as Arduino uses an older version of gcc w/o specifying
     c++11 support
       Note bassLine[] = { {nC3, 2}, {nDS3, 2}, {nF3, 1} }; // The actual bass part


dns: only capture linkgo.io

dns: only capture linkgo.io

--- src/neurite.ino
+++ src/neurite.ino
@@ -749,7 +749,9 @@
 		if (SPIFFS.exists(pathWithGz))
 			path += ".gz";
 		File file = SPIFFS.open(path, "r");
+		log_dbg("streaming size: %u\n\r", file.size());
 		size_t sent = server->streamFile(file, contentType);
+		log_dbg("stream return sent: %u\n\r", sent);
 		file.close();
 		path = String();
 		contentType = String();
@@ -961,6 +963,13 @@
 		json = String();
 	});
 	server->on("/wifiscan", HTTP_GET, []() {
+		static bool scanning = false;
+		if (scanning) {
+			server->send(202, "text/plain", "");
+			log_dbg("busy scanning, return\r\n");
+			return;
+		}
+		scanning = true;
 		log_dbg("scan start\r\n");
 		int n = WiFi.scanNetworks();
 		log_dbg("scan done\r\n");
@@ -990,6 +999,7 @@
 			server->send(204, "text/plain", "No WLAN found");
 			log_dbg("No WLAN found\r\n");
 		}
+		scanning = false;
 	});
 	server->on("/ip", HTTP_GET, []() {
 		String ipstr = String();
@@ -1047,7 +1057,7 @@
 			LOG_SERIAL.println(".local to get started");
 #endif
 #ifdef NEURITE_ENABLE_DNSPORTAL
-			dnsServer.start(53, "*", apIP);
+			dnsServer.start(53, "linkgo.io", apIP);
 			log_dbg("DNS server started\n\r");
 #endif
 			server_config(nd);


final angles for the White House Generation Indigenous tech showcase

--- pir-sensor-led/pir-sensor-led.ino
+++ pir-sensor-led/pir-sensor-led.ino
@@ -70,10 +70,10 @@
 Pir pir5(5);
 Servo myservo;  // create servo object to control a servo
                 // a maximum of eight servo objects can be created
-UpListener listener2(&myservo, 120);
-UpListener listener3(&myservo, 100);
-UpListener listener4(&myservo, 80);
-UpListener listener5(&myservo, 60);
+UpListener listener2(&myservo, 165);
+UpListener listener3(&myservo, 120);
+UpListener listener4(&myservo, 75);
+UpListener listener5(&myservo, 30);

 void setup() {
   Serial.begin(9600);