Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
firmware
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
François Revol
firmware
Commits
14d9754e
Commit
14d9754e
authored
Aug 11, 2019
by
Mateusz Zalega
Committed by
Rahix
Sep 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(gfx): Moved RLE decoding code to lib/gfx
Signed-off-by:
Mateusz Zalega
<
mateusz@appliedsourcery.com
>
parent
ee45bbd8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
151 additions
and
42 deletions
+151
-42
bootloader/bootloader-display.c
bootloader/bootloader-display.c
+10
-23
epicardium/main.c
epicardium/main.c
+9
-2
hw-tests/dual-core/main.c
hw-tests/dual-core/main.c
+14
-7
hw-tests/hello-world/main.c
hw-tests/hello-world/main.c
+9
-2
hw-tests/ips/main.c
hw-tests/ips/main.c
+6
-4
lib/gfx/gfx.c
lib/gfx/gfx.c
+94
-2
lib/gfx/gfx.h
lib/gfx/gfx.h
+9
-2
No files found.
bootloader/bootloader-display.c
View file @
14d9754e
...
...
@@ -6,31 +6,18 @@
#include "gfx.h"
#include "display.h"
/*
* "Decompress" splash-screen image. The algorithm works as follows:
*
* Each byte encodes up to 127 pixels in either white or black. The most
* significant bit determines the color, the remaining 7 bits determine the
* amount.
*/
static
void
bootloader_display_splash
(
void
)
{
int
idx
=
0
;
Color
white
=
gfx_color
(
&
display_screen
,
WHITE
);
Color
black
=
gfx_color
(
&
display_screen
,
BLACK
);
for
(
int
i
=
0
;
i
<
sizeof
(
splash
);
i
++
)
{
Color
color
=
(
splash
[
i
]
&
0x80
)
?
white
:
black
;
uint8_t
length
=
splash
[
i
]
&
0x7f
;
for
(
int
j
=
0
;
j
<
length
;
j
++
)
{
uint16_t
x
=
idx
%
160
;
uint16_t
y
=
idx
/
160
;
gfx_setpixel
(
&
display_screen
,
x
,
y
,
color
);
idx
++
;
}
}
gfx_copy_region
(
&
display_screen
,
0
,
0
,
160
,
80
,
GFX_RLE_MONO
,
sizeof
(
splash
),
(
const
void
*
)(
splash
)
);
gfx_update
(
&
display_screen
);
}
...
...
epicardium/main.c
View file @
14d9754e
...
...
@@ -34,8 +34,15 @@ int main(void)
mxc_delay
(
500000
);
epic_disp_clear
(
0x0000
);
if
(
strcmp
(
CARD10_VERSION
,
"v1.10"
)
==
0
)
{
gfx_copy_region_raw
(
&
display_screen
,
0
,
0
,
160
,
80
,
2
,
version_splash
gfx_copy_region
(
&
display_screen
,
0
,
0
,
160
,
80
,
GFX_RAW
,
sizeof
(
version_splash
),
version_splash
);
}
else
{
const
int
off
=
(
160
-
(
int
)
strlen
(
version_buf
)
*
14
)
/
2
;
...
...
hw-tests/dual-core/main.c
View file @
14d9754e
...
...
@@ -3,27 +3,34 @@
******************************************************************************/
/***** Includes *****/
#include "pmic.h"
#include "leds.h"
#include "card10.h"
#include "leds.h"
#include "pmic.h"
#include "gfx.h"
#include "display.h"
#include "gfx.h"
#include "tmr_utils.h"
#include <
stdio
.h>
#include <
Heart
.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <Heart.h>
int
main
(
void
)
{
card10_init
();
card10_diag
();
gfx_copy_region_raw
(
&
display_screen
,
0
,
0
,
160
,
80
,
2
,
(
const
void
*
)(
Heart
)
gfx_copy_region
(
&
display_screen
,
0
,
0
,
160
,
80
,
GFX_RAW
,
sizeof
(
Heart
),
(
const
void
*
)(
Heart
)
);
gfx_update
(
&
display_screen
);
...
...
hw-tests/hello-world/main.c
View file @
14d9754e
...
...
@@ -30,8 +30,15 @@ int main(void)
card10_init
();
card10_diag
();
gfx_copy_region_raw
(
&
display_screen
,
0
,
0
,
160
,
80
,
2
,
(
const
void
*
)(
Heart
)
gfx_copy_region
(
&
display_screen
,
0
,
0
,
160
,
80
,
GFX_RAW
,
sizeof
(
Heart
),
(
const
void
*
)(
Heart
)
);
gfx_update
(
&
display_screen
);
...
...
hw-tests/ips/main.c
View file @
14d9754e
...
...
@@ -37,22 +37,24 @@ int main(void)
gfx_line
(
&
display_screen
,
100
,
10
,
70
,
40
,
2
,
yellow
);
gfx_circle
(
&
display_screen
,
85
,
25
,
22
,
2
,
green
);
gfx_copy_region
_raw
(
gfx_copy_region
(
&
display_screen
,
120
,
0
,
40
,
40
,
2
,
GFX_RAW
,
40
*
40
*
2
,
(
const
void
*
)(
gImage_40X40
)
);
gfx_copy_region
_raw
(
gfx_copy_region
(
&
display_screen
,
0
,
0
,
160
,
80
,
2
,
GFX_RAW
,
160
*
80
*
2
,
(
const
void
*
)(
gImage_160X80
)
);
gfx_update
(
&
display_screen
);
...
...
lib/gfx/gfx.c
View file @
14d9754e
...
...
@@ -273,15 +273,17 @@ Color gfx_color(struct gfx_region *reg, enum gfx_color color)
return
gfx_color_rgb
(
reg
,
c
->
r
,
c
->
g
,
c
->
b
);
}
void
gfx_copy_region_raw
(
static
void
gfx_copy_region_raw
(
struct
gfx_region
*
reg
,
int
x
,
int
y
,
int
w
,
int
h
,
size_t
bpp
,
size_t
size
,
const
void
*
p
)
{
size_t
bpp
=
size
/
(
w
*
h
);
for
(
int
y_
=
0
;
y_
<
h
;
y_
++
)
{
for
(
int
x_
=
0
;
x_
<
w
;
x_
++
)
{
Color
c
;
...
...
@@ -299,6 +301,96 @@ void gfx_copy_region_raw(
}
}
static
void
gfx_copy_region_mono
(
struct
gfx_region
*
reg
,
int
x
,
int
y
,
int
w
,
int
h
,
size_t
size
,
const
void
*
p
)
{
const
char
*
bp
=
p
;
int
bit
=
0
;
Color
white
=
gfx_color
(
reg
,
WHITE
);
Color
black
=
gfx_color
(
reg
,
BLACK
);
for
(
int
y_
=
0
;
y_
<
h
;
y_
++
)
{
for
(
int
x_
=
0
;
x_
<
w
;
x_
++
)
{
int
value
=
*
bp
&
(
1
<<
bit
);
if
(
++
bit
>=
8
)
{
bp
++
;
bit
%=
8
;
if
((
const
void
*
)(
bp
)
>=
(
p
+
size
))
return
;
}
Color
c
=
value
?
white
:
black
;
gfx_setpixel
(
reg
,
x
+
x_
,
y
+
y_
,
c
);
}
}
}
/*
* "Decompress" the image. The algorithm works as follows:
*
* Each byte encodes up to 127 pixels in either white or black. The most
* significant bit determines the color, the remaining 7 bits determine the
* amount.
*/
static
void
gfx_copy_region_rle_mono
(
struct
gfx_region
*
reg
,
int
x
,
int
y
,
int
w
,
int
h
,
size_t
size
,
const
void
*
p
)
{
const
char
*
data
=
p
;
int
idx
=
0
;
Color
white
=
gfx_color
(
reg
,
WHITE
);
Color
black
=
gfx_color
(
reg
,
BLACK
);
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
Color
color
=
(
data
[
i
]
&
0x80
)
?
white
:
black
;
uint8_t
length
=
data
[
i
]
&
0x7f
;
for
(
int
j
=
0
;
j
<
length
;
j
++
)
{
uint16_t
x
=
idx
%
w
;
uint16_t
y
=
idx
/
w
;
gfx_setpixel
(
reg
,
x
,
y
,
color
);
idx
++
;
}
}
}
void
gfx_copy_region
(
struct
gfx_region
*
reg
,
int
x
,
int
y
,
int
w
,
int
h
,
enum
gfx_encoding
encoding
,
size_t
size
,
const
void
*
p
)
{
switch
(
encoding
)
{
case
GFX_RAW
:
gfx_copy_region_raw
(
reg
,
x
,
y
,
w
,
h
,
size
,
p
);
break
;
case
GFX_MONO
:
gfx_copy_region_mono
(
reg
,
x
,
y
,
w
,
h
,
size
,
p
);
break
;
case
GFX_RLE_MONO
:
gfx_copy_region_rle_mono
(
reg
,
x
,
y
,
w
,
h
,
size
,
p
);
break
;
default:
break
;
}
}
void
gfx_copy_raw
(
struct
gfx_region
*
reg
,
const
void
*
p
,
size_t
size
)
{
fb_copy_raw
(
reg
->
fb
,
p
,
size
);
...
...
lib/gfx/gfx.h
View file @
14d9754e
...
...
@@ -43,6 +43,12 @@ enum gfx_color {
COLORS
};
enum
gfx_encoding
{
GFX_RAW
,
GFX_MONO
,
GFX_RLE_MONO
};
struct
gfx_color_rgb
{
uint8_t
r
;
uint8_t
g
;
...
...
@@ -51,8 +57,9 @@ struct gfx_color_rgb {
Color
gfx_color
(
struct
gfx_region
*
reg
,
enum
gfx_color
color
);
void
gfx_copy_region_raw
(
struct
gfx_region
*
reg
,
int
x
,
int
y
,
int
w
,
int
h
,
size_t
bpp
,
const
void
*
p
);
void
gfx_copy_region
(
struct
gfx_region
*
reg
,
int
x
,
int
y
,
int
w
,
int
h
,
enum
gfx_encoding
encoding
,
size_t
size
,
const
void
*
p
);
void
gfx_copy_raw
(
struct
gfx_region
*
reg
,
const
void
*
p
,
size_t
size
);
#endif
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