Make sure each screen stays on for a minimum of three seconds (eight if it contains...
authorSteinar H. Gunderson <sesse@samfundet.no>
Tue, 1 Mar 2005 01:02:20 +0000 (01:02 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Tue, 1 Mar 2005 01:02:20 +0000 (01:02 +0000)
bigscreen/rotatescreen.cpp
bigscreen/rotatescreen.h

index 6b244e8..275b73e 100644 (file)
@@ -20,6 +20,8 @@ bool RotateScreen::check_invalidated()
                return true;
        if (needs_update())
                return true;
+       if (!can_update())
+               return false;
        
        for (unsigned i = 0; i < subscreens.size(); ++i) {
                if (subscreens[i].screen->check_invalidated())
@@ -147,6 +149,22 @@ bool RotateScreen::needs_update()
        return (since >= 10.0);
 }
 
+// hold all screens for minimum three seconds, hold all screens with new info for at minimum eight seconds
+bool RotateScreen::can_update()
+{
+       struct timeval now;
+       gettimeofday(&now, NULL);
+
+       double since = double(now.tv_sec - last_update.tv_sec) +
+               double(now.tv_usec - last_update.tv_usec) * 1.0e-6;
+
+       if (since < 3.0)
+               return false;
+       if (fade_to_new_info && since < 8.0)
+               return false;
+       return true;
+}
+
 void RotateScreen::add_screen(GenericScreen *screen)
 {
        Subscreen ss;
index 114f6c0..6a5c35f 100644 (file)
@@ -26,6 +26,7 @@ private:
        bool in_fade, fade_found_start_time, fade_to_new_info;
 
        bool needs_update();
+       bool can_update();
        
 public:
        RotateScreen();