This sketch uses Profile and a packet handler to generate profile reports on demand that will be valid over days or weeks of runtime. The SFBProfile::getPPM method produces results from 0 to 1,000,000; dividing those values by 10,000 produces percentage figures. This sketch uses the QLED system to blink the LEDs and generate a bit of alarm handling load.

Typical output from this sketch in response to 'p' packets:

    Ln 28.447 BG=97.97 SI=0.01 OI=1.60 PH=0.06 AH=0.35
    Ln 37.321 BG=97.98 SI=0.01 OI=1.60 PH=0.05 AH=0.35
showing that nearly 98% of the time is assigned to 'background', and the next largest category is 'other interrupt' at 1.6%, followed by alarm handlers at 0.35% -- looks like QLED is just too efficient!

// Demonstrate the 'Profile' profiling object

// Report time percentages in all the built-in categories
void reportProfile(u8 *) {
  logNormal("BG=%f SI=%f OI=%f PH=%f AH=%f\n",

void setup() {
  Profile.begin();              // Start the longer-term profiling system
  QLED.begin();                 // Let's use QLEDs to drive some alarm usage

void loop() {

  // Spin the LEDs..
  for (u32 i = 0, f = NORTH; i <= 3; ++i, f = CLOCKWISE_FACE(f)) {,f),i*80);      // First, increasing off time
    QLED.on(pinInFace(FACE_LED_PIN,f),100);        // then same amount of blink time,f),(3-i)*80);  // then decreasing off time to even up

  // ..once per second

Generated on Fri Apr 22 06:54:11 2011 for SFB by doxygen 1.5.9