Skip to content

fix #1422 correct i2c max xfer len (size in bits)#1431

Merged
dhalbert merged 2 commits into
adafruit:masterfrom
hathach:nrf52_i2c_1kb
Dec 28, 2018
Merged

fix #1422 correct i2c max xfer len (size in bits)#1431
dhalbert merged 2 commits into
adafruit:masterfrom
hathach:nrf52_i2c_1kb

Conversation

@hathach
Copy link
Copy Markdown
Member

@hathach hathach commented Dec 28, 2018

TWIM0_EASYDMA_MAXCNT_SIZE=16 is bit size, which means each xfer can be up to 65K bytes.
Issue is caused since it is mistaken as 16 bytes. Which auto break the framebuf data into sub transaction
1 frame data (513 bytes) = Control byte (0x40) + 512 bytes (pixel)

That confuse SSD1306 data parser since data is split in odd position due to control byte.

We won't probably write more than 65KB at a time, so it is safe for 840.
Note for 832: the max size is 255 bytes, SSD lib should write only part of a frame at a time, since it is not possible for i2c driver to do that in the semantic way to conform SSD1306 decoder !!! (not sure).

SSD1306 i2c mode
image

@hathach
Copy link
Copy Markdown
Member Author

hathach commented Dec 28, 2018

note related, but I need to re-enable MICROPY_PY_FRAMEBUF = 1 to build, otherwise it complains

code.py output:
Traceback (most recent call last):
  File "code.py", line 11, in <module>
  File "adafruit_ssd1306.py", line 38, in <module>
ImportError: no module named 'adafruit_framebuf'

@jerryneedell
Copy link
Copy Markdown
Collaborator

@hathach FYI - you ddn't need to enable MICRO_PY_FRAMEBUF in the build, but if it i not there, then you do need to install the library adafruit_framebuf and the latest adafruit_ssd1306 library. Both are in the latest "Bundle" https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases or in their individual repos: https://github.com/adafruit/Adafruit_CircuitPython_framebuf https://github.com/adafruit/Adafruit_CircuitPython_SSD1306

@hathach
Copy link
Copy Markdown
Member Author

hathach commented Dec 28, 2018

ah, I got it, framebuf is now a optional lib instead of built-in. I use the 24 Dec release, which is a few day old :D . @dhalbert

jerryneedell
jerryneedell previously approved these changes Dec 28, 2018
Copy link
Copy Markdown
Collaborator

@jerryneedell jerryneedell left a comment

Choose a reason for hiding this comment

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

Looks good!
I tested this PR on a particle_argon with an 128x32 OLED Featherwing and it sucessfully runs the ssd1306_framebuftest.py (with reset_pin = None).
Also ran the bouncing_ball.py demo.

Both of these failed prior to this PR.

Copy link
Copy Markdown
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.

Thanks for the fix! One Q.

Comment thread ports/nrf/common-hal/busio/I2C.c Outdated
@hathach
Copy link
Copy Markdown
Member Author

hathach commented Dec 28, 2018

@jerryneedell should the docs for SSD1306 also add framebuf as its dependency

@jerryneedell
Copy link
Copy Markdown
Collaborator

@hathach yes -- the dependency should be added. It was hidden before as a builtin.

Copy link
Copy Markdown
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!

@dhalbert dhalbert merged commit 84060e6 into adafruit:master Dec 28, 2018
@ladyada
Copy link
Copy Markdown
Member

ladyada commented Dec 28, 2018

the ssd1306 docs were updated - we'll be writing a guide soon that will help too

@hathach hathach deleted the nrf52_i2c_1kb branch February 20, 2019 15:13
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.

4 participants