Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dos
firmware
Commits
626180e9
Commit
626180e9
authored
5 years ago
by
Mateusz Zalega
Browse files
Options
Downloads
Patches
Plain Diff
epicardium: added textbuffer API
Signed-off-by:
Mateusz Zalega
<
mateusz@appliedsourcery.com
>
parent
c13ee1f8
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
epicardium/epicardium.h
+57
-0
57 additions, 0 deletions
epicardium/epicardium.h
epicardium/modules/display.c
+67
-0
67 additions, 0 deletions
epicardium/modules/display.c
lib/gfx/textbuffer.c
+20
-7
20 additions, 7 deletions
lib/gfx/textbuffer.c
lib/gfx/textbuffer.h
+4
-3
4 additions, 3 deletions
lib/gfx/textbuffer.h
with
148 additions
and
10 deletions
epicardium/epicardium.h
+
57
−
0
View file @
626180e9
...
@@ -51,6 +51,12 @@ typedef _Bool bool;
...
@@ -51,6 +51,12 @@ typedef _Bool bool;
#define API_DISP_CIRC 0x27
#define API_DISP_CIRC 0x27
#define API_DISP_PIXEL 0x28
#define API_DISP_PIXEL 0x28
#define API_DISP_FRAMEBUFFER 0x29
#define API_DISP_FRAMEBUFFER 0x29
#define API_DISP_TXT_UPDATE 0x2A
#define API_DISP_TXT_CLEAR 0x2B
#define API_DISP_TXT_PRINT 0x2C
#define API_DISP_TXT_SET_COLOR 0x2D
#define API_DISP_TXT_SET_CURSOR 0x2E
#define API_DISP_TXT_SET_AUTOUPDATE 0x2F
#define API_FILE_OPEN 0x40
#define API_FILE_OPEN 0x40
#define API_FILE_CLOSE 0x41
#define API_FILE_CLOSE 0x41
...
@@ -695,6 +701,57 @@ API(API_DISP_CIRC,
...
@@ -695,6 +701,57 @@ API(API_DISP_CIRC,
*/
*/
API
(
API_DISP_FRAMEBUFFER
,
int
epic_disp_framebuffer
(
union
disp_framebuffer
*
fb
));
API
(
API_DISP_FRAMEBUFFER
,
int
epic_disp_framebuffer
(
union
disp_framebuffer
*
fb
));
/**
* Redraw the framebuffer
*
* :return: ``0`` on success, can't fail
*/
API
(
API_DISP_TXT_UPDATE
,
int
epic_disp_txt_update
());
/**
* Fills the framebuffer with ' ' characters. Does not update the framebuffer.
*
* :return: ``0`` on success, can't fail
*/
API
(
API_DISP_TXT_CLEAR
,
int
epic_disp_txt_clear
());
/**
* Puts the string on the buffer. Updates the cursor. Does not update the
* framebuffer.
*
* :param string: A null-terminated ASCII string.
* :return: ``0`` on success, can't fail
*/
API
(
API_DISP_TXT_PRINT
,
int
epic_disp_txt_print
(
const
char
*
string
));
/**
* Updates the active background and foreground colors.
*
* :param fg: The display-encoded foreground color
* :param bg: The display-encoded background color
* :return: ``0`` on success, can't fail
*/
API
(
API_DISP_TXT_SET_COLOR
,
int
epic_disp_txt_set_color
(
uint16_t
fg
,
uint16_t
bg
));
/**
* Sets cursor location within the textbuffer space.
*
* :param x: new cursor column
* :param x: new cursor row
* :param draw_cursor: specifies whether the cursor should be drawn
* :return: ``0`` on success, can't fail
*/
API
(
API_DISP_TXT_SET_CURSOR
,
int
epic_disp_txt_set_cursor
(
uint16_t
x
,
uint16_t
y
,
uint16_t
draw_cursor
));
/**
* Enables/disables automatic framebuffer updates. Automatic updates occur
* with every character written to the buffer - epic_disp_txt_update() is
* implicitly called.
*
* :param enabled: if not zero, textbuffer will be updated automatically
* :return: ``0`` on success, can't fail
*/
API
(
API_DISP_TXT_SET_AUTOUPDATE
,
int
epic_disp_txt_set_autoupdate
(
uint16_t
enabled
));
/**
/**
* Start continuous readout of the light sensor. Will read light level
* Start continuous readout of the light sensor. Will read light level
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/display.c
+
67
−
0
View file @
626180e9
...
@@ -194,6 +194,73 @@ int epic_disp_close()
...
@@ -194,6 +194,73 @@ int epic_disp_close()
}
}
}
}
int
epic_disp_txt_update
()
{
int
cl
=
check_lock
();
if
(
cl
<
0
)
{
return
cl
;
}
txt_update
(
&
display_textb
,
1
);
return
0
;
}
int
epic_disp_txt_clear
()
{
int
cl
=
check_lock
();
if
(
cl
<
0
)
{
return
cl
;
}
txt_clear
(
&
display_textb
);
return
0
;
}
int
epic_disp_txt_print
(
const
char
*
string
)
{
int
cl
=
check_lock
();
if
(
cl
<
0
)
{
return
cl
;
}
txt_puts
(
&
display_textb
,
string
);
return
0
;
}
int
epic_disp_txt_set_color
(
uint16_t
fg
,
uint16_t
bg
)
{
int
cl
=
check_lock
();
if
(
cl
<
0
)
{
return
cl
;
}
txt_set_color
(
&
display_textb
,
TEXT_FOREGROUND
,
(
Color
)(
fg
));
txt_set_color
(
&
display_textb
,
TEXT_BACKGROUND
,
(
Color
)(
bg
));
return
0
;
}
int
epic_disp_txt_set_cursor
(
uint16_t
x
,
uint16_t
y
,
uint16_t
draw_cursor
)
{
int
cl
=
check_lock
();
if
(
cl
<
0
)
{
return
cl
;
}
txt_set_cursor
(
&
display_textb
,
x
,
y
,
draw_cursor
);
return
0
;
}
int
epic_disp_txt_set_autoupdate
(
uint16_t
enabled
)
{
int
cl
=
check_lock
();
if
(
cl
<
0
)
{
return
cl
;
}
display_textb
.
auto_update
=
enabled
;
return
0
;
}
void
disp_forcelock
()
void
disp_forcelock
()
{
{
TaskHandle_t
task
=
xTaskGetCurrentTaskHandle
();
TaskHandle_t
task
=
xTaskGetCurrentTaskHandle
();
...
...
This diff is collapsed.
Click to expand it.
lib/gfx/textbuffer.c
+
20
−
7
View file @
626180e9
...
@@ -114,7 +114,7 @@ void txt_clear(struct txt_buffer *tm)
...
@@ -114,7 +114,7 @@ void txt_clear(struct txt_buffer *tm)
tm
->
needs_redraw
=
1
;
tm
->
needs_redraw
=
1
;
if
(
tm
->
auto_update
)
if
(
tm
->
auto_update
)
txt_update
(
tm
);
txt_update
(
tm
,
0
);
}
}
void
txt_putchar
(
struct
txt_buffer
*
tm
,
char
ch
)
void
txt_putchar
(
struct
txt_buffer
*
tm
,
char
ch
)
...
@@ -139,7 +139,7 @@ void txt_putchar(struct txt_buffer *tm, char ch)
...
@@ -139,7 +139,7 @@ void txt_putchar(struct txt_buffer *tm, char ch)
tm
->
needs_redraw
=
1
;
tm
->
needs_redraw
=
1
;
if
(
tm
->
auto_update
)
if
(
tm
->
auto_update
)
txt_update
(
tm
);
txt_update
(
tm
,
0
);
}
}
void
txt_puts
(
struct
txt_buffer
*
tm
,
const
char
*
str
)
void
txt_puts
(
struct
txt_buffer
*
tm
,
const
char
*
str
)
...
@@ -219,8 +219,9 @@ void txt_set_color_f(
...
@@ -219,8 +219,9 @@ void txt_set_color_f(
}
}
}
}
void
txt_set_color
(
struct
txt_buffer
*
tm
,
enum
txt_color
sw
,
int
r
,
int
g
,
int
b
)
void
txt_set_color_rgb
(
{
struct
txt_buffer
*
tm
,
enum
txt_color
sw
,
int
r
,
int
g
,
int
b
)
{
Color
c
=
gfx_color_rgb
(
tm
->
reg
,
r
,
g
,
b
);
Color
c
=
gfx_color_rgb
(
tm
->
reg
,
r
,
g
,
b
);
switch
(
c
)
{
switch
(
c
)
{
...
@@ -233,6 +234,18 @@ void txt_set_color(struct txt_buffer *tm, enum txt_color sw, int r, int g, int b
...
@@ -233,6 +234,18 @@ void txt_set_color(struct txt_buffer *tm, enum txt_color sw, int r, int g, int b
}
}
}
}
void
txt_set_color
(
struct
txt_buffer
*
tm
,
enum
txt_color
sw
,
Color
c
)
{
switch
(
c
)
{
case
TEXT_FOREGROUND
:
tm
->
fg_color
=
c
;
break
;
case
TEXT_BACKGROUND
:
tm
->
bg_color
=
c
;
break
;
}
}
void
txt_set_cursor
(
struct
txt_buffer
*
tm
,
int
x
,
int
y
,
int
draw_cursor
)
void
txt_set_cursor
(
struct
txt_buffer
*
tm
,
int
x
,
int
y
,
int
draw_cursor
)
{
{
tm
->
draw_cursor
=
draw_cursor
;
tm
->
draw_cursor
=
draw_cursor
;
...
@@ -246,7 +259,7 @@ void txt_set_cursor(struct txt_buffer *tm, int x, int y, int draw_cursor)
...
@@ -246,7 +259,7 @@ void txt_set_cursor(struct txt_buffer *tm, int x, int y, int draw_cursor)
tm
->
cursor_row
=
y
;
tm
->
cursor_row
=
y
;
if
(
tm
->
auto_update
)
if
(
tm
->
auto_update
)
txt_update
(
tm
);
txt_update
(
tm
,
0
);
}
}
void
txt_set_transparent
(
struct
txt_buffer
*
tm
)
void
txt_set_transparent
(
struct
txt_buffer
*
tm
)
...
@@ -254,9 +267,9 @@ void txt_set_transparent(struct txt_buffer *tm)
...
@@ -254,9 +267,9 @@ void txt_set_transparent(struct txt_buffer *tm)
tm
->
bg_color
=
tm
->
fg_color
;
tm
->
bg_color
=
tm
->
fg_color
;
}
}
void
txt_update
(
struct
txt_buffer
*
tm
)
void
txt_update
(
struct
txt_buffer
*
tm
,
int
force_redraw
)
{
{
if
(
tm
->
needs_redraw
)
if
(
tm
->
needs_redraw
||
force_redraw
)
txt_draw
(
tm
);
txt_draw
(
tm
);
gfx_update
(
tm
->
reg
);
gfx_update
(
tm
->
reg
);
}
}
This diff is collapsed.
Click to expand it.
lib/gfx/textbuffer.h
+
4
−
3
View file @
626180e9
...
@@ -41,10 +41,11 @@ void txt_puts(struct txt_buffer *tm, const char *str);
...
@@ -41,10 +41,11 @@ void txt_puts(struct txt_buffer *tm, const char *str);
void
txt_draw
(
struct
txt_buffer
*
tm
);
void
txt_draw
(
struct
txt_buffer
*
tm
);
void
txt_set_color_f
(
struct
txt_buffer
*
tm
,
enum
txt_color
sw
,
float
r
,
float
g
,
void
txt_set_color_f
(
struct
txt_buffer
*
tm
,
enum
txt_color
sw
,
float
r
,
float
g
,
float
b
);
float
b
);
void
txt_set_color
(
struct
txt_buffer
*
tm
,
enum
txt_color
sw
,
int
r
,
int
g
,
void
txt_set_color
_rgb
(
struct
txt_buffer
*
tm
,
enum
txt_color
sw
,
int
r
,
int
g
,
int
b
);
int
b
);
void
txt_set_color
(
struct
txt_buffer
*
tm
,
enum
txt_color
sw
,
Color
c
);
void
txt_set_transparent
(
struct
txt_buffer
*
tm
);
void
txt_set_transparent
(
struct
txt_buffer
*
tm
);
void
txt_set_cursor
(
struct
txt_buffer
*
tm
,
int
x
,
int
y
,
int
draw_cursor
);
void
txt_set_cursor
(
struct
txt_buffer
*
tm
,
int
x
,
int
y
,
int
draw_cursor
);
void
txt_update
(
struct
txt_buffer
*
tm
);
void
txt_update
(
struct
txt_buffer
*
tm
,
int
force_redraw
);
#endif
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment