1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Now it compiles without a warning under Visual C++ ... Why? Only because I wanted to have exceptions catched under Windows as we have on Linux. Most users are Windows. They will be all testers :)

This commit is contained in:
bsongis 2011-12-16 19:06:28 +00:00
parent 88fca5135d
commit 43ccaa60e6
10 changed files with 93 additions and 77 deletions

View file

@ -32,19 +32,19 @@ uint8_t s_sync_write = false;
#define BLOCKS (EESIZE/BS) #define BLOCKS (EESIZE/BS)
#define EEFS_VERS 4 #define EEFS_VERS 4
struct DirEnt{ PACK(struct DirEnt{
uint8_t startBlk; uint8_t startBlk;
uint16_t size:12; uint16_t size:12;
uint16_t typ:4; uint16_t typ:4;
}__attribute__((packed)); });
#define MAXFILES (1+MAX_MODELS+3) #define MAXFILES (1+MAX_MODELS+3)
struct EeFs{ PACK(struct EeFs{
uint8_t version; uint8_t version;
uint8_t mySize; uint8_t mySize;
uint8_t freeList; uint8_t freeList;
uint8_t bs; uint8_t bs;
DirEnt files[MAXFILES]; DirEnt files[MAXFILES];
}__attribute__((packed)) eeFs; }) eeFs;
static uint8_t EeFsRead(uint8_t blk, uint8_t ofs) static uint8_t EeFsRead(uint8_t blk, uint8_t ofs)
@ -163,10 +163,6 @@ void EeFsFormat()
{ {
s_sync_write = true; s_sync_write = true;
if (sizeof(eeFs) != RESV){
extern void eeprom_RESV_mismatch();
eeprom_RESV_mismatch();
}
memset(&eeFs,0, sizeof(eeFs)); memset(&eeFs,0, sizeof(eeFs));
eeFs.version = EEFS_VERS; eeFs.version = EEFS_VERS;
eeFs.mySize = sizeof(eeFs); eeFs.mySize = sizeof(eeFs);

View file

@ -290,7 +290,7 @@ void applyExpos(int16_t *anas, uint8_t phase)
} }
bool s_noStickInputs = false; bool s_noStickInputs = false;
inline int16_t __attribute__ ((always_inline)) getValue(uint8_t i) FORCEINLINE int16_t getValue(uint8_t i)
{ {
if(i<NUM_STICKS+NUM_POTS) return (s_noStickInputs ? 0 : calibratedStick[i]); if(i<NUM_STICKS+NUM_POTS) return (s_noStickInputs ? 0 : calibratedStick[i]);
else if(i<MIX_FULL/*srcRaw is shifted +1!*/) return 1024; //FULL/MAX else if(i<MIX_FULL/*srcRaw is shifted +1!*/) return 1024; //FULL/MAX
@ -537,6 +537,9 @@ void doSplash()
void checkLowEEPROM() void checkLowEEPROM()
{ {
int i = 1;
int a = (i+1) / (i-1);
if(g_eeGeneral.disableMemoryWarning) return; if(g_eeGeneral.disableMemoryWarning) return;
if(EeFsGetFree() < 200) if(EeFsGetFree() < 200)
{ {

View file

@ -549,14 +549,18 @@ extern uint8_t s_eeDirtyMsk;
/// liefert Dimension eines Arrays /// liefert Dimension eines Arrays
#define DIM(arr) (sizeof((arr))/sizeof((arr)[0])) #define DIM(arr) (sizeof((arr))/sizeof((arr)[0]))
#ifndef FORCEINLINE
#define FORCEINLINE inline __attribute__ ((always_inline))
#endif
/// liefert Betrag des Arguments /// liefert Betrag des Arguments
template<class t> inline t __attribute__ ((always_inline)) abs(t a){ return a>0?a:-a; } template<class t> FORCEINLINE t abs(t a){ return a>0?a:-a; }
/// liefert das Minimum der Argumente /// liefert das Minimum der Argumente
template<class t> inline t __attribute__ ((always_inline)) min(t a, t b){ return a<b?a:b; } template<class t> FORCEINLINE t min(t a, t b){ return a<b?a:b; }
/// liefert das Maximum der Argumente /// liefert das Maximum der Argumente
template<class t> inline t __attribute__ ((always_inline)) max(t a, t b){ return a>b?a:b; } template<class t> FORCEINLINE t max(t a, t b){ return a>b?a:b; }
template<class t> inline int8_t __attribute__ ((always_inline)) sgn(t a){ return a>0 ? 1 : (a < 0 ? -1 : 0); } template<class t> FORCEINLINE t sgn(t a){ return a>0 ? 1 : (a < 0 ? -1 : 0); }
template<class t> inline t __attribute__ ((always_inline)) limit(t mi, t x, t ma){ return min(max(mi,x),ma); } template<class t> FORCEINLINE t limit(t mi, t x, t ma){ return min(max(mi,x),ma); }
/// Markiert einen EEPROM-Bereich als dirty. der Bereich wird dann in /// Markiert einen EEPROM-Bereich als dirty. der Bereich wird dann in
/// eeCheck ins EEPROM zurueckgeschrieben. /// eeCheck ins EEPROM zurueckgeschrieben.

View file

@ -21,8 +21,7 @@
#include "menus.h" #include "menus.h"
#undef ALTERNATE #define ALTERNATE_VIEW 0x10
#define ALTERNATE 0x10
enum MainViews { enum MainViews {
e_outputValues, e_outputValues,
@ -90,7 +89,7 @@ void menuMainView(uint8_t event)
#ifdef FRSKY #ifdef FRSKY
bool telemViewSw = isFunctionActive(FUNC_VIEW_TELEMETRY); bool telemViewSw = isFunctionActive(FUNC_VIEW_TELEMETRY);
if (switchView == 255 && telemViewSw) { view = switchView = e_telemetry + ALTERNATE; } if (switchView == 255 && telemViewSw) { view = switchView = e_telemetry + ALTERNATE_VIEW; }
if (switchView != 255 && !telemViewSw) { view = g_eeGeneral.view; switchView = 255; } if (switchView != 255 && !telemViewSw) { view = g_eeGeneral.view; switchView = 255; }
#endif #endif
@ -111,7 +110,7 @@ void menuMainView(uint8_t event)
case EVT_KEY_BREAK(KEY_RIGHT): case EVT_KEY_BREAK(KEY_RIGHT):
case EVT_KEY_BREAK(KEY_LEFT): case EVT_KEY_BREAK(KEY_LEFT):
if (switchView != 255) break; if (switchView != 255) break;
g_eeGeneral.view = (view + (event == EVT_KEY_BREAK(KEY_RIGHT) ? ALTERNATE : tabViews[view_base]*ALTERNATE-ALTERNATE)) % (tabViews[view_base]*ALTERNATE); g_eeGeneral.view = (view + (event == EVT_KEY_BREAK(KEY_RIGHT) ? ALTERNATE_VIEW : tabViews[view_base]*ALTERNATE_VIEW-ALTERNATE_VIEW)) % (tabViews[view_base]*ALTERNATE_VIEW);
eeDirty(EE_GENERAL); eeDirty(EE_GENERAL);
beepKey(); beepKey();
break; break;
@ -197,7 +196,7 @@ void menuMainView(uint8_t event)
trim2OfsSwLock = trimSw; trim2OfsSwLock = trimSw;
#ifdef FRSKY #ifdef FRSKY
if (view_base == e_telemetry && view > ALTERNATE) { if (view_base == e_telemetry && view > ALTERNATE_VIEW) {
putsModelName(0, 0, g_model.name, g_eeGeneral.currModel, 0); putsModelName(0, 0, g_model.name, g_eeGeneral.currModel, 0);
uint8_t att = (g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK : 0); uint8_t att = (g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK : 0);
putsVBat(14*FW,0,att); putsVBat(14*FW,0,att);
@ -323,7 +322,7 @@ void menuMainView(uint8_t event)
} }
} }
displayCount = (displayCount+1) % 50; displayCount = (displayCount+1) % 50;
if (view == e_telemetry+ALTERNATE) { if (view == e_telemetry+ALTERNATE_VIEW) {
if (g_model.frsky.channels[0].ratio || g_model.frsky.channels[1].ratio) { if (g_model.frsky.channels[0].ratio || g_model.frsky.channels[1].ratio) {
x0 = 0; x0 = 0;
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {
@ -388,7 +387,7 @@ void menuMainView(uint8_t event)
lcd_outdezAtt(17 * FW - 2, 7*FH, frskyRSSI[1].max, LEFT); lcd_outdezAtt(17 * FW - 2, 7*FH, frskyRSSI[1].max, LEFT);
} }
#ifdef FRSKY_HUB #ifdef FRSKY_HUB
else if (g_eeGeneral.view == e_telemetry+2*ALTERNATE) { // if on second alternate telemetry view else if (g_eeGeneral.view == e_telemetry+2*ALTERNATE_VIEW) { // if on second alternate telemetry view
// Date // Date
lcd_outdezNAtt(1*FW, 1*FH, frskyHubData.year+2000, LEFT, 4); lcd_outdezNAtt(1*FW, 1*FH, frskyHubData.year+2000, LEFT, 4);
lcd_putc(lcd_lastPos, 1*FH, '-'); lcd_putc(lcd_lastPos, 1*FH, '-');
@ -441,7 +440,7 @@ void menuMainView(uint8_t event)
lcd_outdezAtt(lcd_lastPos+2, 7*FH, frskyHubData.gpsAltitude_ap, LEFT|UNSIGN); // after '.' lcd_outdezAtt(lcd_lastPos+2, 7*FH, frskyHubData.gpsAltitude_ap, LEFT|UNSIGN); // after '.'
lcd_putc(lcd_lastPos, 7*FH, 'm'); lcd_putc(lcd_lastPos, 7*FH, 'm');
} }
else if (g_eeGeneral.view == e_telemetry+3*ALTERNATE) { // if on second alternate telemetry view else if (g_eeGeneral.view == e_telemetry+3*ALTERNATE_VIEW) { // if on second alternate telemetry view
uint8_t y = 2*FH; uint8_t y = 2*FH;
@ -527,8 +526,8 @@ void menuMainView(uint8_t event)
#endif #endif
else if (view_base<e_timer2) { else if (view_base<e_timer2) {
doMainScreenGrphics(); doMainScreenGrphics();
int8_t a = (view == e_inputs) ? 1 : 4+(view/ALTERNATE)*6; int8_t a = (view == e_inputs) ? 1 : 4+(view/ALTERNATE_VIEW)*6;
int8_t b = (view == e_inputs) ? 7 : 7+(view/ALTERNATE)*6; int8_t b = (view == e_inputs) ? 7 : 7+(view/ALTERNATE_VIEW)*6;
for(int8_t i=a; i<(a+3); i++) putsSwitches(2*FW-2, (i-a)*FH+4*FH, i, getSwitch(i, 0) ? INVERS : 0); for(int8_t i=a; i<(a+3); i++) putsSwitches(2*FW-2, (i-a)*FH+4*FH, i, getSwitch(i, 0) ? INVERS : 0);
for(int8_t i=b; i<(b+3); i++) putsSwitches(17*FW-1, (i-b)*FH+4*FH, i, getSwitch(i, 0) ? INVERS : 0); for(int8_t i=b; i<(b+3); i++) putsSwitches(17*FW-1, (i-b)*FH+4*FH, i, getSwitch(i, 0) ? INVERS : 0);
} }

View file

@ -101,9 +101,9 @@ typedef PROGMEM void (*MenuFuncP_PROGMEM)(uint8_t event);
#define TITLEP(pstr) lcd_putsAtt(0,0,pstr,INVERS) #define TITLEP(pstr) lcd_putsAtt(0,0,pstr,INVERS)
#define TITLE(str) TITLEP(PSTR(str)) #define TITLE(str) TITLEP(PSTR(str))
#define MENU(title, tab, menu, lines_count, lines...) \ #define MENU(title, tab, menu, lines_count, ...) \
TITLE(title); \ TITLE(title); \
static prog_uint8_t APM mstate_tab[] = lines; \ static prog_uint8_t APM mstate_tab[] = __VA_ARGS__; \
if (!check(event,menu,tab,DIM(tab),mstate_tab,DIM(mstate_tab)-1,lines_count-1)) return; if (!check(event,menu,tab,DIM(tab),mstate_tab,DIM(mstate_tab)-1,lines_count-1)) return;
#define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \ #define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \
@ -113,9 +113,9 @@ if (!check_simple(event,menu,tab,DIM(tab),lines_count-1)) return;
TITLE(title); \ TITLE(title); \
SIMPLE_MENU_NOTITLE(tab, menu, lines_count) SIMPLE_MENU_NOTITLE(tab, menu, lines_count)
#define SUBMENU(title, lines_count, lines...) \ #define SUBMENU(title, lines_count, ...) \
TITLE(title); \ TITLE(title); \
static prog_uint8_t APM mstate_tab[] = lines; \ static prog_uint8_t APM mstate_tab[] = __VA_ARGS__; \
if (!check(event,0,NULL,0,mstate_tab,DIM(mstate_tab)-1,lines_count-1)) return; if (!check(event,0,NULL,0,mstate_tab,DIM(mstate_tab)-1,lines_count-1)) return;
#define SIMPLE_SUBMENU_NOTITLE(lines_count) \ #define SIMPLE_SUBMENU_NOTITLE(lines_count) \

View file

@ -168,15 +168,15 @@ void menuProcModelSelect(uint8_t event)
} }
uint8_t _event = (s_warning ? 0 : event); uint8_t _event = (s_warning ? 0 : event);
uint8_t __event = _event; uint8_t _event_ = _event;
if (s_copyMode || !EFile::exists(FILE_MODEL(g_eeGeneral.currModel))) { if (s_copyMode || !EFile::exists(FILE_MODEL(g_eeGeneral.currModel))) {
if ((_event & 0x1f) == KEY_EXIT) if ((_event & 0x1f) == KEY_EXIT)
__event -= KEY_EXIT; _event_ -= KEY_EXIT;
} }
int8_t oldSub = m_posVert; int8_t oldSub = m_posVert;
if (!check_submenu_simple(__event, MAX_MODELS-1)) return; if (!check_submenu_simple(_event_, MAX_MODELS-1)) return;
int8_t sub = m_posVert; int8_t sub = m_posVert;
lcd_puts_P( 9*FW, 0, PSTR("free")); lcd_puts_P( 9*FW, 0, PSTR("free"));
@ -1239,9 +1239,9 @@ inline void displayExpoLine(uint8_t row, uint8_t expo, uint8_t ch, uint8_t idx,
} }
} }
void menuProcExpoMix(uint8_t expo, uint8_t __event) void menuProcExpoMix(uint8_t expo, uint8_t _event_)
{ {
uint8_t _event = (s_warning ? 0 : __event); uint8_t _event = (s_warning ? 0 : _event_);
uint8_t event = _event; uint8_t event = _event;
uint8_t key = (event & 0x1f); uint8_t key = (event & 0x1f);
@ -1425,7 +1425,7 @@ void menuProcExpoMix(uint8_t expo, uint8_t __event)
} }
s_maxLines = cur; s_maxLines = cur;
if (sub >= s_maxLines-1) m_posVert = s_maxLines-1; if (sub >= s_maxLines-1) m_posVert = s_maxLines-1;
displayWarning(__event); displayWarning(_event_);
} }
void menuProcExposAll(uint8_t event) void menuProcExposAll(uint8_t event)

View file

@ -43,23 +43,27 @@
#define EEPROM_VER_r751 5 #define EEPROM_VER_r751 5
#define EEPROM_VER 201 #define EEPROM_VER 201
typedef struct t_TrainerMix { #ifndef PACK
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#endif
PACK(typedef struct t_TrainerMix {
uint8_t srcChn:6; // 0-7 = ch1-8 uint8_t srcChn:6; // 0-7 = ch1-8
uint8_t mode:2; // off,add-mode,subst-mode uint8_t mode:2; // off,add-mode,subst-mode
int8_t studWeight; int8_t studWeight;
} __attribute__((packed)) TrainerMix; // }) TrainerMix; //
typedef struct t_TrainerData { PACK(typedef struct t_TrainerData {
int16_t calib[4]; int16_t calib[4];
TrainerMix mix[4]; TrainerMix mix[4];
} __attribute__((packed)) TrainerData; }) TrainerData;
typedef struct t_FrSkyRSSIAlarm { PACK(typedef struct t_FrSkyRSSIAlarm {
uint8_t level:2; uint8_t level:2;
int8_t value:6; int8_t value:6;
} __attribute__((packed)) FrSkyRSSIAlarm; }) FrSkyRSSIAlarm;
typedef struct t_EEGeneral { PACK(typedef struct t_EEGeneral {
uint8_t myVers; uint8_t myVers;
int16_t calibMid[7]; int16_t calibMid[7];
int16_t calibSpanNeg[7]; int16_t calibSpanNeg[7];
@ -91,11 +95,11 @@ typedef struct t_EEGeneral {
uint8_t templateSetup; //RETA order according to chout_ar array uint8_t templateSetup; //RETA order according to chout_ar array
int8_t PPM_Multiplier; int8_t PPM_Multiplier;
FrSkyRSSIAlarm frskyRssiAlarms[2]; FrSkyRSSIAlarm frskyRssiAlarms[2];
} __attribute__((packed)) EEGeneral; }) EEGeneral;
// eeprom modelspec // eeprom modelspec
typedef struct t_ExpoData { PACK(typedef struct t_ExpoData {
uint8_t mode:2; // 0=end, 1=pos, 2=neg, 3=both uint8_t mode:2; // 0=end, 1=pos, 2=neg, 3=both
uint8_t chn:2; uint8_t chn:2;
uint8_t curve:4; // 0=no curve, 1-6=std curves, 7-10=CV1-CV4, 11-15=CV9-CV13 uint8_t curve:4; // 0=no curve, 1-6=std curves, 7-10=CV1-CV4, 11-15=CV9-CV13
@ -104,18 +108,15 @@ typedef struct t_ExpoData {
uint8_t negPhase:1; uint8_t negPhase:1;
uint8_t weight:7; uint8_t weight:7;
int8_t expo; int8_t expo;
} __attribute__((packed)) ExpoData; }) ExpoData;
typedef struct t_LimitData { PACK(typedef struct t_LimitData {
int8_t min; int8_t min;
int8_t max; int8_t max;
bool revert; bool revert;
int16_t offset; int16_t offset;
} __attribute__((packed)) LimitData; }) LimitData;
typedef struct t_MixData {
uint8_t destCh:5; // 0, 1..NUM_CHNOUT
uint8_t mixWarn:3; // mixer warning
#define MIX_P1 5 #define MIX_P1 5
#define MIX_P2 6 #define MIX_P2 6
#define MIX_P3 7 #define MIX_P3 7
@ -124,6 +125,14 @@ typedef struct t_MixData {
#define MIX_CYC1 10 #define MIX_CYC1 10
#define MIX_CYC2 11 #define MIX_CYC2 11
#define MIX_CYC3 12 #define MIX_CYC3 12
#define MLTPX_ADD 0
#define MLTPX_MUL 1
#define MLTPX_REP 2
PACK(typedef struct t_MixData {
uint8_t destCh:5; // 0, 1..NUM_CHNOUT
uint8_t mixWarn:3; // mixer warning
uint8_t srcRaw; // uint8_t srcRaw; //
int8_t weight; int8_t weight;
int8_t swtch; int8_t swtch;
@ -133,24 +142,21 @@ typedef struct t_MixData {
uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle) uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown:4; // 0 nichts uint8_t speedDown:4; // 0 nichts
uint8_t carryTrim:1; uint8_t carryTrim:1;
#define MLTPX_ADD 0
#define MLTPX_MUL 1
#define MLTPX_REP 2
uint8_t mltpx:3; // multiplex method 0=+ 1=* 2=replace uint8_t mltpx:3; // multiplex method 0=+ 1=* 2=replace
int8_t phase:4; // -5=!FP4, 0=normal, 5=FP4 int8_t phase:4; // -5=!FP4, 0=normal, 5=FP4
int8_t sOffset; int8_t sOffset;
} __attribute__((packed)) MixData; }) MixData;
typedef struct t_CustomSwData { // Custom Switches data PACK(typedef struct t_CustomSwData { // Custom Switches data
int8_t v1; //input int8_t v1; //input
int8_t v2; //offset int8_t v2; //offset
uint8_t func; uint8_t func;
} __attribute__((packed)) CustomSwData; }) CustomSwData;
typedef struct t_SafetySwData { // Safety Switches data PACK(typedef struct t_SafetySwData { // Safety Switches data
int8_t swtch; int8_t swtch;
int8_t val; int8_t val;
} __attribute__((packed)) SafetySwData; }) SafetySwData;
#define FUNC_TRAINER 1 #define FUNC_TRAINER 1
#define FUNC_TRAINER_RUD 2 #define FUNC_TRAINER_RUD 2
@ -162,12 +168,12 @@ typedef struct t_SafetySwData { // Safety Switches data
#define FUNC_VIEW_TELEMETRY 8 #define FUNC_VIEW_TELEMETRY 8
#define FUNC_LAST 8 #define FUNC_LAST 8
typedef struct t_FuncSwData { // Function Switches data PACK(typedef struct t_FuncSwData { // Function Switches data
int8_t swtch; //input int8_t swtch; //input
uint8_t func; uint8_t func;
} __attribute__((packed)) FuncSwData; }) FuncSwData;
typedef struct t_FrSkyChannelData { PACK(typedef struct t_FrSkyChannelData {
uint8_t ratio; // 0.0 means not used, 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc. uint8_t ratio; // 0.0 means not used, 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t type:4; // channel unit (0=volts, ...) uint8_t type:4; // channel unit (0=volts, ...)
int8_t offset:4; // calibration offset. Signed 0.1V steps. EG. -4 to substract 0.4V int8_t offset:4; // calibration offset. Signed 0.1V steps. EG. -4 to substract 0.4V
@ -177,13 +183,13 @@ typedef struct t_FrSkyChannelData {
uint8_t spare:2; uint8_t spare:2;
int8_t barMin; // minimum for bar display int8_t barMin; // minimum for bar display
uint8_t barMax; // ditto for max display (would usually = ratio) uint8_t barMax; // ditto for max display (would usually = ratio)
} __attribute__((packed)) FrSkyChannelData; }) FrSkyChannelData;
typedef struct t_FrSkyData { PACK(typedef struct t_FrSkyData {
FrSkyChannelData channels[2]; FrSkyChannelData channels[2];
} __attribute__((packed)) FrSkyData; }) FrSkyData;
typedef struct t_SwashRingData { // Swash Ring data PACK(typedef struct t_SwashRingData { // Swash Ring data
uint8_t invertELE:1; uint8_t invertELE:1;
uint8_t invertAIL:1; uint8_t invertAIL:1;
uint8_t invertCOL:1; uint8_t invertCOL:1;
@ -195,20 +201,21 @@ typedef struct t_SwashRingData { // Swash Ring data
uint8_t lim; // 0 mean off 100 full deflection uint8_t lim; // 0 mean off 100 full deflection
uint8_t chX; // 2 channels to limit uint8_t chX; // 2 channels to limit
uint8_t chY; // 2 channels to limit */ uint8_t chY; // 2 channels to limit */
} __attribute__((packed)) SwashRingData; }) SwashRingData;
typedef struct t_PhaseData {
#define TRIM_EXTENDED_MAX 500 #define TRIM_EXTENDED_MAX 500
#define TRIM_EXTENDED_MIN (-TRIM_EXTENDED_MAX) #define TRIM_EXTENDED_MIN (-TRIM_EXTENDED_MAX)
#define TRIM_MAX 125 #define TRIM_MAX 125
#define TRIM_MIN (-TRIM_MAX) #define TRIM_MIN (-TRIM_MAX)
PACK(typedef struct t_PhaseData {
int8_t trim[4]; // -500..500 => trim value, 501 => use trim of phase 0, 502, 503, 504 => use trim of phases 1|2|3|4 instead int8_t trim[4]; // -500..500 => trim value, 501 => use trim of phase 0, 502, 503, 504 => use trim of phases 1|2|3|4 instead
int8_t trim_ext:8; // 2 less significant extra bits per trim (10bits trims) int8_t trim_ext:8; // 2 less significant extra bits per trim (10bits trims)
int8_t swtch; // swtch of phase[0] is not used int8_t swtch; // swtch of phase[0] is not used
char name[6]; char name[6];
uint8_t fadeIn:4; uint8_t fadeIn:4;
uint8_t fadeOut:4; uint8_t fadeOut:4;
} __attribute__((packed)) PhaseData; }) PhaseData;
#define MAX_MODELS 16 #define MAX_MODELS 16
#define MAX_PHASES 5 #define MAX_PHASES 5
@ -221,14 +228,14 @@ typedef struct t_PhaseData {
#define NUM_CSW 12 // number of custom switches #define NUM_CSW 12 // number of custom switches
#define NUM_FSW 12 // number of functions assigned to switches #define NUM_FSW 12 // number of functions assigned to switches
typedef struct t_TimerData { PACK(typedef struct t_TimerData {
int8_t mode; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw int8_t mode; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
uint16_t val:14; uint16_t val:14;
uint8_t persistent:1; uint8_t persistent:1;
uint8_t dir:1; // 0=>Count Down, 1=>Count Up uint8_t dir:1; // 0=>Count Down, 1=>Count Up
} __attribute__((packed)) TimerData; }) TimerData;
typedef struct t_ModelData { PACK(typedef struct t_ModelData {
char name[10]; // 10 must be first for eeLoadModelName char name[10]; // 10 must be first for eeLoadModelName
TimerData timer1; // TODO timers array TimerData timer1; // TODO timers array
uint8_t protocol:3; uint8_t protocol:3;
@ -255,7 +262,7 @@ typedef struct t_ModelData {
PhaseData phaseData[MAX_PHASES]; PhaseData phaseData[MAX_PHASES];
FrSkyData frsky; FrSkyData frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
} __attribute__((packed)) ModelData; }) ModelData;
extern EEGeneral g_eeGeneral; extern EEGeneral g_eeGeneral;
extern ModelData g_model; extern ModelData g_model;

View file

@ -129,7 +129,7 @@ ISR(TIMER1_COMPA_vect) //2MHz pulse generation
//uint16_t PPM_gap = 300 * 2; //Stoplen *2 //uint16_t PPM_gap = 300 * 2; //Stoplen *2
//uint16_t PPM_frame ; //uint16_t PPM_frame ;
inline void __attribute__ ((always_inline)) setupPulsesPPM() // changed 10/05/2010 by dino Issue 128 FORCEINLINE void setupPulsesPPM() // changed 10/05/2010 by dino Issue 128
{ {
#define PPM_CENTER 1200*2 #define PPM_CENTER 1200*2
int16_t PPM_range = g_model.extendedLimits ? 640*2 : 512*2; //range of 0.7..1.7msec int16_t PPM_range = g_model.extendedLimits ? 640*2 : 512*2; //range of 0.7..1.7msec

View file

@ -19,8 +19,14 @@
* *
*/ */
#ifndef __GNUC__
#include <windows.h>
#define sleep(x) Sleep(x)
#else
#include <unistd.h> #include <unistd.h>
#include <time.h> #define sleep(x) usleep(1000*x)
#endif
#include <ctype.h> #include <ctype.h>
#include "simpgmspace.h" #include "simpgmspace.h"
#include "lcd.h" #include "lcd.h"
@ -75,7 +81,7 @@ void *eeprom_write_function(void *)
perror("error in fseek"); perror("error in fseek");
if (fwrite(eeprom_buffer_data, 1, 1, fp) != 1) if (fwrite(eeprom_buffer_data, 1, 1, fp) != 1)
perror("error in fwrite"); perror("error in fwrite");
usleep(5000/*5ms*/); sleep(5/*ms*/);
} }
else { else {
memcpy(&eeprom[eeprom_pointer], eeprom_buffer_data, 1); memcpy(&eeprom[eeprom_pointer], eeprom_buffer_data, 1);
@ -117,15 +123,16 @@ void *main_thread(void *)
while (main_thread_running) { while (main_thread_running) {
perMain(); perMain();
usleep(1000); sleep(1/*ms*/);
} }
return NULL;
#ifdef SIMU_EXCEPTIONS #ifdef SIMU_EXCEPTIONS
} }
catch (...) { catch (...) {
main_thread_running = 0; main_thread_running = 0;
} }
#endif #endif
return NULL;
} }
pthread_t main_thread_pid; pthread_t main_thread_pid;

View file

@ -27,7 +27,7 @@ extern char * main_thread_error;
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#ifdef WIN32 #if defined(WIN32) || !defined(__GNUC__)
#define write_backtrace(output) #define write_backtrace(output)
#else #else
#include <execinfo.h> #include <execinfo.h>