Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 60 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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を使用する場合、必要なライブラリは自動的にインストールされます:
Expand All @@ -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. デバイスの電源を入れる
Expand Down Expand Up @@ -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を一度オフ/オンしてください
- デバイスを再起動してください
Expand Down
12 changes: 9 additions & 3 deletions arduino_ide_version/README_Arduino.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Arduino IDE でのセットアップ手順

> **Note**: このガイドはWindows、Mac、Linux すべてのOSで使用できます。Windows固有の詳細については [Windows セットアップガイド](../docs/WINDOWS_SETUP.md) も参照してください。

### 1. ESP32ボードパッケージのインストール

1. Arduino IDEを開く
Expand Down Expand Up @@ -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. 既存の設定をコメントアウト
Expand Down
43 changes: 43 additions & 0 deletions build_test.bat
Original file line number Diff line number Diff line change
@@ -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!
42 changes: 42 additions & 0 deletions build_test.ps1
Original file line number Diff line number Diff line change
@@ -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!"
158 changes: 158 additions & 0 deletions docs/WINDOWS_SETUP.md
Original file line number Diff line number Diff line change
@@ -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の方が依存関係の管理が自動化されています。