Hi all, please be patience, I'm a newbie
I started to write a simple program to allow comunication and control between App Inventor and Python on RPi4 with Camera, via Bluetooth.
Comunication seems to work just fine. Now, I'm facing with variables implementation issues. Basically, I have a glvars.py file:
EDIT:
Thanks
I started to write a simple program to allow comunication and control between App Inventor and Python on RPi4 with Camera, via Bluetooth.
Comunication seems to work just fine. Now, I'm facing with variables implementation issues. Basically, I have a glvars.py file:
from picamera2 import Picamera2, Preview # Camera init cam = Picamera2() camera_config = cam.create_preview_configuration() cam.configure(camera_config) cam.start_preview(Preview.DRM, x=0, y=0, width=1024, height=600) cam.start() cam.stop_preview()for 'global' variables (I'm not sure this is a good or bad idea) and a myModules.py file with:
import glvars def camExec(*args): # Camera commands clientSock = args[0] cmd = args[1] # line with Picamera2 commands followsmy App Inventor app send strings to RPi via bluetooth and the running python scripts should interpret these strings as Picamera2 commands. For example, if I send the string 'start_preview(True)' (cmd = args[1] variable above), the resulting command for Picamera2 should be:
glvars.cam.start_preview(True)that works just fine, but
glvars.cam.cmddoesn't.
EDIT:
def camExec(*args): # Camera commands clientSock = args[0] cmd = args[1] # glvars.cam.start_preview(True) # works return getattr(glvars.cam, cmd)give me the error:
AttributeError: 'Picamera2' object has no attribute 'start_preview(True)'I tried several string formatting methods but no success. How should I format the final command line in Python?
Thanks