blob: 4a4b464864c8d629a1a7909c95d8c7d4c1d9cc69 [file] [log] [blame]
Adrien Destugues69b1f062017-06-05 13:44:30 +02001/*
2 * Copyright 2017, Adrien Destugues, pulkomandy@pulkomandy.tk
3 * Distributed under terms of the MIT license.
4 */
5
6// Contiki includes
7#include "ctk.h"
8#include "program-handler.h"
9
10#include "clock-conf.h"
11
12// Applications
13#include "netconf-dsc.h"
14#include "dhcp-dsc.h"
15#include "www-dsc.h"
16#include "webserver-dsc.h"
17#include "ftp-dsc.h"
18#include "telnet-dsc.h"
19#include "email-dsc.h"
20#include "irc-dsc.h"
21#include "editor-dsc.h"
22#include "calc-dsc.h"
23#include "processes-dsc.h"
24#include "shell-dsc.h"
25#include "about-dsc.h"
26
27// Bitbox includes
28#include "lib/textmode/textmode.h"
29
30void conio_init(void)
31{
32 // Clear display and set a visible palette (default is black on black)
33 clear();
34
35 for (int i = 0; i < 256; i++)
36 set_palette(i, 0, 0);
37
38 set_palette(0, RGB(0, 0, 0), RGB(0, 0, 0)); // border (ok)
39 set_palette(1, RGB(0, 0, 0), RGB(146, 146, 255)); // screen (ok)
40 set_palette(3, RGB(0, 0, 0), RGB(128, 128, 128)); // open menu (ok)
41 set_palette(4, RGB(0, 0, 0), RGB(255, 128, 128)); // active menu item (ok)
42 set_palette(5, RGB(0, 0, 0), RGB(240,240,240)); // dialogs (ok)
43 set_palette(6, RGB(100,100,255), RGB(255,128,128)); // highlighted hyperlinks (ok)
44 set_palette(8, RGB(64,64,64), RGB(192,192,192)); // inactive window/widgets
45
46 set_palette(2+16, RGB(0, 0, 0), RGB(255, 255, 255)); // menu (ok)
47 set_palette(6+16, RGB(0, 0, 255), RGB(240,240,240)); // hyperlinks (ok)
48 set_palette(7+16, RGB(0,0,0), RGB(255,128,128)); // focus widget
49
50 set_palette(7, RGB(0,0,64), RGB(192,192,255)); // moving window
51
52
53}
54
55clock_time_t clock_time(void)
56{
57 return vga_frame;
58}
59
60void
61log_message(const char *part1, const char *part2)
62{
63 printf("%s%s\n", part1, part2);
64}
65
66void bitbox_main(void)
67{
68 ek_init();
69 conio_init();
70 ctk_init();
71 program_handler_init();
72
73#if 0
74 program_handler_add(&netconf_dsc, "Network setup", 1);
75 program_handler_add(&dhcp_dsc, "DHCP client", 1);
76 program_handler_add(&www_dsc, "Web browser", 1);
77 program_handler_add(&webserver_dsc, "Web server", 1);
78 program_handler_add(&ftp_dsc, "FTP client", 1);
79 program_handler_add(&telnet_dsc, "Telnet", 1);
80 program_handler_add(&email_dsc, "E-mail", 1);
81 program_handler_add(&irc_dsc, "IRC client", 1);
82#endif
83 program_handler_add(&editor_dsc, "Editor", 1);
84 program_handler_add(&calc_dsc, "Calculator", 1);
85 program_handler_add(&processes_dsc, "Processes", 1);
86 //program_handler_add(&shell_dsc, "Command shell", 1);
87 program_handler_add(&about_dsc, "About Contiki", 0);
88
89 // Call ek_run until everything is initialized. Then, load welcome.prg.
90 while(1) {
91 if(ek_run() == 0) {
92 //program_handler_load("welcome.prg", NULL);
93 //TODO we don't have a loader; so call the init func directly
94 break;
95 }
96 }
97 // Run the main loop.
98 while(1) {
99 if (ek_run() == 0) {
100 // We are out of events to run, sleep a little.
101 wait_vsync(1);
102 }
103 }
104}