示例#1
0
void gui_gyro_calib_loop()
{
	uint8_t value;
	char tmp[20];

	gui_dialog_P(PSTR("Gyroscope"));
	disp.LoadFont(F_TEXT_M);
	uint8_t h_t = disp.GetTextHeight();

	if(gui_gyro_calib.wait_cnt < WAIT_TIME)
	{
		//print message
		strcpy_P(tmp, PSTR("Keep device calm!"));
		gui_caligh_text(tmp, GUI_DISP_WIDTH / 2, GUI_DIALOG_TOP + 1 );
		gui_gyro_calib.wait_cnt += 1;
		return;
	}
	else if(gui_gyro_calib.wait_cnt <= (WAIT_TIME + N_OF_SAMPLES))
	{
		strcpy_P(tmp, PSTR("Calibrating ..."));
		gui_caligh_text(tmp, GUI_DISP_WIDTH / 2, GUI_DIALOG_TOP + 1 );

		gui_gyro_calib.bias.x += (float) fc.gyro.raw.x;
		gui_gyro_calib.bias.y += (float) fc.gyro.raw.y;
		gui_gyro_calib.bias.z += (float) fc.gyro.raw.z;
		gui_gyro_calib.wait_cnt += 1;
	}
	else if(gui_gyro_calib.wait_cnt == (WAIT_TIME + N_OF_SAMPLES + 1))
	{
		gui_gyro_calib.bias.x /= (float) N_OF_SAMPLES;
		gui_gyro_calib.bias.y /= (float) N_OF_SAMPLES;
		gui_gyro_calib.bias.z /= (float) N_OF_SAMPLES;
		gui_gyro_calib.wait_cnt += 1;
	}

	//draw frame
	disp.DrawRectangle(BAR_X1_POS , GUI_DIALOG_TOP + 1 + h_t, BAR_X2_POS, GUI_DIALOG_TOP + 1 + h_t + BAR_HEIGHT, 1, 0);

	//draw bar
	value = uint8_t( BAR_MAX_LENGHT * ( float( gui_gyro_calib.wait_cnt - WAIT_TIME ) / N_OF_SAMPLES ) + 1.5);
	disp.DrawRectangle(BAR_X1_POS , GUI_DIALOG_TOP + 2 + h_t , BAR_X1_POS + value, GUI_DIALOG_TOP + h_t + BAR_HEIGHT, 1, 1);



	//menu
	disp.LoadFont(F_TEXT_S);
	gui_raligh_text_P(PSTR("back"), GUI_DISP_WIDTH - 2, GUI_DIALOG_BOTTOM - 4);

	if(gui_gyro_calib.wait_cnt == (WAIT_TIME + N_OF_SAMPLES + 2))
	{	//if complete

		//add menu option
		gui_caligh_text_P(PSTR("save"), GUI_DISP_WIDTH / 2, GUI_DIALOG_BOTTOM - 4);

		//print message
		disp.LoadFont(F_TEXT_M);
		strcpy_P(tmp, PSTR("Done!"));
		gui_caligh_text(tmp, GUI_DISP_WIDTH / 2, GUI_DIALOG_TOP +1 );
	}
}
示例#2
0
void gui_set_layout_loop()
{
	uint8_t widget_cnt = layout_get_number_of_widgets(set_layout_type);

	for(uint8_t i = 0; i < widget_cnt; i++)
	{
		uint8_t x, y, w, h;
		layout_get_widget_rect(set_layout_type, i, &x, &y, &w, &h);

		disp.DrawRectangle(x, y, x + w - 2, y + h - 2, 1, 0);
		disp.LoadFont(F_VALUES_M);
		char tmp[2];
		sprintf_P(tmp, PSTR("%i"), i + 1);
		uint8_t t_h = disp.GetTextHeight();
		gui_caligh_text(tmp, x + w / 2, y + h / 2 - t_h / 2);
	}


}
示例#3
0
void gui_value_loop()
{
	char tmp[20];
	uint8_t f_h;

	uint8_t sec;
	uint8_t min;
	uint8_t hour;
	uint8_t day;
	uint8_t wday;
	uint8_t month;
	uint16_t year;



	gui_dialog(gui_value_label);
	disp.LoadFont(F_TEXT_L);
	f_h = disp.GetTextHeight();

	switch(gui_value_type)
	{
		case(GUI_VAL_NUMBER):
			sprintf(tmp, gui_value_format, gui_value_tmp);
			gui_caligh_text(tmp, GUI_DISP_WIDTH / 2, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 - f_h / 2);
		break;

		case(GUI_VAL_NUMBER_DISABLE):
			if (gui_value_tmp > 0)
				sprintf(tmp, gui_value_format, gui_value_tmp);
			else
				strcpy_P(tmp, PSTR("disabled"));
			gui_caligh_text(tmp, GUI_DISP_WIDTH / 2, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 - f_h / 2);
		break;

		case(GUI_VAL_VARIO_TEST):
			sprintf(tmp, gui_value_format, gui_value_tmp);
			gui_raligh_text(tmp, GUI_DIALOG_RIGHT - 2, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 - f_h / 2);
			disp.LoadFont(F_TEXT_S);
			f_h = disp.GetTextHeight();
			disp.GotoXY(GUI_DIALOG_LEFT + 1, GUI_DIALOG_TOP + 2);
			fprintf(lcd_out, "f=%0.0f", audio_vario_freq);
			disp.GotoXY(GUI_DIALOG_LEFT + 1, GUI_DIALOG_TOP + 4 + f_h);
			fprintf(lcd_out, "l=%4u", audio_vario_length / 31);
			disp.GotoXY(GUI_DIALOG_LEFT + 1, GUI_DIALOG_TOP + 6 + f_h * 2);
			fprintf(lcd_out, "p=%4u", audio_vario_pause / 31);
		break;



		case(GUI_VAL_TIME):
			time_from_epoch(time_get_actual(), &sec, &min, &hour);

			sprintf_P(tmp, PSTR("%02d : %02d . %02d"), hour, min, sec);
			gui_caligh_text(tmp, GUI_DISP_WIDTH / 2, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 - f_h / 2);
			if (gui_value_index == 0)
				disp.Invert(18, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 - f_h / 2, 32, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 + f_h / 2 - 2);
			if (gui_value_index == 1)
				disp.Invert(36, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 - f_h / 2, 50, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 + f_h / 2 - 2);
			if (gui_value_index == 2)
				disp.Invert(54, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 - f_h / 2, 68, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 + f_h / 2 - 2);
		break;

		case(GUI_VAL_DATE):
			datetime_from_epoch(time_get_actual(), &sec, &min, &hour, &day, &wday, &month, &year);

			sprintf_P(tmp, PSTR("%02d / %02d / %04d"), day, month, year);
			gui_caligh_text(tmp, GUI_DISP_WIDTH / 2, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 - f_h / 2);
			if (gui_value_index == 0)
				disp.Invert(10, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 - f_h / 2, 24, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 + f_h / 2 - 2);
			if (gui_value_index == 1)
				disp.Invert(30, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 - f_h / 2, 44, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 + f_h / 2 - 2);
			if (gui_value_index == 2)
				disp.Invert(50, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 - f_h / 2, 76, GUI_DIALOG_TOP + (GUI_DIALOG_BOTTOM - GUI_DIALOG_TOP) / 2 + f_h / 2 - 2);
		break;

		case(GUI_VAL_CONTRAST):
			gui_value_draw_bar();
		break;

		case(GUI_VAL_BRIGTHNES):
			gui_value_draw_bar();
		break;

		case(GUI_VAL_VOLUME):
			gui_value_draw_bar();
		break;
	}

	if (button_hold(B_LEFT))
	{
		uint8_t t_param = BE_CLICK;
		gui_value_irqh(TASK_IRQ_BUTTON_L, &t_param);
	}

	if (button_hold(B_RIGHT))
	{
		uint8_t t_param = BE_CLICK;
		gui_value_irqh(TASK_IRQ_BUTTON_R, &t_param);
	}
}
示例#4
0
void gui_factory_test_loop()
{
	gui_dialog_P(PSTR("Factory test"));

	bool blik = GUI_BLINK_TGL(1000);
	bool res;
	bool err = false;

	if (f_test_lcd)
	{
		char tmp[16];

		disp.LoadFont(F_TEXT_L);
		switch (f_test_lcd)
		{
			case(FTEST_LCD_MIN_AUTO):
				strcpy_P(tmp, PSTR("Min auto"));
			break;
			case(FTEST_LCD_MIN):
				strcpy_P(tmp, PSTR("Set minimum"));
			break;
			case(FTEST_LCD_MAX_AUTO):
				strcpy_P(tmp, PSTR("Max auto"));
			break;
			case(FTEST_LCD_MAX):
				strcpy_P(tmp, PSTR("Set maximum"));
			break;
			case(FTEST_LCD_MID):
				strcpy_P(tmp, PSTR("Set optimal"));
			break;
		}
		gui_caligh_text(tmp, GUI_DISP_WIDTH / 2, GUI_DIALOG_TOP);

		disp.DrawLine(4, 24, 14, 24, 1);
		disp.DrawLine(4, 26, 14, 26, 1);
		disp.DrawLine(4, 28, 14, 28, 1);
		disp.DrawLine(4, 30, 14, 30, 1);
		disp.DrawLine(4, 32, 14, 32, 1);

		disp.DrawLine(16, 24, 16, 32, 1);
		disp.DrawLine(18, 24, 18, 32, 1);
		disp.DrawLine(20, 24, 20, 32, 1);
		disp.DrawLine(22, 24, 22, 32, 1);
		disp.DrawLine(24, 24, 24, 32, 1);

		disp.DrawRectangle(26, 24, 35, 33, 1, 1);

		disp.DrawRectangle(37, 24, 46, 33, 1, 0);

		disp.DrawRectangle(48, 24, 57, 33, 1, 0);
		disp.DrawRectangle(50, 26, 55, 31, 1, 0);
		disp.DrawRectangle(52, 28, 53, 29, 1, 0);

		disp.DrawCircle(71, 35, 1, 1);
		disp.DrawCircle(71, 35, 3, 1);
		disp.DrawCircle(71, 35, 5, 1);
		disp.DrawCircle(71, 35, 7, 1);
		disp.DrawCircle(71, 35, 9, 1);

		disp.LoadFont(F_TEXT_M);
		disp.GotoXY(4, 36);
		fprintf_P(lcd_out, PSTR("%03d"), f_test_lcd_cont_min);
		disp.GotoXY(24, 36);
		fprintf_P(lcd_out, PSTR("%03d"), f_test_lcd_cont);
		disp.GotoXY(44, 36);
		fprintf_P(lcd_out, PSTR("%03d"), f_test_lcd_cont_max);

		if (f_test_lcd == FTEST_LCD_MIN_AUTO || f_test_lcd == FTEST_LCD_MAX_AUTO)
		{
			f_test_lcd_cont = (f_test_lcd_cont + 1) % 128;
		}

		led_set(0, f_test_lcd_cont / 4, 0);

		if (f_test_lcd == FTEST_LCD_MID)
			disp.SetContrast(lcd_contrast_min + ((lcd_contrast_max - lcd_contrast_min) * f_test_lcd_cont) / GUI_CONTRAST_STEPS);
		else
			disp.SetContrast(f_test_lcd_cont);

		return;
	}

	//store contrast values
	eeprom_busy_wait();
	eeprom_update_byte(&config_ro.lcd_contrast_max, f_test_lcd_cont_max);
	eeprom_update_byte(&config_ro.lcd_contrast_min, f_test_lcd_cont_min);
	eeprom_update_byte(&config_ee.gui.contrast, f_test_lcd_cont);
	eeprom_busy_wait();

	//reload contrast value
	gui_load_eeprom();

	disp.LoadFont(F_TEXT_S);
	uint8_t f_h = disp.GetTextHeight();

	if (!mems_i2c_selftest())
	{
		if (blik)
		{
			disp.GotoXY(4, f_h * 3.5 + 3);
			fprintf_P(lcd_out, PSTR("I2C ERROR"));
			assert(0);
		}
		err = true;
	}
	else
	{
		res = ms5611.SelfTest();
		if (!res) err = true;
		if (res || blik)
		{
			disp.GotoXY(4, f_h * 2 + 3);
			fprintf_P(lcd_out, PSTR("MS5611:%s"), (res) ? "OK" : "ERR");
			assert(res);
		}

		res = lsm303d.SelfTest();
		if (!res) err = true;
		if (res || blik)
		{
			disp.GotoXY(4, f_h * 3 + 3);
			fprintf_P(lcd_out, PSTR("LSM303:%s"), (res) ? "OK" : "ERR");
			assert(res);
		}

		res = l3gd20.SelfTest();
		if (!res) err = true;
		if (res || blik)
		{
			disp.GotoXY(4, f_h * 4 + 3);
			fprintf_P(lcd_out, PSTR("L3GD20:%s"), (res) ? "OK" : "ERR");
			assert(res);
		}

		res = sht21.SelfTest();
		if (!res) err = true;
		if (res || blik)
		{
			disp.GotoXY(4, f_h * 5 + 3);
			fprintf_P(lcd_out, PSTR("SHT21:%s"), (res) ? "OK" : "ERR");
			assert(res);
		}
	}

	res = bt_ready();
	if (!res) err = true;
	if (res || blik)
	{
		assert(res);
		disp.GotoXY(4, f_h * 6 + 3);
		if (!res)
		{
			fprintf_P(lcd_out, PSTR("BT:ERR"));
		}
		else
		{
			if (bt_get_module_type() == BT_PAN1322)
				fprintf_P(lcd_out, PSTR("BT:1322"));
			else
				fprintf_P(lcd_out, PSTR("BT:1026"));
		}
	}

	res = storage_ready();
	if (!res) err = true;
	if (res || blik)
	{
		disp.GotoXY(GUI_DISP_WIDTH / 2, f_h * 2 + 3);
		fprintf_P(lcd_out, PSTR("SD:%s"), (res) ? "OK" : "ERR");
		assert(res);
	}

	res = gps_selftest();
	if (!res) err = true;
	if (res || blik)
	{
		disp.GotoXY(GUI_DISP_WIDTH / 2, f_h * 3 + 3);
		fprintf_P(lcd_out, PSTR("GPS:%s"), (res) ? "OK" : "ERR");
		assert(res);
	}

	res = f_test_button_test == 0b00000111;
	if (!res) err = true;
	if (res || blik)
	{
		disp.GotoXY(GUI_DISP_WIDTH / 2, f_h * 4 + 3);
		fprintf_P(lcd_out, PSTR("BUT:%d %d %d"), f_test_button_test & (1 << 0), (f_test_button_test & (1 << 1)) >> 1, (f_test_button_test & (1 << 2)) >> 2);
		assert(res);
	}