Search found 2856 matches

by dhylands
Sat Oct 20, 2018 12:53 am
Forum: General Discussion and Questions
Topic: a question about const(..)
Replies: 5
Views: 93

Re: a question about const(..)

It seems you can't use const in the while loop. I had to rewrite like this: x = const(100) y = const(1000) z = 0 c = const(x+y) while (c > z): z = z + 1 and got this bytecode: 598 >./micropython -v -v c.py File c.py, code block '<module>' (descriptor: 7f3eb946ef40, bytecode @7f3eb946f2c0 66 bytes) R...
by dhylands
Sat Oct 20, 2018 12:47 am
Forum: General Discussion and Questions
Topic: a question about const(..)
Replies: 5
Views: 93

Re: a question about const(..)

If you run the unix version of micropython with two -v's on the command line then it will dump the bytecode. I modified your program to make it a bit clearer: x = const(100) y = const(1000) z = 0 while (const(x+y) > z): z = z + 1 585 >./micropython -v -v c.py File c.py, code block '<module>' (descri...
by dhylands
Fri Oct 19, 2018 11:49 pm
Forum: General Discussion and Questions
Topic: Does rshell run under Windows?
Replies: 4
Views: 389

Re: Does rshell run under Windows?

I just posted an update to rshell that should make it run better under windows (version 0.0.16)

You still need to manually install pyreadline. Under Windows 10 cmd shell, the colored output works.
by dhylands
Thu Oct 18, 2018 4:15 pm
Forum: General Discussion and Questions
Topic: re.sub regex won't match
Replies: 10
Views: 168

Re: re.sub regex won't match

The bug is in the re module which if passed a pattern containing the two characters \ followed by r (i.e. r'\r') then it should match the single character carriage return (i.e. '\r'). i.e. in CPython: >>> re.sub(r'a\rb', '', 'aa\rbb') 'ab' whereas MicroPython (on my pyboard) gives: >>> re.sub(r'a\rb...
by dhylands
Thu Oct 18, 2018 4:56 am
Forum: General Discussion and Questions
Topic: How to allocate a buffer that won't move around in memory?
Replies: 9
Views: 190

Re: How to allocate a buffer that won't move around in memory?

No it does not do any consolidation. There are lots of discussions in the forum about heap fragmentation.
by dhylands
Wed Oct 17, 2018 11:40 pm
Forum: General Discussion and Questions
Topic: How to allocate a buffer that won't move around in memory?
Replies: 9
Views: 190

Re: How to allocate a buffer that won't move around in memory?

The garbage collector doesn't move anything around.

The only way that the bytearray will move is if you try to add an additional element to the array (i.e. make it be 101 or more elements).

And I'm assuming you mean to use parenthesis rather than square brackets. i.e. ba = bytearray(100)
by dhylands
Wed Oct 17, 2018 2:35 pm
Forum: Programs, Libraries and Tools
Topic: A simple shell for pyboard
Replies: 22
Views: 11308

Re: A simple shell for pyboard

PRs are definitely the preferred approach.

Note that upysh (from Micropython-lib) was written by pfalcon. The simple shell that I wrote is found here: https://github.com/dhylands/upy-shell

I find I tend to use rshell https://github.com/dhylands/rshell now rather than upy-shell
by dhylands
Thu Oct 11, 2018 7:34 pm
Forum: Other Boards
Topic: [nRF52] Where is the umachines library module for the nRF52 boards? Does it even exist?
Replies: 6
Views: 186

Re: [nRF52] Where is the umachines library module for the nRF52 boards? Does it even exist?

The u modules only exist for modules which have an equivalent in CPython. For example, the utime module is a micro-implementation of the CPython time module. See: http://docs.micropython.org/en/latest/library/index.html?highlight=utime#python-standard-libraries-and-micro-libraries for a more detaile...
by dhylands
Thu Oct 11, 2018 7:04 pm
Forum: Other Boards
Topic: [nrf52] Module for register definitions like "stm"
Replies: 4
Views: 92

Re: [nrf52] Module for register definitions like "stm"

You can also add support for machine_mem. You'd need to add these 3 lines: https://github.com/micropython/micropython/blob/338635ccc64204b6f388cfaafca00e120090c622/ports/stm32/modmachine.c#L485-L487 to this file: https://github.com/micropython/micropython/blob/338635ccc64204b6f388cfaafca00e120090c62...