add manual controls menu, remove demu screens
This commit is contained in:
+19
-9
@@ -242,27 +242,37 @@ void LCD_setStrEx(const char *dString, int x, int y, enum Color color, struct Te
|
||||
int spacingy = style.spacing_y;
|
||||
|
||||
struct Utf8Char uchar;
|
||||
int limit = style.max_chars;
|
||||
int limit = style.limit;
|
||||
int skip = style.skip;
|
||||
bool wrap;
|
||||
while ((uchar = Utf8Iterator_Next(&iter)).uint) {
|
||||
LCD_setCharEx(uchar, x, y, color, style);
|
||||
if (skip > 0) {
|
||||
skip -= 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
wrap = uchar.bytes[0] == '\n';
|
||||
|
||||
if (!wrap) LCD_setCharEx(uchar, x, y, color, style);
|
||||
|
||||
if (limit > 0) {
|
||||
limit -= 1;
|
||||
if (limit == 0) return;
|
||||
}
|
||||
|
||||
x += charw;
|
||||
|
||||
if (style.bg) {
|
||||
for (int i = y; i < y + charh; i++) {
|
||||
for (int j = x; j < x + spacingx; j++) {
|
||||
LCD_setPixel(j, i, !color);
|
||||
if (!wrap) {
|
||||
x += charw;
|
||||
if (style.bg) {
|
||||
for (int i = y; i < y + charh; i++) {
|
||||
for (int j = x; j < x + spacingx; j++) {
|
||||
LCD_setPixel(j, i, !color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x += spacingx;
|
||||
if (x > (LCD_WIDTH - charw)) {
|
||||
if (wrap || x > (LCD_WIDTH - charw)) {
|
||||
if (style.nowrap) break;
|
||||
if (style.wrap_to_0) {
|
||||
x = 0;
|
||||
|
||||
@@ -51,9 +51,10 @@ enum TextSize {
|
||||
};
|
||||
|
||||
struct TextStyle {
|
||||
bool bg; //!< Fill the characters background with the opposite color
|
||||
bool bg; //!< Fill the characters background with the opposite color
|
||||
enum TextSize size; //!< Character size
|
||||
int max_chars; //!< Number of characters to print from the string, if > 0
|
||||
int limit; //!< Number of characters to print from the string, if > 0
|
||||
int skip; //!< Characters to skip before printing
|
||||
int spacing_x; //!< Additional X spacing
|
||||
int spacing_y; //!< Additional Y spacing
|
||||
bool nowrap; //!< Stop painting when the right edge of the screen is reached
|
||||
|
||||
@@ -21,6 +21,17 @@ const struct Utf8Char EMPTY_CHAR = (struct Utf8Char) {.uint = 0};
|
||||
// U+40000 - U+FFFFF F1 - F3 80 - BF 80 - BF 80 - BF
|
||||
// U+100000 - U+10FFFF F4 80 - *8F 80 - BF 80 - BF
|
||||
|
||||
size_t utf8_strlen(const char *text)
|
||||
{
|
||||
// TODO optimize
|
||||
struct Utf8Iterator iter;
|
||||
Utf8Iterator_Init(&iter, text);
|
||||
size_t num = 0;
|
||||
while ((Utf8Iterator_Next(&iter)).uint) {
|
||||
num++;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a received character
|
||||
|
||||
@@ -63,6 +63,8 @@ static inline void Utf8Iterator_Init(struct Utf8Iterator *self, const char *sour
|
||||
self->source = source;
|
||||
}
|
||||
|
||||
size_t utf8_strlen(const char *text);
|
||||
|
||||
/**
|
||||
* Get the next character from the iterator; Returns empty character if there are no more characters to parse.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user