Пример #1
0
void u8g_line(uint8_t a) {
    u8g_DrawStr(&u8g, 0, 0, "drawLine");
    u8g_DrawLine(&u8g, 7+a, 10, 40, 55);
    u8g_DrawLine(&u8g, 7+a*2, 10, 60, 55);
    u8g_DrawLine(&u8g, 7+a*3, 10, 80, 55);
    u8g_DrawLine(&u8g, 7+a*4, 10, 100, 55);
}
Пример #2
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));
}
Пример #3
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);
}
Пример #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));
}
Пример #5
0
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;
	}
}
Пример #6
0
// Lua: u8g.drawLine( self, x1, y1, x2, y2 )
static int lu8g_drawLine( 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_DrawLine( LU8G, args[0], args[1], args[2], args[3] );

    return 0;
}
Пример #7
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));
}
Пример #8
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;
}
Пример #9
0
void u8g_drawArrow(uint8_t size, uint8_t pos_x, uint8_t pos_y, uint8_t dir)
{
    uint8_t arrowlines_angle_pc = 2; //PC PerCent, logisch nicht korrekt, aber ok

    if(size > 10)
        arrowlines_angle_pc = 3;

    switch(dir)
    {
    case 1:	//NORTH
        u8g_DrawLine(&u8g, pos_x+(size/2), pos_y, pos_x-(size/2), pos_y);
        u8g_DrawLine(&u8g, pos_x+(size/2), pos_y, pos_x, pos_y-(size/arrowlines_angle_pc));  // -
        u8g_DrawLine(&u8g, pos_x+(size/2), pos_y, pos_x, pos_y+(size/arrowlines_angle_pc));  // -
        break;
    case 2:	//EAST
        u8g_DrawLine(&u8g, pos_x, pos_y+(size/2), pos_x, pos_y-(size/2));
        u8g_DrawLine(&u8g, pos_x, pos_y+(size/2), pos_x-(size/arrowlines_angle_pc),pos_y);  // /
        u8g_DrawLine(&u8g, pos_x, pos_y+(size/2), pos_x+(size/arrowlines_angle_pc), pos_y); //  \ //
        break;
    case 3:	//SOUTH
        u8g_DrawLine(&u8g, pos_x-(size/2), pos_y, pos_x+(size/2), pos_y); // –
        u8g_DrawLine(&u8g, pos_x-(size/2), pos_y, pos_x, pos_y-(size/arrowlines_angle_pc));  // -
        u8g_DrawLine(&u8g, pos_x-(size/2), pos_y, pos_x, pos_y+(size/arrowlines_angle_pc));  // -
        break;
    case 4:	//WEST
        u8g_DrawLine(&u8g, pos_x, pos_y-(size/2), pos_x, pos_y+(size/2)); // |
        u8g_DrawLine(&u8g, pos_x, pos_y-(size/2), pos_x-(size/arrowlines_angle_pc),pos_y);  // /
        u8g_DrawLine(&u8g, pos_x, pos_y-(size/2), pos_x+(size/arrowlines_angle_pc), pos_y); //  \ //
        break;
    default:
        u8g_DrawStr(&u8g, pos_x-(size/2), pos_y, "ERROR");
        break;
    }
}
Пример #10
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;
	}
}