diff --git a/FactoryTest/FactoryTest.ino b/FactoryTest/FactoryTest.ino index 737087b..a3c815d 100644 --- a/FactoryTest/FactoryTest.ino +++ b/FactoryTest/FactoryTest.ino @@ -711,9 +711,11 @@ { // RTC sync from NTP // Wifi → NTP → update RTC → WifiOff + wifi_down(); if (wifi_setup()) ntp_setup(); wifi_down(); + M5.delay(100); Init_ESPNOW(); // ESPNOWの初期化 @@ -767,18 +769,19 @@ void DisplayQRCode() { - while ((!M5.BtnA.isPressed()) /*&& (!M5.BtnB.isPressed())*/ ) + while ((!M5.BtnA.isPressed()) /*&& (!M5.BtnB.isPressed())*/) { // M5.Display.fillRect(0, 0, 240, 135, TFT_BLACK); // M5.Display.qrcode("https://istlab.info", 20, 20, 120); Disbuff.fillRect(0, 0, 240, 135, TFT_WHITE); Disbuff.setFont(&fonts::lgfxJapanGothic_16); - Disbuff.setCursor(0,5); + Disbuff.setTextSize(1); + Disbuff.setCursor(0, 5); Disbuff.setTextColor(TFT_BLUE); Disbuff.println("↑電源ボタン\n←Aボタン\n\n詳しい使い方\n QRコード→\n\nBボタン(側面)↓"); Disbuff.qrcode("https://scrapbox.io/iot-programming/usage", 115, 8, 120); - // M5.Display.setTextScroll(true); + // M5.Display.setTextScroll(true); Disbuff.pushSprite(0, 0); checkAXPPress(); @@ -786,7 +789,7 @@ M5.delay(10); // count++; } - while ((M5.BtnA.isPressed()) /*|| (M5.BtnB.isPressed())*/ ) + while ((M5.BtnA.isPressed()) /*|| (M5.BtnB.isPressed())*/) { M5.update(); checkAXPPress(); @@ -1034,6 +1037,7 @@ } startCoundDownShutdown = false; M5.delay(50); + Disbuff.setTextSize(1); Disbuff.setTextColor(TFT_WHITE); } void countDownWebOTA() @@ -1113,10 +1117,12 @@ Disbuff.pushSprite(0, 0); for (int i = 4000; i > 1000; i -= 100) { - tone(GPIO_NUM_2, i, 20); + tone(GPIO_NUM_2, i, 30); + M5.delay(30); } M5.Display.setBrightness(255); M5.update(); + wifi_down(); start_WebOTA(); // WebOTA.ino } if (M5.BtnB.wasReleasefor(100)) @@ -1133,12 +1139,21 @@ Disbuff.setTextColor(TFT_BLACK); Disbuff.printf("Send\n Shutdown\n Signal!!"); Disbuff.pushSprite(0, 0); - for (int i = 2000; i < 4000; i += 100) - { - tone(GPIO_NUM_2, i, 20); - } - M5.Display.setBrightness(255); - + mytone_switch(1000, 200); + M5.delay(200); + mytone_switch(2000, 200); + M5.delay(200); + mytone_switch(4000, 200); + M5.delay(200); + // for (int i = 2000; i < 4000; i += 100) + // { + // tone(GPIO_NUM_2, i, 30); + // M5.delay(30); + // } + // M5.Display.setBrightness(255); + wifi_down(); + Init_ESPNOW(); // ESPNOWの初期化 + M5.delay(100); uint8_t data[50]; if (TestMode) { @@ -1357,7 +1372,7 @@ checkAXP192(); // バッテリー電圧チェック。低下してたらエラーメッセージ表示 - pinMode(19, OUTPUT); // LEDのポートを出力に設定 + // pinMode(19, OUTPUT); // LEDのポートを出力に設定 // timerSemaphore = xSemaphoreCreateBinary(); // バイナリセマフォ作成 // timer = timerBegin(0, 80, true); // タイマーID=0, 80クロックで1カウントする, カウントアップならtrue // timerAttachInterrupt(timer, &onTimer, true); // 割り込み関数onTimer()を登録 diff --git a/FactoryTest/WebOTA.ino b/FactoryTest/WebOTA.ino index db0f4e5..f25ac5a 100644 --- a/FactoryTest/WebOTA.ino +++ b/FactoryTest/WebOTA.ino @@ -25,23 +25,36 @@ lcdprintln(" -- WebOTA --\n\n wifi connecting...", ORANGE, 0); WiFi.begin(ssid0, password0); // 接続開始 + int count = 50; + M5.Speaker.tone(2000, 200); + M5.delay(500); while (WiFi.status() != WL_CONNECTED) { // 接続中... M5.Speaker.tone(2000, 200); M5.delay(200); M5.delay(1000); M5.Lcd.print("."); + count--; + if (count < 1) + { + break; + } } - // 接続完了!! - M5.Speaker.tone(4000, 1500); - lcdprintln(" Wifi Connected!\n ", GREEN, 0); - String gotip = WiFi.localIP().toString(); // m5デバイスのIPアドレス - M5.Lcd.println(gotip); + if (count > 0) + { + // 接続完了!! + M5.Speaker.tone(4000, 1500); + lcdprintln(" Wifi Connected!\n ", GREEN, 0); + String gotip = WiFi.localIP().toString(); // m5デバイスのIPアドレス + M5.Lcd.println(gotip); - String host = "cit.istlab.info"; - int port = 80; - String bin = "/f/FactoryTest.ino.bin"; - execOTA(host, port, bin); + String host = "cit.istlab.info"; + int port = 80; + String bin = "/f/FactoryTest.ino.bin"; + execOTA(host, port, bin); + } else { + wifi_down(); + } } // Utility to extract header value from headers @@ -140,7 +153,7 @@ { Serial.println("Update successfully completed. Rebooting."); // ESP.restart(); - esp_restart(); // 再起動 + esp_restart(); // 再起動 } else { diff --git a/FactoryTest/wifi.ino b/FactoryTest/wifi.ino index ba036a8..2326c13 100644 --- a/FactoryTest/wifi.ino +++ b/FactoryTest/wifi.ino @@ -81,6 +81,7 @@ M5.Speaker.tone(2000, 1500); setRTCfromLT(localTime); // LocalTimeからRTCへの時刻同期 + wifi_down(); } // LocalTimeからRTCへの時刻同期