Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
fwatch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
fwatch
Commits
621ad3a0
Commit
621ad3a0
authored
Aug 16, 2014
by
Matthieu Cattin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tom_sw_dev' into mcattin_sw_dev
parents
4cc344c6
9e191bc7
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
177 additions
and
53 deletions
+177
-53
Makefile
sw/ui-test/Makefile
+3
-3
digital_watch.c
sw/ui-test/digital_watch.c
+68
-30
font_helv11.c
sw/ui-test/font_helv11.c
+1
-1
gfx.c
sw/ui-test/gfx.c
+41
-2
gfx.h
sw/ui-test/gfx.h
+2
-1
ui.c
sw/ui-test/ui.c
+54
-15
ui.h
sw/ui-test/ui.h
+6
-0
ui_pc.c
sw/ui-test/ui_pc.c
+2
-1
No files found.
sw/ui-test/Makefile
View file @
621ad3a0
OBJS
=
gfx.o ui.o ui_pc.o font_helv17.o font_luct38.o font_xm16x25b.o digital_watch.o font_helv38b.o font_helv29.o font_helv22b.o font_xm4x6.o font_xm5x8.o
OBJS
=
gfx.o ui.o ui_pc.o font_helv17.o font_luct38.o font_xm16x25b.o digital_watch.o font_helv38b.o font_helv29.o font_helv22b.o font_xm4x6.o font_xm5x8.o
font_helv11.o
CFLAGS
=
`
sdl-config
--cflags
`
-I
.
LDFLAGS
=
`
sdl-config
--libs
`
CFLAGS
=
`
sdl-config
--cflags
`
-I
.
-g
-O0
LDFLAGS
=
`
sdl-config
--libs
`
-g
-O0
all
:
$(OBJS)
gcc
-o
pc-ui
$(OBJS)
$(LDFLAGS)
...
...
sw/ui-test/digital_watch.c
View file @
621ad3a0
#include "ui.h"
static
int
dw_h
,
dw_min
,
dw_cycles
;
extern
int64_t
sys_get_tics
();
void
sys_get_time
(
int
*
h
,
int
*
m
,
int
*
cycs
)
{
int64_t
t
=
sys_get_tics
()
/
1200
;
if
(
cycs
)
*
cycs
=
t
%
50
;
t
/=
50
;
if
(
m
)
*
m
=
t
%
60
;
t
/=
60
;
if
(
h
)
*
h
=
t
%
24
;
}
static
void
digital_watch_redraw
(
struct
ui_widget
*
w
)
{
int
h
,
m
,
c
;
sys_get_time
(
&
h
,
&
m
,
&
c
);
char
buf
[
20
];
sprintf
(
buf
,
"%02d:%02d"
,
dw_h
,
dw_min
);
sprintf
(
buf
,
"%02d:%02d"
,
h
,
m
);
gfx_clear
(
&
w
->
dc
,
0
);
gfx_text
(
&
w
->
dc
,
&
font_helv38b
,
0
,
0
,
buf
);
sprintf
(
buf
,
"%02d.%01d"
,
dw_cycles
*
12
/
10
,
(
dw_cycles
*
12
)
%
10
);
sprintf
(
buf
,
"%02d.%01d"
,
c
*
12
/
10
,
(
c
*
12
)
%
10
);
gfx_text
(
&
w
->
dc
,
&
font_helv22b
,
84
,
14
,
buf
);
...
...
@@ -21,16 +39,8 @@ static void digital_watch_event(struct ui_widget *w, struct ui_event event)
switch
(
event
.
type
)
{
case
EVT_NEXT_CYCLE
:
{
dw_cycles
=
event
.
data
%
50
;
event
.
data
/=
50
;
dw_min
=
event
.
data
%
60
;
event
.
data
/=
60
;
dw_h
=
event
.
data
%
24
;
w
->
flags
|=
WF_DIRTY
;
break
;
}
default:
break
;
}
...
...
@@ -44,10 +54,6 @@ struct ui_widget digital_watch = {
WF_ACTIVE
|
WF_VISIBLE
};
void
digtal_watch_create
()
{
ui_add_widget
(
&
digital_watch
);
}
struct
pls_cycle
{
uint8_t
current
;
...
...
@@ -68,29 +74,19 @@ static struct pls_cycle cycles[] = {
{
15
,
5
,
2
,
5
,
"ISOGPS"
}
};
static
int
pls_current
=
0
,
pls_total
=
8
;
int
pls_current
=
0
,
pls_total
=
8
;
static
void
pls_redraw
(
struct
ui_widget
*
w
)
{
gfx_clear
(
&
w
->
dc
,
0
);
// fprintf(stderr, "PLS_redraw!");
/*gfx_line(&w->dc, 64, 0, 127, 0, 1);
gfx_line(&w->dc, 64, 30, 127, 30, 1);
gfx_line(&w->dc, 64, 0, 64, 30, 1);
gfx_line(&w->dc, 127, 0, 127, 30, 1);*/
#define PERIOD 30
int
n
=
-
((
sys_get_tics
()
/
UI_TICK_RATE
)
/
2
)
%
PERIOD
;
// crap!
int
n
=
-
((
sys_get_tics
()
/
UI_TICK_RATE
))
%
PERIOD
;
int
x
=
n
,
y
=
0
,
yn
,
xn
,
x0
;
int
i
;
//printf("x0 %d\n", x);
printf
(
"pls_current %d
\n
"
,
pls_current
);
if
(
n
==
PERIOD
-
1
)
pls_current
++
;
if
(
pls_current
==
pls_total
)
...
...
@@ -164,6 +160,9 @@ static void pls_event(struct ui_widget *w, struct ui_event event)
}
}
struct
ui_widget
pls_viewer
=
{
pls_redraw
,
pls_event
,
...
...
@@ -172,9 +171,48 @@ struct ui_widget pls_viewer = {
WF_ACTIVE
|
WF_VISIBLE
};
void
pls_viewer_create
()
struct
ui_widget
home_screen
=
{
NULL
,
NULL
,
{
0
,
0
,
127
,
127
},
0
,
WF_ACTIVE
|
WF_VISIBLE
};
static
void
status_bar_event
(
struct
ui_widget
*
w
,
struct
ui_event
event
)
{
ui_add_widget
(
&
pls_viewer
);
}
static
void
status_bar_redraw
(
struct
ui_widget
*
w
)
{
//gfx_line(&w->dc, 0, w->pos.y1, 127, w->pos.y1, COLOR_BLACK);
gfx_round_box
(
&
w
->
dc
,
30
,
-
10
,
127
-
30
,
10
,
9
,
COLOR_BLACK
);
gfx_centered_text
(
&
w
->
dc
,
&
font_helv11
,
0
,
"Home"
);
}
struct
ui_widget
status_bar
=
{
status_bar_redraw
,
status_bar_event
,
{
0
,
0
,
127
,
15
},
0
,
WF_ACTIVE
|
WF_VISIBLE
};
void
home_screen_create
()
{
ui_init_widget
(
&
home_screen
);
ui_init_widget
(
&
digital_watch
);
ui_init_widget
(
&
pls_viewer
);
ui_add_widget
(
&
digital_watch
);
ui_add_widget
(
&
pls_viewer
);
ui_add_child
(
&
home_screen
,
&
digital_watch
);
ui_add_child
(
&
home_screen
,
&
pls_viewer
);
ui_add_widget
(
&
home_screen
);
ui_init_widget
(
&
status_bar
);
ui_add_widget
(
&
status_bar
);
}
sw/ui-test/font_helv11.c
View file @
621ad3a0
...
...
@@ -125,7 +125,7 @@ static const uint8_t _gd[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x24
,
0x58
,
0x00
,
0x00
,
0x00
,
0x00
};
const
font
font_helv11
=
{
const
struct
font
font_helv11
=
{
32
,
126
,
11
,
_gw
,
_go
,
_gd
};
...
...
sw/ui-test/gfx.c
View file @
621ad3a0
...
...
@@ -162,10 +162,49 @@ int gfx_text_width( const struct font *font, const char *str)
w
+=
font
->
width_table
[
c
-
font
->
min_char
];
}
printf
(
"Width %d
\n
"
,
w
);
return
w
;
}
void
gfx_fill_circle
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
int
radius
,
int
value
)
{
int
x
=
radius
;
int
y
=
0
;
int
xChange
=
1
-
(
radius
<<
1
);
int
yChange
=
0
;
int
radiusError
=
0
;
while
(
x
>=
y
)
{
int
i
;
for
(
i
=
x0
-
x
;
i
<=
x0
+
x
;
i
++
)
{
gfx_set_pixel
(
surf
,
i
,
y0
+
y
,
value
);
gfx_set_pixel
(
surf
,
i
,
y0
-
y
,
value
);
}
for
(
i
=
x0
-
y
;
i
<=
x0
+
y
;
i
++
)
{
gfx_set_pixel
(
surf
,
i
,
y0
+
x
,
value
);
gfx_set_pixel
(
surf
,
i
,
y0
-
x
,
value
);
}
y
++
;
radiusError
+=
yChange
;
yChange
+=
2
;
if
(((
radiusError
<<
1
)
+
xChange
)
>
0
)
{
x
--
;
radiusError
+=
xChange
;
xChange
+=
2
;
}
}
}
void
gfx_round_box
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
int
x1
,
int
y1
,
int
radius
,
int
value
)
{
gfx_box
(
surf
,
x0
,
y0
+
radius
,
x1
,
y1
-
radius
,
value
);
gfx_box
(
surf
,
x0
+
radius
,
y0
,
x1
-
radius
,
y1
,
value
);
gfx_fill_circle
(
surf
,
x0
+
radius
,
y0
+
radius
,
radius
,
value
);
gfx_fill_circle
(
surf
,
x1
-
radius
,
y0
+
radius
,
radius
,
value
);
gfx_fill_circle
(
surf
,
x1
-
radius
,
y1
-
radius
,
radius
,
value
);
gfx_fill_circle
(
surf
,
x0
+
radius
,
y1
-
radius
,
radius
,
value
);
}
sw/ui-test/gfx.h
View file @
621ad3a0
...
...
@@ -54,6 +54,7 @@ int gfx_text_width( const struct font *font, const char *str );
void
gfx_clear
(
struct
surface
*
surf
,
int
value
);
void
gfx_set_clip
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
int
x1
,
int
y1
);
void
gfx_reset_clip
(
struct
surface
*
surf
);
void
gfx_fill_circle
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
int
radius
,
int
value
);
void
gfx_round_box
(
struct
surface
*
surf
,
int
x0
,
int
y0
,
int
x1
,
int
y1
,
int
radius
,
int
value
);
#endif
\ No newline at end of file
sw/ui-test/ui.c
View file @
621ad3a0
...
...
@@ -22,8 +22,9 @@ void ui_init()
event_queue
.
tail
=
0
;
event_queue
.
count
=
0
;
digtal_watch_create
();
pls_viewer_create
();
// move outsidem
//digtal_watch_create();
//pls_viewer_create(); // move outsidem
}
void
ui_post_event
(
int
type
,
int
data
)
...
...
@@ -72,7 +73,7 @@ void ui_add_widget(struct ui_widget *w)
for
(
wl
=
widget_list
;
wl
->
next
;
wl
=
wl
->
next
);
wl
->
next
=
w
;
}
...
...
@@ -86,6 +87,28 @@ void ui_add_widget(struct ui_widget *w)
}
static
int
update_widget
(
struct
ui_widget
*
w
,
struct
ui_event
evt
)
{
int
i
;
int
rv
=
0
;
if
((
w
->
flags
&
WF_ACTIVE
)
&&
(
w
->
event
))
{
w
->
event
(
w
,
evt
);
}
if
((
w
->
flags
&
WF_VISIBLE
)
&&
(
w
->
flags
&
WF_DIRTY
))
{
if
(
w
->
redraw
)
{
w
->
redraw
(
w
);
w
->
flags
&=
~
WF_DIRTY
;
}
return
1
;
}
return
0
;
}
void
ui_update
()
{
struct
ui_event
evt
;
...
...
@@ -97,21 +120,37 @@ void ui_update()
struct
ui_widget
*
w
;
for
(
w
=
widget_list
;
w
;
w
=
w
->
next
)
{
//DBG("w %p flags %x\n", w, w->flags);
if
((
w
->
flags
&
WF_ACTIVE
)
&&
(
w
->
event
))
{
w
->
event
(
w
,
evt
);
}
if
((
w
->
flags
&
WF_VISIBLE
)
&&
(
w
->
flags
&
WF_DIRTY
))
{
w
->
redraw
(
w
);
w
->
flags
&=
~
WF_DIRTY
;
screen_dirty
=
1
;
}
screen_dirty
|=
update_widget
(
w
,
evt
);
}
}
if
(
screen_dirty
)
lcd_update
(
&
screen
);
}
void
ui_activate
(
struct
ui_widget
*
w
,
int
activate
)
{
}
void
ui_show
(
struct
ui_widget
*
w
,
int
show
)
{
}
void
ui_set_modal
(
struct
ui_widget
*
w
,
int
modal
)
{
}
void
ui_init_widget
(
struct
ui_widget
*
w
)
{
w
->
n_children
=
0
;
}
void
ui_add_child
(
struct
ui_widget
*
w
,
struct
ui_widget
*
child
)
{
w
->
children
[
w
->
n_children
]
=
child
;
w
->
flags
|=
WF_DIRTY
;
w
->
n_children
++
;
}
\ No newline at end of file
sw/ui-test/ui.h
View file @
621ad3a0
...
...
@@ -24,6 +24,8 @@
#define UI_TICK_RATE 30
/* UI refresh ticks = 30 milliseconds */
#define UI_CYCLE_RATE 1200
/* The Machine Cycle */
#define MAX_CHILD_WIDGETS 8
struct
ui_event
{
int
type
;
int
data
;
...
...
@@ -38,8 +40,12 @@ struct ui_widget {
struct
surface
dc
;
struct
ui_widget
*
next
;
struct
ui_widget
*
children
[
MAX_CHILD_WIDGETS
];
int
n_children
;
};
extern
struct
surface
screen
;
#endif
sw/ui-test/ui_pc.c
View file @
621ad3a0
...
...
@@ -25,7 +25,7 @@ static int64_t last_tics = -1;
gettimeofday
(
&
tv
,
&
tz
);
return
(
tv
.
tv_sec
*
1000000LL
+
tv
.
tv_usec
)
/
1000LL
;
return
(
(
int64_t
)
tv
.
tv_sec
*
1000000LL
+
tv
.
tv_usec
)
/
1000LL
;
}
int
sys_update
()
...
...
@@ -167,6 +167,7 @@ main()
sys_init
();
ui_init
();
home_screen_create
();
for
(;;)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment