Exemplo n.º 1
0
/*!
 *  @brief      显示数字(清空多余的位)
 *  @param      site            左上角坐标
 *  @param      num             数字
 *  @param      max_num_bit     最大的位数
 *  @param      Color           字体颜色
 *  @param      bkColor         背景颜色
 *  @since      v5.0
*  Sample usage:        Site_t site = {10,20};   //x = 10 ,y = 20
                        LCD_num_BC(site,123,5, BLUE,RED);
 */
void LCD_num_BC(Site_t site, uint32 num, uint8 max_num_bit, uint16 Color, uint16 bkColor)
{
    uint32 res = num;
    uint8 t = 0;
    Site_t sitetemp;
    Size_t size;

    sitetemp.y = site.y;

    if( num == 0 )
    {
        LCD_char(site, '0', Color, bkColor);

        site.x += 8;
        size.H  = 16;
        size.W  = 8 * (max_num_bit - 1);
        LCD_rectangle(site, size, bkColor);

        return;
    }
    while( res )            /*得到数字长度t*/
    {
        res /= 10;
        t++;
    }
    if(t >= max_num_bit )    //限制最大长度
    {
        t = max_num_bit;
    }

    res = t;

    while( t != 0 )
    {
        sitetemp.x = site.x + (8 * (t--) - 8);
        LCD_char(sitetemp, (num % 10) + '0', Color, bkColor);
        num /= 10 ;
    }

    if(res != max_num_bit )
    {
        size.W = 8 * (max_num_bit - res);
        site.x += (8 * res);
        size.H  = 16;
        LCD_rectangle(site, size, bkColor);
    }
}
Exemplo n.º 2
0
void show_help()
{
  LCD_rectangle(0, 0, 132, 132, 1, BLACK);
  LCD_print_string("/// OSEater \\\\", 4, 4, BIG_FONT, WHITE,
                      BLACK);
  LCD_print_string("Help", 24, 48, BIG_FONT, WHITE, BLACK);
  LCD_print_string("Just move the", 44, 8, BIG_FONT, WHITE, BLACK);
  LCD_print_string("joystick", 64, 8, BIG_FONT, WHITE, BLACK);
  LCD_print_string("to move around", 84, 8, BIG_FONT, WHITE,
                      BLACK);
  while(!read_controls());
}
Exemplo n.º 3
0
/*!
 *  @brief      LCD初始化
 *  @since      v5.0
 */
void LCD_init(void)
{
    Site_t site = {0, 0};
    Size_t size ;

    LCD_INIT();                             //初始化LCD

    //LCD_SET_DIR(LCD_DIR+1);

    //由于初始化的时候进行 屏幕方向 选择,因而初始化完成后,才获取宽高
    size.W = LCD_W;
    size.H = LCD_H;

    LCD_rectangle(site, size, BCOLOUR);     //初始化背景
}
Exemplo n.º 4
0
void show_credits()
{
  LCD_rectangle(0, 0, 132, 132, 1, BLACK);
  LCD_print_string("/// OSEater \\\\", 4, 4, BIG_FONT, WHITE,
                      BLACK);
  LCD_print_string("Credits", 24, 36, BIG_FONT, WHITE, BLACK);
  LCD_print_string("A game by", 44, 8, MEDIUM_FONT, WHITE, BLACK);
  LCD_print_string("Diego Barrios", 56, 8, MEDIUM_FONT, WHITE,
                      BLACK);
  LCD_print_string("Romero.", 68, 8, MEDIUM_FONT, WHITE, BLACK);
  LCD_print_string("Developed for", 80, 8, SMALL_FONT, WHITE,
                      BLACK);
  LCD_print_string("Microprocessors", 90, 8, SMALL_FONT, WHITE,
                      BLACK);
  LCD_print_string("& Micro-", 100, 8, SMALL_FONT, WHITE, BLACK);
  LCD_print_string("controllers", 110, 8, SMALL_FONT, WHITE,
                      BLACK);
  LCD_print_string("subject.", 120, 8, SMALL_FONT, WHITE, BLACK);
  while(!read_controls());
}
Exemplo n.º 5
0
void menu_game_over()
{
  unsigned char selected = 1;
  LCD_rectangle(0, 0, 132, 132, 1, BLACK);
  LCD_print_string("/// OSEater \\\\\\", 4, 4, BIG_FONT, WHITE,
                      BLACK);
  LCD_print_string("Game over", 24, 30, BIG_FONT, WHITE, BLACK);
  LCD_print_string("Play again", 48, 26, MEDIUM_FONT, RED, BLACK);
  LCD_print_string("Yes", 68, 57, SMALL_FONT, RED, BLACK);
  LCD_print_string("No", 88, 60, SMALL_FONT, WHITE, BLACK);
  while (1){
    unsigned int buttons = read_controls();
    if (buttons & BUTTON_CENTRAL){
      switch(selected){
      case 1:
        return;
      case 2:
        off();
        break;
      }
    }
    if (buttons & BUTTON_DOWN){
      if (selected == 1){
        LCD_print_string("Yes", 68, 57, SMALL_FONT, WHITE, BLACK);
        LCD_print_string("No", 88, 60, SMALL_FONT, RED, BLACK);
        selected++;
      }
    }
    else if (buttons & BUTTON_UP){
      if (selected == 2){
        LCD_print_string("Yes", 68, 57, SMALL_FONT, RED, BLACK);
        LCD_print_string("No", 88, 60, SMALL_FONT, WHITE, BLACK);
        selected--;
      }
    }
  }
}
Exemplo n.º 6
0
void menu ()
{
  unsigned char selected = 1;
  LCD_rectangle(0, 0, 132, 132, 1, BLACK);
  LCD_print_string("/// OSEater \\\\\\", 4, 4, BIG_FONT, WHITE,
  BLACK);
  LCD_print_string("Main Menu", 24, 28, BIG_FONT, WHITE, BLACK);
  LCD_print_string("Play", 48, 48, BIG_FONT, RED, BLACK);
  LCD_print_string("Credits", 68, 36, BIG_FONT, WHITE, BLACK);
  LCD_print_string("Help", 88, 48, BIG_FONT, WHITE, BLACK);
  while (1){
    unsigned int buttons = read_controls();
    if (buttons & BUTTON_CENTRAL){
      switch(selected){
      case 1:
        return;
      case 2:
        show_credits();
        selected = 1;
        LCD_rectangle(0, 0, 132, 132, 1, BLACK);
        LCD_print_string("/// OSEater \\\\\\", 4, 4, BIG_FONT, WHITE,
                            BLACK);
        LCD_print_string("Main Menu", 24, 28, BIG_FONT, WHITE, BLACK);
        LCD_print_string("Play", 48, 48, BIG_FONT, RED, BLACK);
        LCD_print_string("Credits", 68, 36, BIG_FONT, WHITE, BLACK);
        LCD_print_string("Help", 88, 48, BIG_FONT, WHITE, BLACK);
        break;
      case 3:
        show_help();
        selected = 1;
        LCD_rectangle(0, 0, 132, 132, 1, BLACK);
        LCD_print_string("/// OSEater \\\\\\", 4, 4, BIG_FONT, WHITE,
                            BLACK);
        LCD_print_string("Main Menu", 24, 28, BIG_FONT, WHITE, BLACK);
        LCD_print_string("Play", 48, 48, BIG_FONT, RED, BLACK);
        LCD_print_string("Credits", 68, 36, BIG_FONT, WHITE, BLACK);
        LCD_print_string("Help", 88, 48, BIG_FONT, WHITE, BLACK);
        break;
      }
    }
    if (buttons & BUTTON_DOWN){
      switch(selected){
      case 1:
        LCD_print_string("Play", 48, 48, BIG_FONT, WHITE,
                            BLACK);
        LCD_print_string("Credits", 68, 36, BIG_FONT, RED,
                            BLACK);
        break;
      case 2:
        LCD_print_string("Credits", 68, 36, BIG_FONT, WHITE,
                            BLACK);
        LCD_print_string("Help", 88, 48, BIG_FONT, RED,
                            BLACK);
        break;
      default:
        selected--;
      }
      selected++;
    }
    else if (buttons & BUTTON_UP){
      switch(selected){
      case 2:
        LCD_print_string("Play", 48, 48, BIG_FONT, RED,
                            BLACK);
        LCD_print_string("Credits", 68, 36, BIG_FONT, WHITE,
                            BLACK);
        break;
      case 3:
        LCD_print_string("Credits", 68, 36, BIG_FONT, RED,
                            BLACK);
        LCD_print_string("Help", 88, 48, BIG_FONT, WHITE,
                            BLACK);
        break;
      default:
        selected++;
      }
      selected--;
    }
    delay(300000);
  }
}
Exemplo n.º 7
0
void off()
{
  LCD_rectangle(0, 0, 132, 132, 1, BLACK);
  LCD_turn_off_backlight();
  while(1);
}