blob: 43ed1352d216666a69b1cc5f55160a41c21333a9 (
plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#include <ncurses.h>
#include <stdio.h>
#include <stdlib.h>
#include "../shared/bin.h"
#include "../shared/protocol.h"
#include "commands.h"
#include "serial.h"
#include "setup.h"
#include "strings.h"
#include "ui.h"
// pointers for endianness check
static const uint16_t _test = 1;
static const uint8_t *_ptest = (uint8_t *)&_test;
uint8_t g_w2_endianness;
void w2_client_setup(int argc, char **argv) {
if (argc < 2) {
printf(W2_UI_CLI_USAGE, argv[0]);
exit(1);
}
if (w2_serial_open(argv[1]) == 0) {
printf(W2_UI_CLI_SERPORT_ERROR);
exit(1);
}
if ((g_w2_ui_win = initscr()) == NULL) {
printf(W2_UI_CLI_INITSCR_FAIL);
exit(1);
}
noecho();
curs_set(false);
nodelay(g_w2_ui_win, true);
keypad(g_w2_ui_win, true);
w2_strings_init();
w2_cmd_setup_handlers();
w2_ui_tabbar_init();
w2_send_info();
g_w2_ui_width = getmaxx(g_w2_ui_win);
g_w2_ui_height = getmaxy(g_w2_ui_win);
g_w2_ui_pad_tabbar = newpad(1, g_w2_ui_width);
g_w2_ui_pad_body = newpad(g_w2_ui_height - 5, g_w2_ui_width);
g_w2_ui_pad_statusbar = newpad(2, g_w2_ui_width);
g_w2_ui_pad_seperator = newpad(1, g_w2_ui_width + 1);
scrollok(g_w2_ui_pad_body, true);
// check endianness
g_w2_endianness = *_ptest;
}
|