FastLED 3.10.9
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 692 of file FastLED.cpp.hpp.

692 {
693 static int br = 0;
694#if SKETCH_HAS_LARGE_MEMORY
695 typedef fl::u32 frame_ms_t;
696#else
697 // Wrapping 16-bit millis saves 2 B RAM; nFrames frames must take < 65 s (#4788).
698 typedef fl::u16 frame_ms_t;
699#endif
700 static frame_ms_t lastframe = 0; // fl::millis();
701
702 if(br++ >= nFrames) {
703 const frame_ms_t sample = static_cast<frame_ms_t>(fl::millis());
704 frame_ms_t now = static_cast<frame_ms_t>(sample - lastframe);
705 if(now == 0) {
706 now = 1; // prevent division by zero below
707 }
708 mNFPS = static_cast<fl::u16>((static_cast<fl::u32>(br) * 1000) / now);
709 br = 0;
710 lastframe = sample;
711 }
712}
fl::u16 mNFPS
tracking for current frames per second (FPS) value
Definition FastLED.h:723
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: