Skip to content

Move consts out of class level #22

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

Merged
merged 2 commits into from
Sep 28, 2020
Merged

Move consts out of class level #22

merged 2 commits into from
Sep 28, 2020

Conversation

caternuson
Copy link
Contributor

Fix for #12

The combination of the use of MicroPython's const() along with naming the variable with a leading _ was leading to incompatibility with non-native CP boards when used at the class level. This PR simply moves the consts to the module level.

Tested on Itsy:

Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit ItsyBitsy M0 Express with samd21g18
>>> import board
>>> import busio
>>> import digitalio
>>> import adafruit_fram
>>> spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
>>> cs = digitalio.DigitalInOut(board.D5)
>>> fram = adafruit_fram.FRAM_SPI(spi, cs)
>>> fram[0] = 1
>>> print(fram[0])
bytearray(b'\x01')
>>>

and RPI:

pi@raspberrypi:~/blinka/lib/python3.7/site-packages $ python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import board
>>> import busio
>>> import digitalio
>>> import adafruit_fram
>>> spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
>>> cs = digitalio.DigitalInOut(board.D5)
>>> fram = adafruit_fram.FRAM_SPI(spi, cs)
>>> fram[0] = 1
>>> print(fram[0])
bytearray(b'\x01')
>>>

@caternuson caternuson requested a review from a team September 28, 2020 22:30
@ladyada ladyada merged commit 743bd24 into adafruit:master Sep 28, 2020
@ladyada
Copy link
Member

ladyada commented Sep 28, 2020

thatnks, this was an 'odd one' to catch because i usually do it at file level :)

@caternuson
Copy link
Contributor Author

yep. totes. this even resulted in some additions to the CP design guide docs.

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Sep 29, 2020
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