styling and removing old comments

styling and removing old comments

--- reg_ferm.ino
+++ reg_ferm.ino
@@ -1,131 +1,112 @@
-/***************************************************
-  This is an example for the Adafruit Thermocouple Sensor w/MAX31855K
-
-  Designed specifically to work with the Adafruit Thermocouple Sensor
-  ----> https://www.adafruit.com/products/269
-
-  These displays use SPI to communicate, 3 pins are required to
-  interface
-  Adafruit invests time and resources providing this open source code,
-  please support Adafruit and open-source hardware by purchasing
-  products from Adafruit!
-
-  Written by Limor Fried/Ladyada for Adafruit Industries.
-  BSD license, all text above must be included in any redistribution
- ****************************************************/
-
-#include <SPI.h>
-#include "Adafruit_MAX31855.h"
-
-// Default connection is using software SPI, but comment and uncomment one of
-// the two examples below to switch between software SPI and hardware SPI:
-
-// Example creating a thermocouple instance with software SPI on any three
-// digital IO pins.
-#define DO   12
-#define CS1  10
-#define CS2  11
-#define CS3  9
-#define CLK  8
-
-Adafruit_MAX31855 thermocouple1(CLK, CS1, DO);
-Adafruit_MAX31855 thermocouple2(CLK, CS2, DO);
-Adafruit_MAX31855 thermocouple3(CLK, CS3, DO);
-
-// Example creating a thermocouple instance with hardware SPI (Uno/Mega only)
-// on a given CS pin.
-//#define CS   11
-//Adafruit_MAX31855 thermocouple(CS);
-
-const int R1KYL = 7;
-const int R2VARME = 5;
-const double intervall = 0.5;
-
-
-void setup() {
-
-  pinMode(R1KYL, OUTPUT);
-  pinMode(R2VARME, OUTPUT);
-
-  digitalWrite(R1KYL, HIGH);
-  digitalWrite(R2VARME, HIGH);
-
-
-  Serial.begin(9600);
-
-
-
-
-  //Serial.println("MAX31855 test");
-  // wait for MAX chip to stabilize
-  delay(500);
-}
-
-void loop() {
-  // basic readout test, just print the current temp
-   //Serial.print("Internal Temp = ");
-   //Serial.println(thermocouple1.readInternal());
-
-    // sets the LED on
-               // waits for a second
-double setpoint = 4;
-
-
-                // say what you got:
-                Serial.print(setpoint);
-                Serial.print(",");
-
-
-
-   double T_fermentor = thermocouple1.readCelsius();
-
-     Serial.print(T_fermentor);
-     Serial.print(",");
-
-
-   delay(400);
-
-   double T_isolering = thermocouple2.readCelsius();
-
-     Serial.print(T_isolering);
-     Serial.print(",");
-
-   double T_kylvatten = thermocouple3.readCelsius();
-
-     Serial.print(T_kylvatten);
-     Serial.print(",");
-
-  double T_luft = thermocouple1.readInternal();
-
-  Serial.println(T_luft);
-
-  // seriella kommunikationen har ordningen (setpoint, T_fermentor, T_isolering, T_kylvatten, T_luft)
-
-
-   delay(1000);
-
-   double setpoint_max = setpoint + intervall;
-   double setpoint_min = setpoint - intervall;
-
-
-
-
-     if (T_fermentor >= setpoint_max) {
-      digitalWrite(R1KYL, LOW); }
-       else { digitalWrite(R1KYL, HIGH);}
-
-
-    if (T_fermentor <= setpoint_min) {
-        digitalWrite(R2VARME, LOW); }
-        else { digitalWrite(R2VARME, HIGH);}
-
-
-delay(300000);
-}
-
-
-
-
-
-
-
+/***************************************************
+  This is an example for the Adafruit Thermocouple Sensor w/MAX31855K
+
+  Designed specifically to work with the Adafruit Thermocouple Sensor
+  ----> https://www.adafruit.com/products/269
+
+  These displays use SPI to communicate, 3 pins are required to
+  interface
+  Adafruit invests time and resources providing this open source code,
+  please support Adafruit and open-source hardware by purchasing
+  products from Adafruit!
+
+  Written by Limor Fried/Ladyada for Adafruit Industries.
+  BSD license, all text above must be included in any redistribution
+ ****************************************************/
+
+#include <SPI.h>
+#include "Adafruit_MAX31855.h"
+
+// Default connection is using software SPI, but comment and uncomment one of
+// the two examples below to switch between software SPI and hardware SPI:
+
+// Example creating a thermocouple instance with software SPI on any three
+// digital IO pins.
+#define DO   12
+#define CS1  10
+#define CS2  11
+#define CS3  9
+#define CLK  8
+
+Adafruit_MAX31855 thermocouple1(CLK, CS1, DO);
+Adafruit_MAX31855 thermocouple2(CLK, CS2, DO);
+Adafruit_MAX31855 thermocouple3(CLK, CS3, DO);
+
+// Example creating a thermocouple instance with hardware SPI (Uno/Mega only)
+// on a given CS pin.
+//#define CS   11
+//Adafruit_MAX31855 thermocouple(CS);
+
+const int R1KYL = 7;
+const int R2VARME = 5;
+const double intervall = 0.5;
+
+
+void setup() {
+
+  pinMode(R1KYL, OUTPUT);
+  pinMode(R2VARME, OUTPUT);
+
+  digitalWrite(R1KYL, HIGH);
+  digitalWrite(R2VARME, HIGH);
+
+  Serial.begin(9600);
+
+  //Serial.println("MAX31855 test");
+  // wait for MAX chip to stabilize
+  delay(500);
+}
+
+void loop() {
+  // basic readout test, just print the current temp
+  //Serial.print("Internal Temp = ");
+  //Serial.println(thermocouple1.readInternal());
+
+  double setpoint = 4;
+
+  // say what you got:
+  Serial.print(setpoint);
+  Serial.print(",");
+
+  double T_fermentor = thermocouple1.readCelsius();
+
+  Serial.print(T_fermentor);
+  Serial.print(",");
+
+  delay(400);
+
+  double T_isolering = thermocouple2.readCelsius();
+
+  Serial.print(T_isolering);
+  Serial.print(",");
+
+  double T_kylvatten = thermocouple3.readCelsius();
+
+  Serial.print(T_kylvatten);
+  Serial.print(",");
+
+  double T_luft = thermocouple1.readInternal();
+
+  Serial.println(T_luft);
+
+  // seriella kommunikationen har ordningen (setpoint, T_fermentor, T_isolering, T_kylvatten, T_luft)
+
+  delay(1000);
+
+  double setpoint_max = setpoint + intervall;
+  double setpoint_min = setpoint - intervall;
+
+  if (T_fermentor >= setpoint_max) {
+    digitalWrite(R1KYL, LOW);
+  } else {
+    digitalWrite(R1KYL, HIGH);
+  }
+
+  if (T_fermentor <= setpoint_min) {
+    digitalWrite(R2VARME, LOW);
+  } else {
+    digitalWrite(R2VARME, HIGH);
+  }
+
+  delay(300000);
+}


Fixed write string line in sketchlist

Fixed write string line in sketchlist

Signed-off-by: bergerkiller <34c1d059d3a687c0064b6822cf3cda4335a41a9c@gmail.com>

--- examples/SketchList/SketchList.ino
+++ examples/SketchList/SketchList.ino
@@ -825,7 +825,7 @@

       PHNDisplay8Bit::fillRect(popup_x, popup_y, popup_w, popup_h, WHITE_8BIT);
       PHNDisplay8Bit::drawRect(popup_x, popup_y, popup_w, popup_h, RED_8BIT);
-      (popup_x + txt_xoff, popup_y + 10, 2, popupMessage, RED_8BIT, WHITE_8BIT);
+      PHNDisplay8Bit::writeString(popup_x + txt_xoff, popup_y + 10, 2, popupMessage, WHITE_8BIT, RED_8BIT);
       delay(800);
       PHNDisplay8Bit::fillRect(popup_x, popup_y, popup_w, popup_h, GRAY_8BIT);
       redrawAll = true;


Increase timestep for now

Increase timestep for now

--- inverted-pendulum.ino
+++ inverted-pendulum.ino
@@ -16,7 +16,7 @@
 #define DIR_PIN 12
 #define CART_RESET_PIN 21

-float prevSetpoint = 0; // temp - debug
+// float prevSetpoint = 0; // temp - debug

 // For incoming serial data
 int incomingByte = 0;
@@ -38,7 +38,7 @@

 // PID control for cart position
 float kp = 2, ki = 10, kd = 0; // Initial/default PID gain coeffs
-unsigned long timeStep = 15; // ms
+unsigned long timeStep = 20; // ms
 PIDControl cartPid(kp, ki, kd, 0, timeStep);
 elapsedMillis pidTimer = 0;

@@ -175,11 +175,14 @@

 void printStatus(PIDControl &pid)
 {
-  String s = String("kp,ki,kd: ") + kp + ", " + ki + ", " + kd
-             + String("; p,i,d: ") + pid.kp + ", " + pid.ki + ", " + pid.kd
-             + String(" setpoint: ") + pid.setpoint
-             + String(" output: ") + pid.output
-             + String(" pwm: ") + dutyCycle;
+  String s = String("{\"pid\":[") + pid.kp + "," + pid.ki + "," + pid.kd + "]"
+             + String(", \"setpoint\":") + (100*pid.setpoint)
+             + String(", \"output\":") + pid.output
+             + String(", \"pwm\":") + dutyCycle
+             + String(", \"x\":") + (100*float(trackEncoder.read())/xMax)
+             + String(", \"theta\":") + thetaEncoder.read()
+             + String(", \"time\":") + millis()
+             + "}";
   Serial.println(s);
 }

@@ -255,13 +258,15 @@

   if (pidTimer >= timeStep)
   {
-    if (prevSetpoint != cartPid.setpoint) { printStatus(cartPid); }
+    // if (prevSetpoint != cartPid.setpoint) { printStatus(cartPid); }
     pidTimer -= timeStep;
     float input = float(trackEncoder.read())/xMax;
     cartPid.update(input, 0.001);
     digitalWrite(DIR_PIN, cartPid.output < 0 ? LEFT : RIGHT);
     analogWrite(PWM_PIN, (fabs(cartPid.output) + 0.1)*maxPwm);
-    prevSetpoint = cartPid.setpoint;
+    // prevSetpoint = cartPid.setpoint;
+
+    printStatus(cartPid);
   }
 }


Update Sensors.ino

Update Sensors.ino

debugging flag activated

--- DroidMain/Sensors.ino
+++ DroidMain/Sensors.ino
@@ -8,7 +8,7 @@
 void JsonReportSensorDHT() {
   // Create Json and publish
   String jsonDHT = String("{\"sensor\":\"temp_hum\",\"time\":\"" + TimeStr + "\",\"data\":[" + dht.readTemperature() + "," + dht.readHumidity() + "]}");
-  Serial.println(jsonDHT);
+  if (debugging == true) { Serial.println(jsonDHT);}
   memset(bufff, 0, 512);  jsonDHT.toCharArray(bufff, 512);
   mqtt.publish("iot-uplink", bufff);
   return;
@@ -19,7 +19,7 @@
 void JsonReportSensorDistance(){
   // Create Json and publish
   String jsonDist = String("{\"sensor\":\"distance\",\"time\":\"" + TimeStr + "\",\"data\":[" + ultrasonic.Ranging(CM) + "]}");
-  Serial.println(jsonDist); // CM or INC
+  if (debugging == true) { Serial.println(jsonDist);}
   memset(bufff, 0, 512); jsonDist.toCharArray(bufff, 512);
   mqtt.publish("iot-uplink", bufff);
   return;
@@ -32,7 +32,7 @@
   accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
   // Create Json and publish
   String jsonAccGyro = String("{\"sensor\":\"acc_gyro\",\"time\":\"" + TimeStr + "\",\"data\":[" + ax + "," + ay + "," + az +"," + gx +"," + gy + "," + gz + "]}");
-  Serial.println(jsonAccGyro);
+  if (debugging == true) { Serial.println(jsonAccGyro);}
   memset(bufff, 0, 512); jsonAccGyro.toCharArray(bufff, 512);
   mqtt.publish("iot-uplink", bufff);
   return;
@@ -45,7 +45,7 @@
   magneto.getHeading(&mx, &my, &mz);
   // Create Json and publish
   String jsonMagneto = String("{\"sensor\":\"magneto\",\"time\":\"" + TimeStr + "\",\"data\":[" + mx + "," + my + "," + mz + "]}");
-  Serial.println(jsonMagneto);
+  if (debugging == true) { Serial.println(jsonMagneto);}
   memset(bufff, 0, 512); jsonMagneto.toCharArray(bufff, 512);
   mqtt.publish("iot-uplink", bufff);
   return;
@@ -56,7 +56,7 @@
 void JsonReportSensorEdge() {
   // Create Json and publish
   String jsonEdge = String("{\"sensor\":\"edge\",\"time\":\"" + TimeStr + "\",\"data\":[" + left_edge + "," + right_edge + "]}");
-  Serial.println(jsonEdge);
+  if (debugging == true) { Serial.println(jsonEdge);}
   memset(bufff, 0, 512); jsonEdge.toCharArray(bufff, 512);
   mqtt.publish("iot-uplink", bufff);
   return;
@@ -88,7 +88,7 @@
     }
     // Create Json and publish
     String jsonRfid = String("{\"sensor\":\"rfid\",\"data\":[" + NUID + "]}");
-    Serial.println(jsonRfid);
+    if (debugging == true) { Serial.println(jsonRfid);}
     memset(bufff, 0, 512); jsonRfid.toCharArray(bufff, 512);
     mqtt.publish("iot-uplink", bufff);
     return;


fix light

fix light

--- examples/Export_Demo/Blynk_ESP8266/Blynk_ESP8266.ino
+++ examples/Export_Demo/Blynk_ESP8266/Blynk_ESP8266.ino
@@ -100,7 +100,7 @@

     float dayPeriod = 3.0 * 60 * 1000;
     // Light level
-    Blynk.virtualWrite(V2, sinusoidal(5, 95, dayPeriod));
+    Blynk.virtualWrite(V2, (int)sinusoidal(5, 95, dayPeriod));
     // Temperature
     Blynk.virtualWrite(V3, sinusoidal(18, 23, dayPeriod) + randomize(-1.0, 1.0));


final version 1

final version 1

--- uAlarm/uAlarm.ino
+++ uAlarm/uAlarm.ino
@@ -9,6 +9,7 @@
 #include <Timezone.h>
 #include <TinyGPS++.h>
 #include <Time.h>
+#include "Streaming.h"

 //for the Adafruit 7-segment display I2C backpack
 #include <Wire.h>
@@ -19,7 +20,7 @@
 //#define DEBUG_FAKE_GPS
 //#define DEBUG_PRINT_BRIGHTNESS
 //#define DEBUG_PRINT_LOOP_SPEED
-#define DEBUG_TEST_TONE
+//#define DEBUG_TEST_TONE

 #define GPS_TIME_UPDATE_INTERVAL_SECS 10
 #define SNOOZE_DURATION_MINS 5
@@ -70,7 +71,7 @@
 boolean alarmOn;
 byte alarmHour = 12; // 24 hour time
 byte alarmMin = 0;
-boolean alarmAMPM = true; // false == AM, true == PM
+//boolean alarmAMPM = true; // false == AM, true == PM
 boolean snoozePressed = false;
 boolean currentlyAlarming = false;

@@ -141,7 +142,7 @@
     //TODO

     //communicate output to a PC
-    Serial.begin(115200);
+    Serial.begin(9600);

     #ifdef DEBUG_FAKE_GPS
     while (*gpsStream) if (gps.encode(*gpsStream++)) displayGPSInfo();
@@ -164,16 +165,17 @@

     //the first time we identify our location, calculate the time zone offset
     if (!locationFound && gps.location.isValid()) {
+        locationFound = true;
         Serial.println("loop: first location lock");
         //based on our location, determine our GMT offset, and whether our location uses DST
         setTimeZoneAndDST(gps.location.lat(), gps.location.lng());
-        locationFound = true;
         //stop blinking the display
         sevenSegmentDisplay.blinkRate(0);
         //set up sync provider for Time.h
         setSyncProvider(gpsTimeSync);
         setSyncInterval(GPS_TIME_UPDATE_INTERVAL_SECS);
         setTime(gpsTimeSync());
+        delay(10);
     }

     readSwitchesUpdateAlarmTime();
@@ -217,7 +219,6 @@
             currentMode = LCDTime;
             digitalClockSerialDisplay();
             writeTimeDisplay(alarmHour,alarmMin,true);
-            Serial.println("showing alarm time");
     }

 #ifdef DEBUG_PRINT_LOOP_SPEED
@@ -1439,8 +1440,6 @@
     Serial.print(alarmHour);
     Serial.print(" alarmMin: ");
     Serial.print(alarmMin);
-    Serial.print(" alarmAMPM: ");
-    Serial.print(alarmAMPM);
     Serial.print(" currentlyAlarming: ");
     Serial.print(currentlyAlarming);
     Serial.println();
@@ -1607,9 +1606,9 @@
     byte	minSwitchVal;
     static byte	prevHourSwitchVal = 255;
     static byte	preMinSwitchVal = 255;
-    boolean alarmAMPM;
     static boolean prevAlarmAMPM = false;
     boolean alarmOnSwitchVal;
+    boolean alarmAMPM;

     //read all of the switches positions
     hourSwitchVal	= AlarmHourSwitchValue(); // noon == 0
@@ -1618,12 +1617,15 @@
     //if the alarm switch is flipped off then turn off the alarm
     alarmOnSwitchVal = (digitalRead(alarmOnPin)==LOW);

+
     if ((hourSwitchVal != prevHourSwitchVal)||
         (minSwitchVal != preMinSwitchVal)   ||
         (alarmAMPM != prevAlarmAMPM)        ||
         (!alarmOn && alarmOnSwitchVal) ) // someone deliberately changed a knob position
     {
-        alarmHour = hourSwitchVal + 12 * (byte)alarmAMPM;
+        Serial << alarmOn << alarmOnSwitchVal << ":" << prevHourSwitchVal << preMinSwitchVal << prevAlarmAMPM << "-->";
+        Serial << hourSwitchVal << minSwitchVal << alarmAMPM << endl;
+       alarmHour = hourSwitchVal + 12 * (byte)alarmAMPM;
         alarmMin = minSwitchVal;
         prevHourSwitchVal = hourSwitchVal;
         preMinSwitchVal = minSwitchVal;
@@ -1693,4 +1695,4 @@
         tone(speakerPin,NOTE_B4,noteDurationMillis);
         nextNoteTime+=noteDurationMillis+noteGapMillis;
     }
-}+}


esp32 crashes on cb route shared pointer

--- examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino
+++ examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino
@@ -55,7 +55,7 @@
 }

 void bindServerCallback(){
-  wm.server->on("/custom",handleRoute);
+  // wm.server->on("/custom",handleRoute); // this is now crashing esp32 for some reason
   // wm.server->on("/info",handleRoute); // you can override wm!
 }


tm: show temperature of two sensors on lcd

--- tm.ino
+++ tm.ino
@@ -1,58 +1,47 @@
 /*
- * tm, by poinck, CC0
+ * tm (temperature measurement), by poinck, CC0
+ *
+ * lcd code used from Mark Bramwell (100700)
+ * - modified (180520)
  */
+
+#include <LiquidCrystal.h>
+#include <EEPROM.h>
+
+LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
+
+// define some values used by the panel and buttons
+int lcd_key = 0;
+int adc_key_in = 0;
+
+#define btnRIGHT  0
+#define btnUP     1
+#define btnDOWN   2
+#define btnLEFT   3
+#define btnSELECT 4
+#define btnNONE   5

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

-#define ONE_WIRE_BUS 6
+#define ONE_WIRE_BUS 2

 OneWire ourWire(ONE_WIRE_BUS);
 DallasTemperature sensors(&ourWire);
 String s1 = "";
 String s2 = "";
-
-void setup() {
-    Serial.begin(9600);
-    delay(1000);
-    Serial.println("start tm with serial 9600 ..");
-    sensors.begin();
-    Serial.println(" - get dallas sensors ..");
-    get_sensors();
-    Serial.println(" - set dallas resolution ..");
-    sensors.setResolution(9);
-    Serial.println(".. tm ready");
-    Serial.println();
-}
-
-void loop() {
-    sensors.requestTemperatures();
-
-    Serial.print(s1);
-    Serial.print(": ");
-    Serial.print(sensors.getTempCByIndex(0));
-    Serial.println();
-    Serial.print(s2);
-    Serial.print(": ");
-    Serial.print(sensors.getTempCByIndex(1));
-    Serial.println();
-
-    delay(15000);
-}
+int t1 = 0;
+int t2 = 0;

 void identify_sensors(const byte* addr_part) {
     String st;
     if (addr_part == 0xF2) {
         Serial.print(", inside");
-        st = "inside";
+        st = "i";
     }
     else if (addr_part == 0xD1) {
         Serial.print(", outside");
-        st = "outside";
-    }
-    else {
-        Serial.print("");
-        st = "unknown";
+        st = "o";
     }

     if (s1 == "") {
@@ -94,3 +83,159 @@

     return;
 }
+
+int read_lcd_buttons() {
+    adc_key_in = analogRead(0);
+
+    if (adc_key_in > 1000) return btnNONE;
+
+    // button thresholds
+    if (adc_key_in < 50)   return btnRIGHT;
+    if (adc_key_in < 195)  return btnUP;
+    if (adc_key_in < 380)  return btnDOWN;
+    if (adc_key_in < 555)  return btnLEFT;
+    if (adc_key_in < 790)  return btnSELECT;
+
+    return btnNONE;
+}
+
+int ee_address = 0;
+
+struct lcdtext {
+    char s[14];
+};
+
+void setup() {
+    // initialize the LCD lib
+    lcd.begin(16, 2);
+    lcd.setCursor(0,0);
+    lcd.print("t:push buttons");
+
+    Serial.begin(9600);
+    delay(1000);
+
+    Serial.println("start tm with serial 9600 ..");
+    sensors.begin();
+    Serial.println(" - get dallas sensors ..");
+    get_sensors();
+    Serial.println(" - set dallas resolution ..");
+    sensors.setResolution(9);
+    Serial.println(".. tm ready");
+    Serial.println();
+
+    Serial.println("type to print on LCD");
+
+    String ee_text = "";
+
+    lcdtext lt_get;
+    EEPROM.get(ee_address, lt_get);
+    Serial.println("current text on EEPROM is");
+    Serial.print("t:");
+    Serial.println(lt_get.s);
+    lcd.setCursor(2,0);
+    lcd.print("              ");
+    lcd.setCursor(2,0);
+    lcd.print(lt_get.s);
+
+    Serial.println("type to print something else on LCD");
+}
+
+int incomingByte = 0;
+String incoming_text = "";
+int next_interval = 0;
+int seconds_past = 0;
+int next_counter = 0;
+
+void loop(){
+    lcd.setCursor(4,1);
+    lcd.print("i:");
+    lcd.setCursor(10,1);
+    lcd.print("o:");
+    seconds_past = millis()/1000;
+
+    lcd.setCursor(0,1);
+    lcd_key = read_lcd_buttons();
+
+    switch (lcd_key){
+        case btnRIGHT: {
+             lcd.print("b:R");
+             break;
+        }
+        case btnLEFT: {
+              lcd.print("b:L");
+              break;
+        }
+        case btnUP: {
+              lcd.print("b:U");
+              break;
+        }
+        case btnDOWN: {
+              lcd.print("b:D");
+              break;
+        }
+        case btnSELECT: {
+              lcd.print("b:S");
+              break;
+        }
+        case btnNONE: {
+              lcd.print("b:N");
+              break;
+        }
+    }
+
+    if (Serial.available() > 0) {
+        //incomingByte = Serial.read();
+        incoming_text = Serial.readString();
+
+        // say what you got:
+        Serial.print("t:");
+        //Serial.println(incomingByte, DEC);
+        Serial.println(incoming_text);
+        lcd.setCursor(2,0);
+        lcd.print("              ");
+        lcd.setCursor(2,0);
+        lcd.print(incoming_text);
+
+        char c_text[14];
+        lcdtext lt;
+        incoming_text.toCharArray(lt.s, 14);
+        //lt.s = c_text;
+
+        EEPROM.put(ee_address, lt);
+    }
+
+    if (next_interval < seconds_past) {
+        next_interval = next_interval + 60;
+        sensors.requestTemperatures();
+
+        Serial.print("s:");
+        Serial.print(seconds_past);
+        Serial.print(" ");
+        Serial.print(s1);
+        Serial.print(":");
+        t1 = (int) sensors.getTempCByIndex(0);
+        Serial.print(t1);
+        lcd.setCursor(6,1);
+        lcd.print("   ");
+        lcd.setCursor(6,1);
+        lcd.print(t1);
+        Serial.print(" ");
+        Serial.print(s2);
+        Serial.print(":");
+        t2 = (int) sensors.getTempCByIndex(1);
+        Serial.print(t2);
+        lcd.setCursor(12,1);
+        lcd.print("   ");
+        lcd.setCursor(12,1);
+        lcd.print(t2);
+        Serial.println();
+    }
+
+    next_counter = (int) ((next_interval - seconds_past) / 10) + 1;
+    lcd.setCursor(13,0);
+    lcd.print("d:");
+    lcd.print(next_counter);
+
+    delay(1000);
+}
+


Update COA_Arduino.ino

Update COA_Arduino.ino


Wakeup & power

Wakeup & power

--- tracker/tracker.ino
+++ tracker/tracker.ino
@@ -70,6 +70,7 @@

 #define LED_DEBUG 13
 #define PIN_TX 12
+#define PIN_PERIF_POWER 7 // PD7

 #define PIN_LDR_LEFT  2 // PC2
 #define PIN_LDR_RIGHT 3 // PC3
@@ -82,6 +83,7 @@
 #define SERVO_HORZ_MIN 700
 #define SERVO_PIN_HORZ_POWER 8 // PB0

+#define DARK_THRESHOLD 500 // too dark below this

 // When the last move was attempted.
 unsigned long move_last = 0;
@@ -93,6 +95,8 @@
 // The transmit interval.
 const long tx_interval = 2000;

+int light_level = 0; // latest light reading from the LDR
+
 byte ledState = HIGH;
 byte msgId = 0;

@@ -102,6 +106,13 @@
 // Store the current servo positions.
 int servo_horz_pos = 1700;

+/**
+ * ISR for INT0
+ */
+void wakeUp()
+{
+  // Just wake up
+}

 void setup()
 {
@@ -111,6 +122,9 @@

     pinMode(LED_DEBUG, OUTPUT);
     pinMode(PIN_TX, OUTPUT);
+
+    pinMode(PIN_PERIF_POWER);
+    digitalWrite(PIN_PERIF_POWER, HIGH); // high = 0n (NPN)

     pinMode(SERVO_PIN_HORZ_POWER, OUTPUT);
     digitalWrite(SERVO_PIN_HORZ_POWER, LOW); // low = 0n (PNP)
@@ -121,11 +135,8 @@
     vw_set_tx_pin(PIN_TX);

     servo_horz.attach(SERVO_PIN_HORZ, SERVO_HORZ_MIN, SERVO_HORZ_MAX);
-
     servo_horz.writeMicroseconds(servo_horz_pos);
-
-
-
+
 }

 void loop()
@@ -139,6 +150,12 @@

         // Move the panels if needed.
         tkr_move();
+
+        if (light_level < DARK_THRESHOLD) {
+          //goToSleep();
+          //TODO connect PIN_LDR_LEFT to INT0
+        }
+
     }

     if (now - tx_last >= tx_interval) {
@@ -193,6 +210,7 @@
     int left = analogRead(PIN_LDR_LEFT);
     int right = analogRead(PIN_LDR_RIGHT);

+    light_level = left;

     Serial.print(left);
     Serial.print(':');
@@ -217,34 +235,50 @@
   // Reset after 8 seconds,
   // unless wdt_reset(); has been successfully called
   wdt_enable(WDTO_8S);
+  wdt_reset();
 }

 void goToSleep()
 {
-
-   // disable ADC
+  // Power down the periferals
+  digitalWrite(PIN_PERIF_POWER, LOW);
+
+  cli();
+
+  // Turn off watchdog
+  wdt_disable();
+
+  // disable ADC
   ADCSRA = 0;

   set_sleep_mode(SLEEP_MODE_PWR_DOWN);

-  //cli();
-
+  // Attach the external interupt to the LDR.
+  attachInterrupt(0, wakeUp, HIGH);
+
   power_all_disable();  // power off ADC, Timer 0 and 1, serial interface
   sleep_enable();
+  sei();
+
   // turn off brown-out enable in software
   MCUCR = bit (BODS) | bit (BODSE);  // turn on brown-out enable select
   MCUCR = bit (BODS);        // this must be done within 4 clock cycles of above
-  sleep_cpu ();              // sleep within 3 clock cycles of above
-  //sleep_enable();
-
-  //sei();
-  //sleep_cpu();
+  sleep_cpu();              // sleep within 3 clock cycles of above
+
+
   sleep_disable();
-  MCUSR = 0; // clear the reset register
+  //MCUSR = 0; // clear the reset register
+
+  watchdog_setup(); // watchdog back on
+
+  detachInterrupt(0); // No wakeup interupt while awake
+
   power_all_enable();    // power everything back on

   ADCSRA = (1 << ADEN); // ADC back on

+  // Power up the periferals
+  digitalWrite(PIN_PERIF_POWER, HIGH); // high = 0n (NPN)
 }

 /**


fsr and pump test

fsr and pump test

--- MTM_MODULE.ino
+++ MTM_MODULE.ino
@@ -29,10 +29,10 @@
 void setup(){
     noInterrupts();
     //Serial.begin(9600);
-    for(int i=0;i<4;i++){			//configures inPins
+    for(int i=0;i< sizeof(inPins); i++){			//configures inPins
         pinMode(inPins[i],OUTPUT);
     }
-    for(int i=0;i<addrSize;i++){	//join I2C bus
+    for(int i=0;i<addrSize;i++){	//join I2C
     	Wire.begin(addr[i]);
     }
     //addr=address();


fixed wrong function call in SensorTest.ino

--- SensorTest.ino
+++ SensorTest.ino
@@ -36,7 +36,7 @@

 void loop() {
     // Read the value from the sensor
-    distance = ultrasonic.MeasureInCentimeters();
+    distance = getDistanceInCentimeters();

     // Convert the value to individual decimal digits for display
     for (int i = 3; i >= 0; i--) {


More defines, added skyview, led on startup

skyview support has not been tested yet.

--- AOA_TONE_EFIS_SERIAL/AOA_TONE_EFIS_SERIAL.ino
+++ AOA_TONE_EFIS_SERIAL/AOA_TONE_EFIS_SERIAL.ino
@@ -41,23 +41,32 @@
 // This is useful because if your on the ground you don't need a beeping in your ear.
 #define MUTE_AUDIO_UNDER_IAS  5

-// dynon expected string length
-#define DYNON_SERIAL_LEN      53
-
-// Tone Pulse Per Sec (PPS) for high and low tones.
-#define HIGH_TONE_PPS_MAX     6.5
-#define HIGH_TONE_PPS_MIN     1.5
+// Expected serial string lengths
+#define DYNON_SERIAL_LEN              53
+#define DYNON_SKYVIEW_SERIAL_LEN      74
+
+// AOA values & Tone Pulse Per Sec (PPS)
+#define HIGH_TONE_STALL_PPS   20      // how many PPS to play during stall
+#define HIGH_TONE_AOA_STALL   90      // % (and above) where stall happens.
+#define HIGH_TONE_AOA_START   70      // % (and above) where high tone starts
+#define HIGH_TONE_PPS_MAX     6.5     // 6.5
+#define HIGH_TONE_PPS_MIN     1.5     // 1.5
+#define HIGH_TONE_HZ          1600    // freq of high tone
+//#define HIGH_TONE2_HZ         1500    // a 2nd high tone that it will cycle between (if defined)
+
+#define LOW_TONE_AOA_SOLID    60      // % (and above) where a solid low tone is played.
+#define LOW_TONE_AOA_START    20      // % (and above) where low
 #define LOW_TONE_PPS_MAX      8.5
 #define LOW_TONE_PPS_MIN      1.5
-
-#define TONE_PIN          2     // TIOA0
-#define PIN_LED1          13    // internal LED for showing AOA status.
-#define PIN_LED2          54    // aka A0. external LED for showing serial input.
-#define TONE1600hz        1600
-#define TONE400hz         400
-#define PULSE_TONE        1
-#define SOLID_TONE        2
-#define TONE_OFF          3
+#define LOW_TONE_HZ           400     // freq of low tone
+
+#define TONE_PIN              2     // TIOA0
+#define PIN_LED1              13    // internal LED for showing AOA status.
+#define PIN_LED2              54    // aka A0. external LED for showing serial input.
+#define PULSE_TONE            1
+#define SOLID_TONE            2
+#define TONE_OFF              3
+#define STARTUP_TONES_DELAY   120

 uint8_t toneState = false;
 unsigned char toneMode = PULSE_TONE;  // current mode of tone.  PULSE_TONE, SOLID_TONE, or TONE_OFF
@@ -79,10 +88,10 @@
 float NewRange, NewValue;

 char inChar;                    // store single serial input char here.
-#define MAXSIZE 70              // max length of string
+#define MAXSIZE 90              // max length of string
 char input[MAXSIZE+1];          // buffer for full serial data input string.
 int inputPos = 0;               // current postion of serial data.
-char tempBuf[50];               // misc char buffer used for debug
+char tempBuf[90];               // misc char buffer used for debug

 void setup() {
   // put your setup code here, to run once:
@@ -95,25 +104,27 @@

   configureToneTimer();   //setup timer used for tone

+  digitalWrite(PIN_LED2, 1);
   setFrequencytone(400);
-  delay(200);
+  delay(STARTUP_TONES_DELAY);
   setFrequencytone(600);
-  delay(200);
+  delay(STARTUP_TONES_DELAY);
   setFrequencytone(800);
-  delay(200);
+  delay(STARTUP_TONES_DELAY);
   setFrequencytone(1000);
-  delay(200);
+  delay(STARTUP_TONES_DELAY);
   setFrequencytone(1200);
-  delay(200);
+  delay(STARTUP_TONES_DELAY);
   setFrequencytone(1000);
-  delay(200);
+  delay(STARTUP_TONES_DELAY);
   setFrequencytone(800);
-  delay(200);
+  delay(STARTUP_TONES_DELAY);
   setFrequencytone(600);
-  delay(200);
+  delay(STARTUP_TONES_DELAY);
   setFrequencytone(400);
-  delay(200);
+  delay(STARTUP_TONES_DELAY);
   setFrequencytone(0);
+  digitalWrite(PIN_LED2, 0);

   // timer callback is used for turning tone on/off.
   Timer4.attachInterrupt(tonePlayHandler);
@@ -125,6 +136,7 @@
 // We use our own counter for how often we should pause between tones (pulses per sec PPS)
 int cycleCounter = 0;
 int cycleCounterResetAt = FREQ_OF_FUNCTION;
+uint8_t Tone2FlipFlop = false;
 void tonePlayHandler(){
   cycleCounter++;
   // check if our counter has reach the reset mark.  if so flip the tone on/off and start again.
@@ -144,7 +156,7 @@
 #ifdef SHOW_SERIAL_DEBUG
     Serial.println("SOLID TONE");
 #endif
-    setFrequencytone(TONE400hz);
+    setFrequencytone(LOW_TONE_HZ);
     return; // skip the rest
   }

@@ -153,17 +165,27 @@
      digitalWrite(PIN_LED1, digitalRead(PIN_LED1)^1);  // cycle led on/off
      //sprintf(tempBuf, "handler() AOA:%i ASI:%i tone: %i PPS:%f handlerFreq: %i",AOA,ASI,toneFreq,pps, handlerFreq);
      //Serial.println(tempBuf);
-     if(highTone)
-        setFrequencytone(TONE1600hz);
-     else
-        setFrequencytone(TONE400hz);
+     if(highTone) {
+// check if we want 2 different tones for the high tone mode.
+#ifdef HIGH_TONE2_HZ
+        Tone2FlipFlop = Tone2FlipFlop ^ 1;
+        if(Tone2FlipFlop)
+          setFrequencytone(HIGH_TONE_HZ);
+        else
+          setFrequencytone(HIGH_TONE2_HZ);
+#else
+        setFrequencytone(HIGH_TONE_HZ);
+#endif
+     } else {
+        setFrequencytone(LOW_TONE_HZ);
+     }

   } else {
     setFrequencytone(0);
   }
 }

-void checkAOA_Dynon() {
+void checkAOA() {
   if(ASI <= MUTE_AUDIO_UNDER_IAS) {
 #ifdef SHOW_SERIAL_DEBUG
   // show audio muted and debug info.
@@ -179,13 +201,13 @@
   }

   // check AOA value and set tone and pauses between tones according to
-  if(AOA >= 90) {
-    // play 20 pps 1600hz tone
+  if(AOA >= HIGH_TONE_AOA_STALL) {
+    // play 20 pps HIGH tone
     highTone = true;
-    setPPSTone(20);
+    setPPSTone(HIGH_TONE_STALL_PPS);
     toneMode = PULSE_TONE;
-  } else if(AOA >= 70) {
-    // play 1600hz tone at Pulse Rate 1.5 PPS to 6.2 PPS (depending on AOA value)
+  } else if(AOA >= HIGH_TONE_AOA_START) {
+    // play HIGH tone at Pulse Rate 1.5 PPS to 6.2 PPS (depending on AOA value)
     highTone = true;
     OldValue = AOA-69;
     toneMode = PULSE_TONE;
@@ -194,15 +216,14 @@
     NewRange = HIGH_TONE_PPS_MAX - HIGH_TONE_PPS_MIN; // (NewMax - NewMin)
     NewValue = (((OldValue - 1) * NewRange) / OldRange) + HIGH_TONE_PPS_MIN; //(((OldValue - OldMin) * NewRange) / OldRange) + NewMin
     setPPSTone(NewValue);
-  } else if(AOA >= 60) {
-    // play a steady 400hz tone
+  } else if(AOA >= LOW_TONE_AOA_SOLID) {
+    // play a steady LOW tone
     highTone = false;
     toneMode = SOLID_TONE;
-    //setFrequencytone(TONE400hz);
-  } else if(AOA > 20) {
+  } else if(AOA > LOW_TONE_AOA_START) {
     toneMode = PULSE_TONE;
     highTone = false;
-    // play 400hz tone at Pulse Rate 1.5 PPS to 8.2 PPS (depending on AOA value)
+    // play LOW tone at Pulse Rate 1.5 PPS to 8.2 PPS (depending on AOA value)
     // scale number using this. http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio
     OldValue = AOA-20;
     OldRange = 40 - 1;  //(OldMax - OldMin)
@@ -237,7 +258,31 @@
         input[inputPos]=inChar;
         inputPos++;
         cyclesWOSerialData = 0;
-        if (inChar == '\n' && inputPos == DYNON_SERIAL_LEN) {  // is EOL?
+
+        // check for dynon skyview data.
+        if (inChar == '\n' && inputPos == DYNON_SKYVIEW_SERIAL_LEN && input[0]=='!' && input[1]=='1') {
+          // skyview data starts with a '!1'... the D series efis has no line prefix.
+          tempBuf[0] = input[43]; //
+          tempBuf[1] = input[44]; //
+          tempBuf[2] = '\0'; //term string
+          liveAOA = strtol(tempBuf, NULL, 10); //convert to int
+
+          // get AOA value
+#ifdef USE_AOA_AVERAGE
+          myAverageAOA += liveAOA;            // store and calcute the mean average AOA from previous values.
+          AOA = myAverageAOA.process().mean;
+#else
+          AOA = liveAOA;  // else just use the live AOA value.
+#endif
+          // get ASI (4 digits) but we only want the first 3. we don't need a 10/th of a knot
+          tempBuf[0] = input[23]; //
+          tempBuf[1] = input[24]; //
+          tempBuf[2] = input[25]; //
+          tempBuf[3] = '\0'; //
+          ASI = strtol(tempBuf, NULL, 10); //convert to int (data comes in knots already on skyview)
+          validAOADataFound();
+        } else if (inChar == '\n' && inputPos == DYNON_SERIAL_LEN) {  // is EOL?
+          // else check for dynon d series data.
           // get AOA from dynon efis string.  details of format can be found from dynon pdf manual.
           tempBuf[0] = input[39]; //
           tempBuf[1] = input[40]; //
@@ -266,19 +311,14 @@
           tempBuf[3] = input[28]; //
           tempBuf[4] = '\0'; //
           ALT = (strtol(tempBuf, NULL, 10) * 0.328) * 10; //convert to long (and from meters to feet)
-
-          // check how often we want to sample the serial data.
-          LedCountDown --;
-          if(LedCountDown<1) {
-             digitalWrite(PIN_LED2, digitalRead(PIN_LED2)^1);  // cycle serial RX led on/off
-             LedCountDown = SERIAL_SAMPLE_RATE;
-             checkAOA_Dynon();  // check AOA data from dynon and store result into AOA var.
-             // TODO: check if we have a different EFIS and create seperate parse function.
-          }
-          inputPos = 0;  // reset postion to start of buffer string for next round.
+          validAOADataFound();
+        } else if(inChar == '\n') {
+          // if we are at the end of line then reset postion to start looking for a new line.
+          inputPos = 0;
+        } else if(inputPos>DYNON_SKYVIEW_SERIAL_LEN) {
+          // else safety check, if we went past the max number of chars then reset to zero
+          inputPos = 0;
         }
-        // else safety check, if we went past the number of expected chars then reset to 0.
-        if(inputPos>DYNON_SERIAL_LEN) inputPos = 0;

       }

@@ -294,7 +334,16 @@
       }
 }

-
+void validAOADataFound() {
+  // check how often we want to sample the serial data.
+  LedCountDown --;
+  if(LedCountDown<1) {
+     digitalWrite(PIN_LED2, digitalRead(PIN_LED2)^1);  // cycle serial RX led on/off
+     LedCountDown = SERIAL_SAMPLE_RATE;
+     checkAOA();  // check AOA data from dynon and store result into AOA var.
+  }
+  inputPos = 0;  // reset postion to start of buffer string for next round.
+}

 void configureToneTimer() {
   // Configure TONE_PIN pin as timer output


write instead of print writes output as one line

--- weather-clock.ino
+++ weather-clock.ino
@@ -83,21 +83,24 @@
     // Serial.println(client.available());

   // }
+  // for(byte x = 0; x < sizeof(c); x++){
+  //   json[x] = c[x];
+  // }
+
+
   while(client.available()) {
     c = client.read();
-    Serial.println(c);
+    Serial.write(c);
     charArr[i] = c;
     i++;
   }

-  // for(byte x = 0; x < sizeof(c); x++){
-  //   json[x] = c[x];
-  // }
+

   JsonObject& root = jsonBuffer.parseObject(charArr);
-  char target[600];
-  root.printTo(target, root.measureLength() + 1);
-  Serial.println(target);
+  // char target[600];
+  // root.printTo(target, root.measureLength() + 1);
+  // Serial.println(target);

   // if the server's disconnected, stop the client:
   if (!client.connected()) {


Stbd BGA motors/enc order change to be symm to Port

Stbd BGA motors/enc order change to be symm to Port.  Wiring (slip rings, etc.) was already changed to be symmetric, so this coding change was required.

--- Arduino/Ard_StbdBGAs_r18/Ard_StbdBGAs_r18.ino
+++ Arduino/Ard_StbdBGAs_r18/Ard_StbdBGAs_r18.ino
@@ -171,26 +171,29 @@

 // 0x70 is the "all call" which means all motor shields connected to this Ardwill be commanded, regardless of their I2C ID.  Works as long as it's not more than one motor shield for each Arduino.
 // (If we ever stack multiple motor shields, will have to address individually)
-//Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x70);
-//Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x70);  // Stbd
-

 // Select which 'port' M1, M2, M3 or M4. In this case, M1,2,4
-Adafruit_DCMotor *myMotorB1A = AFMS.getMotor(1);
-Adafruit_DCMotor *myMotorB3A = AFMS.getMotor(2);
-Adafruit_DCMotor *myMotorB1B = AFMS.getMotor(3);
-Adafruit_DCMotor *myMotorB3B = AFMS.getMotor(4);
+//Adafruit_DCMotor *myMotorB1A = AFMS.getMotor(1);
+//Adafruit_DCMotor *myMotorB3A = AFMS.getMotor(2);
+//Adafruit_DCMotor *myMotorB1B = AFMS.getMotor(3);
+//Adafruit_DCMotor *myMotorB3B = AFMS.getMotor(4);
+
+
+Adafruit_DCMotor *myMotorB3A = AFMS.getMotor(1);
+Adafruit_DCMotor *myMotorB1A = AFMS.getMotor(2);
+Adafruit_DCMotor *myMotorB3B = AFMS.getMotor(3);
+Adafruit_DCMotor *myMotorB1B = AFMS.getMotor(4);

 //Adafruit_DCMotor *myMotorPSARJ = AFMS2.getMotor(1);
 //Adafruit_DCMotor *myMotorSSARJ = AFMS2.getMotor(2);

-Encoder myEnc1A(0, 1);
-Encoder myEnc3A(2, 3); // was 4,5 but motor was oozing, digital pins were toggleing, but count wasn't incrementing (interrupt prob?)
+Encoder myEnc3A(0, 1);
+Encoder myEnc1A(2, 3); // was 4,5 but motor was oozing, digital pins were toggleing, but count wasn't incrementing (interrupt prob?)
 // Pins 9, 10 are used by Servos.
 // Odd issues with Pins 2-4.
 // Pin 13 is nominally used by LED and general guidance from encoder library is to avoid it.
-Encoder myEnc1B(7, 8); // BCM changed from 6,7 to 7,8 on Nov 15, 2018
-Encoder myEnc3B(11, 12);
+Encoder myEnc3B(7, 8); // BCM changed from 6,7 to 7,8 on Nov 15, 2018
+Encoder myEnc1B(11, 12);

 //Encoder myEncPSARJ(16, 17);// BCM changed from 14,15 to 9,10 since pin 15 always staed high for some reason on Nov 15, 2018
 //Encoder myEncSSARJ(14, 15);


new english comment

new english comment

--- Codes/Arduino/sketch_jun04c/sketch_jun04c.ino
+++ Codes/Arduino/sketch_jun04c/sketch_jun04c.ino
@@ -1,4 +1,3 @@
-

 int nextStepX = 1;
 int backStepX = 1;
@@ -8,24 +7,26 @@

 int led = 50;

-int nikoDelay = 10;  // 2ms f platinen!!
+int nikoDelay = 10;  // 2ms for PCB photoresist!!

 int testDigInt;
-
 String contentString;
+
+

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

-  pinMode(9, OUTPUT);   //enables fuer X achse
-  pinMode(10, OUTPUT);  //enables fuer X achse
-  digitalWrite(9, HIGH);  //enables fuer X achse
-  digitalWrite(10, HIGH); //enables fuer X achse
-
-  pinMode(3, OUTPUT);  //enables fuer Y achse
-  pinMode(2, OUTPUT);  //enables fuer Y achse
-  digitalWrite(3, HIGH); //enables fuer Y achse
-  digitalWrite(2, HIGH); //enables fuer Y achse
+
+  pinMode(9, OUTPUT);   //enables for X axis
+  pinMode(10, OUTPUT);  //enables for X axis
+  digitalWrite(9, HIGH);  //enables for X axis
+  digitalWrite(10, HIGH); //enables for X axis
+
+  pinMode(3, OUTPUT);  //enables for Y axis
+  pinMode(2, OUTPUT);  //enables for Y axis
+  digitalWrite(3, HIGH); //enables for Y axis
+  digitalWrite(2, HIGH); //enables for Y axis

   pinMode(13, OUTPUT);
   pinMode(12, OUTPUT);
@@ -37,24 +38,26 @@
   pinMode(5, OUTPUT);
   pinMode(4, OUTPUT);

-  pinMode(52, INPUT);  //Schalter
+
+
+  pinMode(52, INPUT);  //switch
   pinMode(led, OUTPUT);  //laser
 }

 void loop() {

-  int x = map(analogRead(A0),0,1023,1,100);
-  int y = map(analogRead(A1),0,1023,1,100);
-
-  while (Serial.available() > 0) {
-    String RawRead = Serial.readStringUntil('\n');
-    String BackWay = RawRead.substring(300);
+  int x = map(analogRead(A0),0,1023,1,100); //get analog values from potentionometer joystick
+  int y = map(analogRead(A1),0,1023,1,100); //get analog values from potentionometer joystick
+
+  while (Serial.available() > 0) { // get 01010100110 sting from computer running processing
+    String RawRead = Serial.readStringUntil('\n'); //write raw string until end of line
+    String BackWay = RawRead.substring(300);  //get the first 300 characters of input string

     //Serial.print("I Read: ");
     //Serial.println(BackWay);

-    String testDigit = RawRead.substring(0,1);
-    contentString = RawRead.substring(0,300);
+    String testDigit = RawRead.substring(0,1);  //i have absolutely no idea what this was for :D
+    contentString = RawRead.substring(0,300);

     testDigInt = testDigit.toInt();
     //Serial.print("testDig: ");
@@ -63,35 +66,37 @@
     //Serial.print("String: ");
     //Serial.println(contentString);

-    digitalWrite(3, HIGH);
-    digitalWrite(2, HIGH);
-    digitalWrite(9, HIGH);
-    digitalWrite(10, HIGH);
-
-    for (int i=0; i <= 300; i++){
+    digitalWrite(3, HIGH);  //enable stepper motor drivers
+    digitalWrite(2, HIGH);  //enable stepper motor drivers
+    digitalWrite(9, HIGH);  //enable stepper motor drivers
+    digitalWrite(10, HIGH); //enable stepper motor drivers
+
+    for (int i=0; i <= 300; i++){ //run threw the lines until the end of range
       //Serial.print(contentString[i]);

-      if(contentString[i] == '1') {
-        digitalWrite(led, HIGH);
+      if(contentString[i] == '1') { //when string contains a black pixel at the current point...
+        digitalWrite(led, HIGH);    //set laser high
         //Serial.println("1");
-        doStepY(0);
-        delay(nikoDelay);
+
+        // not sure if the order is in the right way! maybe wait before doSepY(0); ?? but it workd this way!
+        doStepY(0);   // do next step
+        delay(nikoDelay); // wait for the time the laser should burn
       }
       else {
-        digitalWrite(led, LOW);
+        digitalWrite(led, LOW);   // set/keep laser off
         //Serial.println("0");
-        doStepY(0);
-        delay(2);  //2ms für ruhigen lauf
+        doStepY(0); // do next step
+        delay(2);  //2ms for good running behaviour
       }
     }
-    doStepX(1);
-
-
-    for (int i=0; i <= 300; i++){
+    doStepX(1); // to step next for the laser mechanic
+
+
+    for (int i=0; i <= 300; i++){ //get threw the lines in reversed orientation...
       //Serial.print(contentString[i]);

-
+      //same procedure as last time
       if(BackWay[i] == '1') {
         digitalWrite(led, HIGH);
         //Serial.println("1");
@@ -105,24 +110,25 @@
         delay(2);
       }
     }
-    doStepX(1);
-
-    Serial.write("k");
-
-  }
-
-  digitalWrite(9, LOW);
-  digitalWrite(10, LOW);
-  digitalWrite(3, LOW);
-  digitalWrite(2, LOW);
-
-  if(digitalRead(52) == HIGH) {
-    digitalWrite(led, HIGH);
-  }else digitalWrite(led, LOW);
-
-
-  if(x > 60 || x < 40 || y > 60 || y < 40) {
-    if(x > 60) {
+    doStepX(1); // to step next for the laser mechanic
+
+    Serial.write("k"); //write feedback for processing
+
+  }// end of serial.available
+
+  digitalWrite(9, LOW); //disable all motordrivers
+  digitalWrite(10, LOW);  //disable all motordrivers
+  digitalWrite(3, LOW); //disable all motordrivers
+  digitalWrite(2, LOW); //disable all motordrivers
+
+  if(digitalRead(52) == HIGH) { //if button is pressed...
+    digitalWrite(led, HIGH);  // turn on laser
+  }else digitalWrite(led, LOW); //if button is not pressed, turn off laser
+
+
+
+  if(x > 60 || x < 40 || y > 60 || y < 40) {  // if joystick is moved enough...
+    if(x > 60) {  // move axis when joystick is moved
       doStepX(1);
       //Serial.println("StepX 1");
     }
@@ -130,17 +136,17 @@
       doStepX(0);
       //Serial.println("StepX 0");
     }
-    if(x > 40 && x < 60) {
+    if(x > 40 && x < 60) { //set of X motor drivers, when joystick is not moved enough
       digitalWrite(9, LOW);
       digitalWrite(10, LOW);
     }
-    else {
+    else {  //set on X motors, when joystick X axis is moved enough
       digitalWrite(9, HIGH);
       digitalWrite(10, HIGH);
     }
-
-
-    if(y > 60) {
+
+
+    if(y > 60) {  //same for Y axis...
       doStepY(1);
       //Serial.println("StepY 1");
     }
@@ -157,11 +163,12 @@
       digitalWrite(2, HIGH);
     }

-    delay(3);
+    delay(3); // for moveing the steppermotors not to fast, when joystick is moved
   }

 }
-void doStepX(int dirForX) {
+
+void doStepX(int dirForX) {   //stepper motor function for X axis
   if(dirForX == 1) {
     switch(nextStepX) {
       case 1:
@@ -300,7 +307,7 @@

 }

-void doStepY(int dirForY) {
+void doStepY(int dirForY) {   //stepper motor function for Y axis
   if(dirForY == 1) {
     switch(nextStepY) {
       case 1:


Improved mDNS logic.

Improved mDNS logic.

--- webservertask.ino
+++ webservertask.ino
@@ -776,22 +776,24 @@
   addr.addr = 0;
   ESP_LOGI( TAG, "Looking for: %s.local...", hostname );
   esp_err_t res = mdns_query_a( hostname, 2000, &addr );
-  if ( res == ESP_ERR_NOT_FOUND )
-  {
-    ESP_LOGI( TAG, "Setting up %s in mDNS.", hostname );
-    mdns_hostname_set( hostname );
-    mdns_service_add( NULL, "_http", "_tcp", 80, NULL, 0 );
-    mdns_service_instance_name_set( "_http", "_tcp", hostname );
-    mdns_txt_item_t serviceTxtData[3] = {
-      { (char *)"description", (char *)"5 Channel LED controller" },
-      { (char *)"source url", (char *)"https://github.com/CelliesProjects/aquacontrol32" },
-      { (char *)"name", (char *)"Aquacontrol32" }
-    };
-    //set txt data for service (will free and replace current data)
-    mdns_service_txt_set( "_http", "_tcp", serviceTxtData, 3 );
-    preferences.putString( "hostname", hostname );
-    return true;
+
+  if ( res != ESP_ERR_NOT_FOUND )
+  {
+    ESP_LOGI( TAG, "Hostname %s not set because %s is already present!", hostname, hostname );
+    return false;
   }
-  ESP_LOGI( TAG, "Host %s already present!", hostname );
-  return false;
+
+  ESP_LOGI( TAG, "Setting up %s in mDNS.", hostname );
+  mdns_hostname_set( hostname );
+  mdns_service_add( NULL, "_http", "_tcp", 80, NULL, 0 );
+  mdns_service_instance_name_set( "_http", "_tcp", hostname );
+  mdns_txt_item_t serviceTxtData[3] = {
+    { (char *)"description", (char *)"5 Channel LED controller" },
+    { (char *)"source url", (char *)"https://github.com/CelliesProjects/aquacontrol32" },
+    { (char *)"name", (char *)"Aquacontrol32" }
+  };
+  //set txt data for service (will free and replace current data)
+  mdns_service_txt_set( "_http", "_tcp", serviceTxtData, 3 );
+  preferences.putString( "hostname", hostname );
+  return true;
 }