Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easy setup and instructions #108

Merged
merged 21 commits into from Jan 18, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions firmware/.eslintrc
Expand Up @@ -4,14 +4,13 @@
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
"ecmaVersion": "latest",
"project": "./tsconfig.json"
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier/@typescript-eslint"
"plugin:prettier/recommended"
],
"plugins": ["@typescript-eslint"],
"rules": {
Expand Down
3 changes: 1 addition & 2 deletions firmware/.gitignore
@@ -1,5 +1,4 @@
/node_modules/
/build/
/tmp/
/stackchan/assets/sounds/*.wav
/scripts/key.json
/tsconfig.json
85 changes: 12 additions & 73 deletions firmware/README.md
Expand Up @@ -8,79 +8,18 @@
* We are currently working on [issue](https://github.com/meganetaaan/stack-chan/issues/65) to make install steps more user friendly. Please post your feedback if any problem.
* If you are friendly with Arduino IDE, [stack-chan-tester](https://github.com/mongonta0716/stack-chan-tester) by @mongonta0716 is another option to try (only for PWM servo).

## Prerequisites
## Directory structure

* Host computer
* Tested on Linux(Ubuntu 20.04)
* M5Stack Basic
* USB type-C cable
* [ModdableSDK](https://github.com/Moddable-OpenSource/moddable)
* See [Getting Started Doc](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/Moddable%20SDK%20-%20Getting%20Started.md)
* Node.js
- [stackchan](./stackchan/): Firmware source code.
- [mods](./mods/): Source code of mods.
- [scripts](./scripts/): Scripts for Stack-chan's voice synthesis, etc.
- [extern](./extern/): External modules.
- [typings](./typings/): TypeScript type definition files (d.ts).
- Stack-chan firmware is implemented in TypeScript, so no separate type definition files are needed.

### (Optional) Using Docker Image
## Documents

This repository provides the build environment by Dockerfile. You can build, write and debug the firmware inside the Docker container. See [the instruction below](#optional-build-and-launch-docker-container).

## How to Build and Flash Firmware

### Clone this repo with submodules

```
git clone --recursive https://github.com/meganetaaan/stack-chan.git
cd stack-chan/firmware
```

### (Optional) Build and Launch Docker Container

#### Using terminal

```
$user@host# ./build-container.sh
$user@host# ./launch-container.sh
$root@container# npm install
```

#### Using VSCode Development Container (devcontainer)

* Open command palette
* Type and run `>Remote-Containers: Reopen in Container`

### Connect Stack-chan to Your Host Computer

![connect](./docs/images/connect.jpg)

### Build and Flash (w/o debug function)

```sh
# For M5Stack Basic/Gray/Fire
npm run deploy

# For M5Stack CORE2
npm run deploy:m5stack_core2
```

### Build, Flash and Debug

```sh
# For M5Stack Basic/Gray/Fire
npm run debug

# For M5Stack CORE2
npm run debug:m5stack_core2
```

This command flashes debug build to Stack-chan and launches `xsbug`, the debugger of ModdableSDK.
See [xsbug(the official docs)](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/xs/xsbug.md) for further details.

## Default App Usage

* __Button-A__: Show messages on balloon
* __Button-B__: Hide messages
* __Button-C__: Toggle move/stop

## API

### TTS

See [text-to-speech.md](./docs/text-to-speech.md)
- [Building Environment](docs/getting-started.md)
- [Building and Writing Programs](docs/flashing-firmware.md)
- [API](docs/api.md)
- [MOD](mods/README.md)
83 changes: 12 additions & 71 deletions firmware/README_ja.md
Expand Up @@ -6,77 +6,18 @@
* 「Moddableの環境構築の手順が多くて大変」という課題に対して、現在[issue](https://github.com/meganetaaan/stack-chan/issues/65)を立てて対応中です。環境構築でつまづいた方はフィードバックをぜひお寄せください。
* Arduino IDEになじみのある方は @mongonta0716 さんの[stack-chan-tester](https://github.com/mongonta0716/stack-chan-tester)もお試しください(PWMサーボのみ対応)。

## 開発に必要なもの
## ディレクトリ構成

* ホストPC
* Linux(Ubuntu20.04)でテスト済み
* M5Stack Basic
* USB type-Cケーブル
* [ModdableSDK](https://github.com/Moddable-OpenSource/moddable)
* [Getting Started Doc](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/Moddable%20SDK%20-%20Getting%20Started.md)を参照
* Node.js
- [stackchan](./stackchan/): ファームウェアのソースコードです。
- [mods](./mods/): MODのソースコードです。
- [scripts](./scripts/): スタックチャンの音声合成などに用いるスクリプトです。
- [extern](./extern/): 外部のモジュールです。
- [typings](./typings/): TypeScriptの型定義ファイル(d.ts)です。
- ※スタックチャンのファームウェアは一部を除きTypeScriptで実装されているので別途型定義ファイルは必要ありませんが、Moddable SDKの新しめのモジュールは型定義ファイルが提供されていないため、それを補う用途で置いてあります。

### (オプション) Dockerイメージを使う
## ドキュメント

このリポジトリはDockerfileによるビルド環境を提供しています。
Dockerコンテナの中でファームウェアのビルド、書き込みとデバッグが可能です。
本READMEの[インストラクション](#optional-build-and-launch-docker-container)を参照ください。

## ファームウェアのビルドと書き込み

### リポジトリをサブモジュールと一緒にクローンする

```
git clone --recursive https://github.com/meganetaaan/stack-chan.git
cd stack-chan/firmware
```

### (オプション) Dockerコンテナのビルドと起動

#### ターミナルを使う場合

```
$user@host# ./build-container.sh
$user@host# ./launch-container.sh
$root@container# npm install
```

#### VSCode Development Container (devcontainer)を使う場合

* コマンドパレットを開く
* `>Remote-Containers: Reopen in Container`を実行する

### スタックチャンをホストPCと接続する

![connect](./docs/images/connect.jpg)

### ビルドと書き込み(デバッグ機能を使わない場合)

```sh
# M5Stack Basic/Gray/Fireの場合
npm run deploy

# M5Stack CORE2の場合
npm run deploy:m5stack_core2
```


### ビルドと書き込み(デバッグする場合)

```sh
# M5Stack Basic/Gray/Fireの場合
npm run debug

# M5Stack CORE2の場合
npm run debug:m5stack_core2
```

このコマンドはデバッグ用にビルドしたファームウェアを書き込むと同時に、ModdableSDKのデバッガである`xsbug`を起動します。
詳しくは[xsbug(公式ドキュメント)](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/xs/xsbug.md)を参照してください。


## API

### TTS(音声合成)

[text-to-speech.md](./docs/text-to-speech.md)を参照(英語)。
- [環境構築](docs/getting-started_ja.md)
- [プログラムのビルドと書き込み](docs/flashing-firmware_ja.md)
- [API](docs/api_ja.md)
- [MOD](mods/README_ja.md)
15 changes: 15 additions & 0 deletions firmware/docs/api.md
@@ -0,0 +1,15 @@
# API

TBD

## クラス構成

## Robot

## Renderer

## Driver

## TTS

- [Using Text To Speech(TTS)](./text-to-speech.md)
15 changes: 15 additions & 0 deletions firmware/docs/api_ja.md
@@ -0,0 +1,15 @@
# API

TBD

## クラス構成

## Robot

## Renderer

## Driver

## TTS

- [TTS(音声合成)の使用](./text-to-speech_ja.md)
55 changes: 55 additions & 0 deletions firmware/docs/flashing-firmware.md
@@ -0,0 +1,55 @@
## Build and flash firmware

## Firmware architecture

Stack-chan's firmware consists of a program that provide the basic operation of Stack-chan (host), and a user application (mod).
Once the host is written, the mod can be installed in a short time for fast development.
First write the host, and then write the mods as needed.

## Writing hosts

The following commands are used to build and write a host.

```console
# For M5Stack Basic/Gray/Fire
$ npm run build
$ npm run deploy

# For M5Stack CORE2
$ npm run build --target=esp32/m5stack_core2
$ npm run deploy --target=esp32/m5stack_core2
```

The program will be saved under the `$MODDABLE/build/` directory.

## Writing MODs

The following command is used to build and write a mod.

```console
# For M5Stack Basic/Gray/Fire
$ npm run mod [mod manifest file path]

# For M5Stack Core2
$ npm run mod --device=esp32/m5stack_core2 [mod manifest file path]
```

__Example: Installing [`mods/look_around`](../mods/look_around/)__

```console
$ npm run mod ./mods/look_around/manifest.json

> stack-chan@0.2.1 mod
> mcrun -d -m -p ${npm_config_target=esp32/m5stack} ${npm_argument} "./mods/look_around/manifest.json"

# xsc mod.xsb
# xsc check.xsb
# xsc mod/config.xsb
# xsl look_around.xsa
Installing mod...complete
```

## Next Step

- [mods/README.md](../mods/README.md): The list of example mods
- [API](./api.md): API document
56 changes: 56 additions & 0 deletions firmware/docs/flashing-firmware_ja.md
@@ -0,0 +1,56 @@
# プログラムのビルドと書き込み

## スタックチャンのプログラム構成について

スタックチャンのファームウェアは、スタックチャンの基本動作を提供するプログラム(ホスト)とユーザアプリケーション(MOD)から構成されます。
一度ホストを書き込んでしまえば、ユーザアプリケーションのインストールは短時間で終わるため高速な開発が可能です。
最初にホストを書き込み、必要に応じてMODの書き込みを行います。

## ホストの書き込み

次のコマンドでホストの書き込みを行います。


```console
# M5Stack Basic/Gray/Fireの場合
$ npm run build
$ npm run deploy

# M5Stack CORE2の場合
$ npm run build --target=esp32/m5stack_core2
$ npm run deploy --target=esp32/m5stack_core2
```

ビルドしたプログラムは`$MODDABLE/build/`ディレクトリ配下に保存されます。

## MODの書き込み

次のコマンドでMODの書き込みを行います。

```console
# M5Stack Basic/Gray/Fireの場合
$ npm run mod [modのマニフェストファイルのパス]

# M5Stack Core2の場合
$ npm run mod --device=esp32/m5stack_core2 [modのマニフェストファイルのパス]
```

__例: [`mods/look_around`](../mods/look_around/)をインストールする__

```console
$ npm run mod ./mods/look_around/manifest.json

> stack-chan@0.2.1 mod
> mcrun -d -m -p ${npm_config_target=esp32/m5stack} ${npm_argument} "./mods/look_around/manifest.json"

# xsc mod.xsb
# xsc check.xsb
# xsc mod/config.xsb
# xsl look_around.xsa
Installing mod...complete
```

## 次のステップ

- [mods/README_ja.md](../mods/README_ja.md): 同梱のサンプルMODの紹介です。
- [API](./api_ja.md): スタックチャンのAPIドキュメントです。