You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Light turns green for Color(0, 0, 5--10) on TechnicHub #224
Describe the bug
The light turns very bright green on TechnicHub for some low value parameters. On PrimeHub, it turns off correctly.
This seems to indicate a broken conversion from hsv to rgb.
To reproduce
frompybricks.hubsimportTechnicHubfrompybricks.parametersimportColorfrompybricks.toolsimportwaithub=TechnicHub()
# Very faint white light: correcthub.light.on(Color(h=0, s=0, v=4))
wait(2000)
# Bright green: badhub.light.on(Color(h=0, s=0, v=8)) # The range 5--10 is broken.wait(2000)
# Faint white light: correcthub.light.on(Color(h=0, s=0, v=12))
wait(2000)
Expected behavior
Light should be faint, somewhere in between 4 and 12, which do work correctly.
changed the title [-][Bug] Light turns green for Color.BLACK on TechnicHub[/-][+][Bug] Light turns green for Color(0, 0, 5--10) on TechnicHub[/+]on Jan 20, 2021
Yes, v=0 turns it off but v= 7 does not, see example above. I've only tried the latest version.
The definition of BLACK has v=10, should that be v=0?
Although this is not the issue here (I renamed the issue), no -- black is still a bit brighter than nothing at all (None). This is true especially for measured color. This is how you can tell black apart from detecting nothing at all. But it even applies to emitting colors. A black piece of paper does not emit/reflect much light, but still more than a complete void or black hole. 🤓
Hard to create tests that need to look at the color of a hub light . . .
If in my competence I want to help creating tests, But where to start without throwing in a mess?
The v values that light up green on the a13 base firmware I determined with:
from pybricks import version
print(version)
from pybricks.hubs import TechnicHub
from pybricks.parameters import Color
from pybricks.tools import wait
hub = TechnicHub()
hub.light.off()
v_error = [6, 7, 8, 11]
for __i in v_error:
print(__i, "looks wrong")
hub.light.on(Color(h=0, s=0, v=__i))
wait(2000)
for __i in range(50):
if not __i in v_error:
print(__i, "should be OK")
hub.light.on(Color(h=0, s=0, v=__i))
wait(500)
But it would still be fine if it wasn't measured. It doesn't have to be fully automated. It could print out what it is supposed to do, and the human observer may or may notice it. It's something we might do manually for every release, just not every commit.
If in my competence I want to help creating tests, But where to start without throwing in a mess?
The format isn't really defined yet. The idea is to fill up this folder with tests. There's only one there, at the moment.
Hard to create tests that need to look at the color of a hub light . . .
Is it?
Hahaha hi, hi Great Laurens. Test the test subject with the test object. (or is it the other way around?)
But it would still be fine if it wasn't measured. It doesn't have to be fully automated. It could print out what it is supposed to do, and the human observer may or may notice it. It's something we might do manually for every release, just not every commit.
Thanks for the help! It would be really helpful to have one script per sensor, which tests all its methods, with all possible arguments. Like this, but for sensors.
Starting with the SPIKE sensors would be a good start. Perhaps mounted side by side. With one motor (itself not the subject in these tests) waving something (colored) in front of the sensors to verify that they give the expected values. Simpler is better, so that the test itself does not fail mechanically at least.
Let's continue this conversation in the coverage repo.
The light turns very bright green on TechnicHub for some low value parameters. On PrimeHub, it turns off correctly.
This seems to indicate a broken conversion from hsv to rgb.
All of the hubs use the same conversion and at least one hub works so this seems unlikely . Since the issue is on TechnicHub, I would suspect pybricks/pybricks-micropython@7650872
Activity
[-][Bug] Light turns green for Color.BLACK on TechnicHub[/-][+][Bug] Light turns green for Color(0, 0, 5--10) on TechnicHub[/+]laurensvalk commentedon Jan 20, 2021
It also appears that
pbdrv_led_pwm_set_hsvis being called in a loop even if there are no patterns. This seems unnecessary.BertLindeman commentedon Jan 20, 2021
Does this depend on the firmware level?
Using the standard
('technichub', '3.0.0a13', 'v3.0.0a13 on 2021-01-08'), I see a very faint cyan color.The definition of BLACK has
v=10, should that bev=0?Running this
shows
faint/blacklaurensvalk commentedon Jan 20, 2021
Yes, v=0 turns it off but v= 7 does not, see example above. I've only tried the latest version.
Although this is not the issue here (I renamed the issue), no -- black is still a bit brighter than nothing at all (
None). This is true especially for measured color. This is how you can tell black apart from detecting nothing at all. But it even applies to emitting colors. A black piece of paper does not emit/reflect much light, but still more than a complete void or black hole. 🤓BertLindeman commentedon Jan 20, 2021
Understood, thanks
laurensvalk commentedon Jan 20, 2021
I tried the example on this firmware, and the issue is present here too. Very bright green light in the (edited) example.
It's probably been broken for a while. This is why we're starting to create tests that will ultimately test each and every available function.
BertLindeman commentedon Jan 20, 2021
Hard to create tests that need to look at the color of a hub light . . .
If in my competence I want to help creating tests, But where to start without throwing in a mess?
The v values that light up green on the a13 base firmware I determined with:
Strange that 10 is doing oke here..
laurensvalk commentedon Jan 20, 2021
Is it?
But it would still be fine if it wasn't measured. It doesn't have to be fully automated. It could print out what it is supposed to do, and the human observer may or may notice it. It's something we might do manually for every release, just not every commit.
The format isn't really defined yet. The idea is to fill up this folder with tests. There's only one there, at the moment.
BertLindeman commentedon Jan 20, 2021
Hahaha hi, hi Great Laurens. Test the test subject with the test object. (or is it the other way around?)
Any hint on where I might look at first?
sorry for hijacking this issue
laurensvalk commentedon Jan 20, 2021
Thanks for the help! It would be really helpful to have one script per sensor, which tests all its methods, with all possible arguments. Like this, but for sensors.
Starting with the SPIKE sensors would be a good start. Perhaps mounted side by side. With one motor (itself not the subject in these tests) waving something (colored) in front of the sensors to verify that they give the expected values. Simpler is better, so that the test itself does not fail mechanically at least.
Let's continue this conversation in the coverage repo.
dlech commentedon Jan 20, 2021
All of the hubs use the same conversion and at least one hub works so this seems unlikely . Since the issue is on TechnicHub, I would suspect pybricks/pybricks-micropython@7650872
platform/technic_hub: fix race condition in TIM2 irq handler
laurensvalk commentedon Jan 20, 2021
Is this related, or if not, is it intentional?
dlech commentedon Jan 20, 2021
It's not related to the issue. It could probably be made more efficient. I can't remember what I was thinking at the time. 😉
dlech commentedon Feb 27, 2021
This issue seems to be back again.
is bright green
dlech commentedon Feb 27, 2021
slightly different than before
platform/technic_hub: fix LED full brightness when small duty cycle