FastLED 3.10.8
Loading...
Searching...
No Matches

◆ countFPS()

void CFastLED::countFPS ( int nFrames = 25)

For debugging, this will keep track of time between calls to countFPS().

Every nFrames calls, it will update an internal counter for the current FPS.

Todo
Make this a rolling counter
Parameters
nFrameshow many frames to time for determining FPS

Definition at line 688 of file FastLED.cpp.hpp.

688 {
689 static int br = 0;
690#if SKETCH_HAS_LARGE_MEMORY
691 typedef fl::u32 frame_ms_t;
692#else
693 // Wrapping 16-bit millis saves 2 B RAM; nFrames frames must take < 65 s (#4788).
694 typedef fl::u16 frame_ms_t;
695#endif
696 static frame_ms_t lastframe = 0; // fl::millis();
697
698 if(br++ >= nFrames) {
699 const frame_ms_t sample = static_cast<frame_ms_t>(fl::millis());
700 frame_ms_t now = static_cast<frame_ms_t>(sample - lastframe);
701 if(now == 0) {
702 now = 1; // prevent division by zero below
703 }
704 mNFPS = static_cast<fl::u16>((static_cast<fl::u32>(br) * 1000) / now);
705 br = 0;
706 lastframe = sample;
707 }
708}
fl::u16 mNFPS
tracking for current frames per second (FPS) value
Definition FastLED.h:728
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode) FL_NO_EXCEPT
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.

References FL_NO_EXCEPT, fl::millis(), and mNFPS.

Referenced by show(), and showColor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: