Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Robey Pointer
reform
Commits
f259912c
Commit
f259912c
authored
Aug 15, 2021
by
Robey Pointer
Browse files
move cursor logic to be jit
parent
3bc9e0cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
reform2-keyboard-fw/text_display.c
View file @
f259912c
...
...
@@ -35,22 +35,19 @@ void text_display_scroll(text_display_t *display) {
}
void
text_display_putc
(
text_display_t
*
display
,
uint8_t
c
)
{
display
->
cells
[
display
->
cursor
]
=
c
;
display
->
cursor
++
;
if
(
display
->
cursor
>=
display
->
width
*
display
->
height
)
{
display
->
cursor
-=
display
->
width
;
text_display_scroll
(
display
);
}
display
->
cells
[
display
->
cursor
]
=
c
;
display
->
cursor
++
;
display
->
dirty
=
true
;
}
void
text_display_write
(
text_display_t
*
display
,
const
char
*
text
)
{
while
(
*
text
)
{
if
(
*
text
==
'\n'
)
{
display
->
cursor
=
((
display
->
cursor
/
display
->
width
)
+
1
)
*
display
->
width
;
if
(
display
->
cursor
>=
display
->
width
*
display
->
height
)
{
display
->
cursor
-=
display
->
width
;
text_display_scroll
(
display
);
}
}
else
{
text_display_putc
(
display
,
*
text
);
}
...
...
@@ -59,6 +56,7 @@ void text_display_write(text_display_t *display, const char *text) {
}
void
text_display_flush
(
text_display_t
*
display
)
{
if
(
!
display
->
dirty
)
return
;
uint8_t
x_offset
=
(
DisplayWidth
-
display
->
width
*
display
->
font
->
width
)
/
2
;
oled_on
();
...
...
reform2-keyboard-fw/text_display.h
View file @
f259912c
...
...
@@ -27,7 +27,7 @@ typedef struct {
typedef
struct
{
uint8_t
cells
[
MAX_HEIGHT
*
MAX_WIDTH
];
uint8_t
invert
[
MAX_HEIGHT
*
MAX_WIDTH
/
8
];
uint8_t
invert
[
(
MAX_HEIGHT
*
MAX_WIDTH
+
7
)
/
8
];
uint8_t
width
;
uint8_t
height
;
uint8_t
cursor
;
...
...
@@ -35,6 +35,8 @@ typedef struct {
const
monospace_font_t
*
font
;
}
text_display_t
;
extern
const
monospace_font_t
font_oranj
;
void
text_display_init
(
text_display_t
*
display
,
const
monospace_font_t
*
font
);
void
text_display_clear
(
text_display_t
*
display
);
void
text_display_scroll
(
text_display_t
*
display
);
...
...
Write
Preview
Supports
Markdown
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