Skip to content
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

Block order dependency in brightness block #13

Open
DaveAtKitronik opened this issue Sep 18, 2017 · 7 comments
Open

Block order dependency in brightness block #13

DaveAtKitronik opened this issue Sep 18, 2017 · 7 comments

Comments

@DaveAtKitronik
Copy link

There appears to be a dependency on block order for the neopixel package set brightness block.
Used on its own the block does not change the brightness of the LED.
If it is followed by a show colour block then the brightness changes. 
Additionally it only appears to change the brightness of the pixel that has been coloured.
This script:
https://makecode.microbit.org/_Ra5f7VR9xVXf
shows button A does not change brightness, button B does.
Initially reported to micro:bit support as issue 2678, Jonny suggested posting this directly here.

@DaveAtKitronik
Copy link
Author

@jaustin Tagging you for reference.

@DaveAtKitronik
Copy link
Author

This is still broken in newer makecode.
The following testcase shows that if you perform a show colour the brightness changes as expected, but merely performing a show after changing the brightness does not do anything.
https://makecode.microbit.org/_cpL8EogiKdUg
microbit running latest firmware DETAILS.TXT
@pelikhan any idea on when this might get fixed? It is not intuitive for a user to have to repeatedly recolour the pixels to get them to change brightness.

@pelikhan
Copy link
Member

This is currently by design. Internally, we store the colors in a buffer without brightness information. When applying "show color", the current brightness is applied to the color passed by the user and stored in the buffer. We save memory but we also loose the information about the original color. We are already tight in memory on the micro:bit and using long neopixels strips would have further implications here.

@DaveAtKitronik
Copy link
Author

The user experience (for a novice) is that the block should change the brightness of the display on the next show command.
Examining the code it appears that the ease brightness block applies the change to the buffer at the point of executing - although it also does other sums as well.
Show merely pushes out the buffer.
I think unpacking the buffer to apply the brightness to the elements as part of the set brightness block and then repacking it would fix the issue - I'm less clear on how this would cost memory?

@pelikhan
Copy link
Member

pelikhan commented Jan 29, 2019 via email

@DaveAtKitronik
Copy link
Author

I see.
Maybe the show should respect the brightness settings and do the application of the current brightness before pushing the buffer out?

@pelikhan
Copy link
Member

That would mean allocating a second buffer to compute the final colors... which may result in OutOfMemory condition.

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

No branches or pull requests

2 participants