door alarm to slack

door alarm to slack

// slackbot testing using https://github.com/urish/arduino-slack-bot
/**
   Arduino Real-Time Slack Bot
   Copyright (C) 2016, Uri Shaked.
   Licensed under the MIT License
*/

/*
 modified by chaeplin @ gmail.com
 */

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <ESP8266HTTPClient.h>
#include <WebSocketsClient.h>
#include <ArduinoJson.h>

extern "C" {
#include "user_interface.h"
}

#include "/usr/local/src/ap_setting.h"
#include "/usr/local/src/slack_door_setting.h"

// slack.com : Expires: Saturday, 2 February 2019 at 08:59:59 Korean Standard Time
const char* api_fingerprint = "AC 95 5A 58 B8 4E 0B CD B3 97 D2 88 68 F5 CA C1 0A 81 E3 6E";

#define DOOR_PIN 14

//#define SLACK_BOT_TOKEN "put-your-slack-token-here"
//#define SLACK_CHANNEL "xxxxxx"
//#define SLACK_USER "xxxxxxx"
//#define SLACK_TEAM "xxxxxx"

//#define WIFI_SSID       "wifi-name"
//#define WIFI_PASSWORD   "wifi-password"

WiFiClientSecure sslclient;
WebSocketsClient webSocket;

long nextCmdId = 1;
bool connected = false;

volatile bool bdoor_isr;
bool door_status;
volatile uint32_t door_interuptCount = 0;
uint32_t prev_interuptCount = 0;

void ICACHE_RAM_ATTR door_isr() {
  if (bdoor_isr == false) {
    door_interuptCount++;
    bdoor_isr = true;
  }
}

void sendCheck()
{
  DynamicJsonBuffer jsonBuffer;
  JsonObject& root = jsonBuffer.createObject();
  root["type"] = "message";
  root["id"] = nextCmdId++;
  root["channel"] = SLACK_CHANNEL;

  String msg = "door status : ";
  if (door_status) {
    msg += "open";
  } else {
    msg += "closed";
  }

  root["text"] = msg.c_str();
  String json;
  root.printTo(json);
  webSocket.sendTXT(json);
}

/**
  Sends a ping message to Slack. Call this function immediately after establishing
  the WebSocket connection, and then every 5 seconds to keep the connection alive.
*/
void sendPing()
{
  DynamicJsonBuffer jsonBuffer;
  JsonObject& root = jsonBuffer.createObject();
  root["type"] = "ping";
  root["id"] = nextCmdId++;
  String json;
  root.printTo(json);
  webSocket.sendTXT(json);
}

void sendHello()
{
  DynamicJsonBuffer jsonBuffer;
  JsonObject& root = jsonBuffer.createObject();
  root["type"] = "message";
  root["id"] = nextCmdId++;
  root["channel"] = SLACK_CHANNEL;
  root["text"] = "Hello world";
  String json;
  root.printTo(json);
  webSocket.sendTXT(json);
}

void ICACHE_RAM_ATTR processSlackMessage(String receivedpayload)
{
  char json[] = "{\"type\":\"message\",\"channel\":\"XXXXXXXX\",\"user\":\"XXXXXXXX\",\"text\":\"xxxxxxxxxxxx\",\"ts\":\"1491047008.621282\",\"source_team\":\"XXXXXXXX\",\"team\":\"XXXXXXXX\"}";
  receivedpayload.toCharArray(json, 1204);
  StaticJsonBuffer<1024> jsonBuffer;
  JsonObject& root = jsonBuffer.parseObject(json);

  if (!root.success()) {
    Serial.println("root failed");
    return;
  }
  if (root.containsKey("text"))
  {
    const char* text = root["text"];
    Serial.printf("[Processing] text: %s\n", text);

    if (String(text) == "check")
    {
      sendCheck();
    }

  }
}

/**
  Called on each web socket event. Handles disconnection, and also
  incoming messages from slack.
*/
void webSocketEvent(WStype_t type, uint8_t *payload, size_t len)
{
  switch (type) {
    case WStype_DISCONNECTED:
      Serial.printf("[WebSocket] Disconnected :-( \n");
      connected = false;
      break;

    case WStype_CONNECTED:
      Serial.printf("[WebSocket] Connected to: %s\n", payload);
      sendPing();
      webSocket.loop();
      sendHello();
      break;

    case WStype_TEXT:
      Serial.printf("[WebSocket] Message: %s\n", payload);

      String receivedpayload;
      for (int i = 0; i < len; i++)
      {
        receivedpayload += (char)payload[i];
      }
      if (receivedpayload.startsWith("{\"type\":\"message"))
      {
        if (receivedpayload.indexOf(SLACK_CHANNEL) != -1 &&
            receivedpayload.indexOf(SLACK_USER) != -1 &&
            receivedpayload.indexOf(SLACK_TEAM) != -1 )
        {
          processSlackMessage(receivedpayload);
        }
      }
      break;
  }
}

/**
  Establishes a bot connection to Slack:
  1. Performs a REST call to get the WebSocket URL
  2. Conencts the WebSocket
  Returns true if the connection was established successfully.
*/
bool connectToSlack()
{
  // Step 1: Find WebSocket address via RTM API (https://api.slack.com/methods/rtm.start)
  HTTPClient http;
  String uri_to_post = "/api/rtm.start?token=";
  uri_to_post += SLACK_BOT_TOKEN;

  http.begin("slack.com", 443, uri_to_post, api_fingerprint);
  int httpCode = http.GET();
  if (httpCode != HTTP_CODE_OK)
  {
    Serial.printf("HTTP GET failed with code %d\n", httpCode);
    return false;
  }

  WiFiClient *client = http.getStreamPtr();
  client->find("wss:\\/\\/");
  String host = client->readStringUntil('\\');
  String path = client->readStringUntil('"');
  path.replace("\\/", "/");

  // Step 2: Open WebSocket connection and register event handler
  Serial.println("WebSocket Host=" + host + " Path=" + path);
  webSocket.beginSSL(host, 443, path, "", "");
  webSocket.onEvent(webSocketEvent);
  return true;
}

void setup() {
  Serial.begin(115200);
  //Serial.setDebugOutput(true);

  pinMode(DOOR_PIN, INPUT_PULLUP);
  bdoor_isr = false;
  attachInterrupt(DOOR_PIN, door_isr, CHANGE);

  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(100);
  }

  configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov");
}

unsigned long lastPing = 0;

/**
  Sends a ping every 5 seconds, and handles reconnections
*/
void loop()
{
  webSocket.loop();

  if (bdoor_isr) {
    door_status = digitalRead(DOOR_PIN);
    Serial.print("[door_status] ---> bdoor_isr detected : ");
    Serial.print(door_status);
    Serial.print(" door_interuptCount : ");
    Serial.println(door_interuptCount);
    sendCheck();
    bdoor_isr = false;
  }

  if (connected) {
    // Send ping every 5 seconds, to keep the connection alive
    if (millis() - lastPing > 5000)
    {
      sendPing();
      lastPing = millis();
    }
  }
  else
  {
    // Try to connect / reconnect to slack
    connected = connectToSlack();
    if (!connected)
    {
      delay(500);
    }
  }
}

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


Create change_color_with_button.ino

Create change_color_with_button.ino

//***************************************************************
// The whole strip will show the same color.  When the button
// is pressed and held down the strip will cycle through the
// rainbow.  Release the button to stop on a new color.
//
// This is how the button is wired for this example:
// http://i.imgur.com/hOgQwjX.jpg
//
// Marc Miller, Jan 2019
//***************************************************************

//---------------------------------------------------------------
// This sketch uses JChristensen's Button Library from:
//   https://github.com/JChristensen/Button
//
#include "Button.h"    // Include the Button library

// Set the digital pin for the pushbutton, and declare the button
const uint8_t ButtonPin = 4;
Button Push_Button(ButtonPin, true, true, 100);

//---------------------------------------------------------------
#include "FastLED.h"
#define DATA_PIN    11
#define CLK_PIN   13
#define LED_TYPE    LPD8806
#define COLOR_ORDER GRB
#define NUM_LEDS    32
CRGB leds[NUM_LEDS];
#define BRIGHTNESS 128

uint8_t hue;

//---------------------------------------------------------------
void setup() {
  Serial.begin(115200);  // Allows serial monitor output (check baud rate)
  delay(1500); // Startup delay
  //FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(BRIGHTNESS);
  FastLED.clear();
}

//---------------------------------------------------------------
void loop()
{
  readbutton();  // check the button to see if it's pressed

  fill_solid( leds, NUM_LEDS, CHSV(hue,255,255) );  //set color of pixels

  FastLED.show();  // display the pixels

}//end_main_loop

//---------------------------------------------------------------
//Check the button and set the appropriate flag
void readbutton() {
  Push_Button.read();  // check the state of the button

  if(Push_Button.isPressed()) {
    // To make the color change faster when the button is
    // held down, you can either reduce the value of
    // EVERY_N_MILLISECONDS, or you can add a larger value
    // to hue so it increments faster.
    // You can also subtract a value from hue to cycle
    // through the color wheel in the oposite direction.

    EVERY_N_MILLISECONDS(20) {
      hue = hue + 1;   //can be either + or - some value
    }
  }
}//end_readbutton

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


Add example of a custom function in serial

#include "VdlkinoSerial.h"

VdlkinoSerial vdlkino(14, 6, &Serial);

uint16_t get_analog_byte(void *block) {
  VdlkinoBlock *vblock = (VdlkinoBlock*) block;
  return map(analogRead(vblock->pin), 0, 1023, 0, 255);
}

void setup() {
  Serial.begin(9600);
  vdlkino.operations[8] = &get_analog_byte;
}

void loop() {
  vdlkino.run();
}

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


Add a simple example sketch with many explanatory comments

/*
NeoPixel Ring simple sketch (c) 2013 Shae Erisson
released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
*/
#include <Adafruit_NeoPixel.h>
#ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc.
  #include <avr/power.h>
#endif

// Which pin on the FLORA is connected to the NeoPixel ring?
#define PIN            6

// We're using only one ring with 16 NeoPixel
#define NUMPIXELS      16

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 500; // delay for half a second

void setup() {
#ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc.
  if(F_CPU == 16000000) clock_prescale_set(clock_div_1);
  // Seed random number generator from an unused analog input:
  randomSeed(analogRead(2));
#else
  randomSeed(analogRead(A0));
#endif
  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {
  // for one ring of 16, the first NeoPixel is 0, second is 1, all the way up to 15
  for(int i=0;i<NUMPIXELS;i++){
    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i,pixels.Color(0,150,0)); // we choose green
    pixels.show(); // this sends the value once the color has been set
    delay(delayval);
  }
}

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


Added Michael Shiloh's WifiSignalStrengthIndicator example

/*
 Wifi Signal Strength Indicator

 This example demonstrates the use of the bridge and process libraries
 to communicate between the Arduino side and the linux side of the Arduino Yun.

 The Linux script returns the strength of the wifi signal.

 The Arduino sketch uses LEDs to indicate whether the current value of
 the signal strength is above, below, or the same as the last value

 The circuit:
 * LEDs on pins 8, 9, and 10
 * Built-in LED on pin 13

 The script:
 The following one line script must exist in the /root directory of the
 linux file system, in a file named "wifiStrength.sh", and it must be executable:

 tail -1 /proc/net/wireless | cut  -c22-23

 created 06 June 2013
 by Michael Shiloh
 modified 08 June 2013
 by Tom Igoe

 This example code is in the public domain

 */

#include <Process.h>

// global variable to store the last value of the signal strength
int lastValue;

void setup() {
  // set up LED pins as outputs:
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(13,OUTPUT);

  // Indicate that you're ready by flashing pin 13 LED twice
  for (int flash = 0; flash < 3; flash++) {
    digitalWrite(13,HIGH);
    delay(200);
    digitalWrite(13,LOW);
    delay(800);
  }
  // initialize Serial and Bridge:
  Serial.begin(9600);
  Bridge.begin();

  // Indicate that setup is finished
  digitalWrite(13,HIGH);
}

void loop() {
  int value = 0;      // the signal strength as an integer
  String result;      // the result of the process as a String
  Process wifiCheck;  // the process itself

  // Run the script on the linux side. Note that any word
  //or text separated by a tab or space is considered
  //an additional parameter:
  wifiCheck.begin("ash");
  wifiCheck.addParameter("/root/wifiStrength.sh");
  wifiCheck.run();

  // If the process has sent any characters:
  while (wifiCheck.available()>0) {
    result = wifiCheck.readString(); // read the result into a string
    value = result.toInt();  // parse the string as an int
  }

  //  for debugging
  Serial.print("previous strength:");
  Serial.print(lastValue);
  Serial.print("\tcurrent strength:");
  Serial.println(value);

  // indicate the relative string by lighting the appropriate LED
  allOff();      // turn off all the LEDS

  if (value > lastValue) {     // if the signal's getting stronger
    digitalWrite(10, HIGH);
  }
  else if (value < lastValue){ // if the signal's getting weaker
    digitalWrite(8, HIGH);
  }
  else {                       // if the signal's stayed steady
    digitalWrite(9, HIGH);
  }

  lastValue = value; // record this value for next time
  delay(10);      // small delay before next time through the loop
}

void allOff() {
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
}

error: pathspec 'hardware/arduino/avr/libraries/Bridge/examples/WifiSignalStrengthIndicator/WifiSignalStrengthIndicator.ino' did not match any file(s) known to git


Added Arduino buzzer project

Added Arduino buzzer project

int speakerPin = 3;

int length = 15; // the number of notes

//twinkle twinkle little star
char notes[] = "ccggaag ffeeddc ggffeed ggffeed ccggaag ffeeddc "; // a space represents a rest
int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 };
int tempo = 300;

void playTone(int tone, int duration) {
  for (long i = 0; i < duration * 1000L; i += tone * 2) {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(tone);
  }
}

void playNote(char note, int duration) {
  char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
  int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };

  // play the tone corresponding to the note name
  for (int i = 0; i < 8; i++) {
    if (names[i] == note) {
      playTone(tones[i], duration);
    }
  }
}

void play() {
  for (int i = 0; i < length; i++) {
    if (notes[i] == ' ') {
      delay(beats[i] * tempo); // rest
    } else {
      playNote(notes[i], beats[i] * tempo);
    }

    // pause between notes
    delay(tempo / 2);
  }
  noTone(speakerPin);
}

void setup() {
  pinMode(speakerPin, OUTPUT);
  pinMode(4, INPUT);
}

void loop() {
  int i = 0;
  i = digitalRead(4);
  if (i == 1) {
    play();
  }
}

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


Created programmer using datasheet, not working correctly yet.

// Arduino RN2483 programmer
// Implemented using http://ww1.microchip.com/downloads/en/DeviceDoc/41398B.pdf
#define MCLR 4
#define PGD 5
#define PGC 6

int keyseq[]  = {0,1,0,0, 1,1,0,1, 0,1,0,0, 0,0,1,1, 0,1,0,0, 1,0,0,0, 0,1,0,1, 0,0,0,0};

void setup() {
  // put your setup code here, to run once:
  SerialUSB.begin(57600);

  // Wait for serialUSB or start after 30 seconds
  while ((!SerialUSB) && (millis() < 30000));
  SerialUSB.write("SerialUSB set up\r\n");

  // Initialize LED
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);

  // Initialize pins
  pinMode(MCLR, OUTPUT);
  pinMode(PGD, OUTPUT);
  pinMode(PGC, OUTPUT);
  digitalWrite(MCLR, LOW);
  digitalWrite(PGD, LOW);
  digitalWrite(PGC, LOW);

  // Wiggle MCLR
  digitalWrite(MCLR, HIGH);
  delay(10);
  digitalWrite(MCLR, LOW);
  delay(10);
  digitalWrite(MCLR, HIGH);
  delay(10);

  // Entering low-voltage program/verify mode
  enterLVP();
}

// Enter low-voltage program/verify mode
void enterLVP() {
  SerialUSB.write("Entering low-voltage program/verify mode\r\n");

  // Pull all programming pins Low
  digitalWrite(MCLR, LOW);
  digitalWrite(PGD, LOW);
  digitalWrite(PGC, LOW);

  // Wait atleast 100ns (P13)
  delayMicroseconds(1);

  // Set MCLR High then Low
  digitalWrite(MCLR, HIGH);
  delayMicroseconds(1);
  digitalWrite(MCLR, LOW);

  // Wait atleast 1ms (P18)
  delayMicroseconds(2);

  // Enter key sequence on PGD
  for (int n = 0; n < 32; n++) {
    //Lower PGC and write bit to PGD
    digitalWrite(PGC, LOW);
    digitalWrite(PGD, keyseq[n]);
    delayMicroseconds(1);

    //Raise PGC to send bit
    digitalWrite(PGC, HIGH);
    delayMicroseconds(1);
  }
  digitalWrite(PGC, LOW);

  // Wait atleast 40ns
  delayMicroseconds(1);

  // Set MCLR High
  digitalWrite(MCLR, HIGH);

  // Wait atleast 400us
  delayMicroseconds(450);
}

// Exit low-voltage program/verify mode
void exitLVP() {
  SerialUSB.write("Exiting low-voltage program/verify mode\r\n");
  delayMicroseconds(1);
  digitalWrite(MCLR, LOW);
  delayMicroseconds(10);
  digitalWrite(MCLR, HIGH);
}

// Serial program/verify operation
int sendOp(int cmd, int payload) {
  bool valid = true;
  bool isread = false;

  // Check if command is valid and if it contains a read
  switch (cmd) {
    case B0000:
      break;
    case B0010:
      isread = true;
      break;
    case B1000:
      isread = true;
      break;
    case B1001:
      isread = true;
      break;
    case B1010:
      isread = true;
      break;
    case B1011:
      isread = true;
      break;
    case B1100:
      break;
    case B1101:
      break;
    case B1110:
      break;
    case B1111:
      break;
    default:
      valid = false;
  }

  // Check if data payload is the right size
  if ((isread && (payload > 255)) || (!isread && (payload > 65535))) {
    SerialUSB.write("Invalid number of payload bits\r\n");
    return false;
  }

  if (valid) {
    // Send command bits to the RN2483
    for (int n = 0; n < 4; n++) {
      //Lower PGC and write bit to PGD
      digitalWrite(PGC, LOW);
      digitalWrite(PGD, bitRead(cmd, n));
      delayMicroseconds(1);

      //Raise PGC to send bit
      digitalWrite(PGC, HIGH);
      delayMicroseconds(1);
    }
    digitalWrite(PGC, LOW);

    // Wait atleast 40ns (P5)
    delayMicroseconds(1);

    if (isread) {
      // Write 8 payload bits to RN2483
      for (int n = 0; n < 8; n++) {
        //Lower PGC and write bit to PGD
        digitalWrite(PGC, LOW);
        digitalWrite(PGD, bitRead(cmd, n));
        delayMicroseconds(1);

        //Raise PGC to send bit
        digitalWrite(PGC, HIGH);
        delayMicroseconds(1);
      }
      digitalWrite(PGC, LOW);

      // Set PGD to input
      pinMode(PGD, INPUT);

      // Wait atleast 20ns (P6)
      delayMicroseconds(1);

      // Read 8 response bits from RN2483
      int response = 255;
      for (int n = 0; n < 8; n++) {
        //Raise PGC to recieve bit
        digitalWrite(PGC, HIGH);
        delayMicroseconds(1);

        //Lower PGC and read bit from PGD
        digitalWrite(PGC, LOW);
        bitWrite(response, n, digitalRead(PGD));
        delayMicroseconds(1);
      }

      // Set PGD to output
      pinMode(PGD, OUTPUT);

      // Wait atleast 40ns (P5A)
      delayMicroseconds(1);
      SerialUSB.write("Sent 4 command bits and 8 data payload bits\r\nResponse: ");
      SerialUSB.print(String(response, BIN)+"\r\n");

      return response;
    } else {
      // Write all 16 bits from the data payload
      for (int n = 0; n < 16; n++) {
        //Lower PGC and write bit to PGD
        digitalWrite(PGC, LOW);
        digitalWrite(PGD, bitRead(cmd, n));
        delayMicroseconds(1);

        //Raise PGC to send bit
        digitalWrite(PGC, HIGH);
        delayMicroseconds(1);
      }
      digitalWrite(PGC, LOW);

      // Wait atleast 40ns (P5A)
      delayMicroseconds(1);
      SerialUSB.write("Sent 4 command bits and 16 data payload bits\r\n");

      return true;
    }
  } else {
    SerialUSB.write("Command not valid\r\n");
    return false;
  }
}

void loop() {
  if(SerialUSB.available()){
    char ch = SerialUSB.read();
    switch(ch){
      case '1':
        SerialUSB.write("Read address 3FFFFE\r\n");
        sendOp(B0000, 0x0E3F);
        sendOp(B0000, 0x6EF8);
        sendOp(B0000, 0x0EFF);
        sendOp(B0000, 0x6EF7);
        sendOp(B0000, 0x0EFE);
        sendOp(B0000, 0x6EF6);
        sendOp(B1001, 0x0000);
        break;
      case '2':
        SerialUSB.write("Read address 3FFFFF\r\n");
        sendOp(B0000, 0x0E3F);
        sendOp(B0000, 0x6EF8);
        sendOp(B0000, 0x0EFF);
        sendOp(B0000, 0x6EF7);
        sendOp(B0000, 0x0EFF);
        sendOp(B0000, 0x6EF6);
        sendOp(B1001, 0x0000);
        break;
      case '3':
        break;
      case '4':
        break;
      case '5':
        break;
      case '\r':
        break;
      case '\n':
        break;
      default:
        SerialUSB.write("Invalid input\r\n");
    }
  }
}

error: pathspec 'Arduino-RN2483-programmer.ino' did not match any file(s) known to git


Distance Sensor

Distance Sensor

The output voltage is now affected by its input voltage.

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


First release

First release

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


Create potentiometer.ino

Create potentiometer.ino

New example file showing how to use a potentiometer.

/*
*Code to control brightness via a potentiometer.  In this example the pot is plugged into A0
*Tested on a Robotdyn AC Dimmer
*Code and tutorial to use floating point values with the map function here: https://arduinogetstarted.com/tutorials/arduino-potentiometer
*/

#include <TriacDimmer.h>

float floatMap(float x, float in_min, float in_max, float out_min, float out_max) {
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

unsigned char sync = 8; //sync pin
unsigned char channel_1 = 9; // channel 1 pin

void setup() {
  // initialize the dimmer library.
  TriacDimmer::begin();
}

void loop() {
  // read the input on analog pin A0:
  int analogValue = analogRead(A0);
  float brightness = floatMap(analogValue, 0, 1023, 0, 1);
  // set channel 1 to the brightness value:
  TriacDimmer::setBrightness(channel_1, brightness);
}

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


First Commit

First Commit

#include <FastLED.h>
#include <Segment16.h>

Segment16 display;

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

void loop(){
  display.show();
  delay(2);
}


Adding basic XY Matrix example

Adding basic XY Matrix example

#include <FastLED.h>

#define LED_PIN  3

#define COLOR_ORDER GRB
#define CHIPSET     WS2811

#define BRIGHTNESS 64

// Helper functions for an two-dimensional XY matrix of pixels.
// Simple 2-D demo code is included as well.
//
//     XY(x,y) takes x and y coordinates and returns an LED index number,
//             for use like this:  leds[ XY(x,y) ] == CRGB::Red;
//             No error checking is performed on the ranges of x and y.
//
//     XYsafe(x,y) takes x and y coordinates and returns an LED index number,
//             for use like this:  leds[ XY(x,y) ] == CRGB::Red;
//             Error checking IS performed on the ranges of x and y, and an
//             index of "-1" is returned.  Special instructions below
//             explain how to use this without having to do your own error
//             checking every time you use this function.
//             This is a slightly more advanced technique, and
//             it REQUIRES SPECIAL ADDITIONAL setup, described below.

// Params for width and height
const uint8_t kMatrixWidth = 16;
const uint8_t kMatrixHeight = 16;

// Param for different pixel layouts
const bool    kMatrixSerpentineLayout = true;
// Set 'kMatrixSerpentineLayout' to false if your pixels are
// laid out all running the same way, like this:
//
//     0 >  1 >  2 >  3 >  4
//                         |
//     .----<----<----<----'
//     |
//     5 >  6 >  7 >  8 >  9
//                         |
//     .----<----<----<----'
//     |
//    10 > 11 > 12 > 13 > 14
//                         |
//     .----<----<----<----'
//     |
//    15 > 16 > 17 > 18 > 19
//
// Set 'kMatrixSerpentineLayout' to true if your pixels are
// laid out back-and-forth, like this:
//
//     0 >  1 >  2 >  3 >  4
//                         |
//                         |
//     9 <  8 <  7 <  6 <  5
//     |
//     |
//    10 > 11 > 12 > 13 > 14
//                        |
//                        |
//    19 < 18 < 17 < 16 < 15
//
// Bonus vocabulary word: anything that goes one way
// in one row, and then backwards in the next row, and so on
// is call "boustrophedon", meaning "as the ox plows."

// This function will return the right 'led index number' for
// a given set of X and Y coordinates on your matrix.
// IT DOES NOT CHECK THE COORDINATE BOUNDARIES.
// That's up to you.  Don't pass it bogus values.
//
// Use the "XY" function like this:
//
//    for( uint8_t x = 0; x < kMatrixWidth; x++) {
//      for( uint8_t y = 0; y < kMatrixHeight; y++) {
//
//        // Here's the x, y to 'led index' in action:
//        leds[ XY( x, y) ] = CHSV( random8(), 255, 255);
//
//      }
//    }
//
//
uint16_t XY( uint8_t x, uint8_t y)
{
  uint16_t i;

  if( kMatrixSerpentineLayout == false) {
    i = (y * kMatrixWidth) + x;
  }

  if( kMatrixSerpentineLayout == true) {
    if( y & 0x01) {
      // Odd rows run backwards
      uint8_t reverseX = (kMatrixWidth - 1) - x;
      i = (y * kMatrixWidth) + reverseX;
    } else {
      // Even rows run forwards
      i = (y * kMatrixWidth) + x;
    }
  }

  return i;
}

// Once you've gotten the basics working (AND NOT UNTIL THEN!)
// here's a helpful technique that can be tricky to set up, but
// then helps you avoid the needs for sprinkling array-bound-checking
// throughout your code.
//
// It requires a careful attention to get it set up correctly, but
// can potentially make your code smaller and faster.
//
// Suppose you have an 8 x 5 matrix of 40 LEDs.  Normally, you'd
// delcare your leds array like this:
//    CRGB leds[40];
// But instead of that, declare an LED buffer with one extra pixel in
// it, "leds_plus_safety_pixel".  Then declare "leds" as a pointer to
// that array, but starting with the 2nd element (id=1) of that array:
//    CRGB leds_with_safety_pixel[41];
//    const CRGB* leds( leds_plus_safety_pixel + 1);
// Then you use the "leds" array as you normally would.
// Now "leds[0..N]" are aliases for "leds_plus_safety_pixel[1..(N+1)]",
// AND leds[-1] is now a legitimate and safe alias for leds_plus_safety_pixel[0].
// leds_plus_safety_pixel[0] aka leds[-1] is now your "safety pixel".
//
// Now instead of using the XY function above, use the one below, "XYsafe".
//
// If the X and Y values are 'in bounds', this function will return an index
// into the visible led array, same as "XY" does.
// HOWEVER -- and this is the trick -- if the X or Y values
// are out of bounds, this function will return an index of -1.
// And since leds[-1] is actually just an alias for leds_plus_safety_pixel[0],
// it's a totally safe and legal place to access.  And since the 'safety pixel'
// falls 'outside' the visible part of the LED array, anything you write
// there is hidden from view automatically.
// Thus, this line of code is totally safe, regardless of the actual size of
// your matrix:
//    leds[ XYsafe( random8(), random8() ) ] = CHSV( random8(), 255, 255);
//
// The only catch here is that while this makes it safe to read from and
// write to 'any pixel', there's really only ONE 'safety pixel'.  No matter
// what out-of-bounds coordinates you write to, you'll really be writing to
// that one safety pixel.  And if you try to READ from the safety pixel,
// you'll read whatever was written there last, reglardless of what coordinates
// were supplied.

#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
CRGB leds_plus_safety_pixel[ NUM_LEDS + 1];
CRGB* leds( leds_plus_safety_pixel + 1);

uint16_t XYsafe( uint8_t x, uint8_t y)
{
  if( x >= kMatrixWidth) return -1;
  if( y >= kMatrixHeight) return -1;
  return XY(x,y);
}

// Demo that USES "XY" follows code below

void loop()
{
    uint32_t ms = millis();
    int32_t yHueDelta32 = ((int32_t)cos16( ms * (27/1) ) * (350 / kMatrixWidth));
    int32_t xHueDelta32 = ((int32_t)cos16( ms * (39/1) ) * (310 / kMatrixHeight));
    DrawOneFrame( ms / 65536, yHueDelta32 / 32768, xHueDelta32 / 32768);
    if( ms < 5000 ) {
      FastLED.setBrightness( scale8( BRIGHTNESS, (ms * 256) / 5000));
    } else {
      FastLED.setBrightness(BRIGHTNESS);
    }
    FastLED.show();
}

void DrawOneFrame( byte startHue8, int8_t yHueDelta8, int8_t xHueDelta8)
{
  byte lineStartHue = startHue8;
  for( byte y = 0; y < kMatrixHeight; y++) {
    lineStartHue += yHueDelta8;
    byte pixelHue = lineStartHue;
    for( byte x = 0; x < kMatrixWidth; x++) {
      pixelHue += xHueDelta8;
      leds[ XY(x, y)]  = CHSV( pixelHue, 255, 255);
    }
  }
}

void setup() {
  FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);
  FastLED.setBrightness( BRIGHTNESS );
}

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


Fixed sensor registers for Scada simulation

error: pathspec 'libraries/Energia' did not match any file(s) known to git
error: pathspec 'MSP/Examples/ModBus_Serial_Slave/ModBus_Serial_Slave.ino' did not match any file(s) known to git


ESP8266 Blink example for the blue LED on the ESP-01 module

/*
 ESP8266 Blink by Simon Peter
 Blink the blue LED on the ESP-01 module
 This example code is in the public domain
*/

const int ledPin =  1;         // The blue LED on the ESP-01 module is connected to GPIO1
                               // (which is also the TXD pin; so we cannot use
                               // Serial.print() at the same time

void setup() {
  pinMode(ledPin, OUTPUT);     // Initialize the ledPin as an output
  ESP.wdtDisable();            // Disable the watchdog timer built into the ESP8266
                               // otherwise the ESP8266 reboots during the "delay(1000);"
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(ledPin, LOW);   // turn the LED on (Note that LOW is the voltage level
                               // but actually the LED is on; this is because
                               // it is acive low on the ESP-01)
  delay(1000);                 // Wait for a second
  digitalWrite(ledPin, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                 // Wait for two seconds (to demonstrate the active low LED)
}

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


delay before connection attempt

delay before connection attempt

git-svn-id: d8bfcd070c2c81762cca1b3912331324182919ba@18728 0d6f1817-ed0e-0410-87c9-987e46238f29

/*
   Copyright 2016-2019 Bo Zimmerman

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

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

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

void ZConfig::switchTo()
{
  currMode=&configMode;
  serial.setFlowControlType(commandMode.serial.getFlowControlType());
  serial.setPetsciiMode(commandMode.serial.isPetsciiMode());
  savedEcho=commandMode.doEcho;
  newListen=commandMode.preserveListeners;
  commandMode.doEcho=true;
  serverSpec.port=6502;
  if(servs)
    serverSpec = *servs;
  serial.setXON(true);
  showMenu=true;
  EOLN=commandMode.EOLN;
  EOLNC=EOLN.c_str();
  currState = ZCFGMENU_MAIN;
  lastNumber=0;
  lastAddress="";
  lastOptions="";
  settingsChanged=false;
  lastNumNetworks=0;
}

void ZConfig::serialIncoming()
{
  bool crReceived=commandMode.readSerialStream();
  commandMode.clearPlusProgress(); // re-check the plus-escape mode
  if(crReceived)
  {
    doModeCommand();
  }
}

void ZConfig::switchBackToCommandMode()
{
  commandMode.doEcho=savedEcho;
  currMode = &commandMode;
}

void ZConfig::doModeCommand()
{
  String cmd = commandMode.getNextSerialCommand();
  char c='?';
  for(int i=0;i<cmd.length();i++)
  {
    if(cmd[i]>32)
    {
      c=lc(cmd[i]);
      break;
    }
  }
  switch(currState)
  {
    case ZCFGMENU_MAIN:
    {
      if((c=='q')||(cmd.length()==0))
      {
        if(settingsChanged)
        {
          currState=ZCFGMENU_WICONFIRM;
          showMenu=true;
        }
        else
        {
          commandMode.showInitMessage();
          switchBackToCommandMode();
          return;
        }
      }
      else
      if(c=='a') // add to phonebook
      {
        currState=ZCFGMENU_NUM;
        showMenu=true;
      }
      else
      if(c=='w') // wifi
      {
        currState=ZCFGMENU_WIMENU;
        showMenu=true;
      }
      else
      if(c=='h') // host
      {
        currState=ZCFGMENU_NEWHOST;
        showMenu=true;
      }
      else
      if(c=='f') // flow control
      {
        currState=ZCFGMENU_FLOW;
        showMenu=true;
      }
      else
      if(c=='p') // petscii translation toggle
      {
        commandMode.serial.setPetsciiMode(!commandMode.serial.isPetsciiMode());
        serial.setPetsciiMode(commandMode.serial.isPetsciiMode());
        settingsChanged=true;
        showMenu=true;
      }
      else
      if(c=='e') // echo
      {
        savedEcho = !savedEcho;
        settingsChanged=true;
        showMenu=true;
      }
      else
      if(c=='b') // bbs
      {
        currState=ZCFGMENU_BBSMENU;
        showMenu=true;
      }
      else
      if(c>47 && c<58) // its a phonebook entry!
      {
        PhoneBookEntry *pb=PhoneBookEntry::findPhonebookEntry(cmd);
        if(pb == null)
        {
          serial.printf("%s%sPhone number not found: '%s'.%s%s",EOLNC,EOLNC,cmd.c_str(),EOLNC,EOLNC);
          currState=ZCFGMENU_MAIN;
          showMenu=true;
        }
        else
        {
          lastNumber = pb->number;
          lastAddress = pb->address;
          lastOptions = pb->modifiers;
          currState=ZCFGMENU_ADDRESS;
          showMenu=true;
        }
      }
      else
      {
        showMenu=true; // re-show the menu
      }
      break;
    }
    case ZCFGMENU_WICONFIRM:
    {
      if((cmd.length()==0)||(c=='n'))
      {
        commandMode.showInitMessage();
        switchBackToCommandMode();
        return;
      }
      else
      if(c=='y')
      {
        if(newListen != commandMode.preserveListeners)
        {
          commandMode.preserveListeners=newListen;
          if(!newListen)
          {
            SPIFFS.remove("/zlisteners.txt");
            WiFiServerNode::DestroyAllServers();
          }
          else
          {
            commandMode.ringCounter=1;
            commandMode.autoStreamMode=true;
            WiFiServerNode *s=WiFiServerNode::FindServer(serverSpec.port);
            if(s != null)
              delete s;
            s = new WiFiServerNode(serverSpec.port,serverSpec.flagsBitmap);
            WiFiServerNode::SaveWiFiServers();
          }
        }
        else
        if(commandMode.preserveListeners)
        {
          WiFiServerNode *s = WiFiServerNode::FindServer(serverSpec.port);
          if( s != null)
          {
            if(s->flagsBitmap != serverSpec.flagsBitmap)
            {
              s->flagsBitmap = serverSpec.flagsBitmap;
              WiFiServerNode::SaveWiFiServers();
            }
          }
          else
          {
            WiFiServerNode::DestroyAllServers();
            s = new WiFiServerNode(serverSpec.port,serverSpec.flagsBitmap);
            WiFiServerNode::SaveWiFiServers();
          }
        }
        commandMode.reSaveConfig();
        serial.printf("%sSettings saved.%s",EOLNC,EOLNC);
        commandMode.showInitMessage();
        switchBackToCommandMode();
        return;
      }
      else
        showMenu=true;
    }
    case ZCFGMENU_NUM:
    {
      PhoneBookEntry *pb=PhoneBookEntry::findPhonebookEntry(cmd);
      if(pb != null)
      {
        serial.printf("%s%sNumber already exists '%s'.%s%s",EOLNC,EOLNC,cmd.c_str(),EOLNC,EOLNC);
        currState=ZCFGMENU_MAIN;
        showMenu=true;
      }
      else
      if(cmd.length()==0)
      {
        currState=ZCFGMENU_MAIN;
        showMenu=true;
      }
      else
      {
        lastNumber = atol((char *)cmd.c_str());
        lastAddress = "";
        lastOptions = "";
        currState=ZCFGMENU_ADDRESS;
        showMenu=true;
      }
      break;
    }
    case ZCFGMENU_NEWPORT:
    {
      if(cmd.length()>0)
      {
        serverSpec.port = atoi((char *)cmd.c_str());
        settingsChanged=true;
      }
      currState=ZCFGMENU_BBSMENU;
      showMenu=true;
      break;
    }
    case ZCFGMENU_ADDRESS:
    {
      PhoneBookEntry *entry = PhoneBookEntry::findPhonebookEntry(lastNumber);
      if(cmd.equalsIgnoreCase("delete") && (entry != null))
      {
        delete entry;
        currState=ZCFGMENU_MAIN;
        serial.printf("%sPhonebook entry deleted.%s%s",EOLNC,EOLNC,EOLNC);
      }
      else
      if((cmd.length()==0) && (entry != null))
          currState=ZCFGMENU_OPTIONS; // just keep old values
      else
      {
        boolean fail = cmd.indexOf(',') >= 0;
        int colonDex=cmd.indexOf(':');
        fail = fail || (colonDex <= 0) || (colonDex == cmd.length()-1);
        fail = fail || (colonDex != cmd.lastIndexOf(':'));
        if(!fail)
        {
          for(int i=colonDex+1;i<cmd.length();i++)
            if(strchr("0123456789",cmd[i])<0)
              fail=true;
        }
        if(fail)
        {
          serial.printf("%sInvalid address format (hostname:port) for '%s'.%s%s",EOLNC,cmd.c_str(),EOLNC,EOLNC);
        }
        else
        {
          lastAddress = cmd;
          currState=ZCFGMENU_OPTIONS;
        }
      }
      showMenu=true; // re-show the menu
      break;
    }
    case ZCFGMENU_BBSMENU:
    {
      if(cmd.length()==0)
        currState=ZCFGMENU_MAIN;
      else
      {
        ConnSettings flags(serverSpec.flagsBitmap);
        switch(c)
        {
        case 'h':
          currState=ZCFGMENU_NEWPORT;
          break;
        case 'd':
          newListen=false;
          settingsChanged=true;
          break;
        case 'p':
          if(newListen)
          {
            flags.petscii=!flags.petscii;
            settingsChanged=true;
          }
          break;
        case 't':
          if(newListen)
          {
            flags.telnet=!flags.telnet;
            settingsChanged=true;
          }
          break;
        case 'e':
          if(newListen)
            flags.echo=!flags.echo;
          else
            newListen=true;
          settingsChanged=true;
          break;
        case 'f':
          if(newListen)
          {
            if(flags.xonxoff)
            {
              flags.xonxoff=false;
              flags.rtscts=true;
            }
            else
            if(flags.rtscts)
              flags.rtscts=false;
            else
              flags.xonxoff=true;
            settingsChanged=true;
          }
          break;
        case 's':
          if(newListen)
          {
            flags.secure=!flags.secure;
            settingsChanged=true;
          }
          break;

        default:
          serial.printf("%sInvalid option '%s'.%s%s",EOLNC,cmd.c_str(),EOLNC,EOLNC);
          break;
        }
        settingsChanged=true;
        serverSpec.flagsBitmap = flags.getBitmap();
      }
      showMenu=true;
      break;
    }
    case ZCFGMENU_OPTIONS:
    {
      if(cmd.length()==0)
      {
        PhoneBookEntry *entry = PhoneBookEntry::findPhonebookEntry(lastNumber);
        if(entry != null)
        {
          serial.printf("%sPhonebook entry updated.%s%s",EOLNC,EOLNC,EOLNC);
          delete entry;
        }
        else
          serial.printf("%sPhonebook entry added.%s%s",EOLNC,EOLNC,EOLNC);
        entry = new PhoneBookEntry(lastNumber,lastAddress.c_str(),lastOptions.c_str());
        PhoneBookEntry::savePhonebook();
        currState=ZCFGMENU_MAIN;
      }
      else
      {
        ConnSettings flags(lastOptions.c_str());
        switch(c)
        {
          case 'p':
            flags.petscii=!flags.petscii;
            break;
          case 't':
            flags.telnet=!flags.telnet;
            break;
          case 'e':
            flags.echo=!flags.echo;
            break;
          case 'f':
            if(flags.xonxoff)
            {
              flags.xonxoff=false;
              flags.rtscts=true;
            }
            else
            if(flags.rtscts)
              flags.rtscts=false;
            else
              flags.xonxoff=true;
            break;
          case 's':
            flags.secure=!flags.secure;
            break;
          default:
            serial.printf("%sInvalid toggle option '%s'.%s%s",EOLNC,cmd.c_str(),EOLNC,EOLNC);
            break;
        }
        lastOptions = flags.getFlagString();
      }
      showMenu=true; // re-show the menu
      break;
    }
    case ZCFGMENU_WIMENU:
    {
      if(cmd.length()==0)
      {
        currState=ZCFGMENU_MAIN;
        showMenu=true;
      }
      else
      {
        int num=atoi(cmd.c_str());
        if((num<=0)||(num>lastNumNetworks))
            serial.printf("%sInvalid number.  Try again.%s",EOLNC,EOLNC);
        else
        if(WiFi.encryptionType(num-1) == ENC_TYPE_NONE)
        {
          if(!connectWifi(WiFi.SSID(num-1).c_str(),""))
          {
            serial.printf("%sUnable to connect to %s. :(%s",EOLNC,WiFi.SSID(num-1).c_str(),EOLNC);
          }
          else
          {
            wifiSSI=WiFi.SSID(num-1);
            wifiPW="";
            settingsChanged=true;
            serial.printf("%sConnected!%s",EOLNC,EOLNC);
            currState=ZCFGMENU_MAIN;
          }
          showMenu=true;
        }
        else
        {
          lastNumber=num-1;
          currState=ZCFGMENU_WIFIPW;
          showMenu=true;
        }
      }
      break;
    }
    case ZCFGMENU_NEWHOST:
      if(cmd.length()==0)
        currState=ZCFGMENU_WIMENU;
      else
      {
        hostname=cmd;
        hostname.replace(',','.');
        if((wifiSSI.length() > 0) && (WiFi.status()==WL_CONNECTED))
        {
            if(!connectWifi(wifiSSI.c_str(),wifiPW.c_str()))
              serial.printf("%sUnable to connect to %s. :(%s",EOLNC,wifiSSI.c_str(),EOLNC);
            settingsChanged=true;
        }
        currState=ZCFGMENU_MAIN;
        showMenu=true;
      }
      break;
    case ZCFGMENU_WIFIPW:
      if(cmd.length()==0)
      {
        currState=ZCFGMENU_WIMENU;
        showMenu=true;
      }
      else
      {
          for(int i=0;i<500;i++)
          {
            if(serial.isSerialOut())
              serialOutDeque();
            delay(1);
          }
          if(!connectWifi(WiFi.SSID(lastNumber).c_str(),cmd.c_str()))
            serial.printf("%sUnable to connect to %s.%s",EOLNC,WiFi.SSID(lastNumber).c_str(),EOLNC);
          else
          {
            wifiSSI=WiFi.SSID(lastNumber);
            wifiPW=cmd;
            settingsChanged=true;
            serial.printf("%sConnected!%s",EOLNC,EOLNC);
            currState=ZCFGMENU_MAIN;
          }
          showMenu=true;
      }
      break;
    case ZCFGMENU_FLOW:
      if(cmd.length()==0)
      {
        currState=ZCFGMENU_WIMENU;
        showMenu=true;
      }
      else
      {
        currState=ZCFGMENU_MAIN;
        showMenu=true;
        if(c=='x')
          commandMode.serial.setFlowControlType(FCT_NORMAL);
        else
        if(c=='r')
          commandMode.serial.setFlowControlType(FCT_RTSCTS);
        else
        if(c=='d')
          commandMode.serial.setFlowControlType(FCT_DISABLED);
        else
        {
          serial.printf("%sUnknown flow control type '%s'.  Try again.%s",EOLNC,cmd.c_str(),EOLNC);
          currState=ZCFGMENU_FLOW;
        }
        settingsChanged = settingsChanged || (currState ==ZCFGMENU_MAIN);
        serial.setFlowControlType(commandMode.serial.getFlowControlType());
        serial.setXON(true);
      }
      break;
  }
}

void ZConfig::loop()
{
  if(showMenu)
  {
    showMenu=false;
    switch(currState)
    {
      case ZCFGMENU_MAIN:
      {
        serial.printf("%sMain Menu%s",EOLNC,EOLNC);
        serial.printf("[HOST] name: %s%s",hostname.c_str(),EOLNC);
        serial.printf("[WIFI] connection: %s%s",(WiFi.status() == WL_CONNECTED)?wifiSSI.c_str():"Not connected",EOLNC);
        String flowName;
        switch(commandMode.serial.getFlowControlType())
        {
          case FCT_NORMAL:
            flowName = "XON/XOFF";
            break;
          case FCT_RTSCTS:
            flowName = "RTS/CTS";
            break;
          case FCT_DISABLED:
            flowName = "DISABLED";
            break;
          default:
            flowName = "OTHER";
            break;
        }
        String bbsMode = "DISABLED";
        if(newListen)
        {
          bbsMode = "Port ";
          bbsMode += serverSpec.port;
        }
        serial.printf("[FLOW] control: %s%s",flowName.c_str(),EOLNC);
        serial.printf("[ECHO] keystrokes: %s%s",savedEcho?"ON":"OFF",EOLNC);
        serial.printf("[BBS] host: %s%s",bbsMode.c_str(),EOLNC);
        serial.printf("[PETSCII] translation: %s%s",commandMode.serial.isPetsciiMode()?"ON":"OFF",EOLNC);
        serial.printf("[ADD] new phonebook entry%s",EOLNC);
        PhoneBookEntry *p = phonebook;
        if(p != null)
        {
          serial.printf("Phonebook entries:%s",EOLNC);
          while(p != null)
          {
            serial.printf("  [%lu] %s%s",p->number, p->address, EOLNC);
            p=p->next;
          }
        }
        serial.printf("%sEnter command or entry or ENTER to exit: ",EOLNC,EOLNC);
        break;
      }
      case ZCFGMENU_NUM:
        serial.printf("%sEnter a new fake phone number (digits ONLY)%s: ",EOLNC,EOLNC);
        break;
      case ZCFGMENU_NEWPORT:
        serial.printf("%sEnter a port number to listen on%s: ",EOLNC,EOLNC);
        break;
      case ZCFGMENU_ADDRESS:
      {
        PhoneBookEntry *lastEntry = PhoneBookEntry::findPhonebookEntry(lastNumber);
        if(lastEntry == null)
          serial.printf("%sEnter a new hostname:port%s: ",EOLNC,EOLNC);
        else
          serial.printf("%sModify hostname:port, or enter DELETE (%s)%s: ",EOLNC,lastAddress.c_str(),EOLNC);
        break;
      }
      case ZCFGMENU_OPTIONS:
      {
        ConnSettings flags(lastOptions.c_str());
        serial.printf("%sConnection Options:%s",EOLNC,EOLNC);
        serial.printf("[PETSCII] Translation: %s%s",flags.petscii?"ON":"OFF",EOLNC);
        serial.printf("[TELNET] Translation: %s%s",flags.telnet?"ON":"OFF",EOLNC);
        serial.printf("[ECHO]: %s%s",flags.echo?"ON":"OFF",EOLNC);
        serial.printf("[FLOW] Control: %s%s",flags.xonxoff?"XON/XOFF":flags.rtscts?"RTS/CTS":"DISABLED",EOLNC);
        serial.printf("%sEnter option to toggle or ENTER to exit%s: ",EOLNC,EOLNC);
        break;
      }
      case ZCFGMENU_BBSMENU:
      {
        serial.printf("%sBBS host settings:%s",EOLNC,EOLNC);
        if(newListen)
        {
          ConnSettings flags(serverSpec.flagsBitmap);
          serial.printf("%s[HOST] Listener Port: %d%s",EOLNC,serverSpec.port,EOLNC);
          serial.printf("[PETSCII] Translation: %s%s",flags.petscii?"ON":"OFF",EOLNC);
          serial.printf("[TELNET] Translation: %s%s",flags.telnet?"ON":"OFF",EOLNC);
          serial.printf("[ECHO]: %s%s",flags.echo?"ON":"OFF",EOLNC);
          serial.printf("[FLOW] Control: %s%s",flags.xonxoff?"XON/XOFF":flags.rtscts?"RTS/CTS":"DISABLED",EOLNC);
          serial.printf("[DISABLE] BBS host listener%s",EOLNC);
        }
        else
          serial.printf("%s[ENABLE] BBS host listener%s",EOLNC,EOLNC);
        serial.printf("%sEnter option to toggle or ENTER to exit%s: ",EOLNC,EOLNC);
        break;
      }
      case ZCFGMENU_WIMENU:
      {
        int n = WiFi.scanNetworks();
        if(n>20)
          n=20;
        serial.printf("%sWiFi Networks:%s",EOLNC,EOLNC);
        lastNumNetworks=n;
        for (int i = 0; i < n; ++i)
        {
          serial.printf("[%d] ",(i+1));
          serial.prints(WiFi.SSID(i).c_str());
          serial.prints(" (");
          serial.printi(WiFi.RSSI(i));
          serial.prints(")");
          serial.prints((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");
          serial.prints(EOLN.c_str());
          serial.flush();
          delay(10);
        }
        serial.printf("%sEnter number to connect, or ENTER: ",EOLNC);
        break;
      }
      case ZCFGMENU_NEWHOST:
      {
        serial.printf("%sEnter a new hostname: ",EOLNC);
        break;
      }
      case ZCFGMENU_WIFIPW:
      {
        serial.printf("%sEnter your WiFi Password: ",EOLNC);
        break;
      }
      case ZCFGMENU_FLOW:
      {
        serial.printf("%sEnter RTS/CTS, XON/XOFF, or DISABLE flow control%s: ",EOLNC,EOLNC);
        break;
      }
      case ZCFGMENU_WICONFIRM:
      {
        serial.printf("%sYour setting changed.  Save them (y/N)?",EOLNC);
        break;
      }
    }
  }
  if(commandMode.checkPlusEscape())
  {
    switchBackToCommandMode();
  }
  else
  if(serial.isSerialOut())
  {
    serialOutDeque();
  }
}

/*
   Copyright 2016-2019 Bo Zimmerman

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

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

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

void ZConfig::switchTo()
{
  currMode=&configMode;
  serial.setFlowControlType(commandMode.serial.getFlowControlType());
  serial.setPetsciiMode(commandMode.serial.isPetsciiMode());
  savedEcho=commandMode.doEcho;
  newListen=commandMode.preserveListeners;
  commandMode.doEcho=true;
  serverSpec.port=6502;
  if(servs)
    serverSpec = *servs;
  serial.setXON(true);
  showMenu=true;
  EOLN=commandMode.EOLN;
  EOLNC=EOLN.c_str();
  currState = ZCFGMENU_MAIN;
  lastNumber=0;
  lastAddress="";
  lastOptions="";
  settingsChanged=false;
  lastNumNetworks=0;
}

void ZConfig::serialIncoming()
{
  bool crReceived=commandMode.readSerialStream();
  commandMode.clearPlusProgress(); // re-check the plus-escape mode
  if(crReceived)
  {
    doModeCommand();
  }
}

void ZConfig::switchBackToCommandMode()
{
  commandMode.doEcho=savedEcho;
  currMode = &commandMode;
}

void ZConfig::doModeCommand()
{
  String cmd = commandMode.getNextSerialCommand();
  char c='?';
  for(int i=0;i<cmd.length();i++)
  {
    if(cmd[i]>32)
    {
      c=lc(cmd[i]);
      break;
    }
  }
  switch(currState)
  {
    case ZCFGMENU_MAIN:
    {
      if((c=='q')||(cmd.length()==0))
      {
        if(settingsChanged)
        {
          currState=ZCFGMENU_WICONFIRM;
          showMenu=true;
        }
        else
        {
          commandMode.showInitMessage();
          switchBackToCommandMode();
          return;
        }
      }
      else
      if(c=='a') // add to phonebook
      {
        currState=ZCFGMENU_NUM;
        showMenu=true;
      }
      else
      if(c=='w') // wifi
      {
        currState=ZCFGMENU_WIMENU;
        showMenu=true;
      }
      else
      if(c=='h') // host
      {
        currState=ZCFGMENU_NEWHOST;
        showMenu=true;
      }
      else
      if(c=='f') // flow control
      {
        currState=ZCFGMENU_FLOW;
        showMenu=true;
      }
      else
      if(c=='p') // petscii translation toggle
      {
        commandMode.serial.setPetsciiMode(!commandMode.serial.isPetsciiMode());
        serial.setPetsciiMode(commandMode.serial.isPetsciiMode());
        settingsChanged=true;
        showMenu=true;
      }
      else
      if(c=='e') // echo
      {
        savedEcho = !savedEcho;
        settingsChanged=true;
        showMenu=true;
      }
      else
      if(c=='b') // bbs
      {
        currState=ZCFGMENU_BBSMENU;
        showMenu=true;
      }
      else
      if(c>47 && c<58) // its a phonebook entry!
      {
        PhoneBookEntry *pb=PhoneBookEntry::findPhonebookEntry(cmd);
        if(pb == null)
        {
          serial.printf("%s%sPhone number not found: '%s'.%s%s",EOLNC,EOLNC,cmd.c_str(),EOLNC,EOLNC);
          currState=ZCFGMENU_MAIN;
          showMenu=true;
        }
        else
        {
          lastNumber = pb->number;
          lastAddress = pb->address;
          lastOptions = pb->modifiers;
          currState=ZCFGMENU_ADDRESS;
          showMenu=true;
        }
      }
      else
      {
        showMenu=true; // re-show the menu
      }
      break;
    }
    case ZCFGMENU_WICONFIRM:
    {
      if((cmd.length()==0)||(c=='n'))
      {
        commandMode.showInitMessage();
        switchBackToCommandMode();
        return;
      }
      else
      if(c=='y')
      {
        if(newListen != commandMode.preserveListeners)
        {
          commandMode.preserveListeners=newListen;
          if(!newListen)
          {
            SPIFFS.remove("/zlisteners.txt");
            WiFiServerNode::DestroyAllServers();
          }
          else
          {
            commandMode.ringCounter=1;
            commandMode.autoStreamMode=true;
            WiFiServerNode *s=WiFiServerNode::FindServer(serverSpec.port);
            if(s != null)
              delete s;
            s = new WiFiServerNode(serverSpec.port,serverSpec.flagsBitmap);
            WiFiServerNode::SaveWiFiServers();
          }
        }
        else
        if(commandMode.preserveListeners)
        {
          WiFiServerNode *s = WiFiServerNode::FindServer(serverSpec.port);
          if( s != null)
          {
            if(s->flagsBitmap != serverSpec.flagsBitmap)
            {
              s->flagsBitmap = serverSpec.flagsBitmap;
              WiFiServerNode::SaveWiFiServers();
            }
          }
          else
          {
            WiFiServerNode::DestroyAllServers();
            s = new WiFiServerNode(serverSpec.port,serverSpec.flagsBitmap);
            WiFiServerNode::SaveWiFiServers();
          }
        }
        commandMode.reSaveConfig();
        serial.printf("%sSettings saved.%s",EOLNC,EOLNC);
        commandMode.showInitMessage();
        switchBackToCommandMode();
        return;
      }
      else
        showMenu=true;
    }
    case ZCFGMENU_NUM:
    {
      PhoneBookEntry *pb=PhoneBookEntry::findPhonebookEntry(cmd);
      if(pb != null)
      {
        serial.printf("%s%sNumber already exists '%s'.%s%s",EOLNC,EOLNC,cmd.c_str(),EOLNC,EOLNC);
        currState=ZCFGMENU_MAIN;
        showMenu=true;
      }
      else
      if(cmd.length()==0)
      {
        currState=ZCFGMENU_MAIN;
        showMenu=true;
      }
      else
      {
        lastNumber = atol((char *)cmd.c_str());
        lastAddress = "";
        lastOptions = "";
        currState=ZCFGMENU_ADDRESS;
        showMenu=true;
      }
      break;
    }
    case ZCFGMENU_NEWPORT:
    {
      if(cmd.length()>0)
      {
        serverSpec.port = atoi((char *)cmd.c_str());
        settingsChanged=true;
      }
      currState=ZCFGMENU_BBSMENU;
      showMenu=true;
      break;
    }
    case ZCFGMENU_ADDRESS:
    {
      PhoneBookEntry *entry = PhoneBookEntry::findPhonebookEntry(lastNumber);
      if(cmd.equalsIgnoreCase("delete") && (entry != null))
      {
        delete entry;
        currState=ZCFGMENU_MAIN;
        serial.printf("%sPhonebook entry deleted.%s%s",EOLNC,EOLNC,EOLNC);
      }
      else
      if((cmd.length()==0) && (entry != null))
          currState=ZCFGMENU_OPTIONS; // just keep old values
      else
      {
        boolean fail = cmd.indexOf(',') >= 0;
        int colonDex=cmd.indexOf(':');
        fail = fail || (colonDex <= 0) || (colonDex == cmd.length()-1);
        fail = fail || (colonDex != cmd.lastIndexOf(':'));
        if(!fail)
        {
          for(int i=colonDex+1;i<cmd.length();i++)
            if(strchr("0123456789",cmd[i])<0)
              fail=true;
        }
        if(fail)
        {
          serial.printf("%sInvalid address format (hostname:port) for '%s'.%s%s",EOLNC,cmd.c_str(),EOLNC,EOLNC);
        }
        else
        {
          lastAddress = cmd;
          currState=ZCFGMENU_OPTIONS;
        }
      }
      showMenu=true; // re-show the menu
      break;
    }
    case ZCFGMENU_BBSMENU:
    {
      if(cmd.length()==0)
        currState=ZCFGMENU_MAIN;
      else
      {
        ConnSettings flags(serverSpec.flagsBitmap);
        switch(c)
        {
        case 'h':
          currState=ZCFGMENU_NEWPORT;
          break;
        case 'd':
          newListen=false;
          settingsChanged=true;
          break;
        case 'p':
          if(newListen)
          {
            flags.petscii=!flags.petscii;
            settingsChanged=true;
          }
          break;
        case 't':
          if(newListen)
          {
            flags.telnet=!flags.telnet;
            settingsChanged=true;
          }
          break;
        case 'e':
          if(newListen)
            flags.echo=!flags.echo;
          else
            newListen=true;
          settingsChanged=true;
          break;
        case 'f':
          if(newListen)
          {
            if(flags.xonxoff)
            {
              flags.xonxoff=false;
              flags.rtscts=true;
            }
            else
            if(flags.rtscts)
              flags.rtscts=false;
            else
              flags.xonxoff=true;
            settingsChanged=true;
          }
          break;
        case 's':
          if(newListen)
          {
            flags.secure=!flags.secure;
            settingsChanged=true;
          }
          break;

        default:
          serial.printf("%sInvalid option '%s'.%s%s",EOLNC,cmd.c_str(),EOLNC,EOLNC);
          break;
        }
        settingsChanged=true;
        serverSpec.flagsBitmap = flags.getBitmap();
      }
      showMenu=true;
      break;
    }
    case ZCFGMENU_OPTIONS:
    {
      if(cmd.length()==0)
      {
        PhoneBookEntry *entry = PhoneBookEntry::findPhonebookEntry(lastNumber);
        if(entry != null)
        {
          serial.printf("%sPhonebook entry updated.%s%s",EOLNC,EOLNC,EOLNC);
          delete entry;
        }
        else
          serial.printf("%sPhonebook entry added.%s%s",EOLNC,EOLNC,EOLNC);
        entry = new PhoneBookEntry(lastNumber,lastAddress.c_str(),lastOptions.c_str());
        PhoneBookEntry::savePhonebook();
        currState=ZCFGMENU_MAIN;
      }
      else
      {
        ConnSettings flags(lastOptions.c_str());
        switch(c)
        {
          case 'p':
            flags.petscii=!flags.petscii;
            break;
          case 't':
            flags.telnet=!flags.telnet;
            break;
          case 'e':
            flags.echo=!flags.echo;
            break;
          case 'f':
            if(flags.xonxoff)
            {
              flags.xonxoff=false;
              flags.rtscts=true;
            }
            else
            if(flags.rtscts)
              flags.rtscts=false;
            else
              flags.xonxoff=true;
            break;
          case 's':
            flags.secure=!flags.secure;
            break;
          default:
            serial.printf("%sInvalid toggle option '%s'.%s%s",EOLNC,cmd.c_str(),EOLNC,EOLNC);
            break;
        }
        lastOptions = flags.getFlagString();
      }
      showMenu=true; // re-show the menu
      break;
    }
    case ZCFGMENU_WIMENU:
    {
      if(cmd.length()==0)
      {
        currState=ZCFGMENU_MAIN;
        showMenu=true;
      }
      else
      {
        int num=atoi(cmd.c_str());
        if((num<=0)||(num>lastNumNetworks))
            serial.printf("%sInvalid number.  Try again.%s",EOLNC,EOLNC);
        else
        if(WiFi.encryptionType(num-1) == ENC_TYPE_NONE)
        {
          if(!connectWifi(WiFi.SSID(num-1).c_str(),""))
          {
            serial.printf("%sUnable to connect to %s. :(%s",EOLNC,WiFi.SSID(num-1).c_str(),EOLNC);
          }
          else
          {
            wifiSSI=WiFi.SSID(num-1);
            wifiPW="";
            settingsChanged=true;
            serial.printf("%sConnected!%s",EOLNC,EOLNC);
            currState=ZCFGMENU_MAIN;
          }
          showMenu=true;
        }
        else
        {
          lastNumber=num-1;
          currState=ZCFGMENU_WIFIPW;
          showMenu=true;
        }
      }
      break;
    }
    case ZCFGMENU_NEWHOST:
      if(cmd.length()==0)
        currState=ZCFGMENU_WIMENU;
      else
      {
        hostname=cmd;
        hostname.replace(',','.');
        if((wifiSSI.length() > 0) && (WiFi.status()==WL_CONNECTED))
        {
            if(!connectWifi(wifiSSI.c_str(),wifiPW.c_str()))
              serial.printf("%sUnable to connect to %s. :(%s",EOLNC,wifiSSI.c_str(),EOLNC);
            settingsChanged=true;
        }
        currState=ZCFGMENU_MAIN;
        showMenu=true;
      }
      break;
    case ZCFGMENU_WIFIPW:
      if(cmd.length()==0)
      {
        currState=ZCFGMENU_WIMENU;
        showMenu=true;
      }
      else
      {
          if(!connectWifi(WiFi.SSID(lastNumber).c_str(),cmd.c_str()))
          {
            serial.printf("%sConnection failed.  Retrying %s.%s",EOLNC,WiFi.SSID(lastNumber).c_str(),EOLNC);
            for(int t=0;t<3;t++)
            {
              for(int i=0;i<500;i++)
              {
                if(serial.isSerialOut())
                  serialOutDeque();
                delay(1);
              }
            }
            if((wifiSSI.length() == 0) || (WiFi.status()!=WL_CONNECTED))
              serial.printf("%sUnable to connect to %s.%s",EOLNC,WiFi.SSID(lastNumber).c_str(),EOLNC);
          }
          else
          {
            wifiSSI=WiFi.SSID(lastNumber);
            wifiPW=cmd;
            settingsChanged=true;
            serial.printf("%sConnected!%s",EOLNC,EOLNC);
            currState=ZCFGMENU_MAIN;
          }
          showMenu=true;
      }
      break;
    case ZCFGMENU_FLOW:
      if(cmd.length()==0)
      {
        currState=ZCFGMENU_WIMENU;
        showMenu=true;
      }
      else
      {
        currState=ZCFGMENU_MAIN;
        showMenu=true;
        if(c=='x')
          commandMode.serial.setFlowControlType(FCT_NORMAL);
        else
        if(c=='r')
          commandMode.serial.setFlowControlType(FCT_RTSCTS);
        else
        if(c=='d')
          commandMode.serial.setFlowControlType(FCT_DISABLED);
        else
        {
          serial.printf("%sUnknown flow control type '%s'.  Try again.%s",EOLNC,cmd.c_str(),EOLNC);
          currState=ZCFGMENU_FLOW;
        }
        settingsChanged = settingsChanged || (currState ==ZCFGMENU_MAIN);
        serial.setFlowControlType(commandMode.serial.getFlowControlType());
        serial.setXON(true);
      }
      break;
  }
}

void ZConfig::loop()
{
  if(showMenu)
  {
    showMenu=false;
    switch(currState)
    {
      case ZCFGMENU_MAIN:
      {
        serial.printf("%sMain Menu%s",EOLNC,EOLNC);
        serial.printf("[HOST] name: %s%s",hostname.c_str(),EOLNC);
        serial.printf("[WIFI] connection: %s%s",(WiFi.status() == WL_CONNECTED)?wifiSSI.c_str():"Not connected",EOLNC);
        String flowName;
        switch(commandMode.serial.getFlowControlType())
        {
          case FCT_NORMAL:
            flowName = "XON/XOFF";
            break;
          case FCT_RTSCTS:
            flowName = "RTS/CTS";
            break;
          case FCT_DISABLED:
            flowName = "DISABLED";
            break;
          default:
            flowName = "OTHER";
            break;
        }
        String bbsMode = "DISABLED";
        if(newListen)
        {
          bbsMode = "Port ";
          bbsMode += serverSpec.port;
        }
        serial.printf("[FLOW] control: %s%s",flowName.c_str(),EOLNC);
        serial.printf("[ECHO] keystrokes: %s%s",savedEcho?"ON":"OFF",EOLNC);
        serial.printf("[BBS] host: %s%s",bbsMode.c_str(),EOLNC);
        serial.printf("[PETSCII] translation: %s%s",commandMode.serial.isPetsciiMode()?"ON":"OFF",EOLNC);
        serial.printf("[ADD] new phonebook entry%s",EOLNC);
        PhoneBookEntry *p = phonebook;
        if(p != null)
        {
          serial.printf("Phonebook entries:%s",EOLNC);
          while(p != null)
          {
            serial.printf("  [%lu] %s%s",p->number, p->address, EOLNC);
            p=p->next;
          }
        }
        serial.printf("%sEnter command or entry or ENTER to exit: ",EOLNC,EOLNC);
        break;
      }
      case ZCFGMENU_NUM:
        serial.printf("%sEnter a new fake phone number (digits ONLY)%s: ",EOLNC,EOLNC);
        break;
      case ZCFGMENU_NEWPORT:
        serial.printf("%sEnter a port number to listen on%s: ",EOLNC,EOLNC);
        break;
      case ZCFGMENU_ADDRESS:
      {
        PhoneBookEntry *lastEntry = PhoneBookEntry::findPhonebookEntry(lastNumber);
        if(lastEntry == null)
          serial.printf("%sEnter a new hostname:port%s: ",EOLNC,EOLNC);
        else
          serial.printf("%sModify hostname:port, or enter DELETE (%s)%s: ",EOLNC,lastAddress.c_str(),EOLNC);
        break;
      }
      case ZCFGMENU_OPTIONS:
      {
        ConnSettings flags(lastOptions.c_str());
        serial.printf("%sConnection Options:%s",EOLNC,EOLNC);
        serial.printf("[PETSCII] Translation: %s%s",flags.petscii?"ON":"OFF",EOLNC);
        serial.printf("[TELNET] Translation: %s%s",flags.telnet?"ON":"OFF",EOLNC);
        serial.printf("[ECHO]: %s%s",flags.echo?"ON":"OFF",EOLNC);
        serial.printf("[FLOW] Control: %s%s",flags.xonxoff?"XON/XOFF":flags.rtscts?"RTS/CTS":"DISABLED",EOLNC);
        serial.printf("%sEnter option to toggle or ENTER to exit%s: ",EOLNC,EOLNC);
        break;
      }
      case ZCFGMENU_BBSMENU:
      {
        serial.printf("%sBBS host settings:%s",EOLNC,EOLNC);
        if(newListen)
        {
          ConnSettings flags(serverSpec.flagsBitmap);
          serial.printf("%s[HOST] Listener Port: %d%s",EOLNC,serverSpec.port,EOLNC);
          serial.printf("[PETSCII] Translation: %s%s",flags.petscii?"ON":"OFF",EOLNC);
          serial.printf("[TELNET] Translation: %s%s",flags.telnet?"ON":"OFF",EOLNC);
          serial.printf("[ECHO]: %s%s",flags.echo?"ON":"OFF",EOLNC);
          serial.printf("[FLOW] Control: %s%s",flags.xonxoff?"XON/XOFF":flags.rtscts?"RTS/CTS":"DISABLED",EOLNC);
          serial.printf("[DISABLE] BBS host listener%s",EOLNC);
        }
        else
          serial.printf("%s[ENABLE] BBS host listener%s",EOLNC,EOLNC);
        serial.printf("%sEnter option to toggle or ENTER to exit%s: ",EOLNC,EOLNC);
        break;
      }
      case ZCFGMENU_WIMENU:
      {
        int n = WiFi.scanNetworks();
        if(n>20)
          n=20;
        serial.printf("%sWiFi Networks:%s",EOLNC,EOLNC);
        lastNumNetworks=n;
        for (int i = 0; i < n; ++i)
        {
          serial.printf("[%d] ",(i+1));
          serial.prints(WiFi.SSID(i).c_str());
          serial.prints(" (");
          serial.printi(WiFi.RSSI(i));
          serial.prints(")");
          serial.prints((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");
          serial.prints(EOLN.c_str());
          serial.flush();
          delay(10);
        }
        serial.printf("%sEnter number to connect, or ENTER: ",EOLNC);
        break;
      }
      case ZCFGMENU_NEWHOST:
      {
        serial.printf("%sEnter a new hostname: ",EOLNC);
        break;
      }
      case ZCFGMENU_WIFIPW:
      {
        serial.printf("%sEnter your WiFi Password: ",EOLNC);
        break;
      }
      case ZCFGMENU_FLOW:
      {
        serial.printf("%sEnter RTS/CTS, XON/XOFF, or DISABLE flow control%s: ",EOLNC,EOLNC);
        break;
      }
      case ZCFGMENU_WICONFIRM:
      {
        serial.printf("%sYour setting changed.  Save them (y/N)?",EOLNC);
        break;
      }
    }
  }
  if(commandMode.checkPlusEscape())
  {
    switchBackToCommandMode();
  }
  else
  if(serial.isSerialOut())
  {
    serialOutDeque();
  }
}


Create QtArduino1.ino

Create QtArduino1.ino

/*
**    Arduino - Qt 'qextserialport' lib test file 1
**
**    controls the brightness of a LED present on the pin 9
**
**    ~schematics: Gnd <->l LED L<->1KOhm resistor<->pin9
**
*/

const int ledPin = 9; // the pin the LED is attached to
//const byte ledBrightness = 150;

void setup()
{
    Serial.begin(9600); //start the serial port at 9600 bauds
    pinMode(ledPin, OUTPUT); // init the LED pin as an output
    //analogWrite(ledPin, ledBrightness);// set the brightness of the LED
}

void loop()
{
    byte brightness;
    // if we get data from the computer, update the LED brightness
    if ( Serial.available() > 0 ) // if data is available from the serial
    {
        brightness = Serial.read(); // read the most recent byte ('ll be from 0 to 255)
        analogWrite(ledPin, brightness);// set the brightness of the LED
    }
}

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


Delete build.ino

Delete build.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/AJama50/CS207-Project.git/'


Scanner I2C

Scanner I2C

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>

void setup()
{
  Wire.begin();

  Serial.begin(9600);
  Serial.println("\nI2C Scanner");
}

void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknow error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

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


Create e.ino

Create e.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/Aroltd/e.git/'


Added Alarm Condition reset to non NOBODY OPMODES

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


updates notes

updates notes

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


Add the firmware source

Add the firmware source

const int led_pins[] = {11, 10, 9, 6, 5, 3};
const int led_count = sizeof(led_pins) / sizeof(int);
const int step_size = 8;

int value = 0;
long last_input = 0;

void setup()
{
  Serial.setTimeout(100);
  Serial.begin(4800);

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);

  for (int i = 0; i < led_count; ++i) {
    pinMode(led_pins[i], OUTPUT);
    analogWrite(led_pins[i], 0);
  }
}

void loop()
{
  if (Serial.available() > 0) {
    value = Serial.parseInt();
    last_input = millis();
  }

  long dt = millis() - last_input;
  if (dt < 0 || dt > 1000)
    value = 0;

  int led_level = map(value, 0, 1000, 0, led_count * step_size);

  for (int i = 0; i < led_count; ++i) {
    int rpins = led_level / step_size;
    if (i < rpins) {
      analogWrite(led_pins[i], 255);
    } else if (i == rpins) {
      int res = led_level % step_size;
      analogWrite(led_pins[i], (1 << res) - 1);
    } else {
      analogWrite(led_pins[i], 0);
    }
  }
}

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


Init add

Init add

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif

#define PIN            6

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      18

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 65; // delay for half a second

void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  // End of trinket special code

  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {

  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  int on_pixel;
  int off_pixel;
  int num_pixels_on = 2;
  for(int i=0;i < NUMPIXELS;i++){
    on_pixel = i;
    off_pixel = i - num_pixels_on;
    if (on_pixel <  0){
      on_pixel += NUMPIXELS;
    }
    if (off_pixel < 0){
      off_pixel += NUMPIXELS;
    }
    if (on_pixel > NUMPIXELS){
      on_pixel -= NUMPIXELS;
    }
    if (off_pixel > NUMPIXELS){
      off_pixel -= NUMPIXELS;
    }
    pixels.setPixelColor(on_pixel, pixels.Color(255,255,255)); // Moderately bright green color.
    pixels.show(); // This sends the updated pixel color to the hardware.
    pixels.setPixelColor(off_pixel, pixels.Color(0,0,0)); // Moderately bright green color.
    pixels.show(); // This sends the updated pixel color to the hardware.
    delay(delayval); // Delay for a period of time (in milliseconds).
  }
}

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


add arduino code

add arduino code

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


Updated serial.ino for light pulses

Updated serial.ino for light pulses


Initial Alpha Code

Initial Alpha Code

#include "FastLED.h"
/*
 * Jenn's colors RGB  0 0 81  BLUE
 * 0 100 100 Teal 006464
 * 60 100 100 Cool White 3C6464
 * 60 10 100 Violet 3C0A64
 * 60 0 50 Purple 3C0032
 * start white fades to Teal
 * violet to purple
 * teal to blue
 * red to blue
 */
#define NUM_LEDS 26
#define BRIGHTNESS  120  // 0...255
#define UPDATES_PER_SECOND 100
#define PIN_LED 3
#define PIN_PIR_DOWN 5
#define PIN_PIR_UP 7
#define STEP_DELAY 200  //ms = 1/5th second.

uint8_t lightsOn = LOW; // track lights on/off
uint8_t gHue = 0;
uint8_t gStair = 0;
uint8_t gBright = 0;
uint8_t gStairStart = 0;
uint8_t gStairEnd = 0;

CRGB leds[NUM_LEDS];

void setup() {
  delay (3000); // Power Up 3 second safety delay.
  Serial.begin(9600);
  FastLED.addLeds<WS2812B, PIN_LED, GRB>(leds, NUM_LEDS);
  //FastLED.setBrightness(BRIGHTNESS);
  //Serial.print("calibrating sensor ");
  pinMode(PIN_PIR_DOWN, INPUT);
  pinMode(PIN_PIR_UP, INPUT);
  digitalWrite(PIN_PIR_DOWN, LOW);
  digitalWrite(PIN_PIR_UP, LOW);
  Serial.println(" done");
  // Sparkle rainbow welcome give delay to calibrate pir sensors.  This also indicates if program crashed.
  for ( int i = 0; i < 500; i++ ){
    rainbowWithGlitter();
    FastLED.show();
    FastLED.delay(8.3);
    EVERY_N_MILLISECONDS( 20 ) { gHue++; }
  }
  for (int tick=0; tick < 64; tick++){
    for ( uint8_t i = 0; i < NUM_LEDS; i++ ){
      leds[i].fadeToBlackBy( 64 );
      FastLED.show();
      FastLED.delay(1);
    }
  }
    Serial.println("SENSOR ACTIVE");
}

// Main Loop track PIR sensors.
void loop() {
  // Walk Down.
  if ( digitalRead(PIN_PIR_UP) == HIGH ){
    if ( lightsOn == LOW ) {
      lightsOn = HIGH;
      //fade7(1);
      //walk(1);
      flicker(1);
      delay(50);
    }
  }
  // Walk Up.
  if ( digitalRead(PIN_PIR_DOWN) == HIGH  ){
    if ( lightsOn == LOW ) {
      lightsOn = HIGH;
      //fade7(-1); //Up
      //walk(-1); // Up
      flicker(-1);
      delay(50);
    }
  }
}

void walk(int8_t dir) {
  Serial.print("Walk dir: ");
  Serial.println(dir);
  static uint8_t hueStart = 208; //purple;
  static uint8_t hueEnd = 160;
  static uint8_t hueShift = 0;
  static uint8_t brightTop = 200;
  static int i = 0;
  setStartEnd(dir);

  for(gStair=gStairStart; (dir == 1 && gStair < gStairEnd ) || (dir == -1 && gStair >= gStairEnd && gStair <= gStairStart+1 ); gStair+=(2*dir)) {
    // Fade in step
    hueShift = hueStart;
    for (gBright=0; gBright<=brightTop; gBright+=2) {
      leds[gStair] = CHSV( hueStart, 204, gBright );  // purple
      leds[gStair + 1*dir] = CHSV( hueStart, 204, gBright );  // purple
      if (  (dir == 1 && gStair >= 2) || (dir == -1 && gStair <= (gStairStart-2)) ) { // slide hue from pruple to blue on previous stair
        //hueShift = hueShift + ((hueEnd-hueStart)/brightTop*gBright); //=D1+((160-240)/200*10)
        if ( hueShift >= hueEnd ) {
          hueShift--;
          leds[gStair - 1*dir] = CHSV( hueShift, 204, 200 );
          leds[gStair - 2*dir] = CHSV( hueShift, 204, 200 );
        }
      }
      FastLED.show();
      //FastLED.delay(1);
    }
    Serial.print(gStair);
    Serial.println(" step");
  }

  Serial.println("Last Stairs");
  hueShift = hueStart;
  for (gBright=0; gBright<=brightTop; gBright+=2) {
    if ( hueShift >= hueEnd )
    //hueShift = 1/(hueShift + ((hueEnd-hueStart)/brightTop*bright));
    hueShift--;
    leds[gStairEnd] = CHSV( hueShift, 204, 200 );
    leds[gStairEnd - 1*dir] = CHSV( hueShift, 204, 200 );
    FastLED.show();
    //FastLED.delay(1);
  }
  //Flash
  FastLED.delay(500);
  for(gStair=gStairStart; (dir == 1 && gStair <= gStairEnd ) || (dir == -1 && gStair >= gStairEnd && gStair <= gStairStart+1 ); gStair+=(2*dir)) {
    leds[gStair] = CRGB( 100, 100, 100);
    leds[gStair + 1*dir] = CRGB( 100, 100, 100);
    FastLED.show();
  }
  for(gStair=gStairStart; (dir == 1 && gStair <= gStairEnd ) || (dir == -1 && gStair >= gStairEnd && gStair <= gStairStart+1 ); gStair+=(2*dir)) {
    leds[gStair] = CHSV( hueEnd, 204, 200 );
    leds[gStair+1*dir] = CHSV( hueEnd, 204, 200 );
    FastLED.show();
  }

  Serial.println("Delay");
  // Stay on for a bit
  fill_solid(leds, NUM_LEDS, CHSV( hueEnd, 204, 200 ));
  //addGlitter(70);
  FastLED.show();
  FastLED.delay(5000);

  // Turn off steps
  Serial.println("Steps Off");
  for(gStair=gStairStart; (dir == 1 && gStair <= gStairEnd ) || (dir == -1 && gStair >= gStairEnd && gStair <= gStairStart+1 ); gStair+=(2*dir)) {
    // Fade in step
    //hueShift = hueStart;
    for (gBright=200; gBright>=1; gBright--) {
      leds[gStair] = CHSV(hueEnd, 204, gBright);
      leds[gStair + 1*dir] = CHSV(hueEnd, 204, gBright);
      FastLED.show();
      FastLED.delay(1);
    }
    leds[gStair].setHSV( 0, 0, 0);
    leds[gStair + 1*dir].setHSV( 0, 0, 0);
    FastLED.show();
  }
  lightsOn = LOW;

  Serial.println("Done");
}

// startup rainbow
void rainbow()
{
  // FastLED's built-in rainbow generator
  fill_rainbow( leds, NUM_LEDS, gHue, 7);
}
void rainbowWithGlitter()
{
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(80);
}

void addGlitter( fract8 chanceOfGlitter)
{
  if( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB::Grey;
  }
}

// Candle flicker.
void flicker(int8_t dir){
  setStartEnd(dir);
  static uint16_t i = 0;
  static uint8_t rnd = 0;
  uint8_t stair = 0;
  gBright = 0;
  for(gStair=gStairStart; (dir == 1 && gStair < gStairEnd ) || (dir == -1 && gStair >= gStairEnd && gStair <= gStairStart+1 ); gStair+=(2*dir)) {
    for( i = 0; i <= 18; i++ ) {
      for (stair = gStairStart; (dir == 1 && stair <= gStair ) || ( dir == -1 && stair >= gStair && stair <= gStairStart+1); stair+=(2*dir)) {
        rnd = random8(1, 4);
        if ( rnd == 2 ){
          gBright = random8(90,140);
          leds[stair] = CHSV( 60, 200, gBright );
          leds[stair + 1*dir] = CHSV( 60, 200, gBright );
        }
        FastLED.show();
      }
    }
  }
  // Wait
  Serial.println("Wait");
  for ( i=0; i<=300; i++) {
    for( gStair = 0; gStair < NUM_LEDS; gStair+=2) {
      rnd = random8(1, 4);
      if ( rnd == 2 ){
        gBright = random8(90,140);
        leds[gStair] = CHSV( 60, 200, gBright );
        leds[gStair+1] = CHSV( 60, 200, gBright );
      }
    }
    FastLED.show();
    FastLED.delay(25);
  }
  Serial.println("Shutdown");
  // Shutdown
  for(gStair=gStairStart; (dir == 1 && gStair <= gStairEnd ) || (dir == -1 && gStair >= gStairEnd && gStair <= gStairStart+1 ); gStair+=(2*dir)) {
    for( i = 0; i <= 18; i++) {
      for (stair = gStair; (dir == 1 && stair <= gStairEnd ) || ( dir == -1 && stair >= gStair && stair <= gStairStart+1); stair+=(2*dir)) {
        rnd = random8(1, 4);
        if ( rnd == 2 ){
          gBright = random8(90,140);
          leds[stair] = CHSV( 60, 200, gBright );
          leds[stair + 1*dir] = CHSV( 60, 200, gBright );
          leds[gStair] = CRGB( 0,0,0 );
          leds[gStair + 1*dir] = CRGB( 0,0,0 );
        }
        FastLED.show();
      }
    }
    leds[gStair] = CRGB( 0,0,0 );
    leds[gStair + 1*dir] = CRGB( 0,0,0 );
    FastLED.show();
    FastLED.delay(25);
  }
  lightsOn = LOW;
}

// Fade7 effect.
void fade7(int8_t dir){
  setStartEnd(dir);
  Serial.print("Fade7 dir: ");
  Serial.println(dir);
  const uint8_t mx = BRIGHTNESS;
  uint8_t r = mx;
  uint8_t g = 0;
  uint8_t b = 0;
  const uint8_t del = 25;
  boolean glitter = ( random8() < 120 );
  for(gStair=gStairStart; (dir == 1 && gStair < gStairEnd ) || (dir == -1 && gStair >= gStairEnd && gStair <= gStairStart+1 ); gStair+=(2*dir)) {
    for (r=0; r<mx; r+=2) {
      leds[gStair] = CRGB( r, g, b );
      leds[gStair + 1*dir] = CRGB( r, g, b );
      FastLED.show();
      FastLED.delay(1);
    }
  }
  for (b=0; b<mx; b++){
    fill_solid(leds, NUM_LEDS, CRGB( r, g, b ));
    if (glitter) addGlitter(80);
    FastLED.show();
    delay(del);
  }
  for (r=mx; r>0; r--){
    fill_solid(leds, NUM_LEDS, CRGB( r, g, b ));
    if (glitter) addGlitter(70);
    FastLED.show();
    delay(del);
  }
  for (g=0; g<mx; g++){
    fill_solid(leds, NUM_LEDS, CRGB( r, g, b ));
    if (glitter) addGlitter(60);
    FastLED.show();
    delay(del);
  }
  for (b=mx; b>0; b--){
    fill_solid(leds, NUM_LEDS, CRGB( r, g, b ));
    if (glitter) addGlitter(50);
    FastLED.show();
    delay(del);
  }
  for (r=0; r<mx; r++){
    fill_solid(leds, NUM_LEDS, CRGB( r, g, b ));
    if (glitter) addGlitter(40);
    FastLED.show();
    delay(del);
  }
  for (b=0; b<mx; b++){
    fill_solid(leds, NUM_LEDS, CRGB( r, g, b ));
    if (glitter) addGlitter(30);
    FastLED.show();
    delay(del);
  }
  for (b=mx; b>0; b--){
    g=b;
    fill_solid(leds, NUM_LEDS, CRGB( r, g, b ));
    if (glitter) addGlitter(10);
    FastLED.show();
    delay(del);
  }
  for(gStair=gStairStart; (dir == 1 && gStair <= gStairEnd ) || (dir == -1 && gStair >= gStairEnd && gStair <= gStairStart+1 ); gStair+=(2*dir)) {
    for (r=mx; r>1; r--) {
      leds[gStair] = CRGB( r, g, b );
      leds[gStair + 1*dir] = CRGB( r, g, b );
      FastLED.show();
      FastLED.delay(1);
    }
    r = 0; g = 0; b = 0;
    leds[gStair] = CRGB( r, g, b );
    leds[gStair + 1*dir] = CRGB( r, g, b );
    FastLED.show();
  }
  lightsOn = LOW;
}

void setStartEnd(int8_t dir){
  if (dir == 1){ //Down
    gStairStart = 0;
    gStairEnd = NUM_LEDS-1;
  } else {
    gStairStart = NUM_LEDS-1;
    gStairEnd = 0;
  }
}

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


is this enough to move?? (adding output to check it )

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


Added Cbor Serialbuffer send example.

Added Cbor Serialbuffer send example.

/*

Arduino Sketch to show how Send Encode Cbor package via Serial port

Author: Juanjo Tara
email:  j.tara@arduino.cc
date:   24/04/2015
*/

#include "CborEncoder.h"
#include "SerialBuffer.h"

#define SERIAL_PORT Serial

#define BUFFER_SIZE 32
unsigned char buffer[BUFFER_SIZE];

// declare the serial buffer
SerialBuffer serialBuffer;

void setup() {

  // set up the buffer storage and maximum size
  serialBuffer.buffer = buffer;
  serialBuffer.bufferSize = BUFFER_SIZE;

  // reset the buffer
  serialBuffer.reset();
  Serial.begin(115200);
  randomSeed(analogRead(0));

}

void loop() {

  testSerialPort();

  int maxBytes = SERIAL_PORT.available();
  while (maxBytes--) {

    byte inputByte = SERIAL_PORT.read();

    // present the input byte to the serial buffer for decoding
    // whenever receive() returns >= 0, there's a complete message
    // in the buffer ready for processing at offset zero.
    // (return value is message length)
    int bufferStatus = serialBuffer.receive(inputByte);

    if (bufferStatus >= 0) {

      // handle message
      // ...
      // ...

    }
  }
  delay(100);

}

void testSerialPort() {
    CborStaticOutput output(32);
    CborWriter writer(output);
    //Write a Cbor Package with a number and String
    int randNumb = random(15);
    for(int i = 0; i < randNumb; i++) {
      int numb = random(300);
      writer.writeInt(numb);
    }
    //writer.writeInt(0x7F);
    //writer.writeInt(0x7E);
    //writer.writeInt(0x7D);
    //writer.writeString("Hello David");
    //writer.writeInt(321);

    //get length and data of cbor package
    unsigned char *datapkg = output.getData();
    int length = output.getSize();
    serialBuffer.startMessage();
    for(int i = 0; i < length; i++) {
      serialBuffer.write(datapkg[i]);
    }
    serialBuffer.endMessage();
    //print in Serial port the Data length and Cbor in binary
    //Serial.print("datalength:");
    //Serial.print(output.getSize());
    //Serial.println(output.getSize());
    Serial.write(serialBuffer.buffer, serialBuffer.messageLength());
}

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