Пример #1
0
void gui_value_time_irqh(uint8_t type, uint8_t * buff)
{
	int16_t inc = 0;

	switch (type)
	{
	case(TASK_IRQ_BUTTON_L):
		if (*buff == BE_CLICK)
			inc += -gui_value_step;
		if (*buff == BE_DBL_CLICK)
			inc += -gui_value_step;
	break;

	case(TASK_IRQ_BUTTON_R):
		if (*buff == BE_CLICK)
			inc += +gui_value_step;
		if (*buff == BE_DBL_CLICK)
			inc += +gui_value_step;
	break;

	case(TASK_IRQ_BUTTON_M):
		if (*buff == BE_CLICK)
		{
			if (gui_value_index == 2)
				gui_value_cb(gui_value_tmp);
			else
				gui_value_index++;
		}
	break;
	}

	switch (gui_value_index)
	{
		case(0):
			time_set_actual(time_get_actual() + (60 * 60) * inc);
		break;
		case(1):
			time_set_actual(time_get_actual() + (60) * inc);
		break;
		case(2):
			time_set_actual(time_get_actual() + inc);
		break;
	}
}
Пример #2
0
void fc_sync_gps_time()
{
	time_set_actual(fc.gps_data.utc_time + (fc.time_zone * 3600ul) / 2);
	gui_showmessage_P(PSTR("GPS Time set"));
}
Пример #3
0
void gui_value_date_irqh(uint8_t type, uint8_t * buff)
{
	int16_t inc = 0;

	switch (type)
	{
	case(TASK_IRQ_BUTTON_L):
		if (*buff == BE_CLICK)
			inc += -gui_value_step;
//		if (*buff == BE_DBL_CLICK)
//			inc += -gui_value_step;
	break;

	case(TASK_IRQ_BUTTON_R):
		if (*buff == BE_CLICK)
			inc += +gui_value_step;
//		if (*buff == BE_DBL_CLICK)
//			inc += +gui_value_step;
	break;

	case(TASK_IRQ_BUTTON_M):
		if (*buff == BE_CLICK)
		{
			if (gui_value_index == 2)
				gui_value_cb(gui_value_tmp);
			else
				gui_value_index++;
		}
	break;
	}

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

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

	switch (gui_value_index)
	{
		case(0):
			day += inc;
			if (day < 1)
				day = monthDays[month - 1];

			if ((((!(year % 4)) && (year % 100) ) || (!(year % 400))) && month == 2)
			{
				if (day > 29)
					day = 29;
			}
			else
			{
				if (day > monthDays[month - 1])
					day = monthDays[month - 1];
			}
		break;

		case(1):
			month += inc;
			if (month < 1)
				month = 1;
			if (month > 12)
				month = 12;
		break;

		case(2):
			year += inc;
			if (year < 2015)
				year = 2015;
			if (year > 2100)
				year = 2100;
		break;
	}

	uint32_t diff = 0;

	//do not change flight time during update
	if (fc.flight_state == FLIGHT_FLIGHT)
		diff = time_get_actual() - fc.flight_timer;

	time_set_actual(datetime_to_epoch(sec, min, hour, day, month, year));

	//do not change flight time during update
	if (fc.flight_state == FLIGHT_FLIGHT)
		fc.flight_timer = time_get_actual() - diff;
}