示例#1
0
void u8g_box_frame(uint8_t a) {
    u8g_DrawStr(&u8g, 0, 0, "drawBox");
    u8g_DrawBox(&u8g, 5,10,20,10);
    u8g_DrawBox(&u8g, 10+a,15,30,7);
    u8g_DrawStr(&u8g, 0, 30, "drawFrame");
    u8g_DrawFrame(&u8g, 5,10+30,20,10);
    u8g_DrawFrame(&u8g, 10+a,15+30,30,7);
}
示例#2
0
文件: main.c 项目: 88kacper8/u8glib
int main(void)
{
  u8g_uint_t w,h;
  u8g_uint_t r, g, b, x, y;
  u8g_t u8g;
  
  u8g_Init(&u8g, &u8g_dev_sdl_8bit);
  u8g_FirstPage(&u8g);
  do
  {
    u8g_SetFont(&u8g, u8g_font_10x20);
    u8g_SetFont(&u8g, u8g_font_fur25);

    /*
  for ( x = 0; x < 128; x++ )
    for ( y = 0; y < 64; y++ )
    {
      u8g_SetColorIndex(&u8g, ((x&3)+y*4) & 255);
      u8g_DrawPixel(&u8g, x, y);
    }
    */
  w = 4;
  h = 4;
  for( b = 0; b < 4; b++ )
    for( g = 0; g < 8; g++ )
      for( r = 0; r < 8; r++ )
      {
        u8g_SetColorIndex(&u8g, (r<<5) |  (g<<2) | b );
        u8g_DrawBox(&u8g, g*w + b*w*8, r*h, w, h);
        u8g_DrawBox(&u8g, g*w + b*w*8, r*h+32, w, h);
      }

    
    w = u8g_GetFontBBXWidth(&u8g);
    h = u8g_GetFontBBXHeight(&u8g);
    u8g_SetColorIndex(&u8g, 1);
    u8g_DrawStr(&u8g, 20, 40, "U8glib");
    u8g_SetColorIndex(&u8g, 2);
    u8g_DrawStr(&u8g, 20+1, 40+1, "U8glib");
    u8g_SetColorIndex(&u8g, 3);
    u8g_DrawStr(&u8g, 20+2, 40+2, "U8glib");
    
  }while( u8g_NextPage(&u8g) );
  
  while( u8g_sdl_get_key() < 0 )
    ;
  
  return 0;
}
示例#3
0
void drawMainMenu(uint8_t menuPosition){
	char *mainMenuStrings[MAIN_MENU_ITEMS] = {"Last swim", "New Swim"};
	uint8_t i, h;
	u8g_uint_t w, d;
	u8g_SetFont(&u8g, u8g_font_6x13);
	u8g_SetFontRefHeightText(&u8g);
	u8g_SetFontPosTop(&u8g);
	h = u8g_GetFontAscent(&u8g) - u8g_GetFontDescent(&u8g);
	w = u8g_GetWidth(&u8g);
	
	char vccChar[10];
	my_itoa(vcc, vccChar, 10);

	// Doing the actual drawing
	u8g_FirstPage(&u8g);
	do{
		
		for (i = 0; i < MAIN_MENU_ITEMS; i++){
			d = (w - u8g_GetStrWidth(&u8g, mainMenuStrings[i])) / 2;
			u8g_SetDefaultForegroundColor(&u8g);
			if (i == menuPosition){
				u8g_DrawBox(&u8g, 0, i*h+1, w, h);
				u8g_SetDefaultBackgroundColor(&u8g);
			}
			u8g_DrawStr(&u8g, d, i*h, mainMenuStrings[i]);
		}
		u8g_SetDefaultForegroundColor(&u8g);
		u8g_DrawFrame(&u8g, 0, 0, 128, 64);
		
		u8g_DrawStr(&u8g, 5, 50, vccChar);
	} while (u8g_NextPage(&u8g));
}
示例#4
0
void dog_ClrBox(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
{
  y1 = dog_height_minus_one - y1;
  y2 = dog_height_minus_one - y2;
  u8g_SetColorIndex(&u8g_dogm128_obj, 0);
  u8g_DrawBox(&u8g_dogm128_obj, x1, y2, x2-x1+1, y1-y2+1);
}
示例#5
0
/* drawing callback for menu */
int gui_menu_draw_cb(u8g_t *u8g, struct GuiWindow *win,
                struct GuiPoint abspos)
{
    struct GuiMenu *menu = (struct GuiMenu *)win;

    int y0 = menu->selected*10;

    u8g_SetDefaultBackgroundColor(u8g);
    u8g_DrawBox(u8g, abspos.x, y0, abspos.x+10, abspos.y+70);

    // u8g_SetDefaultMidColor(u8g);
    u8g_SetDefaultForegroundColor(u8g);
    u8g_DrawTriangle(u8g, abspos.x, y0,
            abspos.x+10, y0+5,
            abspos.x, y0+10);

    u8g_SetDefaultForegroundColor(u8g);

    for (int i = 0; i < 7; ++i) {
        y0 = (i+1)*10;
        const char *s = menutext[i];

        if (i == menu->selected) {
            u8g_SetFont(u8g, u8g_font_helvB08);
        } else {
            u8g_SetFont(u8g, u8g_font_helvR08);
        }
        u8g_DrawStr(u8g,  abspos.x+12, y0, s);
    }

    return 0;
}
示例#6
0
void draw_color_box2(void)
{
  u8g_uint_t w,h;
  u8g_uint_t r, g, b;
  
  b = 1;
  
  w = u8g_GetWidth(&u8g)/64;
  h = u8g_GetHeight(&u8g)/32;
    for( g = 0; g < 16; g++ )
      for( r = 0; r < 32; r++ )
      {
	u8g_SetRGB(&u8g, r<<3, g<<4, b<<6);
	u8g_DrawBox(&u8g, g*w + 0*w*16, r*h, w, h);
	u8g_DrawBox(&u8g, (16-1-g)*w + 1*w*16, r*h, w, h);
	u8g_DrawBox(&u8g, g*w + 2*w*16, r*h, w, h);
	u8g_DrawBox(&u8g, (16-1-g)*w + 3*w*16, r*h, w, h);
	  
      }
}
示例#7
0
/* draw procedure of the u8g picture loop */
void draw(void)
{
  u8g_SetDefaultForegroundColor(&u8g);
  
  if ( is_led_on )
    u8g_DrawBox(&u8g, 0,0,5,5);
  else
    u8g_DrawFrame(&u8g, 0,0,5,5);
  /* call the m2 draw procedure */
  m2_Draw();
}
示例#8
0
/* origin is low left */
void m2_u8g_draw_box(uint8_t x0, uint8_t y0, uint8_t w, uint8_t h)
{
  u8g_uint_t y;
  /* transform y to upper left */
  y = m2_u8g_dev_variables.m2_u8g_height_minus_one;
  y -= y0;
  y -= h;
  y++;			/* 13 Jan 2013: Issue 95 */
  u8g_SetColorIndex(m2_u8g_dev_variables.m2_u8g, m2_u8g_dev_variables.m2_u8g_draw_color);
  u8g_DrawBox(m2_u8g_dev_variables.m2_u8g, x0, y, w, h);
}
示例#9
0
文件: ui.c 项目: mtl/tmk_keyboard
static void draw_page( char * title ) {

    // Draw title bar:
    display_set_draw_color( &menu_title_color_bg );
    int title_bar_height = menu_title_font_vsize + ( menu_title_pad << 1 );
    u8g_DrawBox( u8g, 0, 0, 128, title_bar_height );
    display_set_draw_color( &menu_title_color_fg );
    u8g_SetFont( u8g, menu_title_font );
    u8g_DrawStr(
        u8g,
        menu_title_pad + 1,
        menu_title_font_height + menu_title_pad,
        title
    );

    // Draw list background:
    display_set_draw_color( &menu_list_color_bg );
    page_body_start = title_bar_height + menu_title_gap;
    u8g_DrawBox( u8g, 0, page_body_start, 128, 128 - page_body_start );

    return;
}
示例#10
0
void menu_draw(menu_t *menu, u8g_t *u8g)
{
	uint8_t i, h;
	static char ramstr[32];
	menu_buttons_t *b;
	u8g_uint_t w, d;
	
	if(!menu)
		return;
	
	// Calculate text size
	u8g_SetFont(u8g, u8g_font_5x7);
	u8g_SetFontRefHeightText(u8g);
	u8g_SetFontPosTop(u8g);
	h = u8g_GetFontAscent(u8g)-u8g_GetFontDescent(u8g);
	w = u8g_GetWidth(u8g);
	for( i = 0;; i++ ) {        // draw all menu items
		// Copy string from program memory to a work string in RAM
		strncpy_P(ramstr, (PGM_P)pgm_read_word(&(menu->strings[i])), sizeof(ramstr));
		ramstr[31] = 0;
		// Zero length string marks end of string list. 
		if(!ramstr[0])
			break;
		// Get its length in pixels
		d = (w-u8g_GetStrWidth(u8g, ramstr))/2;
		// Set foreground color
		u8g_SetDefaultForegroundColor(u8g);
		// If item selected
		if ( i == menu->selected ) {            // current selected menu item
			u8g_DrawBox(u8g, 0, i*h+1, w, h);   // draw cursor bar
			u8g_SetDefaultBackgroundColor(u8g);
		}
		// Display the string
		u8g_DrawStr(u8g, d, i*h, ramstr);
	}
	
	// Remember menu item count
	menu->item_count = i;
	
	// Ensure text and background are set back to normal
	u8g_SetDefaultForegroundColor(u8g);
	
	// If there are soft buttons, draw them here
	if(menu->buttons){	
		for(b = menu->buttons; b; b = b->next){
			strncpy_P(ramstr, b->label, sizeof(ramstr));
			ramstr[31] = 0;
			u8g_DrawStr(u8g, b->col, b->row, ramstr);
		}
	}
}
示例#11
0
// Lua: u8g.drawBox( self, x, y, width, height )
static int lu8g_drawBox( lua_State *L )
{
    lu8g_userdata_t *lud;

    if ((lud = get_lud( L )) == NULL)
        return 0;

    u8g_uint_t args[4];
    lu8g_get_int_args( L, 2, 4, args );

    u8g_DrawBox( LU8G, args[0], args[1], args[2], args[3] );

    return 0;
}
示例#12
0
void m2_u8g_draw_box_icon(uint8_t x, uint8_t y, uint8_t font, uint8_t icon)
{
  uint8_t h;
  h = m2_u8g_get_box_icon_size(font);
  y = m2_u8g_height_minus_one - y;
  
  u8g_SetColorIndex(m2_u8g, m2_u8g_current_text_color);
  u8g_DrawFrame(m2_u8g, x, y - h, h, h);
  
  if ( icon == M2_ICON_TOGGLE_ACTIVE || icon == M2_ICON_RADIO_ACTIVE )
  {
    h -= 4;
    u8g_DrawBox(m2_u8g, x + 2, y - h - 2, h, h);
  }
}
示例#13
0
void draw_color_box1(void)
{
  u8g_uint_t w,h;
  u8g_uint_t r, g, b;
  
  w = u8g_GetWidth(&u8g)/64;
  h = u8g_GetHeight(&u8g)/32;
  for( b = 0; b < 4; b++ )
    for( g = 0; g < 16; g++ )
      for( r = 0; r < 32; r++ )
      {
	u8g_SetRGB(&u8g, r<<3, g<<4, b<<6);
	u8g_DrawBox(&u8g, g*w + b*w*16, r*h, w, h);
	  
      }
}
示例#14
0
/* callback to draw the clock face */
int gui_draw_clock_face_cb(u8g_t *u8g, struct GuiWindow *win,
                struct GuiPoint abspos)
{
    struct GuiClockface *f = (struct GuiClockface *)win;

    int center_x = f->center_x + abspos.x;
    int center_y = f->center_y + abspos.y;

    /* clear background to white */
    u8g_SetDefaultBackgroundColor(u8g);
    u8g_DrawBox(u8g, center_x-f->radius, center_y-f->radius, 2*f->radius, 2*f->radius);
    u8g_SetDefaultForegroundColor(u8g);

    /* face */
    u8g_DrawCircle(u8g, center_x, center_y, f->radius, U8G_DRAW_ALL);
    u8g_DrawCircle(u8g, center_x, center_y, f->radius+1, U8G_DRAW_ALL);

    /* hour markers */
    for (int h = 0; h < 12; ++h) {
        u8g_DrawCircle(u8g, 
            sintab60[absrot60(h*5+15)] + center_x, 
            sintab60[h*5] + center_y, 2, U8G_DRAW_ALL);
    }

    int hours = (f->hours % 12);
    int minutes = f->minutes % 60;

    /* hours hand */
    int angle = absrot60(-(short)hours*5 - (short)minutes/12 + 15);
    int x2 = sintab60[absrot60(angle+15)]/2 + center_x;   // cos, x-axis is natural direction
    int y2 = (-sintab60[angle]/2) + center_y;         // sin, y-axis is inverted

    u8g_DrawLine(u8g, center_x, center_y, x2, y2);
    u8g_DrawLine(u8g, center_x+1, center_y, x2+1, y2);
    u8g_DrawLine(u8g, center_x, center_y+1, x2, y2+1);
    u8g_DrawLine(u8g, center_x-1, center_y, x2-1, y2);
    u8g_DrawLine(u8g, center_x, center_y-1, x2, y2-1);

    /* minutes hand */
    angle = absrot60(-(short)minutes + 15);
    x2 = sintab60[absrot60(angle+15)]*30/34 + center_x;   // cos, x-axis is natural direction
    y2 = (-sintab60[angle])*30/34 + center_y;         // sin, y-axis is inverted

    u8g_DrawLine(u8g, center_x, center_y, x2, y2);

    return 0;
}
示例#15
0
/* drawing callback for battery */
int gui_battery_draw_cb(u8g_t *u8g, struct GuiWindow *win,
                struct GuiPoint abspos)
{
    struct GuiBattery *batt = (struct GuiBattery*)win;
    int percent = batt->percent;

    if (percent < 0) { percent = 0; }
    if (percent > 100) { percent = 100; }

    u8g_SetDefaultMidColor(u8g);
    u8g_DrawBox(u8g, abspos.x, abspos.y, percent / (100/batt->win.size.x), batt->win.size.y);

    u8g_SetDefaultForegroundColor(u8g);
    u8g_DrawFrame(u8g, abspos.x, abspos.y, batt->win.size.x, batt->win.size.y);
    u8g_DrawFrame(u8g, abspos.x+batt->win.size.x, abspos.y+2, 2, 4);

    u8g_SetFont(u8g, u8g_font_helvR08);
    char s[12];
#if 0
    /* print percents */
    int k = itostr(s, 16, vbat_percent);
    s[k] = '%';
    s[k+1] = '\0';
#else
    /* print voltage */
    int vbat100 = batt->vbat_measured / 10;
    if ((batt->vbat_measured % 10) >= 5) { vbat100 += 1; }
    int k = itostr(s, 16, vbat100);
    memmove(s+2, s+1, k-1);
    s[1] = '.';
    s[k+1] = 'V';
    s[k+2] = batt->batt_state;
    s[k+3] = '\0';
#endif
    u8g_DrawStr(u8g,  abspos.x+batt->win.size.x+4, abspos.y+batt->win.size.y, s);

    return 0;
}
示例#16
0
文件: menu.c 项目: gnkarn/u8glib
void draw_menu(void)
{
    uint8_t i, h;
    u8g_uint_t w, d;

    u8g_SetFont(&u8g, u8g_font_6x13);
    u8g_SetFontRefHeightText(&u8g);
    u8g_SetFontPosTop(&u8g);

    h = u8g_GetFontAscent(&u8g)-u8g_GetFontDescent(&u8g);
    w = u8g_GetWidth(&u8g);
    for( i = 0; i < MENU_ITEMS; i++ )
    {
        d = (w-u8g_GetStrWidth(&u8g, menu_strings[i]))/2;
        u8g_SetDefaultForegroundColor(&u8g);
        if ( i == menu_current )
        {
            u8g_DrawBox(&u8g, 0, i*h+1, w, h);
            u8g_SetDefaultBackgroundColor(&u8g);
        }
        u8g_DrawStr(&u8g, d, i*h, menu_strings[i]);
    }
}
示例#17
0
/* draw a rectange at x/y */
void draw_rectangle(uint8_t x, uint8_t y) {
  u8g_SetDefaultForegroundColor(&u8g);
  u8g_DrawBox(&u8g,x,y,size,size);
}
示例#18
0
void display_clear() {
    u8g_SetRGB( &u8g, 0, 0, 0 );
    u8g_DrawBox( &u8g, 0, 0, 128, 128 );
}
示例#19
0
uint8_t m2_gh_u8g_cffs(m2_gfx_arg_p  arg)
{
  switch(arg->msg)
  {
    case M2_GFX_MSG_DRAW_NORMAL_NO_FOCUS:
      if ( (arg->font & 4) != 0 )
      {
        /* highlight flag is set, draw frame with shadow */
        m2_u8g_draw_color_box(arg->x+1, arg->y+1, arg->w-2, arg->h-2, m2_u8g_highlight_bg_color);
      	m2_u8g_draw_color_frame_shadow(arg->x+m2_u8g_dev_variables.m2_gh_u8g_invisible_frame_border_x_size, arg->y, arg->w-2*m2_u8g_dev_variables.m2_gh_u8g_invisible_frame_border_x_size, arg->h, m2_u8g_highlight_frame_color, m2_u8g_highlight_shadow_color);
      }

      m2_u8g_dev_variables.m2_u8g_current_text_color = m2_u8g_dev_variables.m2_u8g_fg_text_color;
      // if ( m2_gh_u8g_invert_at_depth < m2_gh_u8g_current_depth )
      // {
      //   m2_u8g_current_text_color = m2_u8g_bg_text_color;
      // }
      break;
    case M2_GFX_MSG_DRAW_NORMAL_PARENT_FOCUS:
      break;
    case M2_GFX_MSG_DRAW_NORMAL_FOCUS:
      if ( (arg->font & 4) != 0 )
      {
        /* 
            highlight version
            draw frame with shadow together with a filled box 
        */
	
        //m2_u8g_current_text_color = m2_u8g_bg_text_color;
        m2_u8g_dev_variables.m2_u8g_current_text_color = m2_u8g_dev_variables.m2_u8g_fg_text_color;
        m2_u8g_draw_color_box(arg->x+1, arg->y+1, arg->w-2, arg->h-2, m2_u8g_highlight_focus_bg_color);
      	m2_u8g_draw_color_frame_shadow(arg->x+m2_u8g_dev_variables.m2_gh_u8g_invisible_frame_border_x_size, arg->y, arg->w-2*m2_u8g_dev_variables.m2_gh_u8g_invisible_frame_border_x_size, arg->h, m2_u8g_highlight_focus_frame_color, m2_u8g_highlight_focus_shadow_color);
        // m2_gh_u8g_invert_at_depth = m2_gh_u8g_current_depth;
      }
      else
      {
        /* 
            normal version
            draw only the frame with shadow
        */
        m2_u8g_dev_variables.m2_u8g_current_text_color = m2_u8g_dev_variables.m2_u8g_fg_text_color;
        m2_u8g_draw_color_box(arg->x+1, arg->y+1, arg->w-2, arg->h-2, m2_u8g_normal_focus_bg_color);
      	m2_u8g_draw_color_frame_shadow(arg->x+m2_u8g_dev_variables.m2_gh_u8g_invisible_frame_border_x_size, arg->y, arg->w-2*m2_u8g_dev_variables.m2_gh_u8g_invisible_frame_border_x_size, arg->h, m2_u8g_normal_focus_frame_color, m2_u8g_normal_focus_shadow_color);
      }
      // printf("invert %d, width %d x:%d y:%d\n", m2_gh_u8g_invert_at_depth, arg->w, arg->x, arg->y);
      break;
    case M2_GFX_MSG_DRAW_SMALL_FOCUS:
	  /*
      m2_u8g_current_text_color = m2_u8g_bg_text_color;
      m2_u8g_draw_color_box(arg->x, arg->y, arg->w, arg->h, m2_u8g_fg_text_color);
      */

      m2_u8g_dev_variables.m2_u8g_current_text_color = m2_u8g_dev_variables.m2_u8g_fg_text_color;
      m2_u8g_draw_color_box(arg->x, arg->y, arg->w, arg->h, m2_u8g_small_focus_bg_color);
      break;
    case M2_GFX_MSG_DRAW_GO_UP:
      /* does not work because of missing xor...
         also: can not be fixed with FRAME_DRAW_AT_END
       m2_u8g_current_text_color = m2_u8g_bg_text_color; */
      m2_u8g_draw_color_box(arg->x, arg->y, arg->w, arg->h/2, m2_u8g_exit_data_entry_color);
      break;
    case M2_GFX_MSG_GET_NORMAL_BORDER_HEIGHT:
      return 3;
    case M2_GFX_MSG_GET_NORMAL_BORDER_WIDTH:
      return 3+2*m2_u8g_dev_variables.m2_gh_u8g_invisible_frame_border_x_size+2*m2_u8g_dev_variables.m2_gh_u8g_additional_text_border_x_size;
    case M2_GFX_MSG_GET_NORMAL_BORDER_X_OFFSET:
      return 1+m2_u8g_dev_variables.m2_gh_u8g_invisible_frame_border_x_size+m2_u8g_dev_variables.m2_gh_u8g_additional_text_border_x_size;
    case M2_GFX_MSG_GET_NORMAL_BORDER_Y_OFFSET:
      return 2;
    case M2_GFX_MSG_GET_LIST_OVERLAP_HEIGHT:
      return 0;
    case M2_GFX_MSG_GET_LIST_OVERLAP_WIDTH:
      return 0;
    case M2_GFX_MSG_IS_FRAME_DRAW_AT_END:
      return 0; /* focus (highlight) is drawn first, then the text string */
    case M2_GFX_MSG_START:
      u8g_SetColorIndex(m2_u8g_dev_variables.m2_u8g, m2_u8g_background_color);
      u8g_DrawBox(m2_u8g_dev_variables.m2_u8g, 0, 0, u8g_GetWidth(m2_u8g_dev_variables.m2_u8g), u8g_GetHeight(m2_u8g_dev_variables.m2_u8g));
      break;
  }

  return m2_gh_u8g_base(arg);
}
示例#20
0
void u8g_DrawInfo(void) //Malen der Batterie, Anzeige in %
{
    ///////Infos////  X  /////////
    //  Karte   //Pfeil// Frei  //
    //  akt.    //     // hier: //
    //  Raum    /////////       //
    //          //Info //       //
    //          //Karte//       //
    //////////////////////////////

    u8g_DrawHLine(&u8g, 0, 6, 128); //Horizontale Abgrenzungslinie

    u8g_SetFont(&u8g, u8g_font_4x6); //Schriftart

    //////Batterie////////////
    u8g_DrawFrame(&u8g, 0, 0, 10, 5); //Batteriekörper
    u8g_DrawPixel(&u8g, 10, 2);
    int8_t batt_volumeVar = batt_percent/11; //Berechnung Füllung
    if(batt_volumeVar > 8)
        batt_volumeVar = 8;
    if(batt_volumeVar < 0)
        batt_volumeVar = 0;
    u8g_DrawBox(&u8g, 1, 1, batt_volumeVar, 3); //Füllung

    //Anzeige daneben
    u8g_DrawLong(15,	5, batt_percent);
    u8g_DrawStr(&u8g, 25, 	5, "%");

    //Fehleranzeige daneben:
    if(timer_disp_msg == 0)
    {
        disp_msg_i ++;
        if(disp_msg_i == DISP_MSG_I_TOP)
        {
            disp_msg_i = 0;
            if(!(is_msg & (1<<1)))
            {
                which_msg = 0;
            }
            else
            {
                is_msg &= ~ (1<<1);
            }
        }
        is_msg &= ~ (1<<0);
    }

    switch(disp_msg_i)
    {
    case 0:
        if(batt_percent < 20)
        {
            set_msg();
        }
        break;
    case 1:
        if((check_srf & (1<<0)) ||
                (check_srf & (1<<1)) ||
                (check_srf & (1<<2)) ||
                (check_srf & (1<<3)))
        {
            set_msg();
        }
        break;
    case 2:
        if((check_srf & (1<<4)) ||
                (check_srf & (1<<5)) ||
                (check_srf & (1<<6)) ||
                (check_srf & (1<<7)))
        {
            set_msg();
        }
        break;
    case 3:
        if((check_srf & (1<<8)) ||
                (check_srf & (1<<9)) ||
                (check_srf & (1<<10)) ||
                (check_srf & (1<<11)))
        {
            set_msg();
        }
        break;
    case 4:
        if((check_srf & (1<<12)) ||
                (check_srf & (1<<13)) ||
                (check_srf & (1<<14)) ||
                (check_srf & (1<<15)))
        {
            set_msg();
        }
        break;
    case 5:
        if(check_mlx & (1<<0))
        {
            set_msg();
        }
        break;
    case 6:
        if(check_mlx & (1<<1))
        {
            set_msg();
        }
        break;
    case 7:
        if((check_um6 & (1<<0)) ||
                (check_um6 & (1<<1)))
        {
            set_msg();
        }
        break;
    case 8:
        if(motor_off)
        {
            set_msg();
        }
        break;
    case 9:
        if(timer_bt_is_busy > 0)
        {
            set_msg();
        }
        break;
    case 10:
        if(setup)
        {
            set_msg();
        }
        break;
    case 11:
        if(check_um6 & (1<<2))
        {
            set_msg();
        }
    case 12:
        if(!use_map)
        {
            set_msg();
        }
        break;
    }
    u8g_DrawStr(&u8g, 35, 	5, disp_msg[which_msg]);
}
示例#21
0
文件: ui.c 项目: mtl/tmk_keyboard
static void draw_rgb_config() {

    int frame_width = 1;

    // Render title bar and background:
    draw_page( rgb_widget_title );

    // Compute first line y pos and line height:
    int y = (
        page_body_start + frame_width + widget_focus_frame_pad +
        menu_list_font_height + menu_list_hpad - 1
    );
    int step = ( frame_width << 1 ) + ( widget_focus_frame_pad << 1 ) + menu_list_font_vsize - 1;

    // Compute x pos for numbers:
    u8g_SetFont( u8g, menu_list_font );
    int char_width = u8g_GetStrWidth( u8g, "w" );
    int num_chars = 3;
    if ( rgb_max_value > 255 ) {
        num_chars = 4;
    }
    int num_x = 128 - menu_list_hpad - frame_width - num_chars * char_width;

    // Compute bar dimensions:
    int bar_frame_x = menu_list_hpad;
    int bar_x = bar_frame_x + frame_width + widget_focus_frame_pad;
    uint16_t max_bar_width = num_x - bar_x - ( widget_focus_frame_pad << 1 ) - 1;
    uint32_t bar_width = 0;

    // Draw bars:
    display_set_draw_color( &rgb_red );
    int y_red = y;
    bar_width = max_bar_width;
    bar_width *= rgb_widget_color[ 0 ];
    bar_width /= rgb_max_value;
    u8g_DrawBox(
        u8g,
        bar_x,
        y_red - menu_list_font_height,
        bar_width,
        menu_list_font_vsize
    );

    display_set_draw_color( &rgb_green );
    int y_green = y_red + step;
    bar_width = max_bar_width;
    bar_width *= rgb_widget_color[ 1 ];
    bar_width /= rgb_max_value;
    u8g_DrawBox(
        u8g,
        bar_x,
        y_green - menu_list_font_height,
        bar_width,
        menu_list_font_vsize
    );

    display_set_draw_color( &rgb_blue );
    int y_blue = y_green + step;
    bar_width = max_bar_width;
    bar_width *= rgb_widget_color[ 2 ];
    bar_width /= rgb_max_value;
    u8g_DrawBox(
        u8g,
        bar_x,
        y_blue - menu_list_font_height,
        bar_width,
        menu_list_font_vsize
    );

    // Draw numbers:
    display_set_draw_color( &menu_title_color_fg );
    char digits[] = "   ";
    if ( rgb_max_value < 256 ) {
        digits[ 2 ] = 0;
    }
    int d = 0;
    if ( rgb_max_value > 255 ) {
        digits[ d++ ] = nibchar( rgb_widget_color[ 0 ] >> 8 );
    }