Skip to content

Circuitpython nickzoic 1042 nrf nvm bytearray 3 #1803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

nickzoic
Copy link

OK so this is yet another crack at #1042, rebased onto master yet again.
With many thanks to @dhalbert for his help finding & fixing problems.

I've tested on Feather nRF52840 and since it touches shared-bindings a bit also on the Metro M4 Express.

Adafruit CircuitPython 4.0.0-beta.7-36-g9c42a7227 on 2019-04-16; Adafruit Feather nRF52840 Express with nRF52840
>>> from microcontroller import nvm
>>> nvm[0:5] = b"hello"
>>> nvm[5:13] = b", world!"
>>> nvm[0:13]
bytearray(b'hello, world!')
>>> nvm[3]
108
>>> nvm[3:4]
bytearray(b'l')
>>> nvm[3] += 4
>>> nvm[0:4]
bytearray(b'help')

nickzoic added 10 commits April 16, 2019 14:53
import microcontroller

def dump(n = microcontroller.nvm):
    for i in range(0,len(n)):
        print ("%02X " % n[i], end="")
        if i % 16 == 15: print('')

microcontroller.nvm[0:4096] = bytes([1,2,3,4,5,6,7,8]) * 512
microcontroller.nvm[4096:8192] = bytes([16,17,18,19]) * 1024
microcontroller.nvm[4090:4101] = b'thisisatest'
microcontroller.nvm[100:105] = b'hello'
microcontroller.nvm[8000:8007] = b'goodbye'
dump()
@nickzoic nickzoic requested review from tannewt and dhalbert April 16, 2019 05:18
@tannewt tannewt removed their request for review April 16, 2019 18:21
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks! Tested on Feather 52840 and on Metro M4, with slices and single elements.

@dhalbert dhalbert merged commit c0ce820 into adafruit:master Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants