Skip to content

Python code for enchanted rose prop which runs on Raspberry Pi Zero W

Notifications You must be signed in to change notification settings

stevemurch/enchantedrosepython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

Enchanted Rose Python API

This repo is a companion to the Enchanted Rose front-end React app repo, located at https://github.com/stevemurch/enchantedrose.

The Enchanted Rose is a stage prop used in productions of "Beauty and the Beast." This repo contains the API software for controlling the prop. It's a Flask-based Python API.

The main functions of the prop are:

  • Turn stem light on and off
  • Turn accent light on and off, and set colors and pattern
  • Drop 4 rose petals, one by one, on cue.

Control of the prop is via a Python-based API, which has a front-end control app. That is, the prop itself hosts a web server on the Raspberry Pi, and presents its own private "ad-hoc" network. The stage manager connects the prop's ad-hoc network, and accesses the controller software. This general pattern can be used to build "remote control" devices.

There are three main parts to the Enchanted Rose stage prop:

  1. The front-end control software, written in React/Next.js. You'll find that code in the enchantedrose repository. From a technical standpoint, all this repo does is present a nice front-end layer onto the API.
  2. The Raspberry Pi API (this repo.) This is the essential python-based API software, which controls the GPIO pins on the Raspberry Pi. The role of this software libary is to present an API for turning on/off lights, dropping petals, etc.
  3. The prop hardware itself.

You'll find more information about this prop at my blog, https://stevemurch.com; search for "enchanted."

The file "rose.py" is a Flask application, which is run by gunicorn in /etc/rc.local on every Raspberry Pi boot. You'll find it on port 5001. Here are the paths:

Endpoints

/: welcome message /status: status - used to verify that API is up and running

Lights

At this writing, there are two kinds of lights on the prop: 5V LED "stem lights" (fairy lights), and a strip of addressable multicolored LEDs (Neopixels.)

Stem light

/stemlight/on: turn on stem light /stemlight/off: turn off stem light

Neopixels

/neo/rainbow: do a rainbow display /neo/chase: do a light-chase display /neo/color?r=255&g=255&b=255: set a solid color using r, g, b values

Petal Drop

/drop/1, /drop/2, /drop/3, /drop/4 Drop petals 1..4. Mechanically, this is done by pushing air through pipes 1..4; the petals are simply attached with a straw and "blown off" the stem when these pumps are run.

Get this API to Run at Boot

Flask developers recommend you use "gunicorn" to run the flask app in production. You can configure gunicorn to run at boot time with the instructions you'll find online, or in the main "rose.py" file herein. The "enchantedrose" Next.js app will expect to find the API running at port 5001.

About

Python code for enchanted rose prop which runs on Raspberry Pi Zero W

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published