Port, board and/or hardware
esp32 port, Seeed Studio XIAO ESP32c6
MicroPython version
MicroPython v1.28.0 on 2026-04-06; Seeed XIAO ESP32C6 with ESP32C6
I may be using this wrong. I am use to using Python's numpy.UINT8 and it does overflow correctly.
What I need is an 8 bit byte that I can do binary operations on to control LEDs using (random UINT8, and, or, not).
If I am using this wrong my apologies, but could someone explain it to me? I read through the docs for uctypes on docs.micropython.org and thought I understood it.
If there is a better way to do this in MicroPython I'd love to hear it.
Reproduction
>>> import uctypes
>>> my_byte: uctypes.UINT8 = 0xff | uctypes.UINT8
>>> print(my_byte)
255
>>> my_byte = my_byte + 0x01 | uctypes.UINT8
>>> print(my_byte | uctypes.UINT8)
256
>>>
Expected behaviour
Expected behavior: my_byte should overflow to 0
Observed behaviour
my_byte does not overflow to 0 instead it is 256.
Additional Information
I may be using this wrong. I am use to using Python's numpy.UINT8 and it does overflow correctly.
What I need is an 8 bit byte that I can do binary operations on to control LEDs using (random UINT8, and, or, not).
If I am using this wrong my apologies, but could someone explain it to me? I read through the docs for uctypes on docs.micropython.org and thought I understood it.
If there is a better way to do this in MicroPython I'd love to hear it.
Code of Conduct
Yes, I agree
Port, board and/or hardware
esp32 port, Seeed Studio XIAO ESP32c6
MicroPython version
MicroPython v1.28.0 on 2026-04-06; Seeed XIAO ESP32C6 with ESP32C6
I may be using this wrong. I am use to using Python's numpy.UINT8 and it does overflow correctly.
What I need is an 8 bit byte that I can do binary operations on to control LEDs using (random UINT8, and, or, not).
If I am using this wrong my apologies, but could someone explain it to me? I read through the docs for uctypes on docs.micropython.org and thought I understood it.
If there is a better way to do this in MicroPython I'd love to hear it.
Reproduction
Expected behaviour
Expected behavior: my_byte should overflow to 0
Observed behaviour
my_byte does not overflow to 0 instead it is 256.
Additional Information
I may be using this wrong. I am use to using Python's numpy.UINT8 and it does overflow correctly.
What I need is an 8 bit byte that I can do binary operations on to control LEDs using (random UINT8, and, or, not).
If I am using this wrong my apologies, but could someone explain it to me? I read through the docs for uctypes on docs.micropython.org and thought I understood it.
If there is a better way to do this in MicroPython I'd love to hear it.
Code of Conduct
Yes, I agree