Delete ssd1306_128x64_spi.ino

Delete ssd1306_128x64_spi.ino

--- ssd1306_128x64_spi.ino
+++ ssd1306_128x64_spi.ino
@@ -1,362 +0,0 @@
-
-/*********************************************************************
-This is an example for our Monochrome OLEDs based on SSD1306 drivers
-
-  Pick one up today in the adafruit shop!
-  ------> http://www.adafruit.com/category/63_98
-
-This example is for a 128x64 size display using SPI to communicate
-4 or 5 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, check license.txt for more information
-All text above, and the splash screen must be included in any redistribution
-*********************************************************************/
-
-#include "Adafruit_GFX.h"
-#include "Adafruit_SSD1306.h"
-
-/* Uncomment this block to use hardware SPI
-// If using software SPI (the default case):
-#define OLED_MOSI   D0
-#define OLED_CLK    D1
-#define OLED_DC     D2
-#define OLED_CS     D3
-#define OLED_RESET  D4
-Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
-*/
-
-// use hardware SPI
-#define OLED_DC     D3
-#define OLED_CS     D4
-#define OLED_RESET  D5
-Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
-
-
-#define NUMFLAKES 10
-#define XPOS 0
-#define YPOS 1
-#define DELTAY 2
-
-
-#define LOGO16_GLCD_HEIGHT 16
-#define LOGO16_GLCD_WIDTH  16
-
-static const unsigned char logo16_glcd_bmp[] =
-{ 0B00000000, 0B11000000,
-  0B00000001, 0B11000000,
-  0B00000001, 0B11000000,
-  0B00000011, 0B11100000,
-  0B11110011, 0B11100000,
-  0B11111110, 0B11111000,
-  0B01111110, 0B11111111,
-  0B00110011, 0B10011111,
-  0B00011111, 0B11111100,
-  0B00001101, 0B01110000,
-  0B00011011, 0B10100000,
-  0B00111111, 0B11100000,
-  0B00111111, 0B11110000,
-  0B01111100, 0B11110000,
-  0B01110000, 0B01110000,
-  0B00000000, 0B00110000 };
-
-#if (SSD1306_LCDHEIGHT != 64)
-#error("Height incorrect, please fix Adafruit_SSD1306.h!");
-#endif
-
-void setup()   {
-  Serial.begin(9600);
-
-  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
-  display.begin(SSD1306_SWITCHCAPVCC);
-  // init done
-
-  display.display(); // show splashscreen
-  delay(2000);
-  display.clearDisplay();   // clears the screen and buffer
-
-  // draw a single pixel
-  display.drawPixel(10, 10, WHITE);
-  display.display();
-  delay(2000);
-  display.clearDisplay();
-
-  // draw many lines
-  testdrawline();
-  display.display();
-  delay(2000);
-  display.clearDisplay();
-
-  // draw rectangles
-  testdrawrect();
-  display.display();
-  delay(2000);
-  display.clearDisplay();
-
-  // draw multiple rectangles
-  testfillrect();
-  display.display();
-  delay(2000);
-  display.clearDisplay();
-
-  // draw mulitple circles
-  testdrawcircle();
-  display.display();
-  delay(2000);
-  display.clearDisplay();
-
-  // draw a white circle, 10 pixel radius
-  display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
-  display.display();
-  delay(2000);
-  display.clearDisplay();
-
-  testdrawroundrect();
-  delay(2000);
-  display.clearDisplay();
-
-  testfillroundrect();
-  delay(2000);
-  display.clearDisplay();
-
-  testdrawtriangle();
-  delay(2000);
-  display.clearDisplay();
-
-  testfilltriangle();
-  delay(2000);
-  display.clearDisplay();
-
-  // draw the first ~12 characters in the font
-  testdrawchar();
-  display.display();
-  delay(2000);
-  display.clearDisplay();
-
-  // draw scrolling text
-  testscrolltext();
-  delay(2000);
-  display.clearDisplay();
-
-  // text display tests
-  display.setTextSize(1);
-  display.setTextColor(WHITE);
-  display.setCursor(0,0);
-  display.println("Hello, world!");
-  display.setTextColor(BLACK, WHITE); // 'inverted' text
-  display.println(3.141592);
-  display.setTextSize(2);
-  display.setTextColor(WHITE);
-  display.print("0x"); display.println(0xDEADBEEF, HEX);
-  display.display();
-  delay(2000);
-
-  // miniature bitmap display
-  display.clearDisplay();
-  display.drawBitmap(30, 16,  logo16_glcd_bmp, 16, 16, 1);
-  display.display();
-
-  // invert the display
-  display.invertDisplay(true);
-  delay(1000);
-  display.invertDisplay(false);
-  delay(1000);
-
-  // draw a bitmap icon and 'animate' movement
-  testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
-}
-
-
-void loop() {
-
-}
-
-
-void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
-  uint8_t icons[NUMFLAKES][3];
-
-  // initialize
-  for (uint8_t f=0; f< NUMFLAKES; f++) {
-    icons[f][XPOS] = random(display.width());
-    icons[f][YPOS] = 0;
-    icons[f][DELTAY] = random(5) + 1;
-
-    Serial.print("x: ");
-    Serial.print(icons[f][XPOS], DEC);
-    Serial.print(" y: ");
-    Serial.print(icons[f][YPOS], DEC);
-    Serial.print(" dy: ");
-    Serial.println(icons[f][DELTAY], DEC);
-  }
-
-  while (1) {
-    // draw each icon
-    for (uint8_t f=0; f< NUMFLAKES; f++) {
-      display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE);
-    }
-    display.display();
-    delay(200);
-
-    // then erase it + move it
-    for (uint8_t f=0; f< NUMFLAKES; f++) {
-      display.drawBitmap(icons[f][XPOS], icons[f][YPOS],  logo16_glcd_bmp, w, h, BLACK);
-      // move it
-      icons[f][YPOS] += icons[f][DELTAY];
-      // if its gone, reinit
-      if (icons[f][YPOS] > display.height()) {
-	icons[f][XPOS] = random(display.width());
-	icons[f][YPOS] = 0;
-	icons[f][DELTAY] = random(5) + 1;
-      }
-    }
-   }
-}
-
-
-void testdrawchar(void) {
-  display.setTextSize(1);
-  display.setTextColor(WHITE);
-  display.setCursor(0,0);
-
-  for (uint8_t i=0; i < 168; i++) {
-    if (i == '\n') continue;
-    display.write(i);
-    if ((i > 0) && (i % 21 == 0))
-      display.println();
-  }
-  display.display();
-}
-
-void testdrawcircle(void) {
-  for (int16_t i=0; i<display.height(); i+=2) {
-    display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
-    display.display();
-  }
-}
-
-void testfillrect(void) {
-  uint8_t color = 1;
-  for (int16_t i=0; i<display.height()/2; i+=3) {
-    // alternate colors
-    display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
-    display.display();
-    color++;
-  }
-}
-
-void testdrawtriangle(void) {
-  for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
-    display.drawTriangle(display.width()/2, display.height()/2-i,
-                     display.width()/2-i, display.height()/2+i,
-                     display.width()/2+i, display.height()/2+i, WHITE);
-    display.display();
-  }
-}
-
-void testfilltriangle(void) {
-  uint8_t color = WHITE;
-  for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
-    display.fillTriangle(display.width()/2, display.height()/2-i,
-                     display.width()/2-i, display.height()/2+i,
-                     display.width()/2+i, display.height()/2+i, WHITE);
-    if (color == WHITE) color = BLACK;
-    else color = WHITE;
-    display.display();
-  }
-}
-
-void testdrawroundrect(void) {
-  for (int16_t i=0; i<display.height()/2-2; i+=2) {
-    display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
-    display.display();
-  }
-}
-
-void testfillroundrect(void) {
-  uint8_t color = WHITE;
-  for (int16_t i=0; i<display.height()/2-2; i+=2) {
-    display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
-    if (color == WHITE) color = BLACK;
-    else color = WHITE;
-    display.display();
-  }
-}
-
-void testdrawrect(void) {
-  for (int16_t i=0; i<display.height()/2; i+=2) {
-    display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
-    display.display();
-  }
-}
-
-void testdrawline() {
-  for (int16_t i=0; i<display.width(); i+=4) {
-    display.drawLine(0, 0, i, display.height()-1, WHITE);
-    display.display();
-  }
-  for (int16_t i=0; i<display.height(); i+=4) {
-    display.drawLine(0, 0, display.width()-1, i, WHITE);
-    display.display();
-  }
-  delay(250);
-
-  display.clearDisplay();
-  for (int16_t i=0; i<display.width(); i+=4) {
-    display.drawLine(0, display.height()-1, i, 0, WHITE);
-    display.display();
-  }
-  for (int16_t i=display.height()-1; i>=0; i-=4) {
-    display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
-    display.display();
-  }
-  delay(250);
-
-  display.clearDisplay();
-  for (int16_t i=display.width()-1; i>=0; i-=4) {
-    display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
-    display.display();
-  }
-  for (int16_t i=display.height()-1; i>=0; i-=4) {
-    display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
-    display.display();
-  }
-  delay(250);
-
-  display.clearDisplay();
-  for (int16_t i=0; i<display.height(); i+=4) {
-    display.drawLine(display.width()-1, 0, 0, i, WHITE);
-    display.display();
-  }
-  for (int16_t i=0; i<display.width(); i+=4) {
-    display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
-    display.display();
-  }
-  delay(250);
-}
-
-void testscrolltext(void) {
-  display.setTextSize(2);
-  display.setTextColor(WHITE);
-  display.setCursor(10,0);
-  display.clearDisplay();
-  display.println("scroll");
-  display.display();
-
-  display.startscrollright(0x00, 0x0F);
-  delay(2000);
-  display.stopscroll();
-  delay(1000);
-  display.startscrollleft(0x00, 0x0F);
-  delay(2000);
-  display.stopscroll();
-  delay(1000);
-  display.startscrolldiagright(0x00, 0x07);
-  delay(2000);
-  display.startscrolldiagleft(0x00, 0x07);
-  delay(2000);
-  display.stopscroll();
-}


Refactoring for autofocus pin (configuration)

--- ANI_CameraRemote/ANI_CameraRemote.ino
+++ ANI_CameraRemote/ANI_CameraRemote.ino
@@ -17,6 +17,7 @@
   20180511 M5Stack: WiFi OFF by default, config menu, C button as value accelerator
   20180528 Setting for trigger duration
   20180529 Preparatory work for timetable
+  20180601 Preparatory work for autofocus pin
   --------------------------------------------------*/
 #ifdef ESP32
 #include <M5Stack.h>
@@ -38,6 +39,7 @@
 const int screenSaverTime = 60;                    // M5Stack: Switch off screen after 60 seconds of inactivity

 const int triggerPin = 2;                          // GPIO2 as trigger output
+const int autofocusPin = 0;                        // GPIO0 as autofocus pin, -1 = deactivate autofocus start via pin
 const int startPin = 5;                            // GPIO5 as start input for timelapse, -1 = deactivate input pin processing

 // Timelapse Defaults
@@ -80,9 +82,9 @@
 // Only loadable via GET parameters, not in UI
 // URL Example:
 // 192.168.4.1/?timeTable=w18000,50000x5,20000x10,d2,30,40,50
-// This waits 18000 seconds, triggers the shutter 50000 times every 5 seconds, then
-// triggers the shutter 20000 times every 10 seconds, sets a trigger ON duration of 2 seconds,
-// triggers the shutter after 30 seconds, then after 40 seconds and finally after 50 seconds
+// This waits 18000 seconds, triggers the shutter 50000 times with an interval of 5 seconds, then
+// triggers the shutter 20000 times with an interval of 10 seconds, sets a trigger ON duration of 2 seconds,
+// triggers the shutter after 30 seconds, then after 40 more seconds and finally after 50 more seconds
 String timeTable = "";

 unsigned long delayToStart = default_delayToStart;
@@ -130,6 +132,8 @@
   displaySetup();

   pinMode(triggerPin, OUTPUT); // setup GPIO as camera trigger
+  if (autofocusPin > -1)
+    pinMode(autofocusPin, OUTPUT); // setup GPIO for autofocus start function
   trigger(OFF);
   if (startPin > -1)
     pinMode(startPin, INPUT_PULLUP); // Setup GPIO input for start signal
@@ -299,45 +303,43 @@
         }
     }
   }
-  if ((timeTable != "" ) && (currentExecMode == TIMELAPSESTOP)) // Next element of timetable
-    processTimeTable();
 }

 void processTimeTable()
 {
-	/*
-  delayToStart = 0; // Reset wait (delay) timer anyway
-  numberOfShots = 1; // At least one shot
-  trigger(OFF);
-  int idx = timeTable.indexOf(","); // Find end of next element
-  while (idx >= 1)
-  {
-    String element = timeTable.substring(0, idx);
-    if (element.length() >= 1) // something is there
-    {
-      int xPosition = element.indexOf("X");
-      timeTable = timeTable.substring(idx + 1, timeTable.length()); // remove element from timetable
-      if (element[0] == 'W') // set wait (=Delay) time
-        delayToStart = atol(element.substring(1, element.length()).c_str());
-      else if (element[0] == 'D') // Set trigger duration
-        triggerDuration = atol(element.substring(1, element.length()).c_str());
-      else if ((xPosition >= 1) && (element.length() >= 3)) // Number of shots and delay between shots in one element
-      {
-        numberOfShots = atol(element.substring(0, xPosition).c_str());
-        delayBetweenShots = atol(element.substring(xPosition + 1, element.length()).c_str());
-        break;
-      }
-      else // delay between shots only
-      {
-        delayBetweenShots = atol(element.substring(0, element.length()).c_str());
-        break;
-      }
-    }
-    idx = timeTable.indexOf(","); // Find end of next element
-  }
-  if (numberOfShots > 0)
-    setAndDoProcessMode(TIMELAPSESTART);
-	*/
+  /*
+    delayToStart = 0; // Reset wait (delay) timer anyway
+    numberOfShots = 1; // At least one shot
+    trigger(OFF);
+    int idx = timeTable.indexOf(","); // Find end of next element
+    while (idx >= 1)
+    {
+      String element = timeTable.substring(0, idx);
+      if (element.length() >= 1) // something is there
+      {
+        int xPosition = element.indexOf("X");
+        timeTable = timeTable.substring(idx + 1, timeTable.length()); // remove element from timetable
+        if (element[0] == 'W') // set wait (=Delay) time
+          delayToStart = atol(element.substring(1, element.length()).c_str());
+        else if (element[0] == 'D') // Set trigger duration
+          triggerDuration = atol(element.substring(1, element.length()).c_str());
+        else if ((xPosition >= 1) && (element.length() >= 3)) // Number of shots and delay between shots in one element
+        {
+          numberOfShots = atol(element.substring(0, xPosition).c_str());
+          delayBetweenShots = atol(element.substring(xPosition + 1, element.length()).c_str());
+          break;
+        }
+        else // delay between shots only
+        {
+          delayBetweenShots = atol(element.substring(0, element.length()).c_str());
+          break;
+        }
+      }
+      idx = timeTable.indexOf(","); // Find end of next element
+    }
+    if (numberOfShots > 0)
+      setAndDoProcessMode(TIMELAPSESTART);
+  */
 }

 void switchTriggerOffAndCheckStatus()
@@ -345,7 +347,11 @@
   trigger(OFF);
   currentTDuration = currentTriggerDuration;
   if ((currentNShots <= 0) && (currentExecMode == TIMELAPSERUNNING))  // End of Timelapse mode
+  {
     currentExecMode = TIMELAPSESTOP;
+    if (timeTable != "" )  // Next element of timetable
+      processTimeTable();
+  }
 }

 void extractParams(String params)
@@ -586,6 +592,8 @@

 void trigger(triggerModes tMode)
 {
+  if (autofocusPin > -1)
+    digitalWrite(autofocusPin, tMode);
   digitalWrite(triggerPin, tMode);
   currentTriggerMode =  tMode;
 }


時間調整とitoaの使い方ミスを修正

時間調整とitoaの使い方ミスを修正

--- 2_example/example09m_hum/example09m_hum.ino
+++ 2_example/example09m_hum/example09m_hum.ino
@@ -42,9 +42,8 @@
     mem =readRtcInt();                      // RTCメモリからの読みとる
     if(WAKE_COUNT%SLEEP_N){                 // SLEEP_Nが0以外の時に以下を実行
         if( mem ) mem=(int)(temp*1000)/mem; // メモリ値に対する温度値を算出
-        if( mem>95 && mem<105 ) sleep();    // メモリ値と近い場合にスリープ
+        if( mem>98 && mem<102 ) sleep();    // メモリ値と近い場合にスリープ
     }
-    writeRtcInt((int)(temp*10));            // 温度値X10をRTCメモリへ保存
     WiFi.mode(WIFI_STA);                    // 無線LANをSTAモードに設定
     WiFi.begin(SSID,PASS);                  // 無線LANアクセスポイントへ接続
     while(WiFi.status() != WL_CONNECTED){   // 接続に成功するまで待つ
@@ -74,13 +73,17 @@
         ambient.set(1,s);                   // Ambient(データ1)へ温度を送信
         dtostrf(hum,5,2,s);                 // 湿度を文字列に変換
         ambient.set(2,s);                   // Ambient(データ2)へ湿度を送信
-        itoa(mem,s,3);                      // 前回との差異を文字列へ変換
+        if( mem<0 ) mem=0;					// 下限値を0に
+        if( mem>200) mem=200;				// 上限値を200に
+        itoa(mem,s,10);                     // 前回との差異を文字列へ変換
         ambient.set(3,s);                   // Ambient(データ3)へ差異を送信
-        itoa(WAKE_COUNT,s,2);               // 前回からの測定間隔数を文字列へ変換
+        if(WAKE_COUNT>9e4) WAKE_COUNT=9e4;  // 上限値を90000に
+        itoa(WAKE_COUNT,s,10);              // 前回からの測定間隔数を文字列へ変換
         ambient.set(4,s);                   // Ambient(データ4)へ測定間隔数を送信
         ambient.send();                     // Ambient送信の終了(実際に送信する)
     }
     WAKE_COUNT=1;                           // 起動回数をリセット
+    writeRtcInt((int)(temp*10));            // 温度値X10をRTCメモリへ保存
     delay(200);                             // 送信待ち時間
     sleep();
 }


Fancy lightshow at startup

Fancy lightshow at startup

--- RightpointLabs.Pourcast.Arduino/RightpointLabs.Pourcast.Arduino.ino
+++ RightpointLabs.Pourcast.Arduino/RightpointLabs.Pourcast.Arduino.ino
@@ -114,12 +114,35 @@

 void startupDelay() {
   http->LogMessage("Begining startup delay");
+
+  // turn on the pour lights for a few seconds while we clear things out
+  digitalWrite(8, HIGH);
+  digitalWrite(7, HIGH);
+
   delay(2000);
+
   long tap1Pulses = tap1->Clear();
   long tap2Pulses = tap2->Clear();
   char buf[128];
   PString pBuf(buf, 128);
   pBuf << "Startup delay complete (ignored " << tap1Pulses << " and " << tap2Pulses << ")";
+  http->LogMessage(buf);
+
+  // and now we blink a few times to confirm we're starting up
+  for(int i=0; i<32; i++) {
+    digitalWrite(9, i % 2 < 1 ? HIGH : LOW);
+    digitalWrite(8, i % 4 < 2 ? HIGH : LOW);
+    digitalWrite(7, i % 8 < 4 ? HIGH : LOW);
+    delay(250);
+  }
+
+  // and now go back to normal states
+  digitalWrite(9, HIGH);
+  digitalWrite(8, LOW);
+  digitalWrite(7, LOW);
+
+  pBuf.begin();
+  pBuf << F("Light show complete, really starting");
   http->LogMessage(buf);
 }


chose a random id (once) and replace if collision

--- rf95_ping/rf95_ping.ino
+++ rf95_ping/rf95_ping.ino
@@ -7,7 +7,7 @@
 // It is designed to work with the other example rf95_client
 // Tested with Anarduino MiniWirelessLoRa

-
+#include <EEPROM.h>
 #include <SPI.h>
 #include <RH_RF95.h>

@@ -26,9 +26,27 @@
 #define T_PING 1
 #define T_PONG 2

+void genId(const bool update) {
+	const bool validMarker = EEPROM.read(1) == 123;
+
+	if (validMarker && !update)
+		ping.initiator = EEPROM.read(0);
+	else {
+		Serial.println(F("Update/set ID"));
+		ping.initiator = rand();
+		if (!validMarker)
+			EEPROM.write(1, 123);
+		EEPROM.write(0, ping.initiator);
+		delay(5);
+		EEPROM.read(1);
+		EEPROM.read(0);
+	}
+}
+
 void setup() {
 	Serial.begin(115200);
-	Serial.println(F("Hello World from Server!"));
+	Serial.println(F("Init LoRa test"));
+
 	if (!rf95.init())
 		Serial.println(F("init failed"));
 	// Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
@@ -39,22 +57,26 @@
 	for(uint8_t i=A0; i<=A7; i++)
 		r ^= analogRead(i);
 	srandom(r);
+	srand(~r);

 	//    rf95.setTxPower(20);

 	// init ping
+	genId(false);
 	ping.type = T_PING;
 	ping.count = 0;
 	ping.rssi = 0;
-	ping.initiator = 214; // FIXME CHANGE THIS TO SOMETHING UNIQUE
 	pong.replier = -1;
+
+	Serial.print(F("Hello World from "));
+	Serial.println(ping.initiator);

 	pong.initiator = -1;
 	pong.replier = ping.initiator;
 }

 static char line[128];
-static uint8_t buf[64];
+static uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];

 void loop()
 {
@@ -74,15 +96,18 @@

 	unsigned long now = millis();
 	while (millis() - now < wait) {
-		uint8_t len = sizeof(buf);
+		uint8_t len = sizeof buf;

 		if (rf95.available()) {
+			memset(buf, 0x00, sizeof buf);
 			rf95.recv(buf, &len);

 			if (len == sizeof(pong)) {
 				memcpy(&pong, buf, sizeof(pong));

+				bool col = false;
 				if (pong.type == T_PING) {
+					col = pong.initiator == ping.initiator;
 					// got ping
 					sprintf(line, "Recv PING(%d,%d,%d)", pong.count, pong.rssi, pong.initiator);
 					Serial.println(line);
@@ -96,6 +121,7 @@
 					rf95.waitPacketSent();
 				}
 				else if (pong.type == T_PONG) {
+					col = pong.replier == ping.initiator;
 					// got pong, print stats
 					sprintf(line, "Got PONG(%d,%d,%d)", pong.count, pong.rssi, pong.replier);
 					Serial.println(line);
@@ -103,6 +129,16 @@
 				else {
 					sprintf(line, "???(%d,%d,%d,%d,%d)", pong.count, pong.rssi, pong.initiator, pong.replier, pong.type);
 					Serial.println(line);
+				}
+
+				if (col) {
+					sprintf(line, "ID COL: %d,%d", pong.initiator, pong.replier);
+					if (pong.initiator == ping.initiator) {
+						Serial.println(F("ID collision, force new"));
+						genId(true);
+						Serial.print(F("New ID:"));
+						Serial.println(ping.initiator);
+					}
 				}
 			} else {
 				Serial.println(F("Got spurious message: "));


Update Master-board.ino

Update Master-board.ino

--- Firmware/Ball/Master-Board/Master-board.ino
+++ Firmware/Ball/Master-Board/Master-board.ino
@@ -1,6 +1,6 @@
 String version = "0.1.1";
 /*
-
+http://shanes.net/another-nrf24l01-sketch-string-sendreceive/
  >      FIRMWARE ONLY FOR AN ARDUINO NANO !!    <
  > IF YOU USE ANOTHER ARDUINO, ADAPT THE PINOUT <


Updated script for Galileo Gen2/Edison support

--- arduino/IoTkit/examples/IoTkitSimpleExample/IoTkitSimpleExample.ino
+++ arduino/IoTkit/examples/IoTkitSimpleExample/IoTkitSimpleExample.ino
@@ -44,6 +44,15 @@
 IoTkit iotkit;
 int temp;

+/*
+ "therm_file" - SoC temperature sensor:
+ On Galileo Gen2 - use thermal_zone0
+ On Edison       - use thermal_zone1 (ambient temp)
+                       thermal_zone3 (core0)
+                       thermal_zone4 (core1)
+*/
+char* therm_file = "/sys/devices/virtual/thermal/thermal_zone3/temp";
+

 void setup() {
   Serial.begin(115200);
@@ -53,7 +62,7 @@

 void loop() {
   Serial.println("Reading temperature");
-  temp = getADCTemp();
+  temp = getTemp();
   Serial.print("Temperature is ");
   Serial.print(temp);
   Serial.println(" degrees celcius.");
@@ -86,65 +95,29 @@
   delay(2000);
 }

-// reads hardware temp sensor
-int getADCTemp(){
+// Generic Edison/Galileo function to read hardware temp sensor
+int getTemp()
+{
   bool successful = true;
-  char scale[4];
-  char raw[4];
-  char offset[4];

-  int raw_i;
-  int scale_i;
-  int offset_i;
-
-  //read the values from scale, raw and offset files.
-  //we need all three values, because the formula for
-  //calulating the actual temperature in milli-degrees Celcius
-  //is: TEMP = (RAW + OFFSET) * SCALE
-  FILE *fp_raw;
-  fp_raw = fopen("/sys/bus/iio/devices/iio:device0/in_temp0_raw", "r");
-  if(fp_raw != NULL) {
-    fgets(raw, 4, fp_raw);
-    fclose(fp_raw);
+  // SoC DTS_1
+  int socTemp;
+  char rawTemp[6];
+  FILE *fp_temp;
+  fp_temp = fopen(therm_file, "r");
+  if(fp_temp != NULL) {
+    fgets(rawTemp, 6, fp_temp);
+    fclose(fp_temp);
   } else {
-    Serial.println("Cannot open file /sys/bus/iio/devices/iio:device0/in_temp0_raw for reading.");
-    Serial.println("Try another sensors readings in this directory");
-    successful = false;
-  }
-
-
-  FILE *fp_scale;
-  fp_scale = fopen("/sys/bus/iio/devices/iio:device0/in_temp0_scale", "r");
-  if(fp_scale != NULL) {
-    fgets(scale, 4, fp_scale);
-    fclose(fp_scale);
-  } else {
-    Serial.println("Cannot open file /sys/bus/iio/devices/iio:device0/in_temp0_raw for reading.");
-    Serial.println("Try another sensors readings in this directory");
-    successful = false;
-  }
-
-
-  FILE *fp_offset;
-  fp_offset = fopen("/sys/bus/iio/devices/iio:device0/in_temp0_offset", "r");
-  if(fp_offset != NULL) {
-    fgets(offset, 4, fp_offset);
-    fclose(fp_offset);
-  } else {
-    Serial.println("Cannot open file /sys/bus/iio/devices/iio:device0/in_temp0_raw for reading.");
+    Serial.println("Cannot open file for reading.");
+    Serial.println(therm_file);
     Serial.println("Try another sensors readings in this directory");
     successful = false;
   }

   if(successful) {
-    raw_i = atoi(raw);         //we have the values now, but they are in ASCII form-
-    scale_i = atoi(scale);     //we need them as integers so we can use them for calculations.
-    offset_i = atoi(offset);
-
-    int temp = (raw_i + /*offset_i*/ 0) * scale_i;  //Calculate temperature in milli-degrees celcius
-    temp /= 1000;                                   //divide by 1000 to convert to degrees celcius
-    temp = raw_i;
-    return temp;
+    socTemp = atoi(rawTemp)/1000;
+    return socTemp;
   }
   return 0;
 }


Changed comment in header

Changed comment in header

--- arduino/IoTkit/examples/IoTkitSimpleExample/IoTkitSimpleExample.ino
+++ arduino/IoTkit/examples/IoTkitSimpleExample/IoTkitSimpleExample.ino
@@ -33,7 +33,7 @@
 //You need iotkit-agent installed and running.
 //Device should be activated. (by running: iotkit-admin activate ACTIVATION_CODE)
 //Following components should be registered (by running: iotkit-admin register NAME TYPE):
-//temp type e.g. temperature.v1.0
+//temperature of type temperature.v1.0
 //power of type powerswitch.v1.0
 //You can also use IoTkitRegisterExample to activate and register new components


implemented update of TrackDb for Adafruit PN532 library

--- Arduino_codeline/fairytale23/fairytale23.ino
+++ Arduino_codeline/fairytale23/fairytale23.ino
@@ -133,7 +133,8 @@
                            an album directory currently not connected to a tag (functionality yet to come)
 */

-// make sure to change this to comment this out before uploading in production as it turns on lots and lots of serial messages
+// make sure to comment this out before uploading in production as it turns on lots and lots of serial messages
+// if it is not define, no Serial.print is possible, as also Serial.begin() is omitted
 //#define DEBUG 1

@@ -162,10 +163,10 @@
 // Define the NFC <-> Album implementation
 // ONLY ONE of the these two options can be chosen
 // to use NDEF to get the album directory uncomment the following line
-#define NFCNDEF 1
+//#define NFCNDEF 1
 // to use the Adafruit NFC library to get the Tag UID and retrieve the directory from the trackDb
 // uncomment the following line.
-//#define NFCTRACKDB 1
+#define NFCTRACKDB 1

 // uncomment the next line to enable resuming the last played album on switch on
 // this is achieved via a special file on the SD card and works without a tag but uses the pause/resume button instead
@@ -178,26 +179,26 @@
 #include <SD.h>

 // These are the SPI pins shared among all components
-#define CLK           13    // SPI Clock shared with VS1053, SD card and NFC breakout board
-#define MISO          12    // Input data from VS1053, SD card and NFC breakout board
-#define MOSI          11    // Output data to VS1053, SD card and NFC breakout board
+#define CLK             13    // SPI Clock shared with VS1053, SD card and NFC breakout board
+#define MISO            12    // Input data from VS1053, SD card and NFC breakout board
+#define MOSI            11    // Output data to VS1053, SD card and NFC breakout board

 //
 // SETUP MUSIC MAKER SHIELD
 //
 #include <Adafruit_VS1053.h>
 // These are the pins used for the music maker shield
-#define SHIELD_RESET  -1    // VS1053 reset pin (unused!)
-#define SHIELD_CS      7    // VS1053 chip select pin (output)
-#define SHIELD_DCS     6    // VS1053 Data/command select pin (output)
+#define SHIELD_RESET     -1    // VS1053 reset pin (unused!)
+#define SHIELD_CS         7    // VS1053 chip select pin (output)
+#define SHIELD_DCS        6    // VS1053 Data/command select pin (output)

 //
 // SETUP SD CARD
 //
 // These are common pins between breakout and shield
-#define CARDCS         4    // Card chip select pin
+#define CARDCS            4    // Card chip select pin
 // DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
-#define DREQ           3    // VS1053 Data request, ideally an Interrupt pin
+#define DREQ              3    // VS1053 Data request, ideally an Interrupt pin
 // Create shield object
 Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);

@@ -205,21 +206,37 @@
 //
 // SETUP NFC ADAPTER
 //
+// this implementation uses the Speedmaster Library and Don's NDEF library to read NFC Tags and
+// get the album directory that is stored as an NDEF Message on the tag. That means, it does NOT
+// use the decribed TrackDB. It is also much heavier (in Progmem size than the Adafruit PN532
+// implementation below and does NOT support recognition of a removed track. Furthermore the user
+// has to turn off the box before she can listen to the next album :-(
 #ifdef NFCNDEF
   // these includes are sued for the NDEF implementation
   #include <PN532_SPI.h>
   #include <PN532.h>
   #include <NfcAdapter.h>
-  #define PN532_SCK     13    // SPI Clock shared with VS1053, SD card and NFC breakout board
-  #define PN532_MISO    12    // Input data from VS1053, SD card and NFC breakout board
-  #define PN532_MOSI    11    // Output data to VS1053, SD card and NFC breakout board
-  #define PN532_SS      10    // NFC breakout board chip select pin
+  #define PN532_SCK         13    // SPI Clock shared with VS1053, SD card and NFC breakout board
+  #define PN532_MISO        12    // Input data from VS1053, SD card and NFC breakout board
+  #define PN532_MOSI        11    // Output data to VS1053, SD card and NFC breakout board
+  #define PN532_SS          10    // NFC breakout board chip select pin
   PN532_SPI pn532spi(SPI, PN532_SS);
   NfcAdapter nfc = NfcAdapter(pn532spi);
 #endif

+// this implementation uses the Adafruit PN532 library alone - it is way smaller and preferrable
+// as it allows for tag removal recognition and does not enforce the user to turn off the box
+// after an album was played, as the above implementation does.
 #ifdef NFCTRACKDB
   // INCLUDE Adafruit NFC LIbrary here
+  #include <Wire.h>
+  #include <Adafruit_PN532.h>
+  //#define PN532_SCK         13    // SPI Clock shared with VS1053, SD card and NFC breakout board
+  //#define PN532_MISO        12    // Input data from VS1053, SD card and NFC breakout board
+  //#define PN532_MOSI        11    // Output data to VS1053, SD card and NFC breakout board
+  #define PN532_SS          10    // NFC breakout board chip select pin
+  //Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
+  Adafruit_PN532 nfc(SCK, MISO, MOSI, PN532_SS);
 #endif

@@ -250,8 +267,8 @@

 // trackDb on the SD card - this is where we store the NFC TAG <-> Directory connection and the track to start playback with
 #ifdef NFCTRACKDB
-  const char trackDbDir[]     = "/trackdb0";               // where do we store the files for each album
-  const char trackDbFile[]    = "/trackdb0/albumnfc.txt";  // path to the file that holds the connection between an NFC tag UID and the corresponding directory / file name
+  const char trackDbDir[]   = "/trackdb0";               // where do we store the files for each album
+  const char trackDbFile[]  = "/trackdb0/albumnfc.txt";  // path to the file that holds the connection between an NFC tag UID and the corresponding directory / file name
   char tDirFile[sizeof(trackDbFile)];                      // a char array to hold the path to the file with track and directory infos (name is shared with directory name plus .txt
   char trackDbEntry[35];                                   // will hold a nfc <-> album info connection in the form of [NFC Tag UID]:[album]:[Track] e.g.: 43322634231761291:larsrent:1

@@ -263,28 +280,28 @@

 // volume control variables for the analog poti
 #ifdef VOLUMEPOT
-  const byte volPotPin     = A0;      // the analog input pin that we use for the potentiometer
-  word lastVolSensorValue  = 0;       // keeps the last read sensor value
+  const byte volPotPin      = A0;      // the analog input pin that we use for the potentiometer
+  word lastVolSensorValue   = 0;       // keeps the last read sensor value
 #endif

 // control buttons definition
 #ifdef BUTTONS
-  const byte btnLinePin    = A1;      // pin on which the button line (4 buttons) is connected
+  const byte btnLinePin     = A1;      // pin on which the button line (4 buttons) is connected

   word btnVal;                        // stores the value we receive on the btnLinePin for comparance with the predefined analog reads for the 4 buttons
-  const byte btnValDrift   = 5;       // maximum allowed difference + and - the predefined value for each button we allow
-  const word btnPressDelay = 500;     // delay in milliseconds to prevent double press detection
+  const byte btnValDrift    = 5;       // maximum allowed difference + and - the predefined value for each button we allow
+  const word btnPressDelay  = 500;     // delay in milliseconds to prevent double press detection
   unsigned long btnPressTime = 0;     // time in millis() when the button was pressed
-  const word btnLightValue = 1021;    // 33 Ohm  - The value we receive from analog input if the Light On/Off Button is pressed
-  const word btnPauseValue = 933;     // 1K Ohm  - The value we receive from analog input if the Pause Button is pressed
-  const word btnNextValue  = 1002;    // 220 Ohm - The value we receive from analog input if the Next (aka Fast Forward) Button is pressed
-  const word btnPrevValue  = 991;     // 330 Ohm - The value we receive from analog input if the Previos (aka Prev or Rewind) Button is pressed
-  const word minBtnValue   = 800;     // we use this value to determine, whether or not to check the buttons. Set to lower val than smallest of buttons
+  const word btnLightValue  = 1021;    // 33 Ohm  - The value we receive from analog input if the Light On/Off Button is pressed
+  const word btnPauseValue  = 933;     // 1K Ohm  - The value we receive from analog input if the Pause Button is pressed
+  const word btnNextValue   = 1002;    // 220 Ohm - The value we receive from analog input if the Next (aka Fast Forward) Button is pressed
+  const word btnPrevValue   = 991;     // 330 Ohm - The value we receive from analog input if the Previos (aka Prev or Rewind) Button is pressed
+  const word minBtnValue    = 800;     // we use this value to determine, whether or not to check the buttons. Set to lower val than smallest of buttons
 #endif

 // IR remote control
 #ifdef IRREMOTE
-  const byte iRRemotePin   = A4;      // the pin the IR remote control diode (receiver) is connected to
+  const byte iRRemotePin    = A4;      // the pin the IR remote control diode (receiver) is connected to

   // IR Remote control
   // to reduce PROGMEM size I decided to not use the whole decimal value for each button on the remote control but instead do a calculation
@@ -312,8 +329,8 @@

 // battery control
 #ifdef LOWBAT
-  const byte lowBatPin   = A2;      // pulled high to BAT but when the charger detects a low voltage (under 3.2V) the pin will drop down to 0V (LOW)
-  boolean lowBatWarn     = true;    // we use this bool so we may only tell the user every 5 Minite sthat the Battery is low
+  const byte lowBatPin      = A2;      // pulled high to BAT but when the charger detects a low voltage (under 3.2V) the pin will drop down to 0V (LOW)
+  boolean lowBatWarn        = true;    // we use this bool so we may only tell the user every 5 Minite sthat the Battery is low
 #endif

@@ -322,11 +339,11 @@
   #ifdef OPRLIGHTTIME
     unsigned long lightStartUpTime = 0; // millis() the operations light started
   #endif
-  const byte infoLedPin    = 5;       // the pin to which the operation led is connected to
-  boolean lightOn          = true;    // if true, the operations light fader is active. is set to false via a button, or after a maxLightTime (see below) is reached
-#endif
-const byte warnLedPin    = 8;       // the pin to which the warning led is connected to
-const byte errorLedPin   = 9;       // the pin to which the error led is connected to
+  const byte infoLedPin     = 5;       // the pin to which the operation led is connected to
+  boolean lightOn           = true;    // if true, the operations light fader is active. is set to false via a button, or after a maxLightTime (see below) is reached
+#endif
+const byte warnLedPin       = 8;       // the pin to which the warning led is connected to
+const byte errorLedPin      = 9;       // the pin to which the error led is connected to

@@ -386,7 +403,9 @@
 //      SSSSSS   EEEEEE     TT      UUUUU   PP
 //
 void setup() {
-  Serial.begin(38400);
+  #ifdef DEBUG
+    Serial.begin(38400);
+  #endif

   // set the buttons as input
   #ifdef VOLUMEPOT
@@ -411,15 +430,17 @@

   // initialize the music player
   if (! musicPlayer.begin()) {
-    Serial.println(F("VS1053 Not found"));
-
+    #ifdef DEBUG
+      Serial.println(F("VS1053 Not found"));
+    #endif
     // flash the red light to indicate we have an error
     for (;;) { digitalWrite(errorLedPin, HIGH); }
   }
   // initialize the SD card
   if (!SD.begin(CARDCS)) {
-    Serial.println(F("SD-Card Not found"));
-
+    #ifdef DEBUG
+      Serial.println(F("SD-Card Not found"));
+    #endif
     // flash the red light to indicate we have an error
     for (;;) { digitalWrite(errorLedPin, HIGH); }
   }
@@ -430,7 +451,9 @@
   // that's Digital #2 or #3
   // See http://arduino.cc/en/Reference/attachInterrupt for other pins
   if (! musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT)) {
-    Serial.println(F("No interrupt on DREQ pin"));
+    #ifdef DEBUG
+      Serial.println(F("No interrupt on DREQ pin"));
+    #endif
     for (;;) { digitalWrite(errorLedPin, HIGH); }
   }

@@ -443,14 +466,31 @@
   }

-  // now as the last thing, start the nfc reader either the simple one with NDEF support
+  // now as the last thing, start the nfc reader
   #ifdef NFCNDEF
+    // either use the simple one with NDEF support to get the   tag <-> album directory  connection
     nfc.begin();
   #endif
-
-  // or the one which allows for resume and rescan etc. but needs the trackDB as no NDEF messages are supported
+
   #ifdef NFCTRACKDB
-
+    // or use the Adafruit implementation, which allows for resume and rescan etc.
+    //   but needs the trackDB to get the album directory for a tag as no NDEF messages are supported
+    nfc.begin();
+    uint32_t versiondata = nfc.getFirmwareVersion();
+    if (! versiondata) {
+      #ifdef DEBUG
+        Serial.print("Didn't find PN53x board");
+      #endif
+      for (;;) { digitalWrite(errorLedPin, HIGH); }
+    }
+    #ifdef DEBUG
+      // Got ok data, print it out!
+      Serial.print(F("Found chip PN5")); Serial.println((versiondata>>24) & 0xFF, HEX);
+      Serial.print(F("Firmware ver. ")); Serial.print((versiondata>>16) & 0xFF, DEC);
+      Serial.print(F('.')); Serial.println((versiondata>>8) & 0xFF, DEC);
+    #endif
+    // configure board to read RFID tags
+    nfc.SAMConfig();
   #endif

   // ALL DONE
@@ -496,7 +536,7 @@
       if (btnVal > minBtnValue && (millis()-btnPressTime) > btnPressDelay) {
         if ( ((btnVal - btnValDrift) < btnPauseValue) && ((btnVal + btnValDrift) > btnPauseValue) ) {
           #ifdef DEBUG
-            Serial.println(F("Pause Button Pressed"));
+            Serial.println(F("Resume last album"));
           #endif
         }
       }
@@ -507,9 +547,17 @@
     Serial.print(F("."));
   #endif

-  // if a tag is found, we continue
-  weHaveATag = nfc.tagPresent(1000);
-  if (weHaveATag) {
+  // if a tag is found, we continue - this implementation uses the Speedmaster Library and Don's NDEF lib
+  #ifdef NFCNDEF
+    weHaveATag = nfc.tagPresent(1000);
+  #endif
+
+  // if a tag is found, we continue - this implementation uses the Adafruit PN532 library alone
+  #ifdef NFCTRACKDB
+    weHaveATag = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
+  #endif
+
+  if (weHaveATag || resumeLast) {
     #ifdef DEBUG
       Serial.println(F(" tag found!"));
     #endif
@@ -673,6 +721,9 @@
         //Serial.print(F("set ")); Serial.print(firstTrackToPlay); Serial.println(F(" as first track to play"));
       #endif
       #ifdef NFCTRACKDB
+        // first create the new trackDb entry:
+        setTrackDbEntry();
+        // second store this entry in the TrackDb files
         if (!writeTrackDbEntry()) {
           issueWarning("trackdb update error", "", false);
         }
@@ -1021,9 +1072,12 @@
     #endif
     success = true;
   } else {
-    Serial.print(F("  error writing "));Serial.println(trackDbFile);
+    #ifdef DEBUG
+      Serial.print(F("  error writing "));Serial.println(trackDbFile);
+    #endif
+    digitalWrite(warnLedPin, HIGH);
   }
-
+  */
   // SECOND write the tDirFile --> e.g. larsrent.txt
   memset(tDirFile, 0, sizeof(tDirFile));          // make sure var to hold path to track db file is empty
   strcat(tDirFile, trackDbDir);                   // add the trackDb Directory to the
@@ -1040,10 +1094,13 @@
     #endif
     success = false;
   } else {
-    Serial.print(F("  error writing "));Serial.println(tDirFile);
+    #ifdef DEBUG
+      Serial.print(F("  error writing "));Serial.println(tDirFile);
+    #endif
+    digitalWrite(warnLedPin, HIGH);
     success = false;
   }
-  */
+
   return (success);
 }
 #endif


RFduino - incompatibilities solved

RFduino - incompatibilities solved

--- LBridge_RFduino_V09/LBridge_RFduino_V09.ino
+++ LBridge_RFduino_V09/LBridge_RFduino_V09.ino
@@ -46,7 +46,6 @@
  *  - queue length adjusted to 8h
  *  - added debug output for decodeSN
  *  V0.9.07
-<<<<<<< HEAD
  *  - serial.begin wait now for port online (delay code by @bertrooode)
  *  - error fixed in decodeSN (@bertrooode)
  *  - reworked program config section (#define section)
@@ -56,11 +55,6 @@
  *  - additional reset of CR95HF after ULP wakeup and Serial.start (@bertrooode)
  *  - own printf() code to avoid fragmented Serial.print() calls / reduce system load? to be verified
  *  - set different minimum voltage level for Simblee (@FPV-UAV)
-=======
- *  - serial.begin fixed (delay code by @bertrooode)
- *  - error fixed in decodeSN (@bertrooode)
- *  - reworked program config section (#define section)
->>>>>>> 889c98de6bfe5483b6c10b253498555ce3125e25
  */

 /* ********************* program configuration options **********************/
@@ -88,13 +82,8 @@
 #define LB_ADVERT "rfduino"     // dont change "rfduino"
                                 // length of device name and advertisement <=15!!!
 #define LB_VERSION "V0.9"       // program version
-<<<<<<< HEAD
 #define LB_MINOR_VERSION ".08"  // indicates minor version
 #define LB_DATETIME "180219_2147" // date_time
-=======
-#define LB_MINOR_VERSION ".07"  // indicates minor version
-#define LB_DATETIME "180216_1051" // date_time
->>>>>>> 889c98de6bfe5483b6c10b253498555ce3125e25
 #define SPIKE_HEIGHT 40         // minimum delta to be a spike

 #ifdef RFD
@@ -378,7 +367,6 @@
   // init and open serial line
   Serial.begin(9600);
   // time to settle, avoid serial ghost characters
-<<<<<<< HEAD
   delay(2000);
   // time to settle, method introduced by @bertrooode
   // wait for serial interface up and running or if 5 secs are elapsed
@@ -387,16 +375,6 @@
     delay(100);
   } while ( !Serial && ((mymillis()-ct) < 5000) );
 //  print_statef("serial interface ready after %d ms", mymillis()-ct);
-=======
-//  delay(2000);
-  // time to settle, method in troduced by @bertrooode
-  // wait for serial interface up and running or if 5 secs are elapsed
-  unsigned long ct = mymillis();
-  while ( !Serial && ((mymillis()-ct) < 5000) ) {
-    delay(100);
-  }
-  print_statef("serial interface ready after %d ms", ct-mymillis());
->>>>>>> 889c98de6bfe5483b6c10b253498555ce3125e25

   myprintf("\r\n=== starting =====================================================================================================");

@@ -533,7 +511,6 @@
   // time to settle, method in troduced by @bertrooode
   // wait for serial interface up and running or if 5 secs are elapsed
   unsigned long ct = mymillis();
-<<<<<<< HEAD
   do {
     delay(100);
   } while ( !Serial && ((mymillis()-ct) < 5000) );
@@ -545,12 +522,6 @@
   digitalWrite(PIN_SPI_SS, HIGH);
   delay(1);

-=======
-  while ( !Serial && ((mymillis()-ct) < 5000) ) {
-    delay(100);
-  }
-  print_statef("serial interface ready after %d ms", ct-mymillis());
->>>>>>> 889c98de6bfe5483b6c10b253498555ce3125e25
 }

 /*


LED toggle for IFTTT demo

LED toggle for IFTTT demo

--- examples/_0150_MQTT_LED/_0150_MQTT_LED.ino
+++ examples/_0150_MQTT_LED/_0150_MQTT_LED.ino
@@ -31,6 +31,15 @@
     } else if (value == "1") {
       espert.led.on();
       espert.println("LED: On");
+    } else if (value == "2") {
+      if( espert.led.isOn() ) {
+        espert.led.off();
+        espert.println("LED (Toglle): off");
+      }
+      else {
+        espert.led.on();
+        espert.println("LED (Toglle): On");
+      }
     }

     String outString  = "{\"status\":\"" + String(espert.led.isOn() ? 1 : 0) + "\", ";


First cut of portable 2 / 3 selftest

First cut of portable 2 / 3 selftest

--- selftest.ino
+++ selftest.ino
@@ -2,7 +2,9 @@
 #include <SPI.h>
 #include <GD2.h>

-#define UART_SPEED 9600
+#define GD3 ft8xx_model
+
+#define UART_SPEED 115200

 #include "selftest_assets.h"

@@ -32,7 +34,6 @@
 {
   Serial.begin(UART_SPEED);
   Serial.println("---- GAMEDUINO 2 SELFTEST ----");
-  GD.begin(0);
 }

 static void ramp(int y, uint32_t color)
@@ -46,8 +47,11 @@
 {
   // GD.ClearColorRGB(0x204060);

+  GD.get_inputs();
   GD.Clear();
-  GD.cmd_text(240, 12, 28, OPT_CENTER, "Gameduino2 Self test");
+  GD.cmd_text(240, 12, 28, OPT_CENTER,
+    GD3 ? "Gameduino3 Self test" :
+          "Gameduino2 Self test");

   int y;

@@ -81,8 +85,17 @@
     GD.ColorRGB(pass ? 0x40ff40 : 0xff4040);
   GD.cmd_text(120, 180, 31, OPT_CENTERY, message);

+  GD.ColorRGB(0xffffff);
+  GD.Begin(LINES);
+
+  GD.Vertex2f(PIXELS(GD.inputs.x), PIXELS(0));
+  GD.Vertex2f(PIXELS(GD.inputs.x), PIXELS(GD.h));
+
+  GD.Vertex2f(PIXELS(0),    PIXELS(GD.inputs.y));
+  GD.Vertex2f(PIXELS(GD.w), PIXELS(GD.inputs.y));
+
   GD.swap();
-
+  GD.finish();
 }

 #define SCREENTEST(NAME) \
@@ -118,7 +131,8 @@

   float measured = float(t2 - t1);
   // measured should be 48e6, within 2%
-  float expected = 48e6 / SPEEDUP;
+
+  float expected = (GD3 ? 60e6 : 48e6) / SPEEDUP;
   Serial.println(measured, DEC);
   Serial.println(expected, DEC);
   float diff = measured - expected;
@@ -264,15 +278,17 @@

 static byte test_touch(void)
 {
-  GD.Clear();
-  GD.cmd_text(240, 100, 30, OPT_CENTERX, "please tap on the dot");
-  GD.self_calibrate();
-  // write the new calibration back to EEPROM
+  if (!GD3) {
+    GD.Clear();
+    GD.cmd_text(240, 100, 30, OPT_CENTERX, "please tap on the dot");
+    GD.self_calibrate();
+    // write the new calibration back to EEPROM

 #if !defined(RASPBERRY_PI) && !defined(__DUE__)
-  for (int i = 0; i < 24; i++)
-    EEPROM.write(1 + i, GD.rd(REG_TOUCH_TRANSFORM_A + i));
+    for (int i = 0; i < 24; i++)
+      EEPROM.write(1 + i, GD.rd(REG_TOUCH_TRANSFORM_A + i));
 #endif
+  }

   byte hit = 0;
   while (hit != 0x0f) {
@@ -423,8 +439,209 @@
   { 255, 255 }
 };

+static const uint8_t GD3_43__init[128] = {
+255, 255, 1, 1, 26, 255, 255, 255, 12, 32, 48, 0, 4, 0, 0, 0, 0, 135,
+147, 3, 26, 255, 255, 255, 80, 33, 48, 0, 24, 0, 0, 0, 46, 46, 46, 46,
+46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
+46, 46, 46, 34, 255, 255, 255, 88, 32, 48, 0, 120, 156, 99, 100, 96,
+96, 216, 198, 200, 192, 0, 68, 12, 204, 12, 16, 26, 132, 217, 128, 24,
+0, 17, 207, 0, 197, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255,
+255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
+255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255
+};
+static const uint8_t GD3_7__init[128] = {
+255, 255, 1, 1, 26, 255, 255, 255, 12, 32, 48, 0, 4, 0, 0, 0, 0, 39,
+134, 3, 26, 255, 255, 255, 80, 33, 48, 0, 24, 0, 0, 0, 46, 46, 46, 46,
+46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
+46, 46, 46, 34, 255, 255, 255, 44, 32, 48, 0, 120, 156, 59, 201, 204,
+192, 16, 193, 192, 192, 160, 0, 164, 65, 192, 0, 136, 89, 152, 128,
+124, 32, 253, 128, 17, 34, 6, 149, 98, 0, 113, 183, 49, 66, 104, 100,
+49, 160, 114, 6, 0, 164, 38, 3, 65, 0, 0, 0, 0, 255, 255, 255, 0, 255,
+255, 255, 0, 255, 255, 255, 0, 255, 255, 255
+};
+static const uint8_t GD3_VGA__init[128] = {
+255, 255, 1, 2, 26, 255, 255, 255, 12, 32, 48, 0, 4, 0, 0, 0, 64, 210,
+223, 3, 26, 255, 255, 255, 148, 32, 48, 0, 4, 0, 0, 0, 16, 0, 0, 0,
+34, 255, 255, 255, 44, 32, 48, 0, 120, 156, 115, 96, 101, 96, 208, 96,
+100, 96, 96, 96, 97, 0, 131, 14, 32, 86, 99, 102, 96, 80, 6, 113, 152,
+33, 98, 108, 12, 248, 1, 72, 59, 0, 77, 136, 1, 81, 0, 0, 0, 255, 255,
+255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255,
+255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
+255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255
+};
+#define FREQUENCY_OFFSET 16
+#define CALIBRATION_OFFSET 32
+
+uint8_t gpio, gpio_dir;
+
+void set_SDA(byte n)
+{
+  GD.wr(REG_GPIO_DIR, gpio_dir | (0x03 - n));    // Drive SCL, SDA low
+}
+
+void set_SCL(byte n)
+{
+  GD.wr(REG_GPIO, gpio | (n << 1));
+}
+
+int get_SDA(void)
+{
+  return GD.rd(REG_GPIO) & 1;
+}
+
+void i2c_start(void)
+{
+  set_SDA(1);
+  set_SCL(1);
+  set_SDA(0);
+  set_SCL(0);
+}
+
+void i2c_stop(void)
+{
+  set_SDA(0);
+  set_SCL(1);
+  set_SDA(1);
+  set_SCL(1);
+}
+
+int i2c_rx1()
+{
+  set_SDA(1);
+  set_SCL(1);
+  byte r = get_SDA();
+  set_SCL(0);
+  return r;
+}
+
+void i2c_tx1(byte b)
+{
+  set_SDA(b);
+  set_SCL(1);
+  set_SCL(0);
+}
+
+int i2c_tx(byte x)
+{
+  for (int i = 7; i >= 0; i--)
+    i2c_tx1(1 & (x >> i));
+  return i2c_rx1();
+}
+
+int i2c_rx(int nak)
+{
+  byte r = 0;
+  for (byte i = 0; i < 8; i++)
+    r = (r << 1) | i2c_rx1();
+  i2c_tx1(nak);
+  return r;
+}
+
+void i2c_begin(void)
+{
+  gpio = GD.rd(REG_GPIO) & ~3;
+  gpio_dir = GD.rd(REG_GPIO_DIR) & ~3;
+
+  // 2-wire software reset
+  i2c_start();
+  i2c_rx(1);
+  i2c_start();
+  i2c_stop();
+}
+
+#define ADDR  0xa0
+
+void ram_write(const uint8_t *v)
+{
+  for (byte i = 0; i < 128; i += 8) {
+    i2c_start();
+    i2c_tx(ADDR);
+    i2c_tx(i);
+    for (byte j = 0; j < 8; j++)
+      i2c_tx(*v++);
+    i2c_stop();
+    delay(6);
+  }
+}
+
+byte ram_read(byte a)
+{
+  i2c_start();
+  i2c_tx(ADDR);
+  i2c_tx(a);
+
+  i2c_start();
+  i2c_tx(ADDR | 1);
+  byte r = i2c_rx(1);
+  i2c_stop();
+  return r;
+}
+
+void ramdump(void)
+{
+  for (int i = 0; i < 128; i++) {
+    byte v = ram_read(i);
+    Serial.print(i, HEX);
+    Serial.print(" ");
+    Serial.println(v, HEX);
+  }
+}
+
+void ram_get(byte *v)
+{
+  i2c_start();
+  i2c_tx(ADDR);
+  i2c_tx(0);
+
+  i2c_start();
+  i2c_tx(ADDR | 1);
+  for (int i = 0; i < 128; i++) {
+    *v++ = i2c_rx(i == 127);
+    // Serial.println(v[-1], DEC);
+  }
+  i2c_stop();
+}
+
+static void load_flash()
+{
+  GD.begin(0);
+
+  if (GD3) {
+    uint8_t stage[128];
+    memcpy(stage, GD3_43__init, 128);
+
+    i2c_begin();
+
+    GD.Clear();
+    GD.cmd_text(240, 100, 30, OPT_CENTERX, "please tap on the dot");
+    GD.self_calibrate();
+    GD.finish();
+
+    for (int i = 0; i < 24; i++)
+      stage[CALIBRATION_OFFSET + i] = GD.rd(REG_TOUCH_TRANSFORM_A + i);
+
+    ram_write(stage);
+    byte b[128];
+    ram_get(b);
+    Serial.print("compare ");
+    int diff = memcmp(stage, b, 128);
+    if (diff != 0) {
+      GD.Clear();
+      GD.cmd_text(240, 100, 30, OPT_CENTERX, "FLASH fault");
+      GD.swap();
+      for (;;);
+    }
+    Serial.println(diff);
+  }
+}
+
 void loop()
 {
+  if (EEPROM.read(0) == 0x7c)
+    EEPROM.write(0, 0xff);
+  load_flash();
+  GD.begin(0);
+
   x = y = 0;
   testcard(1, "Starting tests");
   GD.finish();
@@ -435,27 +652,26 @@

   {
     SCREENTEST(ident);
-    SCREENTEST(tune);
+    if (!GD3)
+      SCREENTEST(tune);
     SCREENTEST(clock);
     SCREENTEST(RAM);
     SCREENTEST(PWM);
-    if (1) {
-      SCREENTEST(storage);
-      SCREENTEST(SDcard);
-    }
-    // SCREENTEST(accel);
+    SCREENTEST(storage);
+    SCREENTEST(SDcard);
+    if (0)
+      SCREENTEST(accel);
     if (1) {
       SCREENTEST(touch);
       SCREENTEST(audio);
     }
-    testcard(1, "* ALL PASS *");
     {
-      byte i = 0, t = 0;
+      int i = 0, t = 0;
       for (;;) {
-        if (t == pacman[i].t)
+        testcard(1, "* ALL PASS *");
+        if (t == 4 * pacman[i].t)
           GD.play(HARP, pacman[i++].note - 12);
-        delay(65);
-        if (++t == 64) {
+        if (++t == 256) {
           t = 0;
           i = 0;
         }


Updated SWD init sequence with old unlock code (0x6DB7).

--- firmware/arduino_nano/swdtest/swdtest.ino
+++ firmware/arduino_nano/swdtest/swdtest.ino
@@ -11,7 +11,7 @@
 #define SWDDAT_PIN 2
 #define SWDCLK_PIN 3

-#define SWDDELAY_us 10
+#define SWDDELAY_us 300

 // *********************************************************
 //   Perform SWD transaction
@@ -180,17 +180,27 @@
   pinMode(SWDDAT_PIN, OUTPUT);
   delayMicroseconds(1000);

-  for(uint32_t i=0; i<50; i++)
-  {
-    SWDWriteBit(true);
-  }
+  for(uint32_t i=0; i<64; i++)
+  {
+    SWDWriteBit(true);
+  }
+
   SWDWord(0x79E7);
-  /*
-  for(uint32_t i=0; i<50; i++)
-  {
-    SWDWriteBit(true);
-  }
-*/
+
+  for(uint32_t i=0; i<64; i++)
+  {
+    SWDWriteBit(true);
+  }
+
+  SWDWord(0x6DB7);
+
+  for(uint32_t i=0; i<64; i++)
+  {
+    SWDWriteBit(true);
+  }
+
+  SWDIdle();
+
   //READ IDCODE, hopefully..
   Serial.println(SWDTransaction(false, true, 0, 0), HEX);
 }


update

--- esp8266/sparc_esp8266_node_callback/sparc_esp8266_node_callback.ino
+++ esp8266/sparc_esp8266_node_callback/sparc_esp8266_node_callback.ino
@@ -84,23 +84,11 @@
     if (client.connect(clientId.c_str())) {
       Serial.println("connected");
       // Once connected, publish an announcement...
-      float h = dht.readHumidity();
-      float t = dht.readTemperature();
-       if (isnan(h) || isnan(t)) {
-      Serial.println("Failed to read from DHT sensor!");
-      return;
-      }
-      float hic = dht.computeHeatIndex(t, h, false);
-
-      Serial.println(h);
-      Serial.println(t);
-      int h2 = (int) h;
-      int t2 = (int) t;

       char data[190];

       String payload = "{\"type\": \"Temperature Humidity Sensor\",\"name\": \"demo\", \"serial_number\": "+ serial_number +", \"location\": \"demo\",\"info\":{ \"humidity\":\"float\",\"temperature\":\"float\" }";
-      //String payload = "Hej";
+
       payload.toCharArray(data, (payload.length() + 1));
       Serial.println(payload);
       Serial.println(payload.length());
@@ -140,17 +128,18 @@
   long now = millis();
   if (now - lastMsg > 2000) {
     lastMsg = now;
+
     float h = dht.readHumidity();
     float t = dht.readTemperature();

     char data[150];

     String payload = "{\"ts\":" + (String)millis() +",\"serial_number\": "+ serial_number +",\"values\":{\"temperature\": "+ (String)t +",\"humidity\": "+(String)h+"}} ";
-    //String payload = "hej";
+
     payload.toCharArray(data, (payload.length() + 1));
     Serial.print("Publish message: ");
     Serial.println(payload.length());
-    client.publish(topic_info, data);
+    client.publish(info_topic, data);
     Serial.println(payload);
   }
 }


Update Arduino_Serial_USB.ino

Update Arduino_Serial_USB.ino

--- examples/BoardsAndShields/Arduino_Serial_USB/Arduino_Serial_USB.ino
+++ examples/BoardsAndShields/Arduino_Serial_USB/Arduino_Serial_USB.ino
@@ -35,7 +35,7 @@
  *
  *      for Linux and OSX:
  *
- *                    ./blynk-ser.sh (may need to run with sudo)
+ *                    bash ./blynk-ser.sh (may need to run with sudo)
  *
  *    You can specify port, baud rate, and server endpoint like this:
  *      ./blynk-ser.sh -c <serial port> -b <baud rate> -s <server address> -p <server port>


Tidy code

Tidy code

--- wcci/esp_at.ino
+++ wcci/esp_at.ino
@@ -3,160 +3,104 @@
 bool sendATCipClose() {
   bool res = false;

-
   Serial.println("AT+CIPCLOSE");
   // listen for response
-    if (Serial.find("OK")) {
-
-      res = true;
-
-    } else {
-
-    }
-
+  if (Serial.find("OK")) {
+    res = true;
+  } else { }
   return res;
 }

 bool sendATUnlockDoor() {
     bool res = false;
-    String url_path = "GET /log_visit_state/0 HTTP/1.0\r\n\r\n";
+    String url_path = "GET /log_visit_state/0 HTTP/1.1\r\n\r\n";

   Serial.println(url_path);
   // listen for response
     if (Serial.find("OK")) {
-
       res = true;
-
-    } else {
-
-    }
-
-
+    } else { }
   return res;
 }

 bool sendATPrepareUnlockDoor() {
-    bool res = false;
-    String url_path = "GET /log_visit_state/0 HTTP/1.0\r\n\r\n";
+  bool res = false;
+  String url_path = "GET /log_visit_state/0 HTTP/1.1\r\n\r\n";

   Serial.print("AT+CIPSEND=4,");
   Serial.println(url_path.length());
   // listen for response
-    if (Serial.find(">")) {
-
-      res = true;
-
-    } else {
-
-    }
-
-
+  if (Serial.find(">")) {
+    res = true;
+  } else { }
   return res;
 }

-
 bool sendATLockDoor() {
     bool res = false;
-    String url_path = "GET /log_visit_state/1 HTTP/1.0\r\n\r\n";
+    String url_path = "GET /log_visit_state/1 HTTP/1.1\r\n\r\n";

   Serial.println(url_path);
   // listen for response
-    if (Serial.find("OK")) {
-
-      res = true;
-
-    } else {
-
-    }
-
-
+  if (Serial.find("OK")) {
+    res = true;
+    } else { }
   return res;
 }

-
 bool sendATPrepareLockDoor() {
-    bool res = false;
-    String url_path = "GET /log_visit_state/1 HTTP/1.0\r\n\r\n";
+  bool res = false;
+  String url_path = "GET /log_visit_state/1 HTTP/1.1\r\n\r\n";

   Serial.print("AT+CIPSEND=4,");
   Serial.println(url_path.length());
   // listen for response
-    if (Serial.find(">")) {
-
-      res = true;
-
-    } else {
-
-    }
-
-
+  if (Serial.find(">")) {
+    res = true;
+  } else { }
   return res;
 }

 bool sendATConnectServer() {
   bool res = false;

-  Serial.println("AT+CIPSTART=4,\"TCP\",\"10.225.56.58\",3000");
+  Serial.println("AT+CIPSTART=4,\"TCP\",\"10.225.56.65\",3000");
   // listen for response
-    if (Serial.find("OK")) {
-
-      res = true;
-
-    } else {
-
-    }
-
-
+  if (Serial.find("OK")) {
+    res = true;
+  } else { }
   return res;
 }

 bool sendATMultipleConnections() {
-
   bool res = false;
-
   Serial.println("AT+CIPMUX=1");
-
-
   // listen for response
-    if (Serial.find("OK")) {
-
-      res = true;
-
-    } else {
-
-    }
+  if (Serial.find("OK")) {
+    res = true;
+  } else { }
   return res;
 }

 bool sendATJoinNetwork() {
   bool res = false;
-//  String SSID = "";
+  //  String SSID = "";
   Serial.println("AT+CWJAP=" + SSID + "," + PWD );
   // listen for response
-    if (Serial.find("OK")) {
-
-      res = true;
-
-    } else {
-
-    }
-
+  if (Serial.find("OK")) {
+    res = true;
+  } else { }
   return res;
 }

 bool sendATModeStation() {
   bool res = false;
-  Serial.println("AT+CWMODE=3");
-
-
+  Serial.println("AT+CWMODE=1");
   // listen for response
-    if (Serial.find("OK")) {
-
-      res = true;
-
-    }
-
+  if (Serial.find("OK")) {
+    res = true;
+  } else {}
   return res;
 }

@@ -165,11 +109,11 @@
   Serial.println("AT+RST");

   // listen for response
-    if (Serial.find("ready")) {
-      res = true;
-    }
-    delay(500);
-    return res;
+  if (Serial.find("ready")) {
+    res = true;
+  }
+  delay(500);
+  return res;
 }

@@ -181,23 +125,3 @@
   return false;
 }

-/*
-void blink() {
-        digitalWrite(GREEN, HIGH);
-        digitalWrite(YELLOW, HIGH);
-        digitalWrite(RED, HIGH);
-        delay(500);
-        digitalWrite(GREEN, LOW);
-        digitalWrite(YELLOW, LOW);
-        digitalWrite(RED, LOW);
-        delay(500);
-        digitalWrite(GREEN, HIGH);
-        digitalWrite(YELLOW, HIGH);
-        digitalWrite(RED, HIGH);
-        delay(500);
-        digitalWrite(GREEN, LOW);
-        digitalWrite(YELLOW, LOW);
-        digitalWrite(RED, LOW);
-        delay(500);
-}
-*/


adds comment to esp8266 demo

adds comment to esp8266 demo

--- examples/esp8266Example/esp8266Example.ino
+++ examples/esp8266Example/esp8266Example.ino
@@ -23,6 +23,8 @@
   4. Upload the sketch

   ### Troubleshooting
+
+  for PIN layout on the NodeMCU, check: https://github.com/esp8266/Arduino/blob/master/doc/boards.md#nodemcu-1-0

 */


Update mech.ino

Update mech.ino

--- mech/mech.ino
+++ mech/mech.ino
@@ -162,6 +162,14 @@
   yeld();
   uint16_t prevSetepPwr = rflPwrPercent;
   while (step != 0) {
+    if ((fwdPwrVal >> 4) == 0) {
+      dprintf("optimize() - aborting due power conditions.\n");
+      break;
+    }
+     if ((rflPwrVal >> 4) == 0) {
+      dprintf("optimize() - aborting due rflPwrVal precision.\n");
+      break;
+    }
     chanel->move(step);
     yeld();
     if (prevSetepPwr < (rflPwrPercent + hysteresis)) {
@@ -173,10 +181,6 @@
       }
     }
     prevSetepPwr = rflPwrPercent;
-    if (((fwdPwrVal >> 4) == 0) || ((rflPwrVal >> 4) == 0)) {
-      dprintf("optimize() - aborting due power conditions\n");
-      break;
-    }
     stepCount++;
   }
   dprintf("optimize() - finished in %d step(s)\n", stepCount);


Modem loop fix, cleanup.

Modem loop fix, cleanup.

--- MicroView/WiFiModem-Menu/WiFiModem-Menu.ino
+++ MicroView/WiFiModem-Menu/WiFiModem-Menu.ino
@@ -46,7 +46,7 @@

 ;  // Keep this here to pacify the Arduino pre-processor

-#define VERSION "0.12b2"
+#define VERSION "0.12b3"

 unsigned int BAUD_RATE=2400;
 unsigned int WiFly_BAUD_RATE=2400;
@@ -171,7 +171,7 @@
 #define TIMEDOUT  -1
 boolean baudMismatch = (BAUD_RATE != WiFly_BAUD_RATE ? 1 : 0);
 boolean Modem_flowControl = false;   // for &K setting.
-boolean Modem_isDcdInverted = true;
+boolean Modem_isDcdInverted = true;             // Normally true on the C64.  False for commodoreserver 38,400.
 boolean Modem_DCDFollowsRemoteCarrier = false;    // &C
 byte    Modem_dataSetReady = 0;         // &S
 int WiFlyLocalPort = 0;
@@ -1548,8 +1548,9 @@
         C64Serial.print(F("OK"));
         C64Serial.println();
     }
-
-    Modem_Loop();
+
+    while (true)
+        Modem_Loop();
 }

@@ -2427,13 +2428,154 @@
     }
 }

-void Modem_ProcessData()
-{
-    while (C64Serial.available() >0)
+void Modem_Answer()
+{
+    if (!Modem_isRinging)    // If not actually ringing...
+    {
+        Modem_Disconnect(true);  // This prints "NO CARRIER"
+        return;
+    }
+
+    Modem_Connected(true);
+}
+
+// Main processing loop for the virtual modem.  Needs refactoring!
+void Modem_Loop()
+{
+    // Modem to C64 flow
+    boolean wiflyIsConnected = wifly.isConnected();
+
+    if (wiflyIsConnected && commodoreServer38k)
+    {
+        while (wifly.available() > 0)
+        {
+            DoFlowControlModemToC64();
+            C64Serial.write(wifly.read());
+        }
+    }
+    else
+    {
+        if (wiflyIsConnected) {
+            // Check for new remote connection
+            if (!Modem_isConnected && !Modem_isRinging)
+            {
+                //wifly.println(F("CONNECTING..."));
+
+                Display(F("INCOMING\nCALL"));
+                Modem_Ring();
+                return;
+            }
+
+            // If connected, handle incoming data
+            if (Modem_isConnected)
+            {
+                // Echo an error back to remote terminal if in command mode.
+                if (Modem_isCommandMode && wifly.available() > 0)
+                {
+                    // If we print this, remote end gets flooded with this message
+                    // if we go to command mode on the C64 and remote side sends something..
+                    //wifly.println(F("error: remote modem is in command mode."));
+                }
+                else
+                {
+                    int data;
+
+                    // Buffer for 1200 baud
+                    char buffer[10];
+                    int buffer_index = 0;
+
+                    {
+                        while (wifly.available() > 0)
+                        {
+                            int data = wifly.read();
+
+                            // If first character back from remote side is NVT_IAC, we have a telnet connection.
+                            if (isFirstChar) {
+                                if (data == NVT_IAC)
+                                {
+                                    isTelnet = true;
+                                    CheckTelnetInline();
+                                }
+                                else
+                                {
+                                    isTelnet = false;
+                                }
+                                isFirstChar = false;
+                            }
+                            else
+                            {
+                                if (data == NVT_IAC && isTelnet)
+                                {
+                                    if (baudMismatch)
+                                    {
+                                        digitalWriteFast(WIFI_CTS, LOW);        // re-enable data
+                                        if (CheckTelnetInline())
+                                            buffer[buffer_index++] = NVT_IAC;
+                                        digitalWriteFast(WIFI_CTS, HIGH);     // ..stop data from Wi-Fi
+                                    }
+                                    else
+                                    {
+                                        if (CheckTelnetInline())
+                                            C64Serial.write(NVT_IAC);
+                                    }
+
+                                }
+                                else
+                                {
+                                    if (baudMismatch)
+                                    {
+                                        digitalWriteFast(WIFI_CTS, HIGH);     // ..stop data from Wi-Fi
+                                        buffer[buffer_index++] = data;
+                                    }
+                                    else
+                                    {
+                                        DoFlowControlModemToC64();
+                                        C64Serial.write(data);
+                                    }
+                                }
+                            }
+                        }
+                        if (baudMismatch)
+                        {
+                            // Dump the buffer to the C64 before clearing WIFI_CTS
+                            if (buffer_index > 8)
+                                buffer_index = 8;
+                            for (int i = 0; i < buffer_index; i++) {
+                                C64Serial.write(buffer[i]);
+                            }
+                            buffer_index = 0;
+
+                            digitalWriteFast(WIFI_CTS, LOW);
+                        }
+                    }
+                }
+            }
+        }
+        else  // !wiflyIsConnected
+        {
+            // Check for a dropped remote connection while ringing
+            if (Modem_isRinging)
+            {
+                Modem_Disconnect(true);
+                return;
+            }
+
+            // Check for a dropped remote connection while connected
+            if (Modem_isConnected)
+            {
+                Modem_Disconnect(true);
+                return;
+            }
+        }
+    }
+
+    // C64 to Modem flow
+    //Modem_ProcessData();
+    while (C64Serial.available() > 0)
     {
         if (commodoreServer38k)
         {
-            //DoFlowControlC64ToModem();
+            DoFlowControlC64ToModem();

             wifly.write(C64Serial.read());
         }
@@ -2447,8 +2589,8 @@

                 if (Modem_flowControl)
                 {
-                    digitalWriteFast(C64_CTS, (Modem_isCtsRtsInverted ? LOW : HIGH));
-                    //digitalWriteFast(C64_CTS, LOW);
+                    // Tell the C64 to stop
+                    digitalWriteFast(C64_CTS, (Modem_isCtsRtsInverted ? LOW : HIGH));       // Stop
                 }
                 //char inbound = toupper(_serial->read());
                 char inbound = C64Serial.read();
@@ -2460,14 +2602,14 @@
                 PET AT = OK
                 */
                 /*if ((inbound >= 0xc1) && (inbound <= 0xda))
-                    petscii_char = true;
+                petscii_char = true;
                 inbound = charset_p_toascii_upper_only(inbound);

                 if (inbound == 0)
-                    return;*/
-
-
-                    // Block non-ASCII/PETSCII characters
+                return;*/
+
+
+                // Block non-ASCII/PETSCII characters
                 unsignedInbound = (unsigned char)inbound;

                 // Do not delete this.  Used for troubleshooting...
@@ -2487,8 +2629,8 @@
                 {
                     if (!Modem_flowControl)
                         delay(100 / ((BAUD_RATE >= 2400 ? BAUD_RATE : 2400) / 2400));     // Slow down command mode to prevent garbage if flow control
-                                                             // is disabled.  Doesn't work at 9600 but flow control should
-                                                             // be on at 9600 baud anyways.  TODO:  Fix
+                                                                                // is disabled.  Doesn't work at 9600 but flow control should
+                                                                                // be on at 9600 baud anyways.  TODO:  Fix
                     C64Serial.write(inbound);
                 }

@@ -2547,7 +2689,7 @@
                             strcpy(Modem_CommandBuffer, Modem_LastCommandBuffer);
                             if (Modem_flowControl)
                             {
-                                digitalWriteFast(C64_CTS, (Modem_isCtsRtsInverted ? HIGH : LOW));
+                                digitalWriteFast(C64_CTS, (Modem_isCtsRtsInverted ? HIGH : LOW));       // Go
                             }
                             Modem_ProcessCommandBuffer();
                             Modem_ResetCommandBuffer();  // To prevent A matching with A/ again
@@ -2559,7 +2701,7 @@
                 {
                     if (Modem_flowControl)
                     {
-                        digitalWriteFast(C64_CTS, (Modem_isCtsRtsInverted ? HIGH : LOW));
+                        digitalWriteFast(C64_CTS, (Modem_isCtsRtsInverted ? HIGH : LOW));       // Go
                     }
                     Modem_ProcessCommandBuffer();
                 }
@@ -2626,361 +2768,12 @@
             }
         }
     }
-    if (Modem_flowControl && !commodoreServer38k)
-    {
-        digitalWriteFast(C64_CTS, (Modem_isCtsRtsInverted ? HIGH : LOW));
-    }
-}
-
-void Modem_Answer()
-{
-    if (!Modem_isRinging)    // If not actually ringing...
-    {
-        Modem_Disconnect(true);  // This prints "NO CARRIER"
-        return;
-    }
-
-    Modem_Connected(true);
-}
-
-// Main processing loop for the virtual modem.  Needs refactoring!
-void Modem_Loop()
-{
-    while (true)
-    {
-        // Modem to C64 flow
-        boolean wiflyIsConnected = wifly.isConnected();
-
-        if (wiflyIsConnected && commodoreServer38k)
-        {
-            while (wifly.available() > 0)
-            {
-                DoFlowControlModemToC64();
-                C64Serial.write(wifly.read());
-            }
-        }
-        else
-        {
-            if (wiflyIsConnected) {
-                // Check for new remote connection
-                if (!Modem_isConnected && !Modem_isRinging)
-                {
-                    //wifly.println(F("CONNECTING..."));
-
-                    Display(F("INCOMING\nCALL"));
-                    Modem_Ring();
-                    return;
-                }
-
-                // If connected, handle incoming data
-                if (Modem_isConnected)
-                {
-                    // Echo an error back to remote terminal if in command mode.
-                    if (Modem_isCommandMode && wifly.available() > 0)
-                    {
-                        // If we print this, remote end gets flooded with this message
-                        // if we go to command mode on the C64 and remote side sends something..
-                        //wifly.println(F("error: remote modem is in command mode."));
-                    }
-                    else
-                    {
-                        int data;
-
-                        // Buffer for 1200 baud
-                        char buffer[10];
-                        int buffer_index = 0;
-
-                        {
-                            while (wifly.available() > 0)
-                            {
-                                int data = wifly.read();
-
-                                // If first character back from remote side is NVT_IAC, we have a telnet connection.
-                                if (isFirstChar) {
-                                    if (data == NVT_IAC)
-                                    {
-                                        isTelnet = true;
-                                        CheckTelnetInline();
-                                    }
-                                    else
-                                    {
-                                        isTelnet = false;
-                                    }
-                                    isFirstChar = false;
-                                }
-                                else
-                                {
-                                    if (data == NVT_IAC && isTelnet)
-                                    {
-                                        if (baudMismatch)
-                                        {
-                                            digitalWriteFast(WIFI_CTS, LOW);        // re-enable data
-                                            if (CheckTelnetInline())
-                                                buffer[buffer_index++] = NVT_IAC;
-                                            digitalWriteFast(WIFI_CTS, HIGH);     // ..stop data from Wi-Fi
-                                        }
-                                        else
-                                        {
-                                            if (CheckTelnetInline())
-                                                C64Serial.write(NVT_IAC);
-                                        }
-
-                                    }
-                                    else
-                                    {
-                                        if (baudMismatch)
-                                        {
-                                            digitalWriteFast(WIFI_CTS, HIGH);     // ..stop data from Wi-Fi
-                                            buffer[buffer_index++] = data;
-                                        }
-                                        else
-                                        {
-                                            DoFlowControlModemToC64();
-                                            C64Serial.write(data);
-                                        }
-                                    }
-                                }
-                            }
-                            if (baudMismatch)
-                            {
-                                // Dump the buffer to the C64 before clearing WIFI_CTS
-                                if (buffer_index > 8)
-                                    buffer_index = 8;
-                                for (int i = 0; i < buffer_index; i++) {
-                                    C64Serial.write(buffer[i]);
-                                }
-                                buffer_index = 0;
-
-                                digitalWriteFast(WIFI_CTS, LOW);
-                            }
-                        }
-                    }
-                }
-            }
-            else  // !wiflyIsConnected
-            {
-                // Check for a dropped remote connection while ringing
-                if (Modem_isRinging)
-                {
-                    Modem_Disconnect(true);
-                    return;
-                }
-
-                // Check for a dropped remote connection while connected
-                if (Modem_isConnected)
-                {
-                    Modem_Disconnect(true);
-                    return;
-                }
-            }
-        }
-
-        // C64 to Modem flow
-        //Modem_ProcessData();
-        while (C64Serial.available() > 0)
-        {
-            if (commodoreServer38k)
-            {
-                DoFlowControlC64ToModem();
-
-                wifly.write(C64Serial.read());
-            }
-            else
-            {
-                // Command Mode -----------------------------------------------------------------------
-                if (Modem_isCommandMode)
-                {
-                    unsigned char unsignedInbound;
-                    //boolean petscii_char;
-
-                    if (Modem_flowControl)
-                    {
-                        // Tell the C64 to stop
-                        digitalWriteFast(C64_CTS, (Modem_isCtsRtsInverted ? LOW : HIGH));       // Stop
-                    }
-                    //char inbound = toupper(_serial->read());
-                    char inbound = C64Serial.read();
-                    // C64 PETSCII terminal programs send lower case 0x41-0x5a, upper case as 0xc1-0xda
-                    /* Real modem:
-                    ASCII at = OK
-                    ASCII AT = OK
-                    PET at = ok
-                    PET AT = OK
-                    */
-                    /*if ((inbound >= 0xc1) && (inbound <= 0xda))
-                    petscii_char = true;
-                    inbound = charset_p_toascii_upper_only(inbound);
-
-                    if (inbound == 0)
-                    return;*/
-
-
-                    // Block non-ASCII/PETSCII characters
-                    unsignedInbound = (unsigned char)inbound;
-
-                    // Do not delete this.  Used for troubleshooting...
-                    //char temp[5];
-                    //sprintf(temp, "-%d-",unsignedInbound);
-                    //C64Serial.write(temp);
-
-                    if (unsignedInbound == 0x08 || unsignedInbound == 0x0a || unsignedInbound == 0x0d || unsignedInbound == 0x14) {}  // backspace, LF, CR, C= Delete
-                    else if (unsignedInbound <= 0x1f)
-                        break;
-                    else if (unsignedInbound >= 0x80 && unsignedInbound <= 0xc0)
-                        break;
-                    else if (unsignedInbound >= 0xdb)
-                        break;
-
-                    if (Modem_EchoOn)
-                    {
-                        if (!Modem_flowControl)
-                            delay(100 / ((BAUD_RATE >= 2400 ? BAUD_RATE : 2400) / 2400));     // Slow down command mode to prevent garbage if flow control
-                                                                                // is disabled.  Doesn't work at 9600 but flow control should
-                                                                                // be on at 9600 baud anyways.  TODO:  Fix
-                        C64Serial.write(inbound);
-                    }
-
-                    if (IsBackSpace(inbound))
-                    {
-                        if (strlen(Modem_CommandBuffer) > 0)
-                        {
-                            Modem_CommandBuffer[strlen(Modem_CommandBuffer) - 1] = '\0';
-                        }
-                    }
-                    //else if (inbound != '\r' && inbound != '\n' && inbound != Modem_S2_EscapeCharacter)
-                    else if (inbound != '\r' && inbound != '\n')
-                    {
-                        if (strlen(Modem_CommandBuffer) >= COMMAND_BUFFER_SIZE) {
-                            //Display (F("CMD Buf Overflow"));
-                            Modem_PrintERROR();
-                            Modem_ResetCommandBuffer();
-                        }
-                        else {
-                            // TODO:  Move to Modem_ProcessCommandBuffer?
-                            if (Modem_AT_Detected)
-                            {
-                                Modem_CommandBuffer[strlen(Modem_CommandBuffer)] = inbound;
-                            }
-                            else
-                            {
-                                switch (strlen(Modem_CommandBuffer))
-                                {
-                                case 0:
-                                    switch (unsignedInbound)
-                                    {
-                                    case 'A':
-                                    case 'a':
-                                    case 0xC1:
-                                        Modem_CommandBuffer[strlen(Modem_CommandBuffer)] = inbound;
-                                        break;
-                                    }
-                                    break;
-                                case 1:
-                                    switch (unsignedInbound)
-                                    {
-                                    case 'T':
-                                    case 't':
-                                    case '/':
-                                    case 0xD4:
-                                        Modem_CommandBuffer[strlen(Modem_CommandBuffer)] = inbound;
-                                        Modem_AT_Detected = true;
-                                        break;
-                                    }
-                                    break;
-                                }
-                            }
-
-                            if (toupper(charset_p_toascii_upper_only(Modem_CommandBuffer[0])) == 'A' && (Modem_CommandBuffer[1] == '/'))
-                            {
-                                strcpy(Modem_CommandBuffer, Modem_LastCommandBuffer);
-                                if (Modem_flowControl)
-                                {
-                                    digitalWriteFast(C64_CTS, (Modem_isCtsRtsInverted ? HIGH : LOW));       // Go
-                                }
-                                Modem_ProcessCommandBuffer();
-                                Modem_ResetCommandBuffer();  // To prevent A matching with A/ again
-                            }
-                        }
-                    }
-                    // It was a '\r' or '\n'
-                    else if (toupper(charset_p_toascii_upper_only(Modem_CommandBuffer[0])) == 'A' && toupper(charset_p_toascii_upper_only(Modem_CommandBuffer[1])) == 'T')
-                    {
-                        if (Modem_flowControl)
-                        {
-                            digitalWriteFast(C64_CTS, (Modem_isCtsRtsInverted ? HIGH : LOW));       // Go
-                        }
-                        Modem_ProcessCommandBuffer();
-                    }
-                    else
-                    {
-                        Modem_ResetCommandBuffer();
-                    }
-                }
-
-                else    // Online ------------------------------------------
-                {
-                    if (Modem_isConnected)
-                    {
-                        char C64input = C64Serial.read();
-
-                        // +++ escape
-                        if (Modem_S2_EscapeCharacter < 128) // 128-255 disables escape sequence
-                        {
-                            if ((millis() - ESCAPE_GUARD_TIME) > escapeTimer)
-                            {
-                                if (C64input == Modem_S2_EscapeCharacter && lastC64input != Modem_S2_EscapeCharacter)
-                                {
-                                    escapeCount = 1;
-                                    lastC64input = C64input;
-                                }
-                                else if (C64input == Modem_S2_EscapeCharacter && lastC64input == Modem_S2_EscapeCharacter)
-                                {
-                                    escapeCount++;
-                                    lastC64input = C64input;
-                                }
-                                else
-                                {
-                                    escapeCount = 0;
-                                    escapeTimer = millis();   // Last time non + data was read
-                                }
-                            }
-                            else
-                            {
-                                escapeTimer = millis();   // Last time data was read
-                            }
-
-
-                            if (escapeCount == 3) {
-                                Display("Escape!");
-                                escapeReceived = true;
-                                escapeCount = 0;
-                                escapeTimer = 0;
-                                Modem_isCommandMode = true;
-                                C64Println();
-                                Modem_PrintOK();
-                            }
-                        }
-
-                        lastC64input = C64input;
-
-                        DoFlowControlC64ToModem();
-
-                        // If we are in telnet binary mode, write and extra 255 byte to escape NVT
-                        if ((unsigned char)C64input == NVT_IAC && telnetBinaryMode)
-                            wifly.write(NVT_IAC);
-
-                        int result = wifly.write(C64input);
-                    }
-                }
-            }
-        }
-        if (Modem_flowControl)
-        {
-            digitalWriteFast(C64_CTS, (Modem_isCtsRtsInverted ? HIGH : LOW));       // Go
-        }
-
-        //digitalWrite(DCE_RTS, HIGH);
-    }
+    if (Modem_flowControl)
+    {
+        digitalWriteFast(C64_CTS, (Modem_isCtsRtsInverted ? HIGH : LOW));       // Go
+    }
+
+    //digitalWrite(DCE_RTS, HIGH);
 }

 #endif // HAYES
@@ -3268,8 +3061,12 @@
                 digitalWriteFast(C64_DSR, LOW);
             }
             break;
-        }
-
+        }
+    }
+    else
+    {
+        pinModeFast(C64_DSR, INPUT);    // Set as input to make sure it doesn't interfere with UP9600.
+                                        // Some computers have issues with 100 ohm resistor pack
     }
 }


adding features for BT to connect Glass

adding features for BT to connect Glass

--- glass/glass.ino
+++ glass/glass.ino
@@ -42,6 +42,7 @@
 int ir_current_rssi = 0;
 char current_id[03] = "00";
 bool is_increase_available = false;
+bool is_connected = false;
 char message[20];
 unsigned long start_time;
 boolean isWaitingReply;
@@ -76,7 +77,8 @@
 }

 void loop() {
-  if(ir_bcast_mode){
+  // in IR broadcast mode, we keep sending IR signal and hover the one with largeste intensity reading
+  if (ir_bcast_mode) {
     // constantly sending out ir broadcast as visual cue
     Serial.println(ir_time);
     if(millis() - ir_time > ir_cycle) {
@@ -97,7 +99,6 @@
       }
     }

-    delay(10);
     if (XBee.available()) {
       delay(10);
       while (XBee.available()) {
@@ -116,7 +117,24 @@
 	}
       }
     }
+    if (BT.available()) {
+      delay(10);
+      DEBUG_PRINT("[BT]: ");
+      readStringfromSerial(&BT, message);
+      // if it's LIST command, then list all available devices by sending IR
+      if ( message[0] == 'F' && message[1] == 'F') {
+	// return currentId
+	BT.println(currentId);
+      }
+      is_connected = true;
+      ir_bcast_mode = false;
+    }
   }
+  else { // if(ir_bcast_mode){
+    // this is the place when we only have a single connection with one device
+    // TODO: implement later
+  }
+
 }

 boolean isPacketValid(char *message) {


reverted changes to lcd sample

reverted changes to lcd sample

--- code/arduino/sample/LCD_sample/LCD_sample.ino
+++ code/arduino/sample/LCD_sample/LCD_sample.ino
@@ -5,7 +5,7 @@

 #include <LiquidCrystal.h>
 //pin 8to13 used for interfacing via sheild
-LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
+LiquidCrystal lcd(8, 9, 10, 11, 12, 13);

 int backLight = 13;    // pin 13 will control the backlight


Updated ZStabalization

Updated ZStabalization

--- ZstabalizationTest1/ZstabalizationTest1.ino
+++ ZstabalizationTest1/ZstabalizationTest1.ino
@@ -5,6 +5,7 @@

 void setup() {

+  //pinMode(##buttonPin##, INPUT);
   Serial.begin(9600);

   Serial.println("Starting");
@@ -13,11 +14,13 @@

   sensor.init();

-  sensor.setFluidDensity(997); // kg/m^3 (997 freshwater, 1029 for seawater)
+  sensor.setFluidDensity(1001); // kg/m^3 (997 freshwater, 1029 for seawater)
 }

 void loop() {

+  //float depthSavedState = 0;
+  //bool lockedZ = false;
   sensor.read();

   Serial.print("Pressure: ");
@@ -30,14 +33,39 @@

   Serial.print("Depth: ");
   Serial.print(sensor.depth());
-  Serial.println(" m");
+  Serial.println(" m deep");

   Serial.print("Altitude: ");
   Serial.print(sensor.altitude());
   Serial.println(" m above mean sea level");

+  /*
+  buttonState = digitalRead(##buttonPin##);
+  // if putton pressed, ACTIVATE Z
+  if(buttonState == HIGH && !lockedZ){
+    depthSavedState = sensor.depth();
+    lockedZ = true;
+  }
+  // if putton pressed, DEACTIVATE Z
+  if(buttonState == HIGH && lockedZ){
+    depthSavedState = sensor.depth();
+    lockedZ = false;
+  }
+    // if Z STABLAIZATION = ACTIVE
+    while(lockedZ){
+    // if ROV is above saved state
+      if(sensor.depth() > depthSavedState){
+          // Move ROV DOWN
+      }
+    // if ROV is below saved state
+      if(sensor.depth() < depthSavedState){
+          // Move ROV UP
+      }
+
+    }
+
+
+*/
+
   delay(1000);
 }
-
-
-


Use explicit cast to avoid compiler errors

--- examples/ttn-otaa-network-time/ttn-otaa-network-time.ino
+++ examples/ttn-otaa-network-time/ttn-otaa-network-time.ino
@@ -199,7 +199,9 @@
     Serial.print(digits);
 }

-void user_request_network_time_callback(uint32_t *pUserUTCTime, int flagSuccess) {
+void user_request_network_time_callback(void *pVoidUserUTCTime, int flagSuccess) {
+    // Explicit convertion from void* to uint32_t* to avoid compiler errors
+    uint32_t *pUserUTCTime = (uint32_t *) pVoidUserUTCTime;

     // A struct that will be populated by LMIC_getNetworkTimeReference.
     // It contains the following fields:


Typos fixed

Typos fixed

--- src/BLuB.ino
+++ src/BLuB.ino
@@ -75,7 +75,7 @@
 	Serial.println( "Available commands:" );
 	//                   ------- ------- ------- ------- -------
 	Serial.println( "    help    mem     new" );
-	Serial.println( "    elist   eload   esave   eformat" );
+	Serial.println( "    elist   eload   esave   enew" );
 	//                   ------- ------- ------- ------- -------
 }

@@ -125,16 +125,16 @@

-void cmd_eformat( void )
-{
-  Serial.print( "Formatting EEPROM..." );
+void cmd_enew( void )
+{
+  Serial.print( "Formatting EEPROM " );
   for( int i=0 ; i<kEESize ; i++ )
   {
     EEPROM.write( i, 0x00 );
 //    digitalWrite( kLED, i & 0x020 );
     if( i%64 == 0 ) Serial.print( "." );
   }
-  Serial.println( "...DONE!" );
+  Serial.println( " Done." );
 }

 void cmd_elist( void )
@@ -210,9 +210,11 @@

 	// process it
 	if( !strcmp( linebuf, "mem" )) { cmd_mem(); }
+
 	else if( !strcmp( linebuf, "new" )) { cmd_new(); }
 	else if( !strcmp( linebuf, "list" )) { cmd_list(); }
-	else if( !strcmp( linebuf, "eformat" )) { cmd_eformat(); }
+
+	else if( !strcmp( linebuf, "enew" )) { cmd_enew(); }
 	else if( !strcmp( linebuf, "elist" )) { cmd_elist(); }
 	else if( !strcmp( linebuf, "eload" )) { cmd_eload(); }
 	else if( !strcmp( linebuf, "esave" )) { cmd_esave(); }


HTML開始タグ追加

HTML開始タグ追加

--- 2_example/example33b_led/example33b_led.ino
+++ 2_example/example33b_led/example33b_led.ino
@@ -72,8 +72,9 @@
             "LED=%01d
LED ON ,http://%d.%d.%d.%d/L1
",
             digitalRead(PIN_LED),ip[0],ip[1],ip[2],ip[3]);
         client.print("Content-Length: ");   // HTTPヘッダ情報を出力
-        client.println(strlen(s)*2-10+2);   // コンテンツ長さを出力(改行2バイト)
+        client.println(15+strlen(s)*2-9+2); // コンテンツ長さを出力(改行2バイト)
         client.println();                   // HTTPヘッダの終了を出力
+        client.println("");           // HTML開始タグを出力(IE以外で必要)
         client.println(s);                  // HTTPコンテンツを出力
         Serial.println(s);                  // シリアルへコンテンツを出力
         sprintf(s,
@@ -81,6 +82,7 @@
             ip[0],ip[1],ip[2],ip[3]);
         client.println(s);                  // HTTPコンテンツを出力
         Serial.println(s);                  // シリアルへコンテンツを出力
+        client.println("");          // HTML終了タグを出力(IE以外で必要)
     }
     client.stop();                          // クライアントの切断
     Serial.println("Disconnected");         // シリアル出力表示


Correctred menu bug

Correctred menu bug

--- src/cyclop_plus_plus/cyclop_plus_plus.ino
+++ src/cyclop_plus_plus/cyclop_plus_plus.ino
@@ -1113,19 +1113,19 @@
   osd_string(" Exit            ");

   osd(CMD_SET_X, XPOS);
-  osd(CMD_SET_Y, YPOS);
+  osd(CMD_SET_Y, YPOS+1);
   function == 1 ? osd(CMD_ENABLE_INVERSE) : osd(CMD_DISABLE_INVERSE);
   function == 1 ? osd(CMD_ENABLE_FILL) : osd(CMD_DISABLE_FILL);
   osd_string(" Graphic Scanner ");

   osd(CMD_SET_X, XPOS);
-  osd(CMD_SET_Y, YPOS);
+  osd(CMD_SET_Y, YPOS+2);
   function == 2 ? osd(CMD_ENABLE_INVERSE) : osd(CMD_DISABLE_INVERSE);
   function == 2 ? osd(CMD_ENABLE_FILL) : osd(CMD_DISABLE_FILL);
   osd_string(" Auto Scanner    ");

   osd(CMD_SET_X, XPOS);
-  osd(CMD_SET_Y, YPOS);
+  osd(CMD_SET_Y, YPOS+3);
   function == 3 ? osd(CMD_ENABLE_INVERSE) : osd(CMD_DISABLE_INVERSE);
   function == 3 ? osd(CMD_ENABLE_FILL) : osd(CMD_DISABLE_FILL);
   osd_string(" Options         ");