-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathmain.c
124 lines (95 loc) · 2.19 KB
/
main.c
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "u8g2.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "mui.h"
#include "mui_u8g2.h"
/*=================================================*/
/* global variables */
u8g2_t u8g2;
mui_t ui;
muif_t muif_list[] MUI_PROGMEM = {
MUIF_LABEL(mui_u8g2_draw_text)
};
fds_t fds[] MUI_PROGMEM =
MUI_FORM(1)
MUI_LABEL(5,12, "A label")
;
int screenshot_n = 0;
void do_screenshot(void)
{
char s[4096];
u8x8_SaveBitmapTGA(u8g2_GetU8x8(&u8g2), "screenshot.tga");
sprintf( s,
"convert -border 4 -bordercolor 'rgb(255,190,40)'"
" -fill 'rgb(255,170,0)' -opaque white"
" -filter point -resize 200%%"
" screenshot.tga pic%04d.png", screenshot_n);
system(s);
screenshot_n++;
/*
gif animation:
convert -delay 40 -loop 0 pic*.png animation.gif
*/
}
int main(void)
{
int x, y;
int k;
u8g2_SetupBuffer_SDL_128x64_4(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
u8x8_ConnectBitmapToU8x8(u8g2_GetU8x8(&u8g2)); /* connect to bitmap */
u8g2_SetFont(&u8g2, u8g2_font_6x10_tr);
u8g2_SetFontMode(&u8g2, 1);
mui_Init(&ui, &u8g2, fds, muif_list, sizeof(muif_list)/sizeof(muif_t));
mui_GotoForm(&ui, 1, 0);
x = 4; // use as height for the box
y = 0;
for(;;)
{
u8g2_SetFontRefHeightExtendedText(&u8g2);
u8g2_FirstPage(&u8g2);
do
{
mui_Draw(&ui);
} while( u8g2_NextPage(&u8g2) );
do_screenshot();
// printf("mui_GetCurrentCursorFocusPosition=%d\n", mui_GetCurrentCursorFocusPosition(&ui));
do
{
k = u8g_sdl_get_key();
} while( k < 0 );
if ( k == 273 ) y -= 1;
if ( k == 274 ) y += 1;
if ( k == 276 ) x -= 1;
if ( k == 275 ) x += 1;
/*
if ( k == 'e' ) y -= 1;
if ( k == 'x' ) y += 1;
if ( k == 's' ) x -= 1;
if ( k == 'd' ) x += 1;
*/
if ( k == 'q' ) break;
if ( k == 'n' )
{
mui_NextField(&ui);
}
if ( k == 'p' )
{
mui_PrevField(&ui);
}
if ( k == 's' )
{
mui_SendSelect(&ui);
}
if ( k == 't' )
{
puts("screenshot");
do_screenshot();
}
if ( x < 0 )
x = 0;
}
return 0;
}