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

Add setDisplayState() to turn display on and off #78

Merged
merged 3 commits into from
Nov 26, 2023
Merged

Add setDisplayState() to turn display on and off #78

merged 3 commits into from
Nov 26, 2023

Conversation

jonnybergdahl
Copy link

Thank you for creating a pull request to contribute to Adafruit's GitHub code!
Before you open the request please review the following guidelines and tips to
help it be more easily integrated:

  • Describe the scope of your change--i.e. what the change does and what parts
    of the code were modified.
    This will help us understand any risks of integrating
    the code.

I added a setState(bool state) call that you can use to turn the display on or off.

  • Describe any known limitations with your change. For example if the change
    doesn't apply to a supported platform of the library please mention it.

The change exposes an existing command in the HT16K33 chip.

  • Please run any tests or examples that can exercise your modified code. We
    strive to not break users of the code and running tests/examples helps with this
    process.

This does not affect existing code.

Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, blinkRate() is documented to do this already, with the appropriate arguments, and uses the same HT16K33 commands. From the .h file:

  /*!
    @brief  Set display blink rate.
    @param  b  One of:
               HT16K33_BLINK_DISPLAYON = steady on
               HT16K33_BLINK_OFF       = steady off
               HT16K33_BLINK_2HZ       = 2 Hz blink
               HT16K33_BLINK_1HZ       = 1 Hz blink
               HT16K33_BLINK_HALFHZ    = 0.5 Hz blink
  */
  void blinkRate(uint8_t b);

@dhalbert
Copy link
Contributor

OK, looking at the blinkRate() documentation, it's just wrong.

@jonnybergdahl
Copy link
Author

Except the code does not actually do that, it makes sure it is on by hardcoding the ON value in the payload.

uint8_t buffer = HT16K33_BLINK_CMD | HT16K33_BLINK_DISPLAYON | (b << 1);

Also - an on/off command does not really fit in a method named blinkRate, right?

I changed the comment to reflect what values you can actually use.

@dhalbert
Copy link
Contributor

I was looking at this at midnight previously, sorry. My only comment then is that setState() is vague, since state could mean a lot of things.

I haven't found a really good name, but setDisplayOn(), setIlluminated, setDisplayState, are all candidates. Do you have a suggestion?

@jonnybergdahl
Copy link
Author

Agreed. setDisplayState() sounds good to me.

@dhalbert dhalbert changed the title Add state() to turn display on and off Add setDisplayState() to turn display on and off Nov 26, 2023
Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good name, and I had no idea the brightness did not go to zero.

@dhalbert dhalbert merged commit bf0d862 into adafruit:master Nov 26, 2023
1 check passed
@jonnybergdahl
Copy link
Author

I am working on finalizing this - https://github.com/jonnybergdahl/Arduino_JBWopr_Library
Found the brightness issue while doing the finals tests.

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.

3 participants