Modules - Device Drivers

Showroom for MicroPython related hardware projects.
Target audience: Users wanting to show off their project!
SpotlightKid
Posts: 161
Joined: Wed Apr 08, 2015 5:19 am

Re: Modules - Device Drivers

Postby SpotlightKid » Mon May 18, 2015 6:33 am

Yes, I've read about the hardware support, but it only supports a small number of encoders. I also tried the example by dyhlands, but it did not seem to work as reliable as my approach. Also, I want scaling and min / max bounds of the counter (with or without wrap-around), which is easier, if I maintain the counter myself.

PinkInk
Posts: 61
Joined: Tue Mar 11, 2014 3:42 pm

Re: Modules - Device Drivers

Postby PinkInk » Mon May 18, 2015 3:07 pm

@SpotlightKid - In my eagerness to try your midi module with GarageBand on an iPad I connected a 9v to Gnd and, whoops, 3v3 ... so that little test will have to wait till my replacement pyboards turn up ;)

But if it works; what a way to enthuse my kids to take up Python ...

User avatar
pythoncoder
Posts: 1315
Joined: Fri Jul 18, 2014 8:01 am

Watchdog timer

Postby pythoncoder » Fri Oct 02, 2015 3:38 pm

A simple class for accessing the Pyboad's watchdog timer (a device which resets the Pyboard in the event of a software or hardware fault).

Code: Select all

import stm
@micropython.asm_thumb
def clz(r0):
    clz(r0, r0) # return no. of leading zeros in passed integer

class wdog(object):
    def start(self, ms):
        assert ms <= 32768 and ms >= 1, "Time value must be from 1 to 32768mS"
        prescaler = 23 - clz(ms -1)
        div_value = ((ms << 3) -1) >> prescaler
        stm.mem16[stm.IWDG + stm.IWDG_KR] = 0x5555
        stm.mem16[stm.IWDG + stm.IWDG_PR] = (stm.mem16[stm.IWDG + stm.IWDG_PR] & 0xfff8) | prescaler
        stm.mem16[stm.IWDG + stm.IWDG_RLR] = (stm.mem16[stm.IWDG + stm.IWDG_RLR] & 0xf000) | div_value
        stm.mem16[stm.IWDG + stm.IWDG_KR] = 0xcccc
    def feed(self):
        stm.mem16[stm.IWDG + stm.IWDG_KR] = 0xaaaa

To use, create a watchdog instance and call its start() method with the required period in mS. Your code should periodically call feed(). If the dog doesn't get fed in the specified period, the Pyboard will be reset. It is valid to call start() multiple times to alter the watchdog period.
Peter Hinch

Arthurmed
Posts: 4
Joined: Thu Aug 07, 2014 9:20 am

Re: Modules - Device Drivers

Postby Arthurmed » Sun Jan 31, 2016 10:41 am

Thank you very much Pythoncoder, it works great!!

Sokrates
Posts: 15
Joined: Mon Dec 14, 2015 11:24 pm

SBUS receiver driver

Postby Sokrates » Sun Jul 17, 2016 9:33 pm

Hello,

I just posted on github a driver for SBUS receivers:
https://github.com/Sokrates80/sbus_driver_micropython

User avatar
mcauser
Posts: 118
Joined: Mon Jun 15, 2015 8:03 am

Re: Modules - Device Drivers

Postby mcauser » Fri Oct 14, 2016 5:22 am

Perhaps we should make an awesome-micropython list on Github.
eg. https://github.com/vinta/awesome-python

A few of my drivers:

MicroPython library for the Aosong DHT12:
https://github.com/mcauser/micropython-dht12

MicroPython library for the Aosong AM2320:
https://github.com/mcauser/micropython-am2320

MicroPython library for the MLX90614 IR temperature sensor:
https://github.com/mcauser/micropython-mlx90614

User avatar
pythoncoder
Posts: 1315
Joined: Fri Jul 18, 2014 8:01 am

Re: Modules - Device Drivers

Postby pythoncoder » Fri Oct 14, 2016 6:31 am

mcauser wrote:Perhaps we should make an awesome-micropython list on Github...
That's fine so long as there are people willing to take on the task of curating it. Otherwise we have the Wiki http://wiki.micropython.org/Home.
Peter Hinch


Return to “Hardware Projects”

Who is online

Users browsing this forum: No registered users and 1 guest