From 88f460a25546e3a87fcafb21bf8d1af47335970e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Sep 2025 14:24:40 +0000 Subject: [PATCH 1/2] Initial plan From 56f9fddf6fcc70ada75ac802f61afbb946a0735a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Sep 2025 14:30:32 +0000 Subject: [PATCH 2/2] Add Windows compatibility with batch and PowerShell scripts Co-authored-by: NW-Lab <8869009+NW-Lab@users.noreply.github.com> --- README.md | 66 ++++++++++- arduino_ide_version/README_Arduino.md | 12 +- build_test.bat | 43 +++++++ build_test.ps1 | 42 +++++++ docs/WINDOWS_SETUP.md | 158 ++++++++++++++++++++++++++ 5 files changed, 312 insertions(+), 9 deletions(-) create mode 100755 build_test.bat create mode 100644 build_test.ps1 create mode 100644 docs/WINDOWS_SETUP.md diff --git a/README.md b/README.md index b998d20..9c361a3 100644 --- a/README.md +++ b/README.md @@ -30,17 +30,35 @@ VS Code用のタッチスクリーンキーパッドです。GitHub Copilotの ## セットアップ手順 +> **Windows ユーザー向け**: 詳細なWindows固有の手順については [Windows セットアップガイド](docs/WINDOWS_SETUP.md) をご覧ください。 + ### 1. 開発環境の準備 +#### すべてのOS共通 ```bash -# PlatformIOのインストール (VS Code拡張機能推奨) -# または Arduino IDE + ESP32ボードパッケージ - # このリポジトリをクローン git clone https://github.com/NW-Lab/VsCodeKeyPad.git cd VsCodeKeyPad ``` +#### PlatformIOのインストール方法 + +**推奨: VS Code拡張機能** +1. VS CodeでPlatformIO IDE拡張機能をインストール +2. 自動的にPlatformIO Coreもインストールされます + +**コマンドライン:** +```bash +# Python pip経由 (Linux/Mac/Windows) +pip install platformio +``` + +**Windows固有の注意点:** +- PowerShell実行ポリシーの設定が必要な場合があります: + ```powershell + Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + ``` + ### 2. ライブラリの自動インストール PlatformIOを使用する場合、必要なライブラリは自動的にインストールされます: @@ -55,14 +73,33 @@ PlatformIOを使用する場合、必要なライブラリは自動的にイン ### 4. コンパイルと書き込み +#### PlatformIOを使用する場合 + +**Linux/Mac:** ```bash -# PlatformIOの場合 +# ビルドテスト +./build_test.sh + +# アップロード pio run --target upload +``` -# Arduino IDEの場合 -# main.cppの内容をArduino IDEにコピーして書き込み +**Windows:** +```cmd +# ビルドテスト (コマンドプロンプト) +build_test.bat + +# ビルドテスト (PowerShell) +.\build_test.ps1 + +# アップロード +pio run --target upload ``` +#### Arduino IDEを使用する場合 +`arduino_ide_version/VsCodeKeyPad.ino` をArduino IDEで開いてアップロード +詳細は `arduino_ide_version/README_Arduino.md` を参照 + ### 5. ペアリング手順 1. デバイスの電源を入れる @@ -90,6 +127,23 @@ pio run --target upload ## トラブルシューティング +### Windows固有の問題 + +#### "build_test.bat は認識されません" エラー +- コマンドプロンプトでプロジェクトフォルダに移動してから実行 +- または PowerShell で `.\build_test.ps1` を使用 + +#### PowerShellで "実行ポリシー" エラー +```powershell +Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser +``` + +#### COM ポートが認識されない +1. デバイスマネージャーでCP2102/CH340ドライバーを確認 +2. 必要に応じてUSB-Serialドライバーをインストール + +### 共通の問題 + ### Bluetoothが接続できない - PCのBluetoothを一度オフ/オンしてください - デバイスを再起動してください diff --git a/arduino_ide_version/README_Arduino.md b/arduino_ide_version/README_Arduino.md index 734b0df..e60e23d 100644 --- a/arduino_ide_version/README_Arduino.md +++ b/arduino_ide_version/README_Arduino.md @@ -2,6 +2,8 @@ ## Arduino IDE でのセットアップ手順 +> **Note**: このガイドはWindows、Mac、Linux すべてのOSで使用できます。Windows固有の詳細については [Windows セットアップガイド](../docs/WINDOWS_SETUP.md) も参照してください。 + ### 1. ESP32ボードパッケージのインストール 1. Arduino IDEを開く @@ -31,12 +33,16 @@ Arduino IDE のライブラリマネージャーから以下をインストー #### 方法1: User_Setup.h をコピー (推奨) 1. このリポジトリの `User_Setup.h` をコピー 2. Arduino ライブラリフォルダを開く: - - Windows: `Documents\Arduino\libraries\TFT_eSPI\` - - Mac: `~/Documents/Arduino/libraries/TFT_eSPI/` - - Linux: `~/Arduino/libraries/TFT_eSPI/` + - **Windows**: `Documents\Arduino\libraries\TFT_eSPI\` または `C:\Users\[ユーザー名]\Documents\Arduino\libraries\TFT_eSPI\` + - **Mac**: `~/Documents/Arduino/libraries/TFT_eSPI/` + - **Linux**: `~/Arduino/libraries/TFT_eSPI/` 3. 既存の `User_Setup.h` をバックアップ 4. コピーした `User_Setup.h` で置き換える +**Windows での注意点:** +- Arduino IDEがPortable版の場合、パスが異なる場合があります +- ファイルエクスプローラーで隠しフォルダの表示を有効にしてください + #### 方法2: User_Setup_Select.h を編集 1. `TFT_eSPI/User_Setup_Select.h` を開く 2. 既存の設定をコメントアウト diff --git a/build_test.bat b/build_test.bat new file mode 100755 index 0000000..92552dc --- /dev/null +++ b/build_test.bat @@ -0,0 +1,43 @@ +@echo off +REM Build test script for VS Code KeyPad (Windows) + +echo === VS Code KeyPad Build Test === +echo. + +REM Check if PlatformIO is available +where pio >nul 2>&1 +if %ERRORLEVEL% EQU 0 ( + echo ✓ PlatformIO found + + REM Try to build the project + echo Building project... + pio run + if %ERRORLEVEL% EQU 0 ( + echo ✓ Build successful! + echo Ready to upload to Lilygo H621 + ) else ( + echo ✗ Build failed + echo Check library dependencies and configuration + exit /b 1 + ) +) else ( + echo ✗ PlatformIO not found + echo Please install PlatformIO: + echo pip install platformio + echo. + echo Or use Arduino IDE with the files in src/ directory +) + +echo. +echo === Hardware Setup === +echo 1. Connect Lilygo H621 via USB +echo 2. Select correct COM port +echo 3. Upload with: pio run --target upload +echo 4. Monitor serial: pio device monitor +echo. +echo === Pairing Instructions === +echo 1. Power on the device +echo 2. Open Bluetooth settings on your computer +echo 3. Look for 'VS Code KeyPad' +echo 4. Pair the device +echo 5. Open VS Code and start coding with Copilot! \ No newline at end of file diff --git a/build_test.ps1 b/build_test.ps1 new file mode 100644 index 0000000..5b204c3 --- /dev/null +++ b/build_test.ps1 @@ -0,0 +1,42 @@ +# Build test script for VS Code KeyPad (PowerShell) + +Write-Host "=== VS Code KeyPad Build Test ===" -ForegroundColor Cyan +Write-Host "" + +# Check if PlatformIO is available +if (Get-Command pio -ErrorAction SilentlyContinue) { + Write-Host "✓ PlatformIO found" -ForegroundColor Green + + # Try to build the project + Write-Host "Building project..." -ForegroundColor Yellow + $result = & pio run + + if ($LASTEXITCODE -eq 0) { + Write-Host "✓ Build successful!" -ForegroundColor Green + Write-Host "Ready to upload to Lilygo H621" -ForegroundColor Green + } else { + Write-Host "✗ Build failed" -ForegroundColor Red + Write-Host "Check library dependencies and configuration" -ForegroundColor Red + exit 1 + } +} else { + Write-Host "✗ PlatformIO not found" -ForegroundColor Red + Write-Host "Please install PlatformIO:" -ForegroundColor Yellow + Write-Host " pip install platformio" -ForegroundColor White + Write-Host "" + Write-Host "Or use Arduino IDE with the files in src/ directory" -ForegroundColor Yellow +} + +Write-Host "" +Write-Host "=== Hardware Setup ===" -ForegroundColor Cyan +Write-Host "1. Connect Lilygo H621 via USB" +Write-Host "2. Select correct COM port" +Write-Host "3. Upload with: pio run --target upload" +Write-Host "4. Monitor serial: pio device monitor" +Write-Host "" +Write-Host "=== Pairing Instructions ===" -ForegroundColor Cyan +Write-Host "1. Power on the device" +Write-Host "2. Open Bluetooth settings on your computer" +Write-Host "3. Look for 'VS Code KeyPad'" +Write-Host "4. Pair the device" +Write-Host "5. Open VS Code and start coding with Copilot!" \ No newline at end of file diff --git a/docs/WINDOWS_SETUP.md b/docs/WINDOWS_SETUP.md new file mode 100644 index 0000000..879f72b --- /dev/null +++ b/docs/WINDOWS_SETUP.md @@ -0,0 +1,158 @@ +# Windows セットアップガイド + +このガイドでは、Windows環境でVS Code KeyPadを構築・使用する方法を説明します。 + +## 必要なソフトウェア + +### 1. Git for Windows (推奨) +- [Git for Windows](https://gitforwindows.org/)をダウンロード・インストール +- Git Bash、Command Prompt、PowerShell すべてで `git` コマンドが使用可能になります + +### 2. Python (PlatformIO使用時) +- [Python 3.7以降](https://www.python.org/downloads/windows/)をインストール +- インストール時に "Add to PATH" オプションを有効にしてください + +### 3. VS Code (推奨) +- [Visual Studio Code](https://code.visualstudio.com/)をダウンロード・インストール +- PlatformIO IDE拡張機能をインストール + +## セットアップ手順 + +### ステップ 1: リポジトリのクローン +```cmd +git clone https://github.com/NW-Lab/VsCodeKeyPad.git +cd VsCodeKeyPad +``` + +### ステップ 2: PlatformIOのインストール + +#### 方法A: VS Code拡張機能 (推奨) +1. VS Codeでプロジェクトフォルダを開く +2. 拡張機能タブ (Ctrl+Shift+X) を開く +3. "PlatformIO IDE" を検索してインストール +4. VS Codeを再起動 + +#### 方法B: コマンドライン +```cmd +pip install platformio +``` + +### ステップ 3: ビルドテスト + +#### コマンドプロンプト +```cmd +build_test.bat +``` + +#### PowerShell +```powershell +# 実行ポリシーの設定 (初回のみ) +Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + +# ビルドテスト実行 +.\build_test.ps1 +``` + +### ステップ 4: デバイスの接続とアップロード +1. Lilygo H621をUSBケーブルでPCに接続 +2. デバイスマネージャーでCOMポートを確認 (例: COM3, COM4) +3. アップロード実行: + ```cmd + pio run --target upload + ``` + +## Windows固有の注意点 + +### COM ポートの確認 +- デバイスマネージャー → ポート(COMとLPT) +- ESP32デバイスが認識されない場合、CP2102またはCH340ドライバーが必要 + +### USB ドライバー +- **CP2102**: [Silicon Labs](https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers) +- **CH340**: [WCH](http://www.wch-ic.com/downloads/CH341SER_EXE.html) + +### Bluetooth ペアリング +1. Windowsの「設定」→「デバイス」→「Bluetoothとその他のデバイス」 +2. 「Bluetoothまたはその他のデバイスを追加する」をクリック +3. "VS Code KeyPad" を選択してペアリング + +## トラブルシューティング + +### ビルドエラー + +#### "pio' は、内部コマンドまたは外部コマンド...として認識されません" +```cmd +# PATHの確認 +echo %PATH% + +# PlatformIOの再インストール +pip uninstall platformio +pip install platformio +``` + +#### "アクセスが拒否されました" エラー +- 管理者権限でコマンドプロンプトを実行 +- アンチウイルスソフトでフォルダを除外設定 + +### アップロードエラー + +#### "シリアルポートに接続できません" +1. デバイスマネージャーでポートを確認 +2. Arduino IDEのシリアルモニタやPuTTYを閉じる +3. USBケーブルを抜き差し +4. BOOTボタンを押しながらENボタンを押してリセット + +#### "アップロード失敗" +```cmd +# 特定のポートを指定 +pio run --target upload --upload-port COM3 + +# モニターでデバッグ +pio device monitor --port COM3 --baud 115200 +``` + +### PowerShell エラー + +#### "実行ポリシーにより禁止されています" +```powershell +# 現在のポリシーを確認 +Get-ExecutionPolicy + +# ユーザースコープで許可 +Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + +# または一時的に許可 +powershell -ExecutionPolicy Bypass -File build_test.ps1 +``` + +## 代替手順: Arduino IDE + +PlatformIOが動作しない場合、Arduino IDEを使用できます: + +1. [Arduino IDE](https://www.arduino.cc/en/software)をダウンロード・インストール +2. `arduino_ide_version/README_Arduino.md` の手順に従ってセットアップ +3. `arduino_ide_version/VsCodeKeyPad.ino` を開いてアップロード + +## パフォーマンス最適化 + +### Windowsでの高速化 +- Windows Defenderのリアルタイム保護でプロジェクトフォルダを除外 +- SSDにプロジェクトを配置 +- 仮想メモリの設定を適切に調整 + +### ビルド時間短縮 +```cmd +# 並列ビルド (コア数に応じて調整) +pio run --jobs 4 +``` + +## よくある質問 + +### Q: WindowsでLinuxのbashスクリプトは実行できますか? +A: Git BashまたはWSL (Windows Subsystem for Linux) を使用すれば可能ですが、ネイティブの `.bat` や `.ps1` スクリプトの使用を推奨します。 + +### Q: コマンドプロンプトとPowerShellのどちらを使うべきですか? +A: どちらでも動作しますが、PowerShellの方が豊富な機能とエラー処理を提供します。 + +### Q: Arduino IDEとPlatformIOのどちらがおすすめですか? +A: 初心者にはArduino IDE、開発者にはPlatformIOを推奨します。PlatformIOの方が依存関係の管理が自動化されています。 \ No newline at end of file