Led8 class initial state

Led8 class initial state

Allows to control the 8 digit 7-segment screen

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

--- ledtest2.ino
+++ ledtest2.ino
@@ -0,0 +1,200 @@
+
+int clock = 5; // SCK pin
+int latch = 6; // RCK pin
+int data = 7; // DIO pin
+
+class Led8
+{
+protected:
+  int _data;
+  int _clock;
+  int _latch;
+  int _symbols[16] =  {
+//   76543210
+    B11000000,    // 0
+    B11111001,    // 1
+    B10100100,    // 2
+    B10110000,    // 3
+    B10011001,    // 4
+    B10010010,    // 5
+    B10000010,    // 6
+    B11111000,    // 7
+    B10000000,    // 8
+    B10010000,    // 9
+    B10001000,    // A
+    B10000011,    // B
+    B11000110,    // C
+    B10100001,    // D
+    B10000110,    // E
+    B10001110};   // F
+
+  int const _space = 0xFF;
+
+  int _buf[8];
+
+  int _cursor = 0;
+
+  void moveRight()
+  {
+    if (_cursor < 7) _cursor++;
+  }
+
+  void update()
+  {
+    outputSymbol(0, _buf[0]);
+    outputSymbol(1, _buf[1]);
+    outputSymbol(2, _buf[2]);
+    outputSymbol(3, _buf[3]);
+    outputSymbol(4, _buf[4]);
+    outputSymbol(5, _buf[5]);
+    outputSymbol(6, _buf[6]);
+    outputSymbol(7, _buf[7]);
+  }
+
+  void outputSymbol(int pos, int symbol)
+  {
+    digitalWrite(_latch, LOW);
+    shiftOut(_data, _clock, MSBFIRST, 1 << pos);
+    shiftOut(_data, _clock, MSBFIRST, symbol);
+    digitalWrite(_latch, HIGH);
+  }
+
+public:
+  void setSymbol(int pos, int symbol)
+  {
+    _buf[pos] = symbol;
+  }
+
+  void andSymbol(int pos, int symbol)
+  {
+    setSymbol(pos, symbol & _buf[pos]);
+  }
+
+  void orSymbol(int pos, int symbol)
+  {
+    setSymbol(pos, symbol | _buf[pos]);
+  }
+
+  void init(int dataPin, int clockPin, int latchPin)
+  {
+    _data = dataPin;
+    _clock = clockPin;
+    _latch = latchPin;
+
+    pinMode(_clock, OUTPUT);
+    pinMode(_latch, OUTPUT);
+    pinMode(_data, OUTPUT);
+  }
+
+  void clear()
+  {
+    setSymbol(0, _space);
+    setSymbol(1, _space);
+    setSymbol(2, _space);
+    setSymbol(3, _space);
+    setSymbol(4, _space);
+    setSymbol(5, _space);
+    setSymbol(6, _space);
+    setSymbol(7, _space);
+  }
+
+  void printSymbol(int pos, int symbol)
+  {
+    setSymbol(pos, symbol);
+  }
+
+  void printSymbol(int symbol)
+  {
+    setSymbol(_cursor, symbol);
+    moveRight();
+  }
+
+  void putSymbol(int symbol)
+  {
+    setSymbol(_cursor, symbol);
+  }
+
+  void print(int pos, int value)
+  {
+    setSymbol(pos, _symbols[value]);
+  }
+
+  void print(int value)
+  {
+    print(_cursor, value);
+    moveRight();
+  }
+
+  void put(int value)
+  {
+    print(_cursor, value);
+  }
+
+  void printSpace()
+  {
+    setSymbol(_cursor, _space);
+    moveRight();
+  }
+
+  void moveTo(int pos)
+  {
+    _cursor = pos;
+  }
+
+  void moveToStart()
+  {
+    moveTo(0);
+  }
+
+  void tick(int millis)
+  {
+    update();
+  }
+};
+
+Led8 led;
+int del = 300;
+int start = 0;
+int lastmils = 0;
+int dir = 1;
+
+void setup()
+{
+  led.init(data, clock, latch);
+  led.clear();
+
+  led.moveToStart();
+  led.print(0);
+  led.print(1);
+  led.print(2);
+  led.print(3);
+  led.print(4);
+  led.print(5);
+  led.print(6);
+  led.print(7);
+}
+
+void loop()
+{
+  led.tick(0);
+
+  int mils = millis();
+  if (mils - lastmils < del) return;
+  lastmils = mils;
+
+  led.moveToStart();
+  for (int i=start; i<8+start;i++)
+    led.print(i);
+
+  if (dir > 0)
+    if (start < 8)
+      start++;
+    else dir = -1;
+  else if (start > 0)
+    start--;
+    else dir = 1;
+
+}
+
+
+


int size is actually 2 bytes

int size is actually 2 bytes

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/jeremywrnr/wampum.git/'


initial commit

initial commit

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

--- buzzword.ino
+++ buzzword.ino
@@ -0,0 +1,166 @@
+/*
+
+Description:   Prototype sketch for catchprhase device
+Author:        Alex D Glover (alexdglover@gmail.com)
+Initial Date:  21-Jun-2015
+License:       GPLv2.1 (due to libraries being licensed under GPLv2.1)
+
+Credits:
+Code for timer functionality - http://playground.arduino.cc/Main/CountDownTimer
+Original TFT library - https://github.com/Seeed-Studio/TFT_Touch_Shield_V2
+Original Touchscreen Library - https://github.com/Seeed-Studio/Touch_Screen_Driver
+Modified TFT Library for screen orientation - http://forum.arduino.cc/index.php?topic=150900.0
+
+*/
+
+// Paint application - Demonstate both TFT and Touch Screen
+#include <stdint.h>
+#include <SeeedTouchScreen.h>
+#include <TFTv2.h>
+#include <SPI.h>
+
+int ColorPaletteHigh = 30;
+int color = WHITE;  //Paint brush color
+unsigned int colors[8] = {BLACK, RED, GREEN, BLUE, CYAN, YELLOW, WHITE, GRAY1};
+
+//Timer related variables
+unsigned long Watch, _micro, time = micros();
+unsigned int Clock = 0, R_clock;
+boolean Reset = false, Stop = false, Paused = false;
+volatile boolean timeFlag = false;
+
+//List of 'catchphrases' and the current 'catchphrase
+char* listOfWords[]={"test", "puzzle", "watermelon","tree", "boat","squirrel"};
+char* currentWord = "";
+boolean needNewWord = true;
+
+// For better pressure precision, we need to know the resistance
+// between X+ and X- Use any multimeter to read it
+// The 2.8" TFT Touch shield has 300 ohms across the X plate
+
+TouchScreen ts = TouchScreen(XP, YP, XM, YM); //init TouchScreen port pins
+
+void setup()
+{
+    Tft.TFTinit();  //init TFT library
+    Serial.begin(9600);
+    //Draw the pallet
+    /*for(int i = 0; i<8; i++)
+    {
+        Tft.fillRectangle(i*30, 0, 30, ColorPaletteHigh, colors[i]);
+    }*/
+
+    randomSeed(analogRead(0));
+}
+
+boolean CountDownTimer()
+{
+  static unsigned long duration = 1000000; // 1 second
+  timeFlag = false;
+
+  if (!Stop && !Paused) // if not Stopped or Paused, run timer
+  {
+    // check the time difference and see if 1 second has elapsed
+    if ((_micro = micros()) - time > duration )
+    {
+      Clock--;
+      timeFlag = true;
+
+      if (Clock == 0) // check to see if the clock is 0
+        Stop = true; // If so, stop the timer
+
+     // check to see if micros() has rolled over, if not,
+     // then increment "time" by duration
+      _micro < time ? time = _micro : time += duration;
+    }
+  }
+  return !Stop; // return the state of the timer
+}
+
+void ResetTimer()
+{
+  SetTimer(0,0,60);
+  Stop = false;
+}
+
+void StartTimer()
+{
+  Watch = micros(); // get the initial microseconds at the start of the timer
+  Stop = false;
+  Paused = false;
+}
+
+void SetTimer(unsigned int hours, unsigned int minutes, unsigned int seconds)
+{
+  // This handles invalid time overflow ie 1(H), 0(M), 120(S) -> 1, 2, 0
+  unsigned int _S = (seconds / 60), _M = (minutes / 60);
+  if(_S) minutes += _S;
+  if(_M) hours += _M;
+
+  Clock = (hours * 3600) + (minutes * 60) + (seconds % 60);
+  R_clock = Clock;
+  Stop = false;
+}
+
+boolean TimeHasChanged()
+{
+  return timeFlag;
+}
+
+void getNewWord()
+{
+  int listOfWordsLength = sizeof(listOfWords) / sizeof(int);
+  long randomLong = random(listOfWordsLength);
+  Serial.print("Random number is ");
+  Serial.println(randomLong);
+  currentWord = listOfWords[randomLong];
+  Serial.println(currentWord);
+}
+
+void loop()
+{
+    // a point object holds x y and z coordinates.
+    Point p = ts.getPoint();
+
+    //map the ADC value read to into pixel co-ordinates
+
+    p.x = map(p.x, TS_MINX, TS_MAXX, 0, 240);
+    p.y = map(p.y, TS_MINY, TS_MAXY, 0, 320);
+
+    // we have some minimum pressure we consider 'valid'
+    // pressure of 0 means no pressing!
+
+    if (p.z > __PRESURE) {
+        // Detect  paint brush color change
+        if(p.y < ColorPaletteHigh+2)
+        {
+            color = colors[p.x/30];
+        }
+        else
+        {
+            Tft.fillCircle(p.x,p.y,2,color);
+        }
+    }
+
+    if(needNewWord)
+    {
+      getNewWord();
+      needNewWord = false;
+    }
+
+    //show phrase
+    Tft.drawString(currentWord,60,100  ,3,WHITE);
+    //Tft.drawString("World!!",60,220,4,WHITE);
+
+    CountDownTimer(); // run the timer
+
+    // this prevents the time from being constantly shown.
+    if (TimeHasChanged() )
+    {
+      //Show timer/clock
+    }
+
+}
+/*********************************************************************************************************
+  END FILE
+*********************************************************************************************************/


First round of AX25 receiver.

First round of AX25 receiver.

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

--- examples/AX25Receive/AX25Receive.ino
+++ examples/AX25Receive/AX25Receive.ino
@@ -0,0 +1,79 @@
+#define DDS_REFCLK_DEFAULT 9600
+
+#include <HamShield.h>
+#include <Wire.h>
+
+HamShield radio;
+DDS dds;
+
+void setup() {
+  Serial.begin(9600);
+  Wire.begin();
+  pinMode(2, OUTPUT);
+  pinMode(3, OUTPUT);
+
+  Serial.println(F("Radio test connection"));
+  Serial.println(radio.testConnection(), DEC);
+  Serial.println(F("Initialize"));
+  delay(100);
+  radio.initialize();
+  Serial.println(F("Frequency"));
+  delay(100);
+//  radio.setVHF();
+//  radio.setRfPower(0);
+//  radio.setModeReceive();
+  radio.setVolume1(0xFF);
+  radio.setVolume2(0xFF);
+  radio.frequency(145050);
+  Serial.println(F("DDS Start"));
+  delay(100);
+  dds.start();
+  Serial.println(F("AFSK start"));
+  delay(100);
+  radio.afsk.start(&dds);
+  Serial.println(F("Starting..."));
+  pinMode(11, INPUT); // Bodge for now, as pin 3 is hotwired to pin 11
+  delay(100);
+  dds.setAmplitude(255);
+}
+
+uint32_t last = 0;
+void loop() {
+   if(radio.afsk.decoder.read() || radio.afsk.rxPacketCount()) {
+      // A true return means something was put onto the packet FIFO
+      Serial.println("Packet");
+      // If we actually have data packets in the buffer, process them all now
+      while(radio.afsk.rxPacketCount()) {
+        AFSK::Packet *packet = radio.afsk.getRXPacket();
+        if(packet) {
+          for(unsigned short i = 0; i < packet->len; ++i)
+            Serial.write((uint8_t)packet->getByte());
+          AFSK::PacketBuffer::freePacket(packet);
+        }
+      }
+    }
+    /*if(last < millis()) {
+      Serial.println(radio.readRSSI());
+      last = millis()+1000;
+    }*/
+}
+
+/*ISR(TIMER2_OVF_vect) {
+  TIFR2 = _BV(TOV2);
+  static uint8_t tcnt = 0;
+  if(++tcnt == 8) {
+  digitalWrite(2, HIGH);
+  dds.clockTick();
+  digitalWrite(2, LOW);
+    tcnt = 0;
+  }
+}*/
+ISR(ADC_vect) {
+  static uint8_t tcnt = 0;
+  TIFR1 = _BV(ICF1); // Clear the timer flag
+  PORTD |= _BV(2); // Diagnostic pin (D2)
+  //dds.clockTick();
+  radio.afsk.timer();
+  PORTD &= ~(_BV(2)); // Pin D2 off again
+}
+


Added basic signal / slot test example

Added basic signal / slot test example

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

--- examples/TestSignals/TestSignals.ino
+++ examples/TestSignals/TestSignals.ino
@@ -0,0 +1,11 @@
+
+void setup()
+{
+}
+
+void loop()
+{
+}
+
+
+


Use Serial1.available() instead of serialevent1()

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/relayr/Arduino-Bridge-Library.git/'


Create Triggers.ino

Create Triggers.ino

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

--- Triggers.ino
+++ Triggers.ino
@@ -0,0 +1,86 @@
+
+// Triggers checks the PID algorithms and timers, and decides whether to change the state of any of the relays
+
+void Triggers (){
+
+    // temp - PID
+    coolPID.Compute();
+    if(millis() - coolWindowStartTime > coolWindowSize)
+        { //time to shift the Relay Window
+          coolWindowStartTime += coolWindowSize;  }
+
+    heatPID.Compute();
+    if(millis() - heatWindowStartTime > heatWindowSize)
+        { //time to shift the Relay Window
+          heatWindowStartTime += heatWindowSize;   }
+
+    // temp - logic
+    if(Output > (millis() - coolWindowStartTime)/1000 && Output > 2 && (millis() - coolOffElapsed) > minCool*60000) coolON = 1;
+    else {
+       if (coolON == 1) coolOffElapsed = millis();
+       coolON = 0;
+    }
+    if(Outputh > (millis() - heatWindowStartTime)/1000 && Outputh > 2) heatON = 1;
+    else heatON = 0;
+
+    // temp - pins
+    if (coolON == 1) {
+      digitalWrite(ControlCpin, LOW);
+      }
+    else {
+      digitalWrite(ControlCpin, HIGH);
+      }
+
+    if (heatON == 1) digitalWrite(ControlHpin, LOW);
+    else digitalWrite(ControlHpin, HIGH);
+
+    //hum on
+    //hum off
+
+    // lights
+    if ( (millis()+TimeAdjust)%86400000 > LightON && (millis()+TimeAdjust)%86400000 < LightOFF){
+       digitalWrite(ControlLpin, LOW); }
+    else {
+       digitalWrite(ControlLpin, HIGH); }
+
+    // fans
+    if (fanOFF > 0){
+      //If off, check for ON criteria
+      if((millis() - fanOFFmillis) > (fanOFF * 60000) && fanstate == false && coolON == 1){
+         digitalWrite(ControlApin, LOW);
+         fanOFFmillis = millis();
+         fanONmillis = millis();
+         fanstate = true;
+       }
+      //if on, check ffor OFF criteria
+      if((millis() - fanONmillis) > (fanON * 60000) && fanstate == true){
+         digitalWrite(ControlApin, HIGH);
+         fanONmillis = millis();
+         fanOFFmillis = millis();
+         fanstate = false;
+       }
+    }
+    else {
+      int x = PvT - Temp3 ;
+      if(FanAuto == 0 && abs(x) > 3) //fan on when temp diff is >3 high
+         digitalWrite(ControlApin, LOW);
+      else digitalWrite(ControlApin, HIGH);
+         //lcd.setCursor(15,0);
+    }
+
+    //brewtimer
+
+    if (brewtimerON == 1 && millis() > brewtimerRef + (brewtimer * 60000)){
+      brewtimerON = 0;
+      SvT = brewtimerSv;}
+
+    //backlight
+    if(millis() - backlighton > backlighttime && menu == 0){
+      lcd.noBacklight();
+      pulselast = pulses;
+    }
+    else lcd.backlight();
+
+    delay(50);
+}
+


test sketch

test sketch

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


Add examples

Add examples

- add ThingSpeak API example that updates a channel with the temperature value

error: pathspec 'libraries/ParkingShield/examples/03.ThingSpeak/UpdateChannel/UpdateChannel.ino' did not match any file(s) known to git

--- libraries/ParkingShield/examples/03.ThingSpeak/UpdateChannel/UpdateChannel.ino
+++ libraries/ParkingShield/examples/03.ThingSpeak/UpdateChannel/UpdateChannel.ino
@@ -0,0 +1,44 @@
+#include <Esp8266.h>
+#include <SoftwareSerial.h>
+#include <HttpRequest.h>
+
+#include <ParkingShield.h>
+#include <DeviceArduino.h>
+#include <SevenSeg.h>
+
+// CHANGE CHANNEL'S API KEY HERE:
+static const char api_key[] = "QWERTZASDFYXCV";
+
+SoftwareSerial espSerial(2,3);
+Esp8266<SoftwareSerial> esp(espSerial);
+ParkingShield shield;
+
+void setup()
+{
+  Serial.begin(9600);
+
+  esp.configureBaud();
+  esp.joinAccessPoint("ti_iot","ti_iot42!");
+  esp.setMultipleConnections(1);
+}
+
+void loop()
+{
+  String temperature(shield.getTemperature());
+
+  // Build GET request
+  HttpRequest req(F("/update"));
+  req.addParameter(F("api_key"), api_key);
+  req.addParameter(F("field1"), temperature);
+
+  // Build GET request string
+  char getRequest[100];
+  req.get(getRequest);
+
+  // Send get request string
+  esp.connect(1, F("api.thingspeak.com"), 80);
+  esp.send(1, getRequest, strlen(getRequest));
+
+  // Thingspeak requires 15 s delay between requests
+  delay (16000);
+}


Started using front sensors

Started using front sensors

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/Scalpel78/Ghost.git/'


update

update

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/DaveCalaway/ESP8266.git/'


_01_kidSerie_sketch_01.ConfigBT.ino #Kidserie

_01_kidSerie_sketch_01.ConfigBT.ino #Kidserie

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

--- _01_kidSerie_sketch_01.ConfigBT.ino
+++ _01_kidSerie_sketch_01.ConfigBT.ino
@@ -0,0 +1,71 @@
+/*
+  Project name:
+     01 #kidSerie - Arduino & MIT App Instaler 2 & HC-06
+     (Smart Phone App!)
+     Flavour I -
+     Hex File: _01_kidSerie_sketch_01.ConfigBT.ino
+   Revision History:
+     20161008:
+       - board found on Arduino e Cia Examples
+      (connect everything on HC-06 to access smart phone)
+
+   Description:
+        A Simple bluetooth config ardu_sketch to HC-06 setup!!!
+        Please goto lib manager and download SoftwareSerial!!!
+
+   MCU:                  Arduino 1.6.12 - @16MHz       http://www.arduino.cc/
+   IC Chip:              Bluetooth Datasheet - HC-06   https://goo.gl/s9ZcNC
+
+   Connections:
+      See Official youtube channel vids: https://youtu.be/u1xqW6qtFXs
+
+
+
+   Based on:   Módulo Bluetooth JY-MCU - HC-06 - Configuração (Arduino e Cia)
+   https://goo.gl/W13Qnn
+   Code by Arduino e Cia
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License v3 as published by
+   the Free Software Foundation
+*/
+#include <SoftwareSerial.h>
+
+
+SoftwareSerial mySerial(10, 11);        // RX, TX
+String command = "";                    // Stores response of bluetooth device
+                                        // which simply allows \n between each
+                                        // response.
+
+void setup()
+{
+                                        // Open serial communications and wait for port to open:
+  Serial.begin(9600);                   // Default baudrate firmware
+  //Serial.begin(115200);               // I changed to this baudrate...
+  Serial.println("Type AT commands!");
+                                        // SoftwareSerial "com port" data rate. JY-MCU v1.03 defaults to 9600.
+  mySerial.begin(9600);
+  //mySerial.begin(115200);             // ...and do not forget to match baudrate
+}
+
+void loop()
+{
+                                        // Read device output if available.
+  if (mySerial.available())
+  {
+     while(mySerial.available())
+     {                                  // While there is more to be read, keep reading.
+       command += (char)mySerial.read();
+     }
+   Serial.println(command);
+   command = "";                        // No repeats
+  }
+
+                                        // Read user input if available.
+  if (Serial.available())
+  {
+    delay(10);                          // The DELAY!
+    mySerial.write(Serial.read());
+  }
+
+}                                       // END loop()


Adding TrebleBoost_wApp

Adding TrebleBoost_wApp

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

--- examples/06-AppTutorial/TrebleBoost_App/TrebleBoost_App.ino
+++ examples/06-AppTutorial/TrebleBoost_App/TrebleBoost_App.ino
@@ -0,0 +1,276 @@
+/*
+*   TrebleBoost_wApp
+*
+*   Created: Chip Audette, OpenAudio, August 2021
+*   Purpose: Process audio by applying a high-pass filter followed by gain.  Include App interaction.
+*
+*   MIT License.  use at your own risk.
+*/
+
+//here are the libraries that we need
+#include <Tympan_Library.h>  //include the Tympan Library
+
+//set the sample rate and block size
+const float sample_rate_Hz = 44100.0f ; //24000 or 44100 (or 44117, or other frequencies in the table in AudioOutputI2S_F32)
+const int audio_block_samples = 32;     //do not make bigger than AUDIO_BLOCK_SAMPLES from AudioStream.h (which is 128)
+AudioSettings_F32 audio_settings(sample_rate_Hz, audio_block_samples);
+
+//create audio library objects for handling the audio
+Tympan                    myTympan(TympanRev::E);     //do TympanRev::D or TympanRev::E
+AudioInputI2S_F32         i2s_in(audio_settings);     //Digital audio in *from* the Teensy Audio Board ADC.
+AudioFilterBiquad_F32     hp_filt1(audio_settings);   //IIR filter doing a highpass filter.  Left.
+AudioFilterBiquad_F32     hp_filt2(audio_settings);   //IIR filter doing a highpass filter.  Right.
+AudioEffectGain_F32       gain1;                      //Applies digital gain to audio data.  Left.
+AudioEffectGain_F32       gain2;                      //Applies digital gain to audio data.  Right.
+AudioOutputI2S_F32        i2s_out(audio_settings);    //Digital audio out *to* the Teensy Audio Board DAC.
+
+//Make all of the audio connections
+AudioConnection_F32       patchCord1(i2s_in, 0, hp_filt1, 0);   //connect the Left input
+AudioConnection_F32       patchCord2(i2s_in, 1, hp_filt2, 0);   //connect the Right input
+AudioConnection_F32       patchCord3(hp_filt1, 0, gain1, 0);    //Left
+AudioConnection_F32       patchCord4(hp_filt2, 0, gain2, 0);    //right
+AudioConnection_F32       patchCord5(gain1, 0, i2s_out, 0);     //connect the Left gain to the Left output
+AudioConnection_F32       patchCord6(gain2, 0, i2s_out, 1);     //connect the Right gain to the Right output
+
+//define class for handling the GUI on the app
+TympanRemoteFormatter myGUI;  //Creates the GUI-writing class for interacting with TympanRemote App
+
+//Create BLE
+BLE ble = BLE(&Serial1);
+
+// define the setup() function, the function that is called once when the device is booting
+const float input_gain_dB = 10.0f;    //gain on the microphone
+float digital_gain_dB = 0.0;      //this will be set by the app
+float cutoff_Hz = 1000.f;             //frequencies below this will be attenuated
+const float min_allowed_Hz = 100.0f;  //minimum allowed cutoff frequency (Hz)
+const float max_allowed_Hz = 0.9 * (sample_rate_Hz/2.0);  //maximum allowed cutoff frequency (Hz);
+bool printCPUtoGUI = false;
+void setup() {
+  //begin the serial comms (for debugging)
+  myTympan.beginBothSerial(); delay(1000);
+  Serial.println("TrebleBoost_wApp: Starting setup()...");
+
+  //allocate the dynamic memory for audio processing blocks
+  AudioMemory_F32(10,audio_settings);
+
+  //Enable the Tympan to start the audio flowing!
+  myTympan.enable(); // activate AIC
+
+  //Choose the desired input
+  myTympan.inputSelect(TYMPAN_INPUT_ON_BOARD_MIC);     // use the on board microphones
+  //myTympan.inputSelect(TYMPAN_INPUT_JACK_AS_MIC);    // use the microphone jack - defaults to mic bias 2.5V
+  //myTympan.inputSelect(TYMPAN_INPUT_JACK_AS_LINEIN); // use the microphone jack - defaults to mic bias OFF
+
+  //Set the desired volume levels
+  myTympan.volume_dB(0);                   // headphone amplifier.  -63.6 to +24 dB in 0.5dB steps.
+  myTympan.setInputGain_dB(input_gain_dB); // set input volume, 0-47.5dB in 0.5dB setps
+
+  //setup BLE
+  while (Serial1.available()) Serial1.read(); //clear the incoming Serial1 (BT) buffer
+  ble.setupBLE(myTympan.getBTFirmwareRev());  //this uses the default firmware assumption. You can override!
+
+  //Set the cutoff frequency for the highpassfilter
+  cutoff_Hz = 1000.f;
+  setHighpassFilters_Hz(cutoff_Hz);   //function defined near the bottom of this file
+  printHighpassCutoff();
+
+  Serial.println("Setup complete.");
+} //end setup()
+
+
+// define the loop() function, the function that is repeated over and over for the life of the device
+void loop() {
+
+  //look for in-coming serial messages (via USB or via Bluetooth)
+  if (Serial.available()) respondToByte((char)Serial.read());   //USB Serial
+
+  //respond to BLE
+  if (ble.available() > 0) {
+    String msgFromBle; int msgLen = ble.recvBLE(&msgFromBle);
+    for (int i=0; i < msgLen; i++) respondToByte(msgFromBle[i]);
+  }
+
+  //service the BLE advertising state
+  ble.updateAdvertising(millis(),5000); //check every 5000 msec to ensure it is advertising (if not connected)
+
+  //periodically print the CPU and Memory Usage
+  if (printCPUtoGUI) {
+    myTympan.printCPUandMemory(millis(),3000); //print every 3000 msec
+    serviceUpdateCPUtoGUI(millis(),3000);      //print every 3000 msec
+  }
+
+} //end loop();
+
+
+// ///////////////// Servicing routines
+
+
+//respond to the received characters (from the SerialMonitor or from the App)
+void respondToByte(char c) {
+  Serial.print("Received character "); Serial.println(c);
+
+  switch (c) {
+    case 'J': case 'j':
+      printTympanRemoteLayout();
+      break;
+    case 'k':
+      changeGain(3.0);
+      printGainLevels();
+      setButtonText("gainIndicator", String(digital_gain_dB,1));  //send the current value to the App.  show 1 decimal place
+      break;
+    case 'K':
+      changeGain(-3.0);
+      printGainLevels();
+      setButtonText("gainIndicator", String(digital_gain_dB,1)); //send the current value to the App.  show 1 decimal place
+      break;
+    case 't':
+      incrementHighpassFilters(powf(2.0,1.0/3.0)); //raise by 1/3rd octave
+      printHighpassCutoff();
+      setButtonText("cutoffHz", String(cutoff_Hz,0));   //send the current value to the App.  show 0 decimal places
+      break;
+    case 'T':
+      incrementHighpassFilters(1.0/powf(2.0,1.0/3.0));  //lower by 1/3rd octave
+      printHighpassCutoff();
+      setButtonText("cutoffHz", String(cutoff_Hz,0));  //send the current value to the App.  show 0 decimal places
+      break;
+    case 'c':
+      Serial.println("Starting CPU reporting...");
+      printCPUtoGUI = true;
+      setButtonState("cpuStart",printCPUtoGUI);   //show the start button as "on"
+      break;
+    case 'C':
+      Serial.println("Stopping CPU reporting...");
+      printCPUtoGUI = false;
+      setButtonState("cpuStart",printCPUtoGUI);  //show the start button as "off"
+      break;
+  }
+}
+
+//Test to see if enough time has passed to send up updated CPU value to the App
+void serviceUpdateCPUtoGUI(unsigned long curTime_millis, unsigned long updatePeriod_millis) {
+  static unsigned long lastUpdate_millis = 0;
+
+  //has enough time passed to update everything?
+  if (curTime_millis < lastUpdate_millis) lastUpdate_millis = 0; //handle wrap-around of the clock
+  if ((curTime_millis - lastUpdate_millis) > updatePeriod_millis) { //is it time to update the user interface?
+    //send the latest value to the GUI!
+    setButtonText("cpuValue",String(audio_settings.processorUsage(),1)); //one decimal places
+
+    lastUpdate_millis = curTime_millis;
+  } // end if
+} //end serviceUpdateCPUtoGUI();
+
+// ///////////////// functions used to define the GUI on the phone
+
+
+// Print the layout for the Tympan Remote app, in a JSON-ish string
+// (single quotes are used here, whereas JSON spec requires double quotes.  The app converts ' to " before parsing the JSON string).
+// Please don't put commas or colons in your ID strings!
+void printTympanRemoteLayout(void) {
+  if (myGUI.get_nPages() < 1) createTympanRemoteLayout();  //create the GUI, if it hasn't already been created
+  Serial.println(myGUI.asString());
+  ble.sendMessage(myGUI.asString());
+
+  //send the values to populate the GUI with the numerical values
+  setButtonText("gainIndicator", String(digital_gain_dB,1));
+  setButtonText("cutoffHz", String(cutoff_Hz,0));
+  setButtonText("inpGain",String(input_gain_dB,1));
+  setButtonState("cpuStart",printCPUtoGUI);  //illuminate the button if we will be sending the CPU value
+}
+
+//define the GUI for the App
+void createTympanRemoteLayout(void) {
+
+  // Create some temporary variables
+  TR_Page *page_h;  //dummy handle for a page
+  TR_Card *card_h;  //dummy handle for a card
+
+  //Add first page to GUI  (the indentation doesn't matter; it is only to help us see it better)
+  page_h = myGUI.addPage("Treble Boost Demo");
+
+      //Add a card under the first page
+      card_h = page_h->addCard("Highpass Gain (dB)");
+          //Add a "-" digital gain button with the Label("-"); Command("K"); Internal ID ("minusButton"); and width (4)
+          card_h->addButton("-","K","",           4);  //displayed string, command, button ID, button width (out of 12)
+
+          //Add an indicator that's a button with no command:  Label (value of the digital gain); Command (""); Internal ID ("gain indicator"); width (4).
+          card_h->addButton("","","gainIndicator",4);  //displayed string (blank for now), command (blank), button ID, button width (out of 12)
+
+          //Add a "+" digital gain button with the Label("+"); Command("K"); Internal ID ("minusButton"); and width (4)
+          card_h->addButton("+","k","",           4);   //displayed string, command, button ID, button width (out of 12)
+
+      //Add another card to this page
+      card_h = page_h->addCard("Highpass Cutoff (Hz)");
+          card_h->addButton("-","T","",        4);  //displayed string, command, button ID, button width (out of 12)
+          card_h->addButton("", "", "cutoffHz",4);  //displayed string (blank for now), command (blank), button ID, button width (out of 12)
+          card_h->addButton("+","t","",        4);  //displayed string, command, button ID, button width (out of 12)
+
+
+  //Add a second page to the GUI
+  page_h = myGUI.addPage("Globals");
+
+    //Add an example card that just displays a value...no interactive elements
+    card_h = page_h->addCard(String("Analog Input Gain (dB)"));
+      card_h->addButton("",      "", "inpGain",   12); //label, command, id, width (out of 12)...THIS ISFULL WIDTH!
+
+    //Add an example card where one of the buttons will indicate "on" or "off"
+    card_h = page_h->addCard(String("CPU Usage (%)"));
+      card_h->addButton("Start", "c", "cpuStart", 4);  //label, command, id, width...we'll light this one up if we're showing CPU usage
+      card_h->addButton(""     , "",  "cpuValue", 4);  //label, command, id, width...this one will display the actual CPU value
+      card_h->addButton("Stop",  "C", "",         4);  //label, command, id, width...this one will turn off the CPU display
+
+  //add some pre-defined pages to the GUI (pages that are built-into the App)
+  myGUI.addPredefinedPage("serialMonitor");
+  //myGUI.addPredefinedPage("serialPlotter");
+}
+
+
+
+// ///////////////// functions used to respond to the commands
+
+//change the gain from the App
+void changeGain(float change_in_gain_dB) {
+  digital_gain_dB = digital_gain_dB + change_in_gain_dB;
+  gain1.setGain_dB(digital_gain_dB);  //set the gain of the Left-channel gain processor
+  gain2.setGain_dB(digital_gain_dB);  //set the gain of the Right-channel gain processor
+}
+
+//Print gain levels
+void printGainLevels(void) {
+  Serial.print("Analog Input Gain (dB) = ");
+  Serial.println(input_gain_dB); //print text to Serial port for debugging
+  Serial.print("Digital Gain (dB) = ");
+  Serial.println(digital_gain_dB); //print text to Serial port for debugging
+}
+
+//change the highpass cutoff frequency
+void incrementHighpassFilters(float scaleFactor) { setHighpassFilters_Hz(cutoff_Hz*scaleFactor); }
+float setHighpassFilters_Hz(float freq_Hz) {
+  cutoff_Hz = min(max(freq_Hz,min_allowed_Hz),max_allowed_Hz); //set the new value as the new state
+  hp_filt1.setHighpass(0, cutoff_Hz); //biquad IIR filter.  left channel
+  hp_filt2.setHighpass(0, cutoff_Hz); //biquad IIR filter.  right channel
+  return cutoff_Hz;
+}
+
+void printHighpassCutoff(void) {
+  Serial.println("Highpass filter cutoff at " + String(cutoff_Hz,0) + " Hz");
+}
+
+
+// ///////////////// functions used to communicate back to the App
+
+void setButtonText(String btnId, String text) {
+  String str = "TEXT=BTN:" + btnId + ":"+text;
+  Serial.println(str);
+  ble.sendMessage(str);
+}
+
+void setButtonState(String btnId, bool newState) {
+  String str = String("STATE=BTN:") + btnId;
+  if (newState) {
+    str = str + String(":1");
+  } else {
+    str = str + String(":0");
+  }
+  ble.sendMessage(str);
+}


taylor

taylor

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

--- taylor/ContServoLeft.ino
+++ taylor/ContServoLeft.ino
@@ -0,0 +1,19 @@
+/*
+ Robotics with the BOE Shield – LeftServoClockwise
+ Generate a servo full speed clockwise signal on digital pin 13.
+ */
+
+#include <Servo.h>                           // Include servo library
+
+Servo servoLeft;                             // Declare left servo
+
+void setup()                                 // Built in initialization block
+{
+  servoLeft.attach(6);                      // Attach left signal to pin 13
+  servoLeft.writeMicroseconds(1300);         // 1.3 ms full speed clockwise
+}
+
+void loop()                                  // Main loop auto-repeats
+{                                            // Empty, nothing needs repeating
+}
+


Temperature sensor

Temperature sensor

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

--- TemperatureSensor_lm35dz/lm35dz_Temp.ino
+++ TemperatureSensor_lm35dz/lm35dz_Temp.ino
@@ -0,0 +1,51 @@
+// Global variables
+int reading;
+int tempPin = 2;
+int ledPin_high = 2;
+int ledPin_low = 4;
+
+
+// Setting everything up
+void setup()
+{
+// Baud rate
+  Serial.begin(9600);
+  Serial.println('Starting...');
+
+// Setting digital led ports as outputs
+  pinMode(ledPin_high, OUTPUT);
+  pinMode(ledPin_low, OUTPUT);
+}
+
+
+void loop()
+{
+// Reading from the analog pin connected to the lm35dz
+  reading = analogRead(tempPin);
+
+// Conversion to temperature
+  float tCelsius = ( reading / 1024.0 )*500;
+  float tFarh = ( tCelsius*9 )/5 + 32;
+
+// This will light led red if bigger than 24 degrees
+// and green otherwise.
+  if ( tCelsius <= 24. )
+  {
+    digitalWrite(ledPin_low, HIGH);
+    digitalWrite(ledPin_high, LOW);
+  }
+  else
+  {
+    digitalWrite(ledPin_high, HIGH);
+    digitalWrite(ledPin_low, LOW);
+  }
+
+// Sending the temperature measurement throught serial port
+  Serial.print("Temperature = ");
+  Serial.print(tCelsius);
+  Serial.print(" (oC)");
+  Serial.println();
+
+
+  delay(500);
+}


Adding Arduino sketch

Adding Arduino sketch

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

--- sketch/switch_led.ino
+++ sketch/switch_led.ino
@@ -0,0 +1,71 @@
+int led_4 = 4;
+int led_5 = 5;
+int led_6 = 6;
+int led_7 = 7;
+int led_8 = 8;
+
+void setup() {
+  Serial.begin(9600);
+  pinMode(led_4, OUTPUT);
+  pinMode(led_5, OUTPUT);
+  pinMode(led_6, OUTPUT);
+  pinMode(led_7, OUTPUT);
+  pinMode(led_8, OUTPUT);
+  Serial.println("Enter LED number: ");
+}
+
+void loop() {
+  if (Serial.available() > 0) {
+
+    int led = ((int) Serial.read()) - 48;
+
+    switch(led) {
+      case 0:
+        turn_off();
+        return;
+      break;
+      case 1:
+        turn_on();
+        return;
+      break;
+    }
+
+    if (led < led_4 || led > led_8) {
+      Serial.println("Error");
+      return;
+    }
+
+    Serial.println("Led signal: " + String(led));
+
+    switch_led(led);
+  }
+
+}
+
+// Switches a LED depending on its current state.
+void switch_led(int led) {
+  if (digitalRead(led) == LOW) {
+    Serial.println("Turning on LED " + String(led));
+    digitalWrite(led, HIGH);
+  } else {
+    Serial.println("Turning off LED " + String(led));
+    digitalWrite(led, LOW);
+  }
+}
+
+// Turn off all LEDs
+void turn_off() {
+  for (int i = led_4; i <= led_8; i++) {
+    digitalWrite(i, LOW);
+  }
+  Serial.println("Turning off all LEDs");
+}
+
+// Turn on all LEDs
+void turn_on() {
+  for (int i = led_4; i <= led_8; i++) {
+    digitalWrite(i, HIGH);
+  }
+  Serial.println("Turning on all LEDs");
+}
+


Create pool_monitor.ino

Create pool_monitor.ino

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

--- esp8266/pool_monitor.ino
+++ esp8266/pool_monitor.ino
@@ -0,0 +1,414 @@
+//Project: Monitor water level (HC-SR04P) of Balacing tank and the Temperature of Water (DS18b20) / Ambient (DHT22)
+//         Send alert via Blynk app if water level is too high, or water temperature is higher than 28 C
+//         Device hang at the side of the tank
+
+/*
+//https://community.blynk.cc/t/water-tank-level-indicator-with-low-level-warning-notifications/26271
+
+//v1.0 - Wifi Manager + Blynk
+//v1.1 - added deep sleep function - https://community.blynk.cc/t/esp-deep-sleep/5622/13
+//v1.2 - added run time change of deep sleep interval via UI setup
+//v1.3 -
+
+//**** Blynk Virtual Pin Assignments****
+// V0 - Water temperature alert
+// V1 - Tank Height (cm)
+// V2 - Sensor distance from Tank (cm)
+// V3 - Temperature
+// V4 - Battery voltage
+// V6 - Numeric Widget - Sleep interval (mins)
+// V9 - Level V widget - Water Level %
+//V10 - Numeric Widget - Level exceed then will trigger Alert
+//V11 - Button Widget -  To enable / disable Alert
+//V12 - Distance - height from sensor to water level
+
+Hardware:
+1. Wemos D1 Pro
+2. DS18B20 Temperature Sensor
+3. Ultra Sonic Sensor
+4. 4.7k resistor - put between D4 and VCC
+
+
+Ultra sonic Sensor: Vcc - D7, Gnd - Gnd, Echo - D6, Trigger - D5
+DS18820 - Vcc - D8, Gnd - Gnd, Data - D4
+
+Todo
+----
+- if sonar sensor out of range --> don't save but Alert
+- water temperature alert
+
+*/
+
+#include <OneWire.h>
+#include <DallasTemperature.h>
+#include <ESP8266WiFi.h>
+#include <BlynkSimpleEsp8266.h>
+
+char auth[] = "<replace with yr blynk token>";
+
+char ssid[] = "wifi name";
+char pass[] = "wifi pwd";
+
+BlynkTimer timer;
+
+//HC-SR04 ultra sonic sensor
+#define trigPin D5  // Trigger Pin
+#define echoPin D6  // Echo Pin
+#define RadarPowerPin D7 //GPIO12 = D6, GPIO14 = D5, GPIO15 = D8
+
+//DS18820 temperature sensor
+#define sensorPin D4
+#define TempPowerPin D8
+
+#define filterSamples   15              // filterSamples should  be an odd number, no smaller than 3
+
+int alertLevelCounter = 0; //Counter starts at zero
+//int volume1; // for smoothing algorithum
+double wLevel; // for smoothing algorithum
+int levelAlert;
+int wateralert = 0;
+//int sensSmoothArray1 [filterSamples];   // array for holding raw sensor values for sensor1
+int smoothDistance;                     // variables for sensor1 data
+
+//double alertInMin = 0.5;                //Alert time following alert water level being reached (0.5 = 30secs)
+//const int alertDuration = 2;            //Alert sent every 2 minutes
+
+int checkFreq = 2;                //how often run the check / sleep for how long before wake up, in mins
+int tankHeight = 100;             //tank's height
+int heightFrTank = 20;            //sensor distance from tank
+long duration, distance;          // Duration used to calculate distance
+
+//init DS11820
+OneWire oneWire(sensorPin);
+DallasTemperature DS18B20(&oneWire);
+float temp;
+float volt;
+
+BLYNK_CONNECTED() { // runs once at device startup, once connected to server.
+  Blynk.syncVirtual(V1);
+  Blynk.syncVirtual(V2);
+  Blynk.syncVirtual(V6);
+  Blynk.syncVirtual(V10);
+  Blynk.syncVirtual(V11);
+}
+
+BLYNK_WRITE(V1) {
+  tankHeight = param.asInt();
+  Serial.print("\nTank's Height: ");
+  Serial.println(tankHeight);
+  Serial.println();
+}
+
+BLYNK_WRITE(V2) {
+  heightFrTank = param.asInt();
+  Serial.print("Height from Tank: ");
+  Serial.println(heightFrTank);
+  Serial.println();
+}
+
+BLYNK_WRITE(V6) {
+  checkFreq = param.asInt();
+  Serial.print("Sleep Interval: ");
+  Serial.println(checkFreq);
+  Serial.println();
+}
+
+BLYNK_WRITE(V10) {
+  levelAlert = param.asInt();
+  Serial.print("Water Level Alert: ");
+  Serial.println(levelAlert);
+  Serial.println();
+}
+
+BLYNK_WRITE(V11) {
+
+  int alertOff = param.asInt();
+
+  if(alertOff == 0) {
+    resetWaterLevelAlert();
+    wateralert = 1;
+    Serial.print("Level Alert is OFF.");
+    Serial.println();
+  }
+  else {
+    resetWaterLevelAlert();
+    wateralert = 0;
+    Serial.print("Level Alert is ON.");
+    Serial.println();
+  }
+
+}
+
+void resetWaterLevelAlert() {
+  alertLevelCounter = 0;
+  wateralert = 0;
+}
+
+void checkWaterLevel() {
+  Serial.print("Water Level (%) = ");
+  Serial.println(wLevel);
+  Serial.print("Level Alert (%) = ");
+  Serial.println(levelAlert);
+  Serial.print("Alert (1 = off, 0 = on) = ");
+  Serial.println(wateralert);
+
+  if(wLevel > levelAlert && wateralert == 0){
+//    alertLevelCounter += 1;
+    Blynk.notify("Water Tank Level Alert"); // send push notification to blynk app
+
+  }
+
+//  if(alertLevelCounter > alertInMin * 60 && wateralert == 0){
+//    Blynk.notify("Water Tank Level Alert"); // send push notification to blynk app
+//    wateralert = 1;
+//    resetWaterLevelAlert();
+//  }
+}
+
+void MeasureCmForSmoothing() {
+
+  //take multiple reading
+
+  digitalWrite(RadarPowerPin, HIGH);  //provide power
+  delay(1000);
+
+    smoothDistance = mesureDistance();
+
+  digitalWrite(RadarPowerPin, LOW);  //turn off power
+  delay(100);
+
+  Serial.print("Smoothed Distance: ");
+  Serial.println(smoothDistance);
+
+  //tank height 100 cm, sensor is 20 cm above the tank
+  wLevel = (tankHeight + heightFrTank - smoothDistance);
+
+  Serial.print("Water Level (cm): ");
+  Serial.println(wLevel);
+
+  //convert to %
+  wLevel = wLevel / tankHeight * 100;
+
+  Serial.print("Water Level (%): ");
+  Serial.println(wLevel);
+
+  Blynk.virtualWrite(V12, smoothDistance); // virtual pin
+  Blynk.virtualWrite(V9, wLevel); // virtual pin
+  delay(1000);
+}
+
+void UploadMeasureCmForSmoothing() {
+
+  Blynk.virtualWrite(V3, temp); // Water level %
+  Blynk.virtualWrite(V4, volt); // battery
+  Blynk.virtualWrite(V9, wLevel); // Water level %
+  Blynk.virtualWrite(V12, smoothDistance); // virtual pin
+
+}
+
+
+void setup() {
+  Serial.begin(115200);
+  Blynk.begin(auth, ssid, pass);
+
+  pinMode(trigPin, OUTPUT);
+  pinMode(echoPin, INPUT);
+  //pin to provide power to ultra sonic sensor
+  pinMode(RadarPowerPin, OUTPUT);
+
+  //pin to provide power to temperature sensor
+  pinMode(TempPowerPin, OUTPUT);
+
+  Serial.println("Measure Water Temperature");
+  measurementEvent();
+
+  Serial.println("\nMeasure Water Level");
+  MeasureCmForSmoothing();
+
+  Serial.println("Upload Data");
+  UploadMeasureCmForSmoothing();
+
+  Serial.println("check WaterLevel Alert");
+  checkWaterLevel();
+
+  goToSleep();
+
+}
+
+void loop() {
+
+}
+
+int digitalSmooth(int rawIn, int *sensSmoothArray){     // "int *sensSmoothArray" passes an array to the function - the asterisk indicates the array name is a pointer
+int j, k, temp, top, bottom;
+long total;
+static int i;
+// static int raw[filterSamples];
+static int sorted[filterSamples];
+boolean done;
+
+i = (i + 1) % filterSamples;    // increment counter and roll over if necc. -  % (modulo operator) rolls over variable
+sensSmoothArray[i] = rawIn;                 // input new data into the oldest slot
+
+// Serial.print("raw = ");
+
+ for (j=0; j<filterSamples; j++){     // transfer data array into anther array for sorting and averaging
+     sorted[j] = sensSmoothArray[j];
+ }
+
+   done = 0;                // flag to know when we're done sorting
+ while(done != 1){        // simple swap sort, sorts numbers from lowest to highest
+      done = 1;
+        for(j = 0; j < (filterSamples - 1); j++){
+           if(sorted[j] > sorted[j + 1]){     // numbers are out of order - swap
+             temp = sorted[j + 1];
+             sorted [j+1] =  sorted[j] ;
+             sorted [j] = temp;
+             done = 0;
+           }
+        }
+  }
+
+   // throw out top and bottom 15% of samples - limit to throw out at least one from top and bottom
+   //  bottom = max(((filterSamples * 15)  / 100), 1);
+   //  top = min((((filterSamples * 85) / 100) + 1  ), (filterSamples - 1));   // the + 1 is to make up for asymmetry caused by integer rounding
+   bottom = max(((filterSamples * 20)  / 100), 1);
+   top = min((((filterSamples * 80) / 100) + 1  ), (filterSamples - 1));   // the + 1 is to make up for asymmetry caused by integer rounding
+   k = 0;
+   total = 0;
+  for( j = bottom; j< top; j++){
+ total += sorted[j];  // total remaining indices
+ k++;
+ //Serial.print(sorted[j]);
+ //Serial.print("   ");
+ //terminal.print(sorted[j]);
+ //terminal.println("   ");
+
+  }
+   //terminal.print("average: ");
+   //terminal.println(total/k);
+   //terminal.flush();
+   //Serial.println();
+   //Serial.print("average = ");
+   //Serial.println(total/k);
+  return total / k;    // divide by number of samples
+}
+
+int mesureSingleDistance() {
+      long duration, distance;
+
+      digitalWrite(trigPin, LOW);
+      delayMicroseconds(2);
+      digitalWrite(trigPin, HIGH);
+      delayMicroseconds(10);
+      digitalWrite(trigPin, LOW);
+      duration = pulseIn(echoPin, HIGH);
+      distance = (duration/2) / 29.1;
+
+      Serial.print("Distance: ");
+      Serial.println(distance);
+
+      return distance;
+  }
+
+/**
+ * mresure distnce average delay 10ms
+ */
+int mesureDistance() {
+    const int ULTRASONIC_MIN_DISTANCE = heightFrTank;  //20
+    const int ULTRASONIC_MAX_DISTANCE = tankHeight + heightFrTank;  //120
+
+      int i, total_count = 0, total_distance = 0, distance, values[10], average, temp, new_count = 0;
+
+      for(i=0; i<5; i++){
+          distance = mesureSingleDistance();
+          //check if out of range
+          if(distance > ULTRASONIC_MIN_DISTANCE && distance < ULTRASONIC_MAX_DISTANCE) {
+              total_distance += distance;
+              values[total_count++]=distance;
+              Serial.printf("Value %d...\n", distance);
+          }
+      }
+
+      Serial.print("total_count = ");
+      Serial.println(total_count);
+      if(total_count > 0) {
+
+          average = total_distance / total_count;
+          total_distance = 0;
+          Serial.printf("Average %d...\n", average);
+
+          for(i=0; i<total_count; i++){
+              temp = (average - values[i])*100/average;
+              Serial.printf("Analyze %d....%d...\n", values[i],temp);
+              if(temp < 10 && temp > -10){
+                  total_distance += values[i];
+                  new_count++;
+              }
+          }
+
+          if(new_count > 0) {
+//              Serial.print("total_distance = ");
+//              Serial.println(total_distance);
+//              Serial.print("new_count = ");
+//              Serial.println(new_count);
+              return total_distance / new_count;
+          }
+      }
+      Serial.println("Sonar sensor out of range");
+      return 0;  //return 0 meaning the sensor out of range
+  }
+
+void goToSleep() {
+  // calculate required sleep time and go to sleep
+
+  Serial.print(" Going to sleep now for ");
+  Serial.print(checkFreq);
+  Serial.println(" mins");
+
+  ESP.deepSleep(checkFreq * 60 * 1000000); //deepSleep is microseconds 1 sec = 1000000
+  delay(100);
+
+} // end of void goToSleep()
+
+void measurementEvent() {
+
+
+  //******Measure Water Temperature*********************************************
+  digitalWrite(TempPowerPin, HIGH);  //provide power
+  delay(2000);
+
+  DS18B20.begin();
+  DS18B20.requestTemperatures();
+  temp = DS18B20.getTempCByIndex(0); // Celcius
+  Serial.print("Temperature (C) = ");
+  Serial.println(temp);
+
+  digitalWrite(TempPowerPin, LOW);  //turn off power
+  delay(100);
+
+  //******Battery Voltage Monitoring*********************************************
+  //depend on 220k or 100k resistor used, toggle between this 2 calculation
+
+  // using 220k
+  // Voltage divider R1=100k, R2 = (220k + 100k) + 220k = 540k
+  // Calculation to get the factor: 4.2v * 100/540 = 0.7777, 0.7777 * y = 4.2, y = 5.4
+//  float calib_factor = 5.28; // change this value to calibrate the battery voltage, 5.28 is so call calibrated
+//  float calib_factor = 5.4;
+
+  // using 100k
+  // Voltage divider R1 = 100k, R2 = (220k + 100k) + 100k = 420k;
+  // Calculation to get the factor: 4.2v * 100/420 = 1, 1 * y = 4.2, y = 4.2
+  float calib_factor = 4.2;
+
+  unsigned long raw = analogRead(A0);
+//  Serial.print("raw analog = ");
+//  Serial.println(raw);
+  float volt = raw * calib_factor/1024;
+
+  Serial.print( "\nVoltage = ");
+  Serial.print(volt, 2); // print with 2 decimal places
+  Serial.println (" V");
+
+ //*******************************************************************************
+}


Update pt_remote controlled car2.ino

Update pt_remote controlled car2.ino

error: pathspec 'pt_remote' did not match any file(s) known to git
error: pathspec 'controlled' did not match any file(s) known to git
error: pathspec 'car/pt_remote' did not match any file(s) known to git
error: pathspec 'controlled' did not match any file(s) known to git
error: pathspec 'car2.ino' did not match any file(s) known to git


Create spark-plotly.ino

Create spark-plotly.ino

error: pathspec 'example/spark-plotly.ino' did not match any file(s) known to git

--- example/spark-plotly.ino
+++ example/spark-plotly.ino
@@ -0,0 +1,30 @@
+#include "spark-plotly.h"
+
+#define DATA_POINTS 4
+
+char* data_point_tokens[NUM_TOKENS] = {"token1", "token2", "token3","token4"};
+plotly graph = plotly("username", "secret", streaming_tokens, "streamname", DATA_POINTS);
+
+void setup() {
+   graph.init();
+   graph.fileopt = "extend";
+   graph.openStream();
+}
+
+void loop() {
+
+    float val1;
+    float val2;
+    float val3;
+    float val4;
+
+    // up to you to decide what these values represent and how they get initialized/updated.
+
+    unsigned long x = millis();
+
+    graph.plot(x, val1, data_point_tokens[0]);
+    graph.plot(x, val2, data_point_tokens[1]);
+    graph.plot(x, val3, data_point_tokens[2]);
+    graph.plot(x, val4, data_point_tokens[3]);
+
+}


initial commit

initial commit

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

--- TUI.ino
+++ TUI.ino
@@ -0,0 +1,20 @@
+double x = 0;
+double y = 0;
+
+
+void setup() {
+  // put your setup code here, to run once:
+  setPinMode(11,HIGH);
+  setPinMode(12,HIGH);
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+
+  x = analogRead(A12);
+  y = analogRead(A13);
+
+  Serial.print(x);
+  Serial.print(" ");
+  Serial.println(y);
+}


Create IRsendRawDemo.ino

Create IRsendRawDemo.ino

New example should go into new fordel of same name...sorry

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

--- examples/IRsendRawDemo/IRsendRawDemo.ino
+++ examples/IRsendRawDemo/IRsendRawDemo.ino
@@ -0,0 +1,37 @@
+/*
+ * IRremote: IRsendRawDemo - demonstrates sending IR codes with sendRaw
+ * An IR LED must be connected to Arduino PWM pin 3.
+ * Version 0.1 July, 2009
+ * Copyright 2009 Ken Shirriff
+ * http://arcfn.com
+ *
+ * IRsendRawDemo - added by AnalysIR (via www.AnalysIR.com), 24 August 2015
+ *
+ * This example shows how to send a RAW signal using the IRremote library.
+ * The example signal is actually a 32 bit NEC signal.
+ * Remote Control button: LGTV Power On/Off.
+ * Hex Value: 0x20DF10EF, 32 bits
+ *
+ * It is more efficient to use the sendNEC function to send NEC signals.
+ * Use of sendRaw here, serves only as an example of using the function.
+ *
+ */
+
+
+#include <IRremote.h>
+
+IRsend irsend;
+
+void setup()
+{
+
+}
+
+void loop() {
+  int khz = 38; // 38kHz carrier frequency for the NEC protocol
+  unsigned int irSignal[] = {9000, 4500, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 39416, 9000, 2210, 560}; //AnalysIR Batch Export (IRremote) - RAW
+
+  irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.
+
+  delay(5000); //In this example, the signal will be repeated every 5 seconds, approximately.
+}


add dplay firmware

add dplay firmware

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

--- firmware/dplay/dplay.ino
+++ firmware/dplay/dplay.ino
@@ -0,0 +1,105 @@
+char remainData;
+
+void setup(){
+  Serial.begin(115200);
+  Serial.flush();
+  initPorts();
+}
+
+void initPorts () {
+  for (int pinNumber = 0; pinNumber < 14; pinNumber++) {
+    pinMode(pinNumber, OUTPUT);
+    digitalWrite(pinNumber, LOW);
+  }
+}
+
+void loop() {
+  while (Serial.available()) {
+    if (Serial.available() > 0) {
+      char c = Serial.read();
+      updateDigitalPort(c);
+    }
+  }
+  delay(15);
+  sendPinValues();
+  delay(10);
+}
+
+void sendPinValues() {
+  int pinNumber = 0;
+  for (pinNumber = 0; pinNumber < 14; pinNumber++) {
+      sendDigitalValue(pinNumber);
+  }
+  for (pinNumber = 0; pinNumber < 6; pinNumber++) {
+      sendAnalogValue(pinNumber);
+  }
+
+}
+
+void updateDigitalPort (char c) {
+  // first data
+  if (c>>7) {
+    // is output
+    if ((c>>6) & 1) {
+      // is data end at this chunk
+      if ((c>>5) & 1) {
+        int port = (c >> 1) & B1111;
+        setPortWritable(port);
+        if (c & 1)
+          digitalWrite(port, HIGH);
+        else
+          digitalWrite(port, LOW);
+      }
+      else {
+        remainData = c;
+      }
+    } else {
+      int port = (c >> 1) & B1111;
+      setPortReadable(port);
+    }
+  } else {
+    int port = (remainData >> 1) & B1111;
+    int value = ((remainData & 1) << 7) + (c & B1111111);
+    setPortWritable(port);
+    analogWrite(port, value);
+    remainData = 0;
+  }
+}
+
+void sendAnalogValue(int pinNumber) {
+  int value = analogRead(pinNumber);
+  Serial.write(B11000000
+               | ((pinNumber & B111)<<3)
+               | ((value>>7) & B111));
+  Serial.write(value & B1111111);
+}
+
+void sendDigitalValue(int pinNumber) {
+  if (digitalRead(pinNumber) == HIGH) {
+    Serial.write(B10000000
+                 | ((pinNumber & B1111)<<2)
+                 | (B1));
+  } else {
+    Serial.write(B10000000
+               | ((pinNumber & B1111)<<2));
+  }
+}
+
+void setPortReadable (int port) {
+  if (isPortWritable(port)) {
+    pinMode(port, INPUT);
+  }
+}
+
+void setPortWritable (int port) {
+  if (!isPortWritable(port)) {
+    pinMode(port, OUTPUT);
+  }
+}
+
+boolean isPortWritable (int port) {
+  if (port > 7)
+    return bitRead(DDRB, port - 8);
+  else
+    return bitRead(DDRD, port);
+}


Add proof of concept code

Add proof of concept code

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

--- PoF/motorControlPID.ino
+++ PoF/motorControlPID.ino
@@ -0,0 +1,135 @@
+#define     MOTOR_ENCODER_A             2
+#define     MOTOR_ENCODER_B             3
+
+#define     LED_PIN                     13
+
+#define     LOOP_TIME_10ms              5
+#define     LOOP_TIME_100ms             100
+#define     LOOP_TIME_1s                1000
+
+#define     ENCODER_INTEGRAL_FORCE      1
+
+// endcoder needed variables
+uint32_t encoderSpeed, setPoint = 1000, powerLevel, encoderLastSignalChange = 0, encoderLastTimeBetweenPeaks = 0, bufferForEncoder;
+
+// main tasks time handling
+uint32_t LastFire10ms, LastFire100ms, LastFire1s, currentMillis;
+
+// integration filter for encoders
+float sumOfEncoderSpeed = 0.0;
+
+void setup()
+{
+    Serial.begin(115200);
+
+    pinMode(MOTOR_ENCODER_A , INPUT);
+    pinMode(MOTOR_ENCODER_B , INPUT);
+
+    pinMode(LED_PIN         , OUTPUT);
+
+    attachInterrupt(0, handleEncoderPinChange, CHANGE);
+    attachInterrupt(1, handleEncoderPinChange, CHANGE);
+}
+
+void loop()
+{
+    currentMillis = millis();
+    // 10 ms loop
+    if(currentMillis - LastFire10ms > LOOP_TIME_10ms)
+    {
+        // update motor speed
+        bufferForEncoder = getMotorSpeed();
+
+        if (bufferForEncoder < 1500 && bufferForEncoder != 0 && bufferForEncoder != 82) // only when data is not over motor specs
+        {
+            encoderSpeed = bufferForEncoder;
+        }
+
+        // integrate the encoder output to reach smoother values
+        sumOfEncoderSpeed -= (sumOfEncoderSpeed - ((float)encoderSpeed)) * ENCODER_INTEGRAL_FORCE;
+
+        // load the speed in the output variable
+        encoderSpeed = sumOfEncoderSpeed;
+
+        // run 10 ms tasks
+        sendDataToPC();
+
+        // update lat fire
+        LastFire10ms = currentMillis;
+    }
+}
+
+uint32_t getMotorSpeed()
+{
+    // response buffer
+    uint32_t responseVariable;
+
+    // in case the current delay is lower than the last, we need to return the last as the current is still in progress
+    if( micros() - encoderLastSignalChange < encoderLastTimeBetweenPeaks)
+    {
+        // load the response in the buffer
+        responseVariable = encoderLastTimeBetweenPeaks;
+    }
+    else
+    {
+        // load the current time delay as the speed response
+        responseVariable = micros() - encoderLastSignalChange;
+    }
+
+    // convert the encoder value to speed in RPM
+    responseVariable = 1000000 / (responseVariable * 12);
+
+    // response to the caller
+    return responseVariable;
+}
+
+void handleEncoderPinChange()
+{
+    // static flag for peak detection
+    static uint8_t peakStarted = 0;
+
+    // in case the peak eneded we need to update the last time between peaks
+    if (1 == peakStarted)
+    {
+        // load the new peap to peak time in the variable
+        encoderLastTimeBetweenPeaks = micros() - encoderLastSignalChange;
+
+        // reset peak started flag
+        peakStarted = 0;
+    }
+    else
+    {
+        // set peak started flag
+        peakStarted = 1;
+    }
+
+    // update last signal detected
+    encoderLastSignalChange = micros();
+}
+
+void sendDataToPC()
+{
+  // send start to tester
+  Serial.write(0x03);
+
+  // send 32 bit value
+  Serial.write(encoderSpeed);
+  Serial.write(encoderSpeed >> 8);
+  Serial.write(encoderSpeed >> 16);
+  Serial.write(encoderSpeed >> 24);
+
+  // send 32 bit value
+  Serial.write(setPoint);
+  Serial.write(setPoint >> 8);
+  Serial.write(setPoint >> 16);
+  Serial.write(setPoint >> 24);
+
+  // send 32 bit value
+  Serial.write(powerLevel);
+  Serial.write(powerLevel >> 8);
+  Serial.write(powerLevel >> 16);
+  Serial.write(powerLevel >> 24);
+
+  // send end to tester
+  Serial.write(0xFC);
+}


Create spark-http-server.ino

Create spark-http-server.ino

error: pathspec 'spark-http-server.ino' did not match any file(s) known to git

--- spark-http-server.ino
+++ spark-http-server.ino
@@ -0,0 +1,167 @@
+
+TCPServer server = TCPServer(80);
+TCPClient client;
+
+char   addr[16];
+char   myInput[30];
+char   myIncoming;
+int    myLoop1;
+String myInStr;
+
+
+void setup()
+{
+
+   pinMode(D7, OUTPUT);
+   digitalWrite(D7, HIGH);
+   delay(1000);
+   digitalWrite(D7, LOW);
+   delay(1000);
+   digitalWrite(D7, HIGH);
+   delay(1000);
+   digitalWrite(D7, LOW);
+   delay(1000);
+   delay(1000);
+   delay(1000);  // give a few seconds to reflash the core if it gets unresponsive on startup
+   digitalWrite(D7, HIGH);
+   delay(300);
+   digitalWrite(D7, LOW);
+
+
+  server.begin();
+  IPAddress localIP = WiFi.localIP();
+  sprintf(addr, "%u.%u.%u.%u", localIP[0], localIP[1], localIP[2], localIP[3]);
+  Spark.variable("Address", addr, STRING);
+  Spark.variable("myIn",  myInput, STRING);
+  Spark.variable("myLoop1", &myLoop1, INT);
+}
+
+
+void loop() {
+    // listen for incoming clients
+    client = server.available();
+    if (client) {
+
+
+        myLoop1 = 0;
+        myInput[0] = '\0';
+
+        boolean currentLineIsBlank = true;
+        while (client.connected()) {
+
+
+            if (client.available()) {
+
+
+
+
+                myIncoming = client.read();       // read from the http request
+               // client.write(myIncoming);         // great with Telnet to see what is going to the server
+               if (myLoop1 < 29 ){                 // http request should be much longer than 29 characters!
+                   myInput[myLoop1] = myIncoming; // put the character into an array
+
+                } else {                           // read enough information from the http request
+
+                    myInput[myLoop1] = '\0';      // helps make a char array compatible with a string.
+
+                    myInStr = myInput;
+                    myInStr.toUpperCase();
+
+                   if (myInStr.indexOf("D7-ON") >= 0){   digitalWrite(D7, HIGH); }
+                   if (myInStr.indexOf("D7-OFF") >= 0){  digitalWrite(D7, LOW); }
+
+
+
+                   }
+
+                 myLoop1++;
+
+
+
+
+                if (myIncoming == '\n' && currentLineIsBlank) {
+
+
+                    //client.println("
Hello World.
");   // use for debugging to check if http request can get returned
+
+
+                    delay(1);
+                    break;
+                }
+                if (myIncoming == '\n') {          // you're starting a new line
+                    currentLineIsBlank = true;
+                }
+                else if (myIncoming != '\r') {     // you've gotten a character on the current line
+                    currentLineIsBlank = false;
+                }
+
+
+            }
+        }
+        // give the web browser time to receive the data
+        delay(1);
+    }
+    client.flush();
+    client.stop();
+}
+
+
+
+
+
+
+
+
+
+
+/*
+
+MAKE THIS HTML PAGE TO COMMUNICATE WITH YOUR CORE
+
+
+
+
+Address

+
+Click the above link after replacing CORE-ID AND ACCESS-TOKEN.

+After clicking the above from the result change the below code to the correct IP
+
+D7-ON...
+D7-OFF

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+The serial printout looks like
+
+192.145.1.65
+GET /?D7-ON HTTP/1.1
+Host: 192.145.1.65
+Connection: keep-alive
+Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,* / *;q=0.8
+User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2231.0 Safari/537.36
+Accept-Encoding: gzip, deflate, sdch
+Accept-Language: en-US,en;q=0.8
+
+
+
+
+*/
+
+


Submitting basic weather data

Submitting basic weather data

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/rniemand/ArduinoProjects.git/'


cleanup

cleanup

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/nathankoch/arduino-videosynth.git/'


Create com2CsTest.ino

Create com2CsTest.ino

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

--- Csharp/Due/com2CsTest.ino
+++ Csharp/Due/com2CsTest.ino
@@ -0,0 +1,91 @@
+/*
+
+ * Serial Port Monitor
+ *
+ *
+ */
+//Setup Output
+
+int ledPin_3 = 3;
+
+//Setup message bytes
+
+byte inputByte_0;
+
+byte inputByte_1;
+
+byte inputByte_2;
+
+byte inputByte_3;
+
+byte inputByte_4;
+
+//Setup
+
+void setup() {
+
+  pinMode(ledPin_3, OUTPUT);
+  Serial.begin(9600);
+  digitalWrite(ledPin_3, HIGH);//
+  delay(250);//
+  digitalWrite(ledPin_3, LOW);//
+  delay(250);//
+}
+
+//Main Loop
+
+void loop() {
+
+  //Read Buffer
+  if (Serial.available() == 5)
+  {
+    //Read buffer
+    inputByte_0 = Serial.read();
+    delay(100);
+    inputByte_1 = Serial.read();
+    delay(100);
+    inputByte_2 = Serial.read();
+    delay(100);
+    inputByte_3 = Serial.read();
+    delay(100);
+    inputByte_4 = Serial.read();
+  }
+  //Check for start of Message
+  if(inputByte_0 == 16)
+  {
+       //Detect Command type
+       switch (inputByte_1)
+       {
+          case 127:
+             //Set PIN and value
+             switch (inputByte_2)
+            {
+              case 4:
+                if(inputByte_3 == 255)
+                {
+                  digitalWrite(ledPin_3, HIGH);
+                  break;
+                }
+                else
+                {
+                  digitalWrite(ledPin_3, LOW);
+                  break;
+                }
+              break;
+            }
+            break;
+          case 128:
+            //Say hello
+            Serial.print("HELLO FROM ARDUINO");
+            break;
+        }
+        //Clear Message bytes
+        inputByte_0 = 0;
+        inputByte_1 = 0;
+        inputByte_2 = 0;
+        inputByte_3 = 0;
+        inputByte_4 = 0;
+        //Let the PC know we are ready for more data
+        Serial.print("-READY TO RECEIVE");
+  }
+}


draw triangles demo

draw triangles demo

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

--- examples/draw_triangles/draw_triangles.ino
+++ examples/draw_triangles/draw_triangles.ino
@@ -0,0 +1,37 @@
+
+#include <SoftwareSerial.h>
+#include <Warefab_TFT.h>
+
+
+SoftwareSerial ss_tft(2, 3); // RX, TX
+Warefab_TFT tft(&ss_tft);
+
+void setup() {
+  //initialize uart speed, 115200
+  tft.begin(115200);
+  //clear screen
+  tft.clearScreen();
+  delay(1000);
+  //set brush color, fill color
+  tft.brushColor(255, 0, 0);
+  //set pen color
+  tft.penColor(0, 255, 0);
+  delay(20);
+}
+
+void loop() {
+  //draw triangles
+  for (int y = 0; y < 30; y++)
+  {
+    for (int x = 0; x < 11; x++)
+    {
+      if (x % 2) tft.fillTriangle(20 + 20 * x, 10 + y * 10, 10 + x * 20,
+                                    20 + y * 10, 30 + x * 20, 20 + y * 10);
+      else tft.drawTriangle(20 + 20 * x, 10 + y * 10, 10 + x * 20,
+                              20 + y * 10, 30 + x * 20, 20 + y * 10);
+    }
+    delay(20);
+  }
+  //delay for 5 sec before clear screen
+  delay(5000);
+}


Arduino official ethernet shield initial commit

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/Countly/countly-sdk-iot-cpp.git/'


First version of sensor firmware: debugging with LEDs and serial port, no networking

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/qiwi/parking.git/'


Create mainRead.ino

Create mainRead.ino

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

--- mainRead.ino
+++ mainRead.ino
@@ -0,0 +1,135 @@
+// CRAP Codes
+#define USER_ID 0b0110
+#define ENCRYPTED_MESSAGE 0b0100
+#define SUCCESSFUL_ACKNOWLEDGEMENT 0b0111
+#define FAILED_ACKNOWLEDGEMENT 0b1111
+#define INVALID_USER_ID 0b0101
+
+// variables for tracking protocol state
+uint16_t crapUserId = 0;
+uint16_t crapMessage = 0;
+int incomingByteIndex = 0;
+bool didLastMessageFail = false;
+bool isWaiting = true;
+
+// helper function for creating a byte for the protocol
+uint8_t createByte(uint8_t protocolCode, uint8_t data) {
+    uint8_t byte = (protocolCode << 4) | data;
+    return byte;
+}
+
+// converts a user id and message into something that can be sent with a serial communication
+/*uint8_t* convertMessage(uint16_t userId, uint16_t message) {
+    uint8_t[8] convertedMessage = new uint8_t [8];
+    // converting the userId into in the protocol
+    for (int i = 0; i < 4; i++) {
+        int userIdPositon = (3 - i) * 4;
+        uint16_t userIdMask = 0b1111 << userIdPosition;
+        uint8_t data = (userId & userIdMask) >> userIdPosition;
+        convertedMessage[i] = createByte(USER_ID, data);
+    }
+    // converting the message into in the protocol
+    for (int i = 0; i < 4; i++) {
+        int messagePositon = (3 - i) * 4;
+        uint16_t messageMask = 0b1111 << messagePosition;
+        uint8_t data = (message & messageMask) >> messagePosition;
+        convertedMessage[i+4] = createByte(ENCRYPTED_MESSAGE, data);
+    }
+    return convertedMessage;
+}*/
+
+// helper function for reading the code off an incoming byte
+uint8_t getProtocolCode(uint8_t protocolByte) {
+    return (protocolByte >> 4) & 0b1111;
+}
+
+// helper function for reading the data off an incoming byte
+uint8_t getProtocolData(uint8_t protocolByte) {
+    return protocolByte & 0b1111;
+}
+
+// processes incoming byte for the receiver of incoming messages
+void processIncomingByte(uint8_t incomingByte) {
+    uint8_t code = getProtocolCode(incomingByte);
+    uint8_t data = getProtocolData(incomingByte);
+    if (0 <= incomingByteIndex && incomingByteIndex <= 3 && code == USER_ID) {
+        // successful incoming user id
+        didLastMessageFail = false;
+        isWaiting = true;
+        int userIdPosition = (3 - incomingByteIndex) * 4;
+        crapUserId = crapUserId | (data << userIdPosition);
+        incomingByteIndex++;
+    } else if (4 <= incomingByteIndex && incomingByteIndex <= 7 && code == ENCRYPTED_MESSAGE) {
+        // successful incoming message
+        didLastMessageFail = false;
+        isWaiting = true;
+        int messagePositon = (7 - incomingByteIndex) * 4;
+        crapMessage = crapMessage | (data << messagePositon);
+        incomingByteIndex++;
+        if (incomingByteIndex == 8) {
+            // message complete
+            incomingByteIndex = 0;
+            isWaiting = false;
+        }
+    } else {
+        // invalid data, reset protocol and signal that the message failed
+        crapUserId = 0;
+        crapMessage = 0;
+        incomingByteIndex = 0;
+        didLastMessageFail = true;
+    }
+}
+
+// functions for reading protocol state
+bool isMessageComplete() {
+    return !isWaiting;
+}
+
+bool hasMessageFailed() {
+    return didLastMessageFail;
+}
+
+uint16_t getUserId() {
+    return crapUserId;
+}
+
+uint16_t getMessage() {
+    return crapMessage;
+}
+
+uint8_t nextByte = 0;
+
+void updateStatusIndicators() {}
+
+void setup() {
+    // initialize
+    Serial.begin(9600);
+    pinMode(LED_BUILTIN, OUTPUT);
+}
+
+  void loop() {
+    // waiting for incoming data
+    if (Serial.available()) {
+        // reading the next byte and sending it to the CRA Protocol
+        nextByte = Serial.read();
+        processIncomingByte(nextByte);
+        Serial.print("code: ");
+        Serial.print(getProtocolCode(nextByte), BIN);
+        Serial.print(", data: ");
+        Serial.print(getProtocolData(nextByte), BIN);
+        Serial.println();
+
+        // check to see if the message is complete
+        if (isMessageComplete()) {
+          uint16_t userId = getUserId();
+          uint16_t message = getMessage();
+          Serial.println(userId, BIN);
+          Serial.println(message, BIN);
+        }
+    }
+    if (hasMessageFailed()) {
+      digitalWrite(LED_BUILTIN, HIGH);
+    } else {
+      digitalWrite(LED_BUILTIN, LOW);
+    }
+}


first commit of control procedure

first commit of control procedure

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

--- mainproc.ino
+++ mainproc.ino
@@ -0,0 +1,142 @@
+#include <EEPROM.h>
+#include <Adafruit_BMP085_U.h>
+
+Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);
+bool sensorStatus=false;
+uint16_t writePos=0x000;
+
+const uint16_t FLAG_ADDR=0x000;
+enum EEPROM_FLAGS {
+  FLAG_BLANK=0x00,
+  FLAG_DEFAULT=0xA0,
+  FLAG_FIRST_WRITE=0xA1,
+  FLAG_ADDITIONAL_WRITE=0xA2,
+  FLAG_COMPLETED=0xFF
+};
+
+EEPROM_FLAGS eeprom_state=FLAG_DEFAULT;
+
+const uint16_t PRESS_ADDR=0x001;
+float baseLevelPressure=1023.25f;
+
+
+enum ACTUATOR_STATE {
+  STATE_DISENGAGED,
+  STATE_ARMED,
+  STATE_ENGAGED,
+  STATE_EXPIRED
+};
+
+enum ACTUATOR_TYPE {
+  TYPE_DROGUE,
+  TYPE_MAIN_CHUTE
+};
+
+ACTUATOR_STATE states[2]={STATE_DISENGAGED};
+
+void setup() {
+  pinMode(LED_BUILTIN, OUTPUT);
+  Serial.begin(9600);
+
+  // Initialize EEPROM
+  // read EEPROM, check if there's something written by checking 0x000
+  // then, set write location to rightmost nonzero position
+  // EEPROM.write(FLAG_ADDR,FLAG_BLANK);
+  byte flags = EEPROM.read(FLAG_ADDR);
+
+
+  if(flags==FLAG_BLANK){// Buffer is in a blank state:
+    // write first write flag to address 0x000
+    EEPROM.write(FLAG_ADDR,FLAG_FIRST_WRITE);
+    eeprom_state=FLAG_FIRST_WRITE;
+    // set writepos to next address
+    ++writePos;
+
+  } else if(flags==FLAG_FIRST_WRITE) {// Buffer has been written to previously, but not terminated correctly
+    EEPROM.write(FLAG_ADDR,FLAG_ADDITIONAL_WRITE);
+    eeprom_state=FLAG_ADDITIONAL_WRITE;
+    // start reading from the back and search for first byte !=0x00
+    for(uint16_t i=0x398;i>PRESS_ADDR+sizeof(float);--i){
+      if(EEPROM.read(i)!=0x00){//When found
+        // set write position to next address
+        writePos=i+1;
+        // write code 0xF0 (240)
+        EEPROM.write(writePos,0xF0);
+        // move writepos to next address
+        ++writePos;
+        break;
+      }
+    }
+
+  } else if(flags==FLAG_COMPLETED){// Buffer has been written to and terminated successfully
+    Serial.println("EEPROM has been written to successfully and hasn't yest been unloaded. Aborting.");
+    uint16_t longt=400;
+    uint16_t shortt=100;
+    while(true){
+      digitalWrite(LED_BUILTIN, HIGH);
+      delay(shortt);
+      digitalWrite(LED_BUILTIN, LOW);
+      delay(shortt);
+      digitalWrite(LED_BUILTIN, HIGH);
+      delay(shortt);
+      digitalWrite(LED_BUILTIN, LOW);
+      delay(longt);
+    }
+  }
+
+
+  // Initialize atmospheric sensor and height
+
+  Serial.println("Pressure Sensor Test");
+  sensorStatus=bmp.begin();
+
+  if(!sensorStatus){
+    Serial.println("BMP180 Sensor not detected. Aborting.");
+    uint16_t longt=400;
+    uint16_t shortt=100;
+    while(true){
+      digitalWrite(LED_BUILTIN, HIGH);
+      delay(longt);
+      digitalWrite(LED_BUILTIN, LOW);
+      delay(longt);
+      digitalWrite(LED_BUILTIN, HIGH);
+      delay(shortt);
+      digitalWrite(LED_BUILTIN, LOW);
+      delay(longt);
+    }
+
+  } else {
+    if(eeprom_state==FLAG_FIRST_WRITE){
+      sensors_event_t event;
+      bmp.getEvent(&event);
+      while(!event.pressure){
+        bmp.getEvent(&event);
+      }
+      Serial.println("Pressure event detected.");
+
+      baseLevelPressure=event.pressure;
+      EEPROM.put(PRESS_ADDR,baseLevelPressure);
+      Serial.print("Pressure:  ");
+      Serial.println(baseLevelPressure);
+
+    } else if(eeprom_state==FLAG_ADDITIONAL_WRITE) {
+      Serial.println("Getting pressure value from eeprom");
+      EEPROM.get(PRESS_ADDR,baseLevelPressure);
+      Serial.print("Pressure:  ");
+      Serial.println(baseLevelPressure);
+    }
+
+  }
+
+
+
+  // Initialize actuators
+
+}
+
+void loop() {
+
+  digitalWrite(LED_BUILTIN, HIGH);
+  // put your main code here, to run repeatedly:
+
+}


Added a real time clock to the CAN logger

Adapted the Teensy Examples to ad RTC. Also uses an elapsedMillis
construct to get milliseconds per second.

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

--- _03_Add_RealtimeClock/_03_Add_RealtimeClock.ino
+++ _03_Add_RealtimeClock/_03_Add_RealtimeClock.ino
@@ -0,0 +1,138 @@
+//Reading data from CAN and displaying it on a serial port
+//Include the realtime clock functions inspired by the TimeTeensy3.ino example
+
+//Include the CAN libraries for the Teensy microprocessor
+#include <FlexCAN.h>
+#include <TimeLib.h>
+
+//Declare which pin is connected to the LED
+//Use the Teensy Reference Card and the board schematics to determine the pin number
+const int redLEDpin = 21;
+
+//initiate the CAN library at 250kbps
+FlexCAN CANbus(250000);
+
+//Set up the CAN data structure
+static CAN_message_t rxmsg;
+
+//set up a counter for each received message
+unsigned long int rxCount = 0;
+
+//set up a timer to toggle the LEDs so the delay function isn't needed.
+elapsedMillis LEDtoggleTimer;
+elapsedMillis millisecondsPerSecond;
+
+
+//Keep track of the LED state
+boolean ledState = true;
+
+//set up a variable to keep track of the timestamp
+time_t previousTime = 0;
+
+void setup() {
+  // put your setup code here, to run once:
+
+  // set the Time library to use Teensy 3.0's RTC to keep time
+  setSyncProvider(getTeensy3Time);
+
+  //declare the LED Pin to be the output
+  pinMode(redLEDpin,OUTPUT);
+  digitalWrite(redLEDpin,ledState); //Turn on the LED
+
+  //start the CAN access
+  CANbus.begin();
+  rxmsg.timeout = 0;
+
+  //try to wait for the Serial bus to come up for 1 second
+  delay(1000);
+  Serial.println(F("Teensy 3.2 CAN Receive Test."));
+
+  //Set System Time
+  if (timeStatus()!= timeSet) {
+    Serial.println(F("Unable to sync with the RTC"));
+  }
+  else {
+    Serial.println(F("RTC has set the system time"));
+  }
+
+  //print a header
+  Serial.print(F("Count\tuSec\tYYYY-MM-DD HH:MM:SS.milli\tID\tDLC"));
+  for (uint8_t i = 1; i<9;i++){ //label the byte columns according to J1939
+    char byteDigits[4]; //declare a byte display array
+    sprintf(byteDigits,"\tB%i",i);
+    Serial.print(byteDigits);
+  }
+
+  //before entering the loop, set the previous time
+  previousTime = now();
+  //synchronize the millisecondPerSecond timer
+  while (now() - previousTime < 1){
+    millisecondsPerSecond = 0;
+  }
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+
+  //check to see if the number of seconds has changed to reset the millisecond timer for each second
+  if (now() - previousTime == 1){
+    previousTime = now();
+    millisecondsPerSecond = 0;
+  }
+
+  // Uncomment this to synchronize the RTC to your PC time.
+  /*  if (Serial.available()) {
+      time_t t = processSyncMessage();
+      if (t != 0) {
+        Teensy3Clock.set(t); // set the RTC
+        setTime(t);
+      }
+    }
+  */
+
+  while(CANbus.read(rxmsg)){
+    rxCount++;
+
+    uint32_t ID = rxmsg.id;
+    uint8_t len = rxmsg.len;
+
+    char timeCountIDandDLCdigits[50];
+    sprintf(timeCountIDandDLCdigits,"%10i\t%10i\t%04i-%02i-%02iT%02i:%02i:%02i.%03i\t%08X\t%1i",rxCount,micros(),year(),month(),day(),hour(),minute(),second(),int(millisecondsPerSecond),ID,len);
+    Serial.print(timeCountIDandDLCdigits);
+
+    for (uint8_t i = 0; i<len;i++){
+      char byteDigits[4];
+      sprintf(byteDigits,"\t%02X",rxmsg.buf[i]);
+      Serial.print(byteDigits);
+    }
+    Serial.println();
+  }
+
+  if (LEDtoggleTimer >=100){
+    LEDtoggleTimer = 0; //reset the timer
+    ledState = !ledState; // Toggle values
+    digitalWrite(redLEDpin,ledState);
+  }
+
+}
+
+time_t getTeensy3Time(){
+  return Teensy3Clock.get();
+}
+
+
+
+/*  code to process time sync messages from the serial port   */
+unsigned long processSyncMessage() {
+  unsigned long pctime = 0L;
+  const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013
+
+  if(Serial.find("T")) {
+     pctime = Serial.parseInt();
+     return pctime;
+     if( pctime < DEFAULT_TIME) { // check the value is a valid time (greater than Jan 1 2013)
+       pctime = 0L; // return 0 to indicate that the time is not valid
+     }
+  }
+  return pctime;
+}


Support for cosmos

Support for cosmos

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

--- RealGame/cosmos.ino
+++ RealGame/cosmos.ino
@@ -0,0 +1,29 @@
+int leds[][2] = {
+                {A0, D0},
+                {A1, D1},
+                {A2, D2}
+                };
+int prevIndex = 0;
+
+void lightRandom();
+
+void setup() {
+  for(int i = 0; i < 3; i ++)
+  {
+    pinMode(leds[i][0], OUTPUT);
+    pinMode(leds[i][1], OUTPUT);
+  }
+}
+
+void loop() {
+  lightRandom();
+  delay(5000);
+}
+
+void lightRandom() {
+  digitalWrite(leds[prevIndex][0], LOW);
+  digitalWrite(leds[prevIndex][1], LOW);
+  prevIndex = random(3);
+  digitalWrite(leds[prevIndex][0], HIGH);
+  digitalWrite(leds[prevIndex][1], HIGH);
+}


Initial code import, button box

Initial code import, button box

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

--- button_box/button_box.ino
+++ button_box/button_box.ino
@@ -0,0 +1,52 @@
+#define WHITE 5
+#define RED 6
+#define ID0 12
+#define ID1 13
+#define BUTTON_WHITE 0
+#define BUTTON_RED 1
+
+uint8_t white = 0, red = 0, white_state = 0, red_state = 0;
+uint8_t id = 0;
+
+
+void setup () {
+	Serial.begin(9600);
+	pinMode(WHITE, INPUT);
+	pinMode(RED, INPUT);
+	pinMode(ID0, INPUT);
+	pinMode(ID1, INPUT);
+	id += digitalRead(ID0);
+	id += digitalRead(ID1);
+	Serial.println("[Button Box]");
+	Serial.print("[ID: ");
+	Serial.print(id);
+	Serial.println("]");
+}
+
+void loop () {
+	white = digitalRead(WHITE);
+	red = digitalRead(RED);
+	if(white == LOW && white_state == 0) {
+		white_state = 1;
+		txButton(BUTTON_WHITE);
+		delay(200);
+	}
+	else if(white == HIGH && white_state == 1) {
+		white_state = 0;
+	}
+	if(red == LOW && red_state == 0) {
+		red_state = 1;
+		txButton(BUTTON_RED);
+		delay(200);
+	}
+	else if(red == HIGH && red_state == 1) {
+		red_state = 0;
+	}
+	delay(50);
+}
+
+void txButton(uint8_t button) {
+	Serial.print("#"); Serial.print(id); Serial.print(":");
+	Serial.print(button);
+	Serial.println(";");
+}


updated heater pins for heat control

updated heater pins for heat control

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


added thermistor prototype code

added thermistor prototype code

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

--- scratch/thermistor/thermistor.ino
+++ scratch/thermistor/thermistor.ino
@@ -0,0 +1,65 @@
+#include <LiquidCrystal.h>
+#define TP 2      //Trig_pin
+LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
+
+int thermister_temp(int aval) {
+	double R, T;
+
+	// These were calculated from the thermister data sheet
+	//	A = 2.3067434E-4;
+	//	B = 2.3696596E-4;
+	//	C = 1.2636414E-7;
+	//
+	// This is the value of the other half of the voltage divider
+	//	Rknown = 22200;
+
+	// Do the log once so as not to do it 4 times in the equation
+	//	R = log(((1024/(double)aval)-1)*(double)22200);
+	R = log((1 / ((1024 / (double) aval) - 1)) * (double) 1014000);
+	//lcd.print("A="); lcd.print(aval); lcd.print(" R="); lcd.print(R);
+	// Compute degrees C
+	T = (1 / ((4.717016E-4) + (1.90988E-4) * R + (9.955908E-8) * R * R * R)) - 273.25;
+	// return degrees F
+	return ((int) ((T * 9.0) / 5.0 + 32.0));
+}
+
+void CelsiusToFarenheit(float const tCel, float &tFar) {
+	tFar = tCel * 1.8 + 32;
+}
+void setup() {
+  lcd.clear();
+  lcd.begin(16, 2);
+  lcd.setCursor(0,0);
+  Serial.begin(9600);      // open the serial port at 9600 bps:
+  pinMode(TP,OUTPUT);       // set TP output for trigger
+}
+
+void loop() {
+    unsigned int signal = 0;
+    unsigned int pit_temp = 0;
+    signal = analogRead(1);
+    pit_temp = thermister_temp(signal);
+    Serial.print("Temp: ");
+    Serial.print(pit_temp);
+    Serial.print(", Signal: ");
+    Serial.print(signal);
+    Serial.println("");
+    lcd.setCursor(0,0);
+    lcd.print("Pit: ");
+    lcd.print(pit_temp);
+    lcd.print("deg");
+    lcd.setCursor(0,1);
+    lcd.print("Fan: ");
+
+    if(pit_temp > 82){
+      digitalWrite(TP,HIGH);
+      lcd.print("ON ");
+    }
+    else {
+      digitalWrite(TP,LOW);
+      lcd.print("OFF");
+    }
+    Serial.println(digitalRead(2));
+    delay(1000);
+}
+


Added SimplePID example for the A-Star controller.

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

--- examples/AStarPIDTest/AStarPIDTest.ino
+++ examples/AStarPIDTest/AStarPIDTest.ino
@@ -0,0 +1,283 @@
+// AStarPIDTest - Test the PID control for an AStar-based robot.
+//
+// To gather PID tuning data for graphing, put the robot on blocks, then
+// start this program and open a Serial Monitor. Press S4 to start both
+// motors, let them come to a steady speed, then press S4 to stop the
+// motors. Copy the Serial output to a spreadsheet and plot target speed and
+// current speed versus time. You should see a classic PID controller graph
+// with some overshoot.
+
+#include <AStar32U4.h>
+#include <EnableInterrupt.h>
+#include <SimplePID.h>
+
+// Motor parameters. These are based on a Pololu #2285 motor with 48cpr
+// encoder.
+const float GEAR_RATIO = 210.59;
+const float ENCODER_CPR = 12;
+
+// Number of encoder ticks per revolution of the wheel.
+const float TICKS_PER_REV = GEAR_RATIO * ENCODER_CPR;
+
+// Maximum desired motor speed. Pololu #2285 are rated for 130rpm, but we
+// don't drive them with enough voltage to achieve that.
+const float MAX_REVS_PER_SEC = 100.0 / 60.0;
+
+// Use 60% of maximum speed for PID tuning.
+const int PID_TUNING_TICKS_PER_SEC = 0.6 * MAX_REVS_PER_SEC * TICKS_PER_REV;
+
+// DFRobot Romeo v2 and BLE PIN assignments.
+
+const int ONBOARD_SWITCH_PIN = A7;
+
+// Pins for the Pololu motor encoder outputs.
+const int M1_A = 7;
+const int M1_B = 11;
+const int M2_A = 15;
+const int M2_B = 16;
+
+// Minimum motor control value. Motor output below this will stall.
+const int MIN_MOTOR_CMD = 10;
+
+// Maximum motor control value.
+const int MAX_MOTOR_CMD = 400;
+
+AStar32U4Motors motors;
+
+// These objects provide access to the A-Star's on-board
+// buttons.  We will only use buttonA.
+AStar32U4ButtonA buttonA;
+AStar32U4ButtonB buttonB;
+AStar32U4ButtonC buttonC;
+
+enum { NO_BUTTON, BUTTON_A, BUTTON_B, BUTTON_C };
+
+int leftSpeedTarget = 0;
+int rightSpeedTarget = 0;
+
+volatile long leftTicks;
+volatile long rightTicks;
+
+long lastLeftTicks = 0;
+long lastRightTicks = 0;
+
+int leftMotorCmd = 0;
+int rightMotorCmd = 0;
+
+unsigned long lastLoopTime;
+
+unsigned long lastSwitchTime;
+
+float loopTime = 0.0;
+
+// Ziegler-Nichols tuning. See this Wikipedia article for details:
+//     https://en.wikipedia.org/wiki/PID_controller#Loop_tuning
+// To tune the controller, set USE_KU_ONLY to 1 and increase Ku
+// until oscillation occurs, and set Tu to the oscillation period
+// in seconds. Then set USE_KU_ONLY to zero to use the
+// Ziegler-Nichols tune. To get a less agressive tune, set LESS_AGGRESSIVE
+// to 1.
+
+// Set to 1 to use Ku only, to determine oscillation point.
+#define USE_KU_ONLY 0
+
+const float Ku = .15;
+const float Tu = .1142857143;
+
+#define LESS_AGGRESSIVE 0
+
+#if !LESS_AGGRESSIVE
+const float Kp = 0.6*Ku;
+const float Ki = 2*Kp/Tu;
+const float Kd = Kp*Tu/8;
+#else
+const float Kp = 0.2*Ku;
+const float Ki = 2*Kp/Tu;
+const float Kd = Kp*Tu/3;
+#endif
+
+#if USE_KU_ONLY
+SimplePID leftController = SimplePID(Ku, 0, 0);
+SimplePID rightController = SimplePID(Ku, 0, 0);
+#else
+SimplePID leftController = SimplePID(Kp, Ki, Kd);
+SimplePID rightController = SimplePID(Kp, Ki, Kd);
+#endif
+
+// Sets up the serial output and the motor control pins, and attaches
+// interrupt handlers to the pins on which we will read the encoder
+// phototransistor values.
+void setup() {
+  Serial.begin(115200);
+  delay(3000);
+
+  enableInterrupt(M1_A, leftAChange, CHANGE);
+  enableInterrupt(M1_B, leftBChange, CHANGE);
+  enableInterrupt(M2_A, rightAChange, CHANGE);
+  enableInterrupt(M2_B, rightBChange, CHANGE);
+
+  Serial.print("Time (s)\tLeft Target\tLeft Speed\tLeft Cum Error\tLeft Motor");
+  Serial.print("\tRight Target\tRight Speed\tRight Cum Error\tRight Motor");
+  Serial.println();
+
+  lastLoopTime = micros();
+  lastSwitchTime = millis();
+
+  leftTicks = rightTicks = 0;
+}
+
+// Loops forever showing the motor speeds and errors since the last loop,
+// and adjusts the target speeds depending on whether the user is pressing
+// switches S2 through S5, as indicated in the code below.
+void loop() {
+  delay(15);
+
+  unsigned long curLoopTime = micros();
+  noInterrupts();
+  long curLeftTicks = leftTicks;
+  long curRightTicks = rightTicks;
+  interrupts();
+
+  float dt = (curLoopTime - lastLoopTime) / 1E6;
+
+  float leftSpeed = (curLeftTicks - lastLeftTicks) / dt;
+  float rightSpeed = (curRightTicks - lastRightTicks) / dt;
+
+  int leftControl = leftController.getControlValue(leftSpeed, dt);
+  leftMotorCmd += min(MAX_MOTOR_CMD, leftControl);
+  leftMotorCmd = constrain(leftMotorCmd, -MAX_MOTOR_CMD, MAX_MOTOR_CMD);
+  if (leftMotorCmd > 0) {
+    leftMotorCmd = max(leftMotorCmd, MIN_MOTOR_CMD);
+  }
+
+  int rightControl = rightController.getControlValue(rightSpeed, dt);
+  rightMotorCmd += min(MAX_MOTOR_CMD, rightControl);
+  rightMotorCmd = constrain(rightMotorCmd, -MAX_MOTOR_CMD, MAX_MOTOR_CMD);
+  if (rightMotorCmd > 0) {
+    rightMotorCmd = max(rightMotorCmd, MIN_MOTOR_CMD);
+  }
+
+  // Coast to a stop if target is zero.
+  if (leftSpeedTarget == 0) {
+    leftMotorCmd = 0;
+  }
+  if (rightSpeedTarget == 0) {
+    rightMotorCmd = 0;
+  }
+
+  setSpeed(leftMotorCmd, rightMotorCmd);
+
+  if (leftSpeedTarget > 0 || leftSpeed > 0 || rightSpeedTarget > 0 || rightSpeed > 0) {
+    Serial.print(loopTime, 3);
+    Serial.print("\t");
+    Serial.print(leftSpeedTarget);
+    Serial.print("\t");
+    Serial.print(leftSpeed);
+    Serial.print("\t");
+    Serial.print(leftController.getCumulativeError());
+    Serial.print("\t");
+    Serial.print(leftMotorCmd);
+    Serial.print("\t");
+
+    Serial.print(rightSpeedTarget);
+    Serial.print("\t");
+    Serial.print(rightSpeed);
+    Serial.print("\t");
+    Serial.print(rightController.getCumulativeError());
+    Serial.print("\t");
+    Serial.print(rightMotorCmd);
+    Serial.print("\t");
+
+    Serial.println();
+
+    loopTime += dt;
+}
+
+  // Ignore switches for a short time after pressing, to avoid bounce.
+  if (curLoopTime - lastSwitchTime > 0.5*1E6) {
+    int switchValue = readSwitch();
+    if (switchValue > 0) {
+      lastSwitchTime = curLoopTime;
+
+      switch (switchValue) {
+        case BUTTON_A:
+          // Left motor on/off.
+          leftSpeedTarget = (leftSpeedTarget==0 ? PID_TUNING_TICKS_PER_SEC : 0);
+          break;
+        case BUTTON_B:
+          // Right motor on/off.
+          rightSpeedTarget = (rightSpeedTarget==0 ? PID_TUNING_TICKS_PER_SEC : 0);
+          break;
+        case BUTTON_C:
+          // Both motors on/off.
+          leftSpeedTarget = (leftSpeedTarget==0 ? PID_TUNING_TICKS_PER_SEC : 0);
+          rightSpeedTarget = (rightSpeedTarget==0 ? PID_TUNING_TICKS_PER_SEC : 0);
+          break;
+        default:
+          // no change in speed
+          break;
+      }
+
+      leftController.setSetPoint(leftSpeedTarget);
+      rightController.setSetPoint(rightSpeedTarget);
+    }
+  }
+
+  lastLeftTicks = curLeftTicks;
+  lastRightTicks = curRightTicks;
+  lastLoopTime = curLoopTime;
+}
+
+void waitForSwitch1() {
+  while (readSwitch() != 1) {
+    // do nothing
+  }
+}
+
+void setSpeed(int leftSpeed, int rightSpeed) {
+  motors.setSpeeds(leftSpeed, rightSpeed);
+}
+
+void leftAChange() {
+  if (digitalRead(M1_A) == digitalRead(M1_B)) {
+    ++leftTicks;
+  } else {
+    --leftTicks;
+  }
+}
+
+void leftBChange() {
+  if (digitalRead(M1_A) != digitalRead(M1_B)) {
+    ++leftTicks;
+  } else {
+    --leftTicks;
+  }
+}
+
+void rightAChange() {
+  if (digitalRead(M2_A) != digitalRead(M2_B)) {
+    ++rightTicks;
+  } else {
+    --rightTicks;
+  }
+}
+
+void rightBChange() {
+  if (digitalRead(M2_A) == digitalRead(M2_B)) {
+    ++rightTicks;
+  } else {
+    --rightTicks;
+  }
+}
+
+int readSwitch() {
+  if (buttonA.getSingleDebouncedRelease()) {
+    return BUTTON_A;
+  } else if (buttonB.getSingleDebouncedRelease()) {
+    return BUTTON_B;
+  } else if (buttonC.getSingleDebouncedRelease()) {
+    return BUTTON_C;
+  } else {
+    return 0;
+  }
+}


code of photon particle.io

code of photon particle.io

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

--- cuckoo_photon.ino
+++ cuckoo_photon.ino
@@ -0,0 +1,223 @@
+// This #include statement was automatically added by the Particle IDE.
+#include "SparkTime/SparkTime.h"
+#include <climits>
+#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
+#define bitSet(value, bit) ((value) |= (1UL << (bit)))
+#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
+#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
+#define bit(b) (1UL << (b))
+
+#define PI 3.1415926535897932384626433832795
+#define HALF_PI 1.5707963267948966192313216916398
+#define TWO_PI 6.283185307179586476925286766559
+#define DEG_TO_RAD 0.017453292519943295769236907684886
+#define RAD_TO_DEG 57.295779513082320876798154814105
+typedef uint16_t word;
+#define abs(x) ((x)>0?(x):-(x))
+#define radians(deg) ((deg)*DEG_TO_RAD)
+#define degrees(rad) ((rad)*RAD_TO_DEG)
+#define sq(x) ((x)*(x))
+
+#define lowByte(w) ((uint8_t) ((w) & 0xff))
+#define highByte(w) ((uint8_t) ((w) >> 8))
+UDP UDPClient;
+SparkTime rtc;
+
+unsigned long currentTime;
+unsigned long lastTime = 0UL;
+String timeStr;
+const byte numPins = 8;
+byte pins[] = {0,1,2,3,4,5,6,7};
+
+bool alarmOnceSet = false;
+short alarmHour = 0;
+short alarmMinute = 0;
+bool timeOnceSet = false;
+short lastFPGAState = 0xf;
+bool internetOnceConnected = false;
+
+void setup() {
+    Particle.publish("devStatus", "Device ON - Cuckoo MODE");
+
+    //internet time sync
+    rtc.begin(&UDPClient, "north-america.pool.ntp.org");
+    rtc.setTimeZone(6); // gmt offset
+
+
+
+    //set pin D0-D7 to be output
+    for(int i=0;i<numPins;i++){
+        pinMode(i, OUTPUT);
+    }
+
+    //set pin A0-A3 to be input
+    for(int i=10;i<14;i++){
+        pinMode(i, INPUT);
+    }
+    setIdleStateOnFPGA();
+
+    //set debug LED
+    pinMode(A4, OUTPUT); //FGPA Programmed?
+    pinMode(A5, OUTPUT); //internet?
+
+    delay(1000);
+    reportState();
+}
+
+void loop() {
+    if(lastFPGAState != 0xf){
+        if(timeOnceSet == true){
+            //check if an hour already
+        }else{
+            setTimeOnFPGA();
+        }
+    }
+    delay(1000*5);
+    reportState();
+}
+
+void checkInternet(){
+    if(internetOnceConnected = WiFi.ready())digitalWrite(A5, HIGH);
+    else digitalWrite(A5, LOW);
+}
+
+void reportState(){
+    checkInternet();
+    short state = 0;
+    for(int i=0;i<4;i++){
+        bitWrite(state, i, digitalRead(10+i));
+    }
+    digitalWrite(A4,LOW);
+    switch (state) {
+        case 0: Particle.publish("fpgaStatus", "normal"); break;
+        case 1: Particle.publish("fpgaStatus", "never Set Clock"); break;
+        case 2: Particle.publish("fpgaStatus", "never Set Alarm"); break;
+        case 3: Particle.publish("fpgaStatus", "ringing"); break;
+        case 0xf: Particle.publish("fpgaStatus", "fpga is on but unprogramed"); digitalWrite(A4,HIGH); break;
+        default: break;
+    }
+    lastFPGAState = state ;
+}
+
+void setIdleStateOnFPGA(){
+    setOpPins(0x0);
+    setDataPins(0);
+}
+
+void setTimeOnFPGA(){
+    Particle.publish("debug", "run setTimeOnFPGA");
+    currentTime = rtc.now();
+
+    short hour =  rtc.hour(currentTime);
+    short hour_ = hour/10;
+    short hour__ = hour-hour_*10;
+    setOpPins(0xe);
+    setDataPins(hour__);
+    delay(50);
+    setOpPins(0xf);
+    setDataPins(hour_);
+    delay(50);
+
+    short min =  rtc.minute(currentTime);
+    short min_ = min/10;
+    short min__ = min-min_*10;
+    setOpPins(0xc);
+    setDataPins(min_);
+    delay(50);
+    setOpPins(0xd);
+    setDataPins(min__);
+    delay(50);
+
+    short second =  rtc.second(currentTime);
+    short second_ = second/10;
+    short second__ = second-second_*10;
+    setOpPins(0xa);
+    setDataPins(second_);
+    delay(50);
+    setOpPins(0xb);
+    setDataPins(second__);
+    delay(50);
+    Particle.publish("Debug", "Clock is seted at"+rtc.ISODateString(currentTime));
+}
+
+void setAlarmOnFPGA(short hour,short min){
+    short hour_ = hour/10;
+    short hour__ = hour-hour_*10;
+    setOpPins(0x6);
+    setDataPins(hour__);
+    delay(5);
+    setOpPins(0x7);
+    setDataPins(hour_);
+    delay(5);
+
+    short min_ = min/10;
+    short min__ = min-min_*10;
+    setOpPins(0x4);
+    setDataPins(min_);
+    delay(5);
+    setOpPins(0x5);
+    setDataPins(min__);
+    delay(5);
+
+    timeStr = "";
+    timeStr += rtc.hour12String(currentTime);
+    timeStr += ":";
+    timeStr += rtc.minuteString(currentTime);
+    timeStr += ":";
+    timeStr += rtc.secondString(currentTime);
+    timeStr += " ";
+    timeStr += rtc.AMPMString(currentTime);
+    Particle.publish("info", timeStr);
+    Particle.publish("Debug", "Clock is seted at"+rtc.ISODateString(currentTime)+"  "+timeStr);
+}
+
+/*function to set pin D0-D3 to desire byte*/
+void setOpPins(byte data){
+    for(int i=0;i<4;i++){
+        byte state = bitRead(data, i);
+        digitalWrite(pins[i], state);
+    }
+}
+/*function to set pin D4-D7 to desire number*/
+void setDataPins(byte data){
+    for(int i=4;i<8;i++){
+        byte state = bitRead(data, i);
+        digitalWrite(pins[i], state);
+    }
+}
+
+
+void publishTime(){
+    currentTime = rtc.now();
+    if (currentTime != lastTime) {
+        byte sec = rtc.second(currentTime);
+        if (sec == 10) {
+        	// Build Date String
+        	timeStr = "";
+        	timeStr += rtc.dayOfWeekString(currentTime);
+        	timeStr += ", ";
+        	timeStr += rtc.monthNameString(currentTime);
+        	timeStr += " ";
+        	timeStr += rtc.dayString(currentTime);
+        	timeStr += ", ";
+        	timeStr += rtc.yearString(currentTime);
+        	Particle.publish("info", timeStr);
+        } else if (sec == 40) {
+    	    // Including current timezone
+    	    Particle.publish("info", rtc.ISODateString(currentTime));
+    	    //Serial.println(rtc.ISODateString(currentTime));
+        } else {
+        	// Just the time in 12 hour format
+        	timeStr = "";
+        	timeStr += rtc.hour12String(currentTime);
+        	timeStr += ":";
+        	timeStr += rtc.minuteString(currentTime);
+        	timeStr += ":";
+        	timeStr += rtc.secondString(currentTime);
+        	timeStr += " ";
+        	timeStr += rtc.AMPMString(currentTime);
+        	Particle.publish("info", timeStr);
+        }
+        lastTime = currentTime;
+    }
+}


Update Titan16_3DOF.ino

Update Titan16_3DOF.ino

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


Expand colour bar test from Ucg Graphicstest

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