Added: RemoteLogger example

Added: RemoteLogger example

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

--- examples/ESP8266/RemoteLogger/RemoteLogger.ino
+++ examples/ESP8266/RemoteLogger/RemoteLogger.ino
@@ -0,0 +1,107 @@
+/*
+  RemoteLogger by Meeo
+
+  This example will make use of Meeo. If you haven't already,
+  visit Meeo at https://meeo.io and create an account. Then
+  check how to get started with the Meeo library through
+  https://github.com/meeo/meeo-arduino
+
+  Log important events and see it anywhere you go.
+  More details of the project here: https://meeo.io/l/1000
+
+  Copyright: Meeo
+  Author: Terence Anton Dela Fuente
+  License: MIT
+*/
+
+#include <Meeo.h>
+
+String nameSpace = "my_namespace";
+String accessKey = "my_access_key";
+String ssid = "MyWiFi";
+String pass = "qwerty123";
+String loggerChannel = "button-logs";
+
+#define BUTTON_A_PIN D1
+#define BUTTON_B_PIN D2
+uint8_t previousButtonAState = LOW;
+uint8_t previousButtonBState = LOW;
+
+unsigned long previous = 0;
+
+void setup() {
+  Serial.begin(115200);
+
+  Meeo.setEventHandler(meeoEventHandler);
+  Meeo.setDataReceivedHandler(meeoDataHandler);
+  Meeo.begin(nameSpace, accessKey, ssid, pass);
+  Meeo.setLoggerChannel(loggerChannel);
+
+  pinMode(BUTTON_A_PIN,INPUT);
+  pinMode(BUTTON_B_PIN,INPUT);
+}
+
+void loop() {
+  Meeo.run();
+
+  uint8_t buttonAState = digitalRead(BUTTON_A_PIN);
+  if( buttonAState != previousButtonAState){
+    delay(100); //Debounce
+    buttonAState = digitalRead(BUTTON_A_PIN);
+
+    if(buttonAState != previousButtonAState){
+      previousButtonAState = buttonAState;
+
+      if(buttonAState == HIGH){
+        Meeo.println("[INFO] Button A Pressed! " + String(millis()));
+      }
+    }
+  }
+  uint8_t buttonBState = digitalRead(BUTTON_B_PIN);
+  if( buttonBState != previousButtonBState){
+    delay(100); //Debounce
+    buttonBState = digitalRead(BUTTON_B_PIN);
+
+    if(buttonBState != previousButtonBState){
+      previousButtonBState = buttonBState;
+
+      if(buttonBState == HIGH){
+        Meeo.println("[ERROR] Button B Pressed! " + String(millis()));
+      }
+    }
+  }
+
+
+}
+
+void meeoDataHandler(String topic, String payload) {
+
+}
+
+void meeoEventHandler(MeeoEventType event) {
+  switch (event) {
+    case WIFI_DISCONNECTED:
+      Serial.println("Not Connected to WiFi");
+      break;
+    case WIFI_CONNECTING:
+      Serial.println("Connecting to WiFi");
+      break;
+    case WIFI_CONNECTED:
+      Serial.println("Connected to WiFi");
+      break;
+    case MQ_DISCONNECTED:
+      Serial.println("Not Connected to MQTT Server");
+      break;
+    case MQ_CONNECTED:
+      Serial.println("Connected to MQTT Server");
+      break;
+    case MQ_BAD_CREDENTIALS:
+      Serial.println("Bad Credentials");
+      break;
+    case AP_MODE:
+      Serial.println("AP Mode");
+      break;
+    default:
+      break;
+  }
+}


daily tuning

daily tuning

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


Added unit tests that run on target for the ApiClient class.

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

--- tests/ApiClientTest.ino
+++ tests/ApiClientTest.ino
@@ -0,0 +1,126 @@
+#line 2 "ApiClientTest.ino"
+#define private public
+#define OFFLINE
+#include <Arduino.h>
+#include <ArduinoUnit.h>
+#include <Bridge.h>
+#include <ApiClient.h>
+
+ApiClient client;
+
+test(setAuthorizationHeader)
+{
+  const __FlashStringHelper *auth_header_flashstring = F("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
+  client.setAuthorizationHeader(auth_header_flashstring);
+  assertEqual(client.auth_header.type, POINTER_UNION_TYPE_FLASHSTRING);
+  assertEqual(client.auth_header.u.flashstring_ptr, auth_header_flashstring);
+
+  String auth_header_string = String("00000000000000000000000000000000");
+  client.setAuthorizationHeader(&auth_header_string);
+  assertEqual(client.auth_header.type, POINTER_UNION_TYPE_STRING);
+  assertEqual(*client.auth_header.u.string_ptr, auth_header_string);
+
+  const char *auth_header_char = "00000000000000000000000000000000";
+  client.setAuthorizationHeader(auth_header_char);
+  assertEqual(client.auth_header.type, POINTER_UNION_TYPE_CHAR);
+  assertEqual(client.auth_header.u.char_ptr, auth_header_char);
+
+}
+
+test(setContentTypeHeader)
+{
+  const __FlashStringHelper *contenttype_header_flashstring = F("application/json");
+  client.setContentTypeHeader(contenttype_header_flashstring);
+  assertEqual(client.contenttype_header.type, POINTER_UNION_TYPE_FLASHSTRING);
+  assertEqual(client.contenttype_header.u.flashstring_ptr, contenttype_header_flashstring);
+
+  String contenttype_header_string = String("application/json");
+  client.setContentTypeHeader(&contenttype_header_string);
+  assertEqual(client.contenttype_header.type, POINTER_UNION_TYPE_STRING);
+  assertEqual(*client.contenttype_header.u.string_ptr, contenttype_header_string);
+
+  const char *contenttype_header_char = "application/json";
+  client.setContentTypeHeader(contenttype_header_char);
+  assertEqual(client.contenttype_header.type, POINTER_UNION_TYPE_CHAR);
+  assertEqual(client.contenttype_header.u.char_ptr, contenttype_header_char);
+
+}
+
+test(setUserAgentHeader)
+{
+  const __FlashStringHelper *useragent_header_flashstring = F("Arduino/0.1a");
+  client.setUserAgentHeader(useragent_header_flashstring);
+  assertEqual(client.useragent_header.type, POINTER_UNION_TYPE_FLASHSTRING);
+  assertEqual(client.useragent_header.u.flashstring_ptr, useragent_header_flashstring);
+
+  String useragent_header_string = String("Arduino/0.1a");
+  client.setUserAgentHeader(&useragent_header_string);
+  assertEqual(client.useragent_header.type, POINTER_UNION_TYPE_STRING);
+  assertEqual(*client.useragent_header.u.string_ptr, useragent_header_string);
+
+  const char *useragent_header_char = "Arduino/0.1a";
+  client.setUserAgentHeader(useragent_header_char);
+  assertEqual(client.useragent_header.type, POINTER_UNION_TYPE_CHAR);
+  assertEqual(client.useragent_header.u.char_ptr, useragent_header_char);
+
+}
+
+test(post)
+{
+  int retval = -1;
+
+  client.setContentTypeHeader(F("application/json"));
+  client.setAuthorizationHeader(F("00000000000000000000000000000000"));
+
+  String request = "curl -X POST -H \"Authorization: 00000000000000000000000000000000\" -H \"Content-Type: application/json\" -d '{}' https://api.keen.io/3.0/projects/000000000000000000000000/events/sign_ups";
+
+  retval = client.post(F("https://api.keen.io/3.0/projects/000000000000000000000000/events/sign_ups"), F("{}"));
+  assertEqual(client.request_buffer, request);
+  assertEqual(retval, 0);
+
+  String url_string = "https://api.keen.io/3.0/projects/000000000000000000000000/events/sign_ups";
+  String data_string = "{}";
+  retval = client.post(url_string, data_string);
+  assertEqual(client.request_buffer, request);
+  assertEqual(retval, 0);
+
+  char *url_char = "https://api.keen.io/3.0/projects/000000000000000000000000/events/sign_ups";
+  char *data_char = "{}";
+  retval = client.post(url_char, data_char);
+  assertEqual(client.request_buffer, request);
+  assertEqual(retval, 0);
+}
+
+test(get)
+{
+ int retval = -1;
+
+ retval = client.get(F("https://api.keen.io"));
+ assertEqual(retval, 0);
+
+ String url_string = "https://api.keen.io";
+ retval = client.get(url_string);
+ assertEqual(retval, 0);
+
+ char *url_char = "https://api.keen.io";
+ retval = client.get(url_char);
+ assertEqual(retval, 0);
+}
+
+void setup()
+{
+  pinMode(13, OUTPUT);
+  digitalWrite(13, LOW);
+  Bridge.begin();
+  digitalWrite(13, HIGH);
+
+  Serial.begin(115200);
+
+  while (!Serial); // wait for a serial connection
+}
+
+void loop()
+{
+  Test::run();
+}
+


Added special conditions for duty cycle interpretation

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 sensor.ino

Update sensor.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/Wobbe-Steeland/weather-station.git/'


example

example

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

--- pruebas_LearnCbot_h.ino
+++ pruebas_LearnCbot_h.ino
@@ -0,0 +1,52 @@
+
+#include "LearnCbot.h"
+
+LCbot lcbot;
+
+volatile int lapso;
+
+void setup() {
+    lcbot.ShowStart();
+
+    attachInterrupt(0,tope,FALLING);
+    attachInterrupt(1,zero,FALLING);
+}
+
+void loop() {
+    for (lapso = 200; lapso > 0; lapso--) {
+	clignoter(lapso);
+    }
+
+    for (lapso = 0; lapso < 200; lapso++) {
+	clignoter(lapso);
+    }
+}
+
+void clignoter(int lapso) {
+    for (int i = Led1_pin; i <= Led4_pin; i++) {
+
+	lcbot.set_on(i);
+
+	delay(lapso);
+
+	lcbot.set_off(i);
+
+	delay(lapso);
+    }
+}
+
+void tope() {
+    lapso = 200;
+    attandre();
+}
+
+void zero() {
+    lapso = 0;
+    attandre();
+}
+
+void attandre() {
+    for (int i = 0; i < 5000; i++) {
+	;
+    }
+}


Optocoupling

Optocoupling

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

--- Project_15/Project_15.ino
+++ Project_15/Project_15.ino
@@ -0,0 +1,23 @@
+const int optoPin = 2;
+int mode = 0;
+
+void setup() {
+  Serial.begin(9600);
+  pinMode(optoPin, OUTPUT);
+  Serial.println("Enter 0 or 1");
+}
+
+void loop() {
+  if (Serial.available()) {
+    mode = Serial.parseInt();
+    if (mode == 0) {
+      digitalWrite(optoPin, LOW);
+    }
+    else {
+      digitalWrite(optoPin, HIGH);
+    }
+    Serial.print("New value ");
+    Serial.println(mode);
+    Serial.println("Enter 0 or 1");
+  }
+}


added in-node program for boards with mma8452q sensor

error: pathspec 'src/ard/posture-mma8452q/posture-mma8452q.ino' did not match any file(s) known to git

--- src/ard/posture-mma8452q/posture-mma8452q.ino
+++ src/ard/posture-mma8452q/posture-mma8452q.ino
@@ -0,0 +1,279 @@
+//
+// Sloth: An Energy-Efficient Activity Recognition System
+// Copyright 2016 Pejman Ghorbanzade <mail@ghorbanzade.com>
+// Released under the terms of MIT License
+// https://github.com/ghorbanzade/sloth/blob/master/LICENSE
+//
+
+/**
+ * This program reads sensor data from MPU-6050 module, converts the
+ * acceleratiton data to the number assigned to a region of the
+ * recognition sphere the acceleration data points to, increments the
+ * element of activity code whose index corresponds to that region and
+ * after an interval of multiple sensor reading, transmits that array in
+ * one single packet.
+ *
+ * A sample packet has the form:
+ * |3|015|003|000|006|013|014|00a|02e|000|000|001|
+ *
+ * size of the array being transmitted depends on the number of regions
+ * on the recognition sphere which is calculated based on THETA_REGIONS
+ * macro.
+ */
+
+#define MY 3                    // Identifier for each sensor board
+#define INTERVAL 5000           // Sampling Time in (ms)
+#define THETA_REGIONS 8         // Number of sphere segments in zenith direction
+#define MATH_PI 3.14159         // Number PI
+#define MSG_LEN 128             // maximum length of the message to be transmitted
+
+// function to convert nibble to hex character
+#define TO_HEX(i) (i <= 9 ? '0' + i : 'A' - 10 + i)
+// offset to correct acceleration reading
+#define ACC_OFFSET_X 0
+#define ACC_OFFSET_Y 0
+#define ACC_OFFSET_Z 0
+// the threshold acceleration to interprete sensor reading as currupted
+#define MAX_ACCELERATION 1.2 * 16384
+
+#include <Wire.h>
+#include <SparkFun_MMA8452Q.h>
+
+/**
+ * a recognition model structure holds the total number of regions that
+ */
+struct recognition_model
+{
+	uint16_t num_region;
+	int *prsm;
+	int *aprm;
+};
+
+/**
+ * accelerations are read in three x, y, z orientations.
+ */
+enum acc
+{
+	ACC_X,
+	ACC_Y,
+	ACC_Z,
+	ACC_COUNT
+};
+
+/**
+ * global variables include the recognition model
+ */
+struct recognition_model model;
+
+/**
+ * global variable to store sensor readings
+ */
+MMA8452Q accel;
+
+/**
+ * this function will initialize the recognition model with information
+ * that will be used to quickly infer the sphere region based on obtained
+ * acceleration data.
+ *
+ * @param model the object whose members should be initialized
+ * @return zero for success and non-zero for failure
+ */
+int init_model(struct recognition_model *model)
+{
+	double trsm[THETA_REGIONS + 1];
+	double strm[THETA_REGIONS];
+	model->prsm = (int*) calloc(THETA_REGIONS, sizeof(int));
+	model->aprm = (int*) calloc(THETA_REGIONS, sizeof(int));
+	if (model->prsm == NULL)
+		return EXIT_FAILURE;
+	if (model->aprm == NULL)
+		return EXIT_FAILURE;
+	for (int i = 0; i < THETA_REGIONS + 1; i++)
+		trsm[i] = i * MATH_PI / THETA_REGIONS;
+	for (int i = 0; i < THETA_REGIONS; i++) {
+		strm[i] = cos(trsm[i]) - cos(trsm[i + 1]);
+		model->prsm[i] = round(strm[i] / strm[0]);
+	}
+	model->aprm[0] = 0;
+	for (int i = 1; i < THETA_REGIONS; i++)
+		model->aprm[i] = model->aprm[i - 1] + model->prsm[i - 1];
+	model->num_region = model->aprm[THETA_REGIONS - 1] + model->prsm[THETA_REGIONS - 1];
+	return EXIT_SUCCESS;
+}
+
+/**
+ * this function reads mpu6050 sensor and updates a given array with accelartion
+ * data.
+ *
+ * @param accs the array that should be initialized with acceleration data
+ */
+void read_raw_sensor_data(int16_t *accs)
+{
+	if (accel.available()) {
+		accel.read();
+		accs[ACC_X] = (int16_t) (accel.cx * 16384);
+		accs[ACC_Y] = (int16_t) (accel.cy * 16384);
+		accs[ACC_Z] = (int16_t) (accel.cz * 16384);
+	} else {
+		accs[ACC_X] = MAX_ACCELERATION;
+		accs[ACC_Y] = MAX_ACCELERATION;
+		accs[ACC_Z] = MAX_ACCELERATION;
+	}
+}
+
+/**
+ * Depending on how the sensor module is soldered and what resistors have
+ * been used on the module, sensor acceleration readings may have significant
+ * accuracies. To resolve this issue, the following functions adds an offset
+ * value to the sensor readings. These values defined as macros, should be
+ * obtained by uploading the calibrate.ino sketch on each board and monitoring
+ * received packets from the board while it has a steady state (e.g. placed
+ * on a table).
+ *
+ * @param accs acceleration data to be calibrated
+ */
+void calibrate(int16_t *accs)
+{
+	accs[ACC_X] += ACC_OFFSET_X;
+	accs[ACC_Y] += ACC_OFFSET_Y;
+	accs[ACC_Z] += ACC_OFFSET_Z;
+}
+
+/**
+ * Acceleration data read from the sensor are static acceleration together
+ * with dynamic acceleration caused by body movement. In case dynamic
+ * acceleration is not negligible (e.g. the subject is running), recognition
+ * model being used fails to correctly interpret the region numer. This
+ * function makes sure packets affected by dynamic acceleration are discarded
+ * and do not affect the activity code being constructed.
+ *
+ * @param accs acceleration data read from the sensor
+ * @return whether sensor data are severely affected by dynamic acceleration
+ */
+int is_currupt(int16_t *accs)
+{
+	int i;
+	for (i = 0; i < ACC_COUNT; i++) {
+		if (accs[i] >= MAX_ACCELERATION)
+			return 1;
+	}
+	return 0;
+}
+
+/**
+ * this function converts raw acceleration data to the number assigned to the
+ * region they are mapped to. It uses a previously initialized model to reduce
+ * the amount of required calculations.
+ *
+ * @param raw raw acceleration data read from the sensor
+ * @param region the variable to be updated based on acceleration data
+ * @param model the recognition model to be used to calculate the sphere region
+ */
+void process_region(
+	int16_t *raw,
+	uint8_t *region,
+	struct recognition_model const *const model
+) {
+	double phi, theta;
+	int16_t reg_phi, reg_theta;
+	phi = atan2(raw[ACC_Y], raw[ACC_X]) * 180.0 / MATH_PI + 180.0;
+	theta = atan2(sqrt(pow(raw[ACC_X], 2) + pow(raw[ACC_Y], 2)), raw[ACC_Z]) * 180 / MATH_PI;
+	reg_theta = floor(theta * THETA_REGIONS / 180.0) + 1;
+	if (phi >= 360.0 - 180.0 / model->prsm[reg_theta - 1])
+		reg_phi = 1;
+	else
+		reg_phi = floor(phi * model->prsm[reg_theta - 1] / 360.0 + 0.5) + 1;
+	*region = model->aprm[reg_theta - 1] + reg_phi;
+}
+
+/**
+ * This function resets the posture to all zeros every time a packet is
+ * transmitted.
+ *
+ * @param the array representing posture
+ * @param the size of the array
+ */
+void reset_posture(uint16_t *posture, uint8_t posture_size)
+{
+	for (int i = 0; i < posture_size; i++) {
+		posture[i] = 0;
+	}
+}
+
+/**
+ * This function takes a 1 byte integer and converts it to string
+ * representation of its hexa decimal equivalent.
+ *
+ * @param num the integer which should be converted to hexa
+ * @param ch a pointer to the string being built
+ */
+void uint16_to_hexstr(uint16_t num, char *ch)
+{
+	// most significant nibble is always 0
+	// ch[0] = TO_HEX(((num & 0xF000) >> 12));
+	ch[0] = TO_HEX(((num & 0x0F00) >> 8));
+	ch[1] = TO_HEX(((num & 0x00F0) >> 4));
+	ch[2] = TO_HEX((num & 0x000F));
+}
+
+/**
+ * After the listening time window is over, a string repreesntation of the
+ * activity code should be constructed for transmission. This function
+ * constructs the message to be sent which contains the id of the board and
+ * the activity code for passed time window.
+ *
+ * @param ch a pointer to the string that should be constructed
+ * @param posture the array of activity code
+ * @param size of the posture array (equal to number of regions in sphere)
+ */
+void build_message(char *ch, uint16_t *posture, uint16_t posture_size)
+{
+	int i;
+	sprintf(ch, "|%d|", MY);
+	while (*ch != '\0')
+		ch++;
+	for (i = 0; i < posture_size; i++) {
+		uint16_to_hexstr(posture[i], ch);
+		ch[3] = '|';
+		ch = ch + 4;
+	}
+	*ch++ = '\n';
+	*ch = '\0';
+}
+
+/**
+ * This function initializes the recognition model and prepares the board
+ * for reading MPU6050 and transmitting via zigbee module.
+ */
+void setup()
+{
+	init_model(&model);
+	Serial.begin(9600);
+	accel.init();
+}
+
+/**
+ * This function reads acceleration data from MPU-6050, converts them to the
+ * number assigned to a region of recognition sphere that the acceleration data
+ * is mapped to and transmits the region number via the zigbee module. This
+ * function is called repeatedly as long as the board is turned on.
+ */
+void loop()
+{
+	unsigned long tic = millis();
+	int16_t raw[ACC_COUNT];
+	uint16_t posture[model.num_region];
+	uint8_t region;
+	char message[MSG_LEN];
+	reset_posture(posture, model.num_region);
+	while (millis() - tic < INTERVAL) {
+		read_raw_sensor_data(&raw[0]);
+		calibrate(&raw[0]);
+		if (is_currupt(&raw[0]))
+			continue;
+		process_region(&raw[0], &region, &model);
+		posture[region - 1]++;
+	}
+	build_message(message, &posture[0], model.num_region);
+	Serial.write(message);
+}


Added electrode wear comp. and feed forward from RT material level comp.

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


MultiFlash example added

MultiFlash example added

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

--- ArduinoInteraktiv/examples/MultiFlash/MultiFlash.ino
+++ ArduinoInteraktiv/examples/MultiFlash/MultiFlash.ino
@@ -0,0 +1,14 @@
+#include <ArduinoInteraktiv.h>
+
+ArduinoInteraktiv camera;
+
+void setup()
+{
+}
+
+void loop()
+{
+  if (camera.GetPushButtonState() == HIGH) {
+  camera.MultiFlash();
+  }
+}


add Akeru skeleton

add Akeru skeleton

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

--- akeru_skeleton/akeru_skeleton.ino
+++ akeru_skeleton/akeru_skeleton.ino
@@ -0,0 +1,174 @@
+/*
+  Sigfox Akeru/Akene skeleton program
+
+  Note         : Take care to init SoftwareSerial for Akene or Akeru (see above)
+  With card(s) : 1. Akeru or Akene with UNO like board
+  License      : MIT
+
+*/
+
+// library
+// Arduino core
+#include <SoftwareSerial.h>
+// AVR low-power library (see https://github.com/rocketscream/Low-Power)
+#include "LowPower.h"
+
+// some const
+#define TEST_LED     13
+
+// some types
+typedef struct {
+  uint32_t test;
+} sigfox_payload;
+
+// some vars
+// Akeru UNB modem : S_RX is D4, S_TX is D5
+SoftwareSerial modem(5,4); //uC Rx D5, Tx D4
+// Akene UNB modem : S_RX is D5, S_TX is D4
+//SoftwareSerial modem(4,5); //uC Rx D4, Tx D5
+uint32_t tick_1s   = 0;
+bool debug_mode = 0;
+// link stdout (printf) to Serial object
+// create a FILE structure to reference our UART
+static FILE console_out = {0};
+// create a FILE structure to reference our UNB modem
+static FILE modem_out = {0};
+
+// create serial outputs functions
+// This works because Serial.write, although of
+// type virtual, already exists.
+static int console_putchar (char c, FILE *stream) {
+  Serial.write(c);
+  return 0;
+}
+
+static int modem_putchar (char c, FILE *stream) {
+  modem.write(c);
+  return 0;
+}
+
+void setup() {
+  // IO setup
+  pinMode(TEST_LED, OUTPUT);
+  // test led on
+  digitalWrite(TEST_LED, HIGH);
+  // open serial communications, link Serial to stdio lib
+  Serial.begin(9600);
+  // set the data rate for the SoftwareSerial port
+  modem.begin(9600);
+  //modem.setTimeout(5000);
+  // fill in the UART file descriptor with pointer to writer
+  fdev_setup_stream(&console_out, console_putchar, NULL, _FDEV_SETUP_WRITE);
+  fdev_setup_stream(&modem_out,   modem_putchar,   NULL, _FDEV_SETUP_WRITE);
+  // standard output device STDOUT is console
+  stdout = &console_out;
+  // fill in the UART file descriptor with pointer to writer
+  fdev_setup_stream(&console_out, console_putchar, NULL, _FDEV_SETUP_WRITE);
+  fdev_setup_stream(&modem_out,   modem_putchar,   NULL, _FDEV_SETUP_WRITE);
+  // standard output device STDOUT is console
+  stdout = &console_out;
+  // UNB modem boot time
+  fprintf_P(&console_out, PSTR("system startup\r\n"));
+  fprintf_P(&console_out, PSTR("wait 3s for UNB modem boot time...\r\n"));
+  delay(3000);
+  // test led off
+  digitalWrite(TEST_LED, LOW);
+  // set reroute (console <-> UNB modem) ?
+  fprintf_P(&console_out, PSTR("PRESS \"r\" key to reroute to UNB modem\r\n"));
+  fprintf_P(&console_out, PSTR("PRESS \"d\" key to set debug mode\r\n"));
+  fprintf_P(&console_out, PSTR("wait 4s...\r\n"));
+  uint8_t k_loop = 0;
+  char key;
+  while (k_loop++ < 4) {
+    delay(1000);
+    key = Serial.read();
+    if (key != -1) break;
+  }
+  // check user choice : debug
+  if (key == 'd') {
+    debug_mode = 1;
+    fprintf_P(&console_out, PSTR("debug mode on\r\n"));
+  // check user choice : reroute
+  } else if (key == 'r') {
+    // debug mode : reroute console to UNB modem
+    fprintf_P(&console_out, PSTR("reroute to UNB modem (reset board to exit this mode)\r\n"));
+    while (1)  {
+      // read from port 0, send to port 1:
+      while (Serial.available())
+        modem.write(Serial.read());
+      // read from port 1, send to port 0:
+      while (modem.available())
+        Serial.write(modem.read());
+    }
+  } else {
+    // startup message
+    fprintf_P(&console_out, PSTR("system ready\r\n"));
+  }
+}
+
+void loop() {
+  // vars
+  sigfox_payload s_pld;
+  // update tick
+  tick_1s++;
+  // send Sigfox frame
+  // send index: every 10 mins
+  if (tick_1s % 600 == 0) {
+    s_pld.test = tick_1s;
+    sig_send(&s_pld, sizeof(s_pld));
+  }
+  // debug mode
+  if (debug_mode) {
+    fprintf_P(&console_out, PSTR("tick_1s=%d\r\n"), tick_1s);
+  }
+  // flush serials before sleep
+  Serial.flush();
+  modem.flush();
+  // enter power down state for 1 s with ADC and BOD module disabled
+  LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
+}
+
+bool sig_send(const void* data, uint8_t len) {
+  // check param
+  if (len > 12)
+    return false;
+  // vars
+  char buffer[25];
+  char digits[3];
+  // init
+  strcpy_P(buffer, PSTR(""));
+  uint8_t* bytes = (uint8_t*)data;
+  // data -> hex string
+  for(uint8_t i = 0; i < len; ++i) {
+    sprintf(digits, "%02x", bytes[i]);
+    strcat(buffer, digits);
+  }
+  // send command
+  fprintf_P(&modem_out, PSTR("AT$SS=%s\r"), buffer);
+  // debug message
+  if (debug_mode) {
+    fprintf_P(&console_out, PSTR("send \"AT$SS=%s\"\r\n"), buffer);
+  }
+  return true;
+}
+
+// swap byte order function for 32 and 16 bits
+uint32_t bswap_32(uint32_t x) {
+  // vars
+  unsigned char c[4], temp;
+  // do swap
+  memcpy (c, &x, 4);
+  temp = c[0];
+  c[0] = c[3];
+  c[3] = temp;
+  temp = c[1];
+  c[1] = c[2];
+  c[2] = temp;
+  memcpy (&x, c, 4);
+  return (x);
+}
+
+uint16_t bswap_16(uint16_t x) {
+  return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
+}
+


Removed comments added String char[] parsing

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


Removed unnecessary invocation of Ethernet.maintain()

Since this example utilizes a statically assigned IP address, it is not necessary to call Ethernet.maintain().

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


Create midibody.ino

Create midibody.ino

The version 0

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

--- midibody.ino
+++ midibody.ino
@@ -0,0 +1,747 @@
+
+#include <math.h>
+#include <Wire.h>
+#include <LiquidCrystal_I2C.h>
+
+#include "I2Cdev.h"
+#include "MPU6050.h"
+
+#include <Stdio.h>
+
+//Arduino Leonardo: connect SDA to digital pin 2 and SCL to digital pin 3 on your Arduino.
+
+#if defined(ARDUINO) && ARDUINO >= 100
+#define printByte(args)  write(args);
+#else
+#define printByte(args)  print(args,BYTE);
+#endif
+
+LiquidCrystal_I2C lcd(0x20,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
+
+// class default I2C address is 0x68
+// specific I2C addresses may be passed as a parameter here
+// AD0 low = 0x68 (default for InvenSense evaluation board)
+// AD0 high = 0x69
+
+//*** MODES *****
+int fModeIR =0;
+int fModeMotion = 1;
+int fModeDirection = 0;
+
+
+MPU6050 accelgyro;
+
+int16_t ax, ay, az,axDelta,ayDelta,azDelta;
+int16_t axMax,axMin,ayMax,ayMin,azMax,azMin,gzMax,gzMin;
+int16_t gx, gy, gz,gxDelta,gyDelta,gzDelta;
+int16_t mx, my, mz;
+int16_t var_compass;
+
+char previousAx=0;
+char previousAy=0;
+char previousFB=0;
+
+int cNotes=0;
+int c=0,cMD=0,cResetMD=0;
+
+#define MIDI_MODE_NOTE 0
+#define MIDI_MODE_CHORDS 1
+#define MIDI_MODE_EX 2
+
+//#define DO   30
+
+#define DO   36
+#define DOd  37
+#define RE   38
+#define REd  39
+#define MIb  39
+#define MI   40
+#define FA   41
+#define FAd  42
+#define SOL  43
+#define SOLd 44
+#define LA   45
+#define LAd  46
+#define SIb  46
+#define SI   47
+#define DO_HIGH 48
+
+#define countChords 5 //=> change if you add chords
+
+int vNote= RE; // default note for snare
+
+  int chordsMajor[][5]={
+{DO,MI,SOL,DO-24,DO-12},
+{DO,FA,LA,FA-24,FA-12},
+{SOL,SI,RE,SOL-24,SOL-12},
+{RE,FAd,LA,RE-24,RE-12},
+{RE,SOL,LAd,LAd-24,LAd-12},
+};
+
+//******************************
+// les variables du programme
+
+int led = 13;
+
+#define SensorDirection_pin1  10
+#define SensorDirection_pin2  11
+
+
+int i=0;
+char a[17]; // pour stocker le texte à afficher sur le LCD
+int note=0;
+int currentNote=-1;
+int distance=0;
+int currentDistance = -1;
+int midiMode;
+int midiChannelDrum=10; // drums
+
+int iControler = 0;
+int controler;
+
+#define cControler 3
+char* TabControlerLabel[]= {"Filter Frequency", "Filter Reso.", "Volume"};
+int TabControler[]={74,42,7};
+
+int iMotionMode=0;
+int motionMode;
+
+#define MOTION_MODE_0  0
+#define MOTION_MODE_1  1
+
+#define cMotionMode 2
+char* TabMotionModeLabel[]= {"Motion Mode 0", "Motion Mode 1"};
+int TabMotionMode[]={MOTION_MODE_0, MOTION_MODE_1};
+// for string conversion, if you can't just do e.g. dir.toString():
+char * azimuthHeadings[] = { "E", "NE", "N", "NW", "W", "SW", "S", "SE" };
+
+
+unsigned long timerButtons;                               // create a time variable
+unsigned long timerMotion;
+unsigned long timerLastDrum=0;
+unsigned long lastAzNegTime=0xFFFFFFFF;
+unsigned long lastAzPlusTime=0xFFFFFFFF;
+unsigned long tAzP=0;
+unsigned long tAzM=0;
+unsigned long tStartNote=0;
+int16_t accelSensitivity=2000;
+unsigned int azimuth=0;
+unsigned int velocity;
+int lastNote;
+boolean up= true;                                 // create a boolean variable
+unsigned long irTimer ;                           // timer for managing the sensor reading flash rate
+boolean fRight=true;
+boolean fVertical=false;
+
+int16_t lastAzMin=0;
+
+//******************************
+// fonction pour afficher un texte sur la 2eme ligne du LCD (pour debugger)
+void displayL1(char* t)
+{
+ char a[17];
+ int l,i;
+
+ for (l=0; l<16; l++) {if (t[l]==0) break; a[l]=t[l];}
+ for (i=l; i<16; i++) a[i]=' ';
+ a[16]=0;
+ lcd.setCursor(0, 0); // curseur sur colonne 0 et ligne 0 (0=ligne haute, 1 =ligne basse)
+ lcd.print(a); // affiche texte
+}
+
+//******************************
+// fonction pour afficher un texte sur la 2eme ligne du LCD (pour debugger)
+void displayL2(char* t)
+{
+ char a[17];
+ int l,i;
+
+ for (l=0; l<16; l++) {if (t[l]==0) break; a[l]=t[l];}
+ for (i=l; i<16; i++) a[i]=' ';
+ a[16]=0;
+ lcd.setCursor(0, 1); // curseur sur colonne 0 et ligne 1 (0=ligne haute, 1 =ligne basse)
+ lcd.print(a); // affiche texte
+ }
+
+//******************************
+const int key_S1_5 = 7; // pind de la mesure des boutons 1 a 5
+
+int boutons_check(){
+// Cette fonction vérifie les boutons et retourne
+// 0 si pas de bouton appuyé ou sinon 1 à 5 suivant S1...S5
+// Priorités : S1, S2, S3, S4, S5
+
+int w = analogRead(key_S1_5);
+
+#define vS1 0
+#define vS2 130
+#define vS3 306
+#define vS4 478
+#define vS5 720
+if ( w < vS2/2 ) return 1;
+if ( w < (vS3+vS2)/2 ) return 2;
+if ( w < (vS4+vS3)/2 ) return 3;
+if ( w < (vS5+vS4)/2 ) return 4;
+if ( w < (1024+vS5)/2 ) return 5;
+return 0;
+}
+
+//*********************
+void calibrate()
+{
+accelgyro.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);
+axDelta=-ax; ayDelta=-ay; azDelta=-az;
+//gxDelta=-gx; gyDelta=-gy; gzDelta=-gz; //no need
+
+}
+
+//***********************
+void computeAzimuth()
+{
+float angle;
+/*
+  var_compass=atan2((double)my,(double)mx) * (180 / PI) -90; // angle in degrees
+if (var_compass>0){var_compass=var_compass-360;}
+var_compass=(360+var_compass);
+Serial.print("AAzimuth meth1: ");Serial.print(var_compass);Serial.print("\t");
+*/
+// actual conversion code:
+angle = atan2( my, mx );
+azimuth = round( 8 * angle / (2*PI) + 8 ) % 8;
+
+/*
+Serial.print("AAzimuth meth2: ");Serial.print(angle); Serial.print(" "); Serial.print(headings[octant]);
+Serial.print(" ");
+
+// from diy.powet.eu
+angle = (180*(atan2(-my, mx )/PI))+180;
+Serial.print("AAzimuth meth3: ");Serial.print(angle); Serial.print(" \t");
+*/
+
+}
+
+//***********************
+void initializeMotionSensor()
+{
+      // join I2C bus (I2Cdev library doesn't do this automatically)
+    Wire.begin();
+
+    displayL1("Init motion...");
+    accelgyro.initialize();
+
+    accelgyro.setMotionDetectionThreshold(1);
+    accelgyro.setMotionDetectionDuration(1);
+    accelgyro.setZeroMotionDetectionThreshold(10);
+    accelgyro.setZeroMotionDetectionDuration(1);
+
+    // verify connection
+    displayL1("Chk motion sens.");
+    if (accelgyro.testConnection()) displayL1("MPU9150 Cnx OK"); else displayL1("MPU9150 Cnx FAILED!");
+
+    //attachInterrupt(0, acceleroInterrupt, RISING);
+
+    accelgyro.setIntEnabled(0x40);
+    //accelgyro.setIntEnabled(MPU6050_INTERRUPT_FF_BIT|MPU6050_INTERRUPT_MOT_BIT|MPU6050_INTERRUPT_ZMOT_BIT);
+    //m=accelgyro.getInterruptMode();
+    //sprintf(a,"InterruptMode = %d\t",m); Serial.print(a);
+    //accelgyro.setIntEnabled(MPU6050_INTERRUPT_FF_BIT);
+    //accelgyro.setIntEnabled(MPU6050_INTERRUPT_ZMOT_BIT);
+
+    calibrate();
+}
+
+
+//**************************************
+void setup()
+{
+  lcd.init();                      // initialize the lcd
+  lcd.backlight();
+  lcd.home();
+  lcd.print("MIDI Body V1");
+
+  pinMode(led, OUTPUT);
+  pinMode(SensorDirection_pin1, INPUT);
+  pinMode(SensorDirection_pin2, INPUT);
+
+ Serial.begin(31250); // supprimer pour ne pas faire de midi
+
+ midiMode= MIDI_MODE_CHORDS;
+ motionMode = TabMotionMode[MOTION_MODE_0];
+
+// displayL1("Play Chords");
+
+ initializeMotionSensor();
+ delay(1000);
+ displayL1("MidiBody V1");
+}
+
+
+//********************************
+// si on veut que les boutons commandent la pince
+void actionBoutonMotionMode (int bouton)
+{
+ if ( bouton >0 )
+ {
+  if (bouton ==1)
+   {
+     midiMode= MIDI_MODE_NOTE;
+     displayL1("Play Notes");
+   }
+  else if (bouton == 2)
+   {
+    if (accelSensitivity<30000) accelSensitivity+=1000;
+    else accelSensitivity=0;
+    sprintf(a,"Sensit=%d",accelSensitivity); displayL2(a);
+   }
+  else if (bouton == 3)
+   {
+    if (accelSensitivity>1000) accelSensitivity-=1000;
+    else accelSensitivity=30000;
+        sprintf(a,"Sensit=%d",accelSensitivity); displayL2(a);
+   }
+  else if (bouton == 4)
+   {
+    sprintf(a,"Note=%d",++vNote); displayL2(a);
+   }
+  else if (bouton == 5)
+   {
+    sprintf(a,"Note=%d",--vNote); displayL2(a);
+   }
+
+
+ }
+}
+
+//********************************
+// si on veut que les boutons commandent la pince
+void actionBouton (int bouton)
+{
+ if ( bouton >0 )
+ {
+//   sprintf(a,"Bouton %d", bouton);
+//   displayL1(a);
+  // un bouton est appuyé
+  if (bouton ==1)
+   {
+     midiMode= MIDI_MODE_NOTE;
+     displayL1("Play Notes");
+   }
+  else if (bouton == 2)
+   {
+     midiMode= MIDI_MODE_CHORDS;
+     displayL1("Play Chords");
+   }
+  else if (bouton == 3)
+   {
+     midiMode= MIDI_MODE_EX;
+     displayL1("MIDI Exclusive");
+   }
+  else if (bouton == 4)
+   {
+    if (iControler<cControler-1) iControler++;
+    else iControler = 0;
+    sprintf(a,"%s", TabControlerLabel[iControler]);
+    controler = TabControler[iControler];
+    displayL1(a);
+   }
+  else if (bouton == 5)
+   {
+    if (iMotionMode<cMotionMode-1) iMotionMode++;
+    else iMotionMode = 0;
+    sprintf(a,"%s", TabMotionModeLabel[iMotionMode]);
+    motionMode = TabMotionMode[iMotionMode];
+    displayL1(a);
+   }
+
+
+ }
+}
+
+//*********************************
+void midiNoteOn(int c, int pitch, int velocity) {
+  Serial.write(0x90-1+c); // Note on: hexa 9n  n= midi channel
+  Serial.write(pitch);
+  Serial.write(velocity);
+}
+
+//*********************************
+void midiNoteOff(int c, int pitch, int velocity) {
+  Serial.write(0x80-1+c); // note off: hexa 8n
+  Serial.write(pitch);
+  Serial.write(velocity);
+}
+
+//*********************************
+void playNote(int cmd, int pitch, int velocity) {
+  Serial.write(cmd);
+  Serial.write(pitch);
+  Serial.write(velocity);
+}
+
+
+//*********************************
+void playChord(int cmd, int pitch, int velocity) {
+  int shift;
+
+pitch = pitch;
+
+//30,32,34,35,37,39,41, 42,44,46,47,49,51,53, 54,56,58,59,61,63,65, 66,68,70,71,73,75,77, 78,80,82,83,85,87,89, 90,92,94,95,97,99,101, 30,32,33,35,37,40, 42,44,45,47,49,52, 54};
+if (pitch >= countChords) return;
+
+ shift= 24;
+  Serial.write(cmd);  Serial.write(chordsMajor[pitch][0]+shift);  Serial.write(velocity);
+  Serial.write(cmd);  Serial.write(chordsMajor[pitch][1]+shift);  Serial.write(velocity);
+  Serial.write(cmd);  Serial.write(chordsMajor[pitch][2]+shift);  Serial.write(velocity);
+  Serial.write(cmd);  Serial.write(chordsMajor[pitch][3]+shift);  Serial.write(velocity);
+  Serial.write(cmd);  Serial.write(chordsMajor[pitch][4]+shift);  Serial.write(velocity);
+
+}
+
+//********************************
+void midiControler(int i)
+{
+// midi controls: Bn , Number, Value (0-127)
+
+if (i>127) i=127;
+
+  Serial.write(0xB0);
+  Serial.write(controler);
+  Serial.write(i);
+}
+
+
+#define thresholdAPlus 3000
+#define thresholdAMinus 3000
+
+//**************************
+int16_t isOver(int16_t i)
+{
+   if (((i>0) && (i <thresholdAPlus)) || ((i<0) && (i>-thresholdAMinus))) return 0;
+   else return i;
+}
+
+//**************************
+char* displayVal(char *txt, int16_t i)
+{
+    if (!isOver(i)) sprintf(txt," ");
+    else { if (i>0) sprintf(txt,"+"); else sprintf(txt,"-");   }
+return txt;
+}
+
+//*******************************
+void actionDirection()
+{
+char a[32];
+int rl; // right, left flag
+int bf; // backward forward flag
+
+bf = digitalRead(SensorDirection_pin1);
+rl = digitalRead(SensorDirection_pin2);
+
+sprintf(a,"rl: %d, bf: %d", rl, bf);
+displayL2(a);
+
+if ((previousFB=='B') && (bf==0)) // sensor was backward and moved forward
+ {
+  playNote(0x90,DO,0x45);
+  previousFB='F';
+ }
+
+else
+{
+  if ((previousFB=='F') && (bf==0)) playNote(0x80,DO,0);
+    previousFB=(bf==1)? 'B':'F';
+}
+
+}
+
+//*******************************
+void actionMotion()
+{
+char a[32];// should be 17 max...we keep more, not clean but good enough
+char aa[17];
+char b[16];
+unsigned long t;
+int fDisplay = 0;
+
+//#define minBetweenDrum_  100
+
+//if (timerLastDrum + minBetweenDrum_ > millis()) return;
+//timerLastDrum=millis();
+
+accelgyro.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);
+if (az<lastAzMin) lastAzMin=az;
+
+ax+=axDelta; ay+=ayDelta; az+=azDelta; gx+=gxDelta; gy+=gyDelta; gz+=gzDelta;
+
+if ((az>0) && (az>azMax)) { azMax= az; } //sprintf (a,"az max=%d",azMax); displayL1(a);}
+if ((az<0) && (az<azMin)) { azMin= az; }; //sprintf (a,"az min=%d",azMin); displayL2(a);}
+//if ((gz>0) && (gz>gzMax)) { gzMax= gz; sprintf (a,"gz max=%d",gzMax); displayL1(a);}
+//if ((gz<0) && (gz<gzMin)) { gzMin= gz; sprintf (a,"gz min=%d",gzMin); displayL2(a);}
+
+if (gz>20000) fRight=false;
+else if (gz<-20000) fRight=true;
+
+t=millis();
+
+// added for synth who need a note off. electronic drums usually dont.
+if (tStartNote && (t - tStartNote >100)) // there is a Note ON since more than xxx milli -> we stop it.
+ {
+  //midiNoteOff(midiChannelDrum,lastNote,0x45); // note on & off
+  tStartNote = 0;
+ }
+
+if ((az<-accelSensitivity) && !tAzM) // we detect a start of move down -negative az
+ {
+   tAzM=t;
+   cMD++;
+   fDisplay=0;
+  }
+/*
+else if (tAzM && (t-tAzM > 200)) // we reset move down time to ignore the previous move - pas au point...
+ {
+   cResetMD++;
+   tAzM=0;
+   fDisplay=1;
+ }
+*/
+
+if ((az>accelSensitivity) && !tAzP && tAzM) // we detect a decceleration after an accel Negative (a tap down)
+ {
+  //computeAzimuth();  //{ "E", "NE", "N", "NW", "W", "SW", "S", "SE" };
+
+  if (lastAzMin==-32768) lastAzMin=-32767; // to correct the extreme case cuasing a bug...
+
+  if (ay<-2000) fVertical=false;
+  else fVertical=true;
+
+  velocity=map(-lastAzMin,-azMax,-azMin,0,126); // set the note velocity depending on negative accel. int16_t is from -32678 to +32767
+  if (fRight)
+   {
+    if (fVertical) midiNoteOn(midiChannelDrum,lastNote= 37,velocity);
+    else  midiNoteOn(midiChannelDrum,lastNote= DO,velocity); //kick
+   }
+  else
+   {
+     if (fVertical) midiNoteOn(midiChannelDrum,lastNote=49,velocity);      // crash:49
+     else midiNoteOn(midiChannelDrum,lastNote= vNote,velocity);
+   }
+
+  tStartNote = t;
+  cNotes++;
+  tAzM=0;
+  //lastAzMin=0;
+
+  fDisplay=0;
+//   sprintf(a,"N=%d MD=%d %d",cNotes,cMD,fRight); displayL1(a);
+   aa[0]=(fRight)?'R':'L';    aa[1]=(fVertical)?'V':'H';   aa[2]=0;
+
+   sprintf(a,"%d %d",azMin,azMax); displayL1(a);
+   sprintf(a,"%s %d %d %d",aa,lastNote,velocity,ay); displayL2(a);
+
+   lastAzMin=32767;
+
+ }
+
+ if (fDisplay==1)
+  {
+//   if (  tStartNote == t) lastAzMin=0;
+  }
+
+
+}
+
+
+//*******************************
+void actionMotionOld2()
+{
+char a[32];
+char b[16];
+#define minBetweenDrum_  100
+
+//if (timerLastDrum + minBetweenDrum_ > millis()) return;
+//timerLastDrum=millis();
+
+accelgyro.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);
+ax+=axDelta; ay+=ayDelta; az+=azDelta; gx+=gxDelta; gy+=gyDelta; gz+=gzDelta;
+
+if ((az>0) && (az>azMax)) { azMax= az; sprintf (a,"az max=%d",azMax); displayL1(a);}
+if ((az<0) && (az<azMin)) { azMin= az; sprintf (a,"az min=%d",azMin); displayL2(a);}
+
+
+if (az<-3000)
+ {
+  if (lastAzPlusTime+200<millis()) //detect note at deceleraton just after accel
+   {
+  playNote(0x90,SOL,0x45); delay (10); playNote(0x80,SOL,0x45);
+
+  sprintf(a,"c=%d az=%d",++cNotes,az); displayL1(a);
+  sprintf(a,"%l",millis()); displayL2(a);
+  lastAzNegTime=0xFFFFFFFF;
+  }
+
+   else lastAzNegTime= millis();
+ }
+
+else if (az>3000)
+ {
+  if (lastAzNegTime+200<millis()) //detect note at deceleraton just after accel
+   {
+  playNote(0x90,DO,0x45); delay (10); playNote(0x80,DO,0x45);
+
+  sprintf(a,"c=%d az=%d",++cNotes,az); displayL1(a);
+  lastAzPlusTime=0xFFFFFFFF;
+   }
+  //timerLastDrum=millis();
+  else lastAzPlusTime= millis();
+ }
+
+
+}
+
+//*******************************
+void actionMotionOld()
+{
+char a[32];
+char b[16];
+
+accelgyro.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);
+ax+=axDelta; ay+=ayDelta; az+=azDelta; gx+=gxDelta; gy+=gyDelta; gz+=gzDelta;
+
+//az -=16000; // is at this value when nothing moves...
+
+//kick on ax
+
+a[0]=0;
+//strcat (a,displayVal(b,ax));
+
+displayVal(b,ax);
+if ((previousAx=='+') && (b[0]=='-'))
+ {
+  playNote(0x80,SOL,0);
+  playNote(0x90,DO,0x45);
+  previousAx='-';
+ }
+else if ((previousAx=='-') && (b[0]=='+'))
+ {
+  playNote(0x80,DO,0);
+  playNote(0x90,SOL,0x45);
+  previousAx='+';
+ }
+
+else previousAx=b[0];
+
+displayVal(b,ay);
+if ((previousAy=='+') && (b[0]=='-'))
+ {
+  playNote(0x80,SIb,0);
+  playNote(0x90,SIb,0x45);
+  previousAy='-';
+ }
+else if ((previousAy=='-') && (b[0]=='+'))
+ {
+  playNote(0x80,SIb,0);
+  playNote(0x90,SIb,0x45);
+  previousAy='+';
+ }
+
+else previousAy=b[0];
+
+
+displayL2(b);
+}
+
+
+//********************************
+// la boucle principale
+void loop()
+{
+char a[32];
+int v,cm;
+
+//*******************************************
+// test si un bouton est appuyé et decide quoi faire en conséquence
+  if(millis()-timerButtons>=200) // interval
+   {
+    timerButtons = millis();                              // get the current time of programme
+
+     int bouton = boutons_check();
+     if (fModeMotion) actionBoutonMotionMode(bouton);
+     else actionBouton(bouton);
+    }
+
+ if((fModeMotion||fModeDirection) && (millis()-timerMotion>=5))
+   {
+    if (fModeMotion) actionMotion();
+    if (fModeDirection) actionDirection();
+    timerMotion = millis();
+    }
+
+
+ //********************************
+ // measure interval
+  if(fModeIR && ((millis() - irTimer > 50) ))
+   {
+     int gMajeur[]={30,32,34,35,37,39,41, 42,44,46,47,49,51,53, 54,56,58,59,61,63,65, 66,68,70,71,73,75,77, 78,80,82,83,85,87,89, 90,92,94,95,97,99,101, 30,32,33,35,37,40, 42,44,45,47,49,52, 54};
+
+    irTimer = millis();
+    float val=analogRead(0);                      // Read ir distance sensor data
+    int distance=6787.0 /(val - 3.0) - 4.0;     // Convert to the distance - cm
+
+      if (distance < 90)
+      {
+       cm = distance;
+       distance=distance -6; // zero for minimum distance of the cqpteru (usually 6 cm)
+       distance = distance /3;
+
+       if (distance != currentDistance) // we play new note or chord
+        {
+         currentDistance=distance;
+
+         if (midiMode == MIDI_MODE_NOTE)
+          {
+           if (currentNote != -1) playNote(0x90,currentNote,0);  // stop note avec velocité zero
+           currentNote = gMajeur[distance];
+           sprintf(a,"pos:%d,note:%d", distance,currentNote);
+           displayL2(a);
+           playNote(0x90,currentNote,0x45);
+         delay (100);
+          }
+
+         else if (midiMode == MIDI_MODE_CHORDS) // mode chords
+          {
+           if (currentNote !=0) playChord(0x90,currentNote,0);
+           currentNote = distance;
+           playChord(0x90,currentNote,0x45);
+           sprintf(a,"pos:%d,ChordIdx:%d", distance,currentNote);
+           displayL2(a);
+           delay (100);
+          }
+
+         else if (midiMode == MIDI_MODE_EX) // mode MIDI Exclusive to control filter, volume, etc...
+          {
+            cm-=6;
+            v = cm*2;
+            if (v>127) v=127;
+            midiControler(v);
+           sprintf(a,"pos:%d,V:%d", cm,v);
+           displayL2(a);
+          }
+
+
+       }
+      }
+     else // distance >90, on arrete la note qui joue si il y en a une
+      {
+       if (currentNote != -1)
+        {
+          if (midiMode == MIDI_MODE_NOTE) playNote(0x80,currentNote,0); // stop note avec velocité zero
+          else if (midiMode == MIDI_MODE_CHORDS) playChord(0x80,currentNote,0x0);
+
+          currentNote=-1;
+          currentDistance = -1;
+          displayL2("Jouez ...");
+         }
+      }
+   }
+}


Distance-keeping example program.

Distance-keeping example program.

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

--- robot_arm_assign2_extra/robot_arm_assign2_extra.ino
+++ robot_arm_assign2_extra/robot_arm_assign2_extra.ino
@@ -0,0 +1,101 @@
+/**
+ *             robot_arm_assign2_extra.ino
+ * Purpose:    Keeps the sonar sensor at a constant distance from a surface.
+ *
+ * @author:    Tyler Lucas
+ * Student ID: 3305203
+ * Date:       October 3, 2017
+ * Version     0.1
+ *
+ * References: N/A
+ *
+ */
+
+
+#include <Servo.h>  // servo library
+
+#define sonarTrigPin 13
+#define sonarEchoPin 12
+#define servo0PWMPin 11
+
+Servo servo;
+int angle = 90;
+
+void setup()
+{
+  servo.attach( servo0PWMPin );
+
+  pinMode(sonarTrigPin, OUTPUT);
+  pinMode(sonarEchoPin, INPUT);
+
+  Serial.begin(9600);
+
+  servo.write( angle );
+  delay(1000);
+}
+
+void loop()
+{
+  double d_now = readSonarAverage(10);
+  double d_hold = d_now;
+  double d_error;
+
+  while (1)
+  {
+    d_error = d_now - d_hold;
+
+    if (d_error > 5)
+      angle -= 2;
+
+    if (d_error < -5)
+      angle += 2;
+
+    angle = constrain(angle, 30, 120);
+
+    servo.write( angle );
+
+    Serial.println();
+    Serial.print("Distance (current): ");
+    Serial.print( d_now );
+    Serial.print(" [mm] -- (holding): ");
+    Serial.print( d_hold );
+    Serial.print(" [mm] - Angle: ");
+    Serial.print( angle );
+    Serial.print("[deg]");
+
+    delay(25);
+
+    d_now = readSonarAverage(5);
+  }
+}
+
+double readSonar()
+{
+  long duration;
+
+  digitalWrite(sonarTrigPin, LOW);
+  delayMicroseconds(2);
+  digitalWrite(sonarTrigPin, HIGH);
+  delayMicroseconds(10);
+  digitalWrite(sonarTrigPin, LOW);
+
+  duration = pulseIn(sonarEchoPin, HIGH);
+  return 0.146 * duration - 23.843;  // returns in mm
+}
+
+double readSonarAverage(int count)
+{
+  double sum = 0;
+  for (int i=0; i<count; i++)
+    sum += readSonar();
+  return sum / count;
+}
+
+double analogReadAverage(int pin, int count)
+{
+  double sum = 0;
+  for (int i=0; i<count; i++)
+    sum += analogRead(pin);
+  return sum / count;
+}
+


fixing signing??

fixing signing??

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 arduino led controller code

added arduino led controller code

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

--- arduino/src/robotLEDControllerrev2/robotLEDControllerrev2.ino
+++ arduino/src/robotLEDControllerrev2/robotLEDControllerrev2.ino
@@ -0,0 +1,304 @@
+// Program to control the adressable LED strip using input from
+// the digital sidecar
+//
+// Functions:
+// -distance from wall
+// -shooting animation
+// -when the ball is in the craddle
+// -ground pass
+// -catch
+// -idle: purple, newton's ball, one led going around,
+// -winning dance
+// Diagrams of robot:
+//   =========Front:==========
+//     .__________________.
+//  58 |       Top        | 21
+//  57 |                  | 22
+//   . |                  | .
+//   . |     Sponsor      | .
+//   . |      Panel       | .
+//  41 |                  | 38
+//  40 |      Bottom      | 39
+//     .------------------.
+//   =========Back:==========
+//     .__________________.
+//  58 |       Top        | 21
+//  59 |                  | 20
+//   . |     Back of      | .
+//   . |     Sponsor      | .
+//   . |      Panel       | .
+//  78 |                  | 1
+//  79 |      Bottom      | 0
+//     .------------------.
+
+//The led strip library
+#include <FastLED.h>
+
+//led string stuff:
+const int ledsNumber = 80; //number of leds on the strip
+int stripBrightness = 0;
+CRGB leds[ledsNumber];
+
+//color data
+uint32_t distanceColor = 0xFF0000; //start off with the color being red
+
+//used for debugging
+int x;
+int incomingByte;
+
+//communication data
+boolean dataRecieved[] = {
+  false, false, false};
+
+//for animations
+int shooterFrontRight = 39;
+int shooterFrontLeft = 40;
+int shooterBackLeft = 76;
+int shooterBackRight = 3;
+
+
+void setup(){
+
+  //communication pin
+  pinMode(3, INPUT);
+
+  //interupt pin
+  attachInterrupt(0, readSidecar, RISING);
+
+  //setup the led strip
+  FastLED.addLeds<WS2801, RGB>(leds, ledsNumber);
+
+  //clear the LED strip data
+  FastLED.clear();
+
+  //Debugging
+  Serial.begin(9600);  //For debugging
+}
+
+void loop(){
+  //for debugging
+  //Serial.println("It works!");
+
+  //  //for debugging
+  //  Serial.print("Data: ");
+  //  Serial.print(dataRecieved[0]);
+  //  Serial.print(dataRecieved[1]);
+  //  Serial.println(dataRecieved[2]);
+  //  delay(80);
+
+  //for testing
+  if (Serial.available() > 0) {
+    // read the incoming byte:
+    incomingByte = Serial.read();
+  }
+  if (incomingByte == 97){ //a
+    dataRecieved[0] = false;
+    dataRecieved[1] = false;
+    dataRecieved[2] = false;
+    //    clearLeds();
+  }
+  else if (incomingByte == 98){ //b
+    dataRecieved[0] = true;
+    dataRecieved[1] = false;
+    dataRecieved[2] = false;
+    //    setRed();
+  }
+  else if (incomingByte == 99){ //c
+    dataRecieved[0] = false;
+    dataRecieved[1] = true;
+    dataRecieved[2] = true;
+    //    setGreen();
+  }
+  else if (incomingByte == 100){ //d
+    dataRecieved[0] = false;
+    dataRecieved[1] = true;
+    dataRecieved[2] = false;
+    //    shootAndCollect();
+  }
+  else if (incomingByte == 101){ //e
+    distanceColor = 0x008000;
+  }
+
+  //Possible cases
+  if (dataRecieved[0] == false && dataRecieved[1] == false && dataRecieved[2] == false){
+    //clears the strip
+    clearLeds();
+
+    //ensure the variables stay the same
+    dataRecieved[0] = false;
+    dataRecieved[1] = false;
+    dataRecieved[2] = false;
+    delay(10);
+  }
+  else if (dataRecieved[0] == true && dataRecieved[1] == false && dataRecieved[2] == false){
+    //sets the strip to red and the distance color to red
+    setRed();
+    distanceColor = 0xFF0000;
+
+    //ensure the variables stay the same
+    dataRecieved[0] = true;
+    dataRecieved[1] = false;
+    dataRecieved[2] = false;
+    delay(10);
+  }
+  else if (dataRecieved[0] == false && dataRecieved[1] == true && dataRecieved[2] == false){
+    //plays animation when shooting or collecting
+    shootAndCollect();
+
+    //ensure the variables stay the same
+    dataRecieved[0] = false;
+    dataRecieved[1] = true;
+    dataRecieved[2] = false;
+    delay(10);
+  }
+  else if (dataRecieved[0] == false && dataRecieved[1] == false && dataRecieved[2] == true){
+    //play animation when a ball is in the shooter
+    set____();
+
+    //ensure the variables stay the same
+    dataRecieved[0] = false;
+    dataRecieved[1] = false;
+    dataRecieved[2] = true;
+    delay(10);
+  }
+  else if (dataRecieved[0] == false && dataRecieved[1] == true && dataRecieved[2] == true){
+    //play animation when disabled
+    setGreen();
+    distanceColor = 0x008000;
+
+    //ensure the variables stay the same
+    dataRecieved[0] = false;
+    dataRecieved[1] = true;
+    dataRecieved[2] = true;
+    delay(10);
+  }
+  else if (dataRecieved[0] == true && dataRecieved[1] == true && dataRecieved[2] == false){
+    //signal to other teams
+    signal();
+
+    //ensure the variables stay the same
+    dataRecieved[0] = true;
+    dataRecieved[1] = true;
+    dataRecieved[2] = false;
+    delay(10);
+  }
+
+}
+
+
+void readSidecar(){
+  //reads the data coming from the sidecar when the interrupt is detected
+  delayMicroseconds(5000);
+  dataRecieved[0] = digitalRead(3);
+  delayMicroseconds(10000);
+  dataRecieved[1] = digitalRead(3);
+  delayMicroseconds(10000);
+  dataRecieved[2] = digitalRead(3);
+  delayMicroseconds(100000);
+}
+
+void clearLeds(){
+  //clears the whole strip
+  for (int i = 0; i <= 80; i++){
+    leds[i] = CRGB::Black;
+    delayMicroseconds(50);
+  }
+  FastLED.show();
+}
+
+void setRed(){
+  //sets the strip to be all red
+  FastLED.setBrightness(100);
+  for (int i = 0; i <= 80; i++){
+    leds[i] = CRGB:: Red;
+    delayMicroseconds(100);
+  }
+  FastLED.show();
+}
+
+void shootAndCollect(){
+  //showing when robot is shooting or collecting
+
+  for (int i; i<3; i++){ //sets the top few leds to the distance color
+  leds[20+i] = distanceColor;
+  leds[59-i] = distanceColor;
+  }
+
+  for (int i = 0; i<5; i++){
+    //creates the first and third segments
+    leds[shooterFrontRight-i] = distanceColor;
+    leds[shooterFrontRight-i-8] = distanceColor;
+    leds[shooterFrontLeft+i] = distanceColor;
+    leds[shooterFrontLeft+i+8] = distanceColor;
+    leds[shooterBackRight+i] = distanceColor;
+    leds[shooterBackRight+i+8] = distanceColor;
+    leds[shooterBackLeft-i] = distanceColor;
+    leds[shooterBackLeft-i-8] = distanceColor;
+
+    //creates the second and fourth segments (opposite the first and second)
+    leds[shooterFrontRight-i-4] = CRGB::Black;
+    leds[shooterFrontRight-i-12] = CRGB::Black;
+    leds[shooterFrontLeft+i+4] = CRGB::Black;
+    leds[shooterFrontLeft+i+12] = CRGB::Black;
+    leds[shooterBackRight+i+4] = CRGB::Black;
+    leds[shooterBackRight+i+12] = CRGB::Black;
+    leds[shooterBackLeft-i-4] = CRGB::Black;
+    leds[shooterBackLeft-i-12] = CRGB::Black;
+
+    //show the changes
+    FastLED.show();
+    if(i != 4) delay(75);
+  }
+
+  for (int i = 0; i<5; i++){
+    //creates the first and third segments
+    leds[shooterFrontRight-i] = CRGB::Black;
+    leds[shooterFrontRight-i-8] = CRGB::Black;
+    leds[shooterFrontLeft+i] = CRGB::Black;
+    leds[shooterFrontLeft+i+8] = CRGB::Black;
+    leds[shooterBackRight+i] = CRGB::Black;
+    leds[shooterBackRight+i+8] = CRGB::Black;
+    leds[shooterBackLeft-i] = CRGB::Black;
+    leds[shooterBackLeft-i-8] = CRGB::Black;
+
+    //creates the second and fourth segments (opposite the first and second)
+    leds[shooterFrontRight-i-4] = distanceColor;
+    leds[shooterFrontRight-i-12] = distanceColor;
+    leds[shooterFrontLeft+i+4] = distanceColor;
+    leds[shooterFrontLeft+i+12] = distanceColor;
+    leds[shooterBackRight+i+4] = distanceColor;
+    leds[shooterBackRight+i+12] = distanceColor;
+    leds[shooterBackLeft-i-4] = distanceColor;
+    leds[shooterBackLeft-i-12] = distanceColor;
+
+    //show the changes
+    FastLED.show();
+    if (i != 4) delay(75);
+  }
+
+}
+
+void set____(){
+  //shows when a ball is in the shooter
+}
+
+void disabled(){
+  //shows when robot is diabled
+}
+
+void signal(){
+  //shows when player clicks button on joystick
+}
+
+void setGreen(){
+  //sets the strip to be all red
+  FastLED.setBrightness(100);
+  for (int i = 0; i <= 80; i++){
+    leds[i] = CRGB::Green;
+    delayMicroseconds(100);
+  }
+  FastLED.show();
+}
+
+
+


Almost done with serial recieve for percent

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/WestwoodRobotics/BEST-2015.git/'


Wifi for ESP8266

Wifi for ESP8266

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

--- Arduino/sketch_feb29a/sketch_feb29a.ino
+++ Arduino/sketch_feb29a/sketch_feb29a.ino
@@ -0,0 +1,93 @@
+#include <NeoPixelBus.h>
+#include <ESP8266WiFi.h>
+
+#define pixelCount 64
+
+const char WiFiAPPSK[] = "aMakerESP8266";
+
+WiFiServer server(80);
+
+bool debug = true;
+// NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(pixelCount, 4);
+
+void setupWiFi()
+{
+  WiFi.mode(WIFI_AP);
+
+  // Do a little work to get a unique-ish name. Append the
+  // last two bytes of the MAC (HEX'd) to "Thing-":
+  uint8_t mac[WL_MAC_ADDR_LENGTH];
+  WiFi.softAPmacAddress(mac);
+  String macID = String(mac[WL_MAC_ADDR_LENGTH - 2], HEX) +
+                 String(mac[WL_MAC_ADDR_LENGTH - 1], HEX);
+  macID.toUpperCase();
+  String AP_NameString = "ESP8266 Thing " + macID;
+
+  char AP_NameChar[AP_NameString.length() + 1];
+  memset(AP_NameChar, 0, AP_NameString.length() + 1);
+
+  for (int i=0; i<AP_NameString.length(); i++)
+    AP_NameChar[i] = AP_NameString.charAt(i);
+
+  WiFi.softAP(AP_NameChar, WiFiAPPSK);
+}
+
+void printDebug(String toDisplay) {
+  if (debug) {
+      Serial.println(toDisplay);
+  }
+}
+
+void setup()
+{
+  setupWiFi();
+  server.begin();
+  // strip.begin();
+  Serial.begin(9600);
+}
+
+void loop()
+{
+  // Check if a client has connected
+  WiFiClient client = server.available();
+  if (!client) {
+    return;
+  }
+
+  // Read the first line of the request
+  String req = client.readStringUntil('\r');
+  client.flush();
+  printDebug("Request : " + req);
+
+
+  if (req.indexOf("do") != -1) {
+    printDebug("Confirm request received");
+    size_t equals = req.indexOf("?");
+    if (equals != -1) {
+      String colors=req.substring(equals+1);
+      printDebug("colors : " + colors);
+      int currentComma = 0;
+      int nextComma = colors.indexOf(',',currentComma);
+      while (nextComma != -1) {
+        printDebug("Color : " + colors.substring(currentComma, nextComma));
+        currentComma = nextComma + 1;
+        nextComma = colors.indexOf(',',currentComma);
+      }
+    }
+  }
+  client.flush();
+
+  // Prepare the response. Start with the common header:
+  String s = "HTTP/1.1 200 OK\r\n";
+  s += "Content-Type: text/html\r\n\r\n";
+  s += "<!DOCTYPE HTML>\r\n<html>\r\n";
+  s += "</html>\n";
+
+  // Send the response to the client
+  client.print(s);
+  delay(1);
+  Serial.println("Client disonnected");
+
+  // The client will actually be disconnected
+  // when the function returns and 'client' object is detroyed
+}


uploaded ensemble nine firmeware

uploaded ensemble nine firmeware

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

--- Firmeware/EnsembleNine/EnsembleNine.ino
+++ Firmeware/EnsembleNine/EnsembleNine.ino
@@ -0,0 +1,72 @@
+/* PHOBOS - EnsembleNine firmware v.0.2 (27.05.2017)
+ *
+ * using:
+ * Arduino v1.8.0
+ * MIDI_Library v.4.3.1 by fortyseveneffects
+ *
+ * plays:
+ * A - 4 solenoid valves
+ * B - 3 solenoid valves
+ */
+
+#include <MIDI.h>
+#define MIDICH 9
+
+// SOLENOID VALVES_1 PINS
+#define A1 5
+#define A2 6
+#define A3 7
+#define A4 8
+// SOLENOID VALVES_2 PINS
+#define B1 2
+#define B2 3
+#define B3 4
+
+// make note to pin array
+byte note2pin[13];
+byte vel, pitch;
+
+MIDI_CREATE_DEFAULT_INSTANCE();
+
+void setup() {
+  MIDI.begin(MIDICH);
+  MIDI.turnThruOn();
+
+  // set output pins
+  pinMode(A1, OUTPUT);
+  pinMode(A2, OUTPUT);
+  pinMode(A3, OUTPUT);
+  pinMode(A4, OUTPUT);
+
+  pinMode(B1, OUTPUT);
+  pinMode(B2, OUTPUT);
+  pinMode(B3, OUTPUT);
+
+  // set note2pin array
+  note2pin[0] = A1;
+  note2pin[1] = A2;
+  note2pin[2] = A3;
+  note2pin[3] = A4;
+
+  note2pin[12] = B1;
+  note2pin[13] = B2;
+  note2pin[14] = B3;
+
+}
+
+void loop() {
+  if(MIDI.read()){
+      switch(MIDI.getType()){
+        case midi::NoteOn:
+          pitch = MIDI.getData1();
+          vel = MIDI.getData2();
+          analogWrite(note2pin[pitch], vel << 1);
+        break;
+
+        case midi::NoteOff:
+          pitch = MIDI.getData1();
+          analogWrite(note2pin[pitch], LOW);
+        break;
+      }
+  }
+}


Added 3D plotting example

Added 3D plotting example

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

--- Projection/examples/GaussianPlot/GaussianPlot.ino
+++ Projection/examples/GaussianPlot/GaussianPlot.ino
@@ -0,0 +1,90 @@
+///////////////////////////////////////////////
+// GaussianPlot
+// by Andrew Meyer, May 2015
+//
+// Demonstrates drawing a 2D Gaussian function
+// on a MicroView ( http://sfe.io/p12923 ).
+///////////////////////////////////////////////
+
+#include <MicroView.h>
+#include <Projection.h>
+
+#define UPDATE_DELAY  0
+
+// Transform for plot (note Z scale)
+Transform plotTrans = Transform(0, 0, 45, 1, 1, 3, 0, 0, 0);
+
+// Create a camera
+Camera cam(LCDWIDTH, LCDHEIGHT);
+
+void setup()
+{
+    // Start MicroView
+    uView.begin();
+
+    // Set camera back and up a few units and angle downward.
+    //
+    // Note that camera's projection axis is its own Z+ axis,
+    // so an x-angle of -90 deg aligns it with the world Y+
+    // axis, and less than -90 will angle the camera's
+    // projection axis further downward.
+    cam.transform = Transform(-90 - 10, 0, 0, 1, 1, 1, 0, -7, 2);
+
+    // Uncomment these two lines for orthographic projection
+    //cam.projMode = PROJ_ORTHO;
+    //cam.orthoViewWidth = 3.0;
+}
+
+void loop()
+{
+    uView.clear(PAGE);
+
+    // Draw Gaussian plot
+    drawGaussPlot();
+
+    uView.display();
+    delay(UPDATE_DELAY);
+}
+
+void drawGaussPlot()
+{
+    float ux = 0, uy = 0;      // Means
+    float sx = 0.5, sy = 0.5;  // Standard deviations
+
+    // Plotting options
+    float minX = -3, maxX = 3;
+    float minY = -3, maxY = 3;
+    float xStep = 0.25, yStep = 0.25;
+
+    byte numPtsX = (maxX - minX) / xStep;
+    byte numPtsY = (maxY - minY) / yStep;
+
+    for (byte n = 0; n < numPtsX; n++)
+    {
+        for (byte m = 0; m < numPtsY; m++)
+        {
+            // Compute Gaussian point
+            float x = (n * xStep) + minX;
+            float y = (m * yStep) + minY;
+            float z = gauss(x, y, ux, uy, sx, sy);
+            point3 pt3 = { x, y, z };
+
+            // Transform and project 3D point
+            point2 pt2 = cam.project(plotTrans * pt3);
+
+            // Draw point if not clipped
+            if (!isnan(pt2.x))
+            {
+                uView.pixel(pt2.x, pt2.y);
+            }
+        }
+    }
+}
+
+float gauss(float x, float y, float ux, float uy, float sx, float sy)
+{
+    return exp(-(
+        ((x - ux) * (x - ux) / (2 * sx * sx)) +
+        ((y - uy) * (y - uy) / (2 * sy * sy))))
+        / (2 * PI * sx * sy);
+}


delete useless comment; speed up fast run

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


Initial commit. It doesn't crash, so it's already better than testInterrupts.ino.

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


1st version of RTC time set utility

1st version of RTC time set utility

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

--- sketches/utils/rtc_set1/rtc_set1.ino
+++ sketches/utils/rtc_set1/rtc_set1.ino
@@ -0,0 +1,119 @@
+/**
+ * Script to set the date on an RTC on the I2C bus at device 0x68.
+ * This is cobbled together from  jcw's "rtc_demo" sketch for setting
+ * the date and time and from his "parser_demo" sketch for reading
+ * the time from the serial interface.
+ *
+ * The interface is still somewhat clunky because the time
+ * setting requires dots after each number. For example,
+ * setting the clock to "2015-08-14 15:04:10" means entering
+ * "2015. 08. 14. 15. 04. 10. c". However the RTC is updated
+ * immediately after the command is entered so you can set the RTC
+ * accurately.
+ *
+ * Original "rtc_demo" sketch:
+ * 2009-09-17 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
+ * Original "parser_demo" sketch:
+ * 2010-10-23 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
+ * Modifications
+ * 2015-08-13 <bill@jamimi.com> http://opensource.org/licenses/mit-license.php
+ */
+
+#include <JeeLib.h>
+
+PortI2C myport (1 /*, PortI2C::KHZ400 */);
+DeviceI2C rtc (myport, 0x68);
+
+extern InputParser::Commands cmdTab[] PROGMEM;
+InputParser parser (50, cmdTab);
+int clock_set = 0;
+
+static byte bin2bcd (byte val) {
+    return val + 6 * (val / 10);
+}
+
+static byte bcd2bin (byte val) {
+    return val - 6 * (val >> 4);
+}
+
+static void setDate (byte yy, byte mm, byte dd, byte h, byte m, byte s) {
+    rtc.send();
+    rtc.write(0);
+    rtc.write(bin2bcd(s));
+    rtc.write(bin2bcd(m));
+    rtc.write(bin2bcd(h));
+    rtc.write(bin2bcd(0));
+    rtc.write(bin2bcd(dd));
+    rtc.write(bin2bcd(mm));
+    rtc.write(bin2bcd(yy));
+    rtc.write(0);
+    rtc.stop();
+}
+
+static void getDate (byte* buf) {
+	rtc.send();
+	rtc.write(0);
+    rtc.stop();
+
+	rtc.receive();
+    buf[5] = bcd2bin(rtc.read(0));
+    buf[4] = bcd2bin(rtc.read(0));
+    buf[3] = bcd2bin(rtc.read(0));
+    rtc.read(0);
+    buf[2] = bcd2bin(rtc.read(0));
+    buf[1] = bcd2bin(rtc.read(0));
+    buf[0] = bcd2bin(rtc.read(1));
+    rtc.stop();
+}
+
+static void setClockCmd () {
+    int y, m, d, h, i, s;
+    parser >> y >> m >> d >> h >> i >> s;
+    Serial.print("Setting clock to ");
+    Serial.print(y);
+    Serial.print("-");
+    Serial.print(m);
+    Serial.print("-");
+    Serial.print(d);
+    Serial.print(" ");
+    Serial.print(h);
+    Serial.print(":");
+    Serial.print(i);
+    Serial.print(":");
+    Serial.print(s);
+    Serial.println();
+    setDate(y, m, d, h, i, s);
+    clock_set = 1;
+}
+
+InputParser::Commands cmdTab[] = {
+    { 'c', 6, setClockCmd },
+    { 0 }
+};
+
+void setup() {
+    Serial.begin(57600);
+    Serial.println("\n[Set the RTC data/time]");
+    // Be sure to follow each field with a dot!
+    Serial.println("\n[Input y m d h i s c ]");
+}
+
+void loop() {
+    // Read date/time from serial line
+    while (clock_set != 1) {
+      parser.poll();
+    }
+
+    // test code:
+    byte now[6];
+    getDate(now);
+
+    Serial.print("rtc");
+    for (byte i = 0; i < 6; ++i) {
+        Serial.print(' ');
+        Serial.print((int) now[i]);
+    }
+    Serial.println();
+
+    delay(1000);
+ }


Update MC3672_demo.ino

Update MC3672_demo.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/mcubemems/Accelerometer_MC3672.git/'


sketch that demonstrates basic automated movement, utilizing the magnetometer

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

--- examples/basic_automated_movement/basic_automated_movement.ino
+++ examples/basic_automated_movement/basic_automated_movement.ino
@@ -0,0 +1,21 @@
+#include <AFMotor.h>
+#include <Smartcar.h>
+#include <Wire.h>
+#include <HMC5883L.h>
+
+Smartcar elsa;
+
+void setup() {
+    elsa.begin();
+    elsa.goForward(60);
+    elsa.rotateClockwise(90);
+    elsa.goForward(60);
+    elsa.rotateCounterClockwise(90);
+    elsa.goBackward(60);
+    elsa.rotateCounterClockwise(90);
+    elsa.goForward(60);
+    elsa.rotateCounterClockwise(270);
+}
+
+void loop() {
+}


farm +quick start dht11

farm +quick start dht11

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

--- examples/Quick_start_anto_dht11/Quick_start_anto_dht11.ino
+++ examples/Quick_start_anto_dht11/Quick_start_anto_dht11.ino
@@ -0,0 +1,136 @@
+#include <AntoIO.h>
+#include <DHT.h>
+
+// username of anto.io account
+const char *user = "thefarmer";
+
+// key of permission, generated on control panel anto.io
+const char* key = "key";
+
+// your default thing.
+const char* thing = "Node_DHT";
+
+// create AntoIO object named anto.
+// using constructor AntoIO(user, key, thing)
+// or use AntoIO(user, key, thing, clientId)
+// to generate client_id yourself.
+AntoIO anto(user, key, thing);
+
+bool bIsConnected = false;
+
+String Antosend;
+char buf[5];
+
+#define DHTPIN 2    //port D4
+#define DHTTYPE DHT11
+DHT dht(DHTPIN,DHTTYPE);
+
+void setup() {
+    Serial.begin(115200);
+    delay(10);
+
+    Serial.println();
+    Serial.println();
+    Serial.print("Anto library version: ");
+    Serial.println(anto.getVersion());
+
+
+    // Connect to your WiFi access point
+    anto.smartConfig();
+
+    Serial.println();
+    Serial.println("WiFi connected");
+    Serial.println("Connecting to MQTT broker");
+
+    // register callback functions
+    anto.mqtt.onConnected(connectedCB);
+    anto.mqtt.onDisconnected(disconnectedCB);
+    anto.mqtt.onData(dataCB);
+    anto.mqtt.onPublished(publishedCB);
+
+    // Connect to Anto.io MQTT broker
+    anto.mqtt.connect();
+
+    //dht start
+    dht.begin();
+}
+
+
+void loop() {
+  // put your main code here, to run repeatedly:
+   float temp = dht.readTemperature();
+   float humid = dht.readHumidity();
+
+   Serial.print("TEMP: ");
+   Serial.println(temp);
+
+   Serial.print("HUMID: ");
+   Serial.println(humid);
+
+
+   if(temp >= 0){
+      Antosend = String(temp);                     //แปลง temp เป็น string
+      Antosend.toCharArray(buf,Antosend.length()); //string ยัดใส่ buf
+      anto.pub("Temp",(const char*)buf);           //ใช้ buf ส่งค่าขึ้นไป
+   }
+
+   if(humid >= 0){
+      Antosend = String(humid);
+      Antosend.toCharArray(buf,Antosend.length());
+      anto.pub("Humid",(const char*)buf);
+   }
+
+  delay(1000);
+}
+
+/*
+* connectedCB(): a callback function called when the connection to the MQTT broker is establised.
+*/
+void connectedCB()
+{
+    // If the connection is establised, subscribe channels.
+
+    bIsConnected = true;
+    Serial.println("Connected to MQTT Broker");
+
+}
+
+/*
+* disconnectedCB(): a callback function called when the connection to the MQTT broker is broken.
+*/
+void disconnectedCB()
+{
+    bIsConnected = false;
+    Serial.println("Disconnected to MQTT Broker");
+}
+
+/*
+* msgArrvCB(): a callback function called when there a message from the subscribed channel.
+*/
+void dataCB(String& topic, String& msg)
+{
+    uint8_t index = topic.indexOf('/');
+
+    index = topic.indexOf('/', index + 1);
+    index = topic.indexOf('/', index + 1);
+
+    topic.remove(0, index + 1);
+
+    Serial.print(topic);
+    Serial.print(": ");
+    Serial.println(msg);
+
+}
+
+/*
+* publishedCB(): a callback function called when the message is published.
+*/
+void publishedCB(void)
+{
+    Serial.println("published");
+}
+
+
+
+
+


File that combines both sensor readings into one

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

--- Arduino/Combination_Readings/Combination_Readings.ino
+++ Arduino/Combination_Readings/Combination_Readings.ino
@@ -0,0 +1,139 @@
+#include <Wire.h>
+
+#include <Adafruit_10DOF.h>
+
+#include <Adafruit_Sensor.h>
+
+#include <Adafruit_L3GD20_U.h>
+
+#include <Adafruit_LSM303_U.h>
+
+#include <Adafruit_BMP085_U.h>
+
+Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);
+Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(10303);
+Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(11303);
+
+const int firstPin = A0;
+const int secondPin = A1;
+const double smallR = 1.8;
+const int bigR = 18;
+
+void displaySensorDetails(void)
+{
+  sensor_t sensor;
+  accel.getSensor(&sensor);
+  Serial.println("------------------------------------");
+  Serial.print  ("Sensor:       "); Serial.println(sensor.name);
+  Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
+  Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
+  Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" m/s^2");
+  Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" m/s^2");
+  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" m/s^2");
+  Serial.println("------------------------------------");
+  Serial.println("");
+  delay(500);
+}
+
+void setup(void) {
+  Serial.begin(9600);
+  Serial.println("Sensor Test");
+  Serial.println("");
+
+  displaySensorDetails();
+
+  if (!bmp.begin() || !mag.begin() || !accel.begin())
+  {
+    Serial.print("Ooops, no BMP085 or LSM303 detected");
+    while(1);
+  }
+}
+void loop() {
+
+  sensors_event_t eventP;
+  sensors_event_t eventM;
+  sensors_event_t eventA;
+  float temperature;
+
+  int firstVal = analogRead(firstPin);
+  int secondVal = analogRead(secondPin);
+  float firstVolt = (firstVal/1024.0)*5;
+  float secondVolt = (secondVal/1024.0)*5;
+  double current = (firstVolt - secondVolt)/smallR;
+  double power = current*current*(bigR+smallR+20);
+
+  bmp.getEvent(&eventP);
+  mag.getEvent(&eventM);
+  bmp.getTemperature(&temperature);
+  accel.getEvent(&eventA);
+
+  float heading=(atan2(eventM.magnetic.y, eventM.magnetic.x)*180)/PI;
+  while (heading < 0)
+  {
+    heading = 360 + heading;
+  }
+
+  Serial.print("Solar Panel Current: ");
+  Serial.print(current*1000,6);
+  Serial.println("mA");
+
+  Serial.print("Solar Panel Power: ");
+  Serial.print(power,6);
+  Serial.println("W");
+
+    if (eventP.pressure)
+  {
+    Serial.print("Pressure: ");
+    Serial.print(eventP.pressure);
+    Serial.println(" hPa.");
+  }
+  else
+  {
+    Serial.println("Error: Pressure sensor");
+  }
+  if (temperature)
+  {
+    Serial.print("Temperature: ");
+    Serial.print(temperature);
+    Serial.println(" C.");
+  }
+  else
+  {
+    Serial.println("Error: Temperature sensor");
+  }
+   if (heading)
+  {
+    Serial.print("Compass Heading: ");
+    Serial.print(eventM.magnetic.y);
+    Serial.print(", ");
+    Serial.print(eventM.magnetic.x);
+    Serial.print(", ");
+    Serial.print(heading);
+    Serial.print("\n");
+  }
+  else
+  {
+    Serial.println("Error: Compass sensor");
+  }
+
+  if (1)
+  {
+    Serial.print("X Acceleration: ");
+    Serial.print(eventA.acceleration.x);
+    Serial.println(" m/s^2, ");
+    Serial.print("Y Acceleration: ");
+    Serial.print(eventA.acceleration.y);
+    Serial.println(" m/s^2, ");
+    Serial.print("Z Acceleration: ");
+    Serial.print(eventA.acceleration.z);
+    Serial.println(" m/s^2.");
+    Serial.print("\n");
+  }
+  else
+  {
+    Serial.println("Error: Accelerometer sensor");
+  }
+
+   delay(1000);
+
+}


Create ArduinoFileUpload.ino

Create ArduinoFileUpload.ino

Please note that this code was created specifically for the GLK19264A-7T-1U, but can be used with any graphic display, with firmware version 8.1 or higher.  Also note that the glk_arduino.h file must be present in the same folder as this file to run the example.

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

--- Examples/ArduinoFileUpload/ArduinoFileUpload.ino
+++ Examples/ArduinoFileUpload/ArduinoFileUpload.ino
@@ -0,0 +1,129 @@
+//Arduino Uno with Matrix Orbital GLK19264A-7T-1U PCB Reev2.0 (I2C Mode) and BBC (Breadboard Cable)
+//Created by Clark, 22/09/2014
+//support@matrixorbital.ca
+//www.matrixorbital.ca/appnotes
+
+#include <Wire.h>
+#include <stdlib.h>
+#include "glk_arduino.h"
+
+#define I2C_Address 0x28  //Define default 8bit I2C address of 0x50 >> 1 for 7bit Arduino
+
+unsigned int bitmap_id = 2;  //Bitmap file index
+byte bitmap_data[] = { 5, 4, 80, 34, 224 };  //Width, height, plus three bytes smiley face data
+unsigned long bitmap_size = 5;  //Size of bitmap file
+char* error_message;
+
+void setup(){
+  Wire.begin();  //Setup I2C bus and serial reporting
+  delay(1000);
+  Serial.begin(19200);
+  setReportingMode(0);  //Transmit via i2c port rather than serial
+  char* message = "Uploading Image...";
+  clearScreen();
+  writeMessage(message, strlen(message));
+  boolean success = UploadEightPointOneBitmap(bitmap_id, bitmap_size);
+  if(success == true){
+    error_message = "<- Displaying Image Here";
+    Serial.print("Upload Successful!");
+  }
+  else{
+    error_message = "Error Uploading Image!";
+    Serial.print("Upload Error!");
+  }
+  delay(2000);
+}
+
+void loop(){  //Main loop
+  clearScreen();
+  DrawEightPointOneBitmap(bitmap_id, 1, 1);
+  setCursorCoordinates(10, 0);
+  writeMessage(error_message, strlen(error_message));
+  delay(2000);
+}
+
+boolean UploadEightPointOneBitmap(unsigned int id, unsigned long file_size){  //Upload protocol for firmware revision 8.1 and higher only
+  byte command[] = { GLK_CMD_BYTE, GLK_BITMAP_UPLOAD_FILE, (byte)(id), (byte)(id >> 8), (byte)(file_size), (byte)(file_size >> 8), (byte)(file_size >> 16), (byte)(file_size >> 24) };
+  i2cWriteBytes(command, sizeof(command));  //Bitmap upload command
+  byte size_response = i2cReadByte();
+  if (size_response != 1){  //Check that file will fit
+    Serial.print(size_response);
+    Serial.print("Size Error!");
+    return false;
+  }
+  //Begin upload protocol (non-Xmodem)
+  unsigned long i;
+  for (i = 0; i < file_size; i++){
+    Serial.print("Byte: ");
+    Serial.print(i);
+    byte data[] = { bitmap_data[i] };
+    Serial.print("Writing: ");
+    Serial.print(data[0]);
+    i2cWriteBytes(data, 1);  //Write one data byte
+    byte data_response = i2cReadByte();
+    Serial.print("Response: ");
+    Serial.print(data_response);
+    if (data_response == data[0]){  //Check echo from display
+      byte ack[] = { 1 };
+      i2cWriteBytes(ack, 1);   //Confirm echo matches transmitted data
+    }
+    else{
+      byte nack[] = { 8 };
+      i2cWriteBytes(nack, 1);   //Abort upload for display and host if echo does not match
+      Serial.print("Data Error!");
+      return false;
+    }
+  }
+  return true;
+}
+
+void DrawEightPointOneBitmap(unsigned int id, byte x, byte y){  //Drawing protocol for firmware revision 8.1 and higher only
+  byte command[] = { GLK_CMD_BYTE, GLK_BITMAP_DRAW_FROM_MEM, (byte)(id), (byte)(id >> 8), x, y };  //Little Endian protocol
+  i2cWriteBytes(command, sizeof(command));  //Draw command
+}
+
+void clearScreen(){
+  byte command[] = { GLK_CMD_BYTE, GLK_TXT_CLS };
+  i2cWriteBytes(command, sizeof(command));
+}
+
+void setReportingMode(byte mode){
+  byte command[] = { GLK_CMD_BYTE, GLK_COM_PROTO, mode };
+  i2cWriteBytes(command, sizeof(command));
+}
+
+void setCursorCoordinates(byte x, byte y){
+  byte command[] = {GLK_CMD_BYTE, GLK_TXT_CURS_COORD, x, y};
+  i2cWriteBytes(command, sizeof(command));
+}
+
+void writeMessage(char* data, byte length){
+  i2cWriteString(data, length);
+}
+
+void i2cWriteBytes(byte* data, byte length){  //Simple transmission of bytes, used for commands
+  Wire.beginTransmission(GLK_I2C_ADDR);
+  for(int i = 0; i < length; i++){
+    Wire.write(data[i]);
+    delay(10);  //Delay between bytes to ensure proper communication, 10ms works well with the Uno
+  }
+  Wire.endTransmission();
+  delay(50);  //Delay after transaction, avoids accidentally reading data transmitted from the host
+}
+
+void i2cWriteString(char* data, byte length){  //Simple transmission of text strings
+  Wire.beginTransmission(GLK_I2C_ADDR);
+  for(int i = 0; i < length; i++){
+    Wire.write(data[i]);
+    delay(10);
+  }
+  Wire.endTransmission();
+  delay(50);
+}
+
+byte i2cReadByte(){  //Wait for one byte to be available over i2c and read it
+  while(Wire.available()<1){
+  Wire.requestFrom(I2C_Address, 1);
+  }
+  return(Wire.read());
+}


Added example with switch to invoke WiFi manager and custom parameters saved to the flash memory

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

--- examples/ConfigOnSwitchFS/ConfigOnSwitchFS.ino
+++ examples/ConfigOnSwitchFS/ConfigOnSwitchFS.ino
@@ -0,0 +1,255 @@
+#include <FS.h>
+#include <ESP8266WiFi.h>          //https://github.com/esp8266/Arduino
+#include <ArduinoJson.h>          //https://github.com/bblanchon/ArduinoJson
+
+//needed for library
+#include <ESP8266WebServer.h>
+#include <DNSServer.h>
+#include <WiFiManager.h>          //https://github.com/kentaylor/WiFiManager
+
+// Constants
+
+// select wich pin will trigger the configuraton portal when set to LOW
+// ESP-01 users please note: the only pins available (0 and 2), are shared
+// with the bootloader, so always set them HIGH at power-up
+// Onboard LED I/O pin on NodeMCU board
+const int PIN_LED = D4; // 2-D4 on NodeMCU and WeMos. Controls the onboard LED.
+/* Trigger for inititating config mode is Pin D3 and also flash button on NodeMCU
+ * Flash button is convenient to use but if it is pressed it will stuff up the serial port device driver
+ * until the computer is rebooted on windows machines.
+ */
+const int TRIGGER_PIN = D3; // 0-D3 on NodeMCU and WeMos.
+/*
+ * Alternative trigger pin. Needs to be connected to a button to use this pin. It must be a momentary connection
+ * not connected permanently to ground. Either trigger pin will work.
+ */
+const int TRIGGER_PIN2 = D7; // 13-D7 on NodeMCU and WeMos.
+
+const char* CONFIG_FILE = "/config.json";
+
+// Variables
+
+// Indicates whether ESP has WiFi credentials saved from previous session
+bool initialConfig = false;
+
+// Default configuration values
+char thingspeakApiKey[17] = "";
+bool sensorDht22 = true;
+unsigned int pinSda = 2;
+unsigned int pinScl = 14;
+
+// Function Prototypes
+
+bool readConfigFile();
+bool writeConfigFile();
+
+// Setup function
+void setup() {
+  // Put your setup code here, to run once
+  Serial.begin(115200);
+  Serial.println("\n Starting");
+
+  // Initialize the LED digital pin as an output.
+  pinMode(PIN_LED, OUTPUT);
+  // Initialize trigger pins
+  pinMode(TRIGGER_PIN, INPUT_PULLUP);
+  pinMode(TRIGGER_PIN2, INPUT_PULLUP);
+
+  // Mount the filesystem
+  bool result = SPIFFS.begin();
+  Serial.println("SPIFFS opened: " + result);
+
+  if (!readConfigFile()) {
+    Serial.println("Failed to read configuration file, using default values");
+  }
+
+  WiFi.printDiag(Serial); //Remove this line if you do not want to see WiFi password printed
+
+  if (WiFi.SSID() == "") {
+    Serial.println("We haven't got any access point credentials, so get them now");
+    initialConfig = true;
+  } else {
+    digitalWrite(PIN_LED, HIGH); // Turn LED off as we are not in configuration mode.
+    WiFi.mode(WIFI_STA); // Force to station mode because if device was switched off while in access point mode it will start up next time in access point mode.
+    unsigned long startedAt = millis();
+    Serial.print("After waiting ");
+    int connRes = WiFi.waitForConnectResult();
+    float waited = (millis()- startedAt);
+    Serial.print(waited/1000);
+    Serial.print(" secs in setup() connection result is ");
+    Serial.println(connRes);
+  }
+
+  if (WiFi.status()!=WL_CONNECTED){
+    Serial.println("Failed to connect, finishing setup anyway");
+  } else{
+    Serial.print("Local ip: ");
+    Serial.println(WiFi.localIP());
+  }
+}
+
+// Loop function
+
+void loop() {
+  // is configuration portal requested?
+  if ((digitalRead(TRIGGER_PIN) == LOW) || (digitalRead(TRIGGER_PIN2) == LOW) || (initialConfig)) {
+     Serial.println("Configuration portal requested");
+     digitalWrite(PIN_LED, LOW); // turn the LED on by making the voltage LOW to tell us we are in configuration mode.
+    //Local intialization. Once its business is done, there is no need to keep it around
+
+    // Extra parameters to be configured
+    // After connecting, parameter.getValue() will get you the configured value
+    // Format: <ID> <Placeholder text> <default value> <length> <custom HTML> <label placement>
+
+    // Thingspeak API Key - this is a straight forward string parameter
+    WiFiManagerParameter p_thingspeakApiKey("thingspeakapikey", "Thingspeak API Key", thingspeakApiKey, 17);
+
+    // DHT-22 sensor present or not - bool parameter visualized using checkbox, so couple of things to note
+    // - value is always 'T' for true. When the HTML form is submitted this is the value that will be
+    //   sent as a parameter. When unchecked, nothing will be sent by the HTML standard.
+    // - customhtml must be 'type="checkbox"' for obvious reasons. When the default is checked
+    //   append 'checked' too
+    // - labelplacement parameter is WFM_LABEL_AFTER for checkboxes as label has to be placed after the input field
+
+    char customhtml[24] = "type=\"checkbox\"";
+    if (sensorDht22) {
+      strcat(customhtml, " checked");
+    }
+    WiFiManagerParameter p_sensorDht22("sensordht22", "DHT-22 Sensor", "T", 2, customhtml, WFM_LABEL_AFTER);
+
+    // I2C SCL and SDA parameters are integers so we need to convert them to char array but
+    // no other special considerations
+    char convertedValue[3];
+    sprintf(convertedValue, "%d", pinSda);
+    WiFiManagerParameter p_pinSda("pinsda", "I2C SDA pin", convertedValue, 3);
+    sprintf(convertedValue, "%d", pinScl);
+    WiFiManagerParameter p_pinScl("pinscl", "I2C SCL pin", convertedValue, 3);
+
+    // Just a quick hint
+    WiFiManagerParameter p_hint("<small>*Hint: if you want to reuse the already saved WiFi credentials, leave SSID and Password fields empty</small>");
+
+    // Initialize WiFIManager
+    WiFiManager wifiManager;
+
+    //add all parameters here
+
+    wifiManager.addParameter(&p_hint);
+    wifiManager.addParameter(&p_thingspeakApiKey);
+    wifiManager.addParameter(&p_sensorDht22);
+    wifiManager.addParameter(&p_pinSda);
+    wifiManager.addParameter(&p_pinScl);
+
+    // Sets timeout in seconds until configuration portal gets turned off.
+    // If not specified device will remain in configuration mode until
+    // switched off via webserver or device is restarted.
+    // wifiManager.setConfigPortalTimeout(600);
+
+    // It starts an access point
+    // and goes into a blocking loop awaiting configuration.
+    // Once the user leaves the portal with the exit button
+    // processing will continue
+    if (!wifiManager.startConfigPortal()) {
+      Serial.println("Not connected to WiFi but continuing anyway.");
+    } else {
+      // If you get here you have connected to the WiFi
+      Serial.println("Connected...yeey :)");
+
+      // Getting parameters from the web form and overriding local variables' values accordingly
+      strcpy(thingspeakApiKey, p_thingspeakApiKey.getValue());
+      sensorDht22 = (strncmp(p_sensorDht22.getValue(), "T", 1) == 0);
+      pinSda = atoi(p_pinSda.getValue());
+      pinScl = atoi(p_pinScl.getValue());
+      // Writing JSON config file to flash for next boot
+      writeConfigFile();
+    }
+
+    digitalWrite(PIN_LED, HIGH); // Turn LED off as we are not in configuration mode.
+
+    ESP.reset(); // This is a bit crude. For some unknown reason webserver can only be started once per boot up
+    // so resetting the device allows to go back into config mode again when it reboots.
+    delay(5000);
+  }
+
+  // Configuration portal not requested, so run normal loop
+  // Put your main code here, to run repeatedly...
+
+}
+
+bool readConfigFile() {
+  // this opens the config file in read-mode
+  File f = SPIFFS.open(CONFIG_FILE, "r");
+
+  if (!f) {
+    Serial.println("Configuration file not found");
+    return true;
+  } else {
+    // we could open the file
+    size_t size = f.size();
+    // Allocate a buffer to store contents of the file.
+    std::unique_ptr<char[]> buf(new char[size]);
+
+    // Read and store file contents in buf
+    f.readBytes(buf.get(), size);
+    // Closing file
+    f.close();
+    // Using dynamic JSON buffer which is not the recommended memory model, but anyway
+    // See https://github.com/bblanchon/ArduinoJson/wiki/Memory%20model
+    DynamicJsonBuffer jsonBuffer;
+    // Parse JSON string
+    JsonObject& json = jsonBuffer.parseObject(buf.get());
+    // Test if parsing succeeds.
+    if (!json.success()) {
+      Serial.println("JSON parseObject() failed");
+      return false;
+    }
+    json.printTo(Serial);
+
+    // Parse all config file parameters, override
+    // local config variables with parsed values
+    if (json.containsKey("thingspeakApiKey")) {
+      strcpy(thingspeakApiKey, json["thingspeakApiKey"]);
+    }
+
+    if (json.containsKey("sensorDht22")) {
+      sensorDht22 = json["sensorDht22"];
+    }
+
+    if (json.containsKey("pinSda")) {
+      pinSda = json["pinSda"];
+    }
+
+    if (json.containsKey("pinScl")) {
+      pinScl = json["pinScl"];
+    }
+  }
+  Serial.println("\nConfig file was successfully parsed");
+  return true;
+}
+
+bool writeConfigFile() {
+  Serial.println("Saving config file");
+  DynamicJsonBuffer jsonBuffer;
+  JsonObject& json = jsonBuffer.createObject();
+
+  // JSONify local configuration parameters
+  json["thingspeakApiKey"] = thingspeakApiKey;
+  json["sensorDht22"] = sensorDht22;
+  json["pinSda"] = pinSda;
+  json["pinScl"] = pinScl;
+
+  // Open file for writing
+  File f = SPIFFS.open(CONFIG_FILE, "w");
+  if (!f) {
+    Serial.println("Failed to open config file for writing");
+    return false;
+  }
+
+  json.prettyPrintTo(Serial);
+  // Write data to file and close it
+  json.printTo(f);
+  f.close();
+
+  Serial.println("\nConfig file was successfully saved");
+  return true;
+}
+


added console testing codez

added console testing codez

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

--- arduino/lpd8806_firmata_test/lpd8806_firmata_test.ino
+++ arduino/lpd8806_firmata_test/lpd8806_firmata_test.ino
@@ -0,0 +1,51 @@
+#include <Adafruit_NeoPixel.h>
+#include "ws2812.h"
+
+/**
+
+TODO:
+
+1. Convert this to a basic firmata to be able to control it simply via
+the same way you do with the FT ones.
+
+2. From there make it configurable so the constructor is called off a construction
+method so that it can be determined. Look at using a proper SYSEX message for this
+
+3. From there include into the standard simplebot firmata to be able to use it
+in there quite happily.
+**/
+
+
+void setup() {
+    Serial.begin(9600);
+    ws2812_initialise();
+}
+
+void loop() {
+    if (Serial.available() > 10) {
+        SerialParse();
+    }
+
+    delay(1);
+
+}
+
+void SerialParse(void) {
+    // processes the serial commands
+    int bufCount; // counter for the string buffer.
+    char buffer[BUFLENGTH]; // character buffer for the serial message
+
+    bufCount = -1; // reset it
+    bufCount = Serial.readBytesUntil('\n', buffer, BUFLENGTH);
+
+    if (bufCount > 0) {
+
+        String message = String(buffer);
+        // now we have a message, let's parse it.
+        int msg_index = message.lastIndexOf('{');
+        if (msg_index >= 0) {
+            parse_message(message, msg_index);
+        }
+    }
+}
+


Update RTC example

Update RTC example

--- examples/Widgets/RTC/RTC.ino
+++ examples/Widgets/RTC/RTC.ino
@@ -17,7 +17,7 @@
   Please note that the accuracy of this method is up to several seconds.

   App project setup:
-    RTC widget on V5
+    RTC widget (no pin required)
     Value Display M widget on V1
     Value Display M widget on V2


Add offsetCalibration method

Add offsetCalibration method

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

--- examples/offsetCalibration/offsetCalibration.ino
+++ examples/offsetCalibration/offsetCalibration.ino
@@ -0,0 +1,61 @@
+
+#include<CS5490.h>
+
+#define rx 11
+#define tx 12
+
+/* Choose your board */
+
+/* Arduino UNO and ESP8622 */
+CS5490 line(MCLK_default,rx,tx);
+
+/* ESP and MEGA  (Uses Serial2)*/
+//CS5490 line(MCLK_default);
+
+
+void setup() {
+  //Initializing communication with CS5490
+  //600 is the default baud rate velocity.
+  line.begin(600);
+  //Initializing communication arduino/PC to show results in Monitor Serial
+  Serial.begin(115200);
+  // wait for serial port to connect. Needed for Leonardo only
+  while (!Serial);
+  //Set to single conversion
+  line.singConv();
+}
+
+void loop() {
+
+  /* P.S: if the offset is a positive value, you need to
+      write the same value at calibration register, but negative
+   */
+
+  /* Option 1: Manual calibration
+  1 - Read instant value for 0V input
+  2 - Write the value somewere else
+  3 - Write the DC offset voltage (at void setup)
+  */
+
+  /* Option 2: Automated Manual calibration
+  1 - Read instant value for 0V input
+  2 - Store value at Arduino EEPROM
+  3 - Read EEPROM and store DC offset voltage (at void setup)
+  */
+
+  /* Option 3: Automatic calibration
+  1 - Enable the desired calibration
+  2 - Execute calibration
+  3 - Read the results from calibration Register
+  4 - Store at Arduino EEPROM
+  5 - Read EEPROM and store DC offset voltage (at void setup)
+  */
+
+  /*
+
+  //line.write(page,address,value***)
+  line.write(16,34,0xaabbcc);
+
+  *** => value is the concatenated bytes to send
+
+}