mirror of https://github.com/MLXXXp/Arduboy2.git
Add nextFrameDEV() function for checking CPU load
This commit is contained in:
parent
de17257029
commit
6c297fab1e
|
@ -57,6 +57,7 @@ invert KEYWORD2
|
||||||
justPressed KEYWORD2
|
justPressed KEYWORD2
|
||||||
justReleased KEYWORD2
|
justReleased KEYWORD2
|
||||||
nextFrame KEYWORD2
|
nextFrame KEYWORD2
|
||||||
|
nextFrameDEV KEYWORD2
|
||||||
notPressed KEYWORD2
|
notPressed KEYWORD2
|
||||||
off KEYWORD2
|
off KEYWORD2
|
||||||
on KEYWORD2
|
on KEYWORD2
|
||||||
|
|
|
@ -169,6 +169,18 @@ bool Arduboy2Base::nextFrame()
|
||||||
return post_render;
|
return post_render;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Arduboy2Base::nextFrameDEV() {
|
||||||
|
bool ret = nextFrame();
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
if (lastFrameDurationMs > eachFrameMillis)
|
||||||
|
TXLED1;
|
||||||
|
else
|
||||||
|
TXLED0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int Arduboy2Base::cpuLoad()
|
int Arduboy2Base::cpuLoad()
|
||||||
{
|
{
|
||||||
return lastFrameDurationMs*100 / eachFrameMillis;
|
return lastFrameDurationMs*100 / eachFrameMillis;
|
||||||
|
|
|
@ -613,10 +613,37 @@ class Arduboy2Base : public Arduboy2Core
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \see setFrameRate()
|
* \see setFrameRate() nextFrameDEV()
|
||||||
*/
|
*/
|
||||||
bool nextFrame();
|
bool nextFrame();
|
||||||
|
|
||||||
|
/** \brief
|
||||||
|
* Indicate that it's time to render the next frame, and visually indicate
|
||||||
|
* if the code is running slower than the desired frame rate.
|
||||||
|
* **FOR USE DURING DEVELOPMENT**
|
||||||
|
*
|
||||||
|
* \return `true` if it's time for the next frame.
|
||||||
|
*
|
||||||
|
* \details
|
||||||
|
* This function is intended to be used in place of `nextFrame()` during the
|
||||||
|
* development of a sketch. It does the same thing as `nextFrame()` but
|
||||||
|
* additionally will light the yellow TX LED (at the bottom, to the left
|
||||||
|
* of the USB connector) whenever a frame takes longer to generate than the
|
||||||
|
* time allotted per frame, as determined by the `setFrameRate()` function.
|
||||||
|
*
|
||||||
|
* Therefore, whenever the TX LED comes on (while not communicating over
|
||||||
|
* USB), it indicates that the sketch is running slower than the desired
|
||||||
|
* rate set by `setFrameRate()`. In this case the developer may wish to set
|
||||||
|
* a slower frame rate, or reduce or optimize the code for such frames.
|
||||||
|
*
|
||||||
|
* \note
|
||||||
|
* Once a sketch is ready for release, it would be expected that
|
||||||
|
* `nextFrameDEV()` calls be restored to `nextFrame()`.
|
||||||
|
*
|
||||||
|
* \see nextFrame() cpuLoad() setFrameRate()
|
||||||
|
*/
|
||||||
|
bool nextFrameDEV();
|
||||||
|
|
||||||
/** \brief
|
/** \brief
|
||||||
* Indicate if the specified number of frames has elapsed.
|
* Indicate if the specified number of frames has elapsed.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue