Subtle adjustments to dark pixels brightness #881
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is some code I wrote after our very productive conversation in #880 . I'm not sure you'll be interested in it, just thought I might share the code because I'm happy with the results. If there's any interest to merge some part of it, please let me know how I can modify it. Otherwise just feel free to close the request.
I tried to make it generic at first, because in the end there's only a few variables I wanted to change. For example, it might be possible to have the
PicoUnicorn
class templated, and then you can simply select different values forBCD_FRAMES
etc. But eventually that looked like too much work.Some minor modifications are:
DISCHARGE_FRAMES
, because increasing that is a simple way to make everything a little darker.set_pixel_
method lets the user input 16-bit linear values, skipping the LUT, andset_pixel
simply uses the LUT and calls that.The main modification is that we now have a
FRAME_DELAY
, which is the estimated extra time per bit-plane frame. In my experiments, 4 ticks was what I was most pleased with. This time is subtracted from the count of each frame, and in the first frame we have a count of zero. This is also the base time to compute everything, this delay defines our least significant bit in the binary code modulation.Because I increased the minimum time, I found it natural to reduce the total number of bits to 12 instead of 14. This approximately preserves the time for a whole frame refresh, I think.
To go along with this alternative bit-depth, I also computed a new 12-bit LUT, and made it so there's a linear tapering at the beginning, so there are no levels "lost" to a same output value in the darkest range, which was the other thing I was looking forward to.
I'm happy to be able to do these customizations! Perhaps not many people are as concerned as me looking at almost imperceptible dark pixels, but if there's any interest, here is what I did.
Final note: here's some Julia code I used to compute the LUT: https://gist.github.com/nlw0/d020b67d954b9e4a98865aa3ceb9a343