Comments (8)
I certainly can. I'll have a think about how to implement it and get it done when I've got a little time to spare.
from mqtt-io.
Hey @Gr4ffy thanks!
It's currently not implemented I'm afraid. There's no technical reason why it couldn't be, just not enough time in the day 😊
from mqtt-io.
Perfectly thank you, you can also times times whether you can speed up the input of an input? It takes about 1 second until the change is recognized :-( This is too slow at a pushbutton ....
from mqtt-io.
Yep, it's on the list - see #5 :)
from mqtt-io.
Hi,
Great job @flyte
Is PWM implemented already?
from mqtt-io.
Got it, thanks for the feedback.
from mqtt-io.
no pwm yet?
from mqtt-io.
I am also in need of PWM, so I was looking at implementing this, but I'm not sure what the best approach is. I'm not sure if I'll be able to find the time to actually implement this, but in the interest of moving this forward, here are some considerations I had while looking at the code for this. Feedback is welcome.
- One big question is whether this should be handled by the GPIO modules, or some new type of module (like sensors, but then for output). GPIO seems the easiest approach, since that allows reusing a lot of setup and event handling code. However, that works for modules like beaglebone and (I guess) raspberry pi that (I think) talk to hardware directly to set up PWM, but might be less suited to more generic modules. e.g I think libgpiod and
/dev/gpiochipx
has no way to configure PWM output. There is a/sys/class/pwm/pwmchipx
interface, but that does require devicetree configuration to let the PWM driver take control of pins rather than runtime configuration. Of course, it can be acceptable that PWM output is supported only by some modules, and there could mabye even be a pwmchip-sysfs gpio module that only supports PWM output (to be used together with the gpiod module for regular GPIO for example). - If handled by GPIO modules, configuration can just be done like digital_outputs (see docs), but some
supports_pwm
orenable_pwm
directive needs to be added. I guess PWM-enabled pins can still also be controlled as regular digital pins (e.g. by passingon_payload
as value instead of a PWM value), so all regular values can still apply as normal. - Normal digital GPIO is now handled by
digital_output_loop()
(that convertson_payload/off_payload
to a bool) andset_digital_output()
(that logs and passes the value to the right gpio module). The easiest approach would be to generalize these methods to just pass either booleans or numbers, and let the gpio module call the right output method based on the type of value. - An alternative approach that is a bit more explicit is to add
set_pwm_output()
next toset_digital_output()
and add aset_pwm_pin()
to gpio modules, lettingdigital_output_loop()
call the right method based on the type of value. - One step more explicit would be to use a different topic for PWM values, e.g. something like
<topic_prefix>/output/<name>/set_pwm
(which saves the "look at the content to decide whether to do PWM or on/off", which is a bit fragile). This would probably be implemented by letting_handle_digital_output_msg
match theset_pwm
topic and if so, adding a different kind of message to the gpio queue (maybe adding a type flag or so) sodigital_output_loop()
(which processes the loop) can dispatch to the right method. This approach is probably the most explicit and most appropriate, without needing much extra boilerplate code. - A bit off-topic, but looking at the code, I wonder a bit about the code split between
_handle_digital_output_msg()
anddigital_output_loop()
. The former looks at the topic and handlesset_on_ms
andset_off_ms
directly by dispatching a task, and puts regular pin updates in a queue that is handled bydigital_output_loop()
(which also matches the payload againston_payload
/off_payload
config). For theset_on/off_ms
handling, the comments say this is done in a task to prevent blockingdigital_output_loop()
, but the latter also handles thetimed_set_ms
configuration by also dispatching a task, essentially duplicating theset_on_ms
code in a different place. I suspect these different timed features might have been introduced over time, but looking at them now, it seems this code could be refactored to be simpler.
from mqtt-io.
Related Issues (20)
- Stream sensor (serial) not reliable
- Running mqtt-io as a service on Raspberry Pi
- Version 2.2.9 is not available on PyPI HOT 4
- Pinned PyYAML version incompatible with latest Cython 3.0.0 HOT 6
- continuous crashes on pi 3b+ HOT 4
- In case of reconnection to MQTT broker subscriptions are lost
- pip fails on pyyaml, poetry fails on requests.utils on a raspberry pi zero w HOT 8
- How to add and reuse values in config files? HOT 1
- Chip has no attribute 'OPEN_BY_NAME' - Orange Pi Zero HOT 2
- KeyError when trying to run on Orange Pi Zero 2W, Ubuntu 22.04 HOT 2
- Raspberry pi 5 support? HOT 1
- use RPIO instead of RPi.GPIO
- Separate Devices Running MQTT IO Are Recognized as a Single Device in Home Assistant HOT 1
- MQTT Io On OrangePi 5 HOT 1
- Issues with paho-mqtt 2.0 HOT 4
- Crash using gpiod HOT 1
- Release version 2.3.0
- New version not working HOT 12
- Wont Connect to MQTT Broker and getting error in log from python script HOT 2
- DHT22 Adafruit_DHT problem HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mqtt-io.