-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed font, now also supports more characters #4
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and all, but we should keep this as lightweight and fast as possible, with the least number of steps, the user should be able to use drawtext with the same level of ease as they can use printf() UTF-8 is geat and all, but it shouldn't remove the ability to write c strings straight up without thinking too much. consider the overloading thing. But like C does not have overloading the same way as C++, they will have to specifiy the datatype that is being sent, idk the drawtext function is getting kinda lengthy and ugly
@@ -91,6 +89,11 @@ void draw_bitmap(uint8_t *bitmap, size_t sizeof_bitmap, int width, int x, int y, | |||
*(bitmap_new + height*width + j) |= *(screen + (height+y/8)*LCD_H_RES + x + j) & (0b11111111 << bit); | |||
} | |||
} | |||
if (invert){ | |||
for (int i = 0; i < width; i++){ bitmap_new[i] ^= (0b11111111 << bit); } | |||
for (int i = width; i < sizeof_bitmap; i++){ bitmap_new[i] = ~bitmap_new[i]; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is faster than just inverting the whole bitmap if people want to invert it?
@@ -99,16 +102,33 @@ void draw_bitmap(uint8_t *bitmap, size_t sizeof_bitmap, int width, int x, int y, | |||
free(bitmap); | |||
} | |||
|
|||
int binarysearch (uint32_t c) { // retrieves index of character |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this necessary, why not arrange the character in the arrary in a known order? Just like in the previous one
|
||
void draw_text(char *text, int x, int y, uint8_t *screen, bool transparent, bool invert){ | ||
void draw_text(uint32_t *text, int x, int y, uint8_t *screen, bool transparent, bool invert){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overload this with another version that accepts ascii characters, it makes programming much easier for other users
@@ -16,7 +16,7 @@ | |||
|
|||
void print_bitmap_in_horizontal_mode(uint8_t *bitmap, size_t sizeof_bitmap, int width); // prints bitmap on serial out | |||
void draw_bitmap(uint8_t *bitmap, size_t sizeof_bitmap, int width, int x, int y, uint8_t *screen, bool transparent, bool invert); | |||
void draw_text(char *text, int x, int y, uint8_t *screen, bool transparent, bool invert); // uses a bitmap font that can be tweaked in images.h | |||
void draw_text(uint32_t *text, int x, int y, uint8_t *screen, bool transparent, bool invert); // uses a bitmap font that can be tweaked in images.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see the comment above
|
||
static uint32_t chars[] = {0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa9, 0xaa, 0xab, 0xae, 0xb0, 0xb1, 0xb2, 0xb3, 0xb5, 0xb6, 0xb7, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x192, 0x2e3, 0x393, 0x3a3, 0x3a6, 0x3a9, 0x3b1, 0x3b4, 0x3b5, 0x3b8, 0x3bc, 0x3c0, 0x3c3, 0x3c4, 0x3c9, 0x3d5, 0x405, 0x406, 0x408, 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417, 0x418, 0x419, 0x41a, 0x41b, 0x41c, 0x41d, 0x41e, 0x41f, 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427, 0x428, 0x429, 0x42a, 0x42b, 0x42c, 0x42d, 0x42e, 0x42f, 0x2018, 0x2019, 0x201c, 0x201d, 0x20a7, 0x2190, 0x2191, 0x2192, 0x2193, 0x21b2, 0x221e, 0x2229, 0x2264, 0x2265, 0x2302, 0x23eb, 0x23ec, 0x23f8, 0x25b2, 0x25b6, 0x25bc, 0x25c0, 0x25cf, 0x2665, 0x266a, 0x266c, 0x2c60, 0x300c, 0x300d, 0x309b, 0x309c, 0x30a1, 0x30a2, 0x30a3, 0x30a4, 0x30a5, 0x30a6, 0x30a7, 0x30a8, 0x30a9, 0x30aa, 0x30ab, 0x30ad, 0x30af, 0x30b1, 0x30b3, 0x30b5, 0x30b7, 0x30b9, 0x30bb, 0x30bd, 0x30bf, 0x30c1, 0x30c3, 0x30c4, 0x30c6, 0x30c8, 0x30ca, 0x30cb, 0x30cc, 0x30cd, 0x30ce, 0x30cf, 0x30d2, 0x30d5, 0x30d8, 0x30db, 0x30de, 0x30df, 0x30e0, 0x30e1, 0x30e2, 0x30e3, 0x30e4, 0x30e5, 0x30e6, 0x30e7, 0x30e8, 0x30e9, 0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ef, 0x30f2, 0x30f3, 0x30fb, 0x30fc, 0x30fd, 0x1f514}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider doing some magic and label the characters and space all of these out, lmao
No description provided.