Modify variable name &add LED usbcontrol function

--- Software/OpenCM9.04/RovMain/RovMain.ino
+++ Software/OpenCM9.04/RovMain/RovMain.ino
@@ -18,7 +18,7 @@
 #include "LED.h"

 RSP     RovSerial;
-Servo   RovServo[3];
+Servo   RovMotor[3];
 cIMU    IMU;
 cLED    LED;

@@ -36,15 +36,15 @@

 void setup()
 {
-  Serial.begin(115200);
-
-  RovSerial.begin(115200);
-
-  Motor_init();
-
-  LED.Led_init();
-
-  err_code = IMU.begin();
+  Serial.begin(115200);  //USB시리얼 통신 초기화
+
+  RovSerial.begin(115200); //UART1 시리얼 통신 초기화
+
+  Motor_init(); //모터 초기화
+
+  LED.Led_init(); //LED초기화
+
+  err_code = IMU.begin(); // IMU 에러여부 확인 리턴 변수

   IsConnected = false;
 }
@@ -54,42 +54,42 @@
 {
   static uint32_t tTime[3];

+  //-- 500ms마다 LED 토글
   if( (millis()-tTime[0]) >= 500 )
   {
     tTime[0] = millis();
     LED.toggle();
   }

+  //-- IMU 갱신
   IMU.update();
+
   //-- 명령어 수신 처리
-  //
   process_recv_cmd();

   //-- 100ms마다 ROV정보 전달
-  //
   if( (millis()-tTime[1]) >= 100 )
   {
     tTime[1] = millis();

-   sout_IMU_info();
-   send_cmd_info();
+   sout_IMU_info(); //IMU 정보 USB시리얼창에 출력
+   send_cmd_info(); //커맨드 정보 USB시리얼창에 출력
   }
   cal_IMU_acc();

-  if(USB_TEST_AVAILABLE)
+  if(USB_TEST_AVAILABLE)  //USB시리얼로 테스트를 한다면,
   rc_usb_test();

   //-- 연결이 끊어진 상태
-  //
-/*
+/************************************
   if( IsConnected == false )
   {
-    RovServo[RC_MOTOR_L].write(0);
-    RovServo[RC_MOTOR_C].write(0);
-    RovServo[RC_MOTOR_R].write(0);
-  }
-  */
+    RovMotor[RC_MOTOR_L].writeMicroseconds(MOTOR_NEUTRAL);
+    RovMotor[RC_MOTOR_C].writeMicroseconds(MOTOR_NEUTRAL);
+    RovMotor[RC_MOTOR_R].writeMicroseconds(MOTOR_NEUTRAL);
+  }
+ ************************************/
 }

 void process_recv_cmd( void )
@@ -117,14 +117,18 @@
         break;
     }
   }
-  /*else
+
+  // HeartBit
+  /**********************************
+  else
   {
     if( (tTime-millis()) >= 1000 )
     {
       IsConnected = false;
     }
     tTime = millis();
-  }*/
+  }
+  ***********************************/
 }

 void send_cmd_info( void )
@@ -149,7 +153,7 @@
     Pwm[0] = (pCmd->Data[8]<<8) | (pCmd->Data[7]);
     Serial.print("Moter_L : ");
     Serial.println(Pwm[0]);
-    RovServo[RC_MOTOR_L].writeMicroseconds(Pwm[0]);
+    RovMotor[RC_MOTOR_L].writeMicroseconds(Pwm[0]);
   }
   //Moter_Center
   if(pCmd->Data[9] == 1)
@@ -157,7 +161,7 @@
     Pwm[1] = (pCmd->Data[11]<<8) | (pCmd->Data[10]);
     Serial.print("Moter_C : ");
     Serial.println(Pwm[1]);
-    RovServo[RC_MOTOR_C].writeMicroseconds(Pwm[1]);
+    RovMotor[RC_MOTOR_C].writeMicroseconds(Pwm[1]);
   }
   //Moter_Right
   if(pCmd->Data[12] == 1)
@@ -165,7 +169,7 @@
     Pwm[2] = (pCmd->Data[14]<<8) | (pCmd->Data[13]);
     Serial.print("Moter_R : ");
     Serial.println(Pwm[2]);
-    RovServo[RC_MOTOR_R].writeMicroseconds(Pwm[2]);
+    RovMotor[RC_MOTOR_R].writeMicroseconds(Pwm[2]);
   }

@@ -178,6 +182,7 @@
     Serial.println(Led[0]);
     analogWrite(LED_PIN_L, Led[0]);
   }
+/*********************************************
   //Led_Right
   if(pCmd->Data[3] == 1)
   {
@@ -186,18 +191,19 @@
     Serial.println(Led[1]);
     analogWrite(LED_PIN_R, Led[1]);
   }
+**********************************************/
 }

 void Motor_init()
 {
-  RovServo[RC_MOTOR_L].attach(RC_MOTOR_PIN_L, 1000, 2000, 0, 255 );
-  RovServo[RC_MOTOR_C].attach(RC_MOTOR_PIN_C, 1000, 2000, 0, 255 );
-  RovServo[RC_MOTOR_R].attach(RC_MOTOR_PIN_R, 1000, 2000, 0, 255 );
-
-  RovServo[RC_MOTOR_L].writeMicroseconds(MOTOR_NEUTRAL);
-  RovServo[RC_MOTOR_C].writeMicroseconds(MOTOR_NEUTRAL);
-  RovServo[RC_MOTOR_R].writeMicroseconds(MOTOR_NEUTRAL);
+  RovMotor[RC_MOTOR_L].attach(RC_MOTOR_PIN_L, 1000, 2000, 0, 255 );
+  RovMotor[RC_MOTOR_C].attach(RC_MOTOR_PIN_C, 1000, 2000, 0, 255 );
+  RovMotor[RC_MOTOR_R].attach(RC_MOTOR_PIN_R, 1000, 2000, 0, 255 );
+
+  RovMotor[RC_MOTOR_L].writeMicroseconds(MOTOR_NEUTRAL);
+  RovMotor[RC_MOTOR_C].writeMicroseconds(MOTOR_NEUTRAL);
+  RovMotor[RC_MOTOR_R].writeMicroseconds(MOTOR_NEUTRAL);
 }

 void sout_IMU_info()
@@ -245,25 +251,47 @@
   {
     ch = Serial.read();

-    if( ch == 'p' )
+    if( ch =='p' )     // 모터 정지
     {
       rc_pwm = MOTOR_NEUTRAL;
-      RovServo[RC_MOTOR_C].writeMicroseconds(rc_pwm);
+      RovMotor[RC_MOTOR_C].writeMicroseconds(rc_pwm);
+      RovMotor[RC_MOTOR_L].writeMicroseconds(rc_pwm);
+      RovMotor[RC_MOTOR_R].writeMicroseconds(rc_pwm);
+      Serial.print("                                               usb_motor : ");
       Serial.println("Stop");
     }

-    if( ch == 'w' )
+    if( ch == 'w' )     // 모터 가속
     {
       rc_pwm = constrain(rc_pwm++, 1000, 2000);
-      RovServo[RC_MOTOR_C].writeMicroseconds(rc_pwm);
+      RovMotor[RC_MOTOR_C].writeMicroseconds(rc_pwm);
+      RovMotor[RC_MOTOR_L].writeMicroseconds(rc_pwm);
+      RovMotor[RC_MOTOR_R].writeMicroseconds(rc_pwm);
+      Serial.print("                                               usb_motor : ");
       Serial.println(rc_pwm);
     }

-    if( ch == 's' )
+    if( ch == 's' )     // 모터 감속
     {
       rc_pwm = constrain(rc_pwm--, 1000, 2000);
-      RovServo[RC_MOTOR_C].writeMicroseconds(rc_pwm);
+      RovMotor[RC_MOTOR_C].writeMicroseconds(rc_pwm);
+      RovMotor[RC_MOTOR_L].writeMicroseconds(rc_pwm);
+      RovMotor[RC_MOTOR_R].writeMicroseconds(rc_pwm);
+      Serial.print("                                               usb_motor : ");
       Serial.println(rc_pwm);
     }
-  }
-}
+
+    if( ch == 'q' )  // LED OFF
+    {
+      digitalWrite(LED_PIN_L, 1);
+      Serial.println("                                               usb_LED : OFF");
+    }
+    if( ch == 'e' )   // LED ON
+    {
+      digitalWrite(LED_PIN_L, 0);
+      Serial.println("                                               usb_LED : ON");
+    }
+
+
+  }
+}


30/30

--- _07-ac-ir-remote-timer/_07-ac-ir-remote-timer.ino
+++ _07-ac-ir-remote-timer/_07-ac-ir-remote-timer.ino
@@ -14,10 +14,11 @@
     togglePower();
     sleep30Minutes();
     togglePower();
-    sleep60Minutes();
+    //sleep60Minutes();
+    sleep30Minutes();
 }

-
+// USe 9 sec
 void sleep60Minutes()
 {
   for (int i = 0; i < 400; i++) {


Bug fix - Serial interface now updates currentServoVal.

--- software/Arduino/ServoController/ServoController.ino
+++ software/Arduino/ServoController/ServoController.ino
@@ -60,6 +60,7 @@
     correctionFactorZ += (Serial.read() - '0');
     if (negZ) correctionFactorZ = -correctionFactorZ;
     altitude.write(currentServoVal + correctionFactorZ);
+    currentServoVal += correctionFactorZ;
   }
   if (int_flag) {
     j++;


comments - intro

comments - intro

--- Source/RTC_NeoPixel_Clock_Calendar/RTC_NeoPixel_Clock_Calendar.ino
+++ Source/RTC_NeoPixel_Clock_Calendar/RTC_NeoPixel_Clock_Calendar.ino
@@ -1,3 +1,21 @@
+//  Arduino RTC Clock & Perpetual Calendar
+//  Written by David R Ratliff
+//  September, 2013
+//
+//  This sketch was written for use with -
+//    ChronoDot RTC         -- But chipset, address, and memory registers are similar to other popular RTC chips, so they may work
+//                          -- Supports I2C & Serial. This code uses the I2C with the built-in Arduino Wire library.
+//    Arduino Pro Mini 328  -- Chosen for size
+//                          -- This is just a physically tiny and thin Arduino using the same chip as Arduino UNO.
+//    Adafruit LED Backpack -- Uses the 28-pin version of LED driver IC.
+//                          -- I'm not sure other versions/sizes of the HT16K33 chip have enough oututs to drive bi-color matrix
+//    5x7 LED Matrix        -- Bi-Color (Red/Green) matrix is used. This is for the calendar.
+//                          -- Code uses three colors - Red, Green, and mixed == Orange
+//                          -- one color for weekdays, one color for weekends, third color to mark 'TODAY' on calendar
+//    NeoPixel Ring         -- When written, only the 16-pixel ring existed. It took some creative problem solving
+//                          --  to represent 12 hrs & 60 mins with 16 LEDs. It should be easy enough to change code
+//                          --  to work with whatever sized ring you decide to use.
+

 #include <Adafruit_NeoPixel.h>
 #include <Wire.h>


fixed delayMicroseconds(0) bug in readAndReportData that was causing delays when reporting i2c data

--- examples/StandardFirmata/StandardFirmata.ino
+++ examples/StandardFirmata/StandardFirmata.ino
@@ -99,7 +99,11 @@
     Wire.send((byte)theRegister);
     #endif
     Wire.endTransmission();
-    delayMicroseconds(i2cReadDelayTime);  // delay is necessary for some devices such as WiiNunchuck
+    // do not set a value of 0
+    if (i2cReadDelayTime > 0) {
+      // delay is necessary for some devices such as WiiNunchuck
+      delayMicroseconds(i2cReadDelayTime);
+    }
   } else {
     theRegister = 0;  // fill the register with a dummy value
   }


Temp sensor code roughly working with raw ds code

--- firmware/interlock/interlock.ino
+++ firmware/interlock/interlock.ino
@@ -1,4 +1,10 @@
 #include "./OneWire.h"
+
+OneWire  ds(2);  // on pin 2
+
+uint8_t temp1_ID[8] = {0x28, 0xFF, 0x6C, 0xF3, 0x64, 0x15, 0x2, 0x15};
+uint8_t temp2_ID[8] = {0x28, 0xFF, 0xD2, 0xE1, 0x64, 0x15, 0x2, 0xC7};
+uint8_t temp3_ID[8] = {0x28, 0xFF, 0xDB, 0x8D, 0x64, 0x15, 0x2, 0xB6};

 void setup() {
     Serial.begin(9600);
@@ -7,5 +13,103 @@

 void loop() {
+  byte i;
+  byte present = 0;
+  byte type_s;
+  byte data[12];
+  byte addr[8];
+  float celsius;

+  if ( !ds.search(addr)) {
+    Serial.println("No more addresses.");
+    Serial.println();
+    ds.reset_search();
+    delay(10000);
+    return;
+  }
+
+/**  Serial.print("ROM =");
+  for( i = 0; i < 8; i++) {
+    Serial.write(' ');
+    Serial.print(addr[i], HEX);
+  }**/
+/**
+  if (OneWire::crc8(addr, 7) != addr[7]) {
+      Serial.println("CRC is not valid!");
+      return;
+  }
+  Serial.println();**/
+
+
+	if (memcmp(addr, temp1_ID, sizeof(addr)) == 0) {
+        Serial.println("ARRAYS EQUAL");
+    } else {
+        Serial.println("ARRAYS UNEQUAL");
+    }
+
+/**  // the first ROM byte indicates which chip
+  switch (addr[0]) {
+    case 0x10:
+      Serial.println("  Chip = DS18S20");  // or old DS1820
+      type_s = 1;
+      break;
+    case 0x28:
+      Serial.println("  Chip = DS18B20");
+      type_s = 0;
+      break;
+    case 0x22:
+      Serial.println("  Chip = DS1822");
+      type_s = 0;
+      break;
+    default:
+      Serial.println("Device is not a DS18x20 family device.");
+      return;
+  }**/
+
+  ds.reset();
+  ds.select(addr);
+  ds.write(0x44, 1);        // start conversion, with parasite power on at the end
+
+  delay(1000);     // maybe 750ms is enough, maybe not
+  // we might do a ds.depower() here, but the reset will take care of it.
+
+  present = ds.reset();
+  ds.select(addr);
+  ds.write(0xBE);         // Read Scratchpad
+
+  Serial.print("  Data = ");
+  Serial.print(present, HEX);
+  Serial.print(" ");
+  for ( i = 0; i < 9; i++) {           // we need 9 bytes
+    data[i] = ds.read();
+    Serial.print(data[i], HEX);
+    Serial.print(" ");
+  }
+  Serial.print(" CRC=");
+  Serial.print(OneWire::crc8(data, 8), HEX);
+  Serial.println();
+
+  // Convert the data to actual temperature
+  // because the result is a 16 bit signed integer, it should
+  // be stored to an "int16_t" type, which is always 16 bits
+  // even when compiled on a 32 bit processor.
+  int16_t raw = (data[1] << 8) | data[0];
+  if (type_s) {
+    raw = raw << 3; // 9 bit resolution default
+    if (data[7] == 0x10) {
+      // "count remain" gives full 12 bit resolution
+      raw = (raw & 0xFFF0) + 12 - data[6];
+    }
+  } else {
+    byte cfg = (data[4] & 0x60);
+    // at lower res, the low bits are undefined, so let's zero them
+    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
+    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
+    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
+    //// default is 12 bit resolution, 750 ms conversion time
+  }
+  celsius = (float)raw / 16.0;
+  Serial.print("  Temperature = ");
+  Serial.print(celsius);
+  Serial.println(" Celsius ");
 }


Changed Hello World example to reflect changes in setup

--- libraries/BLE/examples/ble_A_Hello_World_Program/ble_A_Hello_World_Program.ino
+++ libraries/BLE/examples/ble_A_Hello_World_Program/ble_A_Hello_World_Program.ino
@@ -290,6 +290,8 @@

 void aci_loop()
 {
+  static bool setup_required = false;
+
   // We enter the if statement only when there is a ACI event available to be processed
   if (lib_aci_event_get(&aci_state, &aci_data))
   {
@@ -302,20 +304,17 @@
         As soon as you reset the nRF8001 you will get an ACI Device Started Event
         */
         case ACI_EVT_DEVICE_STARTED:
-        {
+        {
           aci_state.data_credit_total = aci_evt->params.device_started.credit_available;
           switch(aci_evt->params.device_started.device_mode)
           {
             case ACI_DEVICE_SETUP:
-            /**
-            When the device is in the setup mode
-            */
-            Serial.println(F("Evt Device Started: Setup"));
-            if (ACI_STATUS_TRANSACTION_COMPLETE != do_aci_setup(&aci_state))
-            {
-              Serial.println(F("Error in ACI Setup"));
-            }
-            break;
+              /**
+              When the device is in the setup mode
+              */
+              Serial.println(F("Evt Device Started: Setup"));
+              setup_required = true;
+              break;

             case ACI_DEVICE_STANDBY:
               Serial.println(F("Evt Device Started: Standby"));
@@ -481,6 +480,18 @@
     // Arduino can go to sleep now
     // Wakeup from sleep from the RDYN line
   }
+
+  /* setup_required is set to true when the device starts up and enters setup mode.
+   * It indicates that do_aci_setup() should be called. The flag should be cleared if
+   * do_aci_setup() returns ACI_STATUS_TRANSACTION_COMPLETE.
+   */
+  if(setup_required)
+  {
+    if (SETUP_SUCCESS == do_aci_setup(&aci_state))
+    {
+      setup_required = false;
+    }
+  }
 }

 String inputString     = "";     // a string to hold incoming data


Update rf-laptimer.ino

Update rf-laptimer.ino

--- Arduino/rf-laptimer/rf-laptimer.ino
+++ Arduino/rf-laptimer/rf-laptimer.ino
@@ -55,7 +55,7 @@
 // single analog read with FASTADC defined (see below) takes ~20us on 16MHz arduino
 // so e.g. 10 reads will take 200 ms, which gives resolution of 5 RSSI reads per ms,
 // this means that we can theoretically have 1ms timing accuracy :)
-#define RSSI_READS 2 // 5 should give about 10 000 readings per second 5/16Mhz 2/8Mhz
+#define RSSI_READS 2 // 5 should give about 10 000 readings per second 5 too mutch, not precise

 // input control byte constants
 #define CONTROL_START_RACE 1
@@ -71,7 +71,7 @@
 #define CONTROL_DATA_REQUEST 255

 //----- RSSI --------------------------------------
-#define FILTER_ITERATIONS 3 // 5/16Mhz 3/8Mhz
+#define FILTER_ITERATIONS 3 // 5 too mutch, not precise
 uint16_t rssiArr[FILTER_ITERATIONS + 1];
 uint16_t rssiThreshold = 0;
 uint16_t rssi;


added SERIAL_BUFFER_SIZE
 definition, not sure if that will work

Signed-off-by: lolportal <1888343070d06eb06df67f855bc7a1b14a557af6@gmail.com>

--- Connection_controller/Connection_controller.ino
+++ Connection_controller/Connection_controller.ino
@@ -32,6 +32,15 @@
 // Размерности глобальных переменных определяются через дефайны, объявленные в предыдущем h-файле, поэтому их надо объявлять после i2c_packet_sizes_and_variables.h
 #include "global_variables.h" //глобальные переменные для функций бортового канала связи

+#ifdef SERIAL_BUFFER_SIZE
+	#if (SERIAL_BUFFER_SIZE != 128)
+		#define SERIAL_BUFFER_SIZE 128
+		#warning Serial Buffer Size was redefined and set to 128
+	#endif
+#else
+#define SERIAL_BUFFER_SIZE 128
+#warning Serial Buffer Size was undefined, now set to 128
+#endif

 void setup()
 {


Testing Different Filters

Testing Different Filters

No great results

--- AL5D/al5d.ino
+++ AL5D/al5d.ino
@@ -434,8 +434,8 @@
 {
    double s = pulseToDeg( SHL, g_pulse[SHL] ), e = pulseToDeg( ELB, g_pulse[ELB] ) - 180, w = pulseToDeg( WRI, g_pulse[WRI] ) - 180;
    getFeedback();
-   double uln_r = ULN_R_GRADIENT*g_uln_r.mean() + ULN_R_OFFSET;
-   double uln_h = ULN_H_GRADIENT*g_uln_h.mean() + ULN_H_OFFSET;
+   double uln_r = ULN_R_GRADIENT*analogRead(ULN_R_PIN) + ULN_R_OFFSET;
+   double uln_h = ULN_H_GRADIENT*analogRead(ULN_H_PIN) + ULN_H_OFFSET;
    double uln_angle_d = degrees(  atan2(uln_h,uln_r) );
    DEBUG("uln_r: "); DEBUG(uln_r); DEBUG(", uln_h: "); DEBUG(uln_h); DEBUG(", uln_angle_d: "); DEBUGln(uln_angle_d);
    Serial.print((double)millis()/1000.0f); Serial.print("\t"); Serial.print(uln_angle_d); Serial.print("\t"); Serial.println(s + e);
@@ -522,7 +522,7 @@
   uint32_t count = 0;
   while ( micros() - start < delay_ )
   {
-    if ( count % 5 == 0 ) getFeedback();
+    //if ( count % 5 == 0 ) getFeedback();
     count++;
   }

@@ -600,7 +600,7 @@
          case 'p':
             servoWrite(GRI,GRI_MICROPLATE); Serial.println("Gripped Microplate"); break;
          case 'r':
-            if( ( ret_val = slowMoveArm(BAS_PARK,SHL_PARK,ELB_PARK,WRI_PARK,5,1) ) == 0 ) { Serial.print("("); Serial.print(BAS_PARK); Serial.print(","); Serial.print(SHL_PARK); Serial.print(","); Serial.print(ELB_PARK), Serial.print(","); Serial.print(WRI_PARK); Serial.println(")"); }
+            if( ( ret_val = slowMoveArm(BAS_PARK,SHL_PARK,ELB_PARK,WRI_PARK,5,1) ) == 0 ) { }//Serial.print("("); Serial.print(BAS_PARK); Serial.print(","); Serial.print(SHL_PARK); Serial.print(","); Serial.print(ELB_PARK), Serial.print(","); Serial.print(WRI_PARK); Serial.println(")"); }
             else Serial.println(ret_val);
             break;
          case 'R':
@@ -608,7 +608,7 @@
             else Serial.println(ret_val);
             break;
          case 't':
-            if( ( ret_val = slowMoveArm(90,90,90,90,5,1) ) == 0 ) Serial.println("(90,90,90,90)");
+            if( ( ret_val = slowMoveArm(90,90,90,90,5,1) ) == 0 ) { } //Serial.println("(90,90,90,90)");
             else Serial.println(ret_val);
             break;


Updated Arduino code to create simple protocol

Signed-off-by: Frank de Brabander <cafd918d3f784876b41d5a8d7ac77a2c4861b9fe@gmail.com>

--- WeatherStation.ino
+++ WeatherStation.ino
@@ -7,10 +7,9 @@

 void loop() {
   Serial.print((double) bmp085_get_temperature() / 10);
-  Serial.print(" C, ");
-
+  Serial.print(" ");
   Serial.print((double) bmp085_get_pressure() / 100);
-  Serial.println(" hPa");
+  Serial.println();

   delay(1000);
 }


Updated comments to address new bootloader

--- RGBShades.ino
+++ RGBShades.ino
@@ -7,7 +7,16 @@
 //   ZIP file https://github.com/FastLED/FastLED/archive/master.zip
 //
 //   Use Arduino IDE 1.0 or later
-//   Select device "Arduino Pro or Pro Mini (5V, 16MHz) w/ATmega328
+//
+//   If your RGB Shades were purchased before July 2015:
+//     This version has the standard Arduino bootloader. R9 and R10 near the control buttons will be present.
+//     Select the “Arduino Pro or Pro Mini” option.
+//     Then, go back into the Tools menu and find the Processor option and select “ATmega328 (5V, 16MHz)”.
+//
+//   If your RGB Shades were purchased after July 2015:
+//     This version has the Optiboot bootloader. R9 and 10 near the control buttons will be missing.
+//     Select the “Arduino Mini” option.
+//     Then, go back into the Tools menu and find the Processor option and select “ATmega328”.
 //
 //   [Press] the SW1 button to cycle through available effects
 //   Effects will also automatically cycle at startup


Minor changes to telemetry

Minor changes to telemetry

--- RobotBase.ino
+++ RobotBase.ino
@@ -17,7 +17,6 @@
 #define MOTOR_DISABLE_PIN 8

 // uptime //
-byte NewSecond = 0;
 byte HalfSecond = 0;
 unsigned long uptimeSeconds = 0;

@@ -30,35 +29,35 @@
 byte crc = 0;

 // power measurment //
-#define AMPS_SIZE 30
+#define AMPS_SIZE 20
 #define AMPS_INTERVAL 50
 int amps[AMPS_SIZE];
 byte ampsIndex = 0;
 unsigned long lastAmpsTime = 0;
-long uAh = 0;
+long uAh = 0; // coulomb counter
 Adafruit_INA219 ina219;

+// in-robot display //
 #define DISPLAY_ALTER_INTERVAL 1500
 TM1650 tm;
 unsigned long lastTmTime = 0;
 int tmMode = 0;

 // common vars //
+#define COMMAND_TIMEOUT 1200
 unsigned long lastCommandTime;
-unsigned long commandTimeout = 2500;
 boolean IsConnected = false;

-// RoboClaw //
+// drive //
 #define RC_ADDR 0x80
-RoboClaw roboclaw(DRIVER_RX_PIN, DRIVER_TX_PIN);
-boolean driveEnabled = false;
-unsigned long lastDriveCommandTime;
-unsigned long driveCommandTimeout = 20000;
+#define DRIVE_COMMAND_TIMEOUT 20000
 #define MOTOR_COUNTER_START 3000
 #define MOTOR_TARGET_MAX 127
 #define MOTOR_VELOCITY_0 64
 #define MOTOR_VELOCITY_MAX 63
-#define MOTOR_TARGET_MAX 127
+RoboClaw roboclaw(DRIVER_RX_PIN, DRIVER_TX_PIN);
+boolean driveEnabled = false;
+unsigned long lastDriveCommandTime;
 byte motor1 = MOTOR_VELOCITY_0;
 byte motor1_target = MOTOR_VELOCITY_0;
 byte motor2 = MOTOR_VELOCITY_0;
@@ -66,7 +65,7 @@
 byte motor_increment = 5;
 unsigned int motor_counter = 0;

-// servo controller
+// servo controller //
 BMSerial ssc(SSC_RX_PIN, SSC_TX_PIN);
 MiniMaestro maestro(ssc);

@@ -119,7 +118,7 @@
   // serial input
   ReadSerial();
   if (IsConnected) CheckCommandTimeout();
-  if (driveEnabled) CheckDriveCommandTimeout();
+  if (driveEnabled) checkDriveCommandTimeout();
   ReadAmps();
   DisplayVA();

@@ -130,19 +129,15 @@

 void MaintainUptime()
 {
-  if (millis() % 1000 <= 500 && HalfSecond == 0)
-  {
-    NewSecond = 1;
+  unsigned long x = millis() % 1000;
+
+  if (x <= 500 && HalfSecond == 0)
+  {
+    uptimeSeconds++;
     HalfSecond = 1;
   }

-  if (millis() % 1000 > 500) HalfSecond = 0;
-
-  if (NewSecond == 1)
-  {
-    uptimeSeconds++;
-    NewSecond = 0;
-  }
+  if (x > 500) HalfSecond = 0;
 }

 //=======================================
@@ -150,43 +145,62 @@
 //          in-robot Volts/Amps measurment

 //=======================================
+
+void ResetAmps()
+{
+  uAh = 0;
+  for (int i = 0; i < AMPS_SIZE; i++) amps[i] = 0;
+}

 void ReadAmps()
 {
   unsigned long ampsTime = millis();
   if (ampsTime < lastAmpsTime) lastAmpsTime = 0;
-  if (ampsTime - lastAmpsTime > AMPS_INTERVAL)
+  if (ampsTime - lastAmpsTime >= AMPS_INTERVAL)
   {
     lastAmpsTime = ampsTime;
-    amps[ampsIndex] = int(ina219.getCurrent_mA());
+    amps[ampsIndex] = int(ina219.getCurrent_mA());
+
+    // reset uAh counter on charge begin/end
+    int prev, cur;
+    cur = amps[ampsIndex];
+    if (ampsIndex > 0) prev = amps[ampsIndex - 1]; else prev = amps[AMPS_SIZE - 1];
+    if ((cur > 0 && prev < 0) || (cur < 0 && prev > 0))
+    {
+      ResetAmps();
+      return;
+    }
+
     ampsIndex++;
     if (ampsIndex >= AMPS_SIZE)
     {
       ampsIndex = 0;
-      UpdateUAh();
-    }
-  }
-}
-
-int getAvgAmps()
+      Update_uAh();
+    }
+  }
+}
+
+float getAvgAmps()
 {
   long ampsSum = 0;
   for (int i = 0; i < AMPS_SIZE; i++) ampsSum += amps[i];
-  return int(ampsSum / AMPS_SIZE);
-}
-
-void UpdateUAh()
-{
-  int mA = getAvgAmps();
-  uAh += int(mA * 5 / 12);
+  return ampsSum / AMPS_SIZE;
+}
+
+void Update_uAh()
+{
+  float mA = getAvgAmps();
+  uAh += int(mA * 5 / 18);
 }

 void DisplayVA()
 {
   unsigned long tmTime = millis();
   if (tmTime < lastTmTime) lastTmTime = 0;
-  if (tmTime - lastTmTime > DISPLAY_ALTER_INTERVAL)
-  {
+  if (tmTime - lastTmTime >= DISPLAY_ALTER_INTERVAL)
+  {
+    lastTmTime = tmTime;
+
     if (tmMode == 0)
     {
       displayVolts();
@@ -205,20 +219,18 @@
       tm.displayString("CONN");
       tmMode = 0;
     }
-
-    lastTmTime = tmTime;
   }
 }

 void displayVolts()
 {
-    int voltage = int(ina219.getBusVoltage_V() * 100);
-    displayInt(voltage, 2);
+  int voltage = int(ina219.getBusVoltage_V() * 100);
+  displayInt(voltage, 2);
 }

 void displayAmps()
 {
-  int mA = getAvgAmps();
+  int mA = abs(int(getAvgAmps()));
   displayInt(mA, 1);
 }

@@ -292,10 +304,9 @@

 void CheckCommandTimeout()
 {
-  if (commandTimeout == 0) return;
   unsigned long commandTime = millis();
   if (commandTime >= lastCommandTime) commandTime -= lastCommandTime; else lastCommandTime = 0;
-  if (commandTime > commandTimeout) OnDisconnected();
+  if (commandTime > COMMAND_TIMEOUT) OnDisconnected();
 }

 void OnDisconnected()
@@ -372,7 +383,7 @@
 void telemetry()
 {
   int mV = int(ina219.getBusVoltage_V() * 1000);
-  int mA = getAvgAmps();
+  int mA = int(getAvgAmps());
   Serial.write('b');
   Serial.println(mV);
   Serial.write('a');
@@ -549,12 +560,11 @@
   else pulsePin(MOTOR_DISABLE_PIN, 20);
 }

-void CheckDriveCommandTimeout()
-{
-  if (driveCommandTimeout == 0) return;
+void checkDriveCommandTimeout()
+{
   unsigned long driveCommandTime = millis();
   if (driveCommandTime >= lastDriveCommandTime) driveCommandTime -= lastDriveCommandTime; else lastDriveCommandTime = 0;
-  if (driveCommandTime > driveCommandTimeout) driveEnable(false);
+  if (driveCommandTime > DRIVE_COMMAND_TIMEOUT) driveEnable(false);
 }

 //=======================================


Ready to work on tick jitter problem

Ready to work on tick jitter problem


Don't log aftertouch messages

Don't log aftertouch messages

--- roto.ino
+++ roto.ino
@@ -354,6 +354,12 @@
 // Electro 3 MIDI implementation:
 // http://www.nordkeyboards.com/sites/default/files/files/downloads/manuals/nord-electro-3/Nord%20Electro%203%20English%20User%20Manual%20v3.x%20Edition%203.1.pdf
 void handleControlChange(byte chan, byte ctrl, byte val) {
+    if (ctrl == 1) {
+	// Skip logging aftertouch messages, so the serial log isn't
+	// spammed with them.
+	return;
+    }
+
     Serial.print("Control Change, ch=");
     Serial.print(chan, DEC);
     Serial.print(", control=");


add PortWriteInterface, Port_ShiftRegs

add PortWriteInterface, Port_ShiftRegs

--- examples/keybrd_DH_shift_registers_demo/sr0_LED_shiftRegs/sr0_LED_shiftRegs.ino
+++ examples/keybrd_DH_shift_registers_demo/sr0_LED_shiftRegs/sr0_LED_shiftRegs.ino
@@ -23,7 +23,8 @@

 //LEDs
 #include <LED_uC.h>
-#include <LED_shiftRegs.h>
+#include <Port_ShiftRegs.h>
+#include <LED_ShiftReg.h>

 // ============ SPEED CONFIGURATION ============
 ScanDelay scanDelay(9000);
@@ -33,17 +34,19 @@
 Scanner_ShiftRegsPISOMultiRow scanner_L(HIGH, 6, 1); //active HIGH, SS pin 6, 1 byte

 // ----------------- LEFT LED ------------------
-LED_uC LED_capsLck(4);              //pin 4
+LED_uC LED_left(4);                             //pin 4

 // ---------------- RIGHT LEDs -----------------
-LED_shiftRegs LED_normal(8, 1<<6);  //SS 8, pin 6
-LED_shiftRegs LED_fn(8, 1<<7);      //SS 8, pin 7
+Port_ShiftRegs shiftRegs(8);                    //slave select 8
+
+LED_ShiftReg LED_rightTop(shiftRegs, 1<<6);     //pin 6
+LED_ShiftReg LED_rightBot(shiftRegs, 1<<7);     //pin 7

 // =================== CODES ===================
 // ---------------- LAYER CODE -----------------
 enum layerIds { NORMAL, FN };

-LEDInterface* prtsLayerLEDs[] = { &LED_normal, &LED_fn };
+LEDInterface* prtsLayerLEDs[] = { &LED_rightTop, &LED_left };
 LayerState_LED layerState(prtsLayerLEDs);

 Code_LayerHold l_fn(FN, layerState);
@@ -52,7 +55,7 @@
 Code_Sc s_a(KEY_A);
 Code_Sc s_x(KEY_X);
 Code_Sc s_1(KEY_1);
-Code_LEDLock o_capsLock(KEY_CAPS_LOCK, LED_capsLck);
+Code_LEDLock o_capsLock(KEY_CAPS_LOCK, LED_rightBot);

 // =================== KEYS ====================
 Key* const ptrsKeys_01[] = { &s_a, &s_1 };


update track info when returning to AUX screen

--- IBusCDC.ino
+++ IBusCDC.ino
@@ -286,6 +286,8 @@
       cdc_setPlaying(false);

       _ibus_persistState();
+    } else {
+      cdc_displayTrackinfoStrings();
     }
     return;
   }
@@ -412,4 +414,4 @@

 void bus_tx(uint8_t c) {_ibus_tx(c);}
 #endif
-
+


changed spray to 15min 7 to 19

changed spray to 15min 7 to 19

--- SprayCan/SprayCanProject/SprayCanProject.ino
+++ SprayCan/SprayCanProject/SprayCanProject.ino
@@ -44,8 +44,10 @@
 #define RTC_BASE 64
 byte rtcStore[3];
 uint32_t nextSleep, startTime;
-#define TEN_MIN_TIME 10*60*1000000    // 10 min
+#define ONE_SEC_TIME       1000000   //  1 sec
+#define FIF_MIN_TIME 15*60*1000000    // 15 min
 #define ONE_HOU_TIME 60*60*1000000   //  1 hour
+

 // Time related Valriables
 unsigned int localPort = 2390;      // local port to listen for UDP packets
@@ -62,7 +64,7 @@

   startTime = system_get_time();

-  nextSleep = TEN_MIN_TIME;
+  nextSleep = FIF_MIN_TIME;
   pinMode(14, OUTPUT);
   digitalWrite(14, LOW);

@@ -98,6 +100,8 @@
         message = message + " Power Up Time: " + hh + ":" + mm + ":" + ss;
         message = message + " Count: ";
         message = message + rtcStore[2];
+        message = message + " sleep time : ";
+        message = message + (nextSleep / 60000000);

         if (ESP.getVcc() < 2650) {
           subject = "WARNING: Battery LOW - " + subject;
@@ -113,7 +117,7 @@
       }
       break;
     case STATE_SLEEP_WAKE:
-      if (rtcStore[2] < 72) {
+      if (rtcStore[2] < 48) {
         doWork();
       } else {
         if (connectToInternet()) {
@@ -123,15 +127,17 @@
           subject = subject + rtcStore[2];
           String message =  "Battery Power: ";
           message = message + ESP.getVcc();
+          message = message + " sleep time : ";
+          message = message + (nextSleep / 60000000);
           sendEmail(subject, message);
           disconnectInternet();
         }
-
+        nextSleep = ONE_HOU_TIME;
       }
-      if (rtcStore[2] >= 83) {
+      if (rtcStore[2] >= 59) {
         rtcStore[1] = STATE_HOUSKEEPING;
         system_rtc_mem_write(RTC_BASE, rtcStore, 3);
-        nextSleep = ONE_HOU_TIME - TEN_MIN_TIME;
+        nextSleep = 1000000;
         ESP.deepSleep(nextSleep, WAKE_RFCAL);
       }
       break;
@@ -146,6 +152,9 @@
         message = message + ESP.getVcc();
         message = message + " Power Up Time: " + hh + ":" + mm + ":" + ss;

+        message = message + " sleep time : ";
+        message = message + (nextSleep / 60000000);
+
         if (ESP.getVcc() < 2650) {
           subject = "WARNING: Battery LOW - " + subject;
         }
@@ -154,6 +163,9 @@
         sendEmail(subject, message);
         disconnectInternet();
         rtcStore[1] = STATE_SLEEP_WAKE;
+        if (rtcStore[2] >= 84) {
+          rtcStore[2] = 255;
+        }
         system_rtc_mem_write(RTC_BASE, rtcStore, 3);
       }
       break;
@@ -164,10 +176,6 @@

   uint32_t runtime = system_get_time() - startTime;
   nextSleep = nextSleep - runtime;
-
-  if (nextSleep < 1) {
-    nextSleep = ONE_HOU_TIME;
-  }

   Serial.print("Next sleep : ");
   Serial.println(nextSleep);
@@ -340,6 +348,9 @@
     subject =  subject + rtcStore[2];
     String message =  "Battery Power: ";
     message = message + ESP.getVcc();
+    message = message + " sleep time : ";
+    message = message + (nextSleep / 60000000);
+
     sendEmail(subject, message);
     disconnectInternet();
   }
@@ -351,7 +362,7 @@
 }

 uint32_t doCalculation() {
-  uint32_t nextSleep = TEN_MIN_TIME;
+  uint32_t nextSleep = FIF_MIN_TIME;

   byte _hh = hh - 7;
   _hh = _hh % 24;
@@ -364,12 +375,12 @@

   if (_hh < 12) {
     Serial.print("remaining time in seconds to next slot: ");
-    nextSleep = (timeInSecs % 600);
-    nextSleep = 600 - nextSleep;
+    nextSleep = (timeInSecs % 900);
+    nextSleep = 900 - nextSleep;
     nextSleep = nextSleep * 1000000;
     Serial.println(nextSleep);

-    rtcStore[2] = timeInSecs / 600;
+    rtcStore[2] = timeInSecs / 900;
     system_rtc_mem_write(RTC_BASE, rtcStore, 3);
     Serial.println("Count : ");
     Serial.println(rtcStore[2]);
@@ -384,7 +395,7 @@
     Serial.println(nextSleep);

     _hh = _hh - 12;
-    _hh = _hh + 72;
+    _hh = _hh + 47;
     rtcStore[2] = _hh;
     system_rtc_mem_write(RTC_BASE, rtcStore, 3);

@@ -392,7 +403,7 @@
     Serial.println(rtcStore[2]);

   }
-
+
   startTime = system_get_time();
   return nextSleep;
 }


Code update ...

Code update ...

--- i2c_cmd_slave_attiny85/i2c_cmd_slave_attiny85.ino
+++ i2c_cmd_slave_attiny85/i2c_cmd_slave_attiny85.ino
@@ -21,7 +21,7 @@
 // d - (STANAPB3) Set ATtiny85 PB3 = PWMx (the command asks for a PWM value input)
 // f - (READADC2) Read ATtiny85 ADC2 (the reply has 2 data bytes + 1 CRC byte)
 //
-// Setup:
+// Connections:
 // AtTiny Pin 5 (PB0/SDA) = I2C SDA
 //     connect to SDA on master with external pull-up (~4.7K)
 // AtTiny Pin 7 (PB0/SCL) = I2C SCL


Fixed up an error in frame sending where the command byte was left out.

--- GVRET.ino
+++ GVRET.ino
@@ -102,18 +102,19 @@

 	if (frame.extended) frame.id |= 1 << 31;
 	buff[0] = 0xF1;
-	buff[1] = (uint8_t)(frame.id & 0xFF);
-	buff[2] = (uint8_t)(frame.id >> 8);
-	buff[3] = (uint8_t)(frame.id >> 16);
-	buff[4] = (uint8_t)(frame.id >> 24);
-	buff[5] = frame.length + (uint8_t)(whichBus << 4);
+	buff[1] = 0; //0 = canbus frame sending
+	buff[2] = (uint8_t)(frame.id & 0xFF);
+	buff[3] = (uint8_t)(frame.id >> 8);
+	buff[4] = (uint8_t)(frame.id >> 16);
+	buff[5] = (uint8_t)(frame.id >> 24);
+	buff[6] = frame.length + (uint8_t)(whichBus << 4);
 	for (int c = 0; c < frame.length; c++)
 	{
-		buff[6 + c] = frame.data.bytes[c];
+		buff[7 + c] = frame.data.bytes[c];
 	}
-	temp = checksumCalc(buff, 6 + frame.length);
+	temp = checksumCalc(buff, 7 + frame.length);
 	buff[6 + frame.length] = temp;
-	SerialUSB.write(buff, 7 + frame.length);
+	SerialUSB.write(buff, 8 + frame.length);
 }

 /*


reduce delay in send back device id

reduce delay in send back device id

--- client/client.ino
+++ client/client.ino
@@ -225,7 +225,7 @@
 }

 void sendBackDeviceID() {
-  randomDelay = random(1000);
+  randomDelay = random(500);
   // avoid conflicts
   delay(randomDelay);
   DEBUG_TAGGING("IR received: ", "sending back device ID");


have client identify the type (lamp or laptop) by themselves

--- client/client.ino
+++ client/client.ino
@@ -48,6 +48,9 @@
 #define statusOff 0
 #define statusPending 1
 #define statusOn 2
+
+const char deviceLaptop[3] = "01";
+const char deviceLamp[3] = "02";

 void setup()
 {
@@ -82,8 +85,14 @@
     }
     else if (atoi(p.id) == atoi(deviceId)) {
       // pass this message to the function of client
+      if(deviceId == deviceLaptop) {
+        laptopBridging(p);
+      } else if(deviceId == deviceLamp) {
+        lampClient(p);
+      }
+
       // laptopBridging(p);
-      lampClient(p);
+      // lampClient(p);
     }
   }
 }


changed the led to dynamically toggling indicating being selected

--- client/client.ino
+++ client/client.ino
@@ -21,6 +21,7 @@
 char deviceId[3] = "??";
 char XBeeInString[50];
 int state = IDLE;
+unsigned int ledStateInterval = 500;
 unsigned long randomDelay = 0;
 unsigned long start_time;
 unsigned long end_time;
@@ -107,30 +108,33 @@
   case PENDING:
     end_time = millis();

-    if(end_time - toggle_time > 200) {
+    if(end_time - toggle_time > ledStateInterval) {
       digitalToggle(ledStatePin);
       toggle_time = millis();
     }

-    // soft timer expires
-    if (end_time - start_time > DELAY_IN_WAIT/1000) {
+    // soft timer expires, this should be long enough, 20 seconds
+    if (end_time - start_time > DELAY_IN_WAIT/50) {
       Serial.println("[PENDING] Timer expires, back to IDLE");
       // timeout, return to IDLE
       state = IDLE;
     }
+
     if(XBee.available()) {
       // delay for the complete of transmission
       delay(10);
       Serial.println("[WAIT] Reading Packet");
       struct XBeePacket p = readXBeePacket(&XBee);
       printXBeePacket(p);
+      // packet not error
+      if (p.type[0] != 'e') {
+	start_time = millis();
+      }
+

       if (atoi(p.id) == atoi(deviceId) && p.type[0] == 'c') {
       	// have been confirmed
       	Serial.println("[CONNECTED] entering state");
-
-      	// turn on the ligth to indicate
-      	digitalWrite(ledStatePin, HIGH);

       	state = CONNECTED;
       }
@@ -140,13 +144,14 @@
       	Serial.println("[WAIT] being verified");

       	// may flash the light to indicate this
-
+      	ledStateInterval = 200;
       	state = PENDING;
       }
       // verifying this selection
       else if (atoi(p.id) != atoi(deviceId) && p.type[0] == 'v') {
       	// have been confirmed
       	Serial.println("[WAIT] verifying others");
+	ledStateInterval = 500;
       	state = PENDING;
       }
       else {
@@ -157,8 +162,8 @@
     break;

   case CONNECTED:
-
     // temporarily for debugging
+    // turn on the ligth to indicate
     digitalWrite(ledStatePin, HIGH);
     delay(10000);
     state = IDLE;


Rewrote for PID

Rewrote for PID

--- brewtus_controller.ino
+++ brewtus_controller.ino
@@ -1,10 +1,11 @@
-// Sketch to use an Arduino as tempcontroller
+// Sketch to use an Arduino as tempcontroller
 // in an Expobar Brewtus II espresso machine

 //--> Import libraries <--
 #include <OneWire.h>
 #include <DallasTemperature.h>
 #include <LiquidCrystal.h>
+#include <PID_v1.h>

 //--> Setup variables <--
@@ -18,13 +19,21 @@

 // Timing
 long previousMillis = 0;
-long tempInterval = 2000;
+long tempInterval = 1000;
+
+// PID
+double setpoint = 95;
+double input = 0;
+double oldInput = 0;
+double output;
+int windowSize = 5000;
+unsigned long windowStartTime;

 // Defaults
 int displayMode = 0;
 float temp = 0;
 float oldTemp = 0;
-boolean relayStatus = false;
+boolean relayStatus = true;
 boolean oldRelayStatus = false;
 boolean refreshDisplay = true;

@@ -57,7 +66,7 @@
 // Setup a oneWire instance to communicate with any OneWire devices
 OneWire oneWire(ONE_WIRE_BUS);

-// Pass our oneWire reference to Dallas Temperature.
+// Pass our oneWire reference to Dallas Temperature.
 DallasTemperature sensors(&oneWire);
 DeviceAddress tempProbe = { 0x28, 0x2D, 0x48, 0x4E, 0x05, 0x00, 0x00, 0xF5 };
 //DeviceAddress tempProbe = { 0x28, 0xFF, 0x70, 0xFC, 0x10, 0x14, 0x00, 0xDB };
@@ -65,32 +74,41 @@
 // Initialize LCD display
 LiquidCrystal lcd(5, 4, 0, 1, 2, 3);

+// Setup PID
+#define RelayPin 11
+PID myPID(&input, &output, &setpoint,1600,8,0, DIRECT);
+

 //--> Arduino Setup <--

 void setup(void)
 {
-  // Setup the LCD
+  // Setup the LCD
   lcd.begin(16, 2);
   lcd.createChar(1, on);
   lcd.createChar(2, off);
   // Print startup message to LCD
   lcd.clear();
   lcd.print("-= Brewtus II =-");
-
+
   // start serial port
-  //Serial.begin(9600);
-
+  Serial.begin(9600);
+
   // Setup relay pin
   pinMode(relayPin, OUTPUT);
-
+
   // Start up the sensors library
   sensors.begin();
   // set the resolution to 10 bit
-  sensors.setResolution(tempProbe, 10);
+  sensors.setResolution(tempProbe, 12);
+
+  // Setup PID
+  windowStartTime = millis();
+  myPID.SetOutputLimits(0, windowSize);
+  myPID.SetMode(AUTOMATIC);

   // Add a delay to show the "boot screen"
-  delay(2000);
+  delay(2000);
 }

@@ -130,20 +148,20 @@
   }
 }

-void printDisplay(int mode){
+void printDisplay(int mode, double temp, boolean relayStatus){
   if (mode == 0){
     lcd.clear();
     lcd.print("Temp: ");
     if (temp == 0.00) {
       lcd.print("Read Error");
-    }
+    }
     else {
       lcd.print(temp);
       lcd.print((char)223);
     }
     lcd.setCursor(0,1);
     lcd.print(" Set: ");
-    lcd.print(desiredTemp, 0);
+    lcd.print(setpoint, 0);
     lcd.print((char)223);
     lcd.print(" Heat:");
     if (relayStatus == true){
@@ -160,27 +178,61 @@
 //--> Arduino Main Loop <--

 void loop(void){
-  unsigned long currentMillis = millis();
-
-  // Is it time to check the temp?
-  if(currentMillis - previousMillis > tempInterval) {
-    previousMillis = currentMillis;
-
-    temp = checkTemp();
-    relayStatus = controlRelay(temp, desiredTemp);
-
-    if (temp != oldTemp){
-      refreshDisplay = true;
-      oldTemp = temp;
-    }
-    else if (relayStatus != oldRelayStatus){
-      refreshDisplay = true;
-      oldRelayStatus = relayStatus;
-    }
-  }
-
-  if (refreshDisplay == true){
-    printDisplay(displayMode);
-  }
-}
-
+//  unsigned long currentMillis = millis();
+//
+//  // Is it time to check the temp?
+//  if(currentMillis - previousMillis > tempInterval) {
+//    previousMillis = currentMillis;
+//
+//    temp = checkTemp();
+//    relayStatus = controlRelay(temp, desiredTemp);
+//
+//    if (temp != oldTemp){
+//      refreshDisplay = true;
+//      oldTemp = temp;
+//    }
+//    else if (relayStatus != oldRelayStatus){
+//      refreshDisplay = true;
+//      oldRelayStatus = relayStatus;
+//    }
+//  }
+//
+//  if (refreshDisplay == true){
+//    printDisplay(displayMode);
+//  }
+
+  // PID
+  oldInput = input;
+  input = checkTemp();
+  myPID.Compute();
+
+  /************************************************
+   * turn the output pin on/off based on pid output
+   ************************************************/
+  unsigned long now = millis();
+  if (now - windowStartTime > windowSize){
+    //time to shift the Relay Window
+    windowStartTime += windowSize;
+  }
+  oldRelayStatus = relayStatus;
+  if (input == 0.00){
+    digitalWrite(RelayPin,LOW);
+    relayStatus = false;
+  }
+  else if (output > now - windowStartTime){
+    digitalWrite(RelayPin,HIGH);
+    relayStatus = true;
+  }
+  else {
+    digitalWrite(RelayPin,LOW);
+    relayStatus = false;
+  }
+
+  if (relayStatus != oldRelayStatus){
+    printDisplay(displayMode, input, relayStatus);
+  }
+  if (input != oldInput){
+    printDisplay(displayMode, input, relayStatus);
+  }
+
+}


adding ICACHE_RAM_ATTR to interrupt method moving method up

--- esp8266-anemometer.ino
+++ esp8266-anemometer.ino
@@ -17,6 +17,14 @@

 WiFiClient espClient;
 PubSubClient client(espClient);
+
+void ICACHE_RAM_ATTR Interrupt()
+{
+  if((long)(micros() - last_micros) >= debouncing_time * 1000) {
+    i++;
+    last_micros = micros();
+  }
+}

 void setup() {
   Serial.begin(115200);
@@ -53,15 +61,6 @@
   attachInterrupt(input_pin,Interrupt,RISING);
 }

-
-
-void Interrupt()
-{
-  if((long)(micros() - last_micros) >= debouncing_time * 1000) {
-    i++;
-    last_micros = micros();
-  }
-}

 void loop()
 {


#9 add receive hooks and ppm for sending

--- Node/Node.ino
+++ Node/Node.ino
@@ -32,7 +32,41 @@

 void register_receive_hooks(MqttConnector* mqtt)
 {
-
+  mqtt->on_subscribe([&](MQTT::Subscribe * sub) -> void {
+    Serial.printf("myName = %s \r\n", myName);
+    sub->add_topic(MQTT_PREFIX + "/" + myName + "/$/+");
+    sub->add_topic(MQTT_PREFIX + "/" + MQTT_CLIENT_ID + "/$/+");
+  });
+
+  mqtt->on_before_message_arrived_once([&](void) {
+    pinMode(15, OUTPUT);
+  });
+
+  mqtt->on_message([&](const MQTT::Publish & pub) { });
+
+  mqtt->on_after_message_arrived([&](String topic, String cmd, String payload) {
+    Serial.printf("topic: %s\r\n", topic.c_str());
+    Serial.printf("cmd: %s\r\n", cmd.c_str());
+    Serial.printf("payload: %s\r\n", payload.c_str());
+    if (cmd == "$/command") {
+      if (payload == "ON") {
+        digitalWrite(relayPin, HIGH);
+        digitalWrite(LED_BUILTIN, LOW);
+        pin_state = 1;
+      }
+      else if (payload == "OFF") {
+        digitalWrite(relayPin, LOW);
+        digitalWrite(LED_BUILTIN, HIGH);
+        pin_state = 0;
+      }
+    }
+    else if (cmd == "$/reboot") {
+      ESP.reset();
+    }
+    else {
+
+    }
+  });
 }

 void register_publish_hooks(MqttConnector* mqtt)
@@ -53,6 +87,7 @@
     data["temperature"] = sensorsData->get("temperature");
     data["pressure"] = sensorsData->get("pressure");
     data["humidity"] = sensorsData->get("humidity");
+    data["ppm"] = sensorsData->get("ppm");

   }, PUBLISH_EVERY);

@@ -227,6 +262,7 @@
   root["temperature"] = temperature;
   root["pressure"] = P;
   root["humidity"] = RH;
+  root["ppm"] = ppm;
   root.printTo(Serial);
   sensorsData = &root;


Simplify val_to_str

Simplify val_to_str


Removed old battery conversion function.

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -401,7 +401,6 @@
 {
   int rawVoltage = analogRead(board::V_BATT);
   double voltageReading = 0.008879*rawVoltage + 0.09791;
-  //0.03516*rawVoltage+0.05135;

   char output_str[128];
   snprintf(output_str, 128,


updates firmware to be able to set speed

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -217,6 +217,7 @@
       roboSetup.data.width = atoi(str+1);
     }else if(str[0]=='S'){
       roboSetup.data.speed = atoi(str+1);
+      stepAuxDelay = roboSetup.data.speed;
     }
   }
   syncRobotSetup();
@@ -324,7 +325,7 @@
     roboSetup.data.width = WIDTH;
     roboSetup.data.height = HEIGHT;
     roboSetup.data.motorSwitch = 0;
-    roboSetup.data.speed = 80;
+    roboSetup.data.speed = 40;
     roboSetup.data.penUpPos = 160;
     roboSetup.data.penDownPos = 90;
     syncRobotSetup();


Update PrintCPUandMemoryUsage.ino

Update PrintCPUandMemoryUsage.ino

Changing input from on board mic to mic jack

--- examples/01-Basic/PrintCPUandMemoryUsage/PrintCPUandMemoryUsage.ino
+++ examples/01-Basic/PrintCPUandMemoryUsage/PrintCPUandMemoryUsage.ino
@@ -50,8 +50,8 @@
   audioHardware.enable(); // activate AIC

   //Choose the desired input
-  audioHardware.inputSelect(TYMPAN_INPUT_ON_BOARD_MIC); // use the on board microphones
-  //  audioHardware.inputSelect(TYMPAN_INPUT_JACK_AS_MIC); // use the microphone jack - defaults to mic bias 2.5V
+  //audioHardware.inputSelect(TYMPAN_INPUT_ON_BOARD_MIC); // use the on board microphones
+  audioHardware.inputSelect(TYMPAN_INPUT_JACK_AS_MIC); // use the microphone jack - defaults to mic bias 2.5V
   //  audioHardware.inputSelect(TYMPAN_INPUT_JACK_AS_LINEIN); // use the microphone jack - defaults to mic bias OFF

   //Set the desired volume levels


Changing source code ....

Changing source code ....

--- tools/I2cListener/I2cListener.ino
+++ tools/I2cListener/I2cListener.ino
@@ -134,6 +134,7 @@

+/*

 // function that executes whenever data is received from master
 // this function is registered as an event, see setup()
@@ -144,4 +145,4 @@
     }
     int x = Wire.read();    // receive byte as an integer
     Serial.println(x);         // print the integer
-}+}*/


preflight checks before startup Closes #5

--- LART1.ino
+++ LART1.ino
@@ -34,7 +34,7 @@
 #include "DRA818.h"
 #include "Log.h"

-#define VERSION "Beta-0.999f"
+#define VERSION "Beta-0.999g"
 #define ADC_REFERENCE REF_5V
 #define DEBUG_APRS_SETTINGS false

@@ -200,6 +200,8 @@
        mylog.send(F("Txcr OK Chk")) ;
    } else {
        mylog.send(F("Txcr Fail Chk")) ;
+       delay(1000) ;
+       exit(0) ;
    }
    delay(500UL);

@@ -220,6 +222,8 @@
        mylog.send(buf);
     } else {
         mylog.send(F("Freq Fail"));
+       delay(1000) ;
+       exit(0) ;
     }
    delay(1000UL);

@@ -228,7 +232,8 @@
        mylog.send(buf);
     } else {
         mylog.send(F("Vol Fail"));
-
+       delay(1000) ;
+       exit(0) ;
     }

    delay(500UL);
@@ -238,6 +243,8 @@
       mylog.send(buf);
    } else {
       mylog.send( F("Filter Fail") );
+       delay(1000) ;
+       exit(0) ;
    }

    delay(500UL);


Code update ...

Code update ...

--- i2c_cmd_master_esp8266/i2c_cmd_master_esp8266.ino
+++ i2c_cmd_master_esp8266/i2c_cmd_master_esp8266.ino
@@ -202,7 +202,7 @@
         Serial.print("ESP8266 - Sending Opcode >>> ");
         Serial.print(cmdTX[0]);
         Serial.println("(STANAPB3)");
-        Serial.print("Please enter a value from 0 to 255 for this command: ");
+        Serial.print("Please enter a value between 0 and 255 for this command: ");
         while (newByte == false) {
           //operandValue = random(1, 255);
           operandValue = ReadByte();


Delete Licht.ino

Delete Licht.ino

--- Licht.ino
+++ Licht.ino
@@ -1,141 +0,0 @@
-#include <Adafruit_NeoPixel.h>
-#include <ESP8266WiFi.h>
-#include <PubSubClient.h>
-#include <string.h>
-
-#define PIN 5
-#define NUM_LEDS 8
-#define BRIGHTNESS 255
-
-Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRBW + NEO_KHZ800);
-WiFiClient espClient;
-PubSubClient client(espClient);
-
-void opening(char* topic, byte* payload, unsigned int length);
-void ring(char* topic, byte* payload, unsigned int length);
-void reset();
-
-void setup() {
-  strip.setBrightness(BRIGHTNESS);
-  strip.begin();
-  strip.show();
-
-  WiFi.begin("PIT-Hackathon", "Hackathon");
-  int t;
-  while (WiFi.status() != WL_CONNECTED) {
-    for (int i = 0; i < strip.numPixels(); i++) {
-      strip.setPixelColor(i, strip.Color( 255, 0, 0));
-      strip.show();
-      t = i - 1;
-      delay(50);
-      reset();
-      delay(50);
-    }
-  }
-  for (int i = 0; i < strip.numPixels(); i++) {
-    strip.setPixelColor(i, strip.Color( 0, 255, 0));
-    strip.show();
-  }
-  delay(60);
-  reset();
-  client.setServer("172.16.0.1", 1883);
-  if (client.connect("Kristian_NodeMCU")) {
-    client.subscribe("/theringbot/ring");
-    client.subscribe("/theringbot/opening");
-    client.setCallback(callback);
-    for (int i = 0; i < strip.numPixels(); i++) {
-      strip.setPixelColor(i, strip.Color( 255, 0, 0));
-      strip.show();
-    }
-    delay(60);
-    reset();
-    pinMode(D2, OUTPUT);
-    pinMode(D3, OUTPUT);
-    pinMode(D5, INPUT);
-    pinMode(D6, INPUT);
-    digitalWrite(D2, LOW);
-    digitalWrite(D3, LOW);
-  }
-}
-
-void loop() {
-  client.loop();
-}
-
-void callback(char* topic, byte* payload, unsigned int length) {
-  if (strcmp(topic, "/theringbot/ring") == 0) {
-    ring(topic, payload, length);
-  }
-  if (strcmp(topic, "/theringbot/opening") == 0) {
-    opening(topic, payload, length);
-  }
-
-}
-void ring(char* topic, byte* payload, unsigned int length) {
-  if ((char)payload[0] == 'k' || (char)payload[0] == 'K') {
-    for (int i = 0; i < strip.numPixels(); i++) {
-      strip.setPixelColor(i, 255, 255, 255);
-      strip.show();
-    }
-  }
-  if ((char)payload[0] == 'o' || (char)payload[0] == 'O') {
-    for (int i = 1; i < strip.numPixels(); i = i + 3) {
-      strip.setPixelColor(i, 0, 0, 255);
-      strip.show();
-    }
-  }
-  for (int t = 0; t < 10; t++) {
-    if ((char)payload[0] == 'n' || (char)payload[0] == 'N') {
-      for (int i = 1; i < strip.numPixels(); i = i + 3) {
-        strip.setPixelColor(i, 0, 255, 0);
-        strip.show();
-        delay(10);
-        reset();
-      }
-      delay(10);
-    }
-  }
-  delay(600);
-  reset();
-
-
-}
-
-void opening(char* topic, byte* payload, unsigned int length) {
-  if ((char)payload[0] == 't' || (char)payload[0] == 'T') {
-    digitalWrite(D3, LOW);
-    while (digitalRead(D5) == HIGH) {
-      for (int i = 1; i < strip.numPixels(); i = i + 3) {
-        strip.setPixelColor(i, 0, 0, 255);
-        strip.show();
-        digitalWrite(D2, HIGH);
-        delay(50);
-        reset();
-        digitalWrite(D2, LOW);
-        delay(50);
-      }
-    }
-    client.publish("/theringbot/opening", "o");
-    delay(300);
-    while (digitalRead(D6) == HIGH) {
-      for (int i = 1; i < strip.numPixels(); i = i + 3) {
-        strip.setPixelColor(i, 0, 255, 0);
-        strip.show();
-        digitalWrite(D3, HIGH);
-        delay(70);
-        reset();
-        digitalWrite(D3, LOW);
-        delay(70);
-      }
-    }
-    client.publish("/theringbot/opening", "z");
-  }
-}
-
-void reset() {
-  for(int i = 0;  i < strip.numPixels(); i++ ){
-  strip.setPixelColor(i, strip.Color( 0, 0, 0));
-  strip.show();
-  }
-}
-


Fixed tpyo

Fixed tpyo

--- MRK-1.ino
+++ MRK-1.ino
@@ -25,7 +25,7 @@
 #define LED 13
 #define leftSensor A1
 #define rightSensor A2
-#dfeine IRdriver 6
+#define IRdriver 6

 // Robot Configuration Parameters
 // Speed range is -255 -> 255


Latest Adafruit IO SSL Fingerprint

Latest Adafruit IO SSL Fingerprint

--- examples/adafruitio_secure_esp8266/adafruitio_secure_esp8266.ino
+++ examples/adafruitio_secure_esp8266/adafruitio_secure_esp8266.ino
@@ -44,7 +44,7 @@
 Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);

 // io.adafruit.com SHA1 fingerprint
-static const char *fingerprint PROGMEM = "77 00 54 2D DA E7 D8 03 27 31 23 99 EB 27 DB CB A5 4C 57 18";
+static const char *fingerprint PROGMEM = "59 3C 48 0A B1 8B 39 4E 0D 58 50 47 9A 13 55 60 CC A0 1D AF";

 /****************************** Feeds ***************************************/


phase2.ino

--- phase2.ino
+++ phase2.ino
@@ -1,42 +1,31 @@
-#include <SoftwareSerial.h>
-
-
+#include <cops_and_robbers.h>
 #include <nRF24L01.h>
 #include <packet.h>
 #include <radio.h>
+#include <sensor_struct.h>
 #include <spi.h>
+
 #include <scheduler.h>

 // constants won't change. They're used here to
 // set pin numbers:
+const int joystick_x_pin = 0;
+const int joystick_y_pin = 1;
 const int button_pin = 2;
-const int servo_x_pin = 0;
-const int servo_out_pin = 9;
-const int IR_pin = 13;

 volatile uint8_t rxflag = 0;
 // packets are transmitted to this address
 uint8_t station_addr[5] = { 0xAB, 0xAB, 0xAB, 0xAB, 0xAB };
 // this is this radio's address
 uint8_t my_addr[5] = { 0x18,0x2d,0x44,0x54,0xfb };
-//uint8_t my_addr[5] = {'Z','Z','Z','Z','Z' };
 radiopacket_t packet;

 void check_button(){
   // read the state of the switch into a local variable:
   int val = analogRead(button_pin);
-//  Serial.println(val);
   if( val < 50 ){
-   // send the data
-//   Serial.println((char *)packet.payload.message.messagecontent);
-//   Serial.println((char *)packet.payload.message.address);
-
-   for(int i = 0; i < 24; ++i){
-    Serial.print(packet.payload.message.messagecontent[i]);
-   }
-
-
+   // send the data
    Radio_Transmit(&packet, RADIO_WAIT_FOR_TX);
   }
 }
@@ -50,41 +39,30 @@
        {
           // if there are no more packets on the radio, clear the receive flag;
           // otherwise, we want to handle the next packet on the next loop iteration.
-          digitalWrite(4, HIGH);
           rxflag = 0;
        }

        if (packet.type == MESSAGE)
        {
-         digitalWrite(13, HIGH);
+
        }
     }
 }

-//void handle_servo(){
-//  int val = analogRead(servo_x_pin);            // reads the value of the potentiometer (value between 0 and 1023)
-//  val = map(val, 0, 1023, 500, 2500);     // scale it to use it with the servo (value between 0 and 180)
-//
-//  //http://www.robotshop.com/blog/en/arduino-5-minute-tutorials-lesson-5-servo-motors-3636
-//  // Thanks Geoff and Adam!
-//  digitalWrite(servo_out_pin,HIGH);
-//  delayMicroseconds(val);
-//  digitalWrite(servo_out_pin,LOW);
-//}
+void handle_servo(){
+   int val_x = analogRead(joystick_x_pin);            // reads the value of the potentiometer (value between 0 and 1023)
+   int val_y = analogRead(joystick_y_pin);            // reads the value of the potentiometer (value between 0 and 1023)
+   Serial.println(val_x);
+   Serial.println(val_y);
+}

 void setup() {
   pinMode(button_pin, INPUT);
-//  pinMode(servo_x_pin, INPUT);
-//  pinMode(servo_out_pin, OUTPUT);
-//  pinMode(IR_pin, OUTPUT);
-
-//   pinMode(13, OUTPUT);
-   pinMode(4, OUTPUT);
-   pinMode(10, OUTPUT);
+  pinMode(joystick_x_pin, INPUT);
+  pinMode(joystick_y_pin, INPUT);

-   digitalWrite(4, LOW);
-   digitalWrite(10, LOW);
-
+  pinMode(10, OUTPUT);
+   digitalWrite(10, LOW);
    delay(100);
    digitalWrite(10, HIGH);
    delay(100);
@@ -100,32 +78,20 @@

    // put some data into the packet
    packet.type = MESSAGE;
-//   memcpy(packet.payload.message.address, my_addr, RADIO_ADDRESS_LENGTH);
-//   Serial.println((char *)packet.payload.message.address);
-//   Serial.println((char *) my_addr);
    for(int i = 0;i < 5; ++i){
     packet.payload.message.address[i] = my_addr[i];
    }

-//   packet.payload.message.messageid = 55;
-//   Serial.println((char *)packet.payload.message.messagecontent);
-//   memset(packet.payload.message.messagecontent, 0, sizeof(packet.payload.message.messagecontent));
-//   Serial.println((char *)packet.payload.message.messagecontent);
-//   char *msg = "Test message.";
-//   memcpy(packet.payload.message.messagecontent,msg,strlen(msg));
    for (int i = 0; i < 24; ++i) {
      packet.payload.message.messagecontent[i] = 'A' + i;
    }
-//   snprintf((char*)packet.payload.message.messagecontent, sizeof(packet.payload.message.messagecontent), "Test message.");
-//   Serial.println((char *)packet.payload.message.messagecontent);
-   // The address to which the next transmission is to be sent
    Radio_Set_Tx_Addr(station_addr);

   // Thanks Neil!
   Scheduler_Init();
   Scheduler_StartTask(0,20,check_button);
   Scheduler_StartTask(5,20,recv_packet);
-//  Scheduler_StartTask(5,20,handle_servo);
+  Scheduler_StartTask(8,20,handle_servo);
 }

 void idle(uint32_t idle_period){


fix TSTMODE duration

fix TSTMODE duration

--- arduttons.ino
+++ arduttons.ino
@@ -35,7 +35,7 @@
 const int GETSTAT = 64;

 const unsigned long MAX_UNSIGNED_LONG = 4294967295;
-const unsigned long TSTLEN = 5*60*1000; //5 min
+const unsigned long TSTLEN = 300000; //5 min
 unsigned long tstbgn = 0;
 boolean iststmode = false;

@@ -107,6 +107,18 @@
    return result;
 }

+//
+void doreset(void)
+{
+//
+   for (int i = 0; i < pinc; i++)
+      {
+   //
+       EEPROM.write(eeprom[i], 0);
+       pineepromstate[i] = 0;
+       }
+}
+
 // the loop routine runs over and over again forever:
 void loop()
 {
@@ -143,7 +155,6 @@
          if (cmd & TSTMODE)
             {
          //
-            cmd |= GETSTAT;
             tstbgn = millis();
             iststmode = true;
             }
@@ -152,12 +163,7 @@
             {
          //
             iststmode = false;
-            for (int i = 0; i < pinc; i++)
-               {
-            //
-               EEPROM.write(eeprom[i], 0);
-               pineepromstate[i] = 0;
-               }
+            doreset();
             }
          //else
          if (cmd & GETSTAT)
@@ -176,7 +182,12 @@
       if (currt < tstbgn) duration = (MAX_UNSIGNED_LONG - tstbgn) + currt;
       else                duration = currt - tstbgn;

-      if (duration > TSTLEN) iststmode = false;
+      if (duration > TSTLEN)
+         {
+      //
+         iststmode = false;
+         doreset();
+         }
       }

    //... and little sleep


Clean Up

Clean Up

--- wifi-herbgarden-mqtt.ino
+++ wifi-herbgarden-mqtt.ino
@@ -7,7 +7,6 @@
 void callback(char *topic, byte *payload, unsigned int length);

 // System setting
-STARTUP(System.enableFeature(FEATURE_RETAINED_MEMORY));
 SerialLogHandler logHandler(LOG_LEVEL_ALL);

 // Specify data and clock connections
@@ -19,8 +18,6 @@
 byte server[] = {192, 168, 1, 5};         //MQTT Server Address
 MQTT mqttClient(server, 1883, callback);
 // Define Variables
-retained float _lastTempC;
-retained float _lastHumidity;
 unsigned short int _qos2messageid = 0;
 long _sleepTime = 60; // 1 minute
 long _ms = 0;
@@ -100,7 +97,7 @@
     mqttClient.publish("herbgarden/probe/temperature/min", "-40.00");
     mqttClient.publish("herbgarden/probe/temperature/max", "123.80");

-    mqttClient.publish("herbgarden/probe/humidity/value", String::format("%.4f%", _humidity));
+    mqttClient.publish("herbgarden/probe/humidity/value", String::format("%.4f", _humidity));
     mqttClient.publish("herbgarden/probe/humidity/tag", "AI-0001");
     mqttClient.publish("herbgarden/probe/humidity/eu", "%RH");
     mqttClient.publish("herbgarden/probe/humidity/min", "0.00");
@@ -112,14 +109,12 @@
     mqttClient.publish("herbgarden/battery/voltage/min", "0.00");
     mqttClient.publish("herbgarden/battery/voltage/max", "");

-    mqttClient.publish("herbgarden/battery/charge/value", String::format("%.4f%", batteryMonitor.getSoC()));
+    mqttClient.publish("herbgarden/battery/charge/value", String::format("%.4f", batteryMonitor.getSoC()));
     mqttClient.publish("herbgarden/battery/charge/tag", "XI-0001");
     mqttClient.publish("herbgarden/battery/charge/eu", "%");
     mqttClient.publish("herbgarden/battery/charge/min", "0.00");
     mqttClient.publish("herbgarden/battery/charge/max", "100.00");

-    _lastTempC = _tempC;
-    _lastHumidity = _humidity;
   }

   // Check for a update


Now that we can potentially have negative numbers we need to switch to signed integers.

--- src/rx5808-pro-diversity/rx5808-pro-diversity.ino
+++ src/rx5808-pro-diversity/rx5808-pro-diversity.ino
@@ -957,11 +957,11 @@
 uint16_t readRSSI(char receiver)
 {
 #endif
-    uint16_t rssi = 0;
-    uint16_t rssiA = 0;
-
-#ifdef USE_DIVERSITY
-    uint16_t rssiB = 0;
+    int rssi = 0;
+    int rssiA = 0;
+
+#ifdef USE_DIVERSITY
+    int rssiB = 0;
 #endif
     for (uint8_t i = 0; i < RSSI_READS; i++)
     {


Small change

Small change

--- PulseSensorAmped_Arduino_1dot4/PulseSensorAmped_Arduino_1dot4.ino
+++ PulseSensorAmped_Arduino_1dot4/PulseSensorAmped_Arduino_1dot4.ino
@@ -48,8 +48,7 @@

   if (QS == true){     // A Heartbeat Was Found
                        // BPM and IBI have been Determined
-                       // Quantified Self "QS" true when arduino finds a heartbeat
-        digitalWrite(blinkPin,HIGH);     // Blink LED, we got a beat.
+                       // Quantified Self "QS" true when arduino finds a heartbeat
         fadeRate = 255;         // Makes the LED Fade Effect Happen
                                 // Set 'fadeRate' Variable to 255 to fade LED with pulse
         serialOutputWhenBeatHappens();   // A Beat Happened, Output that to serial.


Update Keypad.ino

Update Keypad.ino

--- ComboKeypad/Keypad.ino
+++ ComboKeypad/Keypad.ino
@@ -1,5 +1,5 @@
 //USER VARIABLES, Variables that YOU change for YOUR preferences
-const int buttons[] {7, 6, 5, 4};   //The PIN of all of the buttons {FIRST, SECOND, etc...}
+const int buttons[] {7, 6, 5, 4};   //The PIN of all of the buttons

 const int combination[] = {3, 1, 2, 4};  //what the combination is, to add just add a "," and a number

@@ -61,7 +61,6 @@

     //If timer has run out, reset all arrays the count variable
     if(count != 0 && millis() - time > del) {   //Resets if timer runs out
-      Serial.println("runns resety");
       reset();   //Runs the Reset function
     }

@@ -138,11 +137,8 @@
         }
 }   //Function pressButton end

-// Functions "Reset"
+// Functions "Reset",
 void reset() {
-  // Reset everything
- Serial.println("Reset");
-
   for (int t = 0; t < numOfCombos; t++) {   //You could aparently declare an int in a for loop... C++ Style?
     input[t] = 0;   //Zeros the input array
   }


Harmonise topics

Harmonise topics

--- src/homie-sonoff-touch.ino
+++ src/homie-sonoff-touch.ino
@@ -14,7 +14,7 @@
 #include <Homie.h>

 #define FW_NAME "homie-sonoff-touch"
-#define FW_VERSION "0.0.8"
+#define FW_VERSION "0.0.9"

 /* Magic sequence for Autodetectable Binary Upload */
 const char *__FLAGGED_FW_NAME = "\xbf\x84\xe4\x13\x54" FW_NAME "\x93\x44\x6b\xa7\x75";
@@ -52,11 +52,11 @@
 bool RelayHandler(String value) {
   if (value == "ON") {
     digitalWrite(PIN_RELAY, HIGH);
-    Homie.setNodeProperty(relayNode, "set", value);
+    Homie.setNodeProperty(relayNode, "relayState", value);
     Serial.println("Relay is on");
   } else if (value == "OFF") {
     digitalWrite(PIN_RELAY, LOW);
-    Homie.setNodeProperty(relayNode, "set", value);
+    Homie.setNodeProperty(relayNode, "relayState", value);
     Serial.println("Relay is off");
   } else {
     Serial.print("Unknown value: ");


Update InputMatch.ino

Update InputMatch.ino

--- Arduino/Basics/Digital/InputMatch.ino
+++ Arduino/Basics/Digital/InputMatch.ino
@@ -89,7 +89,7 @@
   int input = digitalRead( INPUT_PIN );

   // select the code block corresponding to the current state to evaluate the next input
-  switch( state_index) {
+  switch(state_index) {

   case START:
     if (input) state_index = STATE1;


pwm leds to save batteries

pwm leds to save batteries

--- gamecubecontroller.ino
+++ gamecubecontroller.ino
@@ -36,6 +36,8 @@
 const uint32_t watchdogSeconds = 10;
 const uint32_t numInjectionModes = sizeof(injectors)/sizeof(*injectors);

+const uint8_t ledBrightnessLevels[] = {50,50,50,50};
+//const uint8_t ledBrightnessLevels[] = { 50, 25, 25, 150 }; // my PA3 LED is dimmer for some reason
 const uint32_t indicatorLEDs[] = { PA0, PA1, PA2, PA3 };
 const int numIndicators = sizeof(indicatorLEDs)/sizeof(*indicatorLEDs);
 const uint32_t downButton = PA4;
@@ -70,7 +72,7 @@

 void displayNumber(uint8_t x) {
   for (int i=0; i<numIndicators; i++, x>>=1)
-    digitalWrite(indicatorLEDs[i], 1^(x&1));
+    analogWrite(indicatorLEDs[i], (x&1) ? (255-ledBrightnessLevels[i]) : 255);
 }

 void updateDisplay() {
@@ -89,6 +91,10 @@
   pinMode(upButton, INPUT_PULLDOWN);
   debounceDown.begin();
   debounceUp.begin();
+
+  nvic_globalirq_disable();
+  displayNumber(0xF);
+  delay(3000);

 #ifdef SERIAL_DEBUG
   Serial.begin(115200);
@@ -191,6 +197,7 @@
   gameCubeSendBits(rumble ? 0b0100000000000011000000011l : 0b0100000000000011000000001l, 25);
   uint8_t success = gameCubeReceiveBits(data, 64);
   nvic_globalirq_enable();
+
   if (success && 0 == (data->buttons & 0x80) && (data->buttons & 0x8000) ) {
     gpio_write_bit(ledPort, ledPin, 0);
     return 1;


AD7173.ino added get current adc data channel

--- AD7173.ino
+++ AD7173.ino
@@ -69,6 +69,7 @@
 #define GAIN6_REG 0x3E
 #define GAIN7_REG 0x3F
 #define IFMODE_REG 0x02
+#define STATUS_REG 0x00
 #define ADCMODE_REG 0x01
 #define OFFSET0_REG 0x30
 #define OFFSET1_REG 0x31
@@ -206,7 +207,7 @@
 @param int - the length of bytes to write
 =========================================
 */
-int write_adc_register(byte reg, byte *value, int write_len) {
+int set_adc_register(byte reg, byte *value, int write_len) {
     /* when specified register is invalid */
     if (reg < 0x00 || reg > 0x3F) {
         if (DEBUG_ENABLED) {
@@ -245,7 +246,7 @@
 @return byte[] - the ADC register read result
 =============================================
 */
-int read_adc_register(byte reg, byte *value, int read_len) {
+int get_adc_register(byte reg, byte *value, int read_len) {
     /* when specified register is invalid */
     if (reg < 0x00 || reg > 0x3F) {
         if (DEBUG_ENABLED) {
@@ -295,7 +296,7 @@
     }
     byte value[2];
     /* read specified channel configuration */
-    read_adc_register(channel, value, 2);
+    get_adc_register(channel, value, 2);
     /* clear the enable bit */
     value[0] &= ~(1 << 7);
     /* enable or disable this channel */
@@ -322,7 +323,7 @@
     }

     /* update specified channel configuration */
-    write_adc_register(channel, value, 2);
+    set_adc_register(channel, value, 2);
     /* return error code */
     return 0;
 }
@@ -337,13 +338,13 @@
 int set_adc_filter_speed(byte filtcon, byte data_speed) {
     byte value[2];
     /* read the current register value */
-    read_adc_register(filtcon, value, 2);
+    get_adc_register(filtcon, value, 2);
     /* set the speed to default */
     value[1] &= 0xE0;
     /* set the desired speed */
     value[1] |= data_speed;
     /* write the new register value */
-    write_adc_register(filtcon, value, 2);
+    set_adc_register(filtcon, value, 2);
     /* return error code */
     return 0;
 }
@@ -359,13 +360,13 @@
 int set_adc_setup_codig(byte setupcon, int coding_mode) {
     byte value[2];
     /* read the current register value */
-    read_adc_register(setupcon, value, 2);
+    get_adc_register(setupcon, value, 2);
     /* set the coding mode to default */
     value[0] &= 0x7F;
     /* set the desired coding */
     value[0] |= (coding_mode << 7);
     /* write the new register value */
-    write_adc_register(setupcon, value, 2);
+    set_adc_register(setupcon, value, 2);
     /* set to new coding mode */
     adc_setup_coding_output = coding_mode;
     /* return error code */
@@ -383,8 +384,8 @@
     byte if_mode_value[2];
     byte adc_mode_value[2];
     /* read current register values */
-    read_adc_register(IFMODE_REG, if_mode_value, 2);
-    read_adc_register(ADCMODE_REG, adc_mode_value, 2);
+    get_adc_register(IFMODE_REG, if_mode_value, 2);
+    get_adc_register(ADCMODE_REG, adc_mode_value, 2);
     /* set to default read mode */
     adc_mode_value[1] &= 0x8F;

@@ -409,8 +410,8 @@
     }
     adc_data_mode = mode;
     /* write the desired register value */
-    write_adc_register(ADCMODE_REG, adc_mode_value, 2);
-    write_adc_register(IFMODE_REG, if_mode_value, 2);
+    set_adc_register(ADCMODE_REG, adc_mode_value, 2);
+    set_adc_register(IFMODE_REG, if_mode_value, 2);
     /* return error code */
     return 0;
 }
@@ -421,7 +422,7 @@
 @return byte[] - the ADC conversion result
 ==========================================
 */
-int read_adc_data(byte *value) {
+int get_adc_data(byte *value) {
     /* when not in continuous read mode, send the read command */
     if (adc_data_mode != CONTINUOUS_READ_MODE) {
         /* send communication register id 0x00 */
@@ -433,6 +434,7 @@
     value[0] = SPI.transfer(0x00);
     value[1] = SPI.transfer(0x00);
     value[2] = SPI.transfer(0x00);
+
     /* when debug enabled */
     if (DEBUG_ENABLED) {
         Serial.print("read: ");
@@ -446,6 +448,22 @@
 }

 /*
+===================================
+reads the current data channel
+@param byte - current data channel
+@return int - error code
+===================================
+*/
+int get_current_adc_data_channel(byte &channel) {
+    byte value[1];
+    /* read ADC status register */
+    get_adc_register(STATUS_REG, value, 1);
+    channel = value[0];
+    /* return error code */
+    return 0;
+}
+
+/*
 ============================================
 initializes the SPI connection with the ADC
 @return bool - is ADC ID valid
@@ -461,7 +479,7 @@

     byte id[2];
      /* read the ADC device ID */
-    read_adc_register(ID_REG, id, 2);
+    get_adc_register(ID_REG, id, 2);
     /* check if the id matches 0x30DX, where X is don't care */
     id[1] &= 0xF0;
     bool valid_id = id[0] == 0x30 && id[1] == 0xD0;
@@ -507,7 +525,12 @@
     /* when ADC conversion is finished */
     if (DATA_READY) {
         /* read ADC conversion result */
-        read_adc_data(data);
+        get_adc_data(data);
+        byte current_channel;
+        get_current_adc_data_channel(current_channel);
+        if (current_channel == CH0_REG) {
+            /* something lol... */
+        }
         //Serial.write(data[0]);
         //Serial.write(data[1]);
         //Serial.write(data[2]);