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

Change BitmapTransformA-F() methods to accept a single float... #9592

Merged
merged 4 commits into from
Sep 5, 2024

Conversation

jamesbowman
Copy link

…converting to the appropriate fixed-point internally.

No more fiddly 8.8 / 1.15 fixed-point math in user code.

Confirmed on EVE hardware

…ing to the appropriate fixed-point internally.

No more fiddly 8.8 / 1.15 fixed-point math in user code.
@dhalbert
Copy link
Collaborator

dhalbert commented Sep 3, 2024

This is a breaking change to the API. The API is _eve, not eve, so is this somehow considered an internal change, hidden by some library? You are the original submitter of _eve, so you're the expert on this.

I don't really have any idea what the client base of _eve is in CircuitPython.

We generally make breaking changes on a major-version boundary, in this case 10.0, which is not imminent by any means. We often try to make the intermediate versions handle both cases for a while. In this case, the old style takes two arguments, and the new style takes one, so they could be distinguished that way, but it would a noticeable amount of extra code.

@dhalbert
Copy link
Collaborator

dhalbert commented Sep 3, 2024

Side comment re development practices. Instead of submitting PR's from your main branch, we recommend creating a branch for the PR's. That way your main is tied to upstream's main. See https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github/always-work-on-a-branch.

@jamesbowman
Copy link
Author

Right, these methods() are visible to the end user: _eve is the base class for eve.

I'll look at a better implementation that's backwards-compatible.

And thanks, a branch per PR is a good idea.

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.

thanks - will mark this as "Changes Requested"

The setmodel() method controls the behavior
So existing code will continue to work unchanged
Subsequent releases of the ``eve`` library will call setmodel() to enable the new behavior
Confirmed all code paths on EVE hardware
@jamesbowman jamesbowman requested a review from dhalbert September 4, 2024 21:07
@jamesbowman
Copy link
Author

The _eve implementation now works in legacy mode by default. This preserves the existing behavior.

When switched into "new" mode it accepts the new argument formats. It wasn't much more code to handle this.

I've added coverage in my test cases for both modes, and it passes on rp2040.

(Note that I had to turn off _eve for the metro_m4_airlift_lite board, as it overflowed the flash. I don't think anyone is using _eve on this tiny board.)

@dhalbert
Copy link
Collaborator

dhalbert commented Sep 4, 2024

The _eve implementation now works in legacy mode by default. This preserves the existing behavior.

When switched into "new" mode it accepts the new argument formats

So, just to clarify my understanding: is the 2-ints-vs-1-float difference a difference in the eve displays themselves, from older to newer versions, or do they all have the same firmware?

I was thinking you could decide which computation to do based on the number of args to each transform function: if two args (ints) are supplied, do it the old way, if one arg (float), do it the new way.

@jamesbowman
Copy link
Author

jamesbowman commented Sep 4, 2024

So, just to clarify my understanding: is the 2-ints-vs-1-float difference a difference in the eve displays themselves, from older to newer versions, or do they all have the same firmware?

This is an EVE hardware function, and it works in fixed-point coordinates on all the EVE series. What this change is doing is hiding the fixed-point math, so the user code can use floats.

I was thinking you could decide which computation to do based on the number of args to each transform function: if two args (ints) are supplied, do it the old way, if one arg (float), do it the new way.

Right, I thought of doing this. But two of the methods (BitmapTransformC and BitmapTransformF) take 1 parameter. Either an int in the old style (which represents a signed 15.8 bit fixed-point number) or a float in the new style.

There's also a wrinkle in that the hardware got an upgrade between BT810 and BT815, adding a "high-precision" fixed-point format. The code now deals with this correctly.

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.

Alright - thanks!

@dhalbert dhalbert merged commit b4be04e into adafruit:main Sep 5, 2024
15 checks passed
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