File: Timer.cpp

package info (click to toggle)
dasher 5.0.0~beta~repack2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 70,872 kB
  • sloc: xml: 181,314; cpp: 70,860; java: 8,020; python: 3,579; makefile: 939; sh: 324; ansic: 223; perl: 71
file content (30 lines) | stat: -rw-r--r-- 600 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "../Common/Common.h"

#include "Timer.h"
#include "DasherControl.h"

#include <sys/time.h>

gint timer_callback(gpointer data) {
  return static_cast < CDasherControl * >(data)->TimerEvent();
}

gint long_timer_callback(gpointer data) {
  return static_cast < CDasherControl * >(data)->LongTimerEvent();
}

long get_time() {
  // We need to provide a monotonic time source that ticks every millisecond
  long s_now;
  long ms_now;

  struct timeval tv;
  struct timezone tz;

  gettimeofday(&tv, &tz);

  s_now = tv.tv_sec;
  ms_now = tv.tv_usec / 1000;

  return (s_now * 1000 + ms_now);
}