コード例 #1
0
ファイル: u8g.c プロジェクト: rudg/nodemcu-firmware
// Lua: u8g.drawRBox( self, x, y, width, height, radius )
static int lu8g_drawRBox( lua_State *L )
{
    lu8g_userdata_t *lud;

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

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

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

    return 0;
}
コード例 #2
0
ファイル: utils.c プロジェクト: Baradablr/ElPaulo
/*******************************************************************************
 * Отрисовка и обрадотка команд секундомера
 ******************************************************************************/
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;
	}
}