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; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 #include "sky_flash.h"
27 static int dbg_newline = 1;
33 gettimeofday(&tv, NULL);
34 return tv.tv_sec * 1000 + tv.tv_usec / 1000;
38 skytraq_dbg_time(void)
40 int delta = skytraq_millis() - skytraq_open_time;
44 printf ("%4d.%03d ", delta / 1000, delta % 1000);
48 skytraq_dbg_newline(void)
59 skytraq_dbg_set(int input)
63 if (input != dbg_input) {
64 skytraq_dbg_newline();
72 skytraq_dbg_char(int input, char c)
76 skytraq_dbg_set(input);
79 if (c < ' ' || c > '~')
80 printf ("\\%02x", (unsigned char) c);
90 skytraq_dbg_buf(int input, const char *buf, int len)
95 skytraq_dbg_char(input, *buf++);
99 skytraq_dbg_printf(int input, const char *fmt, ...)
103 if (!skytraq_verbose)
105 skytraq_dbg_set(input);