mirror of https://github.com/MLXXXp/Arduboy2.git
Add function to wait for all buttons released
New function waitNoButtons() replaces the code at the end of begin() that waits for all buttons to be released. This is to make it easier to add back this functionality when using boot() in place of begin().
This commit is contained in:
parent
53ea8188d5
commit
eb041d24f8
12
README.md
12
README.md
|
@ -187,10 +187,7 @@ void Arduboy2Base::begin()
|
||||||
|
|
||||||
bootLogo();
|
bootLogo();
|
||||||
|
|
||||||
// wait for all buttons to be released
|
waitNoButtons(); // wait for all buttons to be released
|
||||||
do {
|
|
||||||
delay(50);
|
|
||||||
} while (buttonsState());
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -213,13 +210,10 @@ For example: Let's say a sketch has its own code to enable, disable and save the
|
||||||
|
|
||||||
// bootLogo();
|
// bootLogo();
|
||||||
|
|
||||||
// wait for all buttons to be released
|
// waitNoButtons(); // wait for all buttons to be released
|
||||||
do {
|
|
||||||
delay(50);
|
|
||||||
} while (arduboy.buttonsState());
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This saves whatever code *blank()*, *systemButtons()* and *bootLogo()* would use.
|
This saves whatever code *blank()*, *systemButtons()*, *bootLogo()* and *waitNoButtons()* would use.
|
||||||
|
|
||||||
There are a few functions provided that are roughly equivalent to the standard functions used by *begin()* but which use less code space.
|
There are a few functions provided that are roughly equivalent to the standard functions used by *begin()* but which use less code space.
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ setTextWrap KEYWORD2
|
||||||
SPItransfer KEYWORD2
|
SPItransfer KEYWORD2
|
||||||
systemButtons KEYWORD2
|
systemButtons KEYWORD2
|
||||||
toggle KEYWORD2
|
toggle KEYWORD2
|
||||||
|
waitNoButtons KEYWORD2
|
||||||
width KEYWORD2
|
width KEYWORD2
|
||||||
writeShowUnitNameFlag KEYWORD2
|
writeShowUnitNameFlag KEYWORD2
|
||||||
writeUnitID KEYWORD2
|
writeUnitID KEYWORD2
|
||||||
|
|
|
@ -47,10 +47,7 @@ void Arduboy2Base::begin()
|
||||||
// bootLogoSpritesSelfMasked();
|
// bootLogoSpritesSelfMasked();
|
||||||
// bootLogoSpritesOverwrite();
|
// bootLogoSpritesOverwrite();
|
||||||
|
|
||||||
// wait for all buttons to be released
|
waitNoButtons(); // wait for all buttons to be released
|
||||||
do {
|
|
||||||
delayShort(50);
|
|
||||||
} while (buttonsState());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arduboy2Base::flashlight()
|
void Arduboy2Base::flashlight()
|
||||||
|
@ -174,6 +171,13 @@ void Arduboy2Base::bootLogoShell(void (*drawLogo)(int16_t))
|
||||||
// Virtual function overridden by derived class
|
// Virtual function overridden by derived class
|
||||||
void Arduboy2Base::bootLogoExtra() { }
|
void Arduboy2Base::bootLogoExtra() { }
|
||||||
|
|
||||||
|
// wait for all buttons to be released
|
||||||
|
void Arduboy2Base::waitNoButtons() {
|
||||||
|
do {
|
||||||
|
delayShort(50); // simple button debounce
|
||||||
|
} while (buttonsState());
|
||||||
|
}
|
||||||
|
|
||||||
/* Frame management */
|
/* Frame management */
|
||||||
|
|
||||||
void Arduboy2Base::setFrameRate(uint8_t rate)
|
void Arduboy2Base::setFrameRate(uint8_t rate)
|
||||||
|
|
|
@ -334,6 +334,25 @@ class Arduboy2Base : public Arduboy2Core
|
||||||
// information after the logo stops scrolling down.
|
// information after the logo stops scrolling down.
|
||||||
virtual void bootLogoExtra();
|
virtual void bootLogoExtra();
|
||||||
|
|
||||||
|
/** \brief
|
||||||
|
* Wait until all buttons have been released.
|
||||||
|
*
|
||||||
|
* \details
|
||||||
|
* This function is called by `begin()` and can be called by a sketch
|
||||||
|
* after `boot()`.
|
||||||
|
*
|
||||||
|
* It won't return unless no buttons are being pressed. A short delay is
|
||||||
|
* performed each time before testing the state of the buttons to do a
|
||||||
|
* simple button debounce.
|
||||||
|
*
|
||||||
|
* This function is called at the end of `begin()` to make sure no buttons
|
||||||
|
* used to perform system start up actions are still being pressed, to
|
||||||
|
* prevent them from erroneously being detected by the sketch code itself.
|
||||||
|
*
|
||||||
|
* \see begin() boot()
|
||||||
|
*/
|
||||||
|
void waitNoButtons();
|
||||||
|
|
||||||
/** \brief
|
/** \brief
|
||||||
* Clear the display buffer.
|
* Clear the display buffer.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue