Revert tinygl_text API and add tinygl_draw_message

main
Michael Hayes 14 years ago
parent cc3347edd4
commit 76665cbc7f

@ -29,7 +29,7 @@ static void show_num (char ch, uint8_t count)
buffer[1] = count / 10 + '0'; buffer[1] = count / 10 + '0';
buffer[2] = count % 10 + '0'; buffer[2] = count % 10 + '0';
buffer[3] = 0; buffer[3] = 0;
tinygl_text (buffer, tinygl_point (0, 0)); tinygl_text (buffer);
} }
@ -45,7 +45,7 @@ int main (void)
tinygl_text_speed_set (MESSAGE_RATE); tinygl_text_speed_set (MESSAGE_RATE);
tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL); tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL);
tinygl_text ("NUM?", tinygl_point (0, 0)); tinygl_text ("NUM?");
pacer_init (LOOP_RATE); pacer_init (LOOP_RATE);

@ -43,7 +43,7 @@ static char show_char (char ch)
string[0] = ch; string[0] = ch;
string[1] = 0; string[1] = 0;
tinygl_text (string, tinygl_point (0, 0)); tinygl_text (string);
return ch; return ch;
} }

@ -27,7 +27,7 @@ int main (void)
tinygl_font_set (&font5x7_1); tinygl_font_set (&font5x7_1);
tinygl_text_speed_set (MESSAGE_RATE); tinygl_text_speed_set (MESSAGE_RATE);
tinygl_text ("HELLO WORLD", tinygl_point (0, 0)); tinygl_text ("HELLO WORLD");
pacer_init (LOOP_RATE); pacer_init (LOOP_RATE);

@ -28,7 +28,7 @@ int main (void)
tinygl_text_speed_set (MESSAGE_RATE); tinygl_text_speed_set (MESSAGE_RATE);
tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL); tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL);
tinygl_text ("HELLO WORLD", tinygl_point (0, 0)); tinygl_text ("HELLO WORLD");
pacer_init (LOOP_RATE); pacer_init (LOOP_RATE);

@ -31,7 +31,7 @@ int main (void)
tinygl_text_speed_set (MESSAGE_RATE); tinygl_text_speed_set (MESSAGE_RATE);
tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL); tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL);
tinygl_text ("HELLO WORLD", tinygl_point (0, 0)); tinygl_text ("HELLO WORLD");
pacer_init (LOOP_RATE); pacer_init (LOOP_RATE);

@ -32,7 +32,7 @@ int main (void)
tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL); tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL);
tinygl_text_dir_set (TINYGL_TEXT_DIR_ROTATE); tinygl_text_dir_set (TINYGL_TEXT_DIR_ROTATE);
tinygl_text ("HELLO WORLD ", tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text ("HELLO WORLD ");
pacer_init (LOOP_RATE); pacer_init (LOOP_RATE);

@ -85,7 +85,7 @@ static void show_char (char ch)
buffer[0] = ch; buffer[0] = ch;
buffer[1] = 0; buffer[1] = 0;
tinygl_text (buffer, tinygl_point (0, 0)); tinygl_text (buffer);
} }

@ -89,7 +89,7 @@ static void show_char (char ch)
buffer[0] = ch; buffer[0] = ch;
buffer[1] = 0; buffer[1] = 0;
tinygl_text (buffer, tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text (buffer);
} }
@ -99,7 +99,7 @@ static void show_num (char ch, uint8_t num)
buffer[0] = ch; buffer[0] = ch;
uint8toa (num, buffer + 1, 0); uint8toa (num, buffer + 1, 0);
tinygl_text (buffer, tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text (buffer);
} }

@ -156,7 +156,7 @@ int main (void)
pacer_init (LOOP_RATE); pacer_init (LOOP_RATE);
tinygl_text ("X", tinygl_point (0, 0)); tinygl_text ("X");
led_set (LED1, 0); led_set (LED1, 0);
while (1) while (1)
@ -176,7 +176,7 @@ int main (void)
if (seq != -1) if (seq != -1)
{ {
tinygl_text (strings[seq], tinygl_point (0, 0)); tinygl_text (strings[seq]);
transmit (&codeseqs[seq * CODESEQ_LEN_MAX]); transmit (&codeseqs[seq * CODESEQ_LEN_MAX]);
} }
@ -199,7 +199,7 @@ int main (void)
{ {
if (capture (codeseq, CODESEQ_LEN_MAX)) if (capture (codeseq, CODESEQ_LEN_MAX))
{ {
tinygl_text ("?", tinygl_point (0, 0)); tinygl_text ("?");
led_set (LED1, 1); led_set (LED1, 1);
state = STATE_STORE; state = STATE_STORE;
break; break;
@ -227,7 +227,7 @@ int main (void)
{ {
memcpy (&codeseqs[seq * CODESEQ_LEN_MAX], codeseq, sizeof (codeseq)); memcpy (&codeseqs[seq * CODESEQ_LEN_MAX], codeseq, sizeof (codeseq));
codeseqs_write (codeseqs, CODESEQ_LEN_MAX, CODESEQ_NUM); codeseqs_write (codeseqs, CODESEQ_LEN_MAX, CODESEQ_NUM);
tinygl_text (strings[seq], tinygl_point (0, 0)); tinygl_text (strings[seq]);
led_set (LED1, 0); led_set (LED1, 0);
state = STATE_NORMAL; state = STATE_NORMAL;
} }

@ -29,7 +29,7 @@ static void show_count (uint8_t count)
buffer[0] = 'S'; buffer[0] = 'S';
buffer[1] = count + '0'; buffer[1] = count + '0';
buffer[2] = 0; buffer[2] = 0;
tinygl_text (buffer, tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text (buffer);
} }
@ -40,7 +40,7 @@ static void show_err (uint8_t err)
buffer[0] = 'E'; buffer[0] = 'E';
buffer[1] = err + '0'; buffer[1] = err + '0';
buffer[2] = 0; buffer[2] = 0;
tinygl_text (buffer, tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text (buffer);
} }

@ -28,7 +28,7 @@ static void show_count (uint8_t count)
/* FIXME! */ /* FIXME! */
buffer[0] = count + '0'; buffer[0] = count + '0';
buffer[1] = 0; buffer[1] = 0;
tinygl_text (buffer, tinygl_point (0, 0)); tinygl_text (buffer);
} }

@ -28,7 +28,7 @@ static void show_count (uint8_t count)
/* FIXME! */ /* FIXME! */
buffer[0] = count + '0'; buffer[0] = count + '0';
buffer[1] = 0; buffer[1] = 0;
tinygl_text (buffer, tinygl_point (0, 0)); tinygl_text (buffer);
} }

@ -28,7 +28,7 @@ static void show_count (uint8_t count)
/* FIXME! */ /* FIXME! */
buffer[0] = count + '0'; buffer[0] = count + '0';
buffer[1] = 0; buffer[1] = 0;
tinygl_text (buffer, tinygl_point (0, 0)); tinygl_text (buffer);
} }

@ -27,7 +27,7 @@ static void show_char (char ch)
buffer[0] = ch; buffer[0] = ch;
buffer[1] = 0; buffer[1] = 0;
tinygl_text (buffer, tinygl_point (0, 0)); tinygl_text (buffer);
} }

@ -86,7 +86,7 @@ game_over_display (char *buffer)
*str++ = 'F'; *str++ = 'F';
uint8toa (spacey_shells_fired_get (), str, 0); uint8toa (spacey_shells_fired_get (), str, 0);
tinygl_clear (); tinygl_clear ();
tinygl_text (buffer, tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text (buffer);
} }
@ -99,7 +99,7 @@ game_text_display (uint8_t num, char *buffer, char *msg)
*str++ = *msg++; *str++ = *msg++;
uint8toa (num, str, 0); uint8toa (num, str, 0);
tinygl_clear (); tinygl_clear ();
tinygl_text (buffer, tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text (buffer);
} }
@ -287,8 +287,7 @@ main (void)
break; break;
case STATE_INIT: case STATE_INIT:
tinygl_text ("SPACEY READY V" VERSION " BY MPH ", tinygl_text ("SPACEY READY V" VERSION " BY MPH ");
tinygl_point (0, TINYGL_HEIGHT - 1));
state = STATE_READY; state = STATE_READY;
break; break;

@ -91,7 +91,7 @@ game_over_display (char *buffer)
*str++ = '/'; *str++ = '/';
uint8toa (spacey_shells_fired_get (), str, 0); uint8toa (spacey_shells_fired_get (), str, 0);
tinygl_clear (); tinygl_clear ();
tinygl_text (buffer, tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text (buffer);
} }
@ -104,7 +104,7 @@ game_text_display (uint8_t num, char *buffer, char *msg)
*str++ = *msg++; *str++ = *msg++;
uint8toa (num, str, 0); uint8toa (num, str, 0);
tinygl_clear (); tinygl_clear ();
tinygl_text (buffer, tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text (buffer);
} }
@ -238,8 +238,7 @@ static void game_task (__unused__ void *data)
break; break;
case STATE_INIT: case STATE_INIT:
tinygl_text ("SPACEY READY V" VERSION " BY MPH ", tinygl_text ("SPACEY READY V" VERSION " BY MPH ");
tinygl_point (0, TINYGL_HEIGHT - 1));
state = STATE_READY; state = STATE_READY;
break; break;

@ -152,7 +152,7 @@ game_over_display (char *buffer)
*str++ = '/'; *str++ = '/';
uint8toa (spacey_shells_fired_get (), str, 0); uint8toa (spacey_shells_fired_get (), str, 0);
tinygl_clear (); tinygl_clear ();
tinygl_text (buffer, tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text (buffer);
} }
@ -165,7 +165,7 @@ game_text_display (uint8_t num, char *buffer, char *msg)
*str++ = *msg++; *str++ = *msg++;
uint8toa (num, str, 0); uint8toa (num, str, 0);
tinygl_clear (); tinygl_clear ();
tinygl_text (buffer, tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text (buffer);
} }
@ -304,8 +304,7 @@ static void game_task (__unused__ void *data)
break; break;
case STATE_INIT: case STATE_INIT:
tinygl_text ("SPACEY READY V" VERSION " BY MPH ", tinygl_text ("SPACEY READY V" VERSION " BY MPH ");
tinygl_point (0, TINYGL_HEIGHT - 1));
mmelody_play (melody, game_intro_tune); mmelody_play (melody, game_intro_tune);
state = STATE_READY; state = STATE_READY;
break; break;

@ -87,7 +87,7 @@ game_over_display (char *buffer)
*str++ = '/'; *str++ = '/';
uint8toa (spacey_shells_fired_get (), str, 0); uint8toa (spacey_shells_fired_get (), str, 0);
tinygl_clear (); tinygl_clear ();
tinygl_text (buffer, tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text (buffer);
} }
@ -100,7 +100,7 @@ game_text_display (uint8_t num, char *buffer, char *msg)
*str++ = *msg++; *str++ = *msg++;
uint8toa (num, str, 0); uint8toa (num, str, 0);
tinygl_clear (); tinygl_clear ();
tinygl_text (buffer, tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text (buffer);
} }
@ -303,8 +303,7 @@ main (void)
break; break;
case STATE_INIT: case STATE_INIT:
tinygl_text ("SPACEY READY V" VERSION " BY MPH ", tinygl_text ("SPACEY READY V" VERSION " BY MPH ");
tinygl_point (0, TINYGL_HEIGHT - 1));
state = STATE_READY; state = STATE_READY;
break; break;

@ -38,7 +38,7 @@ int main (void)
pacer_init (LOOP_RATE); pacer_init (LOOP_RATE);
tinygl_text ("#", tinygl_point (0, 0)); tinygl_text ("#");
/* Paced loop. */ /* Paced loop. */
while (1) while (1)
@ -69,11 +69,11 @@ int main (void)
switch (event) switch (event)
{ {
case SPACEY_EVENT_ALIEN_HIT: case SPACEY_EVENT_ALIEN_HIT:
tinygl_text ("*", tinygl_point (0, 0)); tinygl_text ("*");
break; break;
case SPACEY_EVENT_ALIEN_LANDED: case SPACEY_EVENT_ALIEN_LANDED:
tinygl_text ("@", tinygl_point (0, 0)); tinygl_text ("@");
break; break;
} }

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

@ -51,8 +51,7 @@ note_play (tweeter_t tweeter, tweeter_note_t note, uint8_t velocity)
{ {
tinygl_clear (); tinygl_clear ();
if (note != 0 && velocity != 0) if (note != 0 && velocity != 0)
tinygl_text (note_names[note % 12], tinygl_text (note_names[note % 12]);
tinygl_point (0, TINYGL_HEIGHT - 1));
tweeter_note_play (tweeter, note, velocity); tweeter_note_play (tweeter, note, velocity);
} }

@ -42,7 +42,7 @@ static void display_task_init (void)
tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL); tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL);
tinygl_text_dir_set (TINYGL_TEXT_DIR_ROTATE); tinygl_text_dir_set (TINYGL_TEXT_DIR_ROTATE);
tinygl_text ("HELLO WORLD ", tinygl_point (0, TINYGL_HEIGHT - 1)); tinygl_text ("HELLO WORLD ");
} }

@ -23,7 +23,7 @@ static void show_count (uint8_t count)
/* FIXME! */ /* FIXME! */
buffer[0] = count + '0'; buffer[0] = count + '0';
buffer[1] = 0; buffer[1] = 0;
tinygl_text (buffer, tinygl_point (0, 0)); tinygl_text (buffer);
} }

@ -24,7 +24,7 @@ static void show_count (uint8_t count)
/* FIXME! */ /* FIXME! */
buffer[0] = count + '0'; buffer[0] = count + '0';
buffer[1] = 0; buffer[1] = 0;
tinygl_text (buffer, tinygl_point (0, 0)); tinygl_text (buffer);
} }

@ -263,7 +263,7 @@ static void tinygl_text_advance (void)
/** Display a message repeatedly. /** Display a message repeatedly.
@param string null terminated message to display @param string null terminated message to display
@param pos position on screen. */ @param pos position on screen. */
void tinygl_text (const char *string, tinygl_point_t pos) void tinygl_draw_message (const char *string, tinygl_point_t pos)
{ {
tinygl.message_index = 0; tinygl.message_index = 0;
tinygl.scroll_pos = 0; tinygl.scroll_pos = 0;
@ -296,6 +296,19 @@ void tinygl_text (const char *string, tinygl_point_t pos)
} }
/** Display a message repeatedly.
@param string null terminated message to display. */
void tinygl_text (const char *string)
{
tinygl_point_t pos;
pos.x = 0;
pos.y = (tinygl.dir == TINYGL_TEXT_DIR_ROTATE) ? TINYGL_HEIGHT - 1 : 0;
tinygl_draw_message (string, pos);
}
/** Set the message update speed. /** Set the message update speed.
@param speed text advance speed (characters per 10 s). */ @param speed text advance speed (characters per 10 s). */
void tinygl_text_speed_set (uint8_t speed) void tinygl_text_speed_set (uint8_t speed)

@ -136,12 +136,6 @@ static inline tinygl_point_t tinygl_point (tinygl_coord_t x, tinygl_coord_t y)
} }
/** Display a message repeatedly.
@param string null terminated message to display
@param pos position on screen. */
void tinygl_text (const char *string, tinygl_point_t pos);
/** Set the message update speed. /** Set the message update speed.
@param speed text advance speed (characters per 10 s). */ @param speed text advance speed (characters per 10 s). */
void tinygl_text_speed_set (uint8_t speed); void tinygl_text_speed_set (uint8_t speed);
@ -176,6 +170,17 @@ tinygl_point_t tinygl_draw_char (char ch, tinygl_point_t pos);
uint8_t tinygl_draw_string (const char *str, tinygl_point_t pos); uint8_t tinygl_draw_string (const char *str, tinygl_point_t pos);
/** Display a message repeatedly.
@param string null terminated message to display
@param pos position on screen. */
void tinygl_draw_message (const char *string, tinygl_point_t pos);
/** Display a message repeatedly.
@param string null terminated message to display. */
void tinygl_text (const char *string);
/** Draw point. /** Draw point.
@param pos coordinates of point @param pos coordinates of point
@param pixel_value pixel value to draw point. */ @param pixel_value pixel value to draw point. */

Loading…
Cancel
Save