Skip to content

Commit

Permalink
Adding in linting for markdown files
Browse files Browse the repository at this point in the history
  • Loading branch information
frozenwizard committed Jun 13, 2023
1 parent 85cf5a6 commit edb3b1f
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 51 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Lint

on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint-docs:
name: Lint docs
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Lint docs
uses: docker://avtodev/markdown-lint:v1
with:
args: '**/*.md'
config: .markdownlint.yaml
5 changes: 5 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# MD013/line-length - Line length
MD013:
# Number of characters
line_length: 120
2 changes: 2 additions & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
temp/
target/
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ format: ## Format the Python code
autopep8 -i -r src/

.PHONY: lint
lint: ## Lints the python code
lint: ## Lints the python code and documents
markdownlint --fix **/*.md
pylint src/ --ignore src/phew

help: ## Show this help.
Expand Down
51 changes: 38 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,66 @@
# GunplaLED

## What is this?
This repo contains Python code that deploys to a [Raspberry Pi Pico W](https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html#raspberry-pi-pico-w-and-pico-wh) that runs a web server allowing you to control individual LED's or program lightshows for a Gundam (or other gunpla) model kit.

This repo contains Python code that deploys to a [Raspberry Pi Pico W](https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html#raspberry-pi-pico-w-and-pico-wh)
that runs a web server allowing you to control individual LED's or program lightshows for a Gundam (or other gunpla)
model kit.

## Why?
When I was building RX-93 Nu Gundam ver ka, it lets you use a green LED module to light up the head. It was basically out of stock everywhere, so I had to look for alternatives. I also didn't like the idea of not having easy access to the on/off of the LED and having to replace batteries. So I wanted something more hardwired into an outlet that I could plug/unplug. I also do a lot of home automation, so I thought it'd be cool to have it connected to a smart plug. Seeing others on r/gunpla do more complicated LED setups and all the above made me think of running some sort of server I can cURL to make it light up. Then research led me here.

When I was building RX-93 Nu Gundam ver ka, it lets you use a green LED module to light up the head. It was basically
out of stock everywhere, so I had to look for alternatives. I also didn't like the idea of not having easy access to
the on/off of the LED and having to replace batteries. So I wanted something more hardwired into an outlet that I could
plug/unplug. I also do a lot of home automation, so I thought it'd be cool to have it connected to a smart plug.
Seeing others on r/gunpla do more complicated LED setups and all the above made me think of running some sort of server
I can cURL to make it light up. Then research led me here.
**tl;dr** A Pico W and green LED is about the same cost as the official LED module but cooler.

## Goals of this project

* Be simple for anyone not technical to install and configure LEDs to their gunpla
* Widespread Gunpla kit support
* Thorough LED installation documentation and simple configuration
* Eventual support of additional microcontrollers
* Widespread community support

## Project Status
This project is in early alpha. It is considered to be functional and fulfills the minimum requirements of hosting a webserver that can control individual LEDs. However, there is still much to be done in terms of adding support for more gunpla models, expanding lightshows, bug fixes, etc. Therefore, until this project hits beta, there is no backwards support as areas of the codebase are rapidly changing and improving. Thus, when upgrading, it is recommended to start from the initial setup.

# Installation
At this time installation requires setting up a local Python development environment as some of the tooling requires it. The recommended OS's are GNU/Linux(Ubuntu) and macOS. Windows is not currently supported but is on the roadmap as it has a more complicated way of talking to the Raspberry Pi.
This project is in early alpha. It is considered to be functional and fulfills the minimum requirements of hosting a
webserver that can control individual LEDs. However, there is still much to be done in terms of adding support for more
gunpla models, expanding lightshows, bug fixes, etc. Therefore, until this project hits beta, there is no backwards
support as areas of the codebase are rapidly changing and improving. Thus, when upgrading, it is recommended to start
from the initial setup.

## Installation

At this time installation requires setting up a local Python development environment as some of the tooling requires it.
The recommended OS's are GNU/Linux(Ubuntu) and macOS. Windows is not currently supported but is on the roadmap as it
has a more complicated way of talking to the Raspberry Pi.
See the [installation instructions](docs/installation.md) for a full walkthrough of how to install
## Requirements

### Requirements

* cli: make, python, pip, pyenv (optional)

# Developer Setup
The [developer setup](docs/developer_setup.md) to add and contribute to the project mainly consists of setting up an IDE environment in addition to setting up the tooling in [installation](docs/installation.md).
## Developer Setup

The [developer setup](docs/developer_setup.md) to add and contribute to the project mainly consists of setting up an
IDE environment in addition to setting up the tooling in [installation](docs/installation.md).

## Contributing

# Contributing
Contributions are very much welcome. For bugs and/or feature requests file a [issue](https://github.com/frozenwizard/GunplaLED/issues). If you'd like to contribute to a specific area such as HTML, additional kit support, etc submit a [PR](https://github.com/frozenwizard/GunplaLED/pulls) as well.
Contributions are very much welcome. For bugs and/or feature requests file a [issue](https://github.com/frozenwizard/GunplaLED/issues)
. If you'd like to contribute to a specific area such as HTML, additional kit support, etc submit a [PR](https://github.com/frozenwizard/GunplaLED/pulls)
as well.

## Roadmap

# Roadmap
* Better documentation for installation of each LED's on each kit
* More Gunpla model support
* More Gunpla model support
* Windows support
* Better UI
* More lightshows and LED effects
* Easier installation and configuration
* Package and deploy dependencies better
* Add the ability to play sounds

24 changes: 19 additions & 5 deletions docs/configuring_gunpla.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Gunpla Configuration

This document describes how to modify the [settings.py](/src/settings.py) file and the associated config.json in src/config

## settings.py

This file is autogenerated during the ```make setup``` phase. It contains 3 important fields

* **wifi configuration**: Enter your wifi information in ssid and password
* **hostname:** Set the name of "url" to connect to
* **model**: This requires importing the appropriate gunpla model or using the generic model in src/gundpla in the top of the file and using a Python construction to create the Python model.
* **model**: This requires importing the appropriate gunpla model or using the generic model in src/gundpla in the top of
the file and using a Python construction to create the Python model.

### Example settings.py

```python
from src.gunpla.nu_gundam import NuGundam

Expand All @@ -21,10 +25,20 @@ webserver = {
```

## config.json
Every Python gunpla class (in src/gunpla) has an associated configuration file in src/config. This configuration file contains a mapping of LEDs to physical pins on the Pico board and a list of lightshows. [Nu Gundam](/src/config/nu_gundam.json) contains the current examples of how to add lightshows and disable individual leds. As this configuration evolves this document will be expanded to describe all the options.

LEDs to pins can be removed/updated or the entry can be modified to have ```"disabled": true``` inserted to disable the LED. Thus the configuration doesn't have to match what LED's you have installed in your kit. For example, [Nu Gundam](/src/config/nu_gundam.json) has all 6 fin funnels deployed, yours may just have 3 deployed and a beam saber you want lit up. Thus, change it to suit how you want to display your mobile suit.
Every Python gunpla class (in src/gunpla) has an associated configuration file in src/config. This configuration file
contains a mapping of LEDs to physical pins on the Pico board and a list of lightshows. [Nu Gundam](/src/config/nu_gundam.json)
contains the current examples of how to add lightshows and disable individual leds. As this configuration evolves this
document will be expanded to describe all the options.

LEDs to pins can be removed/updated or the entry can be modified to have ```"disabled": true``` inserted to disable the
LED. Thus the configuration doesn't have to match what LED's you have installed in your kit. For example, [Nu Gundam](/src/config/nu_gundam.json)
has all 6 fin funnels deployed, yours may just have 3 deployed and a beam saber you want lit up. Thus, change it to
suit how you want to display your mobile suit.

### Lightshows
Lightshows are listed in the config.json, this contains a human-readable name(name) for it, a short url endpoint(path) and the associated Python function(method).
The implementation of a lightshow is primarily in Python. It uses helper functions to get the name of an LED and the class LEDEffects to perform advanced effects such as brightening, glowing, pulsating, etc.

Lightshows are listed in the config.json, this contains a human-readable name(name) for it, a short url endpoint(path)
and the associated Python function(method).
The implementation of a lightshow is primarily in Python. It uses helper functions to get the name of an LED and the
class LEDEffects to perform advanced effects such as brightening, glowing, pulsating, etc.
25 changes: 19 additions & 6 deletions docs/developer_setup.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
# Developer Setup
The recommended IDE is [Pycharm Community](https://www.jetbrains.com/pycharm). You will need to install the [micropython plugin](https://plugins.jetbrains.com/plugin/9777-micropython).

The recommended IDE is [Pycharm Community](https://www.jetbrains.com/pycharm). You will need to install the
[micropython plugin](https://plugins.jetbrains.com/plugin/9777-micropython)

## Tooling Installation
The tools needed to build and deploy are the same as the normal installation. Follow [this](/docs/installation.md#tooling-setup) for that setup.

The tools needed to build and deploy are the same as the normal installation. Follow [this](/docs/installation.md#tooling-setup)
for that setup.

## Debugging
Right now, there is no IDE support for debugging remotely and pdb has not been tested. So all debugging needs to be done with a Pico board attached and primarily through log or print statments

Right now, there is no IDE support for debugging remotely and pdb has not been tested. So all debugging needs to be
done with a Pico board attached and primarily through log or print statements.

The easiest way is to connect the Pico to the computer and run the following commands:

Build and deploy the latest code

```shell
make build deploy && rshell
```

Navigate to the Pico board file system

```shell
cd /pyboard
```
```

Activate the interactive Python interpreter

```shell
repl
```
```

Import and run the webserver

```python
import main
main.main()
```

The server logs start to appear in the console.
The server logs start to appear in the console.
56 changes: 43 additions & 13 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,86 @@
# Installation

The following describes how to set up the necessary software tooling and deploys software to the Pico board.

It is assumed that the user knows what a terminal, shell, etc is and how to use it, but has nothing configured on their system.
#TODO: Link to an external overview of what the terminal and shell is, and how to use it.
It is assumed that the user knows what a terminal, shell, etc is and how to use it, but has nothing configured on their
system. TODO: Link to an external overview of what the terminal and shell is, and how to use it

## Tooling Setup

### Prerequisites

#### macOS

Install [brew.sh](https://brew.sh) to install the macOS package manager

```shell
brew install pyenv git wget
brew install pyenv git wget markdownlint-cli
```

#### GNU/Linux(Ubuntu)

```shell
sudo apt install pyenv git wget make
sudo apt install pyenv git wget make markdownlint-cli
```

After this make sure Pyenv is enabled correctly on your [shell](https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv)

### Clone this repo
If you have not done so yet git clone this repo to your desired directory. The green '<>code' button in GitHub will give you options on how to do that.

If you have not done so yet git clone this repo to your desired directory. The green '<>code' button in GitHub will
give you options on how to do that.

### Install tooling
Run the following make command to download micropython, install python, python requirements and generate the config file. This is a one time setup.

Run the following make command to download micropython, install python, python requirements and generate the config
file. This is a one time setup.

```shell
make setup && pyenv activate gunpla
```

### Install MicroPython to the Raspberry Pico board
MicroPython needs to be installed on the board before the project can be deployed. Plug a Micro-USB cable into the Pico board, hold down the [bootsel button](https://projects-static.raspberrypi.org/projects/getting-started-with-the-pico/725a421f3b51a5674c539d6953db5f1892509475/en/images/Pico-bootsel.png) and then plug the cable into your computer.
This sets the Pico board as a usb mass storage device. The following OS appropriate command will automatically deploy MicroPython to the Pico board.

MicroPython needs to be installed on the board before the project can be deployed. Plug a Micro-USB cable into the Pico
board, hold down the [bootsel button](https://projects-static.raspberrypi.org/projects/getting-started-with-the-pico/725a421f3b51a5674c539d6953db5f1892509475/en/images/Pico-bootsel.png)
and then plug the cable into your computer.
This sets the Pico board as a usb mass storage device. The following OS appropriate command will automatically deploy
MicroPython to the Pico board.

```shell
make install-micropython-osx
```

Or

```shell
make install-micropython-ubuntu
```
After completion the board will disappear as a device and reappear silently, so wait 10 seconds before continuing.

After completion the board will disappear as a device and reappear silently, so wait 10 seconds before continuing.

## Deploy the test build
The test build is a simple Python script that helps to make sure the tooling has been setup correctly and things work. The test file will blink the onboard Pico LED several times and then stop. Run the following command, once the transfer has completed, unplug the Raspberry Pi Pico W and then plug it back in. You should see the onboard LEDs flash.

The test build is a simple Python script that helps to make sure the tooling has been setup correctly and things work.
The test file will blink the onboard Pico LED several times and then stop. Run the following command, once the transfer
has completed, unplug the Raspberry Pi Pico W and then plug it back in. You should see the onboard LEDs flash.

```shell
make build-test deploy
```

If there are any errors, they should be corrected before continuing to configure your gunpla.

## Deploy your gunpla server
Follow the steps in [configuring your gunpla](/docs/configuring_gunpla.md) to configure some important settings and make any modifications. It is recommended to set the configuration to the GenericGundam and make sure all the settings are correct before installing an LED's. Afterwards, run the following to build and deploy your configuration to the Pico board

Follow the steps in [configuring your gunpla](/docs/configuring_gunpla.md) to configure some important settings and make
any modifications. It is recommended to set the configuration to the GenericGundam and make sure all the settings are
correct before installing an LED's. Afterwards, run the following to build and deploy your configuration to the Pico
board

```shell
make build deploy
```
```

Afterwards, you should be able to open a webpage to the hostname you set in the ```settings.py``` or find the IP address in your routers connected device list. If neither works, follow the [debugging guide](/docs/developer_setup.md)
Afterwards, you should be able to open a webpage to the hostname you set in the ```settings.py``` or find the IP address
in your routers connected device list. If neither works, follow the [debugging guide](/docs/developer_setup.md)

0 comments on commit edb3b1f

Please sign in to comment.