added a firmata cc3000 sketch

added a firmata cc3000 sketch

error: pathspec 'examples/skynetim_mqtt_StandardFirmata_cc3000_ino/skynetim_mqtt_StandardFirmata_cc3000_ino.ino' did not match any file(s) known to git

--- examples/skynetim_mqtt_StandardFirmata_cc3000_ino/skynetim_mqtt_StandardFirmata_cc3000_ino.ino
+++ examples/skynetim_mqtt_StandardFirmata_cc3000_ino/skynetim_mqtt_StandardFirmata_cc3000_ino.ino
@@ -0,0 +1,754 @@
+/*
+ *                SSSSS  kk                            tt
+ *               SS      kk  kk yy   yy nn nnn    eee  tt
+ *                SSSSS  kkkkk  yy   yy nnn  nn ee   e tttt
+ *                    SS kk kk   yyyyyy nn   nn eeeee  tt
+ *                SSSSS  kk  kk      yy nn   nn  eeeee  tttt
+ *                               yyyyy
+ *
+ * SkynetClient for http://skynet.im, OPEN COMMUNICATIONS NETWORK & API FOR
+ * THE INTERNET OF THINGS.
+ *
+ * This sketch uses the MQTT library to bridge firmata to skynet. You can then turn pins
+ * off and on remotely, and much much more. To drive from Node.js and Skynet see:
+ * https://github.com/octoblu/serial/tree/master/examples/firmata/SkynetSerial
+ *
+ * Requires the MQTT library from Nick O'Leary http://knolleary.net/arduino-client-for-mqtt/
+ *
+ * Should work with any cc3000 shield or breakout like Adafruit or Sparkfun:
+ * https://www.sparkfun.com/products/12071
+ *
+ * However no matter which you choose, we have a requirement on the Sparkfun
+ * library: https://github.com/sparkfun/SFE_CC3000_Library/
+ *
+ * Remember not to mess with cc3000's unavailable pins (11, 12, 13 and whatever you set below)
+ *
+ * You will notice we're using F() in Serial.print. It is covered briefly on
+ * the arduino print page but it means we can store our strings in program
+ * memory instead of in ram.
+ *
+ */
+
+#include <SPI.h>
+#include <SFE_CC3000.h>
+#include <SFE_CC3000_Client.h>
+#include <PubSubClient.h>
+#include <StreamBuffer.h>
+#include <ringbuffer.h>
+#include <b64.h>
+#include <Servo.h>
+#include <Wire.h>
+#include <Firmata.h>
+
+// Define your shields pins
+#define CC3000_INT      2   // Needs to be an interrupt pin (D2/D3) //Adafruit is 3
+#define CC3000_EN       7   // Can be any digital pin //Adafruit is 5
+#define CC3000_CS       10  // Preferred is pin 10 on Uno
+
+ringbuffer write(150); //firmata out - Capabilities Response requires ~150 on Uno
+ringbuffer read(50); //firmata in - min 67% of biggest incoming firmata b64 string
+
+StreamBuffer stream(write, read);
+StreamBuffer externalaccess(read, write);
+
+char ssid[] = "yournetworkname";     //  your network SSID (name)
+char pass[] = "yourpassword";  // your WPA network password
+unsigned int ap_security = WLAN_SEC_WPA2; // Security of network
+unsigned int timeout = 30000;             // Milliseconds
+
+char server[] = "skynet.im";
+
+//Your 'firmware' type UUID and token for skynet.im TODO where to get one
+char UUID[]  = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
+char TOKEN[] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
+
+SFE_CC3000 wifi = SFE_CC3000(CC3000_INT, CC3000_EN, CC3000_CS);
+SFE_CC3000_Client client = SFE_CC3000_Client(wifi);
+PubSubClient skynet(server, 1883, onMessage, client);
+
+// move the following defines to Firmata.h?
+#define I2C_WRITE B00000000
+#define I2C_READ B00001000
+#define I2C_READ_CONTINUOUSLY B00010000
+#define I2C_STOP_READING B00011000
+#define I2C_READ_WRITE_MODE_MASK B00011000
+#define I2C_10BIT_ADDRESS_MODE_MASK B00100000
+
+#define MAX_QUERIES 8
+#define MINIMUM_SAMPLING_INTERVAL 10
+
+#define REGISTER_NOT_SPECIFIED -1
+
+/*==============================================================================
+ * GLOBAL VARIABLES
+ *============================================================================*/
+
+/* analog inputs */
+int analogInputsToReport = 0; // bitwise array to store pin reporting
+
+/* digital input ports */
+byte reportPINs[TOTAL_PORTS];       // 1 = report this port, 0 = silence
+byte previousPINs[TOTAL_PORTS];     // previous 8 bits sent
+
+/* pins configuration */
+byte pinConfig[TOTAL_PINS];         // configuration of every pin
+byte portConfigInputs[TOTAL_PORTS]; // each bit: 1 = pin in INPUT, 0 = anything else
+int pinState[TOTAL_PINS];           // any value that has been written
+
+/* timer variables */
+unsigned long currentMillis;        // store the current value from millis()
+unsigned long previousMillis;       // for comparison with currentMillis
+int samplingInterval = 19;          // how often to run the main loop (in ms)
+
+/* i2c data */
+struct i2c_device_info {
+  byte addr;
+  byte reg;
+  byte bytes;
+};
+
+/* for i2c read continuous more */
+i2c_device_info query[MAX_QUERIES];
+
+byte i2cRxData[32];
+boolean isI2CEnabled = false;
+signed char queryIndex = -1;
+unsigned int i2cReadDelayTime = 0;  // default delay time between i2c read request and Wire.requestFrom()
+
+Servo servos[MAX_SERVOS];
+
+/*==============================================================================
+ * FUNCTIONS
+ *============================================================================*/
+
+void readAndReportData(byte address, int theRegister, byte numBytes) {
+  // allow I2C requests that don't require a register read
+  // for example, some devices using an interrupt pin to signify new data available
+  // do not always require the register read so upon interrupt you call Wire.requestFrom()
+  if (theRegister != REGISTER_NOT_SPECIFIED) {
+    Wire.beginTransmission(address);
+    #if ARDUINO >= 100
+    Wire.write((byte)theRegister);
+    #else
+    Wire.send((byte)theRegister);
+    #endif
+    Wire.endTransmission();
+    // 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
+  }
+
+  Wire.requestFrom(address, numBytes);  // all bytes are returned in requestFrom
+
+  // check to be sure correct number of bytes were returned by slave
+  if(numBytes == Wire.available()) {
+    i2cRxData[0] = address;
+    i2cRxData[1] = theRegister;
+    for (int i = 0; i < numBytes; i++) {
+      #if ARDUINO >= 100
+      i2cRxData[2 + i] = Wire.read();
+      #else
+      i2cRxData[2 + i] = Wire.receive();
+      #endif
+    }
+  }
+  else {
+    if(numBytes > Wire.available()) {
+      Firmata.sendString("ERR"); //JJR
+    } else {
+      Firmata.sendString("ERR"); //JJR
+    }
+  }
+
+  // send slave address, register and received bytes
+  Firmata.sendSysex(SYSEX_I2C_REPLY, numBytes + 2, i2cRxData);
+}
+
+void outputPort(byte portNumber, byte portValue, byte forceSend)
+{
+  // pins not configured as INPUT are cleared to zeros
+  portValue = portValue & portConfigInputs[portNumber];
+  // only send if the value is different than previously sent
+  if(forceSend || previousPINs[portNumber] != portValue) {
+    Firmata.sendDigitalPort(portNumber, portValue);
+    previousPINs[portNumber] = portValue;
+  }
+}
+
+/* -----------------------------------------------------------------------------
+ * check all the active digital inputs for change of state, then add any events
+ * to the Serial output queue using Serial.print() */
+void checkDigitalInputs(void)
+{
+  /* Using non-looping code allows constants to be given to readPort().
+   * The compiler will apply substantial optimizations if the inputs
+   * to readPort() are compile-time constants. */
+  if (TOTAL_PORTS > 0 && reportPINs[0]) outputPort(0, readPort(0, portConfigInputs[0]), false);
+  if (TOTAL_PORTS > 1 && reportPINs[1]) outputPort(1, readPort(1, portConfigInputs[1]), false);
+  if (TOTAL_PORTS > 2 && reportPINs[2]) outputPort(2, readPort(2, portConfigInputs[2]), false);
+  if (TOTAL_PORTS > 3 && reportPINs[3]) outputPort(3, readPort(3, portConfigInputs[3]), false);
+  if (TOTAL_PORTS > 4 && reportPINs[4]) outputPort(4, readPort(4, portConfigInputs[4]), false);
+  if (TOTAL_PORTS > 5 && reportPINs[5]) outputPort(5, readPort(5, portConfigInputs[5]), false);
+  if (TOTAL_PORTS > 6 && reportPINs[6]) outputPort(6, readPort(6, portConfigInputs[6]), false);
+  if (TOTAL_PORTS > 7 && reportPINs[7]) outputPort(7, readPort(7, portConfigInputs[7]), false);
+  if (TOTAL_PORTS > 8 && reportPINs[8]) outputPort(8, readPort(8, portConfigInputs[8]), false);
+  if (TOTAL_PORTS > 9 && reportPINs[9]) outputPort(9, readPort(9, portConfigInputs[9]), false);
+  if (TOTAL_PORTS > 10 && reportPINs[10]) outputPort(10, readPort(10, portConfigInputs[10]), false);
+  if (TOTAL_PORTS > 11 && reportPINs[11]) outputPort(11, readPort(11, portConfigInputs[11]), false);
+  if (TOTAL_PORTS > 12 && reportPINs[12]) outputPort(12, readPort(12, portConfigInputs[12]), false);
+  if (TOTAL_PORTS > 13 && reportPINs[13]) outputPort(13, readPort(13, portConfigInputs[13]), false);
+  if (TOTAL_PORTS > 14 && reportPINs[14]) outputPort(14, readPort(14, portConfigInputs[14]), false);
+  if (TOTAL_PORTS > 15 && reportPINs[15]) outputPort(15, readPort(15, portConfigInputs[15]), false);
+}
+
+// -----------------------------------------------------------------------------
+/* sets the pin mode to the correct state and sets the relevant bits in the
+ * two bit-arrays that track Digital I/O and PWM status
+ */
+void setPinModeCallback(byte pin, int mode)
+{
+  if (pinConfig[pin] == I2C && isI2CEnabled && mode != I2C) {
+    // disable i2c so pins can be used for other functions
+    // the following if statements should reconfigure the pins properly
+    disableI2CPins();
+  }
+  if (IS_PIN_SERVO(pin) && mode != SERVO && servos[PIN_TO_SERVO(pin)].attached()) {
+    servos[PIN_TO_SERVO(pin)].detach();
+  }
+  if (IS_PIN_ANALOG(pin)) {
+    reportAnalogCallback(PIN_TO_ANALOG(pin), mode == ANALOG ? 1 : 0); // turn on/off reporting
+  }
+  if (IS_PIN_DIGITAL(pin)) {
+    if (mode == INPUT) {
+      portConfigInputs[pin/8] |= (1 << (pin & 7));
+    } else {
+      portConfigInputs[pin/8] &= ~(1 << (pin & 7));
+    }
+  }
+  pinState[pin] = 0;
+  switch(mode) {
+  case ANALOG:
+    if (IS_PIN_ANALOG(pin)) {
+      if (IS_PIN_DIGITAL(pin)) {
+        pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver
+        digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups
+      }
+      pinConfig[pin] = ANALOG;
+    }
+    break;
+  case INPUT:
+    if (IS_PIN_DIGITAL(pin)) {
+      pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver
+      digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups
+      pinConfig[pin] = INPUT;
+    }
+    break;
+  case OUTPUT:
+    if (IS_PIN_DIGITAL(pin)) {
+      digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable PWM
+      pinMode(PIN_TO_DIGITAL(pin), OUTPUT);
+      pinConfig[pin] = OUTPUT;
+    }
+    break;
+  case PWM:
+    if (IS_PIN_PWM(pin)) {
+      pinMode(PIN_TO_PWM(pin), OUTPUT);
+      analogWrite(PIN_TO_PWM(pin), 0);
+      pinConfig[pin] = PWM;
+    }
+    break;
+  case SERVO:
+    if (IS_PIN_SERVO(pin)) {
+      pinConfig[pin] = SERVO;
+      if (!servos[PIN_TO_SERVO(pin)].attached()) {
+          servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin));
+      }
+    }
+    break;
+  case I2C:
+    if (IS_PIN_I2C(pin)) {
+      // mark the pin as i2c
+      // the user must call I2C_CONFIG to enable I2C for a device
+      pinConfig[pin] = I2C;
+    }
+    break;
+  default:
+    Firmata.sendString("ERR"); // TODO: put error msgs in EEPROM //JJR
+  }
+  // TODO: save status to EEPROM here, if changed
+}
+
+void analogWriteCallback(byte pin, int value)
+{
+  if (pin < TOTAL_PINS) {
+    switch(pinConfig[pin]) {
+    case SERVO:
+      if (IS_PIN_SERVO(pin))
+        servos[PIN_TO_SERVO(pin)].write(value);
+        pinState[pin] = value;
+      break;
+    case PWM:
+      if (IS_PIN_PWM(pin))
+        analogWrite(PIN_TO_PWM(pin), value);
+        pinState[pin] = value;
+      break;
+    }
+  }
+}
+
+void digitalWriteCallback(byte port, int value)
+{
+  byte pin, lastPin, mask=1, pinWriteMask=0;
+
+  if (port < TOTAL_PORTS) {
+    // create a mask of the pins on this port that are writable.
+    lastPin = port*8+8;
+    if (lastPin > TOTAL_PINS) lastPin = TOTAL_PINS;
+    for (pin=port*8; pin < lastPin; pin++) {
+      // do not disturb non-digital pins (eg, Rx & Tx)
+      if (IS_PIN_DIGITAL(pin)) {
+        // only write to OUTPUT and INPUT (enables pullup)
+        // do not touch pins in PWM, ANALOG, SERVO or other modes
+        if (pinConfig[pin] == OUTPUT || pinConfig[pin] == INPUT) {
+          pinWriteMask |= mask;
+          pinState[pin] = ((byte)value & mask) ? 1 : 0;
+        }
+      }
+      mask = mask << 1;
+    }
+    writePort(port, (byte)value, pinWriteMask);
+  }
+}
+
+
+// -----------------------------------------------------------------------------
+/* sets bits in a bit array (int) to toggle the reporting of the analogIns
+ */
+//void FirmataClass::setAnalogPinReporting(byte pin, byte state) {
+//}
+void reportAnalogCallback(byte analogPin, int value)
+{
+  if (analogPin < TOTAL_ANALOG_PINS) {
+    if(value == 0) {
+      analogInputsToReport = analogInputsToReport &~ (1 << analogPin);
+    } else {
+      analogInputsToReport = analogInputsToReport | (1 << analogPin);
+    }
+  }
+  // TODO: save status to EEPROM here, if changed
+}
+
+void reportDigitalCallback(byte port, int value)
+{
+  if (port < TOTAL_PORTS) {
+    reportPINs[port] = (byte)value;
+  }
+  // do not disable analog reporting on these 8 pins, to allow some
+  // pins used for digital, others analog.  Instead, allow both types
+  // of reporting to be enabled, but check if the pin is configured
+  // as analog when sampling the analog inputs.  Likewise, while
+  // scanning digital pins, portConfigInputs will mask off values from any
+  // pins configured as analog
+}
+
+/*==============================================================================
+ * SYSEX-BASED commands
+ *============================================================================*/
+
+void sysexCallback(byte command, byte argc, byte *argv)
+{
+  byte mode;
+  byte slaveAddress;
+  byte slaveRegister;
+  byte data;
+  unsigned int delayTime;
+
+  switch(command) {
+  case I2C_REQUEST:
+    mode = argv[1] & I2C_READ_WRITE_MODE_MASK;
+    if (argv[1] & I2C_10BIT_ADDRESS_MODE_MASK) {
+      Firmata.sendString("ERR"); //JJR
+      return;
+    }
+    else {
+      slaveAddress = argv[0];
+    }
+
+    switch(mode) {
+    case I2C_WRITE:
+      Wire.beginTransmission(slaveAddress);
+      for (byte i = 2; i < argc; i += 2) {
+        data = argv[i] + (argv[i + 1] << 7);
+        #if ARDUINO >= 100
+        Wire.write(data);
+        #else
+        Wire.send(data);
+        #endif
+      }
+      Wire.endTransmission();
+      delayMicroseconds(70);
+      break;
+    case I2C_READ:
+      if (argc == 6) {
+        // a slave register is specified
+        slaveRegister = argv[2] + (argv[3] << 7);
+        data = argv[4] + (argv[5] << 7);  // bytes to read
+        readAndReportData(slaveAddress, (int)slaveRegister, data);
+      }
+      else {
+        // a slave register is NOT specified
+        data = argv[2] + (argv[3] << 7);  // bytes to read
+        readAndReportData(slaveAddress, (int)REGISTER_NOT_SPECIFIED, data);
+      }
+      break;
+    case I2C_READ_CONTINUOUSLY:
+      if ((queryIndex + 1) >= MAX_QUERIES) {
+        // too many queries, just ignore
+        Firmata.sendString("ERR"); //JJR
+        break;
+      }
+      queryIndex++;
+      query[queryIndex].addr = slaveAddress;
+      query[queryIndex].reg = argv[2] + (argv[3] << 7);
+      query[queryIndex].bytes = argv[4] + (argv[5] << 7);
+      break;
+    case I2C_STOP_READING:
+    byte queryIndexToSkip;
+      // if read continuous mode is enabled for only 1 i2c device, disable
+      // read continuous reporting for that device
+      if (queryIndex <= 0) {
+        queryIndex = -1;
+      } else {
+        // if read continuous mode is enabled for multiple devices,
+        // determine which device to stop reading and remove it's data from
+        // the array, shifiting other array data to fill the space
+        for (byte i = 0; i < queryIndex + 1; i++) {
+          if (query[i].addr = slaveAddress) {
+            queryIndexToSkip = i;
+            break;
+          }
+        }
+
+        for (byte i = queryIndexToSkip; i<queryIndex + 1; i++) {
+          if (i < MAX_QUERIES) {
+            query[i].addr = query[i+1].addr;
+            query[i].reg = query[i+1].addr;
+            query[i].bytes = query[i+1].bytes;
+          }
+        }
+        queryIndex--;
+      }
+      break;
+    default:
+      break;
+    }
+    break;
+  case I2C_CONFIG:
+    delayTime = (argv[0] + (argv[1] << 7));
+
+    if(delayTime > 0) {
+      i2cReadDelayTime = delayTime;
+    }
+
+    if (!isI2CEnabled) {
+      enableI2CPins();
+    }
+
+    break;
+  case SERVO_CONFIG:
+    if(argc > 4) {
+      // these vars are here for clarity, they'll optimized away by the compiler
+      byte pin = argv[0];
+      int minPulse = argv[1] + (argv[2] << 7);
+      int maxPulse = argv[3] + (argv[4] << 7);
+
+      if (IS_PIN_SERVO(pin)) {
+        if (servos[PIN_TO_SERVO(pin)].attached())
+          servos[PIN_TO_SERVO(pin)].detach();
+        servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin), minPulse, maxPulse);
+        setPinModeCallback(pin, SERVO);
+      }
+    }
+    break;
+  case SAMPLING_INTERVAL:
+    if (argc > 1) {
+      samplingInterval = argv[0] + (argv[1] << 7);
+      if (samplingInterval < MINIMUM_SAMPLING_INTERVAL) {
+        samplingInterval = MINIMUM_SAMPLING_INTERVAL;
+      }
+    } else {
+      //Firmata.sendString("Not enough data");
+    }
+    break;
+  case EXTENDED_ANALOG:
+    if (argc > 1) {
+      int val = argv[1];
+      if (argc > 2) val |= (argv[2] << 7);
+      if (argc > 3) val |= (argv[3] << 14);
+      analogWriteCallback(argv[0], val);
+    }
+    break;
+  case CAPABILITY_QUERY:
+    Firmata.write(START_SYSEX);
+    Firmata.write(CAPABILITY_RESPONSE);
+    for (byte pin=0; pin < TOTAL_PINS; pin++) {
+      if (IS_PIN_DIGITAL(pin)) {
+        Firmata.write((byte)INPUT);
+        Firmata.write(1);
+        Firmata.write((byte)OUTPUT);
+        Firmata.write(1);
+      }
+      if (IS_PIN_ANALOG(pin)) {
+        Firmata.write(ANALOG);
+        Firmata.write(10);
+      }
+      if (IS_PIN_PWM(pin)) {
+        Firmata.write(PWM);
+        Firmata.write(8);
+      }
+      if (IS_PIN_SERVO(pin)) {
+        Firmata.write(SERVO);
+        Firmata.write(14);
+      }
+      if (IS_PIN_I2C(pin)) {
+        Firmata.write(I2C);
+        Firmata.write(1);  // to do: determine appropriate value
+      }
+      Firmata.write(127);
+    }
+    Firmata.write(END_SYSEX);
+    break;
+  case PIN_STATE_QUERY:
+    if (argc > 0) {
+      byte pin=argv[0];
+      Firmata.write(START_SYSEX);
+      Firmata.write(PIN_STATE_RESPONSE);
+      Firmata.write(pin);
+      if (pin < TOTAL_PINS) {
+        Firmata.write((byte)pinConfig[pin]);
+  Firmata.write((byte)pinState[pin] & 0x7F);
+  if (pinState[pin] & 0xFF80) Firmata.write((byte)(pinState[pin] >> 7) & 0x7F);
+  if (pinState[pin] & 0xC000) Firmata.write((byte)(pinState[pin] >> 14) & 0x7F);
+      }
+      Firmata.write(END_SYSEX);
+    }
+    break;
+  case ANALOG_MAPPING_QUERY:
+    Firmata.write(START_SYSEX);
+    Firmata.write(ANALOG_MAPPING_RESPONSE);
+    for (byte pin=0; pin < TOTAL_PINS; pin++) {
+      Firmata.write(IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127);
+    }
+    Firmata.write(END_SYSEX);
+    break;
+  }
+}
+
+void enableI2CPins()
+{
+  byte i;
+  // is there a faster way to do this? would probaby require importing
+  // Arduino.h to get SCL and SDA pins
+  for (i=0; i < TOTAL_PINS; i++) {
+    if(IS_PIN_I2C(i)) {
+      // mark pins as i2c so they are ignore in non i2c data requests
+      setPinModeCallback(i, I2C);
+    }
+  }
+
+  isI2CEnabled = true;
+
+  // is there enough time before the first I2C request to call this here?
+  Wire.begin();
+}
+
+/* disable the i2c pins so they can be used for other functions */
+void disableI2CPins() {
+    isI2CEnabled = false;
+    // disable read continuous mode for all devices
+    queryIndex = -1;
+    // uncomment the following if or when the end() method is added to Wire library
+    // Wire.end();
+}
+
+/*==============================================================================
+ * SETUP()
+ *============================================================================*/
+
+void systemResetCallback()
+{
+  // initialize a defalt state
+  // TODO: option to load config from EEPROM instead of default
+  if (isI2CEnabled) {
+    disableI2CPins();
+  }
+  for (byte i=0; i < TOTAL_PORTS; i++) {
+    reportPINs[i] = false;      // by default, reporting off
+    portConfigInputs[i] = 0;  // until activated
+    previousPINs[i] = 0;
+  }
+  // pins with analog capability default to analog input
+  // otherwise, pins default to digital output
+  for (byte i=0; i < TOTAL_PINS; i++) {
+
+    // skip SPI pins for Ethernet/Wifi Shield //JJR
+    if ( (i==CC3000_INT) || (i==CC3000_EN) || (i==CC3000_CS) || (i==MOSI) || (i==MISO) || (i==SCK) || (i==SS) )
+      continue;
+
+    if (IS_PIN_ANALOG(i)) {
+      // turns off pullup, configures everything
+      setPinModeCallback(i, ANALOG);
+    } else {
+      // sets the output to 0, configures portConfigInputs
+      setPinModeCallback(i, OUTPUT);
+    }
+  }
+  // by default, do not report any analog inputs
+  analogInputsToReport = 0;
+
+  /* send digital inputs to set the initial state on the host computer,
+   * since once in the loop(), this firmware will only send on change */
+  /*
+  TODO: this can never execute, since no pins default to digital input
+        but it will be needed when/if we support EEPROM stored config
+  for (byte i=0; i < TOTAL_PORTS; i++) {
+    outputPort(i, readPort(i, portConfigInputs[i]), true);
+  }
+  */
+}
+
+//we'll run this if anyone messages us
+void onMessage(char* topic, byte* payload, unsigned int length) {
+
+//  // handle incoming messages, well just print it for now
+//  Serial.println(topic);
+//  for(int i =0; i<length; i++){
+//    Serial.print((char)payload[i]);
+//  }
+//  Serial.println();
+
+  b64::decode((char*)payload, length, externalaccess);
+
+}
+
+
+void setup()
+{
+
+  Serial.begin(9600);
+
+  // Initialize CC3000 (configure SPI communications)
+  if ( wifi.init() ) {
+    Serial.println(F("CC3000 initialization complete"));
+  } else {
+    Serial.println(F("Something went wrong during CC3000 init!"));
+    while(1);
+  }
+
+  Firmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION);
+
+  Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
+  Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback);
+  Firmata.attach(REPORT_ANALOG, reportAnalogCallback);
+  Firmata.attach(REPORT_DIGITAL, reportDigitalCallback);
+  Firmata.attach(SET_PIN_MODE, setPinModeCallback);
+  Firmata.attach(START_SYSEX, sysexCallback);
+  Firmata.attach(SYSTEM_RESET, systemResetCallback);
+
+  Firmata.begin(stream);
+  systemResetCallback();  // reset to default config
+
+}
+
+void loop() {
+  //we need to call loop for the mqtt library to do its thing and send/receive our messages
+  if(skynet.loop()){
+
+    byte pin, analogPin;
+
+    /* DIGITALREAD - as fast as possible, check for changes and output them to the
+     * FTDI buffer using Serial.print()  */
+    checkDigitalInputs();
+
+    /* SERIALREAD - processing incoming messagse as soon as possible, while still
+     * checking digital inputs.  */
+    while(Firmata.available())
+      Firmata.processInput();
+
+    /* SEND FTDI WRITE BUFFER - make sure that the FTDI buffer doesn't go over
+     * 60 bytes. use a timer to sending an event character every 4 ms to
+     * trigger the buffer to dump. */
+
+    currentMillis = millis();
+    if (currentMillis - previousMillis > samplingInterval) {
+      previousMillis += samplingInterval;
+      /* ANALOGREAD - do all analogReads() at the configured sampling interval */
+      for(pin=0; pin<TOTAL_PINS; pin++) {
+        if (IS_PIN_ANALOG(pin) && pinConfig[pin] == ANALOG) {
+          analogPin = PIN_TO_ANALOG(pin);
+          if (analogInputsToReport & (1 << analogPin)) {
+            Firmata.sendAnalog(analogPin, analogRead(analogPin));
+          }
+        }
+      }
+      // report i2c data for all device with read continuous mode enabled
+      if (queryIndex > -1) {
+        for (byte i = 0; i < queryIndex + 1; i++) {
+          readAndReportData(query[i].addr, query[i].reg, query[i].bytes);
+        }
+      }
+    }
+
+    //see if firmata left us any goodies
+    while(externalaccess.available()){
+
+      //wifi has a buffer limit ~90, want around 80, so ~51 before encoding
+      int len = b64::encodeLength(externalaccess.available() > 51 ? 51 : externalaccess.available());
+
+      skynet.publishHeader("tb", len, false);
+
+      b64::encode(externalaccess, client, len);
+
+    }
+
+  }else
+  {
+    //oops we're not connected yet or we lost connection
+    Serial.println(F("connecting..."));
+
+    // Sadly if we don't reinit it never reconnects
+    if ( wifi.init() ) {
+      Serial.println(F("CC3000 initialization complete"));
+    } else {
+      Serial.println(F("Something went wrong during CC3000 init!"));
+      while(1);
+    }
+
+    //lets wait so we don't slam the router
+    delay(10000);
+
+    // attempt to connect to Wifi network:
+    if(wifi.connect(ssid, ap_security, pass, timeout)) {
+
+      // skynet doesnt use client so send empty client string and YOUR UUID and token
+      if (skynet.connect("", UUID, TOKEN)){
+
+        //success!
+        Serial.println(F("connected"));
+
+        //you need to subscribe to your uuid to get messages for you
+        skynet.subscribe(UUID);
+
+      }
+
+    }else
+    {
+        Serial.print(F("couldnt connect to: "));
+        Serial.println(ssid);
+    }
+  }
+}


dfdsfs

dfdsfs

error: pathspec 'code' did not match any file(s) known to git
error: pathspec 'dump/ir_fft/ir_fft.ino' did not match any file(s) known to git


fist release

fist release

error: pathspec 'kiker.ino' did not match any file(s) known to git

--- kiker.ino
+++ kiker.ino
@@ -0,0 +1,249 @@
+#include <Bounce2.h>
+
+
+//TODO
+/*
+ * Больше меньше
+ * Финал игры
+ * Победная музыка
+ * ДОлгое нажатие
+ * Мигание
+ * Ошибка
+ * Изменени натсроек
+ * Рефракторинг
+ * ОБщий сброс
+ *
+ */
+
+
+//Пин подключен к SER входу SN74HC595N
+int dataPinA = 2;
+//Пин подключеный к SRCLR входу SN74HC595N
+int latchPinA = 3;
+//Пин подключеный к SRCLK входу SN74HC595N
+int clockPinA = 4;
+//Пин подключен к SER входу SN74HC595N
+int dataPinB = 7;
+//Пин подключеный к SRCLR входу SN74HC595N
+int latchPinB = 8;
+//Пин подключеный к SRCLK входу SN74HC595N
+int clockPinB = 9;
+
+int ldrPinA = 0;
+int ldrPinB = 1;
+
+
+volatile int currentScoreA = 0;
+volatile int currentScoreB = 0;
+volatile int finalScore = 15;
+int decrButtonPinA = 5;
+int incrButtonPinA = 6;
+
+int decrButtonPinB = 10;
+int incrButtonPinB = 11;
+
+int tonePinA = 12;
+int tonePinB = 13;
+
+
+
+
+// Instantiate a Bounce object
+Bounce debouncerIncrButtonA = Bounce();
+Bounce debouncerDecrButtonA = Bounce();
+Bounce debouncerIncrButtonB = Bounce();
+Bounce debouncerDecrButtonB = Bounce();
+
+volatile int lastLdrAValue = 0;
+volatile int lastLdrBValue = 0;
+int SCORE_TRESHOLD = 150;
+
+
+
+
+void setup() {
+
+
+  Serial.begin(9600);
+  initializeArduinoPins();
+
+  debouncerIncrButtonA.attach(incrButtonPinA);
+  debouncerIncrButtonA.interval(5);
+
+  debouncerDecrButtonA.attach(decrButtonPinA);
+  debouncerDecrButtonA.interval(5);
+
+
+  debouncerIncrButtonB.attach(incrButtonPinB);
+  debouncerIncrButtonB.interval(5);
+
+  debouncerDecrButtonB.attach(decrButtonPinB);
+  debouncerDecrButtonB.interval(5);
+
+
+  displayWrite(currentScoreA);
+  displayWriteB(currentScoreB);
+
+
+}
+void initializeArduinoPins() {
+  pinMode(latchPinA, OUTPUT);
+  pinMode(dataPinA, OUTPUT);
+  pinMode(clockPinA, OUTPUT);
+  pinMode(latchPinB, OUTPUT);
+  pinMode(dataPinB, OUTPUT);
+  pinMode(clockPinB, OUTPUT);
+
+  pinMode(tonePinA, OUTPUT);
+  pinMode(tonePinB, OUTPUT);
+
+  pinMode(incrButtonPinA, INPUT_PULLUP);
+  pinMode(decrButtonPinA, INPUT_PULLUP);
+   pinMode(incrButtonPinB, INPUT_PULLUP);
+  pinMode(decrButtonPinB, INPUT_PULLUP);
+
+}
+
+void resetScore(int command) {
+  currentScoreA = 0;
+  displayWrite(currentScoreA);
+}
+void resetScoreB(int command) {
+  currentScoreB = 0;
+  displayWriteB(currentScoreB);
+}
+
+void increaseScore(int command) {
+  if ( (currentScoreA ) < finalScore) {
+    currentScoreA++;
+    displayWrite(currentScoreA);
+    if (currentScoreA == finalScore){
+      tone (tonePinA, 500); //включаем на 500 Гц
+      delay(100);
+      noTone(tonePinA);
+    }
+  }
+}
+
+void increaseScoreB(int command) {
+  if ( (currentScoreB ) < finalScore ) {
+    currentScoreB++;
+    displayWriteB(currentScoreB);
+    if (currentScoreB == finalScore){
+      tone (tonePinB, 500); //включаем на 500 Гц
+      delay(100);
+      noTone(tonePinB);
+    }
+  }
+}
+
+
+void decreaseScore(int command) {
+  if (currentScoreA > 0) {
+    currentScoreA = currentScoreA - 1;
+    displayWrite(currentScoreA);
+  }
+
+}
+
+void decreaseScoreB(int command) {
+  if (currentScoreB > 0) {
+    currentScoreB = currentScoreB - 1;
+    displayWriteB(currentScoreB);
+  }
+
+}
+
+
+void displayWrite(int number) {
+
+  int numbers[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67};
+  digitalWrite(latchPinA, LOW);
+  shiftOut(dataPinA, clockPinA, MSBFIRST, numbers[number % 10]);
+  shiftOut(dataPinA, clockPinA, MSBFIRST, numbers[(number / 10) % 10]);
+  digitalWrite(latchPinA, HIGH);
+
+}
+void displayWriteB(int number) {
+
+  int numbers[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67};
+  digitalWrite(latchPinB, LOW);
+  shiftOut(dataPinB, clockPinB, MSBFIRST, numbers[number % 10]);
+  shiftOut(dataPinB, clockPinB, MSBFIRST, numbers[(number / 10) % 10]);
+  digitalWrite(latchPinB, HIGH);
+
+}
+
+
+void loop()
+{
+
+  debouncerIncrButtonA.update();
+  debouncerDecrButtonA.update();
+  debouncerIncrButtonB.update();
+  debouncerDecrButtonB.update();
+
+  int incrButtonValueA = debouncerIncrButtonA.read();
+  int decrButtonValueA = debouncerDecrButtonA.read();
+  int incrButtonValueB = debouncerIncrButtonB.read();
+  int decrButtonValueB = debouncerDecrButtonB.read();
+
+  if ( incrButtonValueA == HIGH && decrButtonValueA == HIGH ) {
+    resetScore(0);
+    Serial.println("reset");
+  }
+   if ( incrButtonValueB == HIGH && decrButtonValueB == HIGH ) {
+    resetScoreB(0);
+    Serial.println("resetB");
+  }
+
+  if (debouncerIncrButtonA.fell()) {
+    increaseScore(0);
+
+    Serial.println("increase");
+  }
+
+  if (debouncerDecrButtonA.fell()) {
+    decreaseScore(0);
+    Serial.println("decrease");
+  }
+
+   if (debouncerIncrButtonB.fell()) {
+    increaseScoreB(0);
+    Serial.println("increaseB");
+  }
+
+  if (debouncerDecrButtonB.fell()) {
+    decreaseScoreB(0);
+    Serial.println("decreaseB");
+  }
+
+
+  int currentLdrAValue = analogRead(ldrPinA);
+  Serial.print("current ");
+  Serial.print(currentLdrAValue);
+  Serial.print(" last ");
+  Serial.print(lastLdrAValue);
+  Serial.print(" score ");
+  Serial.println(currentScoreA);
+  if (currentLdrAValue < lastLdrAValue - SCORE_TRESHOLD) {
+    Serial.println("yes");
+    increaseScore(0);
+    delay(500);
+  }
+  lastLdrAValue = currentLdrAValue;
+
+
+ int currentLdrBValue = analogRead(ldrPinB);
+
+  if (currentLdrBValue < lastLdrBValue - SCORE_TRESHOLD) {
+
+    increaseScoreB(0);
+    delay(500);
+  }
+  lastLdrBValue = currentLdrBValue;
+
+
+
+
+}


added implementation for micro stepping 	new file:   microStepping_expriment/microStepping_expriment.ino

error: pathspec 'microStepping_expriment/microStepping_expriment.ino' did not match any file(s) known to git

--- microStepping_expriment/microStepping_expriment.ino
+++ microStepping_expriment/microStepping_expriment.ino
@@ -0,0 +1,58 @@
+const unsigned duty_arr [] =
+{500, 625, 750, 875, 1000, 875, 750, 625, 500, 375, 250, 125, 0,0,0,0,   0,0,0,0, 0,0,0,0,   0,0,0,0 ,0, 125, 250, 375};
+//^0-a                                     ^8-c                          ^16-b               ^24-d
+const unsigned index_A = 0;
+const unsigned index_B = 16;
+const unsigned index_C = 8;
+const unsigned index_D = 24;
+
+const int A = 8;
+const int B = 9;
+const int C = 10;
+const int D = 11;
+
+int a,b,c,d;
+
+void generate(unsigned pin, unsigned period, unsigned duty);
+
+void setup() {
+  pinMode(A, OUTPUT);
+  pinMode(B, OUTPUT);
+  pinMode(C, OUTPUT);
+  pinMode(D, OUTPUT);
+
+  a = index_A;
+  b = index_B;
+  c = index_C;
+  d = index_D;
+}
+
+void loop() {
+
+  generate(A, 1000, duty_arr[a]);
+  generate(C, 1000, duty_arr[b]);
+  generate(B, 1000, duty_arr[c]);
+  generate(D, 1000, duty_arr[d]);
+
+  ++a;
+  ++b;
+  ++c;
+  ++d;
+
+  a %= 32;
+  b %= 32;
+  c %= 32;
+  d %= 32;
+
+  delay(50);
+}
+
+void generate(unsigned pin, unsigned period, unsigned duty)
+{
+  digitalWrite(pin, HIGH);
+  delayMicroseconds(duty);
+
+  digitalWrite(pin, LOW);
+  delayMicroseconds(period - duty);
+}
+


anavi-miracle-controller-gestures.ino: Example

Add an example for turning on and off consecutively LED on
addressable LED strips using ANAVI Miracle Controller and
I2C gesture sensor module APD9960.

When gesture to the left is detected turn off the LED, when
gesture to the right is detected turn on the next LED.

Signed-off-by: Leon Anavi <be92910ae7bb6f58bb9b7c6f845bc30640119592@anavi.org>

error: pathspec 'anavi-miracle-controller/anavi-miracle-controller-gestures/anavi-miracle-controller-gestures.ino' did not match any file(s) known to git

--- anavi-miracle-controller/anavi-miracle-controller-gestures/anavi-miracle-controller-gestures.ino
+++ anavi-miracle-controller/anavi-miracle-controller-gestures/anavi-miracle-controller-gestures.ino
@@ -0,0 +1,99 @@
+#include <FS.h>
+#include <ESP8266WiFi.h>          //https://github.com/esp8266/Arduino
+#include "Adafruit_APDS9960.h"
+
+// For FastLED
+#define FASTLED_ESP8266_RAW_PIN_ORDER
+#include <FastLED.h>
+
+#define LED_PIN1    12
+#define LED_PIN2    14
+#define NUM_LEDS    15
+#define BRIGHTNESS  64
+#define LED_TYPE    WS2812
+#define COLOR_ORDER GRB
+#define FRAMES_PER_SECOND  120
+
+Adafruit_APDS9960 apds;
+
+CRGB leds1[NUM_LEDS];
+CRGB leds2[NUM_LEDS];
+
+int currentPosition = 1;
+
+void updateColor(int numToFill)
+{
+  // Turn off all LEDs
+  fill_solid(leds1, NUM_LEDS, CRGB::Black);
+  // Turn on LEDs depending the gesture
+  fill_rainbow(leds1, numToFill, 0, 7);
+
+  // Turn off all LEDs
+  fill_solid(leds2, NUM_LEDS, CRGB::Black);
+  // Turn on LEDs depending the gesture
+  fill_rainbow(leds2, numToFill, 0, 7);
+
+
+  FastLED.show();
+  FastLED.delay(1000/FRAMES_PER_SECOND);
+}
+
+void setup()
+{
+  Serial.begin(115200);
+  Serial.println();
+
+  Serial.println("ANAVI Miracle Controller");
+  Serial.println("------------------------------");
+  Serial.println("Control LED strip with gesture");
+  Serial.println("------------------------------");
+
+  FastLED.addLeds<LED_TYPE, LED_PIN1, COLOR_ORDER>(leds1, NUM_LEDS).setCorrection( TypicalLEDStrip );
+  FastLED.addLeds<LED_TYPE, LED_PIN2, COLOR_ORDER>(leds2, NUM_LEDS).setCorrection( TypicalLEDStrip );
+  FastLED.setBrightness(  BRIGHTNESS );
+  updateColor(currentPosition);
+  delay(100);
+  Serial.println("LED strips initialized.");
+
+  if(!apds.begin())
+  {
+    Serial.println("ERROR: Failed to initialize gesture sensor! Please check your wiring.");
+  }
+  else Serial.println("Gesture sensor initialized.");
+
+  //gesture mode will be entered once proximity mode senses something close
+  apds.enableProximity(true);
+  apds.enableGesture(true);
+}
+
+void loop()
+{
+  //read a gesture from the device
+  uint8_t gesture = apds.readGesture();
+  if(APDS9960_LEFT == gesture)
+  {
+    if (1 < currentPosition)
+    {
+      Serial.println("Go left!");
+      currentPosition -= 1;
+      updateColor(currentPosition);
+    }
+    else
+    {
+      Serial.println("You have already reached the maximum on the left.");
+    }
+  }
+  else if(APDS9960_RIGHT == gesture)
+  {
+    if (15 > currentPosition)
+    {
+      Serial.println("Go right!");
+      currentPosition += 1;
+      updateColor(currentPosition);
+    }
+    else
+    {
+      Serial.println("You have already reached the maximum on the right.");
+    }
+  }
+}


stepper motor controller L293 with hm example

error: pathspec 'examples/hm_L293_breakout/hm_L293_breakout.ino' did not match any file(s) known to git

--- examples/hm_L293_breakout/hm_L293_breakout.ino
+++ examples/hm_L293_breakout/hm_L293_breakout.ino
@@ -0,0 +1,84 @@
+/* LucidTronix Heart Matrix LEO LED Display.
+ * Text on the Heart Matrix
+ * For instructions details and schematic, See:
+ * http://www.lucidtronix.com/tutorials/57  */
+#include <MsTimer2.h>
+#include <HeartMatrix.h>
+
+HeartMatrix hm = HeartMatrix(5,6,7); // dataPin is on 5, Latch is on 6, and clock is on 7
+
+void displayer2(){
+  hm.displayer();
+}
+
+
+/* LucidTronix Control a stepper motor.
+ * For instructions details and schematic, See:
+ * http://www.lucidtronix.com/tutorials/24
+ */
+#include <Stepper.h>
+// change this to the number of steps on your motor
+#define STEPS 200
+
+// create an instance of the stepper class, specifying
+// the number of step s of the motor and the pins it's
+// attached to:
+Stepper stepper(STEPS, 0,1);
+
+int btn1 = 9 ;
+int pot_pin = 0;
+int mode = 0;
+int num_modes = 2;
+int cur_pos = 100;
+unsigned long last_press = 0;
+
+void setup()
+{
+  // set the speed of the motor to 30 RPMs
+  stepper.setSpeed(30);
+  pinMode(btn1, INPUT);
+  MsTimer2::set(1,displayer2);
+  MsTimer2::start();
+  hm.set_message("L293 Breakout Board Controlled by Heart Matrix from LucidTroniX! ");
+
+}
+
+void loop()
+{
+  if (mode == 0 ) speed_control();
+  else if (mode == 1) phase_control();
+  check_buttons();
+  hm.on();
+  hm.set_scroll_wait(max(20, analogRead(0)/4));
+}
+
+void check_buttons(){
+  if (digitalRead(btn1) == HIGH  && millis() - last_press  > 500){
+    mode = ++mode % num_modes;
+    last_press = millis();
+    stepper.setSpeed(30);
+  }
+}
+
+void speed_control(){
+  int val = analogRead(pot_pin);
+  val -= 512;
+  val /= 5;
+  stepper.setSpeed(abs(val));
+  int step_amount = 0;
+  if ( val > 0) step_amount = 1;
+  else if ( val < 0) step_amount = -1;
+  stepper.step(step_amount);
+}
+
+void phase_control(){
+  int val = analogRead(pot_pin);
+  int degree = map(val,0,1023,0,200);
+  int step_amount = 0;
+  if (cur_pos < degree  && cur_pos < 200) step_amount = 1;
+  else if(cur_pos > degree && cur_pos > 0) step_amount = -1;
+  stepper.step(step_amount);
+  cur_pos += step_amount;
+}
+
+


delay for testing

delay for testing

error: pathspec 'exploration' did not match any file(s) known to git
error: pathspec 'testing/src/main.ino' did not match any file(s) known to git


Update sketch_temp.ino

Update sketch_temp.ino

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Au1st3in/fall2015-e121-arduino-code.git/'


Fixed frequency to 868 MHz and shift to 850 Hz

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/JDat/RocketGPStracker.git/'


Big circle lamp

Big circle lamp

error: pathspec 'bigcircle/bigcircle.ino' did not match any file(s) known to git

--- bigcircle/bigcircle.ino
+++ bigcircle/bigcircle.ino
@@ -0,0 +1,34 @@
+#import <FastLED.h>
+
+#define N_LEDS 150
+CRGBArray<N_LEDS> leds;
+
+void setup() {
+  FastLED.addLeds<WS2812B, 7, GRB>(leds, N_LEDS);
+  FastLED.setMaxPowerInVoltsAndMilliamps(5, 1000);
+}
+
+int rings[3] = { 60, 48, 42 };
+int ring = 10;
+int hue = 0;
+
+void loop() {
+  EVERY_N_MILLISECONDS(80) {
+    int pixels = rings[ring];
+    if (ring < 3) {
+      int offset = 0;
+      for (int i = 0; i < ring; i++) {
+        offset += rings[i];
+      }
+      for(CRGB & pixel : leds(offset, offset + pixels - 1)) {
+        pixel = CHSV(hue, 255, 255);
+      }
+    }
+    ring -= 1;
+    hue += 5;
+    if (ring == -1) { ring = 10; }
+  }
+  fadeToBlackBy(leds, N_LEDS, 10);
+  show_at_max_brightness_for_power();
+}
+


added a arduino file containing fuctions to allow diaganal driving

error: pathspec 'arduino' did not match any file(s) known to git
error: pathspec 'code/OctoDrive/OctoDrive.ino' did not match any file(s) known to git


Added I2C control example. This is still a work in progress and will eventually turn into a library.

error: pathspec 'arduino/I2CControl/I2CControl.ino' did not match any file(s) known to git

--- arduino/I2CControl/I2CControl.ino
+++ arduino/I2CControl/I2CControl.ino
@@ -0,0 +1,166 @@
+/* Blue Robotics Example Code
+-------------------------------
+
+Title: BlueESC Control via I2C (Arduino)
+
+Description: This example code demonstrates the I2C communication capability
+of the Blue Robotics "BlueESC". Motor speed commands are sent via I2C and
+voltage, current, rpm, and temperature data is returned.
+
+The code is designed for the Arduino Uno board and can be compiled and
+uploaded via the Arduino 1.0+ software.
+
+-------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2015 Blue Robotics Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-------------------------------*/
+
+// See here for example: https://github.com/balrog-kun/autopilot/blob/lpc1343/actuators-i2c.h
+
+#include <Wire.h>
+
+#define I2C_ADDR 0x29
+
+// resistance at 25 degrees C
+#define THERMISTORNOMINAL 10000
+// temp. for nominal resistance (almost always 25 C)
+#define TEMPERATURENOMINAL 25
+// The beta coefficient of the thermistor (usually 3000-4000)
+#define BCOEFFICIENT 3950
+// the value of the 'other' resistor
+#define SERIESRESISTOR 3300
+
+// Read the incoming data buffer from an ESC
+void readBuffer(uint8_t address, uint8_t buffer[]) {
+  Wire.beginTransmission(address);
+  Wire.write(0x02); // Data start register
+  Wire.endTransmission();
+
+  delay(100);
+
+  Wire.requestFrom(address,uint8_t(9));
+  delay(100);
+  uint8_t i = 0;
+  while(Wire.available()) {
+    buffer[i] = Wire.read();
+    i++;
+  }
+}
+
+// Check to make sure that ESC is properly attached
+void initESC(uint8_t address) {
+  uint8_t buffer[9];
+
+  delay(100); // Wait for ESCs to boot if starting up
+
+  buffer[8] = 0x00;
+  readBuffer(address,buffer);
+
+  if ( buffer[8] == 0xab ) {
+    Serial.println("ESC is alive!");
+  } else {
+    Serial.println("Can't contact ESC.");
+  }
+}
+
+// Send motor speed command to ESC
+void setESC(uint8_t address, int16_t value) {
+  uint16_t output;
+
+  if ( value < 0 ) {
+    output = (-value)|((1<<15)&0x8000);
+  } else {
+    output = value;
+  }
+
+  Wire.beginTransmission(address);
+  Wire.write(0x00);
+  Wire.write(output>>8);
+  Wire.write(output);
+  Wire.endTransmission();
+}
+
+void readSensors(uint8_t address, uint16_t *rpm, uint16_t *vbat, uint16_t *temp, uint16_t *curr) {
+  uint8_t buffer[9];
+
+  readBuffer(address,buffer);
+
+  *rpm = (buffer[0] << 8) | buffer[1];
+  *vbat = (buffer[2] << 8) | buffer[3];
+  *temp = (buffer[4] << 8) | buffer[5];
+  *curr = (buffer[6] << 8) | buffer[7];
+}
+
+void setup() {
+  Wire.begin();
+  Serial.begin(19200);
+  Serial.println("Starting");
+
+  initESC(I2C_ADDR);
+}
+
+void loop() {
+  static uint32_t writeTimer = 0;
+  static uint32_t readTimer = 0;
+
+  if ( millis() - writeTimer > 100 ) {
+    writeTimer = millis();
+
+    static int16_t signal = 0;
+    static int16_t increment = 50;
+
+    //Serial.print("Sending ");Serial.print(signal);
+    setESC(I2C_ADDR,signal);
+
+    signal += increment;
+
+    if ( abs(signal) > 6000 ) {
+      increment = -increment;
+    }
+  }
+
+  if ( micros() - readTimer > 1000000 ) {
+    uint32_t dt = micros() - readTimer;
+
+    readTimer = micros();
+
+    uint16_t rpm, vbat, temp, curr;
+
+    readSensors(I2C_ADDR,&rpm,&vbat,&temp,&curr);
+
+    float resistance = SERIESRESISTOR/(65535/float(temp)-1);
+
+    float steinhart;
+    steinhart = resistance / THERMISTORNOMINAL;     // (R/Ro)
+    steinhart = log(steinhart);                  // ln(R/Ro)
+    steinhart /= BCOEFFICIENT;                   // 1/B * ln(R/Ro)
+    steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
+    steinhart = 1.0 / steinhart;                 // Invert
+    steinhart -= 273.15;                         // convert to C
+
+    Serial.print("RPM:  ");Serial.println(rpm/(dt/1000000.0f)*60/6);
+    Serial.print("VBat: ");Serial.println(float(vbat)/65536*5*6.45);
+    Serial.print("Temp: ");Serial.println(steinhart);
+    Serial.print("Curr: ");Serial.println((float(curr)-32768)/65536*5*14.706);
+    Serial.println("---------------------");
+  }
+}


added mosfet fan demo

added mosfet fan demo

error: pathspec 'demos/mosfet_fan_demo/mosfet_fan.ino' did not match any file(s) known to git

--- demos/mosfet_fan_demo/mosfet_fan.ino
+++ demos/mosfet_fan_demo/mosfet_fan.ino
@@ -0,0 +1,23 @@
+int fanPower = 0;
+const int distancePin=1;
+const int fanPin = 9;
+
+void setup(){
+   pinMode(fanPin,OUTPUT);
+   Serial.begin(9600);
+}
+
+void loop(){
+
+ // reading the distance sensor value
+ int val = analogRead(distancePin);
+
+ // mapping the analog value to a range between 0 and 255
+ double conv = (val/670.0) * 255.0;
+ int conv2 = (int)conv;
+ fanPower = conv2;
+
+ // sending the PWM signal through fanPin
+ analogWrite(fanPin,fanPower);
+ delay(50);
+}


Create ShowLEDs.ino

Create ShowLEDs.ino

error: pathspec 'examples/ShowLEDs/ShowLEDs.ino' did not match any file(s) known to git


Created simple program to sync clock to a hard-coded time when I hit the "select" button on the LCD board.  Not a super awesome program, and there are better examples that use the serial console in the Time module examples.  But this was easy.

error: pathspec 'RTC_set/RTC_set.ino' did not match any file(s) known to git

--- RTC_set/RTC_set.ino
+++ RTC_set/RTC_set.ino
@@ -0,0 +1,132 @@
+/*
+ * Lee's retirement countdown clock
+ *
+ * I'm using a SainSmart LCD shield with an Uno, and a DS1370 RTC to make it accurate
+ *
+ * Links to the Amazon items I used:
+ * http://www.amazon.com/gp/product/B0076FWAH8
+ * http://www.amazon.com/gp/product/B00LZCTMJM
+ */
+
+/*
+ set up for the RTC
+ Libraries used are at
+  http://www.pjrc.com/teensy/td_libs_Time.html
+  http://www.pjrc.com/teensy/td_libs_DS1307RTC.html
+ as referenced by http://playground.arduino.cc/Code/Time
+*/
+#include <Wire.h>
+#include <DS1307RTC.h>
+#include <Time.h>
+#include <TimeLib.h>
+
+tmElements_t tm;
+
+/*
+ Set up for the LCD
+*/
+#include <LiquidCrystal.h>
+LiquidCrystal lcd(
+ 8, // RS
+ 9, // Enable
+ 4, // bit 4
+ 5, // bit 5
+ 6, // bit 6
+ 7  // bit 7
+);
+
+#define PinBacklight 10
+#define PinButton    0
+
+// define some values used by the panel and buttons
+int lcd_key     = 0;
+int adc_key_in  = 0;
+#define btnRIGHT  0
+#define btnUP     1
+#define btnDOWN   2
+#define btnLEFT   3
+#define btnSELECT 4
+#define btnNONE   5
+
+String line1 = "";
+String line2 = "";
+String secs;
+String key;
+
+#define BrightMax 255
+#define BrightMin 0
+int brightness_increment = -2;
+int brightness = BrightMax;
+
+// read the buttons
+int read_LCD_buttons()
+{
+ adc_key_in = analogRead(PinButton);      // read the value from the sensor
+ // example buttons when read are centered at these valies: 0, 144, 329, 504, 741
+ // values measured in Lee's display: 0, 143, 328, 503, 741 (really close to the author's, apparently)
+ // I add half the distance to the next button to allow for as much variance as is reasonably likely
+ //
+ // I picked 1000 as the top cutoff mostly arbitrarily; ~1024 is the select, due to being "infinite"
+ // I suppose the "right" way would be to do 741+(1024-741/2) to be consistent
+ if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
+ if (adc_key_in < (0   + (143 - 0)   / 2 ))  return btnRIGHT;
+ if (adc_key_in < (143 + (328 - 143) / 2 ))  return btnUP;
+ if (adc_key_in < (328 + (503 - 328) / 2 ))  return btnDOWN;
+ if (adc_key_in < (503 + (741 - 503) / 2 ))  return btnLEFT;
+ if (adc_key_in <= 1000)                     return btnSELECT;
+ return btnNONE;  // when all others fail, return this...
+}
+
+time_t initial_time;
+
+void setup() {
+  // define PWM brightness pin for output
+  pinMode(PinBacklight, OUTPUT);
+  // set up the LCD's number of columns and rows:
+  lcd.begin(16, 2);
+  lcd.clear();
+  tmElements_t t;
+  // set time to 9:45 PM on Feb 24, 2016.
+  t.Second = 0;
+  t.Minute = 45;
+  t.Hour = 21;
+  t.Day = 24;
+  t.Month = 2;
+  t.Year = 116;
+  initial_time = makeTime(t);
+}
+
+void loop() {
+  lcd_key = read_LCD_buttons();
+  switch (lcd_key){
+    case btnSELECT: {
+      key = "SELECT";
+      RTC.set(initial_time);
+      key = "Time set!";
+      break;
+    }
+  }
+
+  // assemble LCD line
+  line1 = "";
+  line1 = "ADC:" + String(adc_key_in);
+  while( line1.length() < 16 - key.length() ){
+    line1 = line1 + " ";
+  }
+  line1 = line1 + key;
+  lcd.setCursor(0,0);
+  lcd.print(line1);
+
+  // assemble second LCD line
+  line2 = "";
+  secs = String(millis()/1000);
+  if(RTC.read(tm)){
+    secs = "ok!" + String(tm.Second);
+  }
+  while( line2.length() < 16 - secs.length() ){
+    line2 = line2 + " ";
+  }
+  line2 = line2 + secs;
+  lcd.setCursor(0,1);
+  lcd.print(line2);
+}


travis, constructing the TERRIFYING TENTACLE for particle

error: pathspec 'examples/tentacle-particle/tentacle-particle.ino' did not match any file(s) known to git

--- examples/tentacle-particle/tentacle-particle.ino
+++ examples/tentacle-particle/tentacle-particle.ino
@@ -0,0 +1,35 @@
+#include <SPI.h>
+
+#include "tentacle-build.h"
+
+#define conn Serial
+
+TentacleArduino tentacle;
+Pseudopod pseudopod(conn, conn, tentacle);
+
+void setup() {
+  Serial.begin(57600);
+}
+
+void loop() {
+  readData();
+
+  if(!pseudopod.isConfigured()) {
+    delay(100);
+    pseudopod.requestConfiguration();
+  }
+
+  if(pseudopod.shouldBroadcastPins() ) {
+    delay(pseudopod.getBroadcastInterval());
+    pseudopod.sendConfiguredPins();
+  }
+}
+
+void readData() {
+  while (conn.available()) {
+    if(pseudopod.readMessage() == TentacleMessageTopic_action) {
+      pseudopod.sendPins();
+    }
+  }
+
+}


Basic RX Testing

Basic RX Testing

error: pathspec 'Caravan_Thermostat_RX/Caravan_Thermostat_RX.ino' did not match any file(s) known to git

--- Caravan_Thermostat_RX/Caravan_Thermostat_RX.ino
+++ Caravan_Thermostat_RX/Caravan_Thermostat_RX.ino
@@ -0,0 +1,59 @@
+/*
+
+  Caravan Thermostat RX
+
+  Copyright 2016 Jon Burrows
+
+*/
+
+// Setup the includes
+#include <SPI.h>
+#include <SoftwareSerial.h>
+
+// Define the pins.
+// BLE
+
+#define BLERXPIN 2
+#define BLETXPIN 3
+
+// Create instances
+SoftwareSerial BTserial(BLERXPIN, BLETXPIN); // RX, TX
+
+// Define Global Variables
+
+void setup() {
+  Serial.begin(9600);
+Serial.println("Enter AT commands:");
+  BTserial.begin(9600);
+  at("AT+NAMECaravanRX");
+  //at("AT+CON0015830084F7"); //Connect to Master Arduino
+  at("AT+ROLE0");
+  at("AT+RESET");
+
+  // Master Address 00:15:83:00:84:F7
+  // Slave Address 00:15:83:00:83:EE
+  delay(1000); // wait a bit, NECESSARY!!
+}
+
+void loop() {
+ // Keep reading from HC-06 and send to Arduino Serial Monitor
+    if (BTserial.available())
+    {
+        Serial.write(BTserial.read());
+    }
+
+    // Keep reading from Arduino Serial Monitor and send to HC-06
+    if (Serial.available())
+    {
+        BTserial.write(Serial.read());
+    }
+}
+
+void at(char* cmd) {
+  BTserial.write(cmd);
+  BTserial.write("\r\n");
+  Serial.print(cmd);
+  while(!BTserial.find("OK")) Serial.print(".");
+
+  Serial.println(" .. OK");
+}


RFduino saves calibration data to Flash memory

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Ossit/SenseBack.git/'


Training Sketch Added

Training Sketch Added

error: pathspec 'tools/examples/word_training/word_training.ino' did not match any file(s) known to git

--- tools/examples/word_training/word_training.ino
+++ tools/examples/word_training/word_training.ino
@@ -0,0 +1,38 @@
+/**Basic training
+*P gives a matrix for recognizing the phoneme
+*I advice you use the uspeech library along with gaussian
+*modelling toolkit this will allow yout to use the library
+*for picking up sound
+*/
+#include <uspeech.h>
+int t;
+uspeech recognizer(A0);
+uword words;
+bool printed= true;
+void setup(){
+  Serial.begin(9600);
+  recognizer.calibrate();
+}
+void loop(){
+  phoneme p= recognizer.get();
+  if(p.loudness()>3){
+    words.attachPhoneme(p);
+    printed = false;
+  }
+  else{
+    if(t == 0){
+      t =millis();
+    }
+    if(millis()-t>500){
+      t = 0;
+      if(!printed){
+        if(words.confidence()>60){
+          words.debugPrint();
+          words.reset();
+          printed = true;
+        }
+        printed = true;
+      }
+    }
+  }
+}


we have to wait until stall guard is read …

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/trinamic/T-Bone.git/'


Add remotexy first test

Add remotexy first test

error: pathspec 'Arduino/test_remotexy/test_remotexy.ino' did not match any file(s) known to git

--- Arduino/test_remotexy/test_remotexy.ino
+++ Arduino/test_remotexy/test_remotexy.ino
@@ -0,0 +1,85 @@
+/*
+   -- New project --
+
+   This source code of graphical user interface
+   has been generated automatically by RemoteXY editor.
+   To compile this code using RemoteXY library 2.3.3 or later version
+   download by link http://remotexy.com/en/library/
+   To connect using RemoteXY mobile app by link http://remotexy.com/en/download/
+     - for ANDROID 4.1.1 or later version;
+     - for iOS 1.2.1 or later version;
+
+   This source code is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+*/
+
+//////////////////////////////////////////////
+//        RemoteXY include library          //
+//////////////////////////////////////////////
+
+// RemoteXY select connection mode and include library
+#define REMOTEXY_MODE__SOFTSERIAL
+#include <SoftwareSerial.h>
+
+#include <RemoteXY.h>
+
+// RemoteXY connection settings
+#define REMOTEXY_SERIAL_RX 2
+#define REMOTEXY_SERIAL_TX 3
+#define REMOTEXY_SERIAL_SPEED 9600
+
+
+// RemoteXY configurate
+#pragma pack(push, 1)
+uint8_t RemoteXY_CONF[] =
+  { 255,4,0,0,0,43,0,8,13,0,
+  1,1,43,18,12,12,2,31,88,0,
+  1,1,29,27,12,12,2,31,88,0,
+  1,1,43,36,12,12,2,31,88,0,
+  1,1,57,27,12,12,2,31,88,0 };
+
+// this structure defines all the variables of your control interface
+struct {
+
+    // input variable
+  uint8_t button_1; // =1 if button pressed, else =0
+  uint8_t button_2; // =1 if button pressed, else =0
+  uint8_t button_3; // =1 if button pressed, else =0
+  uint8_t button_4; // =1 if button pressed, else =0
+
+    // other variable
+  uint8_t connect_flag;  // =1 if wire connected, else =0
+
+} RemoteXY;
+#pragma pack(pop)
+
+/////////////////////////////////////////////
+//           END RemoteXY include          //
+/////////////////////////////////////////////
+
+#define PIN_BUTTON_1 13
+
+
+void setup()
+{
+  RemoteXY_Init ();
+
+  pinMode (PIN_BUTTON_1, OUTPUT);
+
+  // TODO you setup code
+
+}
+
+void loop()
+{
+  RemoteXY_Handler ();
+
+  digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1==0)?LOW:HIGH);
+
+  // TODO you loop code
+  // use the RemoteXY structure for data transfer
+
+
+}


Update Line_sensor.ino

Update Line_sensor.ino

Fixed incorrect comment.

error: pathspec 'Line' did not match any file(s) known to git
error: pathspec 'sensor/Line_sensor/Line_sensor.ino' did not match any file(s) known to git


Sample Code to Run the Motors

Sample Code to Run the Motors

error: pathspec 'Running_Motors/Running_Motors.ino' did not match any file(s) known to git

--- Running_Motors/Running_Motors.ino
+++ Running_Motors/Running_Motors.ino
@@ -0,0 +1,39 @@
+// This script is sample code that initializes your motors and runs them.
+// Much of this code takes more steps than necessary in order to outline what is happening,
+// as you become more familiar coding Arduino scripts, your code will be a lot more
+// concise.
+
+// create the variables that defines which pins the motors are connected to
+const int leftMotorPins = {4, 5, 6};
+const int rightMotorPins = {7, 8, 9};
+
+//----------//
+// This is the set-up for all of the pins you are using on the Arduino
+// This section only runs once each time you begin the script
+void setup() {
+
+// set all the motor pins as OUTPUT pins
+for (int i = 0; i < 3; i++) {
+  pinMode(leftMotorPins[i], OUTPUT); // for loop goes through the index and sets as HIGH
+  pinMode(rightMotorPins[i], OUTPUT); // for loop goes through the index and sets as HIGH
+}
+
+// this sets A0 and B0 to HIGH and A1 and B1 to LOW output on each motor
+// this will determine the direction that the motors turn
+// switch HIGH and LOW to go in the other direction
+digitalWrite(leftMotorPins[0], HIGH);
+digitalWrite(rightMotorPins[0], HIGH);
+digitalWrite(leftMotorPins[1], LOW);
+digitalWrite(rightMotorPins[1], LOW);
+}
+
+
+//----------//
+//This is the main section of your code, it repeatedly loops through.
+void loop() {
+
+  // this tells the motors to run (default value is 100), change this and see what happens.
+  analogWrite(leftMotorPins[2], 100);
+  analogWrite(rightMotorPins[2], 100);
+  delay(20) // this delay is necessary to give it a little more time to move and process.
+}


Multiple features added, see description

Added ARM-Switch for arming the throttle
Added conversion from RAW input to percentage (0-100% and (-)100%-100%)

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/simonlovgren/Arduino-Flight-TX.git/'


add network_uplink exemple

add network_uplink exemple

error: pathspec 'exemples/arduino/network_uplink/network_uplink.ino' did not match any file(s) known to git

--- exemples/arduino/network_uplink/network_uplink.ino
+++ exemples/arduino/network_uplink/network_uplink.ino
@@ -0,0 +1,107 @@
+// ---------------------------------------------------------------------
+// This file is a example for use the library armapi with
+// ARM NANO (NANO_LP with sigfox) on arduino board.
+//
+// This software send periodically 'Hello world' to Sigfox network or
+// Lora network. The choice of the network is automatically choose by
+// the shield plugged on the Arduino.
+//
+// Created date: 13.04.2016
+// ---------------------------------------------------------------------
+
+/***********************************************************************
+
+ Copyright (c) 2016 ATIM
+
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+***********************************************************************/
+
+// ---------------------------------------------------------------------
+// Include
+// ---------------------------------------------------------------------
+#include <arm.h>
+
+// ---------------------------------------------------------------------
+// Define
+// ---------------------------------------------------------------------
+#define LED 13
+
+// ---------------------------------------------------------------------
+// Global variables
+// ---------------------------------------------------------------------
+//Instance of  the class Arm
+Arm myArm;
+//The message to send at Sigfox or Lora
+uint8_t msg[] = "Hello world!";
+
+// ---------------------------------------------------------------------
+// Implemented functions
+// ---------------------------------------------------------------------
+
+void setup()
+{
+	//Init Led for chow error
+	pinMode(LED, OUTPUT);
+	digitalWrite(LED, LOW);
+
+	//Init Arm and set LED to on if error
+	if (myArm.Init(&Serial) != ARM_ERR_NONE)
+		digitalWrite(LED, HIGH);
+
+	//Get the Arm type
+	armType_t armType;
+	myArm.Info(&armType, 0, 0, 0, 0);
+
+	//Set Lora mode or Sigfox mode
+	if(armType == ARM_TYPE_N8_LW)
+		myArm.SetMode(ARM_MODE_LORAWAN);
+	else
+		myArm.SetMode(ARM_MODE_SFX);
+
+	//Set Sigfox mode in uplink.
+	myArm.SfxEnableDownlink(false);
+
+	//Set Lora mode in uplink.
+	myArm.LwSetConfirmedFrame(5);
+    myArm.LwEnableOtaa(false);
+    myArm.LwEnableRxWindows(true);
+    myArm.LwEnableTxAdaptiveSpeed(true);
+    myArm.LwEnableDutyCycle(false);
+    myArm.LwEnableTxAdaptiveChannel(true);
+    myArm.LwEnableRx2Adaptive(true);
+
+    //Update the configuration into the arm.
+	myArm.UpdateConfig();
+}
+
+void loop()
+{
+	unsigned int i;
+
+	//Send the message to Sigfox or Lora
+	myArm.Send(msg, sizeof(msg)-1);
+
+	//Wait 360min
+	for(i=0; i<360; i++)
+		delay(60000);
+}


added octosonar_bench.ino

added octosonar_bench.ino

This is example is what I use to drive the bench test for new boards.

The jig is made of two V2.1 boards that had bad silkscreen and
pogo-pins. The lower board has a PCF8574 at 0x20 so it can spy on the
TRIG signals being sent to the test board. The echo pins are driven from
arduino digital pins.

I ran into horrible problems writing things to the test board and
consistently seeing the result when read back from the jig. At first I
thought it might be a pullup resistor issue, but finally I isolated it
to some kind of timing issue and/or interaction with Serial or some othe
rinternal arduino interrupts.

So with all the debug chatter commented out, it gets all the way through
and gives me a green. Actual boards mounted in actual projects seem to
work fine, so this may just be some wierd interaction specific to the
test jig.

error: pathspec 'examples/octosonar_bench/octosonar_bench.ino' did not match any file(s) known to git

--- examples/octosonar_bench/octosonar_bench.ino
+++ examples/octosonar_bench/octosonar_bench.ino
@@ -0,0 +1,228 @@
+/* bench test for Octosonar V2.x
+    for use with test jig on new boards
+
+    (c) Alastair Young 2017
+*/
+
+#include <Wire.h>
+
+#define JIGADDR 0x20
+#define OCTO_ADDR 0x38
+#define GREEN_LED 13
+#define RED_LED 12
+#define INT_PIN 11
+#define DEBUG_PIN 10
+#define debug(thing) if (digitalRead(DEBUG_PIN) == LOW) {Serial.print(thing);}
+#define debugln(thing) if (digitalRead(DEBUG_PIN) == LOW) {Serial.println(thing); delay(50);}
+#define debugln2(thing,format) if (digitalRead(DEBUG_PIN) == LOW) {Serial.println(thing, format); delay(50);}
+// debug serial chatter all commented out because it seems to interfere with I2C on the jig. Wierd.
+
+uint8_t echoPin[8] = { 2, 3, 4, 5, A0, A1, A2, A3 };
+void setup() {
+  uint8_t i;
+  Serial.begin(9600);
+  Wire.begin();
+  for (i = 0; i <= 7; i++) {
+    pinMode(echoPin[i], OUTPUT);
+    digitalWrite(echoPin[i], LOW);
+  }
+
+  pinMode(GREEN_LED, OUTPUT);
+  digitalWrite(GREEN_LED, HIGH);
+  pinMode(RED_LED, OUTPUT);
+  digitalWrite(RED_LED, HIGH);
+  pinMode(DEBUG_PIN, INPUT_PULLUP);
+
+  byte error = 1;
+  Serial.println("Looking for test jig");
+  while (error != 0) {
+    Wire.beginTransmission(JIGADDR);
+    error = Wire.endTransmission();
+  }
+  Serial.println("Found test jig");
+  Wire.beginTransmission(JIGADDR);
+  Wire.write(0xff); // for read
+  error = Wire.endTransmission(true);
+  if ( error ) {
+    Serial.print("Failed to write to jig error = ");
+    Serial.println(error);
+    digitalWrite(RED_LED, HIGH);
+    while (true) {};
+  }
+  Wire.requestFrom(JIGADDR, 1);
+  Wire.read(); // set to read mode
+  error = Wire.endTransmission(true);
+  if ( error ) {
+    Serial.print("Failed to read from jig error = ");
+    Serial.println(error);
+    digitalWrite(RED_LED, HIGH);
+    while (true) {};
+  }
+  Wire.requestFrom(JIGADDR, 1);
+  Wire.read(); // set to read mode
+  Wire.endTransmission();
+
+}
+void loop() {
+  byte i;
+  byte retVal;
+  byte error = 1;
+  // keep last status 5s before start again
+  delay(5000);
+  digitalWrite(GREEN_LED, LOW);
+  digitalWrite(RED_LED, HIGH);
+  Serial.println("Looking for OctoSonar");
+  while (error != 0) {
+    Wire.beginTransmission(OCTO_ADDR);
+    error = Wire.endTransmission();
+  }
+  Serial.println("Found OctoSonar");
+  digitalWrite(RED_LED, LOW);
+  // wait 1s for good pogopin press
+  delay(1000);
+
+  // set all TRIGs high
+  //  debugln("Set all trigs high");
+  Wire.beginTransmission(OCTO_ADDR);
+  Wire.write(0xff);
+  error = Wire.endTransmission(true);
+  if ( error ) {
+    Serial.print("Failed to write to OctoSonar error = ");
+    Serial.println(error);
+    digitalWrite(RED_LED, HIGH);
+    return;
+  }
+  //read them back
+  Wire.requestFrom(JIGADDR, 1);
+  retVal = Wire.read();
+  Wire.endTransmission();
+
+  if (retVal != 0xff) {
+    Serial.print("Error 2 - I see trigs ");
+    Serial.println(retVal, HEX);
+    digitalWrite(RED_LED, HIGH);
+    return;
+  }
+  // debugln("Trigs all look high");
+
+  // set all echos high
+  for (i = 0; i <= 7; i++) {
+    digitalWrite(echoPin[i], HIGH);
+  }
+
+  // trigs are high, INT should be low from pulldown
+  if (digitalRead(INT_PIN) == HIGH) {
+    Serial.println("Error: INT is high on idle");
+    digitalWrite(RED_LED, HIGH);
+    return;
+  }
+
+  for (byte port = 0; port <= 7; port++) {
+    byte portByte = ~(1 << port);
+    //  debug("Checking port ");
+    //  debugln(port);
+    //  debug("portByte ");
+    //  debugln2(portByte, HEX);
+    // set all echos high
+    for (i = 0; i <= 7; i++) {
+      digitalWrite(echoPin[i], HIGH);
+    }
+    // enable the port
+
+    Wire.beginTransmission(OCTO_ADDR);
+    Wire.write(portByte);
+    error = Wire.endTransmission(true);
+    if ( error ) {
+      Serial.print("Failed to write to OctoSonar error = ");
+      Serial.println(error);
+      digitalWrite(RED_LED, HIGH);
+      return;
+    }
+    //  debug("sent portByte ");
+    //  debugln2(portByte, HEX);
+    //read them back
+    Wire.requestFrom(JIGADDR, 1);
+    retVal = Wire.read();
+    error = Wire.endTransmission(true);
+    if ( error ) {
+      Serial.print("Failed to read from jig error = ");
+      Serial.println(error);
+      digitalWrite(RED_LED, HIGH);
+      return;
+    }
+    if (retVal != portByte) {
+      Serial.print("Error 1 - I see trigs ");
+      Serial.println(retVal, HEX);
+      digitalWrite(RED_LED, HIGH);
+      return;
+    }
+    //    debug("trigs ");
+    //  debugln2(retVal, HEX);
+
+    // check the pin val - should be high
+    if (digitalRead(INT_PIN) == LOW) {
+      Serial.println("Error: INT is low when echo is high");
+      digitalWrite(RED_LED, HIGH);
+      return;
+    }
+    //    debugln("High gives high");
+
+    // drop the other trigs - should have no effect
+    for (i = 0; i <= 7; i++) {
+      if (i == port) continue; // skip self
+      digitalWrite(echoPin[i], LOW);
+      //read them back
+      Wire.requestFrom(JIGADDR, 1);
+      retVal = Wire.read();
+      error = Wire.endTransmission(true);
+      if ( error ) {
+        Serial.print("Failed to read from jig error = ");
+        Serial.println(error);
+        digitalWrite(RED_LED, HIGH);
+        return;
+      }
+      if (retVal != portByte) {
+        Serial.print("Error 3 - I see trigs ");
+        Serial.println(retVal, HEX);
+        digitalWrite(RED_LED, HIGH);
+        return;
+      }
+      if (digitalRead(INT_PIN) == LOW) {
+        Serial.print("Error: INT goes low with pin ");
+        Serial.println(i);
+        Wire.requestFrom(JIGADDR, 1);
+        Serial.println(Wire.read(), HEX);
+        error = Wire.endTransmission(true);
+        if ( error ) {
+          Serial.print("Failed to read from jig error = ");
+          Serial.println(error);
+          digitalWrite(RED_LED, HIGH);
+          return;
+        }
+
+        digitalWrite(RED_LED, HIGH);
+        return;
+      }
+      //     debug("INT ok with low pin ");
+      //     debugln(i);
+    }
+    //   debugln("No interference from other echoes");
+
+    // drop self
+    digitalWrite(echoPin[port], LOW);
+    if (digitalRead(INT_PIN) == HIGH) {
+      Serial.println("Error: INT is high when echo is low");
+      digitalWrite(RED_LED, HIGH);
+      return;
+    }
+    //   debugln("Low gives low");
+  }
+
+  // if we got here, we passed
+  Serial.println("PASS");
+  digitalWrite(GREEN_LED, HIGH);
+  digitalWrite(RED_LED, LOW);
+}
+
+
+


arudino sketch to test the delay of a tv/screen using a zapper

error: pathspec 'arduino/zapper_delay_test/zapper_delay_test.ino' did not match any file(s) known to git

--- arduino/zapper_delay_test/zapper_delay_test.ino
+++ arduino/zapper_delay_test/zapper_delay_test.ino
@@ -0,0 +1,101 @@
+#include <TVout.h>
+#include <video_gen.h>
+#include <font6x8.h>
+
+#define TRIGGER_PIN 3
+#define DETECT_PIN 2
+#define DELAY_TIMEOUT 50
+
+volatile int trigger_state = LOW;
+volatile int detect_state = LOW;
+volatile int vblank = 0;
+
+TVout TV;
+
+void setup() {
+  attachInterrupt(digitalPinToInterrupt(TRIGGER_PIN), trigger_handle, FALLING);
+  attachInterrupt(digitalPinToInterrupt(DETECT_PIN), detect_handle, RISING);
+
+  TV.begin(PAL, 120, 96);
+  TV.clear_screen();
+  TV.select_font(font6x8);
+  TV.set_vbi_hook(vbi_hook_flag);
+
+  reset_state();
+}
+
+/*
+ * Latch TRIGGER state
+ */
+void trigger_handle() {
+  trigger_state = HIGH;
+}
+
+/*
+ * Latch DETECT state
+ */
+void detect_handle() {
+  detect_state = HIGH;
+}
+
+/*
+ * Reset the state of TRIGGER and DETECT
+ */
+inline void reset_state() {
+  trigger_state = LOW;
+  detect_state = LOW;
+}
+
+/*
+ * Set flag when vertical blank happens
+ */
+void vbi_hook_flag() {
+  vblank = 1;
+}
+
+/*
+ * Wait for veritcal blank and reset the flag
+ */
+inline void wait_for_vblank() {
+  while (!vblank);
+  vblank = 0;
+}
+
+/*
+ *
+ */
+void loop() {
+  int delay_count = 0;
+  reset_state();
+  TV.clear_screen();
+  TV.println(0, 0, "Point the Zapper at the TV and pull the trigger");
+
+  while (trigger_state == LOW); // wait for the trigger
+
+  wait_for_vblank();
+
+  // Set the screen to white for 2 frames
+  TV.fill(WHITE);
+  wait_for_vblank();
+  wait_for_vblank();
+
+  TV.clear_screen();
+
+  delay_count = 2;
+
+  // count the number of frames
+  while (detect_state == LOW && delay_count++ < DELAY_TIMEOUT) {
+    wait_for_vblank();
+  }
+
+  TV.clear_screen();
+  if (detect_state == HIGH) {
+    TV.print(0, 0, "Zapper triggered DETECT pin with a delay of:");
+    TV.print(0, 30, delay_count);
+  } else {
+    TV.println(0, 0, "Zapper did not trigger the DETECT pin before timeout");
+  }
+  reset_state();
+  while (trigger_state == LOW); // wait for the trigger
+}
+


Add accelerometer example

Add accelerometer example

error: pathspec 'arduino/accelerometer/accelerometer.ino' did not match any file(s) known to git

--- arduino/accelerometer/accelerometer.ino
+++ arduino/accelerometer/accelerometer.ino
@@ -0,0 +1,91 @@
+/******************************************************************************
+MMA8452Q_Basic.ino
+SFE_MMA8452Q Library Basic Example Sketch
+Jim Lindblom @ SparkFun Electronics
+Original Creation Date: June 3, 2014
+https://github.com/sparkfun/MMA8452_Accelerometer
+
+This sketch uses the SFE_MMA8452Q library to initialize the
+accelerometer, and stream values from it.
+
+Hardware hookup:
+  Arduino --------------- MMA8452Q Breakout
+    3.3V  ---------------     3.3V
+    GND   ---------------     GND
+  SDA (A4) --\/330 Ohm\/--    SDA
+  SCL (A5) --\/330 Ohm\/--    SCL
+
+The MMA8452Q is a 3.3V max sensor, so you'll need to do some
+level-shifting between the Arduino and the breakout. Series
+resistors on the SDA and SCL lines should do the trick.
+
+Development environment specifics:
+	IDE: Arduino 1.0.5
+	Hardware Platform: Arduino Uno
+
+This code is beerware; if you see me (or any other SparkFun employee) at the
+local, and you've found our code helpful, please buy us a round!
+
+Distributed as-is; no warranty is given.
+******************************************************************************/
+#include <Wire.h> // Must include Wire library for I2C
+#include <SFE_MMA8452Q.h> // Includes the SFE_MMA8452Q library
+
+#define MMA8452_ADDRESS 0x1D
+// Begin using the library by creating an instance of the MMA8452Q
+//  class. We'll call it "accel". That's what we'll reference from
+//  here on out.
+MMA8452Q accel(MMA8452_ADDRESS);
+
+// The setup function simply starts serial and initializes the
+//  accelerometer.
+void setup()
+{
+  Serial.begin(9600);
+  // Choose your adventure! There are a few options when it comes
+  // to initializing the MMA8452Q:
+  //  1. Default init. This will set the accelerometer up
+  //     with a full-scale range of +/-2g, and an output data rate
+  //     of 800 Hz (fastest).
+  accel.init();
+  //  2. Initialize with FULL-SCALE setting. You can set the scale
+  //     using either SCALE_2G, SCALE_4G, or SCALE_8G as the value.
+  //     That'll set the scale to +/-2g, 4g, or 8g respectively.
+  //accel.init(SCALE_4G); // Uncomment this out if you'd like
+  //  3. Initialize with FULL-SCALE and DATA RATE setting. If you
+  //     want control over how fast your accelerometer produces
+  //     data use one of the following options in the second param:
+  //     ODR_800, ODR_400, ODR_200, ODR_100, ODR_50, ODR_12,
+  //     ODR_6, or ODR_1.
+  //     Sets to 800, 400, 200, 100, 50, 12.5, 6.25, or 1.56 Hz.
+  //accel.init(SCALE_8G, ODR_6);
+}
+
+// The loop function will simply check for new data from the
+//  accelerometer and print it out if it's available.
+void loop()
+{
+  // Use the accel.available() function to wait for new data
+  //  from the accelerometer.
+  if (accel.available())
+  {
+    // First, use accel.read() to read the new variables:
+    accel.read();
+    printCalculatedAccels();
+    Serial.println(); // Print new line every time.
+  }
+}
+
+// This function demonstrates how to use the accel.cx, accel.cy,
+//  and accel.cz variables.
+// Before using these variables you must call the accel.read()
+//  function!
+void printCalculatedAccels()
+{
+  Serial.print(accel.cx, 3);
+  Serial.print("\t");
+  Serial.print(accel.cy, 3);
+  Serial.print("\t");
+  Serial.print(accel.cz, 3);
+  Serial.print("\t");
+}


Added arduino state machine.

Added arduino state machine.

error: pathspec 'arduino-serial/arduino-serial.ino' did not match any file(s) known to git

--- arduino-serial/arduino-serial.ino
+++ arduino-serial/arduino-serial.ino
@@ -0,0 +1,126 @@
+
+#include <Servo.h>
+
+
+#define fsrAnalogPin A0 // FSR is connected to analog 0
+#define servoPin 3 // Pin for servo
+#define loraSSPin 10 // Pin for Slave Select Lora Shield
+#define rfidSSPin 9 // Pin for Slave Select RFID Shield
+
+#define STATE_EMPTY 0
+#define STATE_FULL 1
+#define STATE_LOCKED 2
+int state = 0;
+
+Servo myservo;  // create servo object to control a servo
+String inputString = "";         // a string to hold incoming data
+boolean stringComplete = false;  // whether the string is complete
+
+void setup() {
+  myservo.attach(servoPin);  // attaches the servo on pin 9 to the servo object
+  pinMode(rfidSSPin, OUTPUT);
+  digitalWrite(rfidSSPin, HIGH);
+  // Disable Lora shield since we use usb communication for the moment.
+  pinMode(loraSSPin, OUTPUT);
+  digitalWrite(loraSSPin, HIGH);
+
+  Serial.begin(9600);
+  while (!Serial) ; // Wait for serial port to be available
+  // reserve 200 bytes for the inputString:
+  inputString.reserve(200);
+}
+
+void loop() {
+  switch(state){
+    case(STATE_EMPTY):
+      StateEmpty();
+      break;
+    case(STATE_FULL):
+      StateFull();
+      break;
+    case(STATE_LOCKED):
+      StateLocked();
+      break;
+  }
+
+}
+
+void StateEmpty(){
+  if(GetFsrValue() > 0){
+    state = STATE_FULL;
+  } else {
+    delay(1000);
+  }
+}
+
+void StateLocked(){
+  if(stringComplete){
+    Serial.print("Received message: ");
+    Serial.print(inputString);
+    Serial.println(";");
+
+    if(inputString == "unlock"){
+      Open();
+      state = STATE_FULL;
+    }
+    // clear the string:
+    inputString = "";
+    stringComplete = false;
+  }
+  // TODO Read RFID
+}
+
+// Close after a delay, so you have time to close the lid.
+void StateFull(){
+  delay(5000);
+  int fsrValue = GetFsrValue();
+  if(fsrValue > 0){
+    Close();
+    printFsrValue(fsrValue);
+    state = STATE_LOCKED;
+  } else {
+    printFsrValue(fsrValue);
+    state = STATE_EMPTY;
+  }
+}
+
+int GetFsrValue(){
+  return analogRead(fsrAnalogPin);
+}
+
+void Close(){
+  myservo.write(170);
+}
+
+void Open(){
+    myservo.write(0);
+}
+
+void printFsrValue(int value){
+    Serial.print("fsrValue:");
+    Serial.print(value);
+    Serial.println();
+}
+
+
+/*
+  SerialEvent occurs whenever a new data comes in the
+ hardware serial RX.  This routine is run between each
+ time loop() runs, so using delay inside loop can delay
+ response.  Multiple bytes of data may be available.
+ */
+void serialEvent() {
+  while (Serial.available()) {
+    // get the new byte:
+    char inChar = (char)Serial.read();
+    // if the incoming character is a newline, set a flag
+    // so the main loop can do something about it:
+    if (inChar == '\n') {
+      stringComplete = true;
+    } else {
+      // add it to the inputString:
+      inputString += inChar;
+    }
+  }
+}
+


Added DISCLAIMER to Main Data

Added DISCLAIMER to Main Data

error: pathspec 'Data' did not match any file(s) known to git
error: pathspec 'Logging/Data-Logging-Main/Data-Logging-Main.ino' did not match any file(s) known to git


Barometer data sending modified

Barometer data sending modified

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/quinten991/PenO3OnTrack.git/'