Added contrast function and example. #4
Merged
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.
First off, apologies if I've done something dumb on the Git end, I've not done a lot with pull requests.
Anyway, I saw the Issue suggesting user-definable contrast and agreed it would be a great feature. After a bit of manual testing I found that if you set the RegRatio to 3 then text would become visible above Electronic Volume values of ~25, and disappear into a dark background with values beginning at around 55.
To that end, I've modified
st7567.py
to set the RegRatio to 3 during init, and added a function to bothst7567.py
andlcd.py
calledcontrast
which allows you to set the contrast. I've allso added a small script (contrast_scanner.py) to the examples folder which scans through the contrast values, first with the backlight off and then all LEDs set to white, and displays the contrast value on the LCD with each contrast value. Possibly not needed, but useful for seeing which contrast values actually work.Any suggestions? Is it worth setting the contrast function to head straight to an EV of ~20 with a user value of 0, or is it better to keep faint options for odd use cases? I've just spotted that Gagetoid has assigned this to himself, so maybe he's already done much of this.