diff --git a/FactoryTest/FactoryTest.ino b/FactoryTest/FactoryTest.ino index b5399db..2180885 100644 --- a/FactoryTest/FactoryTest.ino +++ b/FactoryTest/FactoryTest.ino @@ -99,12 +99,12 @@ { if (M5.BtnPWR.wasPressed()) // 電源ボタン押下したら { - do - { - M5.delay(20); - } while (M5.BtnPWR.wasPressed()); - // ESP.restart(); powerOffOrDeepSleep(); + // do + // { + // M5.delay(20); + // } while (M5.BtnPWR.wasPressed()); + // ESP.restart(); } if (startCoundDownShutdown) @@ -126,15 +126,16 @@ void powerOffOrDeepSleep() { - if (M5.Power.isCharging()) + // M5.Power.isCharging() + if (true) { Disbuff.fillRect(0, 0, 240, 135, TFT_RED); - Disbuff.setCursor(12, 20); + Disbuff.setCursor(12, 20, 4); Disbuff.setTextColor(TFT_WHITE); Disbuff.printf("Enter Deep Sleep"); Disbuff.pushSprite(0, 0); M5.delay(3000); - esp_sleep_enable_timer_wakeup(7 * 86400 * 1000000ULL); // 24時間後に復帰 + esp_sleep_enable_timer_wakeup(7 * 86400 * 1000000ULL); // 1週間後に復帰 esp_deep_sleep_start(); } else diff --git a/upload_by_hash.sh b/upload_by_hash.sh new file mode 100755 index 0000000..fdb38d9 --- /dev/null +++ b/upload_by_hash.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: $0 " + + read -p "Enter the hash: " hash + if [ -z "$hash" ]; then + echo "No hash entered." + exit 1 + fi +else + hash=$1 +fi + +# ダウンロードURL +URL="https://lattr.istlab.info/inobin/dl/${hash}" + +RESPONCE_CODE=$(curl -s -o byhash.bin -w "%{http_code}" $URL) +if [ $RESPONCE_CODE -ne 200 ]; then + echo "Error: $RESPONCE_CODE" + exit 1 +fi + +curl -o byhash.partitions.bin -s ${URL}/partitions +curl -o byhash.bootloader.bin -s ${URL}/bootloader +echo "Downloaded ${hash} as [byhash.bin], [byhash.partitions.bin], [byhash.bootloader.bin]" + +# もし、hashがp1ではじまっていたら、注意喚起する +if [[ $hash =~ ^p1 ]]; then + echo "注:Plus2(黄色)ではなく、Plus(オレンジ色)用のプログラムです。" + board="plus" +else + board="plus2" +fi + +# 書き込みを行う +serials=`arduino-cli board list | grep USB | awk '{print $1}'` +seriallist=($serials) + +if [ -z "${serials}" ]; then + echo "デバイスがみつかりませんでした。" + sleep 2 + echo "デバイスを接続しているのに認識しないときは、ドライバを入れてください。" + sleep 2 + echo "https://ftdichip.com/drivers/vcp-drivers/ → Click here to download + の hereをおす。ZIP解凍して実行。" + exit +fi +for ser in ${seriallist[@]} ; do + echo ${ser} + arduino-cli upload --fqbn esp32:esp32:m5stack_stickc_${board} -p ${ser} --input-file byhash.bin +done + +# 接続デバイスが1つのみの場合、シリアルモニタを開くか確認 +if [[ "${#seriallist[@]}" -eq 1 ]]; then + read -p "シリアルモニタを開きますか?(y/n): " yn + if [ $yn = "y" ]; then + echo "終了するときはCtrl+Cを押してください。" + arduino-cli monitor -p ${seriallist[0]} --config 115200 + fi +fi + +