Revert last change
This commit is contained in:
+62
-14
@@ -131,20 +131,40 @@ static bool tinygl_font_pixel_get (char ch, uint8_t col, uint8_t row)
|
||||
|
||||
/** Draw character using current font.
|
||||
@param ch character to draw
|
||||
@param offset coordinates of top left position. */
|
||||
void tinygl_draw_char (char ch, tinygl_point_t offset)
|
||||
@param offset coordinates of top left position
|
||||
@param rotate non-zero to rotate character
|
||||
@return position to draw next character. */
|
||||
tinygl_point_t tinygl_draw_char (char ch, tinygl_point_t offset, bool rotate)
|
||||
{
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
|
||||
for (x = 0; x < font->width; x++)
|
||||
if (rotate)
|
||||
{
|
||||
for (y = 0; y < font->height; y++)
|
||||
for (x = 0; x < font->height; x++)
|
||||
{
|
||||
tinygl_draw_point (tinygl_point (x + offset.x, y + offset.y),
|
||||
tinygl_font_pixel_get (ch, x, y));
|
||||
for (y = 0; y < font->width; y++)
|
||||
{
|
||||
tinygl_draw_point (tinygl_point (x + offset.x,
|
||||
TINYGL_HEIGHT - 1 - (y + offset.y)),
|
||||
tinygl_font_pixel_get (ch, y, x));
|
||||
}
|
||||
}
|
||||
offset.y += font->width + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (x = 0; x < font->width; x++)
|
||||
{
|
||||
for (y = 0; y < font->height; y++)
|
||||
{
|
||||
tinygl_draw_point (tinygl_point (x + offset.x, y + offset.y),
|
||||
tinygl_font_pixel_get (ch, x, y));
|
||||
}
|
||||
}
|
||||
offset.x += font->width + 1;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,17 +172,26 @@ void tinygl_draw_char (char ch, tinygl_point_t offset)
|
||||
/** 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)
|
||||
uint8_t tinygl_draw_string (const char *str, tinygl_point_t offset, bool rotate)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
|
||||
while (*str)
|
||||
{
|
||||
if (offset.x + font->width > TINYGL_WIDTH)
|
||||
break;
|
||||
tinygl_draw_char (*str, offset);
|
||||
offset.x += font->width + 1;
|
||||
if (rotate)
|
||||
{
|
||||
if (offset.y + font->width > TINYGL_HEIGHT)
|
||||
break;
|
||||
tinygl_draw_char (*str, offset, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (offset.x + font->width > TINYGL_WIDTH)
|
||||
break;
|
||||
tinygl_draw_char (*str, offset, 0);
|
||||
}
|
||||
count++;
|
||||
str++;
|
||||
}
|
||||
@@ -170,11 +199,13 @@ uint8_t tinygl_draw_string (const char *str, tinygl_point_t offset)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Display a character.
|
||||
@param ch character to display
|
||||
@return 1 if character fully displayed. */
|
||||
static bool tinygl_display_char (char ch)
|
||||
{
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
|
||||
if (!font)
|
||||
@@ -182,7 +213,7 @@ static bool tinygl_display_char (char ch)
|
||||
|
||||
switch (text_mode)
|
||||
{
|
||||
case TINYGL_TEXT_MODE_SCROLL:
|
||||
case TINYGL_TEXT_MODE_SCROLL_LEFT:
|
||||
display_scroll_left ();
|
||||
|
||||
for (y = 0; y < font->height; y++)
|
||||
@@ -196,10 +227,27 @@ static bool tinygl_display_char (char ch)
|
||||
if (scroll_pos != 0)
|
||||
break;
|
||||
|
||||
tinygl_draw_char (ch, tinygl_point (0, 0));
|
||||
tinygl_draw_char (ch, tinygl_point (0, 0), 0);
|
||||
break;
|
||||
|
||||
case TINYGL_TEXT_MODE_ROTATE_SCROLL_DOWN:
|
||||
display_scroll_down ();
|
||||
|
||||
for (x = 0; x < font->height; x++)
|
||||
{
|
||||
tinygl_draw_point (tinygl_point (x, 0),
|
||||
tinygl_font_pixel_get (ch, scroll_pos, x));
|
||||
}
|
||||
break;
|
||||
|
||||
case TINYGL_TEXT_MODE_ROTATE_STEP:
|
||||
if (scroll_pos != 0)
|
||||
break;
|
||||
|
||||
tinygl_draw_char (ch, tinygl_point (0, 0), 1);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
scroll_pos++;
|
||||
if (scroll_pos > font->width)
|
||||
scroll_pos = 0;
|
||||
|
||||
+12
-5
@@ -110,7 +110,11 @@ typedef enum
|
||||
/* Stepping text. */
|
||||
TINYGL_TEXT_MODE_STEP,
|
||||
/** Scrolling text. */
|
||||
TINYGL_TEXT_MODE_SCROLL
|
||||
TINYGL_TEXT_MODE_SCROLL_LEFT,
|
||||
/** Rotated scrolling text. */
|
||||
TINYGL_TEXT_MODE_ROTATE_SCROLL_DOWN,
|
||||
/* Stepping rotated text. */
|
||||
TINYGL_TEXT_MODE_ROTATE_STEP
|
||||
} tinygl_text_mode_t;
|
||||
|
||||
|
||||
@@ -148,16 +152,19 @@ void tinygl_font_set (font_t *pfont);
|
||||
|
||||
/** Draw character using current font.
|
||||
@param ch character to draw
|
||||
@param offset coordinates of top left position. */
|
||||
void tinygl_draw_char (char ch, tinygl_point_t offset);
|
||||
@param offset coordinates of top left position
|
||||
@param rotate non-zero to rotate character
|
||||
@return position to draw next character. */
|
||||
tinygl_point_t 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);
|
||||
|
||||
uint8_t tinygl_draw_string (const char *str, tinygl_point_t offset,
|
||||
bool rotate);
|
||||
|
||||
/** Draw point.
|
||||
@param point coordinates of point
|
||||
|
||||
Reference in New Issue
Block a user