Skip to content

enables ROI useage #25

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 3 commits into from
May 21, 2025
Merged

enables ROI useage #25

merged 3 commits into from
May 21, 2025

Conversation

apzerafa
Copy link
Contributor

This should make the ROI functions work

This should make the ROI functions work
@apzerafa
Copy link
Contributor Author

For what it's worth, I am using this for a personal project that I thought would need ROI. Either I was using it incorrectly or it didn't work. After I made these changes I was able to manipulate the ROI. Still didn't work for what I needed. This may or may not be correct, but it did work for me.

@ladyada
Copy link
Member

ladyada commented May 19, 2025

hiya please fix the CI :)

@ladyada ladyada requested a review from FoamyGuy May 19, 2025 16:24
@FoamyGuy
Copy link
Contributor

@apzerafa Hi, thanks for working on this. I ran added a commit with the code formatting get the actions to pass.

I'm not quite sure that I follow how this change could have a functional effect. The changed code seems to always be writing and reading 1 byte, so I'm not understanding how the endeian-ness could factor in since a single byte doesn't really have an "order" since there is only one of them. As an example I ran this in the REPL and it shows that encoding an int into a single byte will always result in the same byte value no matter if "big" or "little" is specified for byte order:

>>> i = 0x12
>>> i.to_bytes(1)
b'\x12'
>>> i.to_bytes(1, "big")
b'\x12'
>>> i.to_bytes(1, "little")
b'\x12'

Are you certain that this change had any functional effect? Can you clarify what you meant by "After I made these changes I was able to manipulate the ROI. " a little? Like what specific behavior where you seeing before you made these changes? And then if the behavior changed after making this change what specifically about it changed?

@FoamyGuy
Copy link
Contributor

Further I just noticed that #21 is proposing essentially the opposite, using "little" endian byte order, and seems to be saying that it is meant to solve the same problem with roi center and xy.

I will need to get my hands on one of these sensors and try to figure out the current behavior and test these fixes. I am a bit perplexed at how either of them would make any functional difference.

@FoamyGuy
Copy link
Contributor

Okay, after puzzling over this a few more minutes and looking closer at the changes I think I understand what is going on.

The code originally didn't pass any arguments at all it was just to_bytes() with no arguments, which indeed raises an exception

>>> i.to_bytes()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: function missing 1 required positional arguments

Both PRs are essentially fixing the same thing which is that the length positional argument is required and not given. Both PRs also added the optional byte_order as well, though set to opposite values. And my understanding about it being a single byte and thus the order not mattering seems to be validated somewhat by the fact that opposite values used have led to same behavior in the code.

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

I added another commit with some additional info in the docstring for roi_center to try to clarify how it is used a little bit, including a helpful table of values from #21.

It turns out that I did already have one of these devices and I was able to successfully test this change with it.

@FoamyGuy FoamyGuy merged commit aaff860 into adafruit:main May 21, 2025
1 check passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 28, 2025
Updating https://github.com/adafruit/Adafruit_CircuitPython_EPD to 2.13.4 from 2.13.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_EPD#88 from makermelissa/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_INA219 to 3.4.28 from 3.4.27:
  > Merge pull request adafruit/Adafruit_CircuitPython_INA219#39 from ilario/importerror_i2c

Updating https://github.com/adafruit/Adafruit_CircuitPython_INA3221 to 1.2.0 from 1.1.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_INA3221#8 from BZab/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_OPT4048 to 1.0.1 from 1.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_OPT4048#1 from FoamyGuy/use_properties

Updating https://github.com/adafruit/Adafruit_CircuitPython_OV5640 to 1.2.8 from 1.2.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_OV5640#40 from FoamyGuy/saturation_effect_fix

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1322 to 1.4.5 from 1.4.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1322#25 from FoamyGuy/displayio_api_update

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1327 to 1.4.5 from 1.4.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1327#27 from adafruit/update-display-modules

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1680 to 2.0.2 from 2.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1680#32 from makermelissa/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_ST7735 to 1.2.17 from 1.2.16:
  > Merge pull request adafruit/Adafruit_CircuitPython_ST7735#23 from FoamyGuy/displayio_api_update

Updating https://github.com/adafruit/Adafruit_CircuitPython_VL53L1X to 1.2.4 from 1.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_VL53L1X#25 from apzerafa/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_Dash_Dis to 3.0.2 from 3.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Dash_Dis#22 from adafruit/dhalbert-patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 3.3.0 from 3.2.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#220 from cinderblockgames/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 4.1.11 from 4.1.10:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#213 from justmobilize/204-fix

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_OPT4048
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