-
Notifications
You must be signed in to change notification settings - Fork 193
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
Add an enclosure service for Picroft #122
base: buster
Are you sure you want to change the base?
Conversation
The code in ~/enclosure/PicroftEnclosure auto-launches from auto_run.sh and also automatically reloads when the code is changed on disk. Currently it handles the shutdown and reboot messages. Also auto-enter the mycroft environment before jumping to the command line on the additional TTY sessions.
Revamped the layout of enclosures on the Picroft image * Code now lives under /opt/mycroft/enclosure instead of ~/enclosure * Setup copies appropriate template to /opt/mycroft/enclosure/my_enclosure.py * A soft link is created to my_enclosure.py in the home directory * Enclosure is run as root * Added basic LED indicator or the Pixel Ring for a Seeed ReSpeaker Mic Array * Add support for a simple button TODO: Enhance Matrix pixel ring support
This revamps how code is structured for enclosures. Rather than repeating code in several places, it now uses objects and inheritance. The original attempted to keep all the logic in a single file, but the GPIO objects already added the need for a user to understand object oriented, so this step seems reasonable. The basics heirarchy is: Enclosure Picroft_Enclosure AIY_Enclosure Generic_Enclosure Matrix_Enclosure ReSpeaker_Enclosure The Picroft_Enclosure contains most of the heavy lifting, with just a little in the subclasses to tie to the special cases. The GPIO_Button and GPIO_LED also implement must of the Raspberry Pi behavior. The Button generates actions for Press, Release, Hold and Double Click. The GPIO_LED is a very simple LED which can turn on, off or flash automatically. Also fixes the typo mentioned in Issue #125
Thanks for this! I just tested it on my RPi4 + Respeaker 2-mic HAT and it works fine... just needed two tiny fixes. I guess the easiest option is to just paste them here:
|
This to be inline with the start of PR of Steve Penrods MycroftAI/enclosure-picroft#122
@@ -380,7 +396,7 @@ function setup_wizard() { | |||
|
|||
# Flash latest Seeed firmware | |||
echo "Downloading and flashing latest firmware from Seeed..." | |||
sudo /home/pi/mycroft-core/.venv/bin/pip install pyusb click | |||
sudo /home/pi/mycroft-core/.venv/bin/pip3 install pyusb click |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that on systems with python2 AND python3, this might be needed .. BUT, afaict, since we should be within the picroft venv ... shouldn't technically be required; and anyway pip
and pip3
are the same on picroft venv systems
(.venv) pi@picroft:~ $ diff /home/pi/mycroft-core/.venv/bin/pip /home/pi/mycroft-core/.venv/bin/pip3ip3
(.venv) pi@picroft:~ $
(.venv) pi@picroft:~ $ which pip
/home/pi/mycroft-core/.venv/bin/pip
(.venv) pi@picroft:~ $ ll /home/pi/mycroft-core/.venv/bin/ | grep pip
-rwxr-xr-x 1 pi pi 243 Jun 20 02:19 pip
-rwxr-xr-x 1 pi pi 243 Jun 20 02:19 pip3
-rwxr-xr-x 1 pi pi 243 Jun 20 02:19 pip3.7
Now a my_enclosure.py gets installed as part of the setup. Specific supported hardware
includes a custom enclosure (e..g AIY, ReSpeaker Mic Array and Matrix) or a generic
enclosure is installed with support for specific GPIOs. All support at least a generic button
and some LED indicators.
The code is in /opt/mycroft/enclosure/my_enclosure.py and auto-launches from auto_run.sh as
a root process. A soft link is created from the home directory, as ~/my_enclosure.py. Changes
The basic hierarchy is:
EnclosureGeneric
Picroft_Enclosure
AIY_Enclosure
Generic_Enclosure
Matrix_Enclosure
ReSpeaker_Enclosure
The Picroft_Enclosure contains most of the heavy lifting, with just a little
in the subclasses to tie to the special cases.
The GPIO_Button and GPIO_LED also implement must of the Raspberry Pi behavior.
The Button generates actions for Press, Release, Hold and Double Click. The
GPIO_LED is a very simple LED which can turn on, off or flash automatically.
Also fixes the typo mentioned in Issue #125
to the enclosure will also be automatically reloaded.
Additionally, logging in to TTY sessions automatically enters the venv now.