Exemplo n.º 1
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.º 2
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.º 3
0
inline void print_field_value(byte *value, ulint len, field_def_t *field) {
	switch (field->type) {
		case FT_INTERNAL:
    		break;

		case FT_CHAR:
		case FT_TEXT:
            print_string((char*)value, len, field);
			break;

		case FT_UINT:
            printf("%llu", get_uint_value(field, value));
			break;

		case FT_INT:
            printf("%lli", get_int_value(field, value));
			break;

		case FT_FLOAT:
			printf("%f", mach_float_read(value));
			break;

		case FT_DOUBLE:
			printf("%lf", mach_double_read(value));
			break;

		case FT_DATETIME:
			print_datetime(make_longlong(mach_read_from_8(value)));
			break;

		case FT_DATE:
			print_date(mach_read_from_3(value));
			break;

		case FT_TIME:
			print_time(mach_read_from_3(value));
			break;

		case FT_ENUM:
			print_enum(mach_read_from_1(value), field);
			break;

        case FT_DECIMAL:
            print_decimal(value, field);
            break;

		default:
    		printf("undef(%d)", field->type);
	}
}
Exemplo n.º 4
0
void Post()
{
	DEBUG("\n *** POST *** \n");

	//Print reset reason
	DEBUG("Reset reason ... ");

	if (system_rst & 0b00100000)
		DEBUG("Software ");
	else
	if (system_rst & 0b00010000)
		DEBUG("Programming ");
	else
	if (system_rst & 0b00001000)
		DEBUG("Watchdog ");
	else
	if (system_rst & 0b00000100)
		DEBUG("Brownout ");
	else
	if (system_rst & 0b00000010)
		DEBUG("External ");
	else
	if (system_rst & 0b00000001)
		DEBUG("Power On ");
	else
		DEBUG("Unknown: %02X", system_rst);

	DEBUG("\n");

	//App name
	print_fw_info();

	//Print actual time
	DEBUG("Time is ... \n");
	print_datetime(time_get_actual());

	DEBUG("Free RAM at start ... %d\n", free_ram_at_start);
	test_memory();

	char id[23];
	GetID_str(id);
	DEBUG("Device serial number ... %s\n", id);

	DEBUG("Board rev ... %u\n", (hw_revision == HW_REW_1504) ? 1504 : 1406);

	//debug info
	debug_last_dump();
}
Exemplo n.º 5
0
void Post()
{
	//buzzer_beep(_1sec, 0, 0, 0, 0);

	DEBUG("\n *** POST *** \n");

	//Print reset reason
	DEBUG("Reset reason ... ");

	system_rst = RST.STATUS;

	if (RST.STATUS & 0b00100000)
		DEBUG("Software ");
	else
	if (RST.STATUS & 0b00010000)
		DEBUG("Programming ");
	else
	if (RST.STATUS & 0b00001000)
		DEBUG("Watchdog ");
	else
	if (RST.STATUS & 0b00000100)
		DEBUG("Brownout ");
	else
	if (RST.STATUS & 0b00000010)
		DEBUG("External ");
	else
	if (RST.STATUS & 0b00000001)
		DEBUG("Power On ");
	else
		DEBUG("Unknown: %02X", RST.STATUS);

	RST.STATUS = 0b00111111;
	DEBUG("\n");

	//App name
	print_fw_info();

	//Print actual time
	DEBUG("Time is ... \n");
	print_datetime();

	DEBUG("Free RAM at start ... %d\n", free_ram_at_start);
	test_memory();

	DEBUG("\n");
}