Exemplo n.º 1
0
void fc_sync_gps_time()
{
    if (time_get_local() == (fc.gps_data.utc_time + config.system.time_zone * 1800ul))
        return;

    DEBUG("Syncing time\n");
    DEBUG(" local    %lu\n", time_get_local());
    DEBUG(" gps + tz %lu\n", fc.gps_data.utc_time + config.system.time_zone * 1800ul);

    time_set_utc(fc.gps_data.utc_time);

    gui_showmessage_P(PSTR("GPS Time set"));

    time_set_flags();
}
Exemplo n.º 2
0
void logger_next_flight()
{
	uint8_t sec, min, hour, day, wday, month;
	uint16_t year;
	uint32_t today;


	datetime_from_epoch(time_get_local(), &sec, &min, &hour, &day, &wday, &month, &year);
	today = datetime_to_epoch(0, 0, 0, day, month, year);
	
	if (today == logger_flight_day)
	{
		logger_flight_number++;

		eeprom_busy_wait();
		eeprom_update_byte(&config_ro.flight_number, logger_flight_number);
	}
	else
	{
		logger_flight_number = 0;
		logger_flight_day = today;

		eeprom_busy_wait();
		eeprom_update_block((void *)&logger_flight_day, &config_ro.flight_date, sizeof(logger_flight_day));
		eeprom_update_byte(&config_ro.flight_number, logger_flight_number);
	}

	DEBUG("date is: ");
	print_datetime(today);
	DEBUG("flight number is: %d\n", logger_flight_number);
}
Exemplo n.º 3
0
void logger_init()
{
	log_fil = new FIL;
	fc.logger_state = LOGGER_IDLE;

	uint8_t sec, min, hour, day, wday, month;
	uint16_t year;
	uint32_t today;


	datetime_from_epoch(time_get_local(), &sec, &min, &hour, &day, &wday, &month, &year);
	today = datetime_to_epoch(0, 0, 0, day, month, year);

	eeprom_busy_wait();
	eeprom_read_block((void *)&logger_flight_day, &config_ro.flight_date, sizeof(logger_flight_day));
	logger_flight_number = eeprom_read_byte(&config_ro.flight_number);

	if (logger_flight_day != today)
	{
		logger_flight_number = 0;
		logger_flight_day = today;

		eeprom_busy_wait();
		eeprom_update_block((void *)&logger_flight_day, &config_ro.flight_date, sizeof(logger_flight_day));
		eeprom_update_byte(&config_ro.flight_number, logger_flight_number);
	}

	DEBUG("date is: ");
	print_datetime(today);
	DEBUG("flight number is: %d\n", logger_flight_number);

}
Exemplo n.º 4
0
void widget_time_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags)
{
	uint8_t sec;
	uint8_t min;
	uint8_t hour;

	time_from_epoch(time_get_local(), &sec, &min, &hour);

	uint8_t lh = widget_label_P(PSTR("Time"), x, y);

	char tmp[7];
	sprintf_P(tmp, PSTR("%02d:%02d"), hour, min);

	widget_value_int(tmp, x, y + lh, w, h - lh);
}
Exemplo n.º 5
0
void widget_date_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags)
{
	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_local(), &sec, &min, &hour, &day, &wday, &month, &year);

	uint8_t lh = widget_label_P(PSTR("Date"), x, y);

	char tmp[7];
	sprintf_P(tmp, PSTR("%02d/%02d"), day, month);

	widget_value_int(tmp, x, y + lh, w, h - lh);
}
Exemplo n.º 6
0
void gui_set_system_item(uint8_t index, char * text, uint8_t * flags, char * sub_text)
{
	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_local(), &sec, &min, &hour, &day, &wday, &month, &year);

	switch (index)
	{
		case (0):
			sprintf_P(text, PSTR("Time & Date"));
			*flags |= GUI_LIST_FOLDER;
		break;

		case (1):
			sprintf_P(text, PSTR("Display"));
			*flags |= GUI_LIST_FOLDER;
		break;

		case (2):
			sprintf_P(text, PSTR("Audio"));
			*flags |= GUI_LIST_FOLDER;
		break;

		case (3):
			sprintf_P(text, PSTR("Mass Storage"));
			if (config.connectivity.usb_mode == USB_MODE_MASSSTORAGE)
				*flags |= GUI_LIST_CHECK_ON;
			else
				*flags |= GUI_LIST_CHECK_OFF;
		break;

		case (4):
			sprintf_P(text, PSTR("Auto power-off"));
			*flags |= GUI_LIST_SUB_TEXT;
			if (config.system.auto_power_off > 0)
				sprintf_P(sub_text, PSTR("%u min"), config.system.auto_power_off);
			else
				sprintf_P(sub_text, PSTR("disabled"));
		break;

		case (5):
			sprintf_P(text, PSTR("Uart function"));
			*flags |= GUI_LIST_SUB_TEXT;
			switch (config.connectivity.uart_function)
			{
				case(UART_FORWARD_DEBUG):
					sprintf_P(sub_text, PSTR("Debug msg"));
				break;
				case(UART_FORWARD_OFF):
					sprintf_P(sub_text, PSTR("Uart off"));
				break;
				case(UART_FORWARD_9600):
					sprintf_P(sub_text, PSTR("Telemetry 9600"));
				break;
				case(UART_FORWARD_19200):
					sprintf_P(sub_text, PSTR("Telemetry 19200"));
				break;
				case(UART_FORWARD_38400):
					sprintf_P(sub_text, PSTR("Telemetry 38400"));
				break;
				case(UART_FORWARD_57600):
					sprintf_P(sub_text, PSTR("Telemetry 57600"));
				break;
				case(UART_FORWARD_115200):
					sprintf_P(sub_text, PSTR("Telemetry 115200"));
				break;
			}
		break;

		case (6):
			sprintf_P(text, PSTR("Format SD"));
			*flags |= GUI_LIST_FOLDER;
		break;
	}
}