Beispiel #1
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));
}
Beispiel #2
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;
}
Beispiel #3
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);
		}
	}
}
Beispiel #4
0
void showHistoryTotal(void){
	EEOpen();
	
	uint8_t lengths = EEReadByte(2);
	history.totalLength = lengths;
	history.showLength = 255;
	// This will be wrong till I update the record length
	uint16_t totalTime = EEReadByte(3) << 8;
	totalTime += EEReadByte(4);
	
	// Creating the times for the history display
	char lengthStr[4], totalTimeStr[10];	
	itoa(lengths, lengthStr, 10);
	timeToString(totalTime, totalTimeStr);
	
	u8g_FirstPage(&u8g);
	u8g_SetDefaultForegroundColor(&u8g);
	do {
		u8g_DrawFrame(&u8g, 0, 0, 128, 64);
		u8g_DrawLine(&u8g, 64, 0, 64, 64);
		
		u8g_DrawStr(&u8g, (64 - u8g_GetStrWidth(&u8g, "Lengths"))/2, 5, "Lengths");
		u8g_DrawStr(&u8g, (64 - u8g_GetStrWidth(&u8g, lengthStr))/2, 5+20, lengthStr);
		
		u8g_DrawStr(&u8g, 64+(64 - u8g_GetStrWidth(&u8g, "Time"))/2, 5, "Time");
		u8g_DrawStr(&u8g, 64+(64 - u8g_GetStrWidth(&u8g, totalTimeStr))/2, 5+20, totalTimeStr);
		
	} while (u8g_NextPage(&u8g));
}
Beispiel #5
0
// Showing the record screen
void showRecordScreen(void){
	char lengthStr[4], totLenTimeStr[9], curLenTimeStr[9];
	itoa(currentLength, lengthStr, 10);
	timeToString(totLenTime, totLenTimeStr);
	timeToString(curLenTime, curLenTimeStr);

	u8g_FirstPage(&u8g);
	u8g_SetDefaultForegroundColor(&u8g);
	u8g_SetFont(&u8g, u8g_font_6x13);
	do{
		// Draw boxes
		u8g_DrawLine(&u8g, 64, 0, 64, 64);
		u8g_DrawLine(&u8g, 64, 32, 128, 32);
		
		// Draw text
		u8g_DrawFrame(&u8g, 0, 0, 128, 64);
		u8g_DrawStr(&u8g, (64 - u8g_GetStrWidth(&u8g, "Length"))/2, 5, "Length");		
		u8g_DrawStr(&u8g, (64 - u8g_GetStrWidth(&u8g, lengthStr))/2, 32+5, lengthStr);
		
		u8g_DrawStr(&u8g, 64+(64 - u8g_GetStrWidth(&u8g, "Total"))/2, 5, "Total");
		u8g_DrawStr(&u8g, 64+(64 - u8g_GetStrWidth(&u8g, totLenTimeStr))/2, 5+15, totLenTimeStr);
		
		u8g_DrawStr(&u8g, 64+(64 - u8g_GetStrWidth(&u8g, "Last len"))/2, 5+32, "Last len");
		//u8g_DrawStr(&u8g, 64+(64 - u8g_GetStrWidth(&u8g, timeToString(lastLengthTime, rS)))/2, 5+32+15, timeToString(lastLengthTime, rS));

	} while (u8g_NextPage(&u8g));
}
Beispiel #6
0
void u8g_setup(void)
{
    /*
      Please uncomment one of the displays below
      Notes:
        - "2x", "4x": high speed version, which uses more RAM
        - "hw_spi": All hardware SPI devices can be used with software SPI also.
    Access type is defined by u8g_com_hw_spi_fn
    */

    // u8g_InitComFn(&u8g, &u8g_dev_uc1701_dogs102_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_uc1701_dogs102_2x_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_uc1701_mini12864_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_uc1701_mini12864_2x_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_st7565_dogm132_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_st7565_dogm128_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_st7565_dogm128_2x_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_st7565_lm6059_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_st7565_lm6059_2x_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_st7565_lm6063_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_st7565_lm6063_2x_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_st7565_nhd_c12864_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_st7565_nhd_c12864_2x_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_st7565_nhd_c12832_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_st7565_64128n_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_st7565_64128n_2x_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_uc1601_c128032_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_uc1601_c128032_2x_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_uc1610_dogxl160_bw_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_uc1610_dogxl160_gr_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_uc1610_dogxl160_2x_bw_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_uc1610_dogxl160_2x_gr_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_pcd8544_84x48_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_pcf8812_96x65_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1325_nhd27oled_bw_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1325_nhd27oled_gr_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1327_96x96_gr_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1327_96x96_2x_gr_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1322_nhd31oled_bw_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1322_nhd31oled_gr_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1322_nhd31oled_2x_gr_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x64_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x64_2x_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1309_128x64_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x32_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x32_2x_hw_spi, u8g_com_hw_spi_fn);
    //u8g_InitComFn(&u8g, &u8g_dev_ssd1351_128x128_332_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1351_128x128_4x_332_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1351_128x128_hicolor_hw_spi, u8g_com_hw_spi_fn);
    // u8g_InitComFn(&u8g, &u8g_dev_ssd1351_128x128_4x_hicolor_hw_spi, u8g_com_hw_spi_fn);

    u8g_InitComFn(&u8g, &u8g_dev_sh1106_128x64_i2c, u8g_com_hw_i2c_fn);
    u8g_SetDefaultForegroundColor(&u8g);

}
Beispiel #7
0
// Lua: u8g.setDefaultForegroundColor( self )
static int lu8g_setDefaultForegroundColor( lua_State *L )
{
    lu8g_userdata_t *lud;

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

    u8g_SetDefaultForegroundColor( LU8G );

    return 0;
}
Beispiel #8
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();
}
Beispiel #9
0
int main(void)
{
    //RCC_ClocksTypeDef Clocks;
    uint8_t pos = 128+64;
     
    SystemInit();
    SystemCoreClockUpdate(); //update the system clock variable
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
    GPIO_Init(GPIOA, &GPIOA_InitStruct);
     
    timercounter = 0;
    //set systick to 1 every 1uS 
    SysTick_Config(SystemCoreClock/8);
    initUSART1();
    GPIO_SetBits(GPIOA, GPIO_Pin_10);
   
    //initialize the watchdog
    
    IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
    IWDG_SetPrescaler(0x00);
    //while(IWDG_GetFlagStatus(IWDG_FLAG_PVU)==SET);
    IWDG_SetReload(0xFFFF);
    //while(IWDG_GetFlagStatus(IWDG_FLAG_RVU)==SET);
    //IWDG_SetWindowValue(0x0000);
    //while(IWDG_GetFlagStatus(IWDG_FLAG_PVU)==SET);
    IWDG_ReloadCounter();
    IWDG_Enable();

    static BitAction toggle = Bit_SET;
    
    int i =0;
   
    //init the u8g library
    u8g_InitComFn(&u8g,  &u8g_dev_ssd1306_128x64_i2c, u8g_com_hw_i2c_fn);
    u8g_SetDefaultForegroundColor(&u8g);
           
    while(1){
        u8g_FirstPage(&u8g);
        do
        {
          IWDG_ReloadCounter();
          draw(pos);
        } while ( u8g_NextPage(&u8g) );
         
         /* refresh screen after some delay */
         ///* update position */
        if(pos < 128+128){  
            pos--;
        }else
        { pos = 128+128;
        }
    }
}
Beispiel #10
0
void showChargingScreen(void){
	char vccChar[10];
	my_itoa(vcc, vccChar, 10);
	
	u8g_FirstPage(&u8g);
	u8g_SetDefaultForegroundColor(&u8g);
	do {
		u8g_DrawFrame(&u8g, 0, 0, 128, 64);
		
		// Show the first length
		u8g_DrawStr(&u8g, (124 - u8g_GetStrWidth(&u8g, "Charging"))/2, 5, "Charging");
		u8g_DrawStr(&u8g, 60, 20, vccChar);
	} while (u8g_NextPage(&u8g));
}
Beispiel #11
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;
}
Beispiel #12
0
void display_init(void)
{
  /* select minimal prescaler (max system speed) */
  CLKPR = 0xFF;
                                                           // SCK    MOSI      CS       D/C
   u8g_InitSPI(&u8g, &u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi, PN(5, 6), PN(5, 5), PN(4, 7),PN(5,7), PN(4,6));
   u8g_SetRot180(&u8g);

   /* assign default color value */
   u8g_SetColorIndex(&u8g, 3);         /* max intensity */
 //  u8g_SetColorIndex(&u8g, 1);         /* pixel on */

  u8g_SetFont(&u8g, u8g_font_profont11);
  u8g_SetFontRefHeightExtendedText(&u8g);
  u8g_SetDefaultForegroundColor(&u8g);
  u8g_SetFontPosTop(&u8g);


}
Beispiel #13
0
void showLength(void){
	uint8_t curTime = EEReadByte(5+history.showLength);
	
	char lengthStr[4], timeStr[9];
	itoa(history.showLength+1, lengthStr, 10);
	timeToString(curTime, timeStr);
	
	u8g_FirstPage(&u8g);
	u8g_SetDefaultForegroundColor(&u8g);
	do {
		u8g_DrawFrame(&u8g, 0, 0, 128, 64);
		u8g_DrawLine(&u8g, 64, 0, 64, 64);
		
		u8g_DrawStr(&u8g, (64 - u8g_GetStrWidth(&u8g, "Length"))/2, 5, "Length");
		u8g_DrawStr(&u8g, (64 - u8g_GetStrWidth(&u8g, lengthStr))/2, 5+20, lengthStr);
		
		u8g_DrawStr(&u8g, 64+(64 - u8g_GetStrWidth(&u8g, "Time"))/2, 5, "Time");
		u8g_DrawStr(&u8g, 64+(64 - u8g_GetStrWidth(&u8g, timeStr))/2, 5+20, timeStr);
		
	} while (u8g_NextPage(&u8g));
}
Beispiel #14
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;
}
Beispiel #15
0
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]);
    }
}
Beispiel #16
0
void main()
{
  uint8_t pos = 0;
  /*
    Please uncomment one of the displays below
    Notes:
      - "2x", "4x": high speed version, which uses more RAM
      - "hw_spi": All hardware SPI devices can be used with software SPI also.
	Access type is defined by u8g_com_hw_spi_fn
  */

  // u8g_InitComFn(&u8g, &u8g_dev_uc1701_dogs102_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_uc1701_dogs102_2x_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_uc1701_mini12864_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_uc1701_mini12864_2x_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_st7565_dogm132_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_st7565_dogm128_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_st7565_dogm128_2x_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_st7565_lm6059_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_st7565_lm6059_2x_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_st7565_lm6063_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_st7565_lm6063_2x_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_st7565_nhd_c12864_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_st7565_nhd_c12864_2x_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_st7565_nhd_c12832_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_st7565_64128n_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_st7565_64128n_2x_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_uc1601_c128032_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_uc1601_c128032_2x_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_uc1610_dogxl160_bw_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_uc1610_dogxl160_gr_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_uc1610_dogxl160_2x_bw_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_uc1610_dogxl160_2x_gr_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_pcd8544_84x48_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_pcf8812_96x65_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1325_nhd27oled_bw_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1325_nhd27oled_gr_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1327_96x96_gr_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1327_96x96_2x_gr_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1322_nhd31oled_bw_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1322_nhd31oled_gr_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1322_nhd31oled_2x_gr_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x64_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x64_2x_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1309_128x64_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x32_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x32_2x_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1351_128x128_332_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1351_128x128_4x_332_hw_spi, u8g_com_hw_spi_fn);
   u8g_InitComFn(&u8g, &u8g_dev_ssd1351_128x128_hicolor_hw_spi, u8g_com_hw_spi_fn);
  // u8g_InitComFn(&u8g, &u8g_dev_ssd1351_128x128_4x_hicolor_hw_spi, u8g_com_hw_spi_fn);
  
  
  u8g_SetDefaultForegroundColor(&u8g);

  for(;;)
  {
    /* picture loop */
    u8g_FirstPage(&u8g);
    do
    {
      draw(pos);
    } while ( u8g_NextPage(&u8g) );
    
    /* refresh screen after some delay */
    u8g_Delay(100);
    
    /* update position */
    pos++;
    pos &= 15;
  }  
}
Beispiel #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);
}
Beispiel #18
0
void u8g_prepare(void) {
    u8g_SetFont(&u8g, u8g_font_6x10);
    u8g_SetFontRefHeightExtendedText(&u8g);
    u8g_SetDefaultForegroundColor(&u8g);
    u8g_SetFontPosTop(&u8g);
}
Beispiel #19
0
/*******************************************************************************
 * Отрисовка и обрадотка команд секундомера
 ******************************************************************************/
void stopwatch(mtk_t * mtk) {
	uint8_t i, x, y;
	uint32_t count;
	char sTemp[11];
	count = sWatch.dsH[sWatch.nums];
	if (mtk->command) {
		switch (mtk->command) {
		case COMMAND_NEXT: {
			if (!sWatch.nums) {
				state.taskList |= TASK_STOPWATCH;//Для отображения на главном экране
				SysTick_task_add(stopwatchTick, 100); //Задача считать время
				sWatch.nums = 1;
				sWatch.select = 1;
				sWatch.dsH[sWatch.nums] = 0;
			} else {
				if (!SysTick_task_check(stopwatchTick)
						&& sWatch.nums == sWatch.select) {
					SysTick_task_add(stopwatchTick, 100);
					state.taskList |= TASK_STOPWATCH;
				} else if (sWatch.select < 9) {
					sWatch.select++;
					if (sWatch.select > sWatch.nums) {
						sWatch.dsH[sWatch.nums + 1] = sWatch.dsH[sWatch.nums];
						sWatch.nums++;
					}
				}
			}
			mtk->command = COMMAND_NULL;
		}
			break;
		case COMMAND_PREV:
			if (sWatch.select > 1) {
				sWatch.select--;
				mtk->command = COMMAND_NULL;
			}
			break;
		case COMMAND_UP: {
			if (sWatch.nums) {
				if (SysTick_task_check(stopwatchTick)) {
					SysTick_task_del(stopwatchTick);
				} else {
					SysTick_task_add(stopwatchTick, 100);
					sWatch.select = sWatch.nums;
				}
				state.taskList ^= TASK_STOPWATCH;
			}
			mtk->command = COMMAND_NULL;
		}
			break;
		case COMMAND_DOWN: {
			SysTick_task_del(stopwatchTick);
			sWatch.nums = 0;
			sWatch.select = 0;
			state.taskList |= TASK_REDRAW;
			state.taskList &= ~ TASK_STOPWATCH;
			mtk->command = COMMAND_NULL;
		}
			break;
		}
	} else {
		u8g_DrawLine(mtk->u8g, 0, 38, 239, 38);

		x = 8, y = 35;
		for (i = 0; i < sWatch.nums; i++) {
			sprintf(sTemp, "%d", i + 1);
			if (sWatch.select == i + 1) {
				u8g_DrawRBox(mtk->u8g, x - 4, y - 16, 18, 18, 3);
				u8g_SetDefaultBackgroundColor(mtk->u8g);
				u8g_DrawStr(mtk->u8g, x, y, sTemp);
				u8g_SetDefaultForegroundColor(mtk->u8g);
			} else
				u8g_DrawStr(mtk->u8g, x, y, sTemp);
			x += 18;
		}
		if (state.taskList & TASK_STOPWATCH)
			u8g_DrawStr(mtk->u8g, 190, y, "RUN");
		else if (!sWatch.nums)
			u8g_DrawStr(mtk->u8g, 188, y, "STOP");
		else
			u8g_DrawStr(mtk->u8g, 180, y, "PAUSE");
		y = 57;
		if (sWatch.select > 1) {
			y -= 6;
			u8g_DrawLine(mtk->u8g, 0, 105, 239, 105);
		}
//Отрисовка верхнего счетчика интервалов.
		count = sWatch.dsH[sWatch.select] - sWatch.dsH[sWatch.select - 1];
		u8g_SetFont(mtk->u8g, u8g_font_elpaulo32n);
		u8g_SetScale2x2(mtk->u8g);
		sprintf(sTemp, "%02d:%02d", (count / 600) % 60, (count / 10) % 60);
		u8g_DrawStr(mtk->u8g, 0, y, sTemp);
		u8g_UndoScale(mtk->u8g);
		sprintf(sTemp, ".%01d", count % 10);
		u8g_DrawStr(mtk->u8g, 205, y * 2, sTemp);
	}
//Отрисовка нижнего/полного счета.
	if (sWatch.select > 1) {
		count = sWatch.dsH[sWatch.select];
		sprintf(sTemp, "%01d:%02d:%02d:%01d", (count / 36000),
				((count / 600) % 60), ((count / 10) % 60), (count % 10));
		if(count/360000)
			x = 43;
		else
			x = 67;
		u8g_DrawStr(mtk->u8g, x, 138, sTemp);
		u8g_SetFont(mtk->u8g, u8g_font_elpaulo20);
		u8g_DrawStr(mtk->u8g, 3, 138, "Total:");
	}
	/* Нарисуем подскуазку*/
	u8g_SetFont(mtk->u8g, u8g_font_elpaulo20);
	x = 0, y = 158;
	u8g_DrawStr(mtk->u8g, x, y, "\x0AStart");
	u8g_DrawStr(mtk->u8g, x + 80, y, "\x0CPause");
	u8g_DrawStr(mtk->u8g, x + 160, y, "\x0DReset");
	u8g_DrawLine(mtk->u8g, 0, 140, 239, 140);
	x = 75;
	for (i = 0; i < 2; i++) {
		u8g_DrawLine(mtk->u8g, x, 141, x, 159);
		x += 80;
	}
}