greenhouse
a creative coding toolkit for spatial interfaces

Timers

Greenhouse objects have an internal timer which can be set to call back at specified intervals, independent of what else may be happening in the application.

It’s important to note that Greenhouse applications are single-threaded. When timers call back into your code, it is on the main run loop. Any slow computations there will slow down the application’s frame rate.

  • SetFireTimer ()
  • Fired ()
  • StopFireTimer ()
  • CurTime ()
  • ZeroTime ()

Example

//  A class that inherits from Image and
//  gets callbacks from a timer

#include "Greenhouse.h"

class CustomImage  :  public Image
{
  public:

  CustomImage (const Str &s)  :  Image (s)
    { SetScale (0.75); }

  void Fired ()
    { Heartbeat (0.66);
      INFORM ("CurTime () = " + ToStr (CurTime ()));
    }

  void PointingHarden (PointingEvent *e)
    { SetFireTimer (0.5);
      ZeroTime ();
    }

  void PointingSoften (PointingEvent *e)
    { StopFireTimer (); }

};

void Setup ()
{ CustomImage *ci = new CustomImage ("share/images/oblong_logo.png");
  ci -> SlapOnFeld ();
}