summaryrefslogtreecommitdiff
path: root/i/serialplot/serialplot_sdl.c
diff options
context:
space:
mode:
Diffstat (limited to 'i/serialplot/serialplot_sdl.c')
-rw-r--r--i/serialplot/serialplot_sdl.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/i/serialplot/serialplot_sdl.c b/i/serialplot/serialplot_sdl.c
index 8dbbb8b..2c4fb32 100644
--- a/i/serialplot/serialplot_sdl.c
+++ b/i/serialplot/serialplot_sdl.c
@@ -35,8 +35,8 @@ draw (int melt, int n, int vals[], double scale[],int position[])
if (y<0)
y=0;
else
- if(y > screen->h)
- y = screen->h;
+ if(y >= screen->h)
+ y = screen->h - 1;
color = SDL_MapRGB (screen->format,
colors[c][0],
colors[c][1],
@@ -67,19 +67,28 @@ draw (int melt, int n, int vals[], double scale[],int position[])
void
nextFrame (void)
{
-// static int lastFrame = 0;
-// static const int minFrame = 1000 / 50;
-// int curFrame;
+ static int lastUpdate = 0;
+ int curFrame;
+ curFrame = SDL_GetTicks ();
+ if (!lastUpdate || lastUpdate < curFrame - 1000 / 10)
+ {
+ lastUpdate = curFrame;
+ SDL_Flip (screen);
+ }
+#if 0
+ static int lastFrame = 0;
+ static const int minFrame = 1000 / 50;
+ int curFrame;
/* Echange les deux tampons. */
SDL_Flip (screen);
/* Freine le programme s'il est trops rapide. */
-// curFrame = SDL_GetTicks ();
-// if (lastFrame && lastFrame + minFrame > curFrame)
-// SDL_Delay (lastFrame + minFrame - curFrame);
+ curFrame = SDL_GetTicks ();
+ if (lastFrame && lastFrame + minFrame > curFrame)
+ SDL_Delay (lastFrame + minFrame - curFrame);
/* Enregistre l'heure de dernier rafraichisement. */
-// lastFrame = curFrame;
-
+ lastFrame = curFrame;
+#endif
}
void