new way to handle movement instructions and some debugging

/*
SharpDistSensorBasic.ino
Source: https://github.com/DrGFreeman/SharpDistSensor
MIT License
Copyright (c) 2017 Julien de la Bruere-Terreault <drgfreeman@tuta.io>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

/*
This example shows how to use the SharpDistSensor library to continuously
read the sensor and display the analog value and the corrseponding distance
in mm.
The library default values corresponding to the Sharp GP2Y0A60SZLF 5V sensor
are used.
See the library README for how to use pre-defined sensor models or custom
fit functions.
*/

#include <SharpDistSensor.h>

// Analog pin to which the sensor is connected
const byte sensorPin = A0; //right IR sensor
const byte sensorPin2 = A1; //left IR sensor
const byte backleft = A6; //back-left line sensor
const byte backright = A7; //back-right line sensor
const byte frontright = A2; //front-left line sensor
const byte frontleft = A3; //front-right line sensor
const byte sensorPin4 = A4; //A4: left peripheral sensor
const byte sensorPin3 = A5;//A5: right peripheral sensor

// Window size of the median filter (odd number, 1 = no filtering)
const byte mediumFilterWindowSize = 5;
int rightDist; //distance from right sensor
int leftDist; //distance from left sensor
int perRightDist; //distance from peripheral right sensor
int perLeftDist; //distance from peripheral left sensor

// Create an object instance of the SharpDistSensor class
SharpDistSensor sensor(sensorPin, mediumFilterWindowSize); //right sensor
SharpDistSensor sensor2(sensorPin2, mediumFilterWindowSize); //left sensor
SharpDistSensor sideright(sensorPin3, mediumFilterWindowSize); //right peripheral sensor
SharpDistSensor sideleft(sensorPin4, mediumFilterWindowSize); //left peripheral sensor
int STBY = 10; //standby

//Right Motor (? I'm not too sure about this)
int PWMA = 3; //Speed control
int AIN1 = 9; //Direction
int AIN2 = 8; //Direction

//Left Motor (? also not too sure about this)
int PWMB = 5; //Speed control
int BIN1 = 11; //Direction
int BIN2 = 12; //Direction

char past; //what direction the robot was moving previously
int count; //counter for how long before the rebot gives up searching in one direction
int threshold; //threshold for line sensors
int prevIR;
int cur;
int prevFlag;
int prevLine;
short iter;
int state;
int rangeThresh;
boolean start;
int lineFlag;
boolean pivotFlag;

int near = 200;
int far = 500;
int degreesMin = 20;
int degrees90 = 50;
int degrees180 = 100;
int dist = 150;
int maxS = 128;
int minS = 20;
int startSpinR = 1000;
int startTurnL = 2000;
int startSpinL = 1000;
int pivotBack = 500;
int pivotSpinR = 1000;
int pivotTurnL = 1000;
int pivotSpinL = 1000;

void setup() {
  Serial.begin(9600);
  pinMode(STBY, OUTPUT);

  pinMode(PWMA, OUTPUT);
  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);

  pinMode(PWMB, OUTPUT);
  pinMode(BIN1, OUTPUT);
  pinMode(BIN2, OUTPUT);

  //initialising values
  past = 'f'; //set default move to forward
  start = true; //set startup flag
  count = 0;
  iter = 0;
  threshold = analogRead(backleft) - 200;
  rightDist = sensor.getDist();
  leftDist = sensor2.getDist();
  perRightDist = sideright.getDist();
  perLeftDist = sideleft.getDist();
  prevLine = millis();
  prevIR = prevLine;
  lineFlag = 0;
  pivotFlag = true;
  prevFlag = prevLine;
  state = 11;
}

void loop() {
  cur = millis();
  movement(state);

  //print out values from sensors and motors to the console
  Serial.print(past);
  Serial.print(", ");
  Serial.print(rightDist);
  Serial.print(", ");
  Serial.print(leftDist);
  Serial.print(", ");
  Serial.print(perRightDist);
  Serial.print(", ");
  Serial.print(perLeftDist);
  Serial.print(", ");
  Serial.print(analogRead(backleft));
  Serial.print(", ");
  Serial.print(analogRead(backright));
  Serial.print(", ");
  Serial.print(analogRead(frontleft));
  Serial.print(", ");
  Serial.println(analogRead(frontright));
  Serial.print(", ");
  Serial.println(cur - prevLine);

  if ((cur - prevLine) >= 5) {
    prevLine = cur;
    if (analogRead(backleft) < threshold || analogRead(backright) < threshold && lineFlag != 1) { //first read from line sensors before doing anything else
      //if line detected by back line sensors, turn left a bit
      state = 0;
      lineFlag = 1;
      prevFlag = cur;
      pivotFlag = false;
    } else if (analogRead(frontleft) < threshold && past == 'l' && lineFlag != 2) {
      state = 6;
      lineFlag = 2;
      prevFlag = cur;
      pivotFlag = false;
    } else if (analogRead(frontleft) < threshold && past == 'r' || analogRead(frontleft) < threshold && past == 'f' && lineFlag != 3) {
      state = 7;
      lineFlag = 3;
      prevFlag = cur;
      pivotFlag = false;
    } else if (analogRead(frontright) < threshold && past == 'l' && lineFlag != 4) {
      state = 8;
      lineFlag = 4;
      prevFlag = cur;
      pivotFlag = false;
    } else if (analogRead(frontright) < threshold && past == 'r' || analogRead(frontright) < threshold && past == 'f' && lineFlag != 5) {
      state = 9;
      lineFlag = 5;
      prevFlag = cur;
      pivotFlag = false;
    } else if (analogRead(frontright) < threshold && analogRead(frontleft) < threshold && lineFlag != 6) {
      state = 10;
      lineFlag = 6;
      prevFlag = cur;
      pivotFlag = false;
    } else if ((cur - prevIR) >= 25) {
      prevIR = cur;
      // Get distance from sensors
      rightDist = sensor.getDist();
      leftDist = sensor2.getDist();
      perRightDist = sideright.getDist();
      perLeftDist = sideleft.getDist();

      //attack code with sensors

      if (!pivotFlag) {
        //other attack cases

        if (perLeftDist <= near) {
          //if there is an object within nearmm of the left peripheral sensor, move left
          //turn left in place
          state = 4;
          past = 'l'; //set past movement to left
          count = 0; //reset abandon search count because the robot has found an object
        } else if (perRightDist <= near) {
          //if there is an object within nearmm of the right peripheral sensor, move right
          //turn right in place
          state = 5;
          past = 'r'; //set past movement to left
          count = 0; //reset abandon search count because the robot has found an object
        } else if (perRightDist <= near && perLeftDist <= near) {
          //if there is an object within nearmm of both peripheral sensors, move forward
          state = 0;
          past = 'f'; //set past movement to left
          count = 0; //reset abandon search count because the robot has found an object
        } else if (lineFlag == 0) {
          if ((abs(rightDist - leftDist) <= 150)
                || ((past == 'f' || count >= 100) && (rightDist > far && leftDist > far && perRightDist > far && perLeftDist > far))) {
            //if (robot moved forward in the past OR it's been searching for 100 iterations) AND (there isn't an object within far of any IR sensor))
            //OR there is an object within near of both sensors
            //OR the difference between the two distances measured by the IR sensors is within 150mm of each other
            //move forward
            state = 0;
            past = 'f'; //set past movement to forward
            count = 0; //reset abandon search count
          } else if ((leftDist <= far || perLeftDist <= far) || leftDist - rightDist < -dist) {
            //if there is an object beyond farmm of the right sensors (i.e. there is something closer in the left sensors), move left
            state = 2;
            past = 'l'; //set past movement to left
            count = 0; //reset abandon search count because the robot has found an object
          } else if ((rightDist <= far || perRightDist <= far) || leftDist - rightDist > dist) {
            //if there is an object beyond farmm of the left sensors (i.e. there is something closer in the right sensors), move right
            state = 3;
            past = 'r'; //set past movement to right
            count = 0; //reset abandon search count because the robot has found an object
          } else if (past == 'l') {
            //if robot has been moving left in the past, move left more
            state = 2;
            past = 'l'; //set past movement to left
            count++; //increment abandon search count
          } else if (past == 'r') {
            //if robot has been moving right in the past, move right
            state = 3;
            past = 'r'; //set past movement to right
            count++; //increment abandon search count
          }
        }

//        } else if (past == 'l' && (rightDist > far && leftDist > far && perRightDist > far && perLeftDist > far)) {
//          //if robot has been moving left in the past, move left more
//          left();
//          past = 'l'; //set past movement to left
//          count++; //increment abandon search count
//        } else if (past == 'r' && (rightDist > far && leftDist > far && perRightDist > far && perLeftDist > far)) {
//          //if robot has been moving right in the past, move right
//          right();
//          past = 'r'; //set past movement to right
//          count++; //increment abandon search count
//        }
      }
    }
  }
}

void move(int motor, int speed, int direction){
  //Move specific motor at speed and direction
  //motor: 1 for right, 2 for left
  //speed: 0 is off, and 255 is full speed
  //direction: 0 clockwise, 1 counter-clockwise

  digitalWrite(STBY, HIGH); //disable standby

  boolean inPin1 = LOW;
  boolean inPin2 = HIGH;

  if(direction == 1){
    inPin1 = HIGH;
    inPin2 = LOW;
  }

  if(motor == 1){
    digitalWrite(AIN1, inPin1);
    digitalWrite(AIN2, inPin2);
    analogWrite(PWMA, speed);
  } else {
    digitalWrite(BIN1, inPin1);
    digitalWrite(BIN2, inPin2);
    analogWrite(PWMB, speed);
  }
}

void stop(){
  //enable standby
  digitalWrite(STBY, LOW);
}

void movement(int state) {
  switch (state) {
    case 0: //forward
      move(1, maxS, 1); //right, full speed, counter clockwise
      move(2, maxS, 0); //left, full speed, clockwise
      break;
    case 1: //attack
      move(1, 255, 1); //right, full speed, counter clockwise
      move(2, 255, 0); //left, full speed, clockwise
      break;
    case 2: //left
      move(1, minS, 1); //right, min speed, counter clockwise
      move(2, maxS, 0); //left, full speed, clockwise
      break;
    case 3: //right
      move(1, maxS, 1); //right, full speed, counter clockwise
      move(2, minS, 0); //left, full speed, clockwise
      break;
    case 4: //left in place
      move(1, maxS, 0); //right, full speed, clockwise
      move(2, maxS, 0); //left, full speed, clockwise
      break;
    case 5: //right in place
      move(1, maxS, 1); //right, full speed, counter clockwise
      move(2, maxS, 1); //left, full speed, counter clockwise
      break;
    case 6: //back right and left
      if (cur - prevFlag < degreesMin) {
        move(1, maxS, 0); //right, full speed, counter clockwise
        move(2, minS, 1); //left, full speed, clockwise
      } else if (cur - prevFlag < degrees90) {
        move(1, maxS, 0); //right, full speed, clockwise
        move(2, maxS, 0); //left, full speed, clockwise
      } else {
        lineFlag = 0;
      }
      break;
    case 7: //back right and right
      if (cur - prevFlag < degreesMin) {
        move(1, maxS, 0); //right, full speed, counter clockwise
        move(2, minS, 1); //left, full speed, clockwise
      } else if (cur - prevFlag < degrees90) {
        move(1, maxS, 1); //right, full speed, counter clockwise
        move(2, maxS, 1); //left, full speed, counter clockwise
      } else {
        lineFlag = 0;
      }
      break;
    case 8: //back left and right
      if (cur - prevFlag < degreesMin) {
        move(1, minS, 0); //right, min speed, counter clockwise
        move(2, maxS, 1); //left, full speed, clockwise
      } else if (cur - prevFlag < degrees90) {
        move(1, maxS, 1); //right, full speed, counter clockwise
        move(2, maxS, 1); //left, full speed, counter clockwise
      } else {
        lineFlag = 0;
      }
      break;
    case 9: //back left and left
      if (cur - prevFlag < degreesMin) {
        move(1, minS, 0); //right, min speed, counter clockwise
        move(2, maxS, 1); //left, full speed, clockwise
      } else if (cur - prevFlag < degrees90) {
        move(1, maxS, 0); //right, full speed, clockwise
        move(2, maxS, 0); //left, full speed, clockwise
      } else {
        lineFlag = 0;
      }
      break;
    case 10: //back and spin 180
      if (cur - prevFlag < degreesMin) {
        move(1, maxS, 0); //right, full speed, clockwise
        move(2, maxS, 0); //left, full speed, clockwise
      } else if (cur - prevFlag < degrees180) {
        move(1, maxS, 0); //right, full speed, clockwise
        move(2, maxS, 0); //left, full speed, clockwise
      } else {
        lineFlag = 0;
      }
      break;
    case 11: //startup movement: spin right, turn left, spin left
      if (cur - prevFlag < startSpinR) {
        move(1, maxS, 1); //right, full speed, counter clockwise
        move(2, maxS, 1); //left, full speed, counter clockwise
      } else if (cur - prevFlag < startTurnL) {
        move(1, minS, 1); //right, min speed, counter clockwise
        move(2, maxS, 0); //left, full speed, clockwise
      } else if (cur - prevFlag < startSpinL) {
        move(1, maxS, 0); //right, full speed, clockwise
        move(2, maxS, 0); //left, full speed, clockwise
      } else {
        past = 'f';
        pivotFlag = false;
      }
      break;
    case 12: //pivot:
      if (cur - prevFlag < pivotBack) {
        move(1, maxS, 0); //right, full speed, clockwise
        move(2, maxS, 0); //left, full speed, clockwise
      } else if (cur - prevFlag < pivotSpinR) {
        move(1, maxS, 1); //right, full speed, counter clockwise
        move(2, maxS, 1); //left, full speed, counter clockwise
      } else if (cur - prevFlag < pivotTurnL) {
        move(1, minS, 1); //right, min speed, counter clockwise
        move(2, maxS, 0); //left, full speed, clockwise
      } else if (cur - prevFlag < pivotSpinL) {
        move(1, maxS, 0); //right, full speed, clockwise
        move(2, maxS, 0); //left, full speed, clockwise
      } else {
        past = 'f';
        pivotFlag = false;
      }
      break;
  }
}

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


Clock example is added

Clock example is added

/*
    MIT License

    Copyright (c) 2018, Alexey Dynda

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
*/
/**
 *   Attiny85 PINS
 *             ____
 *   RESET   -|_|  |- 3V
 *   SCL (3) -|    |- (2)
 *   SDA (4) -|    |- (1)
 *   GND     -|____|- (0)
 *
 *   Atmega328 PINS: connect LCD to A4/A5
 */

#include "ssd1306.h"

uint32_t lastMillis;
uint8_t  hours = 10;
uint8_t  minutes = 35;
uint8_t  seconds = 0;

void printSeconds()
{
    if (seconds & 1)
    {
        ssd1306_printFixed(54,  8, ":", STYLE_NORMAL);
    }
    else
    {
        ssd1306_printFixed(54,  8, " ", STYLE_NORMAL);
    }
}

void printMinutes()
{
    char minutesStr[3] = "00";
    minutesStr[0] = '0' + minutes / 10;
    minutesStr[1] = '0' + minutes % 10;
    ssd1306_printFixed(78,  8, minutesStr, STYLE_NORMAL);
}

void printHours()
{
    char hoursStr[3] = "00";
    hoursStr[0] = '0' + hours / 10;
    hoursStr[1] = '0' + hours % 10;
    ssd1306_printFixed(6,  8, hoursStr, STYLE_NORMAL);
}

void setup() {
    /* Replace the line below with ssd1306_128x32_i2c_init() if you need to use 128x32 display */
    ssd1306_128x64_i2c_init();
    ssd1306_fillScreen(0x00);
    ssd1306_setFixedFont(comic_sans_font24x32_123);
    lastMillis = millis();
    printHours();
    printMinutes();
}

void loop()
{
    if ((uint32_t)(millis() - lastMillis) >= 1000)
    {
        lastMillis += 1000;
        if (++seconds > 59)
        {
            seconds = 0;
            if (++minutes > 59)
            {
                minutes = 0;
                if (++hours > 23)
                {
                    hours = 0;
                }
                printHours();
            }
            printMinutes();
        }
        printSeconds();
    }
}

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


Programmering opgave 2 lektion 3 opryddet

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


adding relay sample sketch

adding relay sample sketch

char inchar; //Will hold the incoming character from the Serial Port.

 int led1 = 8;
 int led2 = 9;
 int relay1=7;
 int relay2=6;
 void setup()
 {
 // prepare the digital output pins
 pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
 digitalWrite(led1, LOW);
 digitalWrite(led2, LOW);
 Serial.begin(9600);
 pinMode(relay1, OUTPUT);
 pinMode(relay2, OUTPUT);
 digitalWrite(7,HIGH);
 digitalWrite(6,HIGH);
 Serial.print("pin state low\n");
 delay(3000); // give time for GSM module to register on network.
 Serial.println("AT+CMGF=1"); // set SMS mode to text
 delay(200);
 Serial.println("AT+CNMI=2,2,0,0,0"); // set module to send SMS data to serial out upon receipt
 delay(200);
 }
 void loop()
 {

 if(Serial.available() >0)
 {
 inchar=Serial.read();
       if (inchar=='#')
        {
            delay(10);
            inchar=Serial.read();
            //first led
            if (inchar=='a')//closed
             {
               delay(10);
               inchar=Serial.read();
               if (inchar=='0')//closed
                   {
                    digitalWrite(led1, LOW);
                    delay(1000);
                    digitalWrite(relay1,HIGH);
                    Serial.print("Relay 1 LOW\n");
                    delay(500);
                    Serial.println("AT+CMGF=1");
                    delay(500);
                    Serial.println("AT+CMGS=\"9894273273\"");//Change the receiver phone number
                    delay(500);
                    Serial.print("Power OFF");    //the message you want to send
                    delay(500);
                    Serial.write(26);
                    delay(500);
                    }
                       else if (inchar=='1')
                          {
                          digitalWrite(led1, HIGH);
                          delay(1000);
                          digitalWrite(relay1, LOW);
                          Serial.print("Relay 1 HIGH\n");
                          delay(500);
                          Serial.println("AT+CMGF=1");
                          delay(500);
                          Serial.println("AT+CMGS=\"9894273273\"");//Change the receiver phone number
                          delay(500);
                          Serial.print("Power ON");    //the message you want to send
                          delay(500);
                          Serial.write(26);
                          delay(500);
                          }

        delay(10);
        inchar=Serial.read();
        if(inchar=='b')
        {
        delay(10);
        inchar=Serial.read();
          if (inchar=='0')
            {
             digitalWrite(led2, LOW);
             delay(500);
             digitalWrite(relay2,HIGH);
             Serial.print("Relay 2 LOW\n");
             }
               else if (inchar=='1')
                 {
                    digitalWrite(led2, HIGH);
                    delay(500);
                    digitalWrite(relay2, LOW);
                    Serial.print("Relay 2 HIGH\n");
                  }
                }
             }
              Serial.println("AT+CMGD=1,4");
        }

    }
}

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


Create env_sensosrs.ino

Create env_sensosrs.ino

#include "DHT.h"
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "bubblestack.io";    // name address for Google (using DNS)
IPAddress ip(2, 2, 2, 226);
EthernetClient client;

long previousMillis = 0;
unsigned long currentMillis = 0;
unsigned long lastConnectionTime = 0;             // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds
long interval = 150000; // READING INTERVAL

float cistern_temp;

#define DHT1PIN 2     // what pin we're connected to
#define DHT2PIN 3
#define DHT1TYPE DHT11   // DHT 11
#define DHT2TYPE DHT11

DHT dht1(DHT1PIN, DHT1TYPE);
DHT dht2(DHT2PIN, DHT2TYPE);

String data;

void setup() {
  Serial.begin(9600);
  pinMode(4, OUTPUT);
  dht1.begin();
  dht2.begin();
  delay(4000);
  float h1 = dht1.readHumidity();
  float t1 = dht1.readTemperature();
  float h2 = dht2.readHumidity();
  float t2 = dht2.readTemperature();

    // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    Ethernet.begin(mac, ip);
  }
}

void loop() {

   cistern_temp = read_temp();
 Serial.println(cistern_temp);

  float h1 = dht1.readHumidity();
  float t1 = dht1.readTemperature();
  float h2 = dht2.readHumidity();
  float t2 = dht2.readTemperature();
delay(1000);

  if (isnan(t1) || isnan(h1)) {
    Serial.println("Failed to read from DHT #1");
  } else {
    Serial.print("Humidity 1: ");
    Serial.print(h1);
    Serial.print(" %\t");
    Serial.print("Temperature 1: ");
    Serial.print(t1);
    Serial.println(" *C");
  }
  if (isnan(t2) || isnan(h2)) {
    Serial.println("Failed to read from DHT #2");
  } else {
    Serial.print("Humidity 2: ");
    Serial.print(h2);
    Serial.print(" %\t");
    Serial.print("Temperature 2: ");
    Serial.print(t2);
    Serial.println(" *C");
  }
  Serial.println();

  data = "&temp1=" + String(t1)+  "&hum1="+ String(h1)+ "&temp2=" +String(t2)+ "&hum2=" +String(h2)+ "&cistern_tmp=" +String(cistern_temp);

    if (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if ten seconds have passed since your last connection,
  // then connect again and send data:
  if (millis() - lastConnectionTime > postingInterval) {
    httpRequest();
  }

}

// this method makes a HTTP connection to the server:
void httpRequest() {
  // close any connection before send a new request.
  // This will free the socket on the WiFi shield
  client.stop();

  // if there's a successful connection:
  if (client.connect(server, 80)) {
    Serial.println("connecting...");
    // send the HTTP PUT request:
    client.println("POST /greenhouse/env.php HTTP/1.1");
    client.println("Host: bubblestack.io");
    client.println("User-Agent: arduino-ethernet");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.print("Content-Length: ");
    client.println(data.length());
    client.println();
    client.print(data);
    client.println();

    // note the time that the connection was made:
    lastConnectionTime = millis();
  }
  else {
    // if you couldn't make a connection:
    Serial.println("connection failed");
  }
 if (client.connected()) {

client.stop();// DISCONNECT FROM THE SERVER

}

}

float read_temp(void){
 float v_out;
 float cistern_temp;
 digitalWrite(A0, LOW);
 digitalWrite(4, HIGH);
 delay(2);
 v_out = analogRead(0);
 digitalWrite(4, LOW);
 v_out*=.0048;
 v_out*=1000;
 cistern_temp= 0.0512 * v_out -20.5128;
return cistern_temp;
}

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


光センサー追加(arduino)

光センサー追加(arduino)

光センサーの値をjson形式で3000ループ毎に送信

void setup(){
    Serial.begin(9600);
    //pinMode(13, OUTPUT);
    pinMode(2, INPUT_PULLUP);
    //digitalWrite(13, 1);
}

int lastSwitchVal = 0;
//int lastButtonVal = 0;

int doorCount = 0;
//int judge = 1;//on:1,off:0

int lightCount = 0;
int lightVal = 0;

void loop() {
    int switchVal;//doorSensor
    /*int buttonVal;

    buttonVal = digitalRead(4);
    if(buttonVal == 1 && buttonVal != lastButtonVal){
        if(doorCount%2 == 0){
            judge = 1;
            digitalWrite(13, 1);
        }else{
            judge = 0;
            digitalWrite(13, 0);
        }
        doorCount++;
    }
    lastButtonVal = buttonVal;*/

    switchVal = digitalRead(2);
    //if(judge == 1){
    if (switchVal != lastSwitchVal){
        if (switchVal == 0){//ドアが閉まった
            Serial.print("0\n");
        }
        else {//ドアが開いた
            Serial.print("1\n");
        }
    }
    //}
    lastSwitchVal = switchVal;

    //lightSensor
    lightCount++;
    if(lightCount > 3000){
        lightVal = analogRead(0)/4;
        Serial.print("{lightSensor: ");
        Serial.print(lightVal);//センサの値
        Serial.print("}\n");

        lightCount = 0;
    }

    Serial.flush();
    delay(100);
}

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


- initial HID keyboard example

- initial HID keyboard example

ported from Nordic example
(https://github.com/NordicSemiconductor/ble-sdk-arduino/tree/master/libr
aries/BLE/examples/ble_HID_keyboard_template)

// Import libraries (BLEPeripheral depends on SPI)
#include <SPI.h>
#include <BLEPeripheral.h>

// define pins (varies per shield/board)
#define BLE_REQ   6
#define BLE_RDY   7
#define BLE_RST   4

// create peripheral instance, see pinouts above
BLEPeripheral blePeripheral = BLEPeripheral(BLE_REQ, BLE_RDY, BLE_RST);
BLEBondStore bleBondStore;

const unsigned char hidReportReferenceDescriptorValue1[] = { 0x00, 0x01 };
const unsigned char hidInformationCharacteriticValue[]   = { 0x11, 0x01, 0x00, 0x03 };

// https://github.com/NordicSemiconductor/ble-sdk-arduino/blob/master/libraries/BLE/examples/ble_HID_keyboard_template/USD%20HID%20Report%20Descriptor%20-%20Keyboard.txt
const unsigned char hidReportDescriptorValue[] = {
  0x05, 0x01,                         // Usage Page (Generic Desktop)
  0x09, 0x06,                         // Usage (Keyboard)
  0xA1, 0x01,                         // Collection (Application)
  0x05, 0x07,                         //     Usage Page (Key Codes)
  0x19, 0xe0,                         //     Usage Minimum (224)
  0x29, 0xe7,                         //     Usage Maximum (231)
  0x15, 0x00,                         //     Logical Minimum (0)
  0x25, 0x01,                         //     Logical Maximum (1)
  0x75, 0x01,                         //     Report Size (1)
  0x95, 0x08,                         //     Report Count (8)
  0x81, 0x02,                         //     Input (Data, Variable, Absolute)

  0x95, 0x01,                         //     Report Count (1)
  0x75, 0x08,                         //     Report Size (8)
  0x81, 0x01,                         //     Input (Constant) reserved byte(1)

  0x95, 0x05,                         //     Report Count (5)
  0x75, 0x01,                         //     Report Size (1)
  0x05, 0x08,                         //     Usage Page (Page# for LEDs)
  0x19, 0x01,                         //     Usage Minimum (1)
  0x29, 0x05,                         //     Usage Maximum (5)
  0x91, 0x02,                         //     Output (Data, Variable, Absolute), Led report
  0x95, 0x01,                         //     Report Count (1)
  0x75, 0x03,                         //     Report Size (3)
  0x91, 0x01,                         //     Output (Data, Variable, Absolute), Led report padding

  0x95, 0x06,                         //     Report Count (6)
  0x75, 0x08,                         //     Report Size (8)
  0x15, 0x00,                         //     Logical Minimum (0)
  0x25, 0x65,                         //     Logical Maximum (101)
  0x05, 0x07,                         //     Usage Page (Key codes)
  0x19, 0x00,                         //     Usage Minimum (0)
  0x29, 0x65,                         //     Usage Maximum (101)
  0x81, 0x00,                         //     Input (Data, Array) Key array(6 bytes)

  0x09, 0x05,                         //     Usage (Vendor Defined)
  0x15, 0x00,                         //     Logical Minimum (0)
  0x26, 0xFF, 0x00,                   //     Logical Maximum (255)
  0x75, 0x08,                         //     Report Count (2)
  0x95, 0x02,                         //     Report Size (8 bit)
  0xB1, 0x02,                         //     Feature (Data, Variable, Absolute)

  0xC0                                // End Collection (Application)
};
const unsigned char hidReportReferenceDescriptorValue2[] = {0x00, 0x02};

BLEService                       hidService                              = BLEService("1812");
BLECharacteristic                hidReportCharacteristic                 = BLECharacteristic("2A4D", BLERead | BLENotify, 8);
BLEDescriptor                    reportReferenceDescriptor1              = BLEDescriptor("2908", hidReportReferenceDescriptorValue1, sizeof(hidReportReferenceDescriptorValue1));
BLEConstantCharacteristic        hidInformationCharacteristic            = BLEConstantCharacteristic("2a4a", hidInformationCharacteriticValue, sizeof(hidInformationCharacteriticValue));
BLEUnsignedCharCharacteristic    hidProtocolModeCharacteristic           = BLEUnsignedCharCharacteristic("2a4e", BLERead | BLEWriteWithoutResponse);
BLEUnsignedCharCharacteristic    hidControlPointCharacteristic           = BLEUnsignedCharCharacteristic("2a4c",BLEWriteWithoutResponse);
BLEConstantCharacteristic        hidReportDescriptor                     = BLEConstantCharacteristic("2a4b", hidReportDescriptorValue, sizeof(hidReportDescriptorValue));
BLEUnsignedCharCharacteristic    hidReportOutputCharacteristic           = BLEUnsignedCharCharacteristic("2a4f", BLERead | BLEWrite | BLEWriteWithoutResponse);
BLEDescriptor                    reportReferenceDescriptor2              = BLEDescriptor("2908", hidReportReferenceDescriptorValue2, sizeof(hidReportReferenceDescriptorValue2));
BLECharacteristic                bootKeyboardInputReportCharacateristic  = BLECharacteristic("2A22", BLERead | BLENotify, 8);
BLEUnsignedCharCharacteristic    bootKeyboardOutputReportCharacateristic = BLEUnsignedCharCharacteristic("2A23", BLERead | BLEWrite | BLEWriteWithoutResponse);

void setup() {
  Serial.begin(9600);
#if defined (__AVR_ATmega32U4__)
  delay(5000);  //5 seconds delay for enabling to see the start up comments on the serial board
#endif

  // clears bond data on every boot
  blePeripheral.setBondStore(bleBondStore);

  blePeripheral.setDeviceName("Arduino Keyboard");
  blePeripheral.setAppearance(961);

  blePeripheral.setLocalName("HID-keyboard");
  blePeripheral.setAdvertisedServiceUuid(hidService.uuid());

  // add attributes (services, characteristics, descriptors) to peripheral
  blePeripheral.addAttribute(hidService);
  blePeripheral.addAttribute(hidReportCharacteristic);
  blePeripheral.addAttribute(reportReferenceDescriptor1);
  blePeripheral.addAttribute(hidInformationCharacteristic);
  blePeripheral.addAttribute(hidProtocolModeCharacteristic);
  blePeripheral.addAttribute(hidControlPointCharacteristic);
  blePeripheral.addAttribute(hidReportDescriptor);
  blePeripheral.addAttribute(hidReportOutputCharacteristic);
  blePeripheral.addAttribute(reportReferenceDescriptor2);
  blePeripheral.addAttribute(bootKeyboardInputReportCharacateristic);
  blePeripheral.addAttribute(bootKeyboardOutputReportCharacateristic);

  // initialize characteristics values
  hidProtocolModeCharacteristic.setValue(0x01);

  unsigned char bootKeyboardInputReportCharacateristicValue[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  bootKeyboardInputReportCharacateristic.setValue(bootKeyboardInputReportCharacateristicValue, sizeof(bootKeyboardInputReportCharacateristicValue));

  // begin initialization
  blePeripheral.begin();

  Serial.println(F("BLE HID Keyboard Peripheral"));
}

void loop() {
  BLECentral central = blePeripheral.central();

  if (central) {
    // central connected to peripheral
    Serial.print(F("Connected to central: "));
    Serial.println(central.address());

    while (central.connected()) {
      uint8_t keyPress[8]= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

      if (Serial.available() > 0) {
        // read the ascii character
        unsigned char ascii = Serial.read();

        Serial.print(F("ascii = "));
        Serial.println(ascii);

        // https://github.com/SFE-Chris/UNO-HIDKeyboard-Library/blob/master/HIDKeyboard.h
        const static uint8_t HIDTable[] =  {
      	  0x00, // 0
          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, // 10
      	  0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 20
      	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, // 30
      	  0x00, 0x2c, 0x1e, 0x34, 0x20, 0x21, 0x22, 0x24, 0x34, 0x26, // 40
      	  0x27, 0x25, 0x2e, 0x36, 0x2d, 0x37, 0x38, 0x27, 0x1e, 0x1f, // 50
      	  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x33, 0x33, 0x36, // 60
      	  0x2e, 0x37, 0x38, 0x1f, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, // 70
      	  0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, // 80
      	  0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, // 90
      	  0x2f, 0x31, 0x30, 0x23, 0x2d, 0x35, 0x04, 0x05, 0x06, 0x07, // 100
      	  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, // 110
      	  0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, // 120
      	  0x1c, 0x1d, 0x2f, 0x31, 0x30, 0x35, 127 // 127
        };

        if (ascii < sizeof(HIDTable)) {

          unsigned char hid = HIDTable[ascii];

          Serial.print(F("hid = "));
          Serial.println(hid);

          // wait until we can notify
          while(!hidReportCharacteristic.canNotify()) {
            blePeripheral.poll();
          }

          // send hid key code
          keyPress[2] = hid;
          hidReportCharacteristic.setValue(keyPress, sizeof(keyPress));

          // wait until we can notify
          while(!hidReportCharacteristic.canNotify()) {
            blePeripheral.poll();
          }

          // send cleared hid code
          keyPress[2] = 0x00;
          hidReportCharacteristic.setValue(keyPress, sizeof(keyPress));
        }
      }
    }

    // central disconnected
    Serial.print(F("Disconnected from central: "));
    Serial.println(central.address());
  }
}

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


Added DSLR_Controller.ino, has skeleton of code for three commands (expose, cancel, query), but needs query and cancel to be written.

/*
Canon DSLR Camera Control

To activate cameras send a serial tring to the board.  The string should
consist of three integers.  The first and second indicate which cameras
should be activated.  Any non-zero, positive integer in the first field
will activate the first camera and any non-zero integer in the second
field will activate the second camera.  The third value is the exposure
time in milliseconds.

Serial Commands to Board:
E,n,n,nnn -- Expose camera.
C,n,n     -- Cancel exposure.
Q         -- Query which cameras are exposing.
*/

// Constants for Camera Relay
const int camera1_pin = 2;
const int camera2_pin = 3;

//-----------------------------------------------------------------------------
// SETUP
//-----------------------------------------------------------------------------
void setup() {
    // Open serial communications and wait for port to open:
    Serial.begin(9600);
    while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
    }

    Serial.print("Setup Camera Relay Pins ... ");
    pinMode(camera1_pin, OUTPUT);
    pinMode(camera2_pin, OUTPUT);
    digitalWrite(camera1_pin, LOW);
    digitalWrite(camera2_pin, LOW);
    Serial.println("done!");
}

//-----------------------------------------------------------------------------
// MAIN LOOP
//-----------------------------------------------------------------------------
void loop() {
    // if there's any serial available, read it:
    while (Serial.available() > 0) {
        int command = Serial.parseInt();
        // Based on the command, parse the rest of the serial string differently.
        if (command == 69) {
            // Expose (E=69) command
            int camera1 = Serial.parseInt();
            int camera2 = Serial.parseInt();
            int exptime_ms = Serial.parseInt();
            // look for the newline. That's the end of your
            // sentence:
            if (Serial.read() == '\n') {
                // expose camera for exptime_ms milliseconds
                Serial.print("Starting ");
                Serial.print(exptime_ms/1000.0);
                Serial.print(" second exposure");
                if (camera1 >= 1) {
                    Serial.print(" on camera1 ");
                    digitalWrite(camera1_pin, HIGH);
                    if (camera2 >= 1) { Serial.print("and"); }
                }
                if (camera2 >= 1) {
                    Serial.print(" on camera2 ");
                    digitalWrite(camera2_pin, HIGH);
                }
                Serial.print("... ");
                // Now go in to loop waiting for exposure time to finish
                // If a cancel command is received, cancel exposure.
                int total_exptime = 0
                int remainder = total_exptime % 100;
                int n_loops = (total_exptime - remainder) / 100;
                for (int index = 0; index < n_loops; index++) {
                    delay(100);
                    total_exptime = total_exptime + 100;
                    // Look for cancel command
                }
                delay(remainder);
                // Set pins low (stop exposure)
                digitalWrite(camera1_pin, LOW);
                digitalWrite(camera2_pin, LOW);
                Serial.println("done");
            }
        }
        if (command == 67) or (command == 81) {
        // Cancel (C=67) or Query (Q=81) command
        }
    }
    delay(100);
}

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


Changed sendPinValues() to send the most significant byte first.

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


Rewritten firmware

Rewritten firmware

Progress on serial parsing and PWM output
To be added is radio network support etc

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


ArduSound

ArduSound

#include <Ultrasonic.h> // This library is licensed under Creative Commons Share alike and Attribution by J.Rodrigo. See: https://github.com/JRodrigoTech/Ultrasonic-HC-SR04

Ultrasonic ultraleft(11,3, 25000);   // (Trig PIN, Echo PIN, Time Out in milliseconds- A lower value will limit the maximum distance reading.)
Ultrasonic ultraright(6,5, 25000);  // (Trig PIN, Echo PIN, Time Out in milliseconds- A lower value will limit the maximum distance reading.)

int pwmleft;
int pwmright;

void setup(){
  pinMode(2, OUTPUT); // GND pin
  digitalWrite(2, LOW);  // GND mode
  Serial.begin(9600);
}

void loop(){
  Serial.print("Left: ");
  Serial.print(ultraleft.Ranging(CM)); // CM or INC
  Serial.print(" cm     " );
  delay(50);
  Serial.print("Right: ");
  Serial.print(ultraright.Ranging(CM)); // CM or INC
  Serial.println(" cm" );
  delay(50);

  pwmleft = map(ultraleft.Ranging(CM), 0, 431, 0, 70); // Map the distance value to the analogue output.
  pwmright = map(ultraright.Ranging(CM), 0, 431, 0, 70); // Map the distance value to the analogue output.
  analogWrite(10, pwmleft); // Output the pwm value as analog output
  analogWrite(9, pwmright); // Output the pwm value as analog output

}

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


Delete ESPArto_timer_functions.ino

Delete ESPArto_timer_functions.ino

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


Create LORA_chat.ino

Create LORA_chat.ino

#include <RHReliableDatagram.h>
#include <RH_RF95.h>
#include <SPI.h>

#define MY_ADDRESS 1
#define TARGET_ADDRESS 2
#define MAX_LEN 40

RH_RF95 driver;
RHReliableDatagram manager(driver, MY_ADDRESS);

bool check = 0;
uint8_t data[MAX_LEN];
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];

char outstr[MAX_LEN];
byte i;
byte SNR;
byte cont = 0;

void setup() {

  Serial.begin(9600);

  if (!manager.init()) {
    Serial.println("init failed");
  }

  driver.setTxPower(23, false);

  Serial.println("---- LORA chat modulo A ----");
  Serial.println("Digita il messaggio e premi INVIO per spedire.");
}

void loop() {

  //**********************************SPEDIZIONE

  if (Serial.available()) {

    delay(100); // Non togliere questo delay!!
    i = 0;

    while(Serial.available()){

      outstr[i] = Serial.read();
      //Serial.println(outstr[i]);
      i++;

      if(i == MAX_LEN){
        break;
      }

    }

    String(outstr).getBytes(data, i);         // Inserisco il dato nell'array da
                                                //   spedire.
    Serial.print("Messaggio da spedire: \t\t\t\t\t\t");
    Serial.println((char*)data);
    Serial.println("Provo a spedire...");

    // Spedisco la stringa all'indirizzo e vedo se l'invio è andato a buon fine
    check = manager.sendtoWait(data, sizeof(data), TARGET_ADDRESS);

    if (check) {

      Serial.println("Invio riuscito!");
      Serial.println("Digita il messaggio e premi INVIO per spedire di nuovo");

    } else {

      Serial.println("Invio fallito!");
      Serial.println("Digita il messaggio e premi INVIO per spedire di nuovo");

    }
  }

  //**********************************RICEZIONE

  if (manager.available()) {

    Serial.println("Manager available");

    uint8_t len = sizeof(buf);
    uint8_t from;

    check = manager.recvfromAckTimeout(buf, &len, 2000, &from);

    if (check) {

      cont++;
      Serial.print("Ricevuto messaggio da : 0x");
      Serial.print(from, HEX);
      Serial.print(": \t\t\t\t\t");
      Serial.print(cont);
      Serial.print("\t");
      Serial.println((char*)buf);

      SNR = driver.lastSNR();
      Serial.print("SNR : ");
      Serial.println(SNR);

    } else {

      Serial.print("Ricezione fallita");

    }

  } // Manager available

}

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


Arduino sketch added

Arduino sketch added

//Own libraries
#include <Menu.h>
#include <RGBLed.h>
#include <Speaker.h>
#include <GasValve.h>
#include <TemperatureSensors.h>
#include <Logger.h>
#include <MyTFT.h>

//3rd party libraries
#include <Encoder.h>

#include <DallasTemperature.h>
#include <OneWire.h>

#include <mmc.h>
#include <tinyFAT.h>

#include "SPI.h"
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>

#include <DS1307RTC.h>
#include <Time.h>
#include <Wire.h>

#include <Servo.h>
#include <Stepper.h>

const int TARGET_TEMP_BARREL = 0;
const int TARGET_TEMP_MEAT = 1;

const int menuSelectorRE_A = 19;
const int menuSelectorRE_B = 27;

const int menuButton = 18;
const int pauseButton = A3;

const int oneWireTempSensors_pin = 3;

const int gasValveMotorRotationCheck_RE_A = A2;
const int gasValveMotorRotationCheck_RE_B = 38;

const int gasValveMotorA = 23;
const int gasValveMotorB = 24;
const int gasValveMotorC = 25;
const int gasValveMotorD = 26;

const int speaker_pin = 37;

const int led1_R = 12;
const int led1_G = 11;
const int led1_B = 10;

const int smokeValveServoPin = 9;
const int smokeValveMin = 0;
const int smokeValveMax = 180;

const int smokerRegulationInterval = 60; // Every minute. Hope it is ok.

const int meatTempPin = A4;
const int barrelTempPin = A5;

const int TFT_CS = 53;
const int TFT_DC = 49;
const int TFT_MOSI = 51;
const int TFT_MISO = 50;
const int TFT_CLK = 52;
const int TFT_RST = 48;
const int SD_CS = 47;

/* Initialize the one wire sensors*/
TemperatureSensors tempSensors(oneWireTempSensors_pin, barrelTempPin, meatTempPin);

/* Initialize the RGB Led */
RGBLed led1(led1_R,led1_G,led1_B);

/* Initialize the speaker */
Speaker speaker(speaker_pin);

/* Initialize the Rotary Encoders */
Encoder menuSelector(menuSelectorRE_A, menuSelectorRE_B);
Encoder gasValveMotorRotationCheck(gasValveMotorRotationCheck_RE_A, gasValveMotorRotationCheck_RE_B);

/* Initialize the LCD Panel */
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
MyTFT *tft;

/* Initialize the RTC (Real Time Clock) */
// nothing?!

/* Initialize the gas valve; it uses a rotary encoder to check if the gas valve is at the end */
GasValve gasValve(&gasValveMotorRotationCheck, gasValveMotorA, gasValveMotorB, gasValveMotorC, gasValveMotorD);

/* Initialize the servo */
SmokeValve *smokeValve;

/* Initialize the menu */
Menu *mainMenu = new Menu(menuButton);

/* Initialize the logger to the SD card*/
Logger logger(SD_CS);

/* Here are all the parameters for the application */
float target_temp = 30.0; // The target temperature
int target_temp_location = TARGET_TEMP_BARREL;
int rooktijd=120; //smoketime in minutes

int current_hour=10;
int current_minute=30;
int current_second=30;
int current_month=2;
int current_day=3;
int current_year=2014;

int smoking_started = 0; //Is the barrel up-and-running, or are we in 'setup mode'?
long encvalue=0; // used for the menu-rotary encoder
volatile bool wasInSelected=false;

time_t starttime, lastregulation; // times for start and lastregulation
boolean firstSmokeLoop=true;
float lasttemp, lasttempdif;

/*
 *Here is all the setup of the project done
 */
void setup() {
  // initialize Serial device to support debugging
  Serial.begin(9600);

  //initialize the LCD
  tft = new MyTFT(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
  //initialize the menu
  createMenu();

  //Close the smoke valve with the servo
  smokeValve = new SmokeValve(smokeValveServoPin, smokeValveMin, smokeValveMax);
  smokeValve->fullyClose();

  //Close the gasvalve
  gasValve.fullyClose();

  //blink light to indicate start
  led1.changeColor(&COLOR_GREEN);
  delay(100);
  led1.changeColor(&COLOR_BLUE);
  delay(100);
  led1.changeColor(&COLOR_RED);
  //test speaker
  speaker.on();
  delay(20);
  speaker.off();

  // Initialize the rotary encoder
  encvalue = menuSelector.read();

  // Initialize the menubutton
  pinMode(menuButton, INPUT);
  attachInterrupt(getInterruptForPin(menuButton), bPressed, FALLING);

  // Create a new file
  logger.createUniqueFileName();
}

/*
 * This is the main of the arduino application
 */
void loop() {
  long gasValvePos, smokeValvePos;
  float barrelTemp, meatTemp, ambientTemp;

  tmElements_t tm;

  long newvalue;
  bool selected = false;
  int steps = 0;

  // Get the time from the RTC
  if (RTC.read(tm)) {
    current_hour=tm.Hour;
    current_minute=tm.Minute;
    current_second=tm.Second;
    current_month=tm.Month;
    current_day=tm.Day;
    current_year=tmYearToCalendar(tm.Year);
  };

  // Do menu things if necessary
  mainMenu->display(tft->getTFT());
  wasInSelected = false;
  selected=false;
  while (!selected && !wasInSelected) {
    newvalue = menuSelector.read();
    if ((newvalue - encvalue) % 4 != 0) {
      continue;
    }
    if (newvalue > encvalue) {
      steps = (newvalue - encvalue)/4;
      for (int i=0;i<steps;i++) {
        mainMenu->highlightNext();
      };
      encvalue=newvalue;
      selected=true;
    }
    else {
      if (newvalue < encvalue) {
        steps = (encvalue - newvalue)/4;
        for (int i=0;i<steps;i++) {
          mainMenu->highlightPrevious();
        };
        encvalue=newvalue;
        selected=true;
      }
      else {
        delay(100);
        //the same so wait for a new value
      }
    }
  }

  // Check the temps
  barrelTemp = tempSensors.getBarrelTemperature();
  meatTemp = tempSensors.getMeatTemperature();
  ambientTemp = tempSensors.getAmbientTemperature();

  RTC.read(tm);
  // display the temps and time at the LCD
  tft->displayTemps(ambientTemp, meatTemp, barrelTemp, target_temp, target_temp_location == TARGET_TEMP_MEAT);
  tft->displayTime(&tm);
//  tft->displayTimeRemaining(seconds_smoking_left, smoking_started);

  // Now check if the smoking is started
  if (smoking_started) {
    if (firstSmokeLoop) {
      logger.writeln("Smoking started");
      starttime = RTC.get();
      // now determine the endtime for the smoking.
      firstSmokeLoop = false;
      lasttemp = 0;
      lasttempdif = 0;
      // Change led to green to indicate that smoking is started
      led1.changeColor(&COLOR_GREEN);
    }
    // Do all the regulating one every x seconds. Else there is to much turning on all the knobs
    time_t current = RTC.get();
    if (current - lastregulation > smokerRegulationInterval) {

      // Check the temps
      barrelTemp = tempSensors.getBarrelTemperature();
      meatTemp = tempSensors.getMeatTemperature();
      ambientTemp = tempSensors.getAmbientTemperature();
      if (ambientTemp > target_temp) {
        logger.writeln("Error: ambient temperature higher than target temperature. Aborting!");
        led1.changeColor(&COLOR_MAGENTA);
        smoking_started = false;
      }
      // Get the positions of the gasvalve steppermotor and smoke valve servo
      gasValvePos = gasValve.getCurrentPosition();
      smokeValvePos = smokeValve->getCurrentPosition();

      // Also update the LCD display to show the current positions (temps are already done
      tft->displayValveStatus(smokeValvePos, gasValvePos);

      // Now determine which temperature to use and see what the diff is between the current temp and the target temp
      float temp = (target_temp_location == TARGET_TEMP_BARREL)?barrelTemp:meatTemp;
      float tempdif = target_temp - temp;

      // Now write all the logging for later inspection
      logger.writeLoggingInfo(ambientTemp, meatTemp, barrelTemp, target_temp, target_temp_location, temp, tempdif, lasttempdif, gasValvePos, smokeValvePos);

      // tempdif > 0 betekent dat de temperatuur nog niet bereikt is. Er mag nog doorgestookt worden,
      // alleen moet als de tempdif bijna bij 0 is wel opgelet worden dat de gaskraan niet meer hoog open blijft.

      if (tempdif > 0) { // is it too cold. but how much? And was it to cold last time?
        logger.writeln("1: tempdif > 0");
        if (lasttempdif < 0) { // was it to hot last time?
          logger.writeln("1.1: lasttempdif < 0");
          if (tempdif < 1) { // is it just 1 degree to cold? Try to regulate it with the smoke valve
            logger.writeln("1.1.1: tempdif < 1");
            smokeValve->close(50); // close it and hope the temp will stabilize
          } else if (tempdif < 3) { // 3 degrees to cold, but last time it was too hot, so the temp dropped a lot
            logger.writeln("1.1.2: tempdif < 3");
            smokeValve->fullyClose(); // close the smokevalve fully.
            gasValve.open(1); // just 1 step open
          } else { // more than 3 degrees temp drop in 1 minute. That is really strange.
            logger.writeln("1.1.3: tempdif >= 3");
            smokeValve->fullyClose(); // close the smokevalve
            gasValve.open(3); // turn on the heat
          }
        } else { // it was not to hot last time
          logger.writeln("1.2: lasttempdif >= 0");
          // now determine how close we are
          if (tempdif < 5) { // just 5 degrees? Look at the last value, so we know how much it was raised in 1 cycle
            logger.writeln("1.2.1: tempdif < 5");
            if (lasttempdif <= tempdif) { // it even got colder?
              logger.writeln("1.2.1.1: lasttempdif <= tempdif");
              gasValve.open(1); // open the gas a little bit
              smokeValve->close(5); // and close the smokevalve;
            } else if (lasttempdif < 10) { // it was 10 degrees to cold and now 5. So lets temper the fire and hope it will use the restwarmte
              logger.writeln("1.2.1.2: lasttempdif < 10");
              if (gasValve.close(5)) { // now fully closed?
                // do something with the smokevalve? I don't know
               logger.writeln("1.2.1.2.1: gasvalve.close == true");
             }
            } else if (lasttempdif < 20) {
              logger.writeln("1.2.1.3: lasttempdif < 20");

              // So it was almost 20 degrees in 1 cycle
              if (gasValve.isFullyClosed()) { // is the gasvalve already closed and it still raised that much?
               logger.writeln("1.2.1.3.1: gasValve.isFullyClosed()");
               smokeValve->fullyOpen();
              } else {
               logger.writeln("1.2.1.3.2: !gasValve.isFullyClosed()");
                gasValve.fullyClose(); //
                smokeValve->open(20);
              }
            } else { // more than 20 degrees in one cycle. So vent it and hope the temp will not raise to much
              logger.writeln("1.2.1.4: lasttempdif >= 20");
              gasValve.fullyClose();
              smokeValve->fullyOpen();
            }
          } else if (tempdif < 10) { // just 10 degrees to cold
              logger.writeln("1.2.2: tempdif < 10");
             if (lasttempdif < 10) { // but last time it was also 10 degrees to cold
               logger.writeln("1.2.2.1: tempdif < 10");
               if (gasValve.open(3)) {// turn on the gas
                 logger.writeln("1.2.2.1.1: gasvalve.open == true");
                 // it is now fully open.
                 smokeValve->fullyClose(); // so close the smokevalve, if opened
               }
             } else {
               logger.writeln("1.2.2.2: tempdif >= 10");
               gasValve.close(3); // close the gas a little bit so it won't rise to fast
             }

          } else if (tempdif < 30) { // 30 degrees to cold.
            logger.writeln("1.2.3: tempdif < 30");
            if (lasttempdif < 30) { // but last time it was also 30 degrees to cold
              logger.writeln("1.2.3.1: lasttempdif < 30");
              if (gasValve.open(5)) {// turn on the gas
                logger.writeln("1.2.3.1.1: gasvalve.open == true");
                // it is now fully open.
                smokeValve->fullyClose(); // so close the smokevalve, if opened
              }
            } else {
              logger.writeln("1.2.3.2: lasttempdif >= 30");
              gasValve.close(1); // close the gas a little bit so it won't rise to fast
            }

          } else {
            logger.writeln("1.2.4: tempdif >= 30");
            gasValve.fullyOpen();
            smokeValve->fullyClose();
          }
        }

      }

      // als tempdif < 0 betekent dat de max-temp overschreden is. Afhankelijk van de grootte van de overschrijding
      // zal de gaskraan helemaal dicht moeten en de rookklep open.
      if (tempdif < 0) {
        logger.writeln("2: tempdif < 0");
        if (lasttempdif < 0) { // Hij was vorige keer ook al te warm.
          logger.writeln("2.1: lasttempdif < 0");
          // now check the position of the gasvalve
          if (gasValve.isFullyClosed()) { // the GasValve is already totally closed
            logger.writeln("2.1.1: gasValve.isFullyClosed()");
            // So check the smokeValve
            if (smokeValve->isFullyOpen()) { // Is the smokevalve totally open?
              logger.writeln("2.1.1.1: smokeValve->isFullyClosed()");
              // I don't know what to do now. Gas is off, smokevalve totally open. Just wait for the temp to drop.
            } else {
              logger.writeln("2.1.1.2: !smokeValve->isFullyClosed()");
              if (tempdif > -1) { // just 1 degree to hot?
                logger.writeln("2.1.1.2.1: tempdif > -1");
                smokeValve->open(1); // just 1 step extra open
              } else if (tempdif >-3) {
                logger.writeln("2.1.1.2.2: tempdif > -3");
                smokeValve->open(5); // 5 steps extra open
              } else { // More than 3 degrees to hot? Open the smokevalve totally
                logger.writeln("2.1.1.2.3: tempdif <= -3");
                smokeValve->fullyOpen();
              }
            }
          } else { // the gasvalve is not fully closed, but the temp is to hot. Just close it now
            logger.writeln("2.1.2: !gasValve.isFullyClosed()");
            gasValve.fullyClose();

            if (tempdif >-3) { // 3 degrees to hot? Open the smokevalve so the temp can drop faster
              logger.writeln("2.1.2.1: tempdif > -3");
              smokeValve->open(10); // 10 steps extra open
            } else { // More than 3 degrees to hot? Open the smokevalve totally
              logger.writeln("2.1.2.2: tempdif <= -3");
              smokeValve->fullyOpen();
            }
          }
        } else { // last time it was not to hot, so it is just to hot
          logger.writeln("2.2: lasttempdif >= 0");
          if (gasValve.isFullyClosed()) { // is the gasvalve already closed?
            logger.writeln("2.2.1: gasValve.isFullyClosed()");
            if (smokeValve->isFullyOpen()) { // is the smokevalve already open?
              logger.writeln("2.2.1.1: smokeValve->isFullyOpen()");
              // Don't know what to do now. Both controls are exhausted
            } else { // only the smokeValve is usable to regulate the temperature
              logger.writeln("2.2.1.2: !smokeValve->isFullyOpen()");
              if (tempdif > -1) { // just 1 degree to hot?
                logger.writeln("2.2.1.2.1: tempdif > -1");
                smokeValve->open(1); // just 1 step extra open
              } else if (tempdif >-3) {
                logger.writeln("2.2.1.2.2: tempdif > -3");
                smokeValve->open(5); // 5 steps extra open
              } else { // More than 3 degrees to hot? Open the smokevalve totally
                logger.writeln("2.2.1.2.3: tempdif <= -3");
                smokeValve->fullyOpen();
              }
            }
          } else { // the gasvalve is not fully closed yet.
           logger.writeln("2.2.2: !gasValve.isFullyClosed()");
           if (tempdif > -1) { // just 1 degree to hot?
              logger.writeln("2.2.2.1: tempdif > -1");
              if (gasValve.close(2)) { // close 2 steps, but is it totally closed now?
                logger.writeln("2.2.2.1.1: gasvalve.close == true");
                smokeValve->open(5); // Open more, because gas is closed now
              }  else {
                logger.writeln("2.2.2.1.2: gasvalve.close != true");
                smokeValve->open(1); // just 1 step extra open
              }
            } else if (tempdif >-3) {
              logger.writeln("2.2.2.2: tempdif > -3");
              if (gasValve.close(5)) {
                logger.writeln("2.2.2.2.1: gasvalve.close == true");
                smokeValve->open(20);
              } else {
                logger.writeln("2.2.2.2.2: gasvalve.close != true");
                smokeValve->open(5); // 5 steps extra open
              }
            } else { // More than 3 degrees to hot? Open the smokevalve totally
              logger.writeln("2.2.2.3: tempdif <= -3");
              gasValve.fullyClose();
              smokeValve->fullyOpen();
            }
          }
        }
      }

      // store the current temps for the next round, so we can see how fast the temp is raising or dropping
      lasttemp = temp;
      lasttempdif = tempdif;

      // now make sure the interval is reset
      lastregulation = RTC.get();
      // now check if the endtime is reached
      long seconds_smoking_left = determineSmokingTimeLeftInSeconds(starttime, lastregulation, rooktijd);
      tft->displayTimeRemaining(seconds_smoking_left, smoking_started);
      if (seconds_smoking_left<0) {
        smoking_started=false;
        firstSmokeLoop=true;
        logger.writeln("Smoking stopped because end time is reached");
        for (int l = 0;l<10;l++) {
          led1.changeColor(&COLOR_BLUE);
          speaker.on();
          delay(500);
          led1.changeColor(&COLOR_GREEN);
          speaker.off();
          delay(500);
        } // for
        led1.changeColor(&COLOR_GREEN);
      } // end time reached?
    } // regulator cycle loop
  } // smoking started
} // main loop

/*
 * calculates the remaining time in seconds
 */
long determineSmokingTimeLeftInSeconds(time_t starttime, time_t currenttime, int smoketime_in_minutes) {
  long timeSmokerActiveInSeconds = currenttime - starttime;
  long totalSmokingTimeInSeconds = (long)smoketime_in_minutes * 60l;

  return totalSmokingTimeInSeconds - timeSmokerActiveInSeconds;
}

/*
 * this method writes the value to the console if the board is connected.
 */
void debug(char* str) {
  logger.writeln(str);
}

/*
 * This is the initialization code for the menu-class. This can be controlled by a rotary encoder and a button
 */
void createMenu() {
  StringOption* opt = new StringOption("Vat\0");
  opt->addOption("Vlees\0");

  StringOption* startopties = new StringOption("Nee\0");
  startopties->addOption("Ja\0");

  FloatSelector *tempsel = new FloatSelector("Stel temperatuur in:\0", &target_temp, 0.5f, 10, 250);
  StringSelector *valuesel = new StringSelector("Meet locatie:\0", &target_temp_location, opt);
  TimeSelector *timesel = new TimeSelector("Rooktijd:\0", &rooktijd, 5);
  StringSelector *smokestartsel = new StringSelector("Nu starten:\0", &smoking_started, startopties);

  Menu *instellingen = new Menu();

  IntSelector *hoursel = new IntSelector ("Selecteer huidige uur:\0", &current_hour, 1, 0, 23);
  IntSelector *minutesel = new IntSelector ("Selecteer huidige minuut:\0", &current_minute, 1, 0, 59);
  instellingen->addItem(20, "Stel uren in", false, NULL, hoursel);
  instellingen->addItem(21, "Stel minuten in", false, NULL, minutesel);

  IntSelector *daysel = new IntSelector ("Selecteer huidige dag:", &current_day, 1, 1, 31);
  IntSelector *monthsel = new IntSelector ("Selecteer huidige maand:", &current_month, 1, 1, 12);
  IntSelector *yearsel = new IntSelector ("Selecteer huidige jaar:", &current_year, 1, 2014, 2020);
  instellingen->addItem(22, "Stel dag in", false, NULL, daysel);
  instellingen->addItem(23, "Stel maand in", false, NULL, monthsel);
  instellingen->addItem(24, "Stel jaar in", false, NULL, yearsel);

  mainMenu->addItem(1, "Start roken\0", false, NULL, smokestartsel);
  mainMenu->addItem(2, "Doel temperatuur\0", false, NULL, tempsel);
  mainMenu->addItem(3, "Vlees of vat sensor\0", false, NULL, valuesel);
  mainMenu->addItem(4, "Rooktijd\0", false, NULL, timesel);
  mainMenu->addItem(5, "Instellingen\0", true, instellingen, NULL);
}

/*
The interrupt routine for the button
 */
void bPressed() {
  mainMenu->selectCurrent();
  wasInSelected = true;
};

/*
Map the pin to an interrupt number for the Arduino Mega
 */
int getInterruptForPin (uint8_t pin) {
  int interrupt=-1;

  switch (pin) {
  case 2:
    interrupt=0;
    break;
  case 3:
    interrupt=1;
    break;
  case 18:
    interrupt=5;
    break;
  case 19:
    interrupt=4;
    break;
  case 20:
    interrupt=3;
    break;
  case 21:
    interrupt=2;
    break;
  }
  return interrupt;
}

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


fixed by Mark, + copyright notice

fixed by Mark, + copyright notice

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


Create pixy-rover.ino

Create pixy-rover.ino

// By Jeremy Ellis.
// Rover should move slowly unless several seconds no response from the pixy then it should stop.
// should move left or right based on where the object is.
// should stop if the object gets to big a width ie it is close.

#define FRAME_SKIP 25                // How many frames to skip. Lower numbers cause faster response

/* Globals -------------------------------------------------------------------*/
// Note my pololu big motor driver needs two digital and one analog PWM controls for the drive motor VNH5019
//   https://www.pololu.com/product/1451

int myForward          = D6;      // set or change these as needed
int myBackward         = D5;      // set or change these as needed
int myDriveMotor       = A0;

// I am using the cheap pololu motor driver that only needs one digital and one analog pins for the turning motor DRV8835
//    https://www.pololu.com/product/2135    note: this can drive two motors but I needed the bigger driver for the 2.3 amp drivemotor

int myLeftRight        = D0;       // different motor driver does both left and right
int myTurnMotor        = A1;   //A4;  // this one must be changed since it is used by the Pixy along with A3,A4,A5

int myD7               = D7;      // to test if wifi is working
int myLast             = Time.now();   // for emergency motor stop after 4 s  no activity from the pixy

// Begin User Defined Defines
#define FRAME_SKIP 25                // How many frames to skip. Lower numbers cause faster response
// End User Defined Defines

//      #include "SPI.h"        // got rid of this since it would not compile
#include "Pixy.h"
#include "TPixy.h"

// Not sure how to flash new code so will not do this yet.
//SYSTEM_MODE(MANUAL);                // Set the system mode to manual. We don't need the cloud for this code

Pixy pixy;                          // Create our pixy object
int i = 0;                          // Create an int to count for frame skipping. Frame skipping is used to artificially slow down the pixy loop

// Setup - Runs Once @ Startup
void setup() {
//    Spark.function("my-main", myMain);
    pinMode(myDriveMotor, OUTPUT);
    pinMode(myForward, OUTPUT);
    pinMode(myBackward, OUTPUT);

    pinMode(myTurnMotor, OUTPUT);
    pinMode(myLeftRight, OUTPUT);

    pinMode(myD7, OUTPUT);

    //Serial.begin(9600);             // Initalize the USB Serial port
   // pixy.init();                    // Initalize the pixy object

    //PUT YOUR SETUP CODE HERE. Note: Only three more functions allowed!
    // test everything using the return int from a function!

    //RGB.control(true);
    //RGB.color(0, 255, 255);  //cyan
    RGB.brightness(1);    // 1=very low light, 255 = max

    Serial.begin(9600);             // Initalize the USB Serial port
    pixy.init();                    // Initalize the pixy object
}

// Loop - Runs over and over
void loop(){

        RGB.brightness(1);
    if (Time.now() >= myLast + 4){                // car may be out of control or wifi down or pixy down

         analogWrite(myDriveMotor,  0);           // shut both motors down
         analogWrite(myTurnMotor,   0);
         RGB.brightness(100);                     // show that no processing lately
    }

    // Variable Creation
    uint16_t blocks;                // Create an unsigned int to hold the number of found blocks
    char buf[50];                   // Create a buffer for printing over serial

    blocks = pixy.getBlocks();      // Do the pixy stuff. Grab the numbers of blocks the pixy finds

  // If we have some blocks increment the frame counter (i) and if enough frames have passed print out data about the found blocks to the serial port
  if (blocks) {
    myLast = Time.now();           // update time to see if car still in wifi control

    //  Deal with all the turning x = 0 - 319

    if (pixy.blocks[0].x < 150){   //object on the left so car should turn right
        digitalWrite(myLeftRight, 1);
        analogWrite(myTurnMotor,  250);
    }  else {

       if (pixy.blocks[0].x > 190){   //object on the right so car should turn left
         digitalWrite(myLeftRight, 0);
         analogWrite(myTurnMotor,  250);

       }  else {   // object in the middle so just go straight
            analogWrite(myTurnMotor,  0);

           }

    }  // end turning  main if

   // deal with the speed of the rover  width = 0 - 320

    if (pixy.blocks[0].width < 30){   //Object is very far away so go faster

        digitalWrite(myForward, 1);
        digitalWrite(myBackward, 0);
        analogWrite(myDriveMotor,  250);

    } else {

        if (pixy.blocks[0].width > 70){   //Object is very wide so it is too close so stop

            analogWrite(myDriveMotor,  0);

        }   else {   // object a good distance away go a medium speed 0-250
                    digitalWrite(myForward, 1);
                    digitalWrite(myBackward, 0);
                    analogWrite(myDriveMotor,  100);
           }
        }

  } // end blocks
}   // end loop

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


Minor comments changes

Minor comments changes

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


Update lcd_1.ino

Update lcd_1.ino

error: pathspec 'LCD' did not match any file(s) known to git
error: pathspec 'TFT' did not match any file(s) known to git
error: pathspec 'Screen/lcd_1/lcd_1.ino' did not match any file(s) known to git


Changes in spider sketch.

Changes in spider sketch.

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


Create digole_UART_20x4_test.ino

Create digole_UART_20x4_test.ino

/*----------NOTE----------
new version of lib will save your compiled code size for the sample
The size for 2 version(@Arduino V1.0.1):
            UART  I2C    SPI
OLD   8998  8988   9132
NEW  6966  7566   6354
------------------------*/
#define _Digole_Serial_UART_  //To tell compiler compile the special communication only,
//other available is: _Digole_Serial_I2C_ and _Digole_Serial_SPI_
#include "DigoleGeo.h"
//--------UART setup, if you don't use UART, use // to comment following line
DigoleSerialDisp mydisp(&Serial1, 9600); //UART:Pin 1(TX)on arduino to RX on module
//--------I2C setup, if you don't use I2C, use // to comment following 2 lines
//#include <Wire.h>
//DigoleSerialDisp mydisp(&Wire,'\x27');  //I2C:SDA (data line) is on analog input pin 4, and SCL (clock line) is on analog input pin 5
//--------SPI setup, if you don't use SPI, use // to comment following line
//DigoleSerialDisp mydisp(8,9,10);  //SPI:Pin 8: data, 9:clock, 10: SS, you can assign 255 to SS, and hard ground SS pin on module
#define LCDCol 20//16
#define LCDRow 4//2

int ptr;
const char a[] = "disp char array";
const char b = 'Q';
int c = 3456;
String d = "I'm a string";
//float pi = 3.1415926535;
double lg10;

void setup() {
    mydisp.begin();
    /*----------for text LCD adapter and graphic LCD adapter ------------*/
    mydisp.clearScreen(); //CLear screen
    //mydisp.displayConfig(1);    //set config display ON, 0=off
    //mydisp.setI2CAddress(0x29);  //this function only working when you connect using I2C, from 1 to 127
    //delay(1000);
    //mydisp.setLCDColRow(16,2);  //set LCD Col and Row, only time set up is OK
    mydisp.disableCursor(); //disable cursor, enable cursore use: enableCursor();
    mydisp.drawStr(6, 0, "Demo now"); //display string at: x=4, y=0

    //Test print function
    mydisp.setPrintPos(0, 1);
    mydisp.print(a); // display a char array
    resetpos();
    mydisp.print("display a char:");
    mydisp.print(b); //display a char
    resetpos();
    mydisp.print("int as DEC:");
    mydisp.print(c); //display 3456 in Dec
    resetpos();
    mydisp.print("as HEX:");
    mydisp.print(c, HEX); //display 3456 in Hex
    resetpos();
    mydisp.print("as OCT:");
    mydisp.print(c, OCT); //display 3456 in Oct
    resetpos();
    mydisp.print("BIN:");
    mydisp.print(c, BIN); //display 3456 in Bin
    resetpos();
    mydisp.print(d); //display String object
    resetpos();
    mydisp.print("float pi=");
    mydisp.print(pi); //display float of PI
    resetpos();
    mydisp.print("Pi6=");
    mydisp.print(pi, 6); //display PI in 6 Accuracy
    resetpos();
    mydisp.print("Pi*3=");
    mydisp.print(pi * 3, 6); //display PI time 3 in 6 Accuracy
    resetpos();
    mydisp.print("lg5=");
    mydisp.print(log(5), 8); //display log(5) in 8 Accuracy
    resetpos();
    for (uint8_t j = 0; j < 4; j++) //making "Hello" string moving
    {
        for (uint8_t i = 0; i < 10; i++) //move string to right
        {
            mydisp.setPrintPos(i, 1);
            mydisp.print(" Hello ");
            delay(100); //delay 100ms
        }
        for (uint8_t i = 0; i < 10; i++) //move string to left
        {
            mydisp.setPrintPos(9 - i, 1);
            mydisp.print(" Hello ");
            delay(100);
        }
    }
    mydisp.print("Enjoy it!");
    mydisp.enableCursor(); //enable cursor
}

void resetpos(void) //for demo use, reset display position and clean the demo line
{
    mydisp.setPrintPos(0, 1);
    delay(2000); //delay 2 seconds
    mydisp.println("                "); //display space, use to clear the demo line
    mydisp.setPrintPos(0, 1);
}
void loop() {
}

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


main firmware file

main firmware file

/*
  Created by Craig Wm. Versek, 2013-08-09
  Released into the public domain.
*/

#include <SPI.h>
#include <MCP4921_DAC12bit.h>
#include <MCP320x_ADC12bit.h>
//3rd Party Libraries
#include <SerialCommand.h>

#define V_REF  3.29
#define V_VGND V_REF/2.0
#define R_CURRSENSE 1000.0

#define DELTA_V 0.1
#define V_MIN (-V_REF/2.0 + DELTA_V)
#define V_MAX ( V_REF/2.0 - DELTA_V)
#define NUM_STEPS 100
#define DELAY_ms 100

//SerialCommand parser
SerialCommand SCmd;

//configure the DAC chip
MCP4921_DAC12bitClass control_DAC(3,     //slaveSelectLowPin
                                  3,     //ldacLowPin
                                  V_VGND //reference voltage at mid-scale
                                 );
//configure the ADC chip
MCP320x_ADC12bitClass sense_ADC(5,   //slaveSelectLowPin
                                V_REF //reference voltage at full-scale
                              );

void setup() {
  Serial.begin(9600);
  //configure the serial commands
  SCmd.addCommand("VCTRL", setControlVoltageCommand);
  SCmd.addCommand("VSWEEP", doSweepCommand);
  SCmd.setDefaultHandler(unrecognizedCommand);
  //start up the SPI bus
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE0);
  //start controlling the voltage supply
  control_DAC.begin();
  //start controlling the sampling
  sense_ADC.begin();
}

void loop() {
  //process serial commands
  SCmd.readSerial();
}

void doSweep() {
  float voltage_step = (V_MAX - V_MIN)/NUM_STEPS;
  float control_voltage;          //referenced to V_VGND
  float RE_voltage;               //referenced to power rails
  float WEtoRE_voltage;           //WE voltage referenced to RE
  float WE_current_sense_voltage; //voltage across current follower sense resistor, ref. to power rails
  float WE_current;               //compute current into WE
  Serial.println("#BEGIN VSWEEP");
  Serial.println("#COLUMNS control_voltage,WEtoRE_voltage,currentWE_in");
  for (int i=0; i <= NUM_STEPS; i++){
    control_voltage = V_MIN + voltage_step*i;
    //change output voltage
    control_DAC.setVoltageOutput(V_REF - (control_voltage + V_VGND)); //shift to center-rail and invert
    //wait for settling
    delay(DELAY_ms);
    //read signals
    RE_voltage               = sense_ADC.readSingle(0);
    WE_current_sense_voltage = sense_ADC.readSingle(1);
    //convert to centerline voltage and correct for inversion
    WEtoRE_voltage =  (RE_voltage - V_VGND);
    WE_current     = -(WE_current_sense_voltage - V_VGND)/R_CURRSENSE;
    //format as YAML
    Serial.print(control_voltage, 6);
    Serial.print(',');
    Serial.print(WEtoRE_voltage, 6);
    Serial.print(',');
    Serial.print(WE_current, 6);
    Serial.print('\n');
    //while (Serial.read() != '\n'){};
  }
  Serial.println("#END VSWEEP");
}

//------------------------------------------------------------------------------
//COMMAND HANDLER FUNCTIONS - called by the SCmd dispatcher

void setControlVoltgeCommand(){
    float control_voltage;
    char *arg;
    arg = SCmd.next();
    if (arg != NULL)
    {
        control_voltage = atof(arg);
        control_DAC.setVoltageOutput(V_REF - (control_voltage + V_VGND)); //shift to center-rail and invert
    }
    else
    {
        Serial.println("### Error: VCTRL requires 1 argument (float control_voltage) ###");
    }
}

void doSweepCommand(){
    char *arg;
    arg = SCmd.next();
    if (arg != NULL)
    {
        Serial.println("### Error: VSWEEP requires 0 arguments ###");
    }
    else
    {
       doSweep();
    }
}

void unrecognizedCommand(const char *command)
{
    Serial.println("### Error: command not recognized ###");
}

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


dedicated coil-pin 9 and 8

dedicated coil-pin 9 and 8

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


Added files via upload

Added files via upload

//
// Microphone to Speaker output
#define NUMEL(x) (sizeof(x)/sizeof((x)[0])) // retuns/calculates the size of an array

#include "NLMS2.h"
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

//*****functions**********
void getBuffer1();
void playData();
void displayData();
void NLMS_AEC1();
int64_t dotp();

// GUItool: begin automatically generated code
AudioInputI2S            Mic;           //microphone
AudioPlayQueue           MicMem;         //queue for microphone
AudioRecordQueue         Memory;
AudioOutputI2S           headphones;           //output
AudioConnection          patchCord1(Mic, 0, Memory, 0);
AudioConnection          patchCord2(MicMem, 0, headphones,0);
AudioConnection          patchCord3(MicMem, 0, headphones,1);
AudioControlSGTL5000     sgtl5000_1;     //xy=339.6666564941406,285.6666488647461

const int numBlocks = 8; //min block size is 2!!!!!!
const int lFilt = numBlocks-1;
const int gg = lFilt*128;
int16_t *pAddr; //pointer to 128 block of getBuffer
int16_t lblock = numBlocks*128; //length of arrays
int16_t ablock[128*numBlocks];  // set an array block
int16_t error[128];
int16_t *Perror;
int16_t *pablock; // pointer to an array block
int16_t *pp; // pointer to getBuffer
int n;
unsigned long time1; // time variable

//***************NMLS const and settings*************************
const int16_t numTaps = gg;
int64_t mu = 1;
int32_t mu0 = 0;
int8_t psi = 1;
int32_t w[numTaps];
int32_t *pw; // pointer to w
int16_t yhat = 0;
//int64_t xtdl = 1;
int16_t y12 = gg/2;
int i = 0;

//define input/source
const int micInput = AUDIO_INPUT_MIC;

void setup() {
  mu = 34359738368*mu;  // scale mu
  memset(w,0,numTaps);
  memset(ablock,100,128*numBlocks*2);
  memset(error,0,128*2);
  //initialize pointers for NLMS
  pw = w;
  Perror = error;
  Serial.begin(9600); // initiate baud rate for serial comm.
  AudioMemory(8); // allocate # of audio memory (each block has 128 sample of data)
  sgtl5000_1.enable(); // enalbe
  sgtl5000_1.volume(0.5); // output volume
  sgtl5000_1.inputSelect(micInput); //input selection (mic or line in)
  sgtl5000_1.micGain(30); // mic gain
  //set array values to zero
  pablock = ablock; // assign pointer to array
  delay(1000);
}

//***************************MAIN LOOP********************************************************************
void loop() {
Serial.println(micros()); // print time
getBuffer1(numBlocks); //returns pointer to the buffered dat
//print sample to serial plotter
//displayData(pablock); // print data to serial plotter
//NLMS_AEC(pablock,pablock);
//NLMS_AEC(pablock,pablock,Perror,pw,gg,mu,4,pxtdl);
//for(int i = gg; i<gg+128;i+=1){
//  Serial.println(ablock[i]);
//}
}

//*********************************************************************************************************
// print data to serial plotter
void displayData(int16_t * data){
  for(int i = 0; i<128*numBlocks;i++){
  Serial.println(*(data+i));
  }
}
// play data to speaker
void playData(void){
    pAddr = MicMem.getBuffer(); //get pointer to 128 array playBuffer
    // take one block from buffer array (ablock) and copy it to playBuffer pointer
    // play that block
    memcpy((byte*)pAddr,(byte*)error,256);
    MicMem.playBuffer();
}

// buffer an array with samples from Microphone
// function receives and array and integer indicating number of blocks
void getBuffer1(int x){
  Memory.begin(); // begin putting sample data into memory
  int l = 0;
  memcpy((byte*)pablock,(byte*)pablock+256,256*(x-1));
  // put 128 blocks of sample into an array size of 128*(number of blocks)
    while(l == 0){ // wait until block samples are available
      if(Memory.available() ==1) {// if availabe copy 128 block to array and get out of while loop
        //read one 128 block of samples and copy it into array
        memcpy((byte*)pablock+(256*(x-1)),Memory.readBuffer(),256);
        Memory.freeBuffer(); // free buffer memory
        l = 1; // set n to 1 to get out of while loop
      }//end if
    }//end while
    l = 0;
   Memory.clear(); // clear all audio memory
   Memory.end();
   NLMS_AEC(pablock,pablock,Perror,pw,gg,mu,5,1);
   playData(); // play 128 block from buffered array
//   return ablock; // regurn pointer to array
}

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


Create USB_PS3_Example.ino

Create USB_PS3_Example.ino

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


midicontroller1

midicontroller1

first shot at a homebrew controller

#include <Encoder.h> // Include the Encoder library.
// This must be done before the Control Surface library.
#include <Control_Surface.h> // Include the Control Surface library

USBMIDI_Interface midi;

// Instantiate a CCButton object
CCButton button = {
  // Push button on pin 5:
  5,
  // General Purpose Controller #1 on MIDI channel 1:
  {MIDI_CC::General_Purpose_Controller_5, CHANNEL_1},
};

// Instantiate a CCRotaryEncoder object
CCRotaryEncoder enc = {
  {2, 3},       // pins
  MCU::V_POT_4, // MIDI address (CC number + optional channel)
  1,            // optional multiplier if the control isn't fast enough
};

// Instantiate a CCPotentiometer object
CCPotentiometer potentiometer0 = {
  A0,                                   // Analog pin connected to potentiometer
  {MIDI_CC::Channel_Volume, CHANNEL_1}, // Channel volume of channel 1
};
CCPotentiometer potentiometer1 = {
  A1,                                   // Analog pin connected to potentiometer
  {MIDI_CC::General_Purpose_Controller_1, CHANNEL_1}, // General_Purpose_Controller_1 of channel 1
};
CCPotentiometer potentiometer2 = {
  A2,                                   // Analog pin connected to potentiometer
  {MIDI_CC::General_Purpose_Controller_2, CHANNEL_1}, // General_Purpose_Controller_2 of channel 1
};
CCPotentiometer potentiometer3 = {
  A3,                                   // Analog pin connected to potentiometer
  {MIDI_CC::General_Purpose_Controller_3, CHANNEL_1}, // General_Purpose_Controller_3 of channel 1
};

// The note numbers corresponding to the buttons in the matrix
const int noteOffset = 36;
const AddressMatrix<4, 3> addresses = {{
  {72-noteOffset, 73-noteOffset, 74-noteOffset},
  {75-noteOffset, 76-noteOffset, 77-noteOffset},
  {78-noteOffset, 79-noteOffset, 80-noteOffset},
  {81-noteOffset, 82-noteOffset, 83-noteOffset},
}};

NoteButtonMatrix<4, 3> buttonmatrix = {
  {10, 16, 14, 15}, // row pins
  {9, 8, 7},    // column pins
  addresses,    // address matrix
  CHANNEL_1,    // channel and cable number
};

analog_t reversePot(analog_t raw) {
    // map the value from [minimumValue, maximumValue] to [0, 16383]
    return map(raw, 0, 16383, 16383, 0);
}

void setup() {
  potentiometer0.map(reversePot);
  potentiometer1.map(reversePot);
  potentiometer2.map(reversePot);
  potentiometer3.map(reversePot);

  // Select the correct relative MIDI CC mode.
  // Options:
  //   - TWOS_COMPLEMENT (default)
  //   - BINARY_OFFSET
  //   - SIGN_MAGNITUDE
  // Aliases:
  //   - REAPER_RELATIVE_1
  //   - REAPER_RELATIVE_2
  //   - REAPER_RELATIVE_3
  //   - TRACKTION_RELATIVE
  //   - MACKIE_CONTROL_RELATIVE
  RelativeCCSender::setMode(relativeCCmode::MACKIE_CONTROL_RELATIVE);
  Control_Surface.begin();
}

void loop() {
  Control_Surface.loop();
}

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


Created automatic switch example

Created automatic switch example

#include "particle-dst.h"

DST dst;

dst_limit_t beginning;
dst_limit_t end;

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

  beginning.hour = 2;
  beginning.day = 3; // tuesday
  beginning.month = 2; // february
  beginning.occurrence = 2;

  end.hour = 3;
  end.day = 4; // wednesday
  end.month = 10; // october
  end.occurrence = 2;

  dst.begin(beginning, end, 1);
  dst.automatic(true);
}

void loop() {

}

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


Add IR sensor readings

Add IR sensor readings

Distance (in centimeters) read by IR sensor

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/tms1337/inverted-pendulum.git/'


REV11 minimal test

REV11 minimal test

/*
The OpenTRV project licenses this file to you
under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance
with the Licence. You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the Licence is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the Licence for the
specific language governing permissions and limitations
under the Licence.

Author(s) / Copyright (s): Deniz Erbilgin 2017
*/
/**
 * Minimal REV11 config for testing power consumption.
 * Aim is to:
 *     - init GPIO pins to safe mode.
 *     - init peripherals to safe low power mode.
 *     - loop endlessly.
 */

// INCLUDES & DEFINES
// Debug output flag
#define DEBUG
// REV11 as Sensor with secure TX.
#define CONFIG_REV11_SECURE_SENSOR //XXX
// Get defaults for valve applications.
#include <OTV0p2_valve_ENABLE_defaults.h>
// All-in-one valve unit (DORM1).
#include <OTV0p2_CONFIG_REV11.h>
// I/O pin allocation and setup: include ahead of I/O module headers.
#include <OTV0p2_Board_IO_Config.h>
// OTV0p2Base Libraries
#include <OTV0p2Base.h>
// Radio Libraries
//#include <OTRadioLink.h>
#include <OTRFM23BLink.h>
// RadValve libraries
#include <OTRadValve.h>

// Debugging output
#ifndef DEBUG
#define DEBUG_SERIAL_PRINT(s) // Do nothing.
#define DEBUG_SERIAL_PRINTFMT(s, format) // Do nothing.
#define DEBUG_SERIAL_PRINT_FLASHSTRING(fs) // Do nothing.
#define DEBUG_SERIAL_PRINTLN_FLASHSTRING(fs) // Do nothing.
#define DEBUG_SERIAL_PRINTLN() // Do nothing.
#define DEBUG_SERIAL_TIMESTAMP() // Do nothing.
#else
// Send simple string or numeric to serial port and wait for it to have been sent.
// Make sure that Serial.begin() has been invoked, etc.
#define DEBUG_SERIAL_PRINT(s) { OTV0P2BASE::serialPrintAndFlush(s); }
#define DEBUG_SERIAL_PRINTFMT(s, fmt) { OTV0P2BASE::serialPrintAndFlush((s), (fmt)); }
#define DEBUG_SERIAL_PRINT_FLASHSTRING(fs) { OTV0P2BASE::serialPrintAndFlush(F(fs)); }
#define DEBUG_SERIAL_PRINTLN_FLASHSTRING(fs) { OTV0P2BASE::serialPrintlnAndFlush(F(fs)); }
#define DEBUG_SERIAL_PRINTLN() { OTV0P2BASE::serialPrintlnAndFlush(); }
// Print timestamp with no newline in format: MinutesSinceMidnight:Seconds:SubCycleTime
extern void _debug_serial_timestamp();
#define DEBUG_SERIAL_TIMESTAMP() _debug_serial_timestamp()
#endif // DEBUG

// OBJECTS & VARIABLES
/**
 * Peripherals present on REV7
 * - Pot        Set input to Hi-Z?  +
 * - PHT        IO_POWER_UP LOW
 * - Encoder    IO_POWER_UP LOW
 * - LED        Set pin HIGH?
 * - Button     Set to INPUT
 * - H-Bridge   Control pins HIGH, Current sense set to input.  +
 * - SHT21      read() once.        +
 * - RFM23B     ??                  +
 * - XTAL       Setup and leave running?
 * - UART       Disable
 */

/**
 * Dummy Types
 */
// Placeholder class with dummy static status methods to reduce code complexity.
typedef OTV0P2BASE::DummySensorOccupancyTracker OccupancyTracker;

/**
 * Supply Voltage instance
 */
// Sensor for supply (eg battery) voltage in millivolts.
// Singleton implementation/instance.
OTV0P2BASE::SupplyVoltageCentiVolts Supply_cV;

/*
 * Radio instance
 */
static constexpr bool RFM23B_allowRX = false;

static constexpr uint8_t RFM23B_RX_QUEUE_SIZE = OTRFM23BLink::DEFAULT_RFM23B_RX_QUEUE_CAPACITY;
static constexpr int8_t RFM23B_IRQ_PIN = -1;// PIN_RFM_NIRQ;
OTRFM23BLink::OTRFM23BLink<OTV0P2BASE::V0p2_PIN_SPI_nSS, RFM23B_IRQ_PIN, RFM23B_RX_QUEUE_SIZE, RFM23B_allowRX> PrimaryRadio;
// Pick an appropriate radio config for RFM23 (if it is the primary radio).
// Nodes talking on fast GFSK channel 0.
static const uint8_t nPrimaryRadioChannels = 1;
static const OTRadioLink::OTRadioChannelConfig RFM23BConfigs[nPrimaryRadioChannels] = {
    // GFSK channel 0 full config, RX/TX, not in itself secure.
    OTRadioLink::OTRadioChannelConfig(OTRFM23BLink::StandardRegSettingsGFSK57600, true), };

/*
 * SHT21 instance
 */
OTV0P2BASE::RoomTemperatureC16_SHT21 TemperatureC16; // SHT21 impl.

// HUMIDITY_SENSOR_SUPPORT is defined if at least one humidity sensor has support compiled in.
// Simple implementations can assume that the sensor will be present if defined;
// more sophisticated implementations may wish to make run-time checks.
// If SHT21 support is enabled at compile-time then its humidity sensor may be used at run-time.
// Singleton implementation/instance.
typedef OTV0P2BASE::HumiditySensorSHT21 RelHumidity_t;
RelHumidity_t RelHumidity;

/**
 * Ambient Light Sensor
 */
typedef OTV0P2BASE::SensorAmbientLight AmbientLight;
// Singleton implementation/instance.
AmbientLight AmbLight;

// FUNCTIONS

/**
 * Panic Functions
 */
// Indicate that the system is broken in an obvious way (distress flashing the main LED).
// DOES NOT RETURN.
// Tries to turn off most stuff safely that will benefit from doing so, but nothing too complex.
// Tries not to use lots of energy so as to keep distress beacon running for a while.
void panic()
{
    // Reset radio and go into low-power mode.
    PrimaryRadio.panicShutdown();
    // Power down almost everything else...
    OTV0P2BASE::minimisePowerWithoutSleep();
    pinMode(OTV0P2BASE::LED_HEATCALL_L, OUTPUT);
    for( ; ; )
    {
        OTV0P2BASE::LED_HEATCALL_ON();
        OTV0P2BASE::nap(WDTO_15MS);
        OTV0P2BASE::LED_HEATCALL_OFF();
        OTV0P2BASE::nap(WDTO_120MS);
    }
}
// Panic with fixed message.
void panic(const __FlashStringHelper *s)
{
    OTV0P2BASE::serialPrintlnAndFlush(); // Start new line to highlight error.  // May fail.
    OTV0P2BASE::serialPrintAndFlush('!'); // Indicate error with leading '!' // May fail.
    OTV0P2BASE::serialPrintlnAndFlush(s); // Print supplied detail text. // May fail.
    panic();
}

/**
 * @brief   Set pins and on-board peripherals to safe low power state.
 */

//========================================
// SETUP
//========================================

// Setup routine: runs once after reset.
// Does some limited board self-test and will panic() if anything is obviously broken.
void setup()
{
    // Set appropriate low-power states, interrupts, etc, ASAP.
    OTV0P2BASE::powerSetup();
    // IO setup for safety, and to avoid pins floating.
    OTV0P2BASE::IOSetup();

    OTV0P2BASE::serialPrintAndFlush(F("\r\nOpenTRV: ")); // Leading CRLF to clear leading junk, eg from bootloader.
    V0p2Base_serialPrintlnBuildVersion();

    OTV0P2BASE::LED_HEATCALL_ON();

    // Give plenty of time for the XTal to settle.
    delay(1000);

    // Have 32678Hz clock at least running before going any further.
    // Check that the slow clock is running reasonably OK, and tune the fast one to it.
    if(!::OTV0P2BASE::HWTEST::calibrateInternalOscWithExtOsc()) { panic(F("Xtal")); } // Async clock not running or can't tune.
//    if(!::OTV0P2BASE::HWTEST::check32768HzOsc()) { panic(F("xtal")); } // Async clock not running correctly.

    // Initialise the radio, if configured, ASAP because it can suck a lot of power until properly initialised.
    PrimaryRadio.preinit(NULL);
    // Check that the radio is correctly connected; panic if not...
    if(!PrimaryRadio.configure(nPrimaryRadioChannels, RFM23BConfigs) || !PrimaryRadio.begin()) { panic(F("r1")); }

    // Collect full set of environmental values before entering loop() in normal mode.
    // This should also help ensure that sensors are properly initialised.

    // No external sensors are *assumed* present if running alt main loop
    // This may mean that the alt loop/POST will have to initialise them explicitly,
    // and the initial seed entropy may be marginally reduced also.
    const int cV = Supply_cV.read();
    DEBUG_SERIAL_PRINT_FLASHSTRING("V: ");
    DEBUG_SERIAL_PRINT(cV);
    DEBUG_SERIAL_PRINTLN();
    const int heat = TemperatureC16.read();
    DEBUG_SERIAL_PRINT_FLASHSTRING("T: ");
    DEBUG_SERIAL_PRINT(heat);
    DEBUG_SERIAL_PRINTLN();
    const uint8_t rh = RelHumidity.read();
    DEBUG_SERIAL_PRINT_FLASHSTRING("RH%: ");
    DEBUG_SERIAL_PRINT(rh);
    DEBUG_SERIAL_PRINTLN();
    const int light = AmbLight.read();
    DEBUG_SERIAL_PRINT_FLASHSTRING("L: ");
    DEBUG_SERIAL_PRINT(light);
    DEBUG_SERIAL_PRINTLN();

    // Initialised: turn main/heatcall UI LED off.
    OTV0P2BASE::LED_HEATCALL_OFF();

    // Do OpenTRV-specific (late) setup.
    PrimaryRadio.listen(false);

    // Long delay after everything set up to allow a non-sleep power measurement.
    delay(10000);
}

//========================================
// MAIN LOOP
//========================================
/**
 * @brief   Sleep in low power mode if not sleeping.
 */
void loop()
{
    // Ensure that serial I/O is off while sleeping.
    OTV0P2BASE::powerDownSerial();
    // Power down most stuff (except radio for hub RX).
    OTV0P2BASE::minimisePowerWithoutSleep();
    // Normal long minimal-power sleep until wake-up interrupt.
    // Rely on interrupt to force quick loop round to I/O poll.
    OTV0P2BASE::sleepUntilInt();
}

/**
 * @note    Power consumption figures (all in mA).
 * Date/commit:         Device: Wake (Sleep) @ Voltage
 * 20161111/0e6ec96     REV7:   1.5 (1.1) @ 2.5 V       REV11:  0.45 (0.03) @ 2.5 V
 * 20161111/f2eed5e     REV7:   0.46 (0.04) @ 2.5 V
 */

error: pathspec 'Arduino/hardware/REV11/testsuite/20170110/REV11Minimal/REV11Minimal.ino' did not match any file(s) known to git


upload utilities folder

upload utilities folder

// test LCD screen dimensions with 2 pots connected on A0 and A1 (x, y)

#include <UTFT.h>
#define DEBUG 0

int x, y;

UTFT lcd(CTE32HR,38,39,40,41);

void setup(){
  lcd.InitLCD();
  if(DEBUG)Serial.begin(9600);
  lcd.fillScr(VGA_BLACK);
}

void loop(){
  x = analogRead(A0);
  y = analogRead(A1);

  if(DEBUG){
    Serial.print("x: ");
    Serial.print(x);
    Serial.print(" | y: ");
    Serial.println(y);
  }

//  lcd.fillScr(VGA_BLACK);
  //lcd.clrScr();
  lcd.setColor(VGA_GREEN);
  lcd.fillRect(0, 0, x, y);

  delay(50);
}

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