Skip to content

Commit

Permalink
more optimizations on types (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitdode authored Sep 20, 2023
1 parent 2f68970 commit b8b5742
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion thermidity-avr/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ static void bufferBitmap(row_t row, col_t col,
uint8_t rotated[8];
memset(rotated, 0, 8);
uint16_t n = 0, x = 0;
uint16_t i_mod_height = 0, i_div_height = 0, x_mod_height = 0;
uint16_t i_div_height = 0;
height_t i_mod_height = 0, x_mod_height = 0;
for (uint16_t i = 0; i < size; i++) {
uint8_t next = bitmap[n];

Expand Down
6 changes: 3 additions & 3 deletions thermidity-avr/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
const __flash Glyph* getGlyphAddress(const __flash Font *font, code_t code) {

// https://en.wikipedia.org/wiki/Binary_search_algorithm
int16_t l = 0;
int16_t r = font->length - 1;
code_t l = 0;
code_t r = font->length - 1;

while (l <= r) {
uint8_t m = (l + r) / 2;
code_t m = (l + r) / 2;
const __flash Glyph *pglyph = &font->glyphs[m];
if (pglyph->code < code) {
l = m + 1;
Expand Down
2 changes: 1 addition & 1 deletion thermidity-avr/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef struct {
/** Glyphs of this font. */
const __flash Glyph *glyphs;
/** Number of glyphs of this font. */
const uint8_t length;
const length_t length;
/** Height of (the glyphs of) this font. */
const height_t height;
} Font;
Expand Down
3 changes: 3 additions & 0 deletions thermidity-avr/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ typedef uint8_t col_t;
/* Char code (like UTF-8 code point) */
typedef uint8_t code_t;

/* Number of glyphs of a font */
typedef uint8_t length_t;

#endif /* TYPES_H */

0 comments on commit b8b5742

Please sign in to comment.