void Display::DrawSignalStrength() { //percentage 0-5 u8g_DrawHLine(&u8g,SIGNALPERCENTAGE_X ,SIGNALPERCENTAGE_Y + 15,2); u8g_DrawHLine(&u8g,SIGNALPERCENTAGE_X + 3 ,SIGNALPERCENTAGE_Y + 15,2); u8g_DrawHLine(&u8g,SIGNALPERCENTAGE_X + 6 ,SIGNALPERCENTAGE_Y + 15,2); u8g_DrawHLine(&u8g,SIGNALPERCENTAGE_X + 9 ,SIGNALPERCENTAGE_Y + 15,2); u8g_DrawHLine(&u8g,SIGNALPERCENTAGE_X + 12,SIGNALPERCENTAGE_Y + 15,2); if (radioSignal >= 14) { u8g_DrawVLine(&u8g,SIGNALPERCENTAGE_X ,SIGNALPERCENTAGE_Y + 12, 3); u8g_DrawVLine(&u8g,SIGNALPERCENTAGE_X + 1 ,SIGNALPERCENTAGE_Y + 12, 3); } if (radioSignal >= 24) { u8g_DrawVLine(&u8g,SIGNALPERCENTAGE_X + 3 ,SIGNALPERCENTAGE_Y + 9 , 6); u8g_DrawVLine(&u8g,SIGNALPERCENTAGE_X + 4 ,SIGNALPERCENTAGE_Y + 9 , 6); } if (radioSignal >= 34) { u8g_DrawVLine(&u8g,SIGNALPERCENTAGE_X + 6 ,SIGNALPERCENTAGE_Y + 6 , 9); u8g_DrawVLine(&u8g,SIGNALPERCENTAGE_X + 7 ,SIGNALPERCENTAGE_Y + 6 , 9); } if (radioSignal >= 44) { u8g_DrawVLine(&u8g,SIGNALPERCENTAGE_X + 9 ,SIGNALPERCENTAGE_Y + 3 , 12); u8g_DrawVLine(&u8g,SIGNALPERCENTAGE_X + 10,SIGNALPERCENTAGE_Y + 3 , 12); } if (radioSignal >= 54) { u8g_DrawVLine(&u8g,SIGNALPERCENTAGE_X + 12,SIGNALPERCENTAGE_Y , 15); u8g_DrawVLine(&u8g,SIGNALPERCENTAGE_X + 13,SIGNALPERCENTAGE_Y , 15); } }
int main(void) { u8g_uint_t w,h; u8g_t u8g; u8g_Init(&u8g, &u8g_dev_sdl_1bit); u8g_SetCursorFont(&u8g, u8g_font_cursor); u8g_SetCursorStyle(&u8g, 34); u8g_SetCursorColor(&u8g, 1, 0); u8g_EnableCursor(&u8g); for(;;) { u8g_FirstPage(&u8g); do { u8g_SetColorIndex(&u8g, 1); u8g_SetFont(&u8g, u8g_font_10x20); //u8g_SetFont(&u8g, u8g_font_fur17); w = u8g_GetFontBBXWidth(&u8g); h = u8g_GetFontBBXHeight(&u8g); //u8g_DrawStr(&u8g, 0, 2*h, 0, "ABCgdef"); u8g_DrawStrDir(&u8g, 0, 5, 0, "g"); u8g_DrawStrDir(&u8g, 10, 7, 0, "g"); u8g_DrawStrDir(&u8g, 20, 9, 0, "g"); u8g_DrawStrDir(&u8g, 20, 9, 0, "ga"); //u8g_DrawStr(&u8g, 40, 9, 0, "g"); u8g_DrawStr(&u8g, 70+3, 25, "gabc"); u8g_DrawStr90(&u8g, 70, 25+3, "gabc"); u8g_DrawStr180(&u8g, 70-3, 25, "gabc"); u8g_DrawStr270(&u8g, 70, 25-3, "gabc"); //u8g_DrawFrame(&u8g, 2, 2, 9, 3); //u8g_DrawFrame(&u8g, 0, 0, 13, 7); //u8g_DrawHLine( &u8g, 0, 16, 50 ); u8g_SetColorIndex(&u8g, 1); u8g_DrawHLine( &u8g, 0, 3, 127 ); u8g_SetColorIndex(&u8g, 0); u8g_DrawHLine( &u8g, 0, 4, 127 ); }while( u8g_NextPage(&u8g) ); while( uiStep(&u8g) == 0 ) ; printf("%d %d\n", cursor_x, cursor_y); u8g_SetCursorPos(&u8g, cursor_x, cursor_y); } return 0; }
void Display::DrawFrostIcon() { u8g_DrawHLine(&u8g,FROSTICON_X + 1 ,FROSTICON_Y + 8 ,6); u8g_DrawVLine(&u8g,FROSTICON_X ,FROSTICON_Y ,8); u8g_DrawVLine(&u8g,FROSTICON_X + 7 ,FROSTICON_Y ,8); u8g_DrawHLine(&u8g,FROSTICON_X + 4 ,FROSTICON_Y + 4 ,10); u8g_DrawLine(&u8g, FROSTICON_X + 11,FROSTICON_Y + 2 , FROSTICON_X + 13, FROSTICON_Y + 4); u8g_DrawLine(&u8g, FROSTICON_X + 13,FROSTICON_Y + 4 , FROSTICON_X + 11, FROSTICON_Y + 6); }
void Display::DrawWaterIcon() { /* * v 0.1 * / unsigned char i, j, x; for (j = 0; j <= 6; j+=3) { x = 0; for (i = 0; i <= 10; i+=2) { u8g_DrawLine(&u8g, WATERICON_X + i, WATERICON_Y + j + (x == 1), WATERICON_X + i + 1 , WATERICON_Y + j + (x == 0)); x = !x; } }*/ /* * v 0.2 */ unsigned char i, x = 0; u8g_DrawHLine(&u8g,WATERICON_X + 1 ,WATERICON_Y + 8 ,12); u8g_DrawVLine(&u8g,WATERICON_X ,WATERICON_Y ,8); u8g_DrawVLine(&u8g,WATERICON_X + 13,WATERICON_Y ,8); for (i = 1; i <= 11; i+=2) { u8g_DrawLine(&u8g, WATERICON_X + i, WATERICON_Y + 1 + (x == 1), WATERICON_X + i + 1 , WATERICON_Y + 1 + (x == 0)); x = !x; } }
int xmain(void) { u8g_uint_t w,h; u8g_t u8g; u8g_Init(&u8g, &u8g_dev_sdl_1bit); u8g_FirstPage(&u8g); u8g_SetCursorFont(&u8g, u8g_font_cursor); do { u8g_SetColorIndex(&u8g, 1); u8g_SetFont(&u8g, u8g_font_9x18); //u8g_SetFont(&u8g, u8g_font_fur17); w = u8g_GetFontBBXWidth(&u8g); h = u8g_GetFontBBXHeight(&u8g); //u8g_DrawStr(&u8g, 0, 2*h, 0, "ABCgdef"); u8g_DrawStrDir(&u8g, 0, 5, 0, "g"); u8g_DrawStrDir(&u8g, 10, 7, 0, "g"); u8g_DrawStrDir(&u8g, 20, 9, 0, "g"); u8g_DrawStrDir(&u8g, 20, 9, 0, "ga"); //u8g_DrawStr(&u8g, 40, 9, 0, "g"); u8g_DrawStr(&u8g, 70+3, 25, "gabc"); u8g_DrawStr90(&u8g, 70, 25+3, "gabc"); u8g_DrawStr180(&u8g, 70-3, 25, "gabc"); u8g_DrawStr270(&u8g, 70, 25-3, "gabc"); //u8g_DrawFrame(&u8g, 2, 2, 9, 3); //u8g_DrawFrame(&u8g, 0, 0, 13, 7); //u8g_DrawHLine( &u8g, 0, 16, 50 ); u8g_SetColorIndex(&u8g, 1); u8g_DrawHLine( &u8g, 0, 3, 127 ); u8g_SetColorIndex(&u8g, 0); u8g_DrawHLine( &u8g, 0, 4, 127 ); }while( u8g_NextPage(&u8g) ); while( u8g_sdl_get_key() < 0 ) ; return 0; }
/* x1 must be lower or equal to x2 */ void dog_SetHLine(uint8_t x1, uint8_t x2, uint8_t y) { //printf("SetHLine x1:%d x2:%d y:%d\n", x1, x2, y); y = dog_height_minus_one - y; u8g_SetColorIndex(&u8g_dogm128_obj, 1); u8g_DrawHLine(&u8g_dogm128_obj, x1, y, x2-x1+1); //printf("SetHLine x:%d y:%d w:%d \n", x1, y, x2-x1+1); }
void Display::DrawSecondScreen() { for (int i = 0; i < DISPLAY_SCREEN_LINE_COUNT; i++) { if (screenHLinesWidth[i] > 0) { u8g_DrawHLine(&u8g, screenHLinesX[i], screenHLinesY[i], screenHLinesWidth[i]); } if (screenVLinesWidth[i] > 0) { u8g_DrawHLine(&u8g, screenVLinesX[i], screenVLinesY[i], screenVLinesWidth[i]); } } u8g_SetFont(&u8g, u8g_font_7x13); for (int i = 0; i < DISPLAY_SCREEN_TEXT_COUNT; i++) { u8g_DrawStr(&u8g, 0, ((i+1)*12), screenText[i]); } }
void draw_logo(uint8_t d) { u8g_SetFont(&u8g, u8g_font_gdr25r); u8g_DrawStr(&u8g, 0+d, 30+d, "U"); u8g_SetFont(&u8g, u8g_font_gdr30n); u8g_DrawStr90(&u8g, 23+d,10+d,"8"); u8g_SetFont(&u8g, u8g_font_gdr25r); u8g_DrawStr(&u8g, 53+d,30+d,"g"); u8g_DrawHLine(&u8g, 2+d, 35+d, 47); u8g_DrawVLine(&u8g, 45+d, 32+d, 12); }
void m2_u8g_draw_frame_shadow(uint8_t x0, uint8_t y0, uint8_t w, uint8_t h) { u8g_uint_t y; y = m2_u8g_dev_variables.m2_u8g_height_minus_one; y -= y0; y -= h; y++; /* 13 Jan 2013: Issue 95 */ w--; h--; u8g_SetColorIndex(m2_u8g_dev_variables.m2_u8g, m2_u8g_dev_variables.m2_u8g_draw_color); u8g_DrawFrame(m2_u8g_dev_variables.m2_u8g, x0, y, w, h); u8g_DrawVLine(m2_u8g_dev_variables.m2_u8g, x0+w, y+1, h); u8g_DrawHLine(m2_u8g_dev_variables.m2_u8g, x0+1, y+h, w); }
// Lua: u8g.drawHLine( self, x, y, width ) static int lu8g_drawHLine( lua_State *L ) { lu8g_userdata_t *lud; if ((lud = get_lud( L )) == NULL) return 0; u8g_uint_t args[3]; lu8g_get_int_args( L, 2, 3, args ); u8g_DrawHLine( LU8G, args[0], args[1], args[2] ); return 0; }
static void pg_hline(pg_struct *pg, u8g_t *u8g) { pg_word_t x1, x2, y; x1 = pg->pge[PG_LEFT].current_x; x2 = pg->pge[PG_RIGHT].current_x; y = pg->pge[PG_RIGHT].current_y; if ( y < 0 ) return; if ( y >= u8g_GetHeight(u8g) ) return; if ( x1 < x2 ) { if ( x2 < 0 ) return; if ( x1 >= u8g_GetWidth(u8g) ) return; if ( x1 < 0 ) x1 = 0; if ( x2 >= u8g_GetWidth(u8g) ) x2 = u8g_GetWidth(u8g); u8g_DrawHLine(u8g, x1, y, x2 - x1); } else { if ( x1 < 0 ) return; if ( x2 >= u8g_GetWidth(u8g) ) return; if ( x2 < 0 ) x1 = 0; if ( x1 >= u8g_GetWidth(u8g) ) x1 = u8g_GetWidth(u8g); u8g_DrawHLine(u8g, x2, y, x1 - x2); } }
void Display::DrawMainScreen() { DrawFrostIcon(); DrawWaterIcon(); u8g_SetFont(&u8g, u8g_font_5x8); u8g_DrawStr(&u8g, 0, 36, "set"); u8g_SetFont(&u8g, u8g_font_7x13); for (int i = 0; i < 3; i++) { u8g_DrawStr(&u8g, 20, ((i+1)*12), temp[i]); } if (strlen(errorText) > 0) { u8g_DrawStr(&u8g, 0, 48, errorText); } else if (heatingState) u8g_DrawStr(&u8g, 0, 48, "Heating"); u8g_DrawStr(&u8g, 0, 64, statusBar); u8g_DrawVLine(&u8g,64,0 ,52); u8g_DrawHLine(&u8g,0 ,51,64); if (radioState) { if (radioStereo) { u8g_SetFont(&u8g, u8g_font_5x8); u8g_DrawStr(&u8g, 108, 8, "st"); u8g_SetFont(&u8g, u8g_font_7x13); } u8g_DrawStr(&u8g, 73, 26, radioChannel); DrawSignalStrength(); } if (audioState) { u8g_DrawStr(&u8g, 81, 38, "Source:"); u8g_DrawStr(&u8g, 66, 50, audioSource); } }
uint8_t m2_gh_u8g_base(m2_gfx_arg_p arg) { /* Do a safety check here: Abort if m2_SetU8g has not been called */ if ( m2_u8g_dev_variables.m2_u8g == NULL ) return 0; /* Proceed with normal message processing */ switch(arg->msg) { case M2_GFX_MSG_INIT: break; case M2_GFX_MSG_START: /* check for proper setup */ break; case M2_GFX_MSG_END: break; case M2_GFX_MSG_DRAW_HLINE: u8g_DrawHLine(m2_u8g_dev_variables.m2_u8g, arg->x, m2_u8g_dev_variables.m2_u8g_height_minus_one - arg->y, arg->w); break; case M2_GFX_MSG_DRAW_VLINE: u8g_DrawVLine(m2_u8g_dev_variables.m2_u8g, arg->x, m2_u8g_dev_variables.m2_u8g_height_minus_one - arg->y, arg->h); break; case M2_GFX_MSG_DRAW_BOX: m2_u8g_draw_box(arg->x, arg->y, arg->w, arg->h); break; case M2_GFX_MSG_DRAW_TEXT: { u8g_uint_t x = arg->x; u8g_uint_t y; u8g_SetColorIndex(m2_u8g_dev_variables.m2_u8g, m2_u8g_dev_variables.m2_u8g_current_text_color); u8g_SetFont(m2_u8g_dev_variables.m2_u8g, m2_u8g_get_font(arg->font)); u8g_SetFontPosBottom(m2_u8g_dev_variables.m2_u8g); if ( (arg->font & 8) != 0 ) { if ( arg->w != 0 ) { x = arg->w; x -= u8g_GetStrWidth(m2_u8g_dev_variables.m2_u8g, arg->s); x >>= 1; x += arg->x; } } y = m2_u8g_dev_variables.m2_u8g_height_minus_one; y -= arg->y; y++; /* 13 Jan 2013: Issue 95, problem 2 */ x -= u8g_GetStrX(m2_u8g_dev_variables.m2_u8g, arg->s); //x += m2_gh_u8g_additional_text_border_x_size; u8g_DrawStr(m2_u8g_dev_variables.m2_u8g, x, y, arg->s); // printf("DRAW_TEXT: x=%d y=%d s=%s\n", x, y, arg->s); } break; case M2_GFX_MSG_DRAW_TEXT_P: { u8g_uint_t x = arg->x; u8g_uint_t y; u8g_SetColorIndex(m2_u8g_dev_variables.m2_u8g, m2_u8g_dev_variables.m2_u8g_current_text_color); u8g_SetFont(m2_u8g_dev_variables.m2_u8g, m2_u8g_get_font(arg->font)); u8g_SetFontPosBottom(m2_u8g_dev_variables.m2_u8g); if ( (arg->font & 8) != 0 ) { if ( arg->w != 0 ) { x = arg->w; x -= u8g_GetStrWidthP(m2_u8g_dev_variables.m2_u8g, (const u8g_pgm_uint8_t *)arg->s); x >>= 1; x += arg->x; } } y = m2_u8g_dev_variables.m2_u8g_height_minus_one; y -= arg->y; x -= u8g_GetStrXP(m2_u8g_dev_variables.m2_u8g, (const u8g_pgm_uint8_t *)arg->s); //x += m2_gh_u8g_additional_text_border_x_size; y++; /* 13 Jan 2013: Issue 95, problem 2 */ u8g_DrawStrP(m2_u8g_dev_variables.m2_u8g, x, y, (const u8g_pgm_uint8_t *)arg->s); }
void dog_ClrHLine(uint8_t x1, uint8_t x2, uint8_t y) { y = dog_height_minus_one - y; u8g_SetColorIndex(&u8g_dogm128_obj, 0); u8g_DrawHLine(&u8g_dogm128_obj, x1, y, x2-x1+1); }
uint8_t m2_gh_u8g_ffs(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_frame_shadow(arg->x+m2_gh_u8g_invisible_frame_border_x_size, arg->y, arg->w-2*m2_gh_u8g_invisible_frame_border_x_size, arg->h); } m2_u8g_current_text_color = 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_draw_box(arg->x+1, arg->y+1, arg->w-2, arg->h-2); m2_u8g_draw_frame_shadow(arg->x+m2_gh_u8g_invisible_frame_border_x_size, arg->y, arg->w-2*m2_gh_u8g_invisible_frame_border_x_size, arg->h); m2_gh_u8g_invert_at_depth = m2_gh_u8g_current_depth; } else { /* normal version draw only the frame with shadow */ m2_u8g_current_text_color = m2_u8g_fg_text_color; m2_u8g_draw_frame_shadow(arg->x+m2_gh_u8g_invisible_frame_border_x_size, arg->y, arg->w-2*m2_gh_u8g_invisible_frame_border_x_size, arg->h); } // 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_box(arg->x, arg->y, arg->w, arg->h); break; case M2_GFX_MSG_DRAW_NORMAL_DATA_ENTRY: m2_u8g_current_text_color = m2_u8g_fg_text_color; u8g_DrawHLine(m2_u8g, arg->x, m2_u8g_height_minus_one - arg->y, arg->w); break; case M2_GFX_MSG_DRAW_SMALL_DATA_ENTRY: m2_u8g_current_text_color = m2_u8g_fg_text_color; u8g_DrawHLine(m2_u8g, arg->x, m2_u8g_height_minus_one - arg->y, arg->w); 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_box(arg->x, arg->y, arg->w, arg->h/2); break; case M2_GFX_MSG_GET_NORMAL_BORDER_HEIGHT: return 3; case M2_GFX_MSG_GET_NORMAL_BORDER_WIDTH: return 3+2*m2_gh_u8g_invisible_frame_border_x_size+2*m2_gh_u8g_additional_text_border_x_size; case M2_GFX_MSG_GET_NORMAL_BORDER_X_OFFSET: return 1+m2_gh_u8g_invisible_frame_border_x_size+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 */ } return m2_gh_u8g_base(arg); }
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]); }