{"id":17102649,"url":"https://github.com/igor47/spaceboard","last_synced_at":"2025-03-23T19:23:32.626Z","repository":{"id":145035165,"uuid":"104116417","full_name":"igor47/spaceboard","owner":"igor47","description":"arduino code for spaceship board controller","archived":false,"fork":false,"pushed_at":"2018-08-22T12:34:12.000Z","size":45742,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T18:54:28.440Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igor47.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-19T19:04:53.000Z","updated_at":"2018-08-22T12:34:14.000Z","dependencies_parsed_at":"2023-04-05T03:47:32.076Z","dependency_job_id":null,"html_url":"https://github.com/igor47/spaceboard","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igor47%2Fspaceboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igor47%2Fspaceboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igor47%2Fspaceboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igor47%2Fspaceboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igor47","download_url":"https://codeload.github.com/igor47/spaceboard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245155165,"owners_count":20569664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T15:29:39.616Z","updated_at":"2025-03-23T19:23:32.600Z","avatar_url":"https://github.com/igor47.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# spaceboard #\n\nthe files for my spaceteam console.\nthis repo is a [platformio](http://platformio.org/) project and also a python project meant to run on a raspberry pi.\n\n## microcontroller ##\n\nthe platformio files are in `src/` and `lib`, and control the on-board microcontroller.\ni am using [this maple-mini clone](http://amzn.to/2k5Q6A4) which is 5x more expensive than a bluepill, but is available next-day on amazon and has nice buttons instead of jumpers and correct pull-up resistors/bootloader for usb programming.\n\nthe maple-mini can be programmed by running `platformio run --target upload`.\nin some cases, the ACM device is not enabled or is stuck (like, if you accidentally wrote a busy-loop that spews to `Serial`).\nyou can get around this by booting the microcontroller into [perpetual bootloader mode](http://wiki.stm32duino.com/index.php?title=Perpetual_bootloader).\nin that mode, the device will boot straight into DFU mode.\nyou'll need to add the DFU port to program it.\non the raspberry pi, it'll be something like `platformio run --target upload --upload-port \u003cpath-in-dev\u003e`.\nyou can figure out what the path is by running `sudo strace -e open dfu-util -l`\n\n## raspberry pi ##\n\ni used [this pi that comes with a case and heatsinks](http://amzn.to/2xKNtbG) and [this breakout board/cable](http://amzn.to/2fFmc4l).\ni had problems powering the pi with a random 5V power supply -- undervoltages would cause reboots.\nusing an [official power supply](http://amzn.to/2fDrOvQ) made life easier.\n\n### python ###\n\nto run the python controller, invoke `spaceteam.py`.\nit doesn't need `root` atm.\n\n### install.sh ###\n\nthe file `install.sh` will correctly configure the pi so that the python project works.\nthere are quite a few settings, especially those controlling the i2c device, disable bluetooth so that hardware serial is available, disable serial consoles, etc...\nthe script will also install various dependencies, including `platformio` and various python modules.\n\nrun it as root on your raspberry pi:\n\n```bash\n$ sudo ./install.sh\n```\n\n### peripherals ###\n\nthe `spaceteam` directory contains the python project files.\nthere are device drivers for several peripherals attached to the pi:\n\n* microcontroller - controls comms with the microcontroller (maple mini)\n* mcp23017 - this is digital IO multiplexer, we talk to it over i2c. i used [this one](https://www.adafruit.com/product/732) and have a few spares\n* ads1115 - an ADC, also on the i2c bus. i used [this one off amazon (yay next-day delivery)](http://amzn.to/2x1RBk8)\n\n## lights ##\n\nfor any on-board lights, i used a single WS2812 run.\nws2812 leds are often known as [neopixels](https://www.adafruit.com/category/168) in the hobbyist community.\ni used [this generic one](http://amzn.to/2xKR61G) off amazon.\n\nin hindsight, ws2812 is not a good choice for this project.\nit's very difficult to drive off the raspberry pi.\ni tried [this library](https://github.com/jgarff/rpi_ws281x) but the DMA was causing segfaults (with SPI) or DMA errors which put the filesystem into RO (with PCM).\nin the end, it was easier to run the lights off a microcontroller where precise timing is easier.\neven there people often use DMA, but i found a bit-banged library that seems to work pretty well without consuming an entire IO port.\n\n_don't forget about level-shifting the lights!!!_\nthankfully, there's an [easy, elegant hack that just involves one diode](https://hackaday.com/2017/01/20/cheating-at-5v-ws2812-control-to-use-a-3-3v-data-line/).\n\n## serial io ##\n\nto talk between the pi and the microcontroller, i used [a binary protocol](https://www.embeddedrelated.com/showarticle/113.php) over serial.\nthis is fast and efficient, i highly recommend using it.\nthe microcontroller library is in `lib/PacketSerial` and on the python side the code in `spaceteam/microcontroller.py` uses a [built-in library](https://pythonhosted.org/cobs/cobs.cobs.html#cobs-examples).\nTODO: i haven't figured out how to *read* the data off the microcontroller from python yet, since python 2.7 removes the ability to set a custom `eol` character for `serial.readline()`; i'll probably have to read one char at a time, but still a binary protocol is way faster and more reliable.\n\n## wiring overview ##\n\nno diagram right now.\nthe basic idea is:\n\n* raspberry pi is connected to an ethernet hub and to power supply via microusb port\n* pi I2C bus is connected to an ads1115 and an mcp23017\n* pi `/dev/serial0` tty is connected to `Serial3` on the maple mini\n* pi USB connected to maple mini USB for programming (via `platformio`) and debugging (via `Serial` on maple and `miniterm.py` on Pi)\n* maple mini is connected to led strip\n* potentiometers on the ads1115, switches on the mcp23017\n* 3.3V bus powers all the peripherals\n* LED strip powered by separate 5V power brick\n\n## switches ##\n\ni used a bunch of buttons and switches off amazon:\n\n* [light-up rockers](http://amzn.to/2xKVnSN)\n* [big toggles](http://amzn.to/2xOSAbw)\n* [small momentary push-buttons](http://amzn.to/2fBGNGL)\n* [mid-size toggles](http://amzn.to/2xFJn2Y)\n* [cheap 7-segment displays](http://amzn.to/2fD8jnq)\n* [giant push-buttons](http://amzn.to/2fEda7D)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figor47%2Fspaceboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figor47%2Fspaceboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figor47%2Fspaceboard/lists"}