uint8_t aero_start(char * path) { char filename[128]; 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_utc(), &sec, &min, &hour, &day, &wday, &month, &year); sprintf_P(filename, PSTR("%sAER"), path); DEBUG("RAW filename %s\n", filename); uint8_t res = f_open(&log_file, filename, FA_WRITE | FA_CREATE_ALWAYS); assert(res == FR_OK); //cannot create file if (res != FR_OK) return false; aero_last_time = 0; return LOGGER_ACTIVE; }
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); }
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); }
void logger_start() { if (!config.logger.enabled) return; logger_next_flight(); if (!storage_ready()) { gui_showmessage_P(PSTR("SD card error!")); fc.logger_state = LOGGER_ERROR; return; } 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_utc(), &sec, &min, &hour, &day, &wday, &month, &year); char path[128]; //base dir sprintf_P(path, PSTR("%S"), LOG_DIR); f_mkdir(path); //year sprintf_P(path, PSTR("%S/%04d"), LOG_DIR, year); f_mkdir(path); //month sprintf_P(path, PSTR("%S/%04d/%02d"), LOG_DIR, year, month); f_mkdir(path); //day sprintf_P(path, PSTR("%S/%04d/%02d/%02d"), LOG_DIR, year, month, day); f_mkdir(path); switch (config.logger.format) { case(LOGGER_IGC): fc.logger_state = igc_start(path); break; case(LOGGER_KML): fc.logger_state = kml_start(path); break; case(LOGGER_RAW): fc.logger_state = raw_start(path); break; } }
/** * Insert a line into the log containing a XML element and "now" as the content, * e.g. "<end>2016-12-24T18:00:00Z</end>". * * \param tag the name of the XML element, in the above example, this would be "end". */ void kml_now(const char *tag) { 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_utc(), &sec, &min, &hour, &day, &wday, &month, &year); kml_sprintf_P(PSTR("<%s>%04d-%02d-%02dT%02d:%02d:%02dZ</%s>"), tag, year, month, day, hour, min, sec, tag); }
void gui_set_time_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_actual(), &sec, &min, &hour, &day, &wday, &month, &year); switch (index) { case (0): sprintf_P(text, PSTR("Time")); sprintf_P(sub_text, PSTR("%02d:%02d.%02d"), hour, min, sec); *flags |= GUI_LIST_SUB_TEXT; break; case (1): sprintf_P(text, PSTR("Date")); sprintf_P(sub_text, PSTR("%02d/%02d/%04d"), day, month, year); *flags |= GUI_LIST_SUB_TEXT; break; case (2): sprintf_P(text, PSTR("Time Zone")); sprintf_P(sub_text, PSTR("UTC %+0.1f"), config.system.time_zone / 2.0); *flags |= GUI_LIST_SUB_TEXT; break; case (3): sprintf_P(text, PSTR("DST")); if (config.system.time_flags & TIME_DST) *flags |= GUI_LIST_CHECK_ON; else *flags |= GUI_LIST_CHECK_OFF; break; case (4): sprintf_P(text, PSTR("Sync with GPS")); if (config.system.time_flags & TIME_SYNC) *flags |= GUI_LIST_CHECK_ON; else *flags |= GUI_LIST_CHECK_OFF; break; } }
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); }
bool kml_start(char * path) { char filename[128]; uint8_t sec; uint8_t min; uint8_t hour; uint8_t day; uint8_t wday; uint8_t month; uint16_t year; char line[79]; char id[32]; datetime_from_epoch(time_get_utc(), &sec, &min, &hour, &day, &wday, &month, &year); sprintf_P(filename, PSTR("/%s/%02d-%02d%02d.KML"), path, logger_flight_number, hour, min); DEBUG("KML filename %s\n", filename); uint8_t res = f_open(log_fil, filename, FA_WRITE | FA_CREATE_ALWAYS); assert(res == FR_OK); //cannot create file if (res != FR_OK) return false; //header GetID_str(id); sprintf_P(line, PSTR("<!-- Generated by SkyDrop vario (www.skybean.eu) -->")); kml_writeline(line); sprintf_P(line, PSTR("<!-- Date: %02d.%02d.%04d -->"), day, month, year); kml_writeline(line); sprintf_P(line, PSTR("<!-- Time: %02d:%02d -->"), hour, min); kml_writeline(line); sprintf_P(line, PSTR("<!-- Pilot: %s -->"), config.logger.pilot); kml_writeline(line); sprintf_P(line, PSTR("<!-- Glider type: %s -->"), config.logger.glider_type); kml_writeline(line); sprintf_P(line, PSTR("<!-- Glider ID: %s -->"), config.logger.glider_id); kml_writeline(line); sprintf_P(line, PSTR("<!-- S/N: %s -->"), id); kml_writeline(line); sprintf_P(line, PSTR("<!-- HW: drop_%d -->"), (hw_revision == HW_REW_1504) ? 1504 : 1506); kml_writeline(line); sprintf_P(line, PSTR("<!-- SW: build %d -->"), BUILD_NUMBER); kml_writeline(line); //body sprintf_P(line, PSTR("<kml xmlns=\"http://earth.google.com/kml/2.0\">")); kml_writeline(line); sprintf_P(line, PSTR("<Document>")); kml_writeline(line); sprintf_P(line, PSTR("<name>Flight log from %02d.%02d.%04d @ %02d:%02d</name>"), day, month, year, hour, min); kml_writeline(line); sprintf_P(line, PSTR("<Placemark>")); kml_writeline(line); sprintf_P(line, PSTR("<name>Flight</name>")); kml_writeline(line); sprintf_P(line, PSTR("<visibility>1</visibility>")); kml_writeline(line); sprintf_P(line, PSTR("<open>1</open>")); kml_writeline(line); sprintf_P(line, PSTR("<Style>")); kml_writeline(line); sprintf_P(line, PSTR("<LineStyle><color>ff00ffff</color></LineStyle>")); kml_writeline(line); sprintf_P(line, PSTR("<PolyStyle><color>7f0000ff</color></PolyStyle>")); kml_writeline(line); sprintf_P(line, PSTR("</Style>")); kml_writeline(line); sprintf_P(line, PSTR("<LineString>")); kml_writeline(line); sprintf_P(line, PSTR("<altitudeMode>absolute</altitudeMode>")); kml_writeline(line); sprintf_P(line, PSTR("<extrude>1</extrude>")); kml_writeline(line); sprintf_P(line, PSTR("<coordinates>")); kml_writeline(line); return (fc.gps_data.valid) ? LOGGER_ACTIVE : LOGGER_WAIT_FOR_GPS; }
uint8_t igc_start(char * path) { char filename[128]; uint8_t sec; uint8_t min; uint8_t hour; uint8_t day; uint8_t wday; uint8_t month; uint16_t year; char line[79]; char id[32]; sha256.init(); IGC_PRIVATE_KEY_ADD; datetime_from_epoch(time_get_utc(), &sec, &min, &hour, &day, &wday, &month, &year); //XXX #define device_uid "DRP" sprintf_P(filename, PSTR("%sIGC"), path); DEBUG("IGC filename %s\n", filename); uint8_t res = f_open(&log_file, filename, FA_WRITE | FA_CREATE_ALWAYS); assert(res == FR_OK); DEBUG("f_open res = %02X\n", res); //cannot create file if (res != FR_OK) return false; //A record GetID_str(id); sprintf_P(line, PSTR("A%S%s:%s"), LOG_MID_P, device_uid, id); igc_writeline(line); //H records //H F DTE sprintf_P(line, PSTR("HFDTE%02u%02u%02u"), day, month, year % 100); igc_writeline(line); // //H F DTE // sprintf_P(line, PSTR("HFDTEDATE:%02u%02u%02u,%02u"), day, month, year % 100, logger_flight_number); // igc_writeline(line); //H F PLT PILOT IN CHARGE sprintf_P(line, PSTR("HFPLTPILOTINCHARGE:%s"), config.logger.pilot); igc_writeline(line); //H F CM2 CREW 2 sprintf_P(line, PSTR("HFCM2CREW2:NIL")); igc_writeline(line); //H F GTY GLIDER TYPE sprintf_P(line, PSTR("HFGTYGLIDERTYPE:%s"), config.logger.glider_type); igc_writeline(line); //H F GID GLIDER ID sprintf_P(line, PSTR("HFGIDGLIDERID:%s"), config.logger.glider_id); igc_writeline(line); //H F DTM GPS DATUM sprintf_P(line, PSTR("HFDTMGPSDATUM:WGS84")); igc_writeline(line); //H F RFW FIRMWARE VERSION sprintf_P(line, PSTR("HFRFWFIRMWAREVERSION:build %d"), BUILD_NUMBER); igc_writeline(line); //H F RHW HARDWARE VERSION sprintf_P(line, PSTR("HFRHWHARDWAREVERSION:drop_%d"), (hw_revision == HW_REW_1504) ? 1504 : 1506); igc_writeline(line); //H F FTY FR TYPE sprintf_P(line, PSTR("HFFTYFRTYPE:SkyBean,SkyDrop")); igc_writeline(line); //H F GPS RECEIVER sprintf_P(line, PSTR("HFGPSRECEIVER:Quectel,L80,22cm,18000m")); igc_writeline(line); //H F PRS PRESS ALT SENSOR sprintf_P(line, PSTR("HFPRSPRESSALTSENSOR:Measurement specialties,MS5611,25907m")); igc_writeline(line); //H F ALG ALT GPS sprintf_P(line, PSTR("HFALGALTGPS:GEO")); igc_writeline(line); //H F ALP sprintf_P(line, PSTR("HFALPALTPRESSURE:ISA")); igc_writeline(line); //H F TZN sprintf_P(line, PSTR("HFTZNTIMEZONE:%+0.1f"), config.system.time_zone / 2.0); igc_writeline(line); #ifdef IGC_NO_PRIVATE_KEY //Developer note: we can't publish the private key for signing the IGC file //H F FRS sprintf_P(line, PSTR("HFFRSSECSUSPECTUSEVALIPROG:This file is not valid. Private key not available!")); igc_writeline(line); #endif //dump the cache // DEBUG("IGC dump len %d\n", igc_pre_start_len); for (uint8_t i = igc_pre_start_len; i > 0; i--) { int8_t index = igc_pre_start_index - i; if (index < 0) index += IGC_PRE_START_BUFFER; // DEBUG("IGC dump %d\n", index); igc_pre_fix * pfix = &igc_pre_start_cache[index]; int16_t galt = pfix->galt; char c = 'A'; if (galt == 0x7FFF) { galt = 0; c = 'V'; } sprintf_P(line, PSTR("B%02d%02d%02d%s%s%c%05d%05d"), pfix->hour, pfix->min, pfix->sec, pfix->cache_igc_latitude, pfix->cache_igc_longtitude, c, pfix->balt, galt); igc_writeline(line); } // igc_comment("End of cache"); igc_write_grecord(); return (fc.gps_data.valid) ? LOGGER_ACTIVE : LOGGER_WAIT_FOR_GPS; }
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_actual(), &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; } }
void gui_set_gps_item(uint8_t index, char * text, uint8_t * flags, char * sub_text) { char tmp[10]; uint8_t sec; uint8_t min; uint8_t hour; uint8_t day; uint8_t wday; uint8_t month; uint16_t year; if (fc.gps_data.valid) { datetime_from_epoch(fc.gps_data.utc_time, &sec, &min, &hour, &day, &wday, &month, &year); } switch (index) { case (0): sprintf_P(text, PSTR("Enable GPS")); if (config.system.use_gps) *flags |= GUI_LIST_CHECK_ON; else *flags |= GUI_LIST_CHECK_OFF; break; case (1): sprintf_P(text, PSTR("Status")); if (config.system.use_gps) { switch (fc.gps_data.fix) { case(2): sprintf_P(tmp, PSTR("2D")); break; case(3): sprintf_P(tmp, PSTR("3D")); break; default: sprintf_P(tmp, PSTR("No")); break; } sprintf_P(sub_text, PSTR("%d/%d %s Fix"), fc.gps_data.sat_used, fc.gps_data.sat_total, tmp); } else { sprintf_P(sub_text, PSTR("GPS disabled")); } *flags |= GUI_LIST_SUB_TEXT; break; case (2): sprintf_P(text, PSTR("GPS time")); if (fc.gps_data.valid) sprintf_P(sub_text, PSTR("%02d:%02d.%02d"), hour, min, sec); else { if (config.system.use_gps) sprintf_P(sub_text, PSTR("Waiting for fix")); else sprintf_P(sub_text, PSTR("GPS disabled")); } *flags |= GUI_LIST_SUB_TEXT; break; case (3): sprintf_P(text, PSTR("GPS date")); if (fc.gps_data.valid) sprintf_P(sub_text, PSTR("%02d/%02d/%04d"), day, month, year); else { if (config.system.use_gps) sprintf_P(sub_text, PSTR("Waiting for fix")); else sprintf_P(sub_text, PSTR("GPS disabled")); } *flags |= GUI_LIST_SUB_TEXT; break; case (4): sprintf_P(text, PSTR("Speed units")); *flags |= GUI_LIST_SUB_TEXT; switch (config.system.gps_format_flags & GPS_SPD_MASK) { case(GPS_SPD_KNOT): sprintf_P(sub_text, PSTR("Knots")); break; case(GPS_SPD_KPH): sprintf_P(sub_text, PSTR("Km/h")); break; case(GPS_SPD_MS): sprintf_P(sub_text, PSTR("m/s")); break; case(GPS_SPD_MPH): sprintf_P(sub_text, PSTR("MPH")); break; } break; case (5): sprintf_P(text, PSTR("Format")); *flags |= GUI_LIST_SUB_TEXT; switch (config.system.gps_format_flags & GPS_FORMAT_MASK) { case(GPS_DDMMSS): sprintf_P(sub_text, PSTR("DD*MM'SS\"")); break; case(GPS_DDMMmmm): sprintf_P(sub_text, PSTR("DD*MM.mmm'")); break; case(GPS_DDdddddd): sprintf_P(sub_text, PSTR("DD.dddddd")); break; } break; } }
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); } }
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; }
uint8_t kml_start(char * path) { char filename[128]; uint8_t sec; uint8_t min; uint8_t hour; uint8_t day; uint8_t wday; uint8_t month; uint16_t year; char id[32]; datetime_from_epoch(time_get_utc(), &sec, &min, &hour, &day, &wday, &month, &year); sprintf_P(filename, PSTR("%sKML"), path); DEBUG("KML filename %s\n", filename); uint8_t res = f_open(&log_file, filename, FA_WRITE | FA_CREATE_ALWAYS); assert(res == FR_OK); //cannot create file if (res != FR_OK) return false; //header GetID_str(id); kml_sprintf_P(PSTR("<!-- Generated by SkyDrop vario (www.skybean.eu) -->")); kml_sprintf_P(PSTR("<!-- Date: %02d.%02d.%04d -->"), day, month, year); kml_sprintf_P(PSTR("<!-- Time: %02d:%02d -->"), hour, min); kml_sprintf_P(PSTR("<!-- Pilot: %s -->"), config.logger.pilot); kml_sprintf_P(PSTR("<!-- Glider type: %s -->"), config.logger.glider_type); kml_sprintf_P(PSTR("<!-- Glider ID: %s -->"), config.logger.glider_id); kml_sprintf_P(PSTR("<!-- S/N: %s -->"), id); kml_sprintf_P(PSTR("<!-- HW: drop_%d -->"), (hw_revision == HW_REW_1504) ? 1504 : 1506); kml_sprintf_P(PSTR("<!-- SW: build %d -->"), BUILD_NUMBER); //body kml_sprintf_P(PSTR("<kml xmlns=\"http://www.opengis.net/kml/2.2\">")); kml_sprintf_P(PSTR("<Document>")); kml_sprintf_P(PSTR("<name>Flight log from %02d.%02d.%04d @ %02d:%02d</name>"), day, month, year, hour, min); kml_sprintf_P(PSTR("<Placemark id=\"%s-%ld\">"), id, time_get_utc()); kml_sprintf_P(PSTR("<name>Flight</name>")); kml_sprintf_P(PSTR("<visibility>1</visibility>")); kml_sprintf_P(PSTR("<open>1</open>")); kml_sprintf_P(PSTR("<TimeSpan>")); kml_now("begin"); // Save position of end date, so that we can overwrite on close: filepos_for_end = f_tell(&log_file); kml_now("end"); kml_sprintf_P(PSTR("</TimeSpan>")); kml_sprintf_P(PSTR("<Style>")); kml_sprintf_P(PSTR("<LineStyle><color>ff00ffff</color></LineStyle>")); kml_sprintf_P(PSTR("<PolyStyle><color>7f0000ff</color></PolyStyle>")); kml_sprintf_P(PSTR("</Style>")); kml_sprintf_P(PSTR("<LineString>")); kml_sprintf_P(PSTR("<extrude>1</extrude>")); kml_sprintf_P(PSTR("<altitudeMode>absolute</altitudeMode>")); kml_sprintf_P(PSTR("<coordinates>")); return (fc.gps_data.valid) ? LOGGER_ACTIVE : LOGGER_WAIT_FOR_GPS; }