Added a union for casting floats to ints and back when storing Floats to the DataFlash

This commit is contained in:
Jason Short 2012-04-21 15:17:09 -07:00
parent 3b5ffe0f61
commit 2aca6c64ab
2 changed files with 19 additions and 0 deletions

View File

@ -488,6 +488,12 @@ static const float radius_of_earth = 6378100; // meters
// Used by Mavlink for unknow reasons
static const float gravity = 9.81; // meters/ sec^2
// Unions for getting byte values
union float_int{
int32_t int_value;
float float_value;
} float_int;
////////////////////////////////////////////////////////////////////////////////
// Location & Navigation

View File

@ -43,6 +43,19 @@ const struct Menu::command log_menu_commands[] PROGMEM = {
{"disable", select_logs}
};
static int32_t get_int(float f)
{
float_int.float_value = f;
return float_int.int_value;
}
static float get_float(int32_t i)
{
float_int.int_value = i;
return float_int.float_value;
}
// A Macro to create the Menu
MENU2(log_menu, "Log", log_menu_commands, print_log_menu);