Search found 2974 matches

by pythoncoder
Wed Oct 17, 2018 5:58 am
Forum: ESP32 boards
Topic: Differences between Micropython ports for ESP32 and ESP8266
Replies: 23
Views: 7358

Re: The pyb module

... I like the idea of an exception being raised if the feature doesn't exist on that port. That way code is portable and if u try to use a feature the hardware doesn't have then u get an exception. I think this makes sense too. Peter, do you have an opinion? ... It's a good idea. As is documenting...
by pythoncoder
Tue Oct 16, 2018 5:59 pm
Forum: Drivers for External Components
Topic: TinyRTC I2C Module DS1307 + AT24C32N
Replies: 13
Views: 545

Re: bizarre circuit design

I guess the diode protects against a reverse-fitted battery. What a revolting way to do it. :!:

R5 only makes sense if they have shares in a battery manufacturer.
by pythoncoder
Tue Oct 16, 2018 5:45 pm
Forum: General Discussion and Questions
Topic: Allocation when slicing memoryview instance
Replies: 5
Views: 80

Re: Allocation when slicing memoryview instance

Indeed. It does seem unfortunate that memoryview objects in particular use the heap. I have raised this RFC with a minimal test case. I'll be interested to see the response.
by pythoncoder
Tue Oct 16, 2018 1:05 pm
Forum: General Discussion and Questions
Topic: Allocation when slicing memoryview instance
Replies: 5
Views: 80

This fails too. OK, I've got it.

from machine import I2C from pyb import Timer a = bytearray(10) m = memoryview(a) b = bytearray((1,2)) def cb(_): m[3:5] = b t = Timer(1, freq=1, callback=cb) So the problem has nothing to do with I2C but with memoryview slicing. [EDIT] I've answered my own question: m[x:y] creates a new memoryview...
by pythoncoder
Tue Oct 16, 2018 1:00 pm
Forum: Development of MicroPython
Topic: Could someone implement a C function for connecing to WLAN with Python?
Replies: 6
Views: 151

How to connect to a WPA2 Enterprise network?

Sorry, I misunderstood. I assumed you'd translated working Python code into C. I think a first step is to ask if anyone has managed to do this in MicroPython. I do wonder whether many people here are in a position to test this.

The alternative is to follow the approach suggested by @jickster.
by pythoncoder
Tue Oct 16, 2018 12:50 pm
Forum: General Discussion and Questions
Topic: Allocation when slicing memoryview instance
Replies: 5
Views: 80

Re: machine.I2C: allocation reading into pre-allocated buffer

A slice of a memoryview returns another memoryview . A memoryview instance doesn't have the methods of the object it's based on, so there aren't many things you can do with it. Thus >>> a = b'the quick brown fox' >>> a.find(b'q') 4 >>> m = memoryview(a) >>> m.find(b'q') Traceback (most recent call l...
by pythoncoder
Tue Oct 16, 2018 12:12 pm
Forum: General Discussion and Questions
Topic: Allocation when slicing memoryview instance
Replies: 5
Views: 80

Allocation when slicing memoryview instance

Am I suffering from brain-fade or is something wrong here? Tests done on a Pyboard using the onboard accelerometer as an I2C data source. This sample works: from machine import I2C from pyb import Timer a = bytearray(2) m = memoryview(a) i = I2C(2) def cb(_): i.readfrom_into(60, m) t = Timer(1, freq...
by pythoncoder
Tue Oct 16, 2018 6:51 am
Forum: Development of MicroPython
Topic: Could someone implement a C function for connecing to WLAN with Python?
Replies: 6
Views: 151

Re: Could someone implement a C function for connecing to WLAN with Python?

@heikki.hietala What is the aim in rewriting working Python code in C? Performance is almost certainly limited by the network. So I assume your aim is security. I don't think there is a solution to an attacker with unrestricted access to the hardware. A very limited degree of obfuscation may be achi...
by pythoncoder
Tue Oct 16, 2018 6:34 am
Forum: The MicroPython pyboard
Topic: rtc.info()
Replies: 1
Views: 27

Re: rtc.info()

If you issue >>> hex(262147) '0x40003' >>> you will see that bits 0x10000 and 0x20000 are zero. Your RTC took 3ms to start up. If this isn't clear I suggest you look up information on binary and hexadecimal numbers. This forum is for MicroPython specific queries and it's not practicable to offer one...
by pythoncoder
Tue Oct 16, 2018 6:04 am
Forum: Drivers for External Components
Topic: Bidirectional communication using I2C
Replies: 5
Views: 88

Re: Bidirectional communication using I2C

Why not SPI, it already has bidirectional data path? One extra wiring line can make SPI asynchronous. A number of people have enquired about I2C slave mode and various partial solutions have been produced. These had limitations and I wanted to produce a general solution. Crucially I wanted one whic...