-
Notifications
You must be signed in to change notification settings - Fork 4
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
Where's a place to do individual things? #48
Comments
It may help for me to mention you can add 'PiCraftZero features' to any kind of standalone python script, e.g. gpiozero scripts. For example the CamJam robot with PiCraftZero controls added, can be run as python3 camjam_edukit3.py However, at the moment PiCraftZero just deals with joysticks, sorry, I've not yet added button presses and I've not documented how to use the HTML/JS/WebSocket parts of PiCraftZero in order for someone to be able to create their own UI components and send custom messages (but it's doable and part of 'the plan'). I am up for taking requests so please raise an issue/request for this and anything else you think needs adding. I think adding couple of buttons/switches to the default UI and a 'button press' would be a nice thing to have. I'd also like to mention that if you've enabled the system service you can also start your own script, instead of the default PiCraftZero script, by adding a line to a 'service' section in the PiCraftZero config. Here's some steps todo that, e.g. if you have a script at Running your own script as a serviceEdit the PicraftZero config file: sudo nano /etc/picraftzero.cfg Add these lines: [service]
script=/home/pi/my_robot.py Follow the log file, in the background, before you restart the service: sudo journalctl -f -u picraftzero & Restart the service: sudo systemctl restart picraftzero You should see in the logs something like:
Your script will now run instead of the default PiCraftZero script every time the Pi boots. |
Maybe this is a bit stupid (I'm not a professional coder...) but I tried to run the following python-code parallel to picraftzero:
The LEDs flicker (normally they should stay on till exit). And by exiting I can't move the rover with picraftzero anymore. Seems to reset the explorer pHat. So this may not be trivial. Also the movement of the Tiny4wd is not as smooth than without the script. |
By the way: what's that LED-setting in the [camera]-section about? |
When running your own script standalone you need to not run sudo systemctl stop picraftzero |
the LED in the camera section is to enable/disable the operation of the red LED indicating when the camera is capturing. |
I made some modifications to the please try replacing: from explorerhat import output with from picraftzero.thirdparty.pimoroni.explorerhat import output |
I made the modifications and started the code with:
LEDs are still flickering, control is still much slower, no change of behavior. After CTRL+C picraftzero-gui doesn't work anymore. |
I've not replicated your setup but that 'while True' loop you have is a 'busy loop' and is going to be a CPU hog, explains why things have become less responsive. Please try this: #!/usr/bin/env python
# coding: Latin-1
# Load library functions we want
from picraftzero import Joystick, Wheelbase, steering_mixer, start
from picraftzero.thirdparty.pimoroni.explorerhat import output
joystick = Joystick()
motors = Wheelbase(left=0, right=1)
motors.source = steering_mixer(joystick.values)
output.one.on()
output.two.on()
try:
print('Press CTRL+C to quit')
start()
except KeyboardInterrupt:
output.one.off()
output.two.off()
print("bye") |
For got to add that you start the script by running it 'as normal' without the -m flag: python3 LightsOn.py |
Adding an issue to record the need to upstream some of the changes made in the bundled Explorer library #50 |
The modified explorer_lights.py works excellent with the LEDs now, no flickering anymore. |
The rock candy joypad has several unused buttons. Is it possible to react on a button press? Within the pimoroni tinypirate example python script there are possibilities to do so:
|
Cool, good to see it's working. I will raise a separate issue for adding button support. |
please see #53 |
Where's the right place to implement individual rover gimmicks/sensors?
I connected two headlight LEDs to the explorer pHat outputs and want to switch them on to do journeys by night.
The text was updated successfully, but these errors were encountered: