Tufty 2350 Case Lights

In the API documents i have found the following

Lighting
Badgeware is fitted with four onboard white LEDs on the back of the board. These can be used as indicators, decoration or anything else you can think of. Tufty also has a front-mounted light sensor which

caselights()
Gets and sets the brightness value for the rear lighting on the badge.

Usage
.caselights() - Returns the current level of the rear LEDs as a tuple.
.caselights(level) - level - Brightness to set on all rear LEDs (0-255)
.caselights(level1, level2, level3, level4) - level1, level2, level3, level4 - Brightness to set for each rear LED individually (0-255)
Returns
None, or a tuple if no parameter specified.

And under Methods

badge.caselights([light1: int, light2: int, light3: int, light4: int]) -> None | tuple

If I run the folowing:

badge.caselights()
# Returns the current level of the rear LEDs as a tuple.
print(badge.caselights())

#badge.caselights(level)
#Brightness to set on all rear LEDs (0-255)
#level = 255
badge.caselights(110)

badge.caselights()
# Returns the current level of the rear LEDs as a tuple.
print(badge.caselights())

I get:

MPY: soft reboot
[0, 0, 0, 0]
[110, 110, 110, 110]

If I go to badge.caselights(113) though, I get this?

MPY: soft reboot
[0, 0, 0, 0]
Traceback (most recent call last):
  File "<stdin>", line 8, in <module>
  File "badgeware/badge.py", line 199, in caselights
OverflowError: overflow converting long int to machine word

Is it “0 to 255” or “0 to 100”, or is there a glitch somewhere?

It’s actually a 0-1 range - it was changed somewhere back down the road, and I think the updated docs are sitting in a pull request waiting to go up.

Ok, so 0 is off and 1 is on? No PWM then? That’s not a complaint, just a for future reference question. ;) My use case (no pun intended :P ) would be just on or off. =)

No, it will take a float, you can still PWM and get the caselights to fade, pulse, whatever you want!

Ok, that’s good news then. =)

Ok, that worked, kind of like setting the LCD Backlight. 0 to 1,not 0 or 1.

Setting the Back Light is, I think, the only thing I haven’t sorted out yet.

Exactly! Any value in between will work.

1 Like