Search found 5956 matches
- Wed Jul 27, 2022 10:00 am
- Forum: General Discussion and Questions
- Topic: Using local time with Pico W
- Replies: 17
- Views: 53719
Re: Using local time with Pico W
Updated version here. This adds portability by using select.poll rather than deprecated socket timeouts (see docs).
- Tue Jul 26, 2022 9:07 am
- Forum: General Discussion and Questions
- Topic: A threading.Event() like concept in MicroPython?
- Replies: 2
- Views: 2677
Re: A threading.Event() like concept in MicroPython?
- Mon Jul 25, 2022 10:42 am
- Forum: ESP8266 boards
- Topic: time.ticks_ms overflow
- Replies: 5
- Views: 25610
Re: time.ticks_ms overflow
Unless you do some special arithmetic it's 298/2 hours. If you perform a modular arithmetic subtraction of t2 - t1 the result may be positive or negative, depending on whether t2 follows or precedes t1. So the result from ticks_diff(t2, t1) may be +- 298/2 hours. This is explained in the docs.
- Sun Jul 24, 2022 10:58 am
- Forum: General Discussion and Questions
- Topic: Traffic lights with a button interrupt - how would you have done it?
- Replies: 12
- Views: 9793
Re: Traffic lights with a button interrupt - how would you have done it?
To give a simple example of where uasyncio trumps the alternative, consider a requirement to flash an LED at a rate which can be varied. Then extend it to say four LED's, all flashing at different rates and with each rate subject to variability. Try to code that using a state machine or otherwise an...
- Sun Jul 24, 2022 10:39 am
- Forum: ESP32 boards
- Topic: int() Anomaly
- Replies: 19
- Views: 9390
- Sat Jul 23, 2022 8:31 am
- Forum: ESP32 boards
- Topic: int() Anomaly
- Replies: 19
- Views: 9390
Re: int() Anomaly
This is not strictly correct. Most MP targets support 32 bit floats, but some support 64 bits, notably the Pyboard D SF6W. Other targets can support 64 bits with a compile option.TheSilverBullet wrote: ↑Sat Jul 23, 2022 7:46 amIf you work with float on MicroPython, that's the precision you can expect:
...
- Sat Jul 23, 2022 7:58 am
- Forum: General Discussion and Questions
- Topic: Traffic lights with a button interrupt - how would you have done it?
- Replies: 12
- Views: 9793
uasyncio every time.
Each to their own. As someone who has been doing asynchronous programming since the days of Intel 8080 assembler, cooperative multi-tasking is the natural way to write firmware. Once you have a handle on the concept it is as much part of programming as OOP. And, in my view, it is as important to lea...
- Fri Jul 22, 2022 2:43 pm
- Forum: Raspberry Pi microcontroller boards
- Topic: Measure RPM with a Hall Sensor
- Replies: 9
- Views: 5861
Re: Measure RPM with a Hall Sensor
The two considerations are accuracy and response time. Counting pulses in a given interval is subject to one pulse of uncertainty. So if you count over 30s you have a 2rpm uncertainty. The shorter the interval, the greater the uncertainty but the less time to achieve a reading. Timing the interval b...
- Fri Jul 22, 2022 2:30 pm
- Forum: General Discussion and Questions
- Topic: Traffic lights with a button interrupt - how would you have done it?
- Replies: 12
- Views: 9793
Asynchronous programming
As @DeaD_EyE says, the best way to do this kind of thing is with asynchronous programming: asyncio in CPython and uasyncio in MicroPython. It allows a more scalable object oriented approach: if you write an asynchronous TrafficLight class, you can implement N of them simply by creating N instances. ...
- Wed Jul 20, 2022 9:17 am
- Forum: ESP32 boards
- Topic: Callback based driver for touchpads
- Replies: 0
- Views: 9789
Callback based driver for touchpads
I have extended my uasyncio-based Pushbutton class to support ESP32 touchpads. See this doc.
This enables callbacks to run on any or all of these conditions:
This enables callbacks to run on any or all of these conditions:
- Touch event.
- Release event.
- Double-touch.
- Long press.