New version of Arduino sketch : both get Rx inputs and Set ESCs

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

--- ARDUINO/i2c_rx_and_servo/i2c_rx_and_servo.ino
+++ ARDUINO/i2c_rx_and_servo/i2c_rx_and_servo.ino
@@ -0,0 +1,328 @@
+/*//
+
+  Author : Vincent Jaunet
+
+
+ This sketch is made for
+  - Get RC from Rx receiver
+  - transmit to Rpi pilot
+  - Receive ESC and Servos input from Rpi Pilot
+
+ based onrcarduino.blogspot.com
+
+*/
+
+// include the pinchangeint library - see the links in the related topics section above for details
+#include <PinChangeInt.h>
+#include <Wire.h>
+#include <Servo.h>
+
+//Define I2C variables
+#define SLAVE_ADDRESS 0x04
+
+//LED pin for checking
+#define LED_PIN 13
+
+//For RC inputs Scaling
+#define THR_MIN 890
+#define THR_MAX 1895
+#define RC_MIN 1000
+#define RC_MAX 2000
+#define K_YAW 30
+#define K_PITCH 20
+#define K_ROLL 20
+
+// These bit flags are set in bUpdateFlagsShared to indicate which
+// channels have new signals
+#define THROTTLE_FLAG 1
+#define YAW_FLAG 2
+#define PITCH_FLAG 4
+#define ROLL_FLAG 8
+
+// Assign your channel in pins
+#define THROTTLE_IN_PIN 8
+#define YAW_IN_PIN 11
+#define PITCH_IN_PIN 10
+#define ROLL_IN_PIN 9
+
+
+// holds the update flags defined above
+volatile uint8_t bUpdateFlagsShared;
+
+// shared variables are updated by the ISR and read by loop.
+// In loop we immediatley take local copies so that the ISR can keep ownership of the
+// shared ones. To access these in loop
+// we first turn interrupts off with noInterrupts
+// we take a copy to use in loop and the turn interrupts back on
+// as quickly as possible, this ensures that we are always able to receive new signals
+volatile uint16_t unThrottleInShared;
+volatile uint16_t unYawInShared;
+volatile uint16_t unPitchInShared;
+volatile uint16_t unRollInShared;
+
+// These are used to record the rising edge of a pulse in the calcInput functions
+// They do not need to be volatile as they are only used in the ISR. If we wanted
+// to refer to these in loop and the ISR then they would need to be declared volatile
+uint32_t ulThrottleStart;
+uint32_t ulYawStart;
+uint32_t ulPitchStart;
+uint32_t ulRollStart;
+
+
+//servo variables
+//Number of servos
+#define SERVO_NUM 4
+
+// Assign your channel out pins
+#define FL_MOTOR_OUT_PIN 4
+#define FR_MOTOR_OUT_PIN 5
+#define BL_MOTOR_OUT_PIN 6
+#define BR_MOTOR_OUT_PIN 7
+
+//define Servo variables
+Servo MOTOR[SERVO_NUM];
+
+
+void setup()
+{
+  Serial.begin(9600);
+  Serial.println("multiChannels");
+
+  pinMode(LED_PIN, OUTPUT);
+
+  // using the PinChangeInt library, attach the interrupts
+  // used to read the channels
+  PCintPort::attachInterrupt(THROTTLE_IN_PIN, calcThrottle,CHANGE);
+  PCintPort::attachInterrupt(YAW_IN_PIN, calcYaw,CHANGE);
+  PCintPort::attachInterrupt(PITCH_IN_PIN, calcPitch,CHANGE);
+  PCintPort::attachInterrupt(ROLL_IN_PIN, calcRoll,CHANGE);
+
+  // attach servo objects, these will generate the correct
+  // pulses for driving Electronic speed controllers, servos or other devices
+  // designed to interface directly with RC Receivers
+  MOTOR[0].attach(FL_MOTOR_OUT_PIN);
+  MOTOR[1].attach(FR_MOTOR_OUT_PIN);
+  MOTOR[2].attach(BL_MOTOR_OUT_PIN);
+  MOTOR[3].attach(BR_MOTOR_OUT_PIN);
+  Wire.onReceive(SetServos);
+
+  // initialize i2c as slave
+  // define call backs ofr I2C
+  Wire.begin(SLAVE_ADDRESS);
+  Wire.onRequest(SendRemote);
+  Wire.onReceive(SetServos);
+
+}
+
+void loop()
+{
+  // create local variables to hold a local copies of the channel inputs
+  // these are declared static so that thier values will be retained
+  // between calls to loop.
+  static uint16_t unThrottleIn;
+  static uint16_t unYawIn;
+  static uint16_t unPitchIn;
+  static uint16_t unRollIn;
+  // local copy of update flags
+  static uint8_t bUpdateFlags;
+
+  // check shared update flags to see if any channels have a new signal
+  if(bUpdateFlagsShared)
+    {
+      noInterrupts(); // turn interrupts off quickly while we take local copies of the shared variables
+
+      // take a local copy of which channels were updated in case we need to use this in the rest of loop
+      bUpdateFlags = bUpdateFlagsShared;
+
+      // in the current code, the shared values are always populated
+      // so we could copy them without testing the flags
+      // however in the future this could change, so lets
+      // only copy when the flags tell us we can.
+
+      if(bUpdateFlags & THROTTLE_FLAG)
+	{
+	  unThrottleIn = unThrottleInShared;
+	}
+
+      if(bUpdateFlags & YAW_FLAG)
+	{
+	  unYawIn = unYawInShared;
+	}
+
+      if(bUpdateFlags & PITCH_FLAG)
+	{
+	  unPitchIn = unPitchInShared;
+	}
+
+      if(bUpdateFlags & ROLL_FLAG)
+	{
+	  unRollIn = unRollInShared;
+	}
+
+      // clear shared copy of updated flags as we have already take
+      // we still have a local copy if we need to use it in bUpdateFlags
+      bUpdateFlagsShared = 0;
+
+      interrupts(); // we have local copies of the inputs, so now we can turn interrupts back on
+      // as soon as interrupts are back on, we can no longer use the shared copies, the interrupt
+      // service routines own these and could update them at any time. During the update, the
+      // shared copies may contain junk. Luckily we have our local copies to work with :-)
+    }
+
+  bUpdateFlags = 0;
+}
+
+
+// On request I2C data Sends shared values the Remote values
+// for Throttle, Yaw, Pitch and Roll
+// Note interrupts sotpped while sending values, should not
+// take much time
+void SendRemote()
+{
+
+  union Sharedblock
+  {
+    byte b[4]; // utiliser char parts[4] pour port série
+    float d;
+  } RCsignal[4];
+
+  RCsignal[0].d=
+    (float) (unThrottleInShared-THR_MIN)/
+    (THR_MAX-THR_MIN) * 100.0;
+  RCsignal[1].d=
+     ((float) unYawInShared-(RC_MAX+RC_MIN)/2)/
+    (RC_MAX-RC_MIN) * K_YAW;
+  RCsignal[2].d=
+     ((float) unPitchInShared-(RC_MAX+RC_MIN)/2)/
+    (RC_MAX-RC_MIN) * K_PITCH;
+  RCsignal[3].d=
+     ((float) unRollInShared-(RC_MAX+RC_MIN)/2)/
+    (RC_MAX-RC_MIN) * K_ROLL;
+
+
+
+  byte data[16];
+  for (int i=0;i<4;i++)
+    {
+    for (int ii=0;ii<4;ii++)
+      {
+	data[ii+4*i] = RCsignal[i].b[ii];
+      }
+    }
+
+  Wire.write(data,16);
+
+}
+
+// simple interrupt service routine
+void calcThrottle()
+{
+  // if the pin is high, its a rising edge of the signal pulse, so lets record its value
+  if(digitalRead(THROTTLE_IN_PIN) == HIGH)
+    {
+      ulThrottleStart = micros();
+    }
+  else
+    {
+      // else it must be a falling edge, so lets get the time and subtract the time of the rising edge
+      // this gives use the time between the rising and falling edges i.e. the pulse duration.
+      unThrottleInShared = (uint16_t)(micros() - ulThrottleStart);
+      // use set the throttle flag to indicate that a new throttle signal has been received
+      bUpdateFlagsShared |= THROTTLE_FLAG;
+    }
+}
+
+void calcYaw()
+{
+  if(digitalRead(YAW_IN_PIN) == HIGH)
+    {
+      ulYawStart = micros();
+    }
+  else
+    {
+      unYawInShared = (uint16_t)(micros() - ulYawStart);
+      bUpdateFlagsShared |= YAW_FLAG;
+    }
+}
+
+void calcPitch()
+{
+  if(digitalRead(PITCH_IN_PIN) == HIGH)
+    {
+      ulPitchStart = micros();
+    }
+  else
+    {
+      unPitchInShared = (uint16_t)(micros() - ulPitchStart);
+      bUpdateFlagsShared |= PITCH_FLAG;
+    }
+}
+
+void calcRoll()
+{
+  if(digitalRead(ROLL_IN_PIN) == HIGH)
+    {
+      ulRollStart = micros();
+    }
+  else
+    {
+      unRollInShared = (uint16_t)(micros() - ulRollStart);
+      bUpdateFlagsShared |= ROLL_FLAG;
+    }
+}
+
+
+void SetServos(int byteCount)
+{
+
+// the RPI shoud send 4 x 1 uint16_t (2 bytes) values
+// one for each PID updated Motor speed
+
+  union int_byt{
+    uint8_t b[2];
+    uint16_t i;
+  };
+
+  uint8_t trash;
+
+  //Expected bytes to be received
+  union int_byt *rcv_data = new int_byt[SERVO_NUM];
+
+  if (byteCount == 8)
+    {
+      while(Wire.available()) {
+
+	for (int i=0;i<SERVO_NUM;i++)
+	  {
+	    rcv_data[i].b[0] = Wire.read(); //upper bits?
+	    rcv_data[i].b[1] = Wire.read(); //upper bits?
+	  }
+      }
+
+    }
+  else {
+    //short read from master
+    //Do nothing
+    // Serial.println("Short read from master :");
+    // Serial.print("Expected 8 bytes,");
+    // Serial.print("Received ");
+    // Serial.print(byteCount);
+    // Serial.println(" bytes");
+
+    return;
+  }
+
+  //Update servo values
+  for (int i=0;i<SERVO_NUM;i++)
+    {
+      	    // Serial.print("Received value ");
+	    // Serial.print(i);
+	    // Serial.print(" = ");
+	    // Serial.println(rcv_data[i].i);
+
+      MOTOR[i].writeMicroseconds(rcv_data[i].i);
+    }
+
+  return;
+
+}


version 29/8

version 29/8

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/janiversen/SolarPower.git/'


Remove FIXME (did this).

Remove FIXME (did this).

--- examples/vseg/vseg.ino
+++ examples/vseg/vseg.ino
@@ -386,8 +386,6 @@

   void widgets_points_scroll_callback(uint8_t selected, int delta)
   {
-    // FIXME: don't edit the save params directly - swap them in between gates
-
     const uint8_t p = (selected + 1) / 2;
     const uint8_t parameter = selected & 1;


Initial arduino fw

Initial arduino fw

Includes initial tach feed reading on an arbitrary digital pin. Note
that this requires the feed volts to be regulated down to 5V HIGH, 0V
LOW (from the tach feed it is ~12V).

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

--- arduino/btdash/btdash.ino
+++ arduino/btdash/btdash.ino
@@ -0,0 +1,85 @@
+#include <digitalWriteFast.h>
+
+
+// By default, communicate at this bitrate. The listener client must match this value.
+const unsigned long SERIAL_BPS = 115200;
+
+#define VERSION_STRING "BTDASH_0.0.1"
+
+// time constants for readability
+const unsigned long MILLIS_PER_SECOND = 1000;
+const unsigned long MICROS_PER_SECOND = 1000000;
+
+// 33% duty cycle. For a 50% duty cycle, use 2, etc.
+const unsigned int TACH_DUTY_CYCLE = 3;
+const unsigned long MICROS_PER_RPM = 100 * MICROS_PER_SECOND / (3 * TACH_DUTY_CYCLE);
+
+// input mapping
+const unsigned int PIN_TACH = 52;
+
+// output mapping
+#define SERIAL_BT Serial
+
+unsigned long duration;
+// word size is 16 bits, so max RPM is 32767. If your engine revs that high, you're driving an F1 from 2154!
+unsigned int uRpm = 0;
+unsigned long ulRpmTrigger = 0;
+
+// the setup routine runs once when you power on or press reset
+void setup()  {
+  // initialize the serial output
+  SERIAL_BT.begin(SERIAL_BPS);
+
+  pinMode(PIN_TACH, INPUT);
+  establishContact();
+}
+
+// the loop routine runs over and over again forever
+void loop() {
+  readTach();
+  writeDash();
+
+  delay(500);
+}
+
+void establishContact() {
+  while (SERIAL_BT.available() <= 0) {
+    SERIAL_BT.println(VERSION_STRING); // send an initial string
+    delay(500);
+  }
+}
+
+//
+// write the current state of the instruments to the serial output.
+//
+void writeDash() {
+  if (SERIAL_BT.available() > 0) {
+    SERIAL_BT.print("rpm=");
+    SERIAL_BT.print(uRpm);
+
+    SERIAL_BT.println();
+  }
+}
+
+//
+// read the tachometer feed from the car's ECU
+//
+void readTach() {
+  // On the Ariel Atom 2 w/ SPA dash, the tach signal is a 12V pulse with a 33% duty cycle on pin 1 of the SPA harness.
+  if (digitalRead(PIN_TACH) == LOW) {
+    if (ulRpmTrigger != 0) {
+      uRpm = MICROS_PER_RPM / (micros() - ulRpmTrigger);
+
+      // reset the trigger
+      ulRpmTrigger = 0;
+    }
+  }
+  else if (ulRpmTrigger == 0) {
+    // transitioning from low to high.
+    ulRpmTrigger = micros();
+  }
+}
+
+
+
+


Added test code which times sensor readings and outputs them on serial.  Allows long runs to discern a suitable value for the minimum sensor threshold.

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

--- PIRTest/PIRTest.ino
+++ PIRTest/PIRTest.ino
@@ -0,0 +1,277 @@
+#include <GSM.h>
+#include <Time.h>
+
+const int kReadingsBufferSize = 30;
+volatile int gReadingIdx = 0;
+unsigned long gReadingsBuffer[30];
+
+#define MEGA 0
+
+#if MEGA
+// The Mega-Hera200 doesn't expose Serial to the expansion connector
+// but Serial3 is on PJ0 and PJ1
+#define LOG_SERIAL_PORT Serial3
+// PIR sensor constants
+const int kPIRSensorPin = 20;
+const int kPIRSensorInterrupt = 3;
+
+#else
+
+// PIR sensor constants
+const int kPIRSensorPin = 1;
+const int kPIRSensorInterrupt = 3;
+#define LOG_SERIAL_PORT Serial
+
+#endif
+
+
+volatile int movementCount =0;
+volatile unsigned long movementStart =0;
+int lastMovementCount =0;
+unsigned long lastMovementTime =0;
+
+
+void setup() {
+  // put your setup code here, to run once:
+  LOG_SERIAL_PORT.begin(9600);
+  while (!LOG_SERIAL_PORT) {
+    ; // wait for serial port to connect. Needed for Leonardo only
+  }
+  pinMode(kPIRSensorPin, INPUT);
+  attachInterrupt(kPIRSensorInterrupt, movementDetected, CHANGE);
+  LOG_SERIAL_PORT.println("Let's go!");
+
+  findTime();
+}
+
+volatile int gLastIdx = 0;
+
+class PrintTime : public Printable
+{
+public:
+  PrintTime(time_t aTime) : iTime(aTime) {};
+  virtual size_t printTo(Print& p) const;
+protected:
+  time_t iTime;
+};
+
+size_t PrintTime::printTo(Print& p) const
+{
+  size_t ret = 0;
+  tmElements_t time_elements;
+
+  breakTime(iTime, time_elements);
+  ret += p.print(tmYearToCalendar(time_elements.Year));
+  ret += p.print("-");
+  if (time_elements.Month < 10)
+  {
+    ret += p.print("0");
+  }
+  ret += p.print(time_elements.Month);
+  ret += p.print("-");
+  if (time_elements.Day < 10)
+  {
+    ret += p.print("0");
+  }
+  ret += p.print(time_elements.Day);
+  ret += p.print("T");
+  if (time_elements.Hour < 10)
+  {
+    ret += p.print("0");
+  }
+  ret += p.print(time_elements.Hour);
+  ret += p.print(":");
+  if (time_elements.Minute < 10)
+  {
+    ret += p.print("0");
+  }
+  ret += p.print(time_elements.Minute);
+  ret += p.print(":");
+  if (time_elements.Second < 10)
+  {
+    ret += p.print("0");
+  }
+  ret += p.print(time_elements.Second);
+  ret += p.print("Z");
+
+  return ret;
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+  int newIdx = gReadingIdx;
+  if (newIdx != gLastIdx)
+  {
+    // We've got a new reading
+    unsigned long the_time = now();
+    PrintTime pt(the_time);
+    LOG_SERIAL_PORT.print(pt);
+    LOG_SERIAL_PORT.print(",");
+    LOG_SERIAL_PORT.print(the_time);
+    LOG_SERIAL_PORT.print(",");
+    LOG_SERIAL_PORT.print(gLastIdx);
+    LOG_SERIAL_PORT.print(",");
+    LOG_SERIAL_PORT.println(gReadingsBuffer[gLastIdx]);
+    gLastIdx = newIdx;
+  }
+  delay(100);
+}
+
+void movementDetected()
+{
+  if (digitalRead(kPIRSensorPin))
+  {
+    movementStart = millis();
+  }
+  else
+  {
+    // Find out how long we've been active, and use that to guide
+    // how many people we think have passed
+    movementCount++;
+    // AMc - the 4430 is the right value, using the lower one
+    // AMc - during testing to check we get decent readings
+//    if (millis()-movementStart > 4430) {
+    if (millis()-movementStart > 4030) {
+      gReadingsBuffer[gReadingIdx++] = millis()-movementStart;
+      if (gReadingIdx >= kReadingsBufferSize)
+      {
+        gReadingIdx = 0;
+      }
+    }
+  }
+}
+
+void findTime()
+{
+  GSMClock modem;
+
+  if(modem.begin())
+  {
+#if DEBUG
+    LOG_SERIAL_PORT.println("modem.begin() succeeded");
+#endif
+  }
+  else
+  {
+#if DEBUG
+    LOG_SERIAL_PORT.println("ERROR, no modem answer.");
+#endif
+  }
+
+  if (modem.getTime()[0] == '0')
+  {
+    // The modem is reporting a time from the 2000s, which means
+    // it's not the right time
+#if !DEBUG
+    LOG_SERIAL_PORT.begin(9600);
+#endif
+
+    // Try to set it from the network
+    if (!modem.setTimeFromNetwork(1*60*1000UL))
+    {
+      LOG_SERIAL_PORT.println("Didn't get the time signal from the network");
+      // Give the user a window to set it via the serial monitor
+      LOG_SERIAL_PORT.println("Enter the time (in seconds since Jan 1 1970):");
+      LOG_SERIAL_PORT.setTimeout(5*60*1000UL);
+      unsigned long the_time = LOG_SERIAL_PORT.parseInt();
+      LOG_SERIAL_PORT.print("Got time of ");
+      LOG_SERIAL_PORT.println(the_time);
+      if (the_time > 0)
+      {
+        // We've been given a time, so let's use it
+        modem.setTime(timeToString(now()));
+      }
+    }
+  }
+  // Set the Time library time from the modem
+  String modemTime = modem.getTime();
+  LOG_SERIAL_PORT.print("The time is ");
+  LOG_SERIAL_PORT.println(modemTime);
+  setTimeFromModem(modemTime);
+  LOG_SERIAL_PORT.print("The internal time is ");
+  LOG_SERIAL_PORT.println(now());
+#if !DEBUG
+  LOG_SERIAL_PORT.end();
+#endif
+}
+
+String timeToString(time_t aTime)
+{
+  TimeElements time_elements;
+  breakTime(aTime, time_elements);
+  String ret(tmYearToY2k(time_elements.Year));
+  ret += "/";
+  if (time_elements.Month < 10)
+  {
+    ret += "0";
+  }
+  ret += time_elements.Month;
+  ret += "/";
+  if (time_elements.Day < 10)
+  {
+    ret += "0";
+  }
+  ret += time_elements.Day;
+  ret += ",";
+  if (time_elements.Hour < 10)
+  {
+    ret += "0";
+  }
+  ret += time_elements.Hour;
+  ret += ":";
+  if (time_elements.Minute < 10)
+  {
+    ret += "0";
+  }
+  ret += time_elements.Minute;
+  ret += ":";
+  if (time_elements.Second < 10)
+  {
+    ret += "0";
+  }
+  ret += time_elements.Second;
+  ret += "+00";
+  return ret;
+}
+
+void setTimeFromModem(String& aTime)
+{
+  const int kDateTimeStringLength = 20;
+  const int kYearOffset = 0;
+  const int kYearLength = 2;
+  const int kMonthOffset = 3;
+  const int kMonthLength = 2;
+  const int kDayOffset = 6;
+  const int kDayLength = 2;
+  const int kHourOffset = 9;
+  const int kHourLength = 2;
+  const int kMinuteOffset = 12;
+  const int kMinuteLength = 2;
+  const int kSecondOffset = 15;
+  const int kSecondLength = 2;
+
+  if (aTime.length() >= kDateTimeStringLength)
+  {
+    String component = aTime.substring(kYearOffset, kYearOffset+kYearLength);
+    tmElements_t time_elements;
+#if DEBUG
+    LOG_SERIAL_PORT.println(component);
+#endif
+    time_elements.Year = y2kYearToTm(component.toInt());
+    component = aTime.substring(kMonthOffset, kMonthOffset+kMonthLength);
+    time_elements.Month = component.toInt();
+    component = aTime.substring(kDayOffset, kDayOffset+kDayLength);
+    time_elements.Day = component.toInt();
+    component = aTime.substring(kHourOffset, kHourOffset+kHourLength);
+    time_elements.Hour = component.toInt();
+    component = aTime.substring(kMinuteOffset, kMinuteOffset+kMinuteLength);
+    time_elements.Minute = component.toInt();
+    component = aTime.substring(kSecondOffset, kSecondOffset+kSecondLength);
+    time_elements.Second = component.toInt();
+
+    // Now use that to set the time
+    setTime(makeTime(time_elements));
+  }
+}
+
+


- Adicionado calibração do sensor ORP

- Adicionado calibração do sensor ORP

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

--- calibration/calibrationORP/calibrationORP.ino
+++ calibration/calibrationORP/calibrationORP.ino
@@ -0,0 +1,96 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2015 DEV Tecnologia, Rede Infoamazônia
+
+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.
+*/
+
+// Offset values
+float orpOffset = 0.0;
+
+// Analog I/O pins
+const byte ORP_PIN = A11;
+
+const byte MULT_A = 42;
+const byte MULT_B = 43;
+const byte MULT_C = 40;
+
+const byte S1_EN = A5; // S1: EC sensor
+const byte S2_EN = A6; // S2: ORP sensor
+const byte S3_EN = A7; // S3: pH sensor
+
+void setup() {
+  Serial.begin(115200);
+
+  // Set output pins
+  pinMode(S1_EN, OUTPUT);
+  digitalWrite(S1_EN, HIGH);
+  pinMode(S2_EN, OUTPUT);
+  digitalWrite(S2_EN, HIGH);
+  pinMode(S3_EN, OUTPUT);
+  digitalWrite(S3_EN, HIGH);
+
+  pinMode(MULT_A, OUTPUT);
+  digitalWrite(MULT_A, HIGH);
+  pinMode(MULT_B, OUTPUT);
+  digitalWrite(MULT_B, HIGH);
+  pinMode(MULT_C, OUTPUT);
+  digitalWrite(MULT_C, LOW);
+
+  Serial.println("Beginning callibration...");
+  Serial.println("Insert a 'Short Circuit' on the ORP opening.");
+  Serial.println("Press enter after the 'Short' is inserted.");
+  while (Serial.available() == 0);
+  Serial.readString();
+  Serial.println("Measuring...");
+  Serial.println();
+
+  orpOffset =  read_orp();
+
+  Serial.println("----------------------------------");
+  Serial.println("Values to calibrate the meter:");
+  Serial.print("orpOffset: ");
+  Serial.println(orpOffset);
+  Serial.println("----------------------------------");
+
+  Serial.println();
+  Serial.println();
+  while (Serial.available() == 0);
+  Serial.readString();
+}
+
+void loop(){
+  Serial.println(read_orp());
+}
+
+float read_orp() {
+  // Read ORP
+  delay(500);
+  digitalWrite(S2_EN, LOW);
+  delay(500);
+
+  float val = analogRead(ORP_PIN) / 1024.0;
+  val = (30.0 * 5.0 * 1000.0) - (75.0 * val * 5.0 * 1000);
+  val = (val / 75.0) - orpOffset;
+
+  digitalWrite(S2_EN, HIGH);
+
+  return val;
+}


Fixed GPS integration

Fixed GPS integration

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/jadalqui/ha_arduino.git/'


Revert the mistaken revert(?) and add clock trim

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/dltn/tortellini.git/'


Create hold.ino

Create hold.ino

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

--- examples/hold.ino
+++ examples/hold.ino
@@ -0,0 +1 @@
+To create folder


DataSafe.ino added /BB

DataSafe.ino added /BB

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

--- DataSafe.ino
+++ DataSafe.ino
@@ -0,0 +1,307 @@
+/***************************************************
+	@author:	bboortz
+	@license:	bsd license
+***************************************************/
+
+
+
+
+/**** library includes ****/
+
+#include <SPI.h>
+#include <Wire.h>                      // this is needed even tho we aren't using it
+
+#include <Adafruit_GFX.h>              // the adafruit core graphics lib
+#include <Adafruit_ILI9341.h>          // the adafruit tft lib
+#include <Adafruit_STMPE610.h>         // the adafruit touch lib
+#include <Adafruit_NFCShield_I2C.h>    // the adafruit nfc shield lib
+
+#include <ScreenLib.h>
+#include <NFCLib.h>
+
+//#include <SD.h>
+//#include <SDLib.h>
+
+
+
+
+/**** widget library settings ****/
+
+ScreenLib screen = ScreenLib(TFT_CS, TFT_DC);
+
+
+
+
+/**** ntc settings ****/
+
+Adafruit_NFCShield_I2C nfc(NFC_IRQ_PIN, NFC_RESET_PIN);
+NFCLib nfclib;
+
+char nfc_key[6] = { 0, 0, 0, 0, 0, 0 }; // the key buffer
+uint8_t nfc_key_count = 0;
+
+
+
+
+/**** sd settings ****/
+
+//SDLib sd;
+
+
+
+
+/**** keyboard settings ****/
+
+// TODO: we should do it in the ScreenLib
+uint16_t last_key_press_ms = 0;
+//char last_key = 0;
+
+
+
+
+/**** current state settings ****/
+
+#define STATE_RESET 		0
+#define STATE_NFC_KEY_LOGIN 	1
+#define STATE_NFC_CARD_LOGIN 	2
+#define STATE_SHOW_DATA 	3
+#define STATE_END 		4
+
+uint8_t current_state = STATE_RESET;
+
+
+
+
+/**** display prepare functions ****/
+
+void clearScreen() {
+    screen.clearScreen();
+}
+
+
+void reset() {
+  // reset all global variables
+  current_state = STATE_RESET;
+//  last_key_press_ms = 0;
+//  last_key = 0;
+  memset(nfc_key, 0, sizeof(nfc_key));
+  nfc_key_count = 0;
+
+  // show the splash screen
+  showSplashScreen();
+
+  // reset the sd card controller
+  // sd.setup();
+
+  // reset the touchscreen
+  uint16_t x, y;
+  uint8_t z;
+  while (!screen.getTouchScreen().bufferEmpty()) {
+    screen.getTouchScreen().readData(&x, &y, &z);
+    Serial.println(screen.getTouchScreen().bufferSize());
+  }
+  screen.getTouchScreen().writeRegister8(STMPE_INT_STA, 0xFF);
+
+  // setup nfc
+  nfclib.setupHost();
+
+  // show the nfc screen
+  showNFCKeyScreen();
+}
+
+
+
+
+/**** show screen functions ****/
+
+void showSplashScreen() {
+  screen.fillScreen(ILI9341_BLACK);
+  screen.setCursor(BOXSIZE, BOXSIZE);
+  screen.setTextColor(ILI9341_RED);  screen.setTextSize(4);
+  screen.println("DataSafe");
+
+  screen.setCursor(BOXSIZE*3, BOXSIZE*3);
+  screen.setTextColor(ILI9341_WHITE);  screen.setTextSize(2);
+  screen.println("v1.0");
+}
+
+
+void showNFCKeyScreen() {
+  current_state = STATE_NFC_KEY_LOGIN;
+  clearScreen();
+  screen.writeTextToTop("nfc card login");
+  screen.writeTextToBottom("type your key!");
+  screen.drawKeyboard();
+}
+
+void showNFCCardScreen() {
+  current_state = STATE_NFC_CARD_LOGIN;
+  clearScreen();
+  screen.writeTextToTop("nfc card login");
+  screen.writeTextToBottom("put your ntc card on the shield!");
+}
+
+
+void showDataScreen() {
+  current_state = STATE_SHOW_DATA;
+  screen.fillScreen(ILI9341_BLACK);
+  screen.setCursor(0, 0);
+  screen.setTextColor(ILI9341_WHITE);  screen.setTextSize(2);
+  screen.println("The data:");
+
+  screen.setCursor(BOXSIZE*2, BOXSIZE*2);
+  screen.println("MY SECRET DATA !!");
+
+//  sd.showFile("test.txt");
+
+  delay(3000);
+}
+
+
+
+
+
+
+/**** touchscreen action functions ****/
+
+void actOnTouchScreenInteraction(uint16_t x, uint16_t y, boolean keyboardOn) {
+  uint16_t millis_now = millis();
+  uint16_t millis_delta = millis_now - last_key_press_ms;
+  char c;
+
+  // check polling
+  if (millis_delta <= KEYBOARD_POLLING_MS) {
+    return;
+  }
+
+
+  // actions
+  actOnButtonPress(x, y);
+
+  if (keyboardOn) {
+    if ( nfc_key_count > 5) {
+      return;
+    }
+    c = screen.actOnKeyboardKeyPress(x, y);
+    if (c != 0) {
+      nfc_key[nfc_key_count] = c;
+      nfc_key_count++;
+
+      char dest[12];
+      char *pChar = &c;
+      strcpy(dest, "key: ");
+      strcat(dest, nfc_key);
+      dest[11] = '\0';
+      screen.writeTextToBottom(dest);
+
+
+      // show the nfc screen when password is fullfilled
+      if (nfc_key_count > 5) {
+        showNFCCardScreen();
+      }
+
+    }
+  }
+
+
+  // set last key press for polling
+  last_key_press_ms = millis_now;
+}
+
+void actOnButtonPress(uint16_t x, uint16_t y) {
+    Serial.print(x); Serial.print(" / "); Serial.print(y);
+  Serial.println("");
+  if (SCREEN_BUTTON_MINY + SCREEN_TEXT_PADDING*2.7 >= y && y <= SCREEN_BUTTON_MINY + SCREEN_TEXT_PADDING*2.7 + SCREEN_BUTTON_SIZE * 2) {
+    if (SCREEN_TEXT_PADDING*3 >= x && x <= SCREEN_TEXT_PADDING*3 + SCREEN_BUTTON_SIZE * 2) {
+      reset();
+    }
+  }
+}
+
+
+
+
+/**** state functions ****/
+
+void nextState() {
+  current_state++;
+  if (current_state == STATE_END) {
+    current_state = STATE_RESET;
+  }
+}
+
+void doStateReset() {
+  // show the splash screen
+  reset();
+}
+
+void doStateNfcKeyLogin() {
+    // wait for the touch and show it
+    if (screen.getTouchScreen().bufferEmpty()) {
+      return;
+    }
+    if (! screen.getTouchScreen().touched()) {
+      return;
+    }
+
+
+    // Retrieve a point
+    TS_Point p = screen.touchscreenGetPoint();
+    /*
+    if (p.z == 0) {
+      return;
+    }
+    */
+
+    // act on touchscreen interaction
+    actOnTouchScreenInteraction(p.x, p.y, true);
+}
+
+void doStateNfcCardLogin() {
+
+    // read the nfc card
+    //uint8_t success;
+    uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };                    // Buffer to store the returned UID
+    uint8_t uidLength = nfclib.initTarget(&*uid);               // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
+    nfclib.printTarget();
+
+    // show the data
+    showDataScreen();
+
+    // reset everything()
+    reset();
+}
+
+void doStateShowData() {
+    // show the data
+    showDataScreen();
+
+    nextState();
+}
+
+
+
+
+/**** arduino default functions ****/
+
+void setup(void) {
+  // setup the screen
+  screen.setup();
+}
+
+void loop()
+{
+  // working with the state pattern because we have different screens (states)
+  switch (current_state) {
+    case STATE_RESET:              doStateReset();              break;
+    case STATE_NFC_KEY_LOGIN:      doStateNfcKeyLogin();        break;
+    case STATE_NFC_CARD_LOGIN:     doStateNfcCardLogin();       break;
+    case STATE_SHOW_DATA:          doStateShowData();           break;
+    case STATE_END:                nextState();                 break;
+    default:                       doStateReset();              break;
+  }
+
+}
+
+
+


Changed timing to final mission parameters

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/tylergrreid/Arduino_Flight_Computer.git/'


Got rid of these lines for some reason.

Got rid of these lines for some reason.

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


initial commit of standing desk timer control code

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

--- arduino/standing-desk-timer/standing-desk-timer.ino
+++ arduino/standing-desk-timer/standing-desk-timer.ino
@@ -0,0 +1,131 @@
+/**
+ * TODO:
+ * - display minutes and seconds
+ * - blink led when time out
+ * - show timegoal for 5 seconds after button press
+ * - require button press to clear blinking and reset
+ * - hold down both to display battery
+ */
+
+#include "Arduino.h"
+#include "Wire.h"
+#include "Qduino.h"
+#include <SoftwareSerial.h>
+#include <EEPROM.h>
+
+#define COLON 4
+
+#define INPUT_PIN_INCR 12
+#define INPUT_PIN_DECR 9
+#define SOFTWARE_TX 8
+#define SOFTWARE_RX 7
+
+enum State {
+  COUNTING_DOWN = 0,
+  SETTING_TIME_GOAL = 1,
+  AT_ZERO = 2
+};
+
+qduino q;
+
+
+State state = COUNTING_DOWN;
+int timeGoalMinutes = 1;
+char tempString[10];
+const int timerGoalAddr = 0;
+unsigned long goalTime = 0;
+unsigned long startedSettingTimeGoalMillis = 0;
+
+SoftwareSerial s7s(SOFTWARE_RX, SOFTWARE_TX);
+
+void setup() {
+  State state = COUNTING_DOWN;
+
+  s7s.begin(9600);
+  s7s.write(0x76);  // Clear display
+  s7s.write(0x77);
+  s7s.write(1<<COLON);
+
+  q.setup();
+  pinMode(INPUT_PIN_INCR, INPUT_PULLUP);
+  pinMode(INPUT_PIN_DECR, INPUT_PULLUP);
+
+  timeGoalMinutes = EEPROM.read(timerGoalAddr);
+  timeGoalMinutes = 1;
+  goalTime = millis() + (timeGoalMinutes * 1000L * 60);
+}
+
+void readGoalAdjustment() {
+  int incrVal = digitalRead(INPUT_PIN_INCR);
+  int decrVal = digitalRead(INPUT_PIN_DECR);
+  if (incrVal == HIGH || decrVal == HIGH) {
+    q.setRGB(PURPLE);
+  }
+  if (incrVal == LOW || decrVal == LOW) {
+    state = SETTING_TIME_GOAL;
+    startedSettingTimeGoalMillis = millis();
+    q.setRGB(YELLOW);
+  }
+
+  if (incrVal == LOW) {
+    timeGoalMinutes++;
+  }
+
+  if (decrVal == LOW) {
+    timeGoalMinutes--;
+  }
+
+  EEPROM.write(timerGoalAddr, timeGoalMinutes);
+}
+
+void displayTimeLeft() {
+  unsigned long timeLeftMillis = goalTime - millis();
+
+  if (millis() > goalTime) {
+    goalTime = millis() + (timeGoalMinutes * 1000L * 60);
+    timeLeftMillis = goalTime;
+  }
+
+
+  int totalSeconds = timeLeftMillis / 1000;
+  int seconds = totalSeconds % 60;
+  int minutes = totalSeconds / 60;
+
+  sprintf(tempString, "%02d%02d", minutes, seconds);
+  s7s.print(tempString);
+
+}
+
+void displayTimeGoal() {
+  sprintf(tempString, "%4d", timeGoalMinutes);
+  s7s.print(tempString);
+}
+
+void writeDisplayCustom() {
+  sprintf(tempString, "%d", state);
+  s7s.print(tempString);
+}
+
+void loop() {
+  switch (state) {
+    case COUNTING_DOWN:
+      displayTimeLeft();
+      break;
+
+    case SETTING_TIME_GOAL:
+      displayTimeGoal();
+      if (millis() > (startedSettingTimeGoalMillis + (1000 * 5))) {
+        state = COUNTING_DOWN;
+      }
+      break;
+
+    case AT_ZERO:
+      break;
+
+    default:
+      writeDisplayCustom();
+      break;
+  }
+
+  readGoalAdjustment();
+}


Added sample

Added sample

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

--- examples/Handlers/JustPrintValue/JustPrintValue.ino
+++ examples/Handlers/JustPrintValue/JustPrintValue.ino
@@ -0,0 +1,22 @@
+#define BLYNK_PRINT Serial
+#include <SPI.h>
+#include <Ethernet.h>
+#include <EthernetClient.h>
+#include <BlynkSimpleEthernet.h>
+
+void setup()
+{
+  Serial.begin(115200);
+  Blynk.begin("00000000000000000000000000000000");
+}
+
+BLYNK_ON_WRITE(1)
+{
+  BLYNK_LOG("Got a value: %s", param[0].asStr());
+}
+
+void loop()
+{
+  Blynk.run();
+}
+


cental radio with debug mode

cental radio with debug mode

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

--- firmware/2017/radio_CCcontrol/radio_CCcontrol.ino
+++ firmware/2017/radio_CCcontrol/radio_CCcontrol.ino
@@ -0,0 +1,287 @@
+/**********FIRMWARE PARA ESTUDO EM CONTROLE***********/
+/* http://www-personal.umich.edu/~johannb/Papers/paper43.pdf
+ *  Usando a ideia de cross coupling control
+  */
+
+
+
+
+#include <SPI.h> //for radio
+#include "RF24.h" // for radio
+
+/*************  USER Configuration *****************************/
+/***********radio***********/
+/*Radio pins*/
+//int CE = 10; //pro micro
+//int CS = A0; //pro micro
+int CE = 3; //nano
+int CS = 2; //nano
+
+
+RF24 radio(CE,CS);                        // Set up nRF24L01 radio on SPI bus plus pins 3 & 2 for nano
+
+
+const uint64_t pipes[2] = { 0xABCDABCD71LL, 0x544d52687CLL };   // Radio pipe addresses for the 2 nodes to communicate.
+uint64_t pipeEnvia=pipes[1];
+uint64_t pipeRecebe=pipes[0];
+
+
+struct dataStruct{
+    char data1;
+    int data2;
+}myData;
+
+struct dataStruct2{
+    int motorA=0;
+    int motorB=0;
+};
+
+String inString = "";
+/***************************************************************/
+
+dataStruct2 velocidades;
+
+void setup(void) {
+
+
+  Serial.begin(115200);
+  while(!Serial);
+
+
+  radioSetup();
+
+  Serial.println("Firwmare para estudo em controle");
+  Serial.println("Objetivo: implementar um cross coupling control");
+  Serial.println("Para testar:");
+  Serial.println("* radio      OK");
+  Serial.println("* enconder");
+  Serial.println("* controle");
+  Serial.println("##############");
+  Serial.println();
+  Serial.println();
+  Serial.println();
+
+
+  menu(); //preicsa abrir o serial pelo computador
+}
+
+void loop(){
+  if (Serial.available()){
+    char c = Serial.read();
+    Serial.println();
+
+    switch(c){
+      case '1':
+      {
+        menu();
+        Serial.println();
+        break;
+      }
+      case '2':
+      {
+        Serial.println("Verificando plataforma");
+        plataforma();
+        break;
+      }
+      case '3':
+      {
+        Serial.println("Teste radio");
+        if(radio.isPVariant()){
+          Serial.println("is PVariant");
+        }else{
+          Serial.println("it is not PVariant");
+        }
+        break;
+      }
+      case '4':
+      {
+        radio_status();
+        break;
+      }
+      case '5':
+      {
+        Serial.println(radio.available());
+        break;
+      }
+      case '6':
+      {
+        mandaMensagem();
+        break;
+      }
+      case '7':
+      {
+        recebeMensagem();
+        break;
+      }
+      case '8':
+      {
+        mandaVelocidades();
+        break;
+      }
+      case '9':
+      {
+        repeteVelocidade();
+        break;
+      }
+      case '0':
+      {
+        mandaVelocidadeZero();
+        break;
+      }
+      default:
+      {
+       Serial.println("opcao nao reconhecida");
+       break;
+      }
+    }
+  }
+}
+
+
+void mandaVelocidadeZero(){
+  velocidades.motorA=0;
+  velocidades.motorB=0;
+  radio.stopListening();
+  radio.enableDynamicAck();
+  radio.write(&velocidades,sizeof(velocidades), 1);
+  radio.startListening();
+}
+void menu(){
+  Serial.println("Menu:");
+  Serial.println("1 - menu");
+  Serial.println("2 - plataforma");
+  Serial.println("3 - teste radio (pvariant test)");
+  Serial.println("4 - radio config");
+  Serial.println("5 - verificar se existe mensagem");
+  Serial.println("6 - mandar mensagem");
+  Serial.println("7 - ler mensagem");
+  Serial.println("8 - mandar velocidades");
+  Serial.println("9 - repete a ultima velocidade");
+  Serial.println("0 - para o robo");
+  Serial.println("a - modoOnline");
+
+}
+
+void repeteVelocidade(){
+  if(velocidades.motorA || velocidades.motorB){
+    Serial.print(velocidades.motorA);
+    Serial.print(" ");
+    Serial.print(velocidades.motorB);
+    Serial.print(" ");
+    radio.stopListening();
+    radio.enableDynamicAck();
+    radio.write(&velocidades,sizeof(velocidades), 1);
+    radio.startListening();
+  }
+}
+
+void mandaVelocidades(){
+  Serial.print("Velocidade motor A:");
+  while(!Serial.available());
+  while (Serial.available() > 0) {
+    int inChar = Serial.read();
+    if (isDigit(inChar)) {
+      // convert the incoming byte to a char
+      // and add it to the string:
+      inString += (char)inChar;
+    }
+    delay(30);
+  }
+  velocidades.motorA=inString.toInt();
+  Serial.println(velocidades.motorA);
+  inString = "";
+  Serial.print("Velocidade motor B:");
+  while(!Serial.available());
+  while (Serial.available() > 0) {
+    int inChar = Serial.read();
+    if (isDigit(inChar)) {
+      // convert the incoming byte to a char
+      // and add it to the string:
+      inString += (char)inChar;
+    }
+    delay(30);
+  }
+  velocidades.motorB=inString.toInt();
+  inString = "";
+  Serial.println(velocidades.motorB);
+
+  //velocidades.motorA*=-1;
+  //velocidades.motorB*=-1;
+  radio.stopListening();
+  radio.enableDynamicAck();
+  radio.write(&velocidades,sizeof(velocidades), 1);
+  radio.startListening();
+  delay(50);
+}
+void recebeMensagem(){
+   if(radio.available()){
+     while(radio.available()){
+      radio.read(&myData,sizeof(myData));
+     }
+     Serial.print("mensagem: ");
+     Serial.println(myData.data1);
+   }
+}
+
+void mandaMensagem(){
+  Serial.println("Escreva 1 caractere");
+  while(!Serial.available());
+
+  char c = toupper(Serial.read());
+  myData.data1=c;
+  radio.stopListening();
+  radio.enableDynamicAck();                 //essa funcao precisa andar colada na de baixo
+  radio.write(&myData,sizeof(myData), 1);   //lembrar que precisa enableDynamicAck antes
+                                            // 1-NOACK, 0-ACK
+  radio.startListening();
+  Serial.println(c);
+}
+
+void radio_status(){
+  Serial.print("CE: ");
+  Serial.println(CE);
+  Serial.print("CS: ");
+  Serial.println(CS);
+
+  Serial.print("Channel: ");
+  Serial.print(radio.getChannel());
+  Serial.println("  0-125");
+  Serial.print("PALevel: ");
+  Serial.print(radio.getPALevel());
+  Serial.println("  0-3");
+  Serial.print("DataRate: ");
+  Serial.print(radio.getDataRate());
+  Serial.println("  0->1MBPS, 1->2MBPS, 2->250KBPS");
+  Serial.println();
+  Serial.print("Enviar por: ");
+  Serial.println(int(pipeEnvia));
+  Serial.print("Recebe por: ");
+  Serial.println(int(pipeRecebe));
+  Serial.print("Payload size: ");
+  Serial.println(radio.getPayloadSize());
+
+
+}
+
+void plataforma(){
+  Serial.println("Plataforma arduino nano");
+  unsigned long time=millis();
+  Serial.println(time);
+}
+
+void radioSetup(){
+  radio.begin();                           // inicializa radio
+  radio.setChannel(108);                   //muda para um canal de frequencia diferente de 2.4Ghz
+  radio.setPALevel(RF24_PA_MAX);           //usa potencia maxima
+  radio.setDataRate(RF24_2MBPS);           //usa velocidade maxima
+
+  radio.openWritingPipe(pipeEnvia);        //escreve pelo pipe0
+  radio.openReadingPipe(1,pipeRecebe);      //escuta pelo pipe1
+
+  radio.enableDynamicPayloads();           //ativa payloads dinamicos(pacote tamamhos diferentes do padrao)
+  radio.setPayloadSize(sizeof(velocidades));   //ajusta os o tamanho dos pacotes ao tamanho da mensagem
+
+  radio.startListening();                 // Start listening
+}
+
+


Add Energia BLE example

Add Energia BLE example

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

--- examples/Boards_Bluetooth/Energia_BLE/Energia_BLE.ino
+++ examples/Boards_Bluetooth/Energia_BLE/Energia_BLE.ino
@@ -0,0 +1,50 @@
+/**************************************************************
+ * Blynk is a platform with iOS and Android apps to control
+ * Arduino, Raspberry Pi and the likes over the Internet.
+ * You can easily build graphic interfaces for all your
+ * projects by simply dragging and dropping widgets.
+ *
+ *   Downloads, docs, tutorials: http://www.blynk.cc
+ *   Blynk community:            http://community.blynk.cc
+ *   Social networks:            http://www.fb.com/blynkapp
+ *                               http://twitter.com/blynk_app
+ *
+ * Blynk library is licensed under MIT license
+ * This example code is in public domain.
+ *
+ **************************************************************
+ *
+ * This example shows how to use Energia BLE
+ * to connect your project to Blynk.
+ *
+ * NOTE: BLE support is in beta!
+ *
+ **************************************************************/
+
+//#define BLYNK_DEBUG
+#define BLYNK_PRINT Serial
+#define BLYNK_RUN_YIELD() { ble.handleEvents(); }
+
+#include <BLE.h>
+#include <BlynkSimpleSerialBLE.h>
+
+// You should get Auth Token in the Blynk App.
+// Go to the Project Settings (nut icon).
+char auth[] = "YourAuthToken";
+
+void setup() {
+  Serial.begin(115200);
+
+  ble.setLogLevel(BLE_LOG_ERRORS);
+  ble.begin();
+  ble.serial();
+  ble.setAdvertName("Blynk BLE");
+  ble.startAdvert();
+
+  Blynk.begin(ble, auth);
+}
+
+void loop() {
+  Blynk.run();
+}
+


Added example for actuation with default powerswich component type. It turns on or off the LED light on Edison board.

error: pathspec 'arduino/IoTkit/examples/IoTKitActuationExample/IotKitActuationExample.ino' did not match any file(s) known to git

--- arduino/IoTkit/examples/IoTKitActuationExample/IotKitActuationExample.ino
+++ arduino/IoTkit/examples/IoTKitActuationExample/IotKitActuationExample.ino
@@ -0,0 +1,63 @@
+//This example reacts for default actuator component if registered on device
+//LED.v1.0 command is used
+//When executed from Control section on dashboard with value 0, LED light is turned off
+//When executed from Control section on dashboard with value 1, LED light is turned on
+//iotkit-agent must use MQTT connection (not REST) for actuation to work.
+//It also sends 1 as power when agent is started.
+
+#include <IoTkit.h>    // include IoTkit.h to use the Intel IoT Kit
+#include <Ethernet.h>  // must be included to use IoTkit
+#include <aJSON.h>
+#include <stdio.h>
+
+// create an object of the IoTkit class
+IoTkit iotkit;
+int temp;
+char buf[112];
+
+void setup() {
+  Serial.begin(115200);
+  // call begin on the IoTkit object before calling any other methods
+  iotkit.begin();
+  delay(10500);
+  iotkit.send("power", 1);
+}
+
+void loop() {
+  iotkit.receive(callback);
+  delay(5000);
+}
+
+void callback(char* json) {
+  Serial.println(json);
+  aJsonObject* parsed = aJson.parse(json);
+  if (&parsed == NULL) {
+    // invalid or empty JSON
+    Serial.println("recieved invalid JSON");
+    return;
+  }
+
+  aJsonObject* component = aJson.getObjectItem(parsed, "component");
+  aJsonObject* command = aJson.getObjectItem(parsed, "command");
+  aJsonObject* argv = aJson.getObjectItem(parsed, "argv");
+  aJsonObject* argvArray = argv->child;
+  aJsonObject* name = argvArray->child; // name : on
+  aJsonObject* value = name->next; // value: 1/0
+
+  if ((component != NULL)) {
+    if (strcmp(component->valuestring, "actuator") == 0) {
+      if ((command != NULL)) {
+        if (strcmp(command->valuestring, "light") == 0 && strcmp(value->valuestring, "0") == 0) {
+          Serial.println("Light Off!");
+          pinMode(13, OUTPUT);
+          digitalWrite(13, false);
+        }
+        if (strcmp(command->valuestring, "light") == 0 && strcmp(value->valuestring, "1") == 0) {
+          Serial.println("Light on!");
+          pinMode(13, OUTPUT);
+          digitalWrite(13, true);
+        }
+      }
+    }
+  }
+}


Update 001_Chodenie rovno a dozadu.ino

Update 001_Chodenie rovno a dozadu.ino

error: pathspec 'Programy/001_Chodenie' did not match any file(s) known to git
error: pathspec 'rovno' did not match any file(s) known to git
error: pathspec 'a' did not match any file(s) known to git
error: pathspec 'dozadu.ino' did not match any file(s) known to git


Create any_analog.ino

Create any_analog.ino

this should be obvious

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

--- any_analog.ino
+++ any_analog.ino
@@ -0,0 +1,11 @@
+int co_sensor = A0;
+
+void setup(){
+  pinMode(co_sensor, INPUT);
+  /*set the sensor to be input*/
+  Serial.begin(9600);
+  /*beign serial @ baudrate of 9600 */
+}
+void loop(){
+  Serial.println(analogRead(co_sensor));
+}


Create oas-0-2.ino

Create oas-0-2.ino

error: pathspec 'firmware/examplers/oas-0-2.ino' did not match any file(s) known to git


All staff cards successfully updated and tested

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


Uploaded ensemble five firmware

Uploaded ensemble five firmware

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

--- Firmeware/EnsembleFive/EnsembleFive.ino
+++ Firmeware/EnsembleFive/EnsembleFive.ino
@@ -0,0 +1,282 @@
+/* PHOBOS - EnsembleFive firmware v.0.2 (27.05.2017)
+ *
+ * using:
+ * Arduino v1.8.0
+ * MIDI_Library v.4.3.1 by fortyseveneffects
+ * Servo Library v.1.1.2
+ * EEPROM Library v.2.0.0
+ *
+ * plays:
+ * A - 1 motor on a vynil with attached strings
+ * B - 1 motor with loose strings
+ * C - 3 servos plucking strings
+ * D - 4 lights controlled by relays
+ */
+
+#include <EEPROM.h>
+#include <Servo.h>
+#include <MIDI.h>
+#define MIDICH 5
+
+// VM VYNIL'S PINS
+#define A1 10
+// VM STRINGS' PINS
+#define B1 9
+// VM SERVOS' PINS
+#define C1 6
+#define C2 7
+#define C3 8
+// LIGHTS' PINS
+#define D1 2
+#define D2 3
+#define D3 4
+#define D4 5
+
+/* Addresses on Arduino EEPROM for servo control parameters*/
+#define S1MININC 0 // servo1 min increment (cc=116)
+#define S1MAXINC 1 // servo1 max increment (cc=117)
+
+#define S2MININC 2 // servo2 min increment (cc=118)
+#define S2MAXINC 3 // servo2 max increment (cc=119)
+
+#define S3MININC 4 // servo3 min increment (cc=120)
+#define S3MAXINC 5 // servo3 max increment (cc=121)
+
+
+#define S1MINANG 6 // servo1 min angle (cc=122)
+#define S1MAXANG 7 // servo1 max angle (cc=123)
+
+#define S2MINANG 8 // servo2 min angle (cc=124)
+#define S2MAXANG 9 // servo2 max angle (cc=125)
+
+#define S3MINANG 10 // servo3 min angle (cc=126)
+#define S3MAXANG 11 // servo3 max angle (cc=127)
+
+// servos
+Servo servo1, servo2, servo3;
+bool servoState[3]; // servo state to control servos out of MIDI loop
+float servoPos[3]; // servo current position
+//byte servoVel[3]; // servo "velocity" value which relates to movement speed
+float servoInc[3]; //servo increment value which relates to movement speed
+float servoMinInc[3]; // servo min increment values
+float servoMaxInc[3]; // servo min increment values
+float servoMinAng[3]; // servo min angle
+float servoMaxAng[3]; // servo max angle
+
+// make note to pin array
+byte note2pin[40];
+byte vel, pitch, val, cc;
+
+MIDI_CREATE_DEFAULT_INSTANCE();
+
+void setup() {
+  MIDI.begin(MIDICH); // Launch MIDI and listen to channel 1
+  MIDI.turnThruOn();
+
+  // set output pins
+  pinMode(A1, OUTPUT);
+
+  pinMode(B1, OUTPUT);
+
+  servo1.attach(C1);
+  servo2.attach(C2);
+  servo3.attach(C3);
+
+  pinMode(D1, OUTPUT);
+  pinMode(D2, OUTPUT);
+  pinMode(D3, OUTPUT);
+  pinMode(D4, OUTPUT);
+  // turn relays off
+  digitalWrite(D1, HIGH);
+  digitalWrite(D2, HIGH);
+  digitalWrite(D3, HIGH);
+  digitalWrite(D4, HIGH);
+
+  // set servos to initial position
+  servoPos[0] = midi2angle(EEPROM.read(S1MINANG));
+  servo1.write(servoPos[0]);
+
+  servoPos[1] = midi2angle(EEPROM.read(S2MINANG));
+  servo2.write(servoPos[1]);
+
+  servoPos[2] = midi2angle(EEPROM.read(S3MINANG));
+  servo3.write(servoPos[2]);
+
+  // set servos' min&max increment values
+  // NOTE: min/max inc values are between 0 and 127 (after mapped correspond to 0.1 to 10 degrees per millisecond)
+  servoMinInc[0] = EEPROM.read(S1MININC);
+  servoMaxInc[0] = EEPROM.read(S1MAXINC);
+
+  servoMinInc[1] = EEPROM.read(S2MININC);
+  servoMaxInc[1] = EEPROM.read(S2MAXINC);
+
+  servoMinInc[2] = EEPROM.read(S3MININC);
+  servoMaxInc[2] = EEPROM.read(S3MAXINC);
+
+  // set servos0 min&max angle
+  // NOTE: min/max angle values are already converted to angles
+  servoMinAng[0] = midi2angle( EEPROM.read(S1MINANG) );
+  servoMaxAng[0] = midi2angle( EEPROM.read(S1MAXANG) );
+
+  servoMinAng[1] = midi2angle( EEPROM.read(S2MINANG) );
+  servoMaxAng[1] = midi2angle( EEPROM.read(S2MAXANG) );
+
+  servoMinAng[2] = midi2angle( EEPROM.read(S3MINANG) );
+  servoMaxAng[2] = midi2angle( EEPROM.read(S3MAXANG) );
+
+
+  // set note2pin array
+  note2pin[0] = A1;
+
+  note2pin[12] = B1;
+
+  note2pin[24] = C1;
+  note2pin[25] = C2;
+  note2pin[26] = C3;
+
+  note2pin[36] = D1;
+  note2pin[37] = D2;
+  note2pin[38] = D3;
+  note2pin[39] = D4;
+}
+
+void loop() {
+  if(MIDI.read()){
+      switch(MIDI.getType()){
+        case midi::NoteOn:
+          pitch = MIDI.getData1();
+          vel = MIDI.getData2();
+
+          if(pitch > 23){ // activate servos and relays
+            if(pitch < 27){ // set servos' values only (activation is done in runServos function)
+              servoInc[pitch-24] = velocity2inc( servoMinInc[pitch-24], servoMaxInc[pitch-24], vel);
+              servoState[pitch-24] = true;
+            }
+            if(pitch > 35){ // activate relay
+              digitalWrite(note2pin[pitch], LOW);
+            }
+          }
+          else{ // activate motors
+            analogWrite(note2pin[pitch], vel << 1);
+          }
+          break;
+
+        case midi::NoteOff:
+          pitch = MIDI.getData1();
+          if(pitch > 23){
+            if(pitch < 27){ // deactivate servos
+              servoState[pitch-24] = false;
+            }
+            if(pitch > 35){ // deactivate relays
+              digitalWrite(note2pin[pitch], HIGH);
+            }
+          }
+          else{ // deactivate motors
+            analogWrite(note2pin[pitch], LOW);
+          }
+          break;
+
+        // CONTROL CHANGE (SET SERVO PARAMETERS)
+        case midi::ControlChange:
+          cc = MIDI.getData1();
+          val = MIDI.getData2();
+          // starting on cc=116
+          EEPROM.write(cc-116, val);
+      }
+  }
+
+  runServos(); // activate servos
+  delay(1); // (used only to set servo increments in a millisecond basis)
+}
+
+/***************** FUNTCIONS *****************/
+byte voltage2byte(float v){
+  return v*255/5.f;
+}
+
+float midi2angle(byte m){
+  return 180/127.f*m;
+}
+
+float velocity2inc(byte _min, byte _max, byte v){ // translate velocity values into position increments usign a min/max inc.
+  return map(v, 0, 127, _min, _max);
+}
+
+void runServos(){
+  // servo1 attack
+  if( servoState[0]==true && servoPos[0] < servoMaxAng[0] ){
+    servo1.write(servoPos[0]);
+    servoPos[0] += servoInc[0];
+  }
+  // servo1 release
+  else if (servoState[0] == false){
+    servoPos[0] = servoMinAng[0];
+    servo1.write( servoPos[0] );
+  }
+
+  // servo2 attack
+  if( servoState[1]==true && servoPos[1] < servoMaxAng[1] ){
+    servo2.write(servoPos[1]);
+    servoPos[1] += servoInc[1];
+  }
+  // servo2 release
+  else if (servoState[1] == false){
+    servoPos[1] = servoMinAng[1];
+    servo2.write( servoPos[1] );
+  }
+
+  // servo3 attack
+  if( servoState[2]==true && servoPos[2] < servoMaxAng[2] ){
+    servo3.write(servoPos[2]);
+    servoPos[2] += servoInc[2];
+  }
+  // servo3 release
+  else if (servoState[2] == false){
+    servoPos[2] = servoMinAng[2];
+    servo3.write( servoPos[2] );
+  }
+}
+
+void updateServoParams(byte addr, byte val){
+  switch(addr){
+    case 116:
+      servoMinInc[0] = val;
+      break;
+    case 117:
+      servoMaxInc[0] = val;
+      break;
+    case 118:
+      servoMinInc[1] = val;
+      break;
+    case 119:
+      servoMaxInc[1] = val;
+      break;
+    case 120:
+      servoMinInc[2] = val;
+      break;
+    case 121:
+      servoMaxInc[2] = val;
+      break;
+    case 122:
+      servoMinAng[0] = midi2angle(val);
+      break;
+    case 123:
+      servoMaxAng[0] = midi2angle(val);
+      break;
+    case 124:
+      servoMinAng[1] = midi2angle(val);
+      break;
+    case 125:
+      servoMaxAng[1] = midi2angle(val);
+      break;
+    case 126:
+      servoMinAng[2] = midi2angle(val);
+      break;
+    case 127:
+      servoMaxAng[2] = midi2angle(val);
+      break;
+
+    default:
+    break;
+  }
+}


Add Ucglib-fonts demo.

Add Ucglib-fonts demo.

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/JulianNicholls/Arduino.git/'


Version 0.7

Version 0.7

Update because changes in main files.

--- examples/GPRS_TCPConnection/GPRS_TCPConnection.ino
+++ examples/GPRS_TCPConnection/GPRS_TCPConnection.ino
@@ -12,13 +12,13 @@

 char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\r\n\r\n";
 char buffer[512];
-GPRS gprs(PIN_TX, PIN_RX, BAUDRATE,"cmnet");
+GPRS gprs(PIN_TX, PIN_RX, BAUDRATE);
 void setup(){
   Serial.begin(9600);
   // use DHCP
   gprs.init();
   // attempt DHCP
-  while(false == gprs.join()) {
+  while(false == gprs.join(F("cmnet"))) {
       Serial.println("gprs join network error");
       delay(2000);
   }


and we will have further numbers

and we will have further numbers

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/'


Math sketch (functions all already implemented)

Change-Id: I1e1310a1c6544164fe062e075f2c2195fc3969c9
GitOrigin-RevId: 7e4032fc12fa9bab3d523a3a9350bc3c507e4d46

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

--- sketches/Math/Math.ino
+++ sketches/Math/Math.ino
@@ -0,0 +1,55 @@
+#include "Arduino.h"
+
+void setup() {
+    Serial.begin(115200);
+}
+
+void loop() {
+    Serial.print("abs(4): ");
+    Serial.println(abs(4));
+    Serial.print("abs(-4): ");
+    Serial.println(abs(-4));
+
+    Serial.print("contrain 4 to [1,3]: ");
+    Serial.println(constrain(4,1,3));
+    Serial.print("contrain -4 to [1,3]: ");
+    Serial.println(constrain(-4,1,3));
+
+    Serial.print("map(512, 0, 1023, 0, 254): ");
+    Serial.println(map(512, 0, 1023, 0, 254));
+
+    Serial.print("max [-2,2]: ");
+    Serial.println(max(-2,2));
+    Serial.print("min [-2,2]: ");
+    Serial.println(min(-2,2));
+
+    Serial.print("pow (2,2): ");
+    Serial.println(pow(2,2));
+
+    Serial.print("sq(2): ");
+    Serial.println(sq(2));
+
+    Serial.print("sqrt 4: ");
+    Serial.println(sqrt(4));
+
+    Serial.print("sin(0): ");
+    Serial.println(sin(0));
+    Serial.print("sin(pi/4): ");
+    Serial.println(sin(PI / 4));
+    Serial.print("sin(pi/2): ");
+    Serial.println(sin(PI / 2));
+
+    Serial.print("cos(0): ");
+    Serial.println(cos(0));
+    Serial.print("cos(pi/4): ");
+    Serial.println(cos(PI / 4));
+    Serial.print("cos(pi/2): ");
+    Serial.println(cos(PI / 2));
+
+    Serial.print("tan(0): ");
+    Serial.println(tan(0));
+    Serial.print("tan(pi/4): ");
+    Serial.println(tan(PI / 4));
+
+    delay(10000);
+}


Create Firmware_Test.ino

Create Firmware_Test.ino

error: pathspec 'src/piggy_back_loggers/SD_prototype_Firmware/Firmware_Test/Firmware_Test.ino' did not match any file(s) known to git

--- src/piggy_back_loggers/SD_prototype_Firmware/Firmware_Test/Firmware_Test.ino
+++ src/piggy_back_loggers/SD_prototype_Firmware/Firmware_Test/Firmware_Test.ino
@@ -0,0 +1,363 @@
+// Firmware for the CIWS Residential Datalogger
+// Arduino IDE ver. 1.8.7
+// Utah Water Research Lab
+// Updated: 10/25/2018
+// Daniel Henshaw and Josh Tracy
+// Note: F("String") keeps string literals in program memory and out of RAM. Saves RAM space. Very good. Don't remove the F. I know it looks funny. But don't do it. Really. The program might crash if you do. And then you'll have dishonor on yourself, dishonor on your cow...
+
+/*******************************************************************************************\
+* Hardware Description
+*                     ___________________                             ___
+*                    |                   |<------------------------->[___] RTC
+*  ________          |                   |                            _______
+* |        |         |                   |<------------------------->|       | SD
+* |        |<------->|                   |<-----[] Activate Serial   |______/
+* |________|         |___________________|<-----[] Sensor
+*  Serial             Controller
+*
+* Serial:          Serial interface for user interaction with the logger
+* Controller:      Arduino Pro/Pro Mini (used for SD library and lower power options)
+* SD:              External SD Card storage for the logger.
+* Activate Serial: Button to wake up the controller and activate the Serial interface
+* Sensor:          Hall Effect Sensor for logging pulses from water meters.
+* RTC:             Real Time Clock to track time and wake up controller every four seconds.
+\*******************************************************************************************/
+
+/*********************************************************\
+* Software Description
+* Overview:
+*   User inputs:
+*     Serial input.
+*   Device outputs:
+*     Serial output
+*     Datalog file
+*
+* Structure:
+*   1. Setup
+*   2. Handle Serial (for start-up configuration)
+*   3. Loop
+*        If serial is enabled
+*          Handle serial input
+*        If four seconds are up
+*          Update the time
+*          Construct a timestamp
+*          Power-on the SD card
+*          Write data
+*          Power-off the SD card
+*        If sleep is enabled (disabled when serial is enabled)
+*          Enter Sleep (low-power mode)
+*          < Will wake up on Interrupt and continue: >
+*      Repeat Loop
+*
+* Interrupts:
+*   1. INT0_ISR()
+*
+*   2. INT1_ISR()
+*
+\*********************************************************/
+
+#include <SPI.h>
+#include <SD.h>
+#include "handleSerial.h"
+#include "powerSleep.h"
+#include "state.h"
+#include "RTC_PCF8523.h"
+#include "storeNewRecord.h"
+
+// These six macros below are the ten's place mask for the various real time clock registers
+#define SECONDS_REG_MASK 0x7                            // keep lower 3 bits
+#define MINUTES_REG_MASK 0x7
+#define HOURS_REG_MASK   0x3                            // keep lower 2 bits
+#define DAYS_REG_MASK    0x3
+#define MONTHS_REG_MASK  0x1                            // keep lower 1 bit
+#define YEARS_REG_MASK   0xF                            // keep all four bits
+
+
+/*********************************************************************************\
+ * Setup:
+ *    System State structure      Complete
+ *    Setup Digital I/O pins
+ *      Pin 2 (INT0)
+ *      Pin 3 (INT1)
+ *      Pin 4 (SD power on/off)
+ *      Pin 5 (Serial Activate Button)
+ *    Setup interrupts
+\*********************************************************************************/
+
+volatile State_t State;           // System State structure
+Date_t Date;                      // System Time and Date structure
+File dataFile;                    // File pointer for SD Card operations
+
+void setup()
+{
+  resetState(&State);             // Setup the System State structure
+
+  pinMode(2, INPUT);              // Setup the Digital Pins
+  pinMode(3, INPUT);
+  pinMode(4, OUTPUT);
+  digitalWrite(4, HIGH);
+  pinMode(5, INPUT);
+
+  rtcTransfer(reg_Tmr_CLKOUT_ctrl, WRITE, 0x3A);                  // Setup RTC Timer
+  rtcTransfer(reg_Tmr_A_freq_ctrl, WRITE, 0x02);
+  rtcTransfer(reg_Tmr_A_reg, WRITE, 0x04);
+  rtcTransfer(reg_Control_2, WRITE, 0x02);
+
+  attachInterrupt(digitalPinToInterrupt(2), INT0_ISR, FALLING);   // Setup Interrupts
+  attachInterrupt(digitalPinToInterrupt(3), INT1_ISR, FALLING);
+  EIMSK &= ~(1 << INT0);        // Disable Hall Effect Sensor interrupt
+  EIMSK |= (1 << INT1);         // Enable 4-Second RTC interrupt.
+
+  loadDateTime(&Date);            // Load Date_t with Date/Time info
+
+  disableUnneededPeripherals();   // Disable unneeded peripherals
+}
+
+void loop()
+{
+  // JOSH
+  /*****************************************\
+  * ButtonCheck: Is the button pressed?
+  * If button is pressed (active-low):
+  *   Set serialOn flag.
+  *   call serialPowerUp()
+  \*****************************************/
+  if((digitalRead(5) == 0) && !State.serialOn)
+  {
+    State.serialOn = true;
+    serialPowerUp();
+  }
+
+  // JOSH
+  /*****************************************\
+  * Serial: User I/O over serial
+  * serialOn flag is set:
+  *   call function handleSerial();
+  \*****************************************/
+  if(State.serialOn)
+    handleSerial(&State, &Date);
+
+  // DANIEL
+  /*****************************************\
+  * 4-second update: Update at 4 seconds
+  * If 4-second flag is set:
+  *   Store a new record
+  \*****************************************/
+  if(State.flag4)
+  {
+    State.flag4 = 0;                                    //     Reset flag4 to zero
+    rtcTransfer(reg_Control_2, WRITE, 0x02);            //     Reset real time clock interrupt flag
+    loadDateTime(&Date);
+    if(State.logging)
+      storeNewRecord();
+  }
+  // JOSH
+  /*****************************************\
+  * Sleep: put processor to sleep
+  *        to be woken by interrupts
+  * If serialOn is not set:
+  *   call function Sleep();
+  \*****************************************/
+  if(!State.serialOn)
+    enterSleep();
+}
+
+// DANIEL
+/* Function Title: INT0_ISR()
+ *
+ * Friendly Name:  Sensor Interrupt Service Routine (ISR)
+ *
+ * Description: increments the value of the pulse count variable by one, each time this
+ *              function is called by hardware.
+ */
+void INT0_ISR()
+{
+  State.pulseCount += 1;  // increment pulseCount variable by one
+}
+
+// DANIEL
+/* Function Title: INT1_ISR()
+ *
+ * Friendly Name:  Real Time Clock OUT Interrupt Service Routine (ISR)
+ *
+ * Description: sets the 4-second flag to true each time this function
+ *              is called by hardware. The Real Time Clock generates
+ *              the signal that calls this ISR once every four seconds.
+ */
+void INT1_ISR()
+{
+  State.flag4 = true;     // sets the "four second flag" to true
+}
+
+/* Function: storeNewRecord
+ *
+ * Author: Daniel Henshaw
+ * Date: 11/10/18
+ *
+ * Description: This function gets the current time from the Real Time Clock, and then
+ *              carries out the communication to write a new record to the SD card and
+ *              then turns off the I2C and SD card.
+ *
+ * Pseudocode:
+ *
+ * Begin
+ *   Reset flag4 to zero
+ *   Reset real time clock interrupt flag
+ *   Declare variables
+ *   Store pulse count to a variable named final count
+ *   Set pulseCount to zero
+ *   Read current time from the Real Time Clock and update the Date struct with the current time
+ *     turn on the I2C interface (function rtcTransfer does this for us)
+ *       read the year and store into temp variable
+ *       convert from binary-coded decimal into binary, and store into years field of Date struct
+ *       read the month and store into temp variable
+ *       convert from binary-coded decimal into binary, and store into months field of Date struct
+ *       read the day and store into temp variable
+ *       convert from binary-coded decimal into binary, and store into days field of Date struct
+ *       read the hour and store into temp variable
+ *       convert from binary-coded decimal into binary, and store into hours field of Date struct
+ *       read the minutes and store into temp variable
+ *       convert from binary-coded decimal into binary, and store into minutes field of Date struct
+ *       read the seconds and store into temp variable
+ *       convert from binary-coded decimal into binary, and store into seconds field of Date struct
+ *     turn off the I2C interface (function rtcTransfer does this for us)
+ *   Write the new record to the SD card
+ *     power on SD card
+ *       write new record to SD card
+ *         open the date-time string by writing a double quotation mark
+ *           write year, month, day, hours,
+ *           if minutes is less than ten
+ *           then
+ *             write a leading zero (the minutes value will be appended to it by the next statement)
+ *           endIf
+ *           write the minutes
+ *           if seconds is less than ten
+ *           then
+ *             write a leading zero (the seconds value will be appended to it by the next statement)
+ *           endIf
+ *           write the seconds
+ *         close the date-time string by writing a double quotation mark
+ *         write a comma to begin a new field (CSV file format)
+ *         write the record number
+ *         write a comma to begin a new field (CSV file format)
+ *         write the number of pulses counted when function was called (finalCount)
+ *       end of writing the record to SD card
+ *     power down SD card
+ * End of function storeNewRecord()
+ */
+
+
+
+void storeNewRecord()
+{                                                       // Begin
+    //State.flag4 = 0;                                    //     Reset flag4 to zero
+    //rtcTransfer(reg_Control_2, WRITE, 0x02);            //     Reset real time clock interrupt flag
+    byte finalCount;                                    //     Declare variables
+    byte temp;
+    finalCount = State.pulseCount;                      //     Store pulse count to a variable named final count
+    State.pulseCount = 0;                               //     Set pulseCount to zero
+                                                        //     Read current time from the Real Time Clock and update the Date struct with the current time
+      temp         = rtcTransfer(reg_Years,  READ, 0);  //         read the Years and store into temp variable
+      Date.years   = bcdtobin(temp, YEARS_REG_MASK);    //         convert from binary-coded decimal into binary, and store into years field of Date struct
+      temp         = rtcTransfer(reg_Months, READ, 0);  //         read the Months and store into temp variable
+      Date.months  = bcdtobin(temp, MONTHS_REG_MASK);   //         convert from binary-coded decimal into binary, and store into months field of Date struct
+      temp         = rtcTransfer(reg_Days,   READ, 0);  //         read the Days and store into temp variable
+      Date.days    = bcdtobin(temp, DAYS_REG_MASK);     //         convert from binary-coded decimal into binary, and store into days field of Date struct
+      temp         = rtcTransfer(reg_Hours,  READ, 0);  //         read the Hours and store into temp variable
+      Date.hours   = bcdtobin(temp, HOURS_REG_MASK);    //         convert from binary-coded decimal into binary, and store into hours field of Date struct
+      temp         = rtcTransfer(reg_Minutes,READ, 0);  //         read the Minutes and store into temp variable
+      Date.minutes = bcdtobin(temp, MINUTES_REG_MASK);  //         convert from binary-coded decimal into binary, and store into minutes field of Date struct
+      temp         = rtcTransfer(reg_Seconds,READ, 0);  //         read the Seconds and store into temp variable
+      Date.seconds = bcdtobin(temp, SECONDS_REG_MASK);  //         convert from binary-coded decimal into binary, and store into seconds field of Date struct
+                                                        //     Write the new record to the SD card
+      //SDPowerUp();                                      //         power on SD card
+      //SD.begin();
+        //Serial.println(F("SD Powerd up."));
+        dataFile = SD.open(F("datalog.csv"), FILE_WRITE);     //         Write new record to SD card
+        dataFile.print('\"');                          //           open the date-time string by writing a double quotation mark
+        dataFile.print(Date.years);                     //             write year, month, day, hours
+        dataFile.print('-');
+        dataFile.print(Date.months);
+        dataFile.print('-');
+        dataFile.print(Date.days);
+        dataFile.print(' ');
+        dataFile.print(Date.hours);
+        dataFile.print(':');
+        if(Date.minutes < 10)                           //             if minutes is less than ten
+        {                                               //             then
+          dataFile.print('0');                         //               write a leading zero (the minutes value will be appended to it by the next statement)
+        }                                               //             endIf
+        dataFile.print(Date.minutes);                   //             write the minutes
+        if(Date.seconds < 10)                           //             if seconds is less than ten
+        {                                               //             then
+          dataFile.print('0');                         //               write a leading zero (the seconds value will be appended to it by the next statement)
+        }                                               //             endIf
+        dataFile.print(':');                            //             write a colon to separate minutes from seconds
+        dataFile.print(Date.seconds);                   //             write the seconds
+        dataFile.print('\"');                           //           close date-time string by writing a double quotation mark
+        dataFile.print(',');                            //           write a comma to begin a new field (CSV file format)
+        dataFile.print(State.recordNum);                //           write the record number
+        dataFile.print(',');                            //           write a comma to begin a new field (CSV file format)
+        dataFile.println(finalCount);                   //           write the number of pulses counted when function was called (finalCount) and then print a new line
+
+        dataFile.close();                               //         end of writing the record to SD card
+        State.recordNum += 1;
+      //SDPowerDown();                                    //       power down SD card
+}                                                       // End of function storeNewRecord()
+
+
+
+
+
+
+/* Function: bcdtobin
+ *
+ * Author: Daniel Henshaw
+ * Date: 11/17/18
+ *
+ * Description: This function converts Binary Coded Decimal (BCD) numbers to
+ *              standard binary format. This is particularly useful when working
+ *              with the real time clock, which stores time data in BCD format
+ *              in its registers. The function takes in the value to convert, and
+ *              the source register the value is coming from. The source register
+ *              is required so that the conversion will be compatible with the
+ *              number of bits into which the BCD value is stored into the RTC's
+ *              registers.
+ *
+ * Optional dependencies: set of macro definitions, included below, improve
+ *              this function's usability or user friendliness. These make it
+ *              straightforward for the user to specify from which register
+ *              the data is coming from. These also do double duty as masks for the
+ *              value, as not all 8 bits in the register are for the BCD value; some
+ *              of the upper bits serve other purposes or are "unused"
+ *              (see datasheet for PCF8523 by NXP).
+ *
+ *              #define SECONDS_REG_MASK 0x7
+ *              #define MINUTES_REG_MASK 0x7
+ *              #define HOURS_REG_MASK   0x3
+ *              #define DAYS_REG_MASK    0x3
+ *              #define MONTHS_REG_MASK  0x1
+ *              #define YEARS_REG_MASK   0xF
+ *
+ * Pseudocode:
+ *
+ * Begin
+ *   Declare variable
+ *   shift right by four the bcdValue (Puts upper 4 bits at the bottom)
+ *   tensPlace is tensPlace ANDed with the provided bit mask a.k.a. conversion constant (hexadecimal value)
+ *   Return the binary value result (the unit's place plus tensPlace times ten)
+ * End
+ */
+
+byte bcdtobin(byte bcdValue, byte sourceReg)
+{
+  byte tensPlace;
+
+  tensPlace  = bcdValue >> 4;
+  tensPlace &= sourceReg;         /* NOTE: sourceReg is actually a bit mask */
+
+  return (bcdValue & 0x0F) + (tensPlace * 10); // return the binary value result:
+                                               //   step 1) First parenthesis: bcdValue ANDed with mask 0xF gives us the one's place,
+                                               //   step 2) Second parenthesis: move the ten's place value over by multiplying by ten
+                                               //   step 3) Add the first parenthesis group to the second parenthesis group
+}


Arduino touch added

Arduino touch added

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

--- unik_teknologihuset/unik_teknologihuset.ino/unik_teknologihuset.ino.ino
+++ unik_teknologihuset/unik_teknologihuset.ino/unik_teknologihuset.ino.ino
@@ -0,0 +1,450 @@
+#include <SPI.h>
+
+#if 0
+  #define DEBUG_BUTTON16(a) (a)
+#else
+  #define DEBUG_BUTTON16(a)
+#endif
+
+#if 1
+  #define DEBUG_STATUS(a) (a)
+#else
+  #define DEBUG_STATUS(a)
+#endif
+
+
+#pragma pack(push, 0)
+
+// TBD: Replace with proper interrupt pin macros. It does not seem to be defined for atmega328p or I am incapable of finding it
+#ifndef INT0_PIN
+#ifdef __AVR_ATmega328P__
+#define INT0_PIN 2
+#else
+  #warning Define INT0_PIN for this microcontroller to use interrupt
+#endif
+#endif
+
+#ifndef INT1_PIN
+#ifdef __AVR_ATmega328P__
+#define INT1_PIN 3
+#else
+  #warning Define INT1_PIN for this microcontroller to use interrupt
+#endif
+#endif
+
+uint32_t g_intCount = 0;
+
+struct CTtp229ButtonEvent
+{
+  uint8_t ButtonNumber : 5;         // ButtonNumber != 0 : Event is present. if equals 0, no event is received
+  uint8_t IsButtonReleased : 1;     // True = Button is pressed. False = Button is released
+};
+
+class CTtP229TouchButton
+{
+  struct CTtp229Prop
+  {
+    uint16_t  SclPin : 6;
+    uint16_t  SdoPin : 6;
+    uint16_t  Is16Button : 1;
+#if defined(INT0_PIN) || defined(INT1_PIN)
+    uint16_t  HasPendingInterrupt : 1;
+    uint16_t  IgnoreNextEvent : 1;            // When reading 16th key and if it is pressed, SDO stays low for 2ms.
+                                              // If we enable interrupt before that, then it will trigger after 2ms, only to find the same condition.
+                                              // To make things worse, at the end of reading the pin will stay low and generate another interrupt.
+                                              // TBD: One possible fix is to send more pulses to make it roll over to HIGH. Have to find out if all 16 keys can be pressed in multi-key scenario (NOT supported yet).
+    uint16_t UnhandledButtonPresses;
+#endif
+    uint16_t PreviousButtonValue;
+  };
+
+  static CTtp229Prop g_prop;
+
+  //
+  //    Internal function that captures the data from TTP229 on which key is pressed.
+  //  Currently, this function only supports one key being pressed. Multi-key press needs to be added later.
+  //
+  //  Return Value : Bit field of buttons pressed
+  //
+  static uint16_t GetPressedButton()
+  {
+    DEBUG_BUTTON16(Serial.println("GetPressedButton : Enter "));
+    uint16_t buttonsPressed = 0;
+    // Need to generate the LOW and then HIGH on the clock and read the value from data when clock is back high.
+    // As per the specification, the TTP229 chip can support 512Khz. This translates to approximately 2us for a cycle. So introducing clock with fall and raise each of 1us.
+    uint8_t maxCnt = g_prop.Is16Button ? 16 : 8;
+    for(uint8_t ndx = 0; ndx < maxCnt; ndx++ )
+    {
+      digitalWrite(g_prop.SclPin, LOW);
+      delayMicroseconds(1);
+      digitalWrite(g_prop.SclPin, HIGH);
+
+      int val = digitalRead(g_prop.SdoPin);
+
+      delayMicroseconds(1);  // Technically this can be moved after the if for most atmel microcontrollers. But if there is a really fast one (now/future) and the next call to GetPressedButton made immediately, we might overclock TTP229. Being safe here
+
+      if( LOW == val )
+      {
+        buttonsPressed |= (1 << ndx);
+      }
+    }
+
+    DEBUG_BUTTON16(Serial.print("GetPressedButton : Exit. Return Value : ")); DEBUG_BUTTON16(Serial.println(buttonsPressed));
+
+    return buttonsPressed;
+  }
+
+#if defined(INT0_PIN) || defined(INT1_PIN)
+  // Detaching the interrupt after receiving the data can cause problem in sleeping. If the interrupt is not properly dispatched, it can lead to permanent sleep and can't wake up from button
+  static void HandleButtonEvent()
+  {
+    if( g_prop.IgnoreNextEvent )
+    {
+      // We ignored an event. Now we will accept the event
+      g_prop.IgnoreNextEvent = false;
+    }
+    else
+    {
+      g_prop.HasPendingInterrupt = true;
+      g_intCount++;
+    }
+  }
+
+  static void SetInterruptHandler()
+  {
+#ifdef INT0_PIN
+    if( INT0_PIN == g_prop.SdoPin )
+    {
+      DEBUG_BUTTON16(Serial.println("Configure : With interrupt 0"));
+      EIFR = 0x01; // Clear INTF0 flag
+      attachInterrupt(0, HandleButtonEvent, RISING); // The pin goes down for 93us and then raises that is when the device is ready (technically after 10us)
+    }
+#endif
+
+#ifdef INT1_PIN
+    if( INT1_PIN == g_prop.SdoPin )
+    {
+      DEBUG_BUTTON16(Serial.println("Configure : With interrupt 1"));
+      EIFR = 0x02; // Clear INTF1 flag
+      attachInterrupt(1, HandleButtonEvent, RISING); // The pin goes down for 93us and then raises that is when the device is ready (technically after 10us)
+    }
+#endif
+  }
+
+  static void RemoveInterruptHandler()
+  {
+#ifdef INT0_PIN
+    if( INT0_PIN == g_prop.SdoPin )
+    {
+      detachInterrupt(0);
+    }
+#endif
+
+#ifdef INT1_PIN
+    if( INT1_PIN == g_prop.SdoPin )
+    {
+      detachInterrupt(1);
+    }
+#endif
+  }
+#endif
+
+  //
+  //    Returns button number being pressed. High bit indicates more changes present
+  //
+  static uint8_t GetButtonNumberFromFlag(uint16_t buttonsChanged)
+  {
+    uint16_t flag = 1;
+    for(uint8_t ndx = 1; ndx <=16; ndx++, flag <<= 1)
+    {
+      if( (buttonsChanged & flag) != 0 )
+      {
+        if( (buttonsChanged & ~flag) != 0 )
+        {
+          // Some other bit is present
+          ndx |= 0x80;
+        }
+
+        return ndx;
+      }
+    }
+
+    return 0;
+  }
+
+  public:
+  //
+  //    Setup the TTP229 Touch button on this input.
+  //
+  // Inputs:
+  //     sclPin  - Clock Pin of the button (3rd from left on button, connected to arduino's digital pin number)
+  //     sdoPin  - Data pin to read from the button (4th pin from left on button, connected to arduino's digital pin number)
+  //     is16Button - true = 16 buttons board. false = 8 button board
+  //
+  static void Configure(int sclPin, int sdoPin, bool is16Button = true)
+  {
+    DEBUG_BUTTON16(Serial.println("Configure : Enter"));
+
+    g_prop.SclPin = sclPin;
+    g_prop.SdoPin = sdoPin;
+    g_prop.Is16Button = is16Button;
+
+    g_prop.PreviousButtonValue = 0;
+
+    // Configure clock as output and hold it high
+    pinMode( sclPin, OUTPUT );
+    digitalWrite(sclPin, HIGH);
+
+    // Configure data pin as input
+    pinMode( sdoPin, INPUT);
+
+    DEBUG_BUTTON16(Serial.print("Button Configuration\n\rSCL Pin : "));
+    DEBUG_BUTTON16(Serial.println(sclPin));
+    DEBUG_BUTTON16(Serial.print("SDO Pin : "));
+    DEBUG_BUTTON16(Serial.println(sdoPin));
+    DEBUG_BUTTON16(Serial.print("Number of Keys : "));
+    DEBUG_BUTTON16(Serial.println(is16Button ? 16 : 8));
+
+#if defined(INT0_PIN) || defined(INT1_PIN)
+    g_prop.UnhandledButtonPresses = 0;
+    g_prop.HasPendingInterrupt = false;
+    g_prop.IgnoreNextEvent = false;
+    SetInterruptHandler();
+#endif
+
+    DEBUG_BUTTON16(Serial.println("Configure : Exit"));
+  }
+
+  //
+  //    Get the current status from the 16 button touch device
+  //
+  //   Return Value : Returns the bitflag of the keys pressed. returns 0, if no key is pressed.
+  //
+  static uint16_t GetButtonStatus()
+  {
+#if defined(INT0_PIN) || defined(INT1_PIN)
+    g_prop.HasPendingInterrupt = 0;
+#endif
+
+    uint16_t returnValue = GetPressedButton();
+
+#if defined(INT0_PIN) || defined(INT1_PIN)
+    returnValue |= g_prop.UnhandledButtonPresses;    // and also include any data that was received that we have not sent yet.
+    g_prop.UnhandledButtonPresses = 0;
+#endif
+
+    g_prop.PreviousButtonValue = returnValue;
+
+    return returnValue;
+  }
+
+  //
+  //    Gets the event from the button. This is useful for monitoring press and release only.
+  // Each button press will generate max 2 events, one for press and another for release. When the button is press and held, this method will return no event.
+  // If the calls were not made often enough, the events could be missed. For instance, you might get 2 pressed, followed by 4 pressed, which automatically means 2 released in single key mode.
+  //
+  // Return Value : if ButtonNumber is 0, then no event
+  //
+  static CTtp229ButtonEvent GetButtonEvent()
+  {
+    CTtp229ButtonEvent returnValue = {0, 0};
+    uint8_t buttonNumber;
+
+    DEBUG_BUTTON16(Serial.print("Old Value  : "));
+    DEBUG_BUTTON16(Serial.println(g_prop.PreviousButtonValue));
+
+
+#if defined(INT0_PIN) || defined(INT1_PIN)
+    if(
+#if defined(INT0_PIN)
+    INT0_PIN == g_prop.SdoPin
+#endif
+#if defined(INT0_PIN) && defined(INT1_PIN)
+    ||
+#endif
+#if defined(INT1_PIN)
+    INT1_PIN == g_prop.SdoPin
+#endif
+    )
+    {
+      // Interrupts are used. Check if we have interrupt
+      if( g_prop.HasPendingInterrupt )
+      {
+        RemoveInterruptHandler();                 // From this point upto SetInterruptHandler is called, ensure there is no return path that will leave without SetInterruptHandler
+      }
+      else
+      {
+        DEBUG_BUTTON16(Serial.println("GetButtonEvent: No interrupt pending"));
+        return returnValue;
+      }
+    }
+#endif
+
+    uint16_t currValue = GetPressedButton();
+
+#if defined(INT0_PIN) || defined(INT1_PIN)
+    currValue |= g_prop.UnhandledButtonPresses; // Get any previously returned but not returned now values also into the mix
+#endif
+
+    uint16_t changes = g_prop.PreviousButtonValue ^ currValue;
+    uint16_t pressed = (changes & currValue);
+    uint16_t released = (changes & g_prop.PreviousButtonValue);
+
+    // First check if any key is that is pressed and generate press event
+    if( 0 != pressed )
+    {
+      buttonNumber = GetButtonNumberFromFlag(pressed);
+      returnValue.ButtonNumber = (buttonNumber & 0x7F);
+
+      uint16_t mask = (1 << (returnValue.ButtonNumber -1));
+      // set the new notified button into prev
+      g_prop.PreviousButtonValue |= mask;
+
+#if defined(INT0_PIN) || defined(INT1_PIN)
+      g_prop.UnhandledButtonPresses = currValue;
+      g_prop.UnhandledButtonPresses = currValue & ~g_prop.PreviousButtonValue;    // clear unhandled for this bit, just in case
+#endif
+    }
+    else if(0 != released)
+    {
+      buttonNumber = GetButtonNumberFromFlag(released);
+      returnValue.ButtonNumber = (buttonNumber & 0x7F);
+
+      // The unmatching bit whose previous value of 1 means, it is released
+      returnValue.IsButtonReleased = true;
+
+      // clear the notified release button
+      g_prop.PreviousButtonValue &= ~(1 << (returnValue.ButtonNumber -1));
+    }
+
+
+#if defined(INT0_PIN) || defined(INT1_PIN)
+
+    if(((!returnValue.IsButtonReleased || (0 == pressed))   // We handle release but no pending press
+          && ((buttonNumber & 0x80) == 0 )) // or more button changes are detected
+        || (returnValue.ButtonNumber == 0) )    // safety in case interrupt and data mismatch or code bug
+    {
+      // No more button notification pending
+      g_prop.HasPendingInterrupt = false;
+    }
+    else
+    {
+      DEBUG_BUTTON16(Serial.println("not Clearing interrupt"));
+    }
+
+    g_prop.IgnoreNextEvent = digitalRead(g_prop.SdoPin) == LOW; // If the pin is still low at the end of reading, ignore next event which is for data finished raise
+    DEBUG_BUTTON16(Serial.print(g_prop.IgnoreNextEvent ? "Ignoring next event\n\r" : "Not ignoring\n\r"));
+
+    // All the data has been read. Now reactivate the interrupt
+    SetInterruptHandler();
+#endif
+
+    DEBUG_BUTTON16(Serial.print("currValue : "));
+    DEBUG_BUTTON16(Serial.println(currValue));
+    DEBUG_BUTTON16(Serial.print("Changes    : "));
+    DEBUG_BUTTON16(Serial.println(changes));
+    DEBUG_BUTTON16(Serial.print("Button N   : "));
+    DEBUG_BUTTON16(Serial.println(buttonNumber));
+    DEBUG_BUTTON16(Serial.print("Unhandled  : "));
+    DEBUG_BUTTON16(Serial.println(g_prop.UnhandledButtonPresses));
+    DEBUG_BUTTON16(Serial.print("ButtonRelease : "));
+    DEBUG_BUTTON16(Serial.println(returnValue.IsButtonReleased));
+    DEBUG_BUTTON16(Serial.print("buttonNumber : "));
+    DEBUG_BUTTON16(Serial.println(buttonNumber));
+    DEBUG_BUTTON16(Serial.print("Pending interrupts :"));
+    DEBUG_BUTTON16(Serial.println(g_prop.HasPendingInterrupt));
+
+    return returnValue;
+  }
+
+#if defined(INT0_PIN) || defined(INT1_PIN)
+  static bool HasEvent()
+  {
+#if defined(INT0_PIN)
+    if( INT0_PIN == g_prop.SdoPin )
+    {
+      return g_prop.HasPendingInterrupt;
+    }
+#endif
+
+#if defined(INT1_PIN)
+    if( INT1_PIN == g_prop.SdoPin )
+    {
+      return g_prop.HasPendingInterrupt;
+    }
+#endif
+
+    return true;
+  }
+#endif
+
+};
+
+CTtP229TouchButton::CTtp229Prop CTtP229TouchButton::g_prop;
+CTtP229TouchButton g_ttp229Button;
+
+#define TTP16Button g_ttp229Button
+#pragma pack(pop)
+
+void setup()
+{
+  Serial.begin(115200);
+
+  DEBUG_STATUS(Serial.println("===================================================================="));
+  DEBUG_STATUS(Serial.println("Button Input tester started"));
+  DEBUG_STATUS(Serial.println("===================================================================="));
+
+  TTP16Button.Configure(7, 2);
+}
+
+void TestStatus()
+{
+  uint8_t buttonNumber = TTP16Button.GetButtonStatus();
+
+  if( 0 != buttonNumber )
+  {
+    DEBUG_STATUS(Serial.print("Button Pressed : "));
+    DEBUG_STATUS(Serial.println(buttonNumber));
+  }
+
+  delayMicroseconds(2500); // TTP229 document says it will reset the output if 2ms idle + little bit safety
+}
+
+void TestEvent()
+{
+#if defined(INT0_PIN) || defined(INT1_PIN)
+  if( TTP16Button.HasEvent())
+#endif
+  {
+    CTtp229ButtonEvent buttonEvent = TTP16Button.GetButtonEvent();
+
+    if( 0 != buttonEvent.ButtonNumber )
+    {
+      if( buttonEvent.IsButtonReleased )
+      {
+        DEBUG_STATUS(Serial.print("Button Released: "));
+      }
+      else
+      {
+        DEBUG_STATUS(Serial.print("Button Pressed : "));
+      }
+      DEBUG_STATUS(Serial.println(buttonEvent.ButtonNumber));
+    }
+    else
+    {
+#if defined(INT0_PIN) || defined(INT1_PIN)
+        DEBUG_STATUS(Serial.println("Are you not using interrupt? Should never come here for interrupt based system."));
+#endif
+    }
+
+    //Serial.print("CurrentTime : "); Serial.println(millis());
+    delayMicroseconds(2500); // TTP229 document says it will reset the output if 2ms idle + little bit safety. Not required if using interrupts
+  }
+
+}
+
+void loop()
+{
+  //TestStatus();
+  TestEvent();
+}


Sketch Arduino

Sketch Arduino

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

--- SW/Arduino/ADS1298_ArduinoDue/ADS1298_ArduinoDue.ino
+++ SW/Arduino/ADS1298_ArduinoDue/ADS1298_ArduinoDue.ino
@@ -0,0 +1,121 @@
+// include the libraries:
+
+#include <SPI.h>
+#include "ADS1298.h" //find all definition for ADS1298
+
+//Type
+ADS1298 ADS1298device;
+
+// global variable
+int transmit = 0;
+volatile int interrupt_pin2 = 0;
+int connect;
+byte SampleRate[1];
+byte ModeADS[1];
+byte ADSNum[1];
+byte ChipSelect[1];
+byte TriggerWord[1];
+byte Gain[1];
+
+boolean toggle = 0;
+String ConnectingWord;
+
+void setup() {
+
+  ModeADS[0] = 0x00;
+  ADSNum[0] = 0x00;
+
+  connect=0;  //Disconnect from a user Interface (Java, C++)
+  attachInterrupt(2, SPIInterrupt, FALLING); //Interrupt on ArduinoDue // 2 menas pin 2
+
+  Serial.begin(9600); //USB programming port Init --> for trigger
+  Serial.flush();
+
+  SerialUSB.begin(256000);  // USB Initialization
+  SerialUSB.flush();
+  delay(100);
+
+  pinMode(13, OUTPUT); // LED that informs you if the device is on or off
+  digitalWrite(13, toggle);
+  TriggerWord[0] = 0x00;
+}
+
+
+//interrupt function IR2
+void SPIInterrupt() {
+    interrupt_pin2 = 1;
+}
+
+void loop() {
+
+  //Arduino Connection and ADC initialization
+  while(!connect){
+    if(SerialUSB.available()>6){ // Check if data are available on the serial bus
+      ConnectingWord = SerialUSB.readString(); //Read data
+      if(ConnectingWord.equals("Connect")){ //Check the connecting word
+        connect = 1;
+        SerialUSB.println("Ready"); // Send the ack word //println-->write
+        delay(500);
+
+        while(!SerialUSB.available()>3); // Wait the Sample Rate
+
+        SerialUSB.readBytes(SampleRate,1);  //Read the sample rate;
+        SerialUSB.readBytes(ModeADS,1);  //Read the Mode;
+        SerialUSB.readBytes(ADSNum,1);  //Read the number of ADS;
+        SerialUSB.readBytes(ChipSelect,1);  //Read the Chip Select;
+        SerialUSB.readBytes(Gain,1);  //Read the Chip Select;
+
+        delay(100);
+
+        ADS1298device.initialize(SampleRate[0],ADSNum[0],ChipSelect[0]); //Initialize the ADS
+        delay(100);
+
+        ADS1298device.reINITforMoreADC(SampleRate[0], ModeADS[0]); //Configure the ADS channels
+        delay(100);
+
+        ADS1298device.START(); //Start conversion
+        delay(100);
+
+         if (Serial.available() > 0) //Flush the Trigger buffer
+           Serial.read();
+
+        toggle = !toggle;
+        digitalWrite(13, toggle);
+      }
+    }
+  }
+
+  //ADC Acquisition
+
+  if(interrupt_pin2==1){
+    ADS1298device.RDATA();
+    ADS1298device.writeADSchannelData(TriggerWord[0]);
+    interrupt_pin2 = 0;
+    TriggerWord[0] = 0x00;
+  }
+
+  //Arduino Connection and ADC initialization
+
+  if(connect){
+    if(SerialUSB.available()>9){
+      ConnectingWord = SerialUSB.readStringUntil('\0');
+
+      if(ConnectingWord.equals("Disconnect")){
+        toggle = !toggle;
+        digitalWrite(13, toggle);
+        connect = 0;
+        ADS1298device.STOP();
+        delay(100);
+        SerialUSB.flush();
+      }
+    }
+
+    if(Serial.available()){
+      Serial.readBytes(TriggerWord,1);
+      Serial.println(TriggerWord[0]);
+    }
+  }
+}
+
+
+