Skip to content
This repository has been archived by the owner on Jan 18, 2019. It is now read-only.

Gamma functions #33

Open
davidhoness opened this issue Aug 16, 2016 · 2 comments
Open

Gamma functions #33

davidhoness opened this issue Aug 16, 2016 · 2 comments

Comments

@davidhoness
Copy link
Member

davidhoness commented Aug 16, 2016

I can see the gamma / low_light properties and gamma_reset function are there but do nothing. I don't expect them to do anything as they're basically pointless in this use case. I would like there to be a warning message, even if it's just an in-line print statement, informing the user that these functions are included only for compatibility but have no effect on the emulated visual output.

I've also noticed you can't seem to use the reversed function on the gamma property.

from sense_hat import SenseHat

sense = SenseHat()

print(len(sense.gamma))
sense.gamma = reversed(sense.gamma)

TypeError: object of type '<invalid type>' has no len() on line 6 in main.py

@davidhoness davidhoness changed the title Gamma function warning Gamma functions Aug 16, 2016
@ebertmi
Copy link

ebertmi commented Aug 18, 2016

The reversed function returns a reverse iterator which seems to be causing problems in the setGamma function. Looking into it.

@waveform80
Copy link

@davidhoness you can't use reversed with gamma on the sense_hat library either; the property setter checks the length of the passed buffer (and generators don't have a length due to their lazy evaluation). Incidentally, it then goes on to check that all values are less than or equal to 31 (although it doesn't test they're also greater than or equal to 0) which, with a generator would immediately evaluate and exhaust the generator (generators won't "replay" later).

You could do the following currently:

sense.gamma = list(reversed(sense.gamma))

Which would construct a list from the generator and pass that to the setter. Alternatively, the setter could be fixed to take account of the generator case (by constructing its own list from whatever buffer is passed)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants