diff --git a/01_download_factorytest.sh b/01_download_factorytest.sh index 2a03e08..15de1a5 100755 --- a/01_download_factorytest.sh +++ b/01_download_factorytest.sh @@ -2,7 +2,7 @@ bindir=FactoryTest/build/esp32.esp32.m5stack_stickc_plus2 mkdir -p "$bindir" -baseurl="https://cit.istlab.info/f/FactoryTest.ino." +baseurl="https://cit.istlab.info/f/plus2/FactoryTest.ino." echo "Downloading FactoryTest firmware files..." for ext in bin bootloader.bin partitions.bin; do diff --git a/98_write4plus.sh b/98_write4plus.sh index 0b73d1f..72f962f 100755 --- a/98_write4plus.sh +++ b/98_write4plus.sh @@ -58,9 +58,9 @@ echo "Flashing completed." # Open serial monitor -read -p "シリアルモニタを開きますか?(y/n): " yn -if [ $yn = "y" ]; then - echo "終了するときはCtrl+Cを押してください。" - arduino-cli monitor -p "$PORT" --config 115200 -fi +#read -p "シリアルモニタを開きますか?(y/n): " yn +#if [ $yn = "y" ]; then +# echo "終了するときはCtrl+Cを押してください。" +# arduino-cli monitor -p "$PORT" --config 115200 +#fi diff --git a/FactoryTest/FactoryTest.ino b/FactoryTest/FactoryTest.ino index 6e4bebe..ff85dee 100644 --- a/FactoryTest/FactoryTest.ino +++ b/FactoryTest/FactoryTest.ino @@ -8,6 +8,33 @@ // #include // #include +// ボード判定用マクロ定義 +#if defined(ARDUINO_M5STACK_STICKC_PLUS2) + #define M5STICKC_PLUS2 + #define DEVICE_NAME "M5StickC Plus2" +#elif defined(ARDUINO_M5STICK_C_PLUS) || defined(ARDUINO_M5STACK_STICKC_PLUS) + #define M5STICKC_PLUS + #define DEVICE_NAME "M5StickC Plus" +#else + #define M5STICKC_PLUS2 // デフォルトはPlus2とする + #define DEVICE_NAME "M5StickC (Unknown)" +#endif + +// デバイス固有のピン定義 +#ifdef M5STICKC_PLUS2 + #define PIN_CLK 0 + #define PIN_DATA 34 + #define LED_PIN 19 + #define BUZZER_PIN 2 + // Plus2固有のピン定義があればここに追加 +#else + #define PIN_CLK 0 + #define PIN_DATA 34 + #define LED_PIN 10 // Plusでは異なる場合があります + #define BUZZER_PIN 2 + // Plus固有のピン定義があればここに追加 +#endif + #define ENABLE_I2S 1 // #define ENABLE_BLE 1 @@ -66,7 +93,7 @@ extern const unsigned char icon_ble_disconnect[1]; #endif -bool TestMode = false; // テストモード 常時ONにした (A/Bボタンを押しながら起動すれば、通常のFactoryTestでもテストモードになる) +bool TestMode = false; // テストモード Off (A/Bボタンを押しながら起動すれば、通常のFactoryTestでもテストモードになる) bool startCoundDownShutdown = false; // 電源OFFのカウントダウンを開始するならtrue bool startWebOTA = false; // WebOTA(from Remote Signal)を開始するならtrue #ifdef ENABLE_OTA @@ -91,7 +118,7 @@ void IRAM_ATTR onTimer() // タイマー処理(LEDをチカチカさせている) { portENTER_CRITICAL_ISR(&timerMux); - digitalWrite(19, TimerCount % 100); // LEDの明るさ + digitalWrite(LED_PIN, TimerCount % 100); // LEDの明るさ TimerCount++; portEXIT_CRITICAL_ISR(&timerMux); } @@ -160,7 +187,14 @@ { Disbuff.setTextSize(1); Disbuff.setTextColor(TFT_GREENYELLOW); - Disbuff.drawString("FactoryTest 2026", 10, 2, 1); + + // デバイス固有の表示 +#ifdef M5STICKC_PLUS2 + Disbuff.drawString("FactoryTest 2026 (Plus2)", 10, 2, 1); +#else + Disbuff.drawString("FactoryTest 2026 (Plus)", 10, 2, 1); +#endif + Disbuff.setTextColor(TFT_WHITE); battery.batteryUpdate(); @@ -668,8 +702,6 @@ } } -#define PIN_CLK 0 -#define PIN_DATA 34 #ifdef ENABLE_I2S void prepareMic() @@ -741,7 +773,14 @@ { float VBat = M5.Power.getBatteryVoltage(); - while (VBat < 3.2) + // デバイス固有のバッテリー電圧閾値 +#ifdef M5STICKC_PLUS2 + float batteryThreshold = 3.2; // Plus2の閾値 +#else + float batteryThreshold = 3.2; // Plusの閾値(必要に応じて変更) +#endif + + while (VBat < batteryThreshold) { VBat = M5.Power.getBatteryVoltage(); ErrorDialog(0x22, "Bat Vol error"); @@ -1078,12 +1117,12 @@ Disbuff.setTextColor(TFT_WHITE); } -void onESPNOWSent(const uint8_t *mac_addr, esp_now_send_status_t status) +void onESPNOWSent(const wifi_tx_info_t *info, esp_now_send_status_t status) { char macStr[18]; snprintf(macStr, sizeof(macStr), "%02X:%02X:%02X:%02X:%02X:%02X", - mac_addr[0], mac_addr[1], mac_addr[2], - mac_addr[3], mac_addr[4], mac_addr[5]); + info->des_addr[0], info->des_addr[1], info->des_addr[2], + info->des_addr[3], info->des_addr[4], info->des_addr[5]); // Serial.print("Last Packet Sent to: "); // Serial.println(macStr); // Serial.print("Last Packet Send Status: "); @@ -1124,7 +1163,7 @@ Disbuff.pushSprite(0, 0); for (int i = 4000; i > 1000; i -= 100) { - tone(GPIO_NUM_2, i, 30); + tone(BUZZER_PIN, i, 30); M5.delay(30); } M5.Display.setBrightness(255); @@ -1335,8 +1374,30 @@ cfg.serial_baudrate = 115200; M5.begin(cfg); + // デバイス情報をシリアル出力 + Serial.println("=== Factory Test 2026 ==="); + Serial.print("Device: "); + Serial.println(DEVICE_NAME); + +#ifdef M5STICKC_PLUS2 + Serial.println("Board: M5StickC Plus2 detected"); + // Plus2固有の初期化処理があればここに記述 + // 例: 特定のセンサー初期化、Plus2専用機能の有効化など +#else + Serial.println("Board: M5StickC Plus detected"); + // Plus固有の初期化処理があればここに記述 + // 例: 旧バージョン対応の初期化処理など +#endif + M5.Display.setRotation(3); // 画面向きは横 - M5.Speaker.setVolume(45); + + // デバイス固有のスピーカー音量設定 +#ifdef M5STICKC_PLUS2 + M5.Speaker.setVolume(45); // Plus2の推奨音量 +#else + M5.Speaker.setVolume(40); // Plusの推奨音量(必要に応じて調整) +#endif + M5.Speaker.tone(2000, 500); M5.Display.setBrightness(255); // M5.Display.setFont(&fonts::lgfxJapanGothic_16); @@ -1406,7 +1467,11 @@ // A(orB)ボタンを押したら、現在実行中の関数のループを抜け、次の関数を実行する MPU6886Test(); // 加速度・ジャイロ DisplayRTC(); // リアルタイムクロック - DisplayMicro(); // マイク + +#ifdef M5STICKC_PLUS2 + DisplayMicro(); // マイク (Plus2のみ) +#endif + DisplayQRCode(); // QRコード // DisplayTestMode(); // バッテリー電圧 ESP_NOW_SendShutdown(); // シャットダウン信号の送信 diff --git a/FactoryTest/WebOTA.ino b/FactoryTest/WebOTA.ino index f25ac5a..c3236d9 100644 --- a/FactoryTest/WebOTA.ino +++ b/FactoryTest/WebOTA.ino @@ -50,7 +50,12 @@ String host = "cit.istlab.info"; int port = 80; - String bin = "/f/FactoryTest.ino.bin"; + #ifdef M5STICKC_PLUS2 + String bin = "/f/plus2/FactoryTest.ino.bin"; + #endif + #ifdef M5STICKC_PLUS + String bin = "/f/plus1/FactoryTest.ino.bin"; + #endif execOTA(host, port, bin); } else { wifi_down(); diff --git a/__admin/12build_upload.sh b/__admin/12build_upload.sh new file mode 100755 index 0000000..26a362b --- /dev/null +++ b/__admin/12build_upload.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +cd .. +./93_compile_factorytest.sh +./97_compile4plus.sh + +cd FactoryTest/build/esp32.esp32.m5stack_stickc_plus2 +sftp -P 10822 miura@istlab.info <