Updated slider example.

Updated slider example.

--- examples/TGUI_Sample_Slider/TGUI_Sample_Slider.ino
+++ examples/TGUI_Sample_Slider/TGUI_Sample_Slider.ino
@@ -4,7 +4,6 @@
 // Widgets includes here:
 #include <Slider.h>
 #include <Display.h>
-

 // Architecture specific pins:
 // For MH-ET Live esp32 MiniKit (ESP32)
@@ -15,19 +14,19 @@
 // TGUI's objects declarations:
 Canvas_XPT2046 canvas = Canvas_XPT2046(TFT_PORTRAIT,BLACK,TFT_CS,TFT_DS,TS_CS);
 Slider blueSlider = Slider();
-Display blueDisp = Display(8);
+Display blueDisp = Display();
 Slider greenSlider = Slider();
-Display greenDisp = Display(8);
+Display greenDisp = Display();
 Slider redSlider = Slider();
-Display redDisp = Display(8);
+Display redDisp = Display();
+
+Display demoDisp = Display();

 //==================================
 // EVENT HANDLING ROUTINES
 //==================================
 void sliderEventHandler(Slider* sld){
-  Serial.print("Slider Pressed, CV = ");
-  Serial.println(sld->currentValue);
-  Serial.println("Calling Display's setNum");
+
   char buf[8];
   String value = String(sld->currentValue);
   value.toCharArray(buf,8);
@@ -46,14 +45,26 @@
     redDisp.setText(buf,false);
     redDisp.update();
   }
+
+  int red = map(redSlider.currentValue,0,100,0,255);
+  int green = map(greenSlider.currentValue,0,100,0,255);
+  int blue = map(blueSlider.currentValue,0,100,0,255);
+  int newColor = canvas.tft->color565(red,green,blue);
+
+  demoDisp.bgColor = newColor;
+  demoDisp.update();
 }

 //==================================
 // SETUP
 //==================================
-void guiSetup(){
+void guiSetup(){
+  demoDisp.setSize(80,40);
+  demoDisp.setColors(ILI9341_BLACK,ILI9341_WHITE,ILI9341_LIGHTGREY);
+  demoDisp.setText("",false);
+
   blueSlider.setDebounce(0);
-  blueSlider.setSize(40,240);
+  blueSlider.setSize(40,140);
   blueSlider.setColors(BLACK,BLUE,WHITE);
   blueSlider.setEventHandler(&sliderEventHandler);

@@ -62,7 +73,7 @@
   blueDisp.setText("",false);

   greenSlider.setDebounce(0);
-  greenSlider.setSize(40,240);
+  greenSlider.setSize(40,140);
   greenSlider.setColors(BLACK,GREEN,WHITE);
   greenSlider.setEventHandler(&sliderEventHandler);

@@ -71,7 +82,7 @@
   greenDisp.setText("",false);

   redSlider.setDebounce(0);
-  redSlider.setSize(40,240);
+  redSlider.setSize(40,140);
   redSlider.setColors(BLACK,RED,WHITE);
   redSlider.setEventHandler(&sliderEventHandler);

@@ -79,14 +90,16 @@
   redDisp.setColors(ILI9341_RED,ILI9341_WHITE,ILI9341_LIGHTGREY);
   redDisp.setText("",false);

-  canvas.add(&blueDisp, 20, 10);
-  canvas.add(&blueSlider, 20, 60);
+  canvas.add(&demoDisp, 80, 25);
+
+  canvas.add(&blueDisp, 20, 110);
+  canvas.add(&blueSlider, 20, 160);

-  canvas.add(&greenDisp, 100, 10);
-  canvas.add(&greenSlider, 100, 60);
+  canvas.add(&greenDisp, 100, 110);
+  canvas.add(&greenSlider, 100, 160);

-  canvas.add(&redDisp, 180, 10);
-  canvas.add(&redSlider, 180, 60);
+  canvas.add(&redDisp, 180, 110);
+  canvas.add(&redSlider, 180, 160);
 }

 void setup() {


test: update include_libraries test sketch

--- resources/test_sketches/include_libraries.ino
+++ resources/test_sketches/include_libraries.ino
@@ -1,13 +1,6 @@
-#include <Adafruit_MCP9808.h>
-#include <Adafruit_NeoPixel.h>
-#include <CapacitiveSensor.h>
 #include <EEPROM.h>
-#include <NewPing.h>
 #include <PinChangeInt.h>
-#include <SFE_MicroOLED.h>
-#include <SoftPWM.h>
 #include <SoftwareSerial.h>
-#include <SparkFunISL29125.h>
 #include <SPI.h>
 #include <Wire.h>


added L System scene

added L System scene

--- taurus.ino
+++ taurus.ino
@@ -37,6 +37,7 @@
 #define WIDTH 120
 #define HEIGHT 96
 #define IMG_SIZE 64
+#define PI 3.14159265

 // Coordinates to place bitmaps on the center of the screen
 #define BMP_X ((WIDTH / 2) - (IMG_SIZE / 2))
@@ -75,12 +76,13 @@
 		PARTY_WORDS,
 		FILL_LINES,
 		CIRCLES,
+		L_SYSTEM,
 		TOTAL
 };

 //TODO: Re-enable "verify code" in Arduino IDE

-Scene currentScene = CIRCLES;
+Scene currentScene = L_SYSTEM;
 Scene lastScene = -1;
 TVout TV;
 unsigned long startTime = 0;
@@ -186,6 +188,20 @@
 		}
 }

+void toCartesian(int x, int y, double degrees, int len, int *endX, int *endY) {
+		int o = (int)(sin((degrees * PI) / 180.0) * len);
+		int a = (int)(cos((degrees * PI) / 180.0) * len);
+
+		*endX = x + a;
+		*endY = y - o;
+}
+
+void drawLineAngle(int x, int y, double degrees, int len) {
+		int endX, endY;
+		toCartesian(x, y, degrees, len, &endX, &endY);
+		TV.draw_line(x, y, endX, endY, 1);
+}
+
 void setup() {
 		pinMode(LED_PIN, OUTPUT);
 		digitalWrite(LED_PIN, LOW);
@@ -859,6 +875,49 @@
 		checkSceneEnded(15);
 }

+int startLen = 40;
+int branches = 3;
+double branchAngle = 30.0;
+double angleOffset = 0.0;
+int rouletteDenominator = 1;
+int treeXOffset = 0;
+
+void lSystemRecursive(int x, int y, double angle, int len) {
+		if (len < 1) {
+				return;
+		}
+
+		drawLineAngle(x, y, angle, len);
+		int endX, endY;
+		toCartesian(x, y, angle, len, &endX, &endY);
+
+		double startAngle = angle + ((branchAngle * (branches - 1)) / 2.0) + angleOffset;
+		for (int i = 0; i < branches; i++) {
+				double a = startAngle - (i * branchAngle);
+				if (random(rouletteDenominator) != 0) {
+						lSystemRecursive(endX, endY, a, len / 2);
+				}
+		}
+}
+
+void drawLSystem() {
+		startLen = random(30, 50);
+		branches = random(3, 5);
+		branchAngle = random(25, 40);
+		angleOffset = -10 + random(20);
+		rouletteDenominator = random(3, 5);
+		treeXOffset = -20 + random(40);
+		lSystemRecursive(treeXOffset + (WIDTH / 2), HEIGHT - 1, 90.0 + angleOffset, startLen);
+}
+
+void lSystemScene() {
+		drawLSystem();
+		TV.delay(200);
+		TV.clear_screen();
+
+		checkSceneEnded(20);
+}
+
 void loop() {
 		bool changed = false;
 		if (currentScene != lastScene) {
@@ -957,6 +1016,9 @@
 				case CIRCLES:
 						circlesScene(changed);
 						break;
+				case L_SYSTEM:
+						lSystemScene();
+						break;
 				default:
 						TV.print("Invalid scene. ");
 						TV.delay(1000);


noch zu groß ...

noch zu groß ...

--- display_controller/display_controller.ino
+++ display_controller/display_controller.ino
@@ -1,196 +1,176 @@
 #include "Arduino.h"
 #include "ArduinoJson.h"
-#include "LedControl.h"
 #include "UTFT.h"
 #include "Wire.h"
 #include "../main_controller/ConsoleSetup.h"

-// Declare which fonts we will be using
-//extern uint8_t SmallFont[];
-extern uint8_t BigFont[];
-//extern uint8_t SevenSegNumFont[];
-
-// Belegung fr braun = 21
- #define SCLK2 17
- #define MOSI2 18
- #define CS2   21
- #define DC2   19
- #define RESET2 20
-
-// Belegung fr braun = 52
-#define SCLK1 44
-#define MOSI1 46
-#define CS1   52
-#define DC1   48
-#define RESET1 50
+// declare font
+extern uint8_t SmallFont[];

 //UTFT(Model, SDA, SCL, CS, RST[, RS]);
-UTFT lcd1(ST7735, MOSI1, SCLK1, CS1, RESET1, DC1);
-UTFT lcd2(ST7735, MOSI2, SCLK2, CS2, RESET2, DC2);
+UTFT lcd_right(ST7735, 2,1,0,4,3);
+UTFT lcd_left(ST7735, 10,9,8,12,11);

+bool write_in_progress = false;
 #define READ_BUFFER_SIZE 200
+char complete_message[READ_BUFFER_SIZE];
 char read_buffer[READ_BUFFER_SIZE];
 int read_buffer_offset = 0;
 int empty_buffer_size = 0;
-
-// constructor args are: DIN, CLK, CS, #CHIPS
-LedControl lc1 = LedControl(4, 3, 2, 1);
-LedControl lc2 = LedControl(7, 6, 5, 1);
+int complete_message_length = 0;

 void setupLCD( UTFT &lcd) {
 	lcd.InitLCD(PORTRAIT);
 	lcd.clrScr();
-	lcd.setColor(200, 255, 200); // red, green, blue
+	lcd.setColor(200, 255, 200);
 	lcd.setBackColor(0, 0, 0);
-	lcd.setFont(BigFont); // Allows 15 rows of 20 characters
+	lcd.setFont(SmallFont); // 20 rows; 15 characters
+	lcd.clrScr();
 }

 void setup() {
+
+	setupLCD( lcd_right );
+	setupLCD( lcd_left );
+
+	reset_input_buffer();
+	reset_message_buffer();
+	Wire.onReceive(receiveEvent);
 	Wire.begin(SLAVE_HW_ADDRESS);

-	setupLCD( lcd1 );
-	setupLCD( lcd2 );
-
-	lc1.shutdown(0, false); // turn off power saving, enables display
-	lc1.setIntensity(0, 15); // sets brightness (0~15 possible values)
-	lc1.clearDisplay(0); // clear screen
-	lc2.shutdown(0, false); // turn off power saving, enables display
-	lc2.setIntensity(0, 15); // sets brightness (0~15 possible values)
-	lc2.clearDisplay(0); // clear screen
 }

-void print_lc(LedControl *target, int val) {
-	if (target == NULL) {
-		return;
-	}
-	int digit = 0;
-	bool negative = (val >= 0) ? false : true;
-	val = abs(val);
-	while (val > 0 && digit < 8) {
-		int last_digit = val % 10;
-		val = val / 10;
-		target->setDigit(0, digit, (byte) last_digit, false);
-		digit++;
-	}
-	if (negative) {
-		target->setChar(0, digit, '-', false);
-		digit++;
-	}
-	while (digit < 8) {
-		target->setChar(0, digit, ' ', false);
-		digit++;
-	}
+void print_lcd( UTFT &lcd, int line, const char *str) {
+	lcd.print( str, LEFT, line*10);
 }

-void print_lc_string(LedControl *target, const char *str) {
-	int len = strlen(str);
-	int digit = 0;
-	while (digit < 8 && len > 0) {
-		target->setChar(0, digit, str[len - 1], false);
-		len--;
-		digit++;
-	}
+void print_lcd( UTFT &lcd, int line, int number) {
+	char buf[20];
+	sprintf( buf, "%d", number);
+	print_lcd( lcd, line, buf);
 }

-void print_lcd1( UTFT &lcd, char *str) {
-	lcd.print(str, LEFT, 0);
-}
-
-void reset_serial_buffer() {
+void reset_input_buffer() {
 	memset(read_buffer, 0, READ_BUFFER_SIZE);
 	read_buffer_offset = 0;
 }

+void reset_message_buffer() {
+	memset(complete_message, 0, READ_BUFFER_SIZE);
+	complete_message_length = 0;
+}
+
 void dieError(int number) {
-	char buf[10];
-	sprintf(buf, "%8d", number);
-	print_lc_string(&lc1, "       E");
-	print_lc_string(&lc2, buf);
-// keep hanging around
+	print_lcd( lcd_left, 0, "Error");
+	print_lcd( lcd_left, 1, number);
+	// stay here
 	while (true) {
 	};
 }

-/**
- * returns true if buffer contains exactly on line including the "\n"
- * otherwise just stores what is on the serial port and returns false
- */
 bool check_message() {
-// always read one full message
-	if (Wire.available()) {
-		char inByte = 0;
-		while (1) {
-			// just wait for the rest to show up ..
-			while (Wire.available() == 0)
-				;
-			inByte = Wire.read();
-			if (inByte == '\n') {
-				read_buffer[read_buffer_offset] = 0;
-				return true;
-			}
-			if (read_buffer_offset < (READ_BUFFER_SIZE - 1)) {
-				read_buffer[read_buffer_offset] = inByte;
-				read_buffer_offset++;
-			} else {
-				dieError(1);
-			}
-		}
+	if( write_in_progress )
+		return false;
+	if( complete_message[complete_message_length]=='\n' ) {
+		complete_message_length--;
+		complete_message[complete_message_length] = 0;
+		return true;
 	}
 	return false;
 }

+// read the data into the buffer,
+// if the current input buffer is not full
+void receiveEvent(int how_many) {
+	write_in_progress = true;
+	while( Wire.available()>0 )
+	{
+		char inByte = Wire.read();
+		// just continue and dump the byte if
+		// we already have a complete buffer and
+		// wait for the app to finish working on the
+		// last one ...
+		if( read_buffer_offset>0 &&
+			read_buffer[read_buffer_offset-1] == '\n' )
+		{
+			continue;
+		}
+		// otherwise store the current byte
+		if (read_buffer_offset < READ_BUFFER_SIZE) {
+			read_buffer_offset++;
+			read_buffer[read_buffer_offset] = inByte;
+		} else {
+			print_lcd( lcd_right, 0, read_buffer);
+			dieError(read_buffer_offset);
+		}
+		if ( inByte == '\n' )
+				break;
+	}
+	// if there is a complete message and the
+	// app says it is done with working on the
+	// last message by setting complete_message[0] to 0
+	// we copy the current message over and reset
+	// the input buffer
+	if( complete_message[0]==0 &&
+		read_buffer[read_buffer_offset] == '\n')
+	{
+		read_buffer[read_buffer_offset+1] = 0;
+		strncpy( complete_message, read_buffer, READ_BUFFER_SIZE);
+		reset_input_buffer();
+		complete_message_length = strlen( complete_message )-1;
+	}
+}
+
 void wait_for_handshake() {
-	reset_serial_buffer();
 	bool dot_on = true;
 	while (true) {
 		if (check_message() == false) {
 			if (dot_on == true) {
-				print_lc_string(&lc1, "        ");
-				print_lc_string(&lc2, "........");
+				print_lcd( lcd_left, 2, ".");
+				print_lcd( lcd_right, 2, " ");
 			} else {
-				print_lc_string(&lc1, "........");
-				print_lc_string(&lc2, "        ");
+				print_lcd( lcd_right, 2, ".");
+				print_lcd( lcd_left, 2, " ");
 			}
 			dot_on = !dot_on;
-			delay(1000);
+			delay(900);
 		} else {
-			StaticJsonBuffer < READ_BUFFER_SIZE > readBuffer;
-			JsonObject& rj = readBuffer.parseObject(read_buffer);
+			print_lcd( lcd_left, 2, " ");
+			print_lcd( lcd_right, 2, " ");
+			StaticJsonBuffer <READ_BUFFER_SIZE> readBuffer;
+			JsonObject& rj = readBuffer.parseObject(complete_message);
 			// the only way to get this thing going
 			if (rj.success() && rj["start"] == 2016) {
-				print_lc_string(&lc1, "       -");
-				print_lc_string(&lc2, "       -");
-				reset_serial_buffer();
+				print_lcd( lcd_left, 1, " OK ");
+				reset_message_buffer();
 				return;
 			}
-			reset_serial_buffer();
+			reset_message_buffer();
 		}
 	}
 }

 void check_for_command() {
 	if (check_message() == true) {
-		StaticJsonBuffer < READ_BUFFER_SIZE > readBuffer;
-		JsonObject& rj = readBuffer.parseObject(read_buffer);
-
+		StaticJsonBuffer <READ_BUFFER_SIZE> readBuffer;
+		JsonObject& rj = readBuffer.parseObject(complete_message);
+		reset_message_buffer();
 		if (!rj.success()) {
-			print_lc_string(&lc1, "E");
-			print_lc(&lc2, 3);
+			dieError(3);
 		} else {
-			char buff[20];
+/*			char buff[20];
 			memset(buff, 0, 20);
 			int speed = rj["speed"];
-			print_lc(&lc1, speed);
+			print_lc( lc_top, speed);
 			int height = rj["height"];
-			print_lc(&lc2, height);
-//			snprintf( buff, 15, "%8d", height);
-//			print_lcd1(buff);
+			print_lc( lc_bottom, height);*/
 		}
-		reset_serial_buffer();
 	}
 }

 void loop() {
 // main loop
-	check_for_command();
+	wait_for_handshake();
+	while ( 1 )
+		check_for_command();
 }


final changes

final changes

--- SimpleClientDHTSSL.ino
+++ SimpleClientDHTSSL.ino
@@ -1,4 +1,4 @@
-#define MOONBASE_BOARD
+//#define MOONBASE_BOARD
 /* WeMos DHT Server
  *
  * Connect to WiFi and respond to http requests with temperature and humidity
@@ -25,12 +25,21 @@
 #define DHTPIN D4       // DHT Shield uses pin D4
 #endif

-//const char* DEVNAME = "VCW100” ; const char* ISSUEID  = “ZGKL01”; const char* ssid = ""; const char* password = “”;
-
+
+//const char* DEVNAME = "VCW100” ; const char* ISSUEID  = ZGKL01“”; const char* ssid = ""; const char* password = “”;
+extern const char* DEVNAME; extern const char* ISSUEID; extern const char* ssid; extern const char* password;
+
+void httpsRequest(float temp, float humid
+#ifdef MOONBASE_BOARD
+, float pressure
+#endif
+);

 IPAddress server(120,138,27,109);

 #ifdef MOONBASE_BOARD
+float pressure;         // Raw float values from the sensor
+char str_pressure[10];  // Rounded sensor values and as strings
 #else
 // Initialize DHT sensor
 // Note that older versions of this library took an optional third parameter to
@@ -64,7 +73,7 @@
 #ifdef MOONBASE_BOARD
     humidity = smeHumidity.readHumidity();
     temperature = smeHumidity.readTemperature();
-    pressure = smePressure.readTemperature();
+    pressure = smePressure.readPressure();
 #else
     // Reading temperature and humidity takes about 250 milliseconds!
     // Sensor readings may also be up to 2 seconds 'old' (it's a very slow sensor)
@@ -85,7 +94,8 @@
 #ifdef MOONBASE_BOARD
     dtostrf(pressure, 1, 2, str_pressure);
     Serial.print("Pressure: ");
-    Serial.print(str_Pressure);
+    Serial.print(str_pressure);
+    Serial.print(" mBAR\t");
 #endif
     Serial.print("Humidity: ");
     Serial.print(str_humidity);


windmill_sim

windmill_sim

add 13 pin to a led.

--- trab1/Arduino/windmill_sim/windmill_sim.ino
+++ trab1/Arduino/windmill_sim/windmill_sim.ino
@@ -13,6 +13,7 @@
 const int buttonPin=2;     //Digital Pin 2.
 const int buttonPin1=3;    //Digital Pin 3.
 const int ledPin=4;        //Digital Pin 4.
+const int ledPin1=13;      //Digital Pin 13.
 const int potPin=A0;       //Analog Pin 0.

 //Variables
@@ -30,13 +31,14 @@

 //clear error buiffer
 void clean_errorbuffer(){
-  memeset(errorbuffer,0,sizeof(errorbuffer));
+  memset(errorbuffer,0,sizeof(errorbuffer));
 }

 //initialization of PinMode
 int init_pinMode(){
   pinMode(buttonPin,INPUT);
   pinMode(buttonPin1,INPUT);
+  pinMode(ledPin,OUTPUT);
   pinMode(ledPin,OUTPUT);

   return 0;
@@ -75,7 +77,7 @@
   buttonState=digitalRead(buttonPin);
   buttonState1=digitalRead(buttonPin1);
   sensorValue=analogRead(potPin);
-
+
   //read UART COM
   if(Serial.available()>0){
     Serial.readBytesUntil('/0',buffer,10);
@@ -114,13 +116,17 @@
     Serial.print("error: ");
     Serial.println(errorbuffer);
     clean_buffer();
+    digitalWrite(ledPin1,LOW);
   }

   if(buttonState==HIGH){
     strcpy(errorbuffer,"error-1");
+    digitalWrite(ledPin1,HIGH);
   }

-  if(buttonState1==HIGH)
+  if(buttonState1==HIGH){
     clean_errorbuffer();
+    digitalWrite(ledPin1,LOW);
+  }
 }


Update ds18b20.ino

Update ds18b20.ino

--- dragino/ds18b20.ino
+++ dragino/ds18b20.ino
@@ -27,7 +27,7 @@
 char message_buff[100];
 char message_buff2[100];
 char message[256];
-String id_sensor = "test4";
+String id_sensor = "prueba5";

 float t2;
@@ -43,7 +43,7 @@
   sensors.begin();
   //sensors.setResolution(probe01, 10);

-  mqtt.subscribe("test/temp", someEvent);
+  mqtt.subscribe("rr/temp", someEvent);

 }
@@ -57,7 +57,15 @@

  tempC2 = sensors.getTempCByIndex(0),4;
  //tempC2 = sensors.getTempC(probe01);
-   if (millis() > (time + 20000)) {
+
+ if (isnan(t) || isnan(h)) {
+    Serial.println("Failed to from DHT");
+  }
+
+  else {
+
+
+   if (millis() > (time + 5000)) {
        time = millis();

  String pubString = "" + String(t) + "," + String(tempC2) + "," + String(h) + "," + id_sensor + "";
@@ -69,6 +77,7 @@

   mqtt.monitor();
    }
+  }

 }


Add hostname

Add hostname

--- Sattrack.ino
+++ Sattrack.ino
@@ -31,6 +31,7 @@
 void setup() {

   initConfig();
+  WiFi.hostname(config->host);

   strip.Begin();
   LedStrip.Begin(&strip);


test use case for pololu leds

test use case for pololu leds

--- engine-room/engine_arduino/engine_arduino.ino
+++ engine-room/engine_arduino/engine_arduino.ino
@@ -1,6 +1,7 @@
 #include <PololuLedStrip.h>

-
+PololuLedStrip<2> leds;
+rgb_color colors[4];

 void setup()
 {
@@ -16,14 +17,49 @@
   digitalWrite(LED_BUILTIN, LOW);
   delay(2000);

+  colors[0] = getRed();
+  colors[1] = getBlue();
+  colors[2] = getGreen();
+  colors[3] = getYellow();

+  leds.write(colors, 4);

   Serial.println('red'); // m is char*
 }

-void red()
+rgb_color getRed()
 {
-
+  rgb_color color;
+  color.red = 255;
+  color.blue = 0;
+  color.green = 0;
+  return color;
 }

+rgb_color getBlue()
+{
+  rgb_color color;
+  color.red = 0;
+  color.blue = 255;
+  color.green = 0;
+  return color;
+}

+rgb_color getGreen()
+{
+  rgb_color color;
+  color.red = 0;
+  color.blue = 0;
+  color.green = 255;
+  return color;
+}
+
+rgb_color getYellow()
+{
+  rgb_color color;
+  color.red = 255;
+  color.blue = 0;
+  color.green = 255;
+  return color;
+}
+


refactor

refactor

--- esp8266_160220_BYOP.ino
+++ esp8266_160220_BYOP.ino
@@ -89,21 +89,22 @@
 bool proc_hello(String csvline)
 {
   String cmdstr = extractCsvRow(csvline, 0);
-  String serNo = extractCsvRow(csvline, 1);
-  String nickName = extractCsvRow(csvline, 2);
+  String serno = extractCsvRow(csvline, 1);
+  String nickname = extractCsvRow(csvline, 2);

-  if (nickName.length() == 0) {
+  if (nickname.length() == 0) {
     return false;
   }

   debug_outputDebugString("proc_hello", "line89 > " + csvline);

-  s_owner.nickName = nickName;
+  s_owner.nickName = nickname;
+  s_owner.serialNo = serno;

-#if 1
-  Serial.println("Your S/N:" + serNo);
-  Serial.println("Your name:" + nickName);
-#endif
+  debug_outputDebugString("proc_hello", "line105 > [S/N]" + serno);
+  debug_outputDebugString("proc_hello", "line106 > [name]" + nickname);
+
+  // TODO: 0m > display "Hello,[nickName]" to LCD

   return true;
 }


add Moving Average method

add Moving Average method

--- Arduino/AlphaChairArduino/AlphaChairArduino.ino
+++ Arduino/AlphaChairArduino/AlphaChairArduino.ino
@@ -15,18 +15,12 @@

 Thread fsrThread = Thread(); // For measuring Pressure data in other thread

-int countFSRThread = 0;
 int count_0 = 0;
 int count_1 = 0;
 int count_2 = 0;
-int count_3 = 0;
-
-int initPosture_0;
-int initPosture_1;
-int initPosture_2;
-int initPosture_3;
-
-float percentage = 0.25;
+int count_3 = 0;
+int count_4 = 0;
+int count_5 = 0;

 //  Mosfet channel
 int MOSFET_C1 = 10;
@@ -83,13 +77,7 @@
   }else if(response.equals(FSR_OFF)){
     Serial.println(response);
     fsrThread.enabled = false;
-
-    initPosture_0 = 0;
-    initPosture_1 = 1;
-    initPosture_2 = 2;
-    initPosture_3 = 3;
-
-    countFSRThread = 0;
+
     count_0 = 0;
     count_1 = 0;
     count_2 = 0;
@@ -113,39 +101,90 @@

 // Runnable for fsrThread
 void readPressure(){
-  countFSRThread++;
+
   int frontRight = analogRead(PRESSURE_0)*5;
   int frontLeft = analogRead(PRESSURE_1)*5;
   int backRight = analogRead(PRESSURE_2)*5;
   int backLeft = analogRead(PRESSURE_3)*5;
-  Serial.println("0 : "+ String(frontRight));
-  Serial.println("1 : "+ String(frontLeft));
-  Serial.println("2 : "+ String(backRight));
-  Serial.println("3 : "+ String(backLeft));

-  if(countFSRThread <= 5){
-    initPosture_0 = frontRight;
-    initPosture_1 = frontLeft;
-    initPosture_2 = backRight;
-    initPosture_3 = backLeft;
-  }else{
-    // 자세 측정 및 알람
-    Serial.println("your initial post : "+String(initPosture_0));
+  Serial.println("frontRight : "+ String(frontRight));
+  Serial.println("frontLeft : "+ String(frontLeft));
+  Serial.println("backRight : "+ String(backRight));
+  Serial.println("backLeft : "+ String(backLeft));
+
     // send 'posture msg' to android
-    if(frontRight>initPosture_0*(percentage+1)){
-      count_0++;
-      if(count_0 >= 5){
-        BTSerial.println("fr");
-        count_0 = 0;
-      }
-    }else{
-      count_0 = 0;
-    }
-  }
+    sendPostureMsg(frontRight,frontLeft,backRight,backLeft);
 }

 void readTmp(){
     digitalWrite(MOSFET_C1,HIGH);
     Serial.println("temperature on");
 }
+void sendPostureMsg(int frontRight,int frontLeft, int backRight, int backLeft){

+    if(frontRight>=10 || frontLeft>=10 || backRight>=10 || backLeft>=10){
+      // 왼쪽으로 기울임 : 0
+    if(frontRight<100 && backRight<100){
+        count_0++;
+        if(count_0 >= 5){
+          BTSerial.println("몸을 왼쪽으로 기울이지 마세요!");
+          count_0 = 0;
+        }
+
+      // 다리꼬기 : 오른쪽 다리 올리기 : 1
+      }else if(frontRight <100){
+        count_1++;
+        if(count_1 >= 5){
+          BTSerial.println("오른쪽 다리를 꼬지마세요!");
+          count_1 = 0;
+        }
+      }else{
+          count_0 = 0;
+          count_1 = 0;
+      }
+
+    // 오른쪽으로 기울임 : 2
+    if(frontLeft<100 && backLeft<100){
+        count_2++;
+        if(count_2 >= 5){
+          BTSerial.println("몸을 오른쪽으로 기울이지 마세요!");
+          count_2 = 0;
+        }
+
+      // 다리꼬기 : 왼쪽 다리 올리기 : 3
+      }else if(frontLeft <100){
+        count_3++;
+        if(count_3 >= 5){
+          BTSerial.println("왼쪽다리를 꼬지마세요!");
+          count_3 = 0;
+        }
+      }else{
+          count_2 = 0;
+          count_3 = 0;
+      }
+
+    // 발끝 들기 : 4
+    if(frontRight<100  && frontLeft<100){
+        count_4++;
+        if(count_4 >= 5){
+          BTSerial.println("발끝을 들지 마세요!");
+          count_4 = 0;
+        }
+    }else{
+        count_4 = 0;
+    }
+
+    // 엎드리기 && 눕기 : 5
+    if(backRight<100  && backLeft<100){
+        count_5++;
+        if(count_5 >= 5){
+          BTSerial.println("엎드리기거나 눕지 마세요!");
+          count_5 = 0;
+        }
+    }else{
+        count_5 = 0;
+    }
+  }
+}
+
+


Update light_sensor_visualization.ino

Update light_sensor_visualization.ino

--- Arduino/examples/light_sensor_visualization.ino
+++ Arduino/examples/light_sensor_visualization.ino
@@ -7,7 +7,7 @@

 uint16_t xpos, ypos, drawHeight;

-//draw graph : using A0 analog noise
+//draw graph : using light sensor values
 void setup()
 {
 	sns.begin(5);


Add a delay after ESP-Now init which seems to make sends more reliable

--- ESP-Now/espnow-sensorNode/espnow-sensorNode.ino
+++ ESP-Now/espnow-sensorNode/espnow-sensorNode.ino
@@ -57,6 +57,8 @@
     ESP.restart();
   }

+  delay(1); // This delay seems to make it work more reliably???
+
   esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);
   esp_now_add_peer(remoteMac, ESP_NOW_ROLE_SLAVE, WIFI_CHANNEL, NULL, 0);


video capture end

video capture end

--- d_BacpacCommands.ino
+++ d_BacpacCommands.ino
@@ -93,6 +93,13 @@
     buf[0] = 0x27; buf[1] = 0;
     SendBufToBacpac();
     if (isMaster) {
+      if (heartBeatIsOn) { // send to slaves
+        Serial.print("TD");
+        for (int i = 3; i < TD_BUFFER_SIZE; i++) {
+          printHex(td[i], true);
+        }
+        Serial.println("");
+      }
       heartBeatIsOn = true;
     }
     break;
@@ -203,15 +210,13 @@
       Serial.println("");
       Serial.flush();
     }
-    buf[0] = 0x83; buf[1] = 'S'; buf[2] = 'R';
-    if (RECV(3) == 0 && td[TD_MODE] != MODE_TIMELAPSE) {
-      // video capture end
-      buf[3] = 3; // notify video saved
-    } else {
-      buf[3] = RECV(3);
-    }
-    delay(200); // a short delay is necessary
-    SendBufToBacpac();
+    buf[0] = 0x83; buf[1] = 'S'; buf[2] = 'R'; buf[3] = RECV(3);
+    delay(200);
+    SendBufToBacpac();
+    if (buf[3] == 0 && td[TD_MODE] != MODE_TIMELAPSE) {
+      queueIn("SR3"); // notify video saved
+      delay(2000);
+    }
     if (td[TD_MODE] == MODE_TIMELAPSE) {
       switch (RECV(3)) {
       case 1:


Clean-up.

Clean-up.

--- examples/DemoArcRPM/DemoArcRPM.ino
+++ examples/DemoArcRPM/DemoArcRPM.ino
@@ -65,11 +65,6 @@
 uint32_t AnimationStart;
 uint32_t LastRPMUpdate, LastLEDUpdate, LastAnimationUpdate, LastRPMLogUpdate,
 LastPowerUpdate, LastPowerLogUpdate, LastBrightnessUpdate, LastSerialUpdate;
-
-uint64_t LastPowerSum = 0;
-uint32_t LastAveragePower = 0;
-uint16_t PowerSumCounter = 0;
-

 void SetupDemo()
 {
@@ -88,6 +83,7 @@
 	LastBrightnessUpdate = StartTime;
 	LastSerialUpdate = StartTime;
 }
+
 void Demo(uint32_t now)
 {
 	if (now - LastAnimationUpdate > ANIMATION_UPDATE_INTERVAL - 1)
@@ -163,11 +159,6 @@
 	SetupDemo();
 }

-cHSV GetAlertBrightness()
-{
-	return { HIGH_COLOUR.h, HIGH_COLOUR.s, max(GlobalBrightness, ALERT_MIN_BRIGHTNESS) };
-}
-
 bool SetupRPMDriver()
 {


Fix parameter

Fix parameter

--- examples/LightScale/LightScale.ino
+++ examples/LightScale/LightScale.ino
@@ -17,7 +17,7 @@
   int light = analogRead(A0);
   Serial.println(light);

-  int scale = map(light, 200, 1000, 0, 2);
+  int scale = map(light, 400, 1000, 0, 2);
   //Serial.println(scale);

   if (scale==0) {
@@ -26,13 +26,13 @@
     digitalWrite(RED, LOW);
   }

-  if (scale<1) {
+  if (scale==1) {
     digitalWrite(YELLOW, HIGH);
   } else {
     digitalWrite(YELLOW, LOW);
   }

-  if (scale<2) {
+  if (scale==2) {
     digitalWrite(GREEN, HIGH);
   } else {
     digitalWrite(GREEN, LOW);
@@ -40,4 +40,4 @@

   delay(200);
-}+}