コード例 #1
0
ファイル: board.c プロジェクト: dforsyth/u-boot-imx
static int board_video_init(void)
{
	conf_disp_pll(24, 1);
	if (factory_dat.pxm50)
		da8xx_video_init(&lcd_panels[0], &lcd_cfg, lcd_cfg.bpp);
	else
		da8xx_video_init(&lcd_panels[1], &lcd_cfg, lcd_cfg.bpp);

	enable_pwm();
	enable_backlight();

	return 0;
}
コード例 #2
0
ファイル: main.c プロジェクト: laszuba/binary_watch
void state_machine() {
	// Spend most of the time in sleep
	switch (current_state) {
		// LEDs off, waiting for button presses
		case SLEEPING:
			next_state = SLEEPING;
			disp_time(DISABLE);

			//TODO: Go back to sleep
			sleep_proc();
			break;

		case IDLE:
			next_state = IDLE;

			if (timeout_ticks > _LED_TIMEOUT_TICKS) {
				next_state = SLEEPING;
			}

			if (SET || MODE) next_state = WAKE;

			break;

		// LEDs on, waiting for timeout
		case WAKE:
			next_state = WAKE;
			enable_pwm();
			disp_on();

			if (!SET && !MODE) {
				next_state = IDLE;
			}

			if ((debouncer_test(SET_BTN) == LONG_PRESSED) &&
			    (debouncer_test(MODE_BTN) == LONG_PRESSED)) {
				next_state = READY_TO_SET_HOURS;
			}
			break;

		case READY_TO_SET_HOURS:
			next_state = READY_TO_SET_HOURS;
			last_set_state = FALSE;

			flash_mins();
			flash_hours();

			if (!MODE && !SET) next_state = SET_HOURS;

			break;

		// Time set mode, pressing set will increment hours up to 24, then
		// roll over, pressing mode will switch to minute set mode
		case SET_HOURS:
			next_state = SET_HOURS;

			flash_mins();

			if (debouncer_test(MODE_BTN) == DEBOUNCED) {
				next_state = READY_TO_SET_MINS;
			}

			if (debouncer_test(SET_BTN) == DEBOUNCED) {
				last_set_state = TRUE;
			}
			else if (debouncer_test(SET_BTN) == LONG_PRESSED) {
				next_state = QUICK_HOURS_INC;
			}

			if ((last_set_state == TRUE) && !SET) {
				last_set_state = FALSE;
				++my_time.hours;
			}
			break;

		case QUICK_HOURS_INC:
			next_state = QUICK_HOURS_INC;

			flash_mins();

			if (!SET) next_state = SET_HOURS;

			if (quick_inc) {
				quick_inc = FALSE;
				++my_time.hours;
			}

			break;

		case READY_TO_SET_MINS:
			next_state = READY_TO_SET_MINS;
			last_set_state = FALSE;

			flash_mins();
			flash_hours();

			if (!MODE) next_state = SET_MINS;

			break;

		// Time set mode, pressing set will increment minutes up to 59, then
		// roll over, pressing mode will exit time set mode
		case SET_MINS:
			next_state = SET_MINS;

			flash_hours();

			if (debouncer_test(MODE_BTN) == DEBOUNCED) {
				next_state = WAKE;
			}

			if (debouncer_test(SET_BTN) == DEBOUNCED) {
				last_set_state = TRUE;
			}
			else if (debouncer_test(SET_BTN) == LONG_PRESSED) {
				next_state = QUICK_MINS_INC;
			}

			if ((last_set_state == TRUE) && !SET) {
				last_set_state = FALSE;
				++my_time.mins;
			}
			break;

		case QUICK_MINS_INC:
			next_state = QUICK_MINS_INC;

			flash_hours();

			if (!SET) next_state = SET_MINS;

			if (quick_inc) {
				quick_inc = FALSE;
				++my_time.mins;
			}

			break;
		default:
			next_state = IDLE;
			break;
	}

	if (current_state != SLEEPING) {
		test_buttons();
	}

	if (next_state != current_state) {
		current_state = next_state;
	}
}