Skip to content
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

expose line function #5

Closed
wants to merge 5 commits into from
Closed

expose line function #5

wants to merge 5 commits into from

Conversation

raidancampbell
Copy link
Contributor

already exists in framebuf, can be used today by reaching through the oled object with oled.framebuf.line(16,16,32,32, 1)

already exists in framebuf, can be used today by reaching through the oled object with `oled.framebuf.line(16,16,32,32, 1)`

changed variable names to conform to conventions

Removed trailing whitespace, and attempted to disable `too-many-arguments` linting
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

One thing to reduce lint clutter.

@@ -130,6 +130,12 @@ def text(self, string, xpos, ypos, col=1):
"""Place text on display"""
self.framebuf.text(string, xpos, ypos, col)

#pylint: disable-msg=too-many-arguments
Copy link
Member

Choose a reason for hiding this comment

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

I think you only need this disable once if you put it in the method after the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops I meant to re-enable it after this block, I saw some other hunk of code that did that. Copy/pasted a bit too much, fixing...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved via 4bc78f8

minor fix for linting hints. re-enable `too-many-arguments` after the block in question
"""Draw a line from initial to final point"""
self.framebuf.line(xpos0, ypos0, xpos1, ypos1, col)
#pylint: enable-msg=too-many-arguments

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be much more efficient to just add self.line = self.framebuf.line to __init__ — and same for all of the other functions.

@deshipu
Copy link
Contributor

deshipu commented Dec 28, 2017

I'm not sure we want to have to do this in every single driver, and then update those drivers when the framebuf gets new methods or changes their signatures, etc. — I think we should simply document how to call the methods on the framebuffer itself.

@raidancampbell
Copy link
Contributor Author

Never thought about that: I agree. I'm unsure how to fully test this however: the lines between py and mpy are pretty blurred for me. It seems like this code automatically interfaces with both mpy (compiled) and py (interpreted) code, depending on which is available.

I have an open PR at the micropython-adafruit-framebuf repo for mirroring the C logic in python. Ideally I'd like that to be accepted before this gets accepted: I've tested that code as working fine.

I haven't ever been able to use the python-backed framebuf: no matter what I try, the actual import is the mpy framebuf. If someone can give me a hand in making that work, I'm happy to unify the mpy/py framebuffers and clean up this library's interface.

@tannewt
Copy link
Member

tannewt commented Jan 2, 2018

@raidancampbell I think the tricky thing here is that the built in framebuf is actually implemented in C and there is a second Python implemented version that can also be converted to bytecode (known as mpy). To test, I'd recommend renaming the python version so that it doesn't conflict and then changing the import in the library.

It'd be awesome to get the framebuf module reorganized in CircuitPython so that its in shared-bindings like struct.

@tannewt
Copy link
Member

tannewt commented Jan 24, 2018

@raidancampbell Are you hoping to get back to this and test it?

@raidancampbell
Copy link
Contributor Author

I implemented and tested, but hadn't gotten around to replying. The "cleaner" method of just mapping the functions is a breaking change: the existing wrapper functions specify a default color if none is given. The wrapped function requires the color to be given. If everyone is okay with that, I'll update with the function mapping to replace wrapping.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

One minor thing.

@@ -35,6 +35,19 @@ class _SSD1306:
"""Base class for SSD1306 display driver"""
def __init__(self, framebuffer, width, height, external_vcc):
self.framebuf = framebuffer
# note this is a breaking change:
# previously these functions were wrapped
# with a default color of "1"
Copy link
Member

Choose a reason for hiding this comment

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

This comment should go in the PR message not the code. I bet col=1 below is actually column not color too.

@tannewt
Copy link
Member

tannewt commented Jan 25, 2018

I'm ok with the breaking change. It seems very minor to me. Ping me on Discord is you need git help.

@raidancampbell
Copy link
Contributor Author

closing to reopen in #9

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.

3 participants