Go to advanced search

by MisterYsLab
Thu Nov 05, 2020 8:53 pm
Forum: Python
Topic: Possible to cleanly shutdown asyncio & websockets?
Replies: 6
Views: 258

Re: Possible to cleanly shutdown asyncio & websockets?

I modified your code slightly and this seems to close cleanly for me upon Control-C. I modified the try/except block and am using run_until complete instead of asyncio.run(main()) Try this out: import socket, asyncio, websockets, datetime #get the server ip s = socket.socket(socket.AF_INET, socket.S...
by MisterYsLab
Wed Nov 04, 2020 10:49 pm
Forum: Python
Topic: Possible to cleanly shutdown asyncio & websockets?
Replies: 6
Views: 258

Re: Possible to cleanly shutdown asyncio & websockets?

I am running websockets in asyncio and here is what I do. Scenario 1: User hits control-c except KeyboardInterrupt: for task in asyncio.Task.all_tasks(): task.cancel() await self.wsocket.close() self.event_loop.stop() self.event_loop.close() sys.exit(0) Scenario 2: websocket closed except (websocket...
by MisterYsLab
Sat Apr 13, 2019 11:39 pm
Forum: Python
Topic: How to detect multiples buttons simultaneously to play a chord
Replies: 2
Views: 420

Re: How to detect multiples buttons simultaneously to play a chord

I substituted the pigpio library for Rpi.GPIO since I am much more familiar with pigpio. Before executing this code, you must start the pigpio daemon sudo pigpiod Here is the code. I am using LEDs to simulate tone A, B and the mix of tones. # remember to start pigpio - sudo pigpiod import pigpio imp...
by MisterYsLab
Fri Apr 12, 2019 2:11 pm
Forum: Python
Topic: Button Behaviour Help
Replies: 1
Views: 256

Re: Button Behaviour Help

It is a little difficult to understand the behavior you are trying to achieve from your description, but here is some code that I think achieves what you are trying to do. I ran this on a Pibrella for test and that is why I set pull_up to False for the switch. import gpiozero as GP import time # est...
by MisterYsLab
Sat Apr 06, 2019 1:42 pm
Forum: Python
Topic: Unable to install pyzmq and RPi.GPIO from requirements.txt
Replies: 3
Views: 1182

Re: Unable to install pyzmq and RPi.GPIO from requirements.txt

To see available wheels go to https://www.piwheels.org.

In a virtualenv install the latest versions of both packages using pip, remove both from the requirements list and reinstall.
by MisterYsLab
Sun Nov 25, 2018 2:55 am
Forum: Python
Topic: GUI not appearing (Guizero)
Replies: 7
Views: 1253

Re: GUI not appearing (Guizero)

I ran this on on Ubuntu box. I will run on an RPi tomorrow and will get back to you.
by MisterYsLab
Sat Nov 17, 2018 8:31 pm
Forum: Python
Topic: Accessing IO in new class
Replies: 18
Views: 1912

Re: Accessing IO in new class

You can organize your classes anyway that makes sense to you. Here I modified the program to handle a button push in the motor and pressure sensor classes. Both are simultaneously listening for a button press on the same pin. I am using a pigio callback that will fire on a rising edge for one class ...
by MisterYsLab
Sat Nov 17, 2018 7:26 pm
Forum: Python
Topic: Accessing IO in new class
Replies: 18
Views: 1912

Re: Accessing IO in new class

import pigpio class PressureSensor: def __init__(self): self.pi = pigpio.pi() # add the rest of your class here class Motors: def __init__(self): self.pi = pigpio.pi() # add the rest of your class here # import PressureSensor # import Motors import time class MyApp: def __init__(self): ps = Pressur...
by MisterYsLab
Thu Oct 11, 2018 8:37 pm
Forum: Python
Topic: Program GPIO pin to execute a script in the terminal after receiving external trigger
Replies: 3
Views: 1339

Re: Program GPIO pin to execute a script in the terminal after receiving external trigger

Glad to help. Since Popen can be difficult to understand, here is a short program example demonstrating its use. Here I am opening xeyes passing it a parameter. I print out the process ID. I wait 2 seconds and then kill the xeyes. #!/usr/bin/env python3 import subprocess from subprocess import Popen...
by MisterYsLab
Fri Sep 30, 2016 4:50 pm
Forum: Troubleshooting
Topic: RPi incredibly slow after Pixel upgrade
Replies: 17
Views: 4929

Re: RPi incredibly slow after Pixel upgrade

Problem resolved for me.

I just reloaded my sd card. This time I used 7zip as suggested and a different card. All is well now, so I am not sure if the original unzip caused the issue or the sd card I used.
by MisterYsLab
Fri Sep 30, 2016 3:56 pm
Forum: Troubleshooting
Topic: RPi incredibly slow after Pixel upgrade
Replies: 17
Views: 4929

Re: RPi incredibly slow after Pixel upgrade

I agree boot and shutdown times are insanely slow. I opened up chromium and CPU utilization on the desktop went to 100% and then chromium crashed. I am going back to the previous release.
by MisterYsLab
Mon Dec 15, 2014 7:25 pm
Forum: Other programming languages
Topic: Snap! - can we get it to run on the RPi
Replies: 15
Views: 13091

Re: Snap! - can we get it to run on the RPi

Xi https://github.com/MrYsLab/xi works well controlling the GPIO pins using Snap! or Scratch 2.0. The current release supports digital in and digital out. We will be testing PWM and Servo in the next few days.

Go to advanced search