2 * Copyright © 2012 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 #include "sky_flash.h"
26 static int dbg_newline = 1;
32 gettimeofday(&tv, NULL);
33 return tv.tv_sec * 1000 + tv.tv_usec / 1000;
37 skytraq_dbg_time(void)
39 int delta = skytraq_millis() - skytraq_open_time;
43 printf ("%4d.%03d ", delta / 1000, delta % 1000);
47 skytraq_dbg_newline(void)
58 skytraq_dbg_set(int input)
62 if (input != dbg_input) {
63 skytraq_dbg_newline();
71 skytraq_dbg_char(int input, char c)
75 skytraq_dbg_set(input);
78 if (c < ' ' || c > '~')
79 printf ("\\%02x", (unsigned char) c);
89 skytraq_dbg_buf(int input, const char *buf, int len)
94 skytraq_dbg_char(input, *buf++);
98 skytraq_dbg_printf(int input, const char *fmt, ...)
102 if (!skytraq_verbose)
104 skytraq_dbg_set(input);