Add tinygl_draw_string

main
Michael Hayes 15 years ago
parent ab139beab9
commit 63c438107d

@ -78,7 +78,7 @@ static void button_task_init (void)
static void display_note (void)
{
tinygl_clear ();
tinygl_text (note_names[note]);
tinygl_draw_string (note_names[note], tinygl_point (0, 0), 1);
}

@ -177,10 +177,43 @@ void tinygl_draw_char (char ch, tinygl_point_t offset, bool rotate)
}
}
}
}
/** Draw string (well, as much as possible) using current font.
@param str string to draw
@param offset coordinates of top left position
@param rotate non-zero to rotate string
@return number of whole characters drawn. */
uint8_t tinygl_draw_string (const char *str, tinygl_point_t offset, bool rotate)
{
uint8_t count = 0;
while (*str)
{
if (rotate)
{
if (offset.y + font->width > TINYGL_HEIGHT)
break;
tinygl_draw_char (*str, offset, 1);
offset.y += font->width + 1;
}
else
{
if (offset.x + font->width > TINYGL_WIDTH)
break;
tinygl_draw_char (*str, offset, 0);
offset.x += font->width + 1;
}
count++;
str++;
}
return count;
}
/** Display a character.
@param ch character to display
@return 1 if character fully displayed. */

@ -153,6 +153,14 @@ void tinygl_font_set (font_t *pfont);
void tinygl_draw_char (char ch, tinygl_point_t offset, bool rotate);
/** Draw string (well, as much as possible) using current font.
@param str string to draw
@param offset coordinates of top left position
@param rotate non-zero to rotate string
@return number of whole characters drawn. */
uint8_t tinygl_draw_string (const char *str, tinygl_point_t offset,
bool rotate);
/** Draw point.
@param point coordinates of point
@param pixel_value pixel value to draw point. */

Loading…
Cancel
Save