You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
11 years ago
|
/*
|
||
7 years ago
|
* This file is part of the TREZOR project, https://trezor.io/
|
||
11 years ago
|
*
|
||
|
* Copyright (C) 2014 Pavol Rusnak <stick@satoshilabs.com>
|
||
|
*
|
||
|
* This library is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||
|
* the Free Software Foundation, either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Lesser General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public License
|
||
|
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
#include "debug.h"
|
||
|
#include "oled.h"
|
||
6 years ago
|
#include "trezor.h"
|
||
8 years ago
|
#include "util.h"
|
||
11 years ago
|
|
||
|
#if DEBUG_LOG
|
||
|
|
||
6 years ago
|
void oledDebug(const char *line) {
|
||
|
static const char *lines[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||
|
static char id = 3;
|
||
|
for (int i = 0; i < 7; i++) {
|
||
|
lines[i] = lines[i + 1];
|
||
|
}
|
||
|
lines[7] = line;
|
||
|
oledClear();
|
||
|
for (int i = 0; i < 8; i++) {
|
||
|
if (lines[i]) {
|
||
|
oledDrawChar(0, i * 8, '0' + (id + i) % 10, FONT_STANDARD);
|
||
|
oledDrawString(8, i * 8, lines[i], FONT_STANDARD);
|
||
|
}
|
||
|
}
|
||
|
oledRefresh();
|
||
|
id = (id + 1) % 10;
|
||
11 years ago
|
}
|
||
|
|
||
6 years ago
|
void debugLog(int level, const char *bucket, const char *text) {
|
||
|
(void)level;
|
||
|
(void)bucket;
|
||
7 years ago
|
#if EMULATOR
|
||
6 years ago
|
puts(text);
|
||
7 years ago
|
#else
|
||
6 years ago
|
oledDebug(text);
|
||
7 years ago
|
#endif
|
||
11 years ago
|
}
|
||
|
|
||
6 years ago
|
char *debugInt(const uint32_t i) {
|
||
|
static uint8_t n = 0;
|
||
|
static char id[8][9];
|
||
|
uint32hex(i, id[n]);
|
||
|
debugLog(0, "", id[n]);
|
||
|
char *ret = (char *)id[n];
|
||
|
n = (n + 1) % 8;
|
||
|
return ret;
|
||
8 years ago
|
}
|
||
|
|
||
11 years ago
|
#endif
|