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

Added contrast function and example. #4

Merged
merged 1 commit into from Mar 5, 2019

Conversation

UnfinishedStuff
Copy link
Contributor

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 both st7567.py and lcd.py called contrast 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.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 6

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 8 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.2%) to 39.916%

Files with Coverage Reduction New Missed Lines %
gfxhat/lcd.py 2 63.64%
gfxhat/st7567.py 6 73.11%
Totals Coverage Status
Change from base Build 4: 0.2%
Covered Lines: 95
Relevant Lines: 238

💛 - Coveralls

@Gadgetoid
Copy link
Member

This is great stuff- thank you! I'll add this to my list to look into and get back to you with answers about the contrast range.

I usually assign tickets to myself to remind me that I've at least looked over the issue. Since I tend to operate in a team of 1 I hadn't considered that might indicate I'm working on it. I might have to re-think that practise!

@Gadgetoid Gadgetoid merged commit ac7cd4a into pimoroni:master Mar 5, 2019
@Gadgetoid
Copy link
Member

Thank you- I fixed a few linting errors and slightly refactored the contrast-scanner.py example to avoid the external font dependency and skip the first 20 contrast values since the wait was excruciating! But, otherwise, works beautifully!

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

Successfully merging this pull request may close these issues.

None yet

3 participants