Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00014
00015 #ifndef _AP_COMMON_H
00016 #define _AP_COMMON_H
00017
00018 #include <stdint.h>
00019 #include "include/menu.h"
00020 #include "c++.h"
00021 #include "AP_Vector.h"
00022 #include "AP_Loop.h"
00023
00026
00027
00028
00029
00030
00031
00032
00033
00034 #pragma GCC diagnostic warning "-Wall"
00035 #pragma GCC diagnostic warning "-Wextra"
00036 #pragma GCC diagnostic warning "-Wlogical-op"
00037 #pragma GCC diagnostic ignored "-Wredundant-decls"
00038
00039
00040
00041
00042
00043
00044
00045 #pragma GCC diagnostic error "-Wfloat-equal"
00046
00047
00048
00049
00050
00051 #if PRINTF_FORMAT_WARNING_DEBUG
00052 # undef PSTR
00053 # define PSTR(_x) _x // help the compiler with printf_P
00054 # define float double // silence spurious format warnings for %f
00055 #else
00056
00057
00058
00059
00060
00061
00062
00063 # undef PROGMEM
00064 # define PROGMEM __attribute__(( section(".progmem.data") ))
00065 # undef PSTR
00066 # define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];}))
00067 #endif
00068
00070
00076
00077
00078 struct Location {
00079 uint8_t id;
00080 uint8_t p1;
00081 int32_t alt;
00082 int32_t lat;
00083 int32_t lng;
00084 };
00085
00091 template <class type>
00092 class AP_Var
00093 {
00094 public:
00098 AP_Var(const type & data, const char * name = "", const bool & sync=false) :
00099 _data(data), _name(name), _sync(sync)
00100 {
00101 }
00102
00106 void set(const type & val) {
00107 _data = val;
00108 if (_sync) save();
00109 }
00110
00114 const type & get() {
00115 if (_sync) load();
00116 return _data;
00117 }
00118
00122 void setAsFloat(const float & val) {
00123 set(val);
00124 }
00125
00129 const float & getAsFloat() {
00130 return get();
00131 }
00132
00133
00137 virtual void save()
00138 {
00139 }
00140
00144 virtual void load()
00145 {
00146 }
00147
00151 const char * getName() { return _name; }
00152
00157 const bool & getSync() { return _sync; }
00158 void setSync(bool sync) { _sync = sync; }
00159
00160 protected:
00161 type _data;
00162 const char * _name;
00163 bool _sync;
00164 };
00165
00167
00173
00174
00177 #define ToDeg(x) (x*57.2957795131) // *180/pi
00178
00180
00181
00182 #endif // _AP_COMMON_H