removed PrefixPath debug line
[opentx.git] / companion / src / simulation / simulatorimport.h
blob7cf338c911b0222d454d132900a8c44e941c1319
1 /*
2 * Author - Bertrand Songis <bsongis@gmail.com>
3 *
4 * Based on th9x -> http://code.google.com/p/th9x/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #include <stdint.h>
19 #if !defined(NUM_LOGICAL_SWITCH) && defined(NUM_CSW)
20 #define NUM_LOGICAL_SWITCH NUM_CSW
21 #endif
23 #ifdef INIT_IMPORT
24 #undef INIT_IMPORT
25 #ifdef FRSKY
26 frskyStreaming = 20;
27 #endif
28 #endif
30 #ifdef SETVALUES_IMPORT
31 #undef SETVALUES_IMPORT
32 for (int i=0; i<NUM_STICKS; i++)
33 g_anas[i] = inputs.sticks[i];
34 for (int i=0; i<NUM_POTS; i++)
35 g_anas[NUM_STICKS+i] = inputs.pots[i];
36 for (int i=0; i<C9X_NUM_SWITCHES; i++)
37 simuSetSwitch(i, inputs.switches[i]);
38 for (int i=0; i<C9X_NUM_KEYS; i++)
39 simuSetKey(i, inputs.keys[i]);
40 for (int i=0; i<NUM_STICKS*2; i++)
41 simuSetTrim(i, inputs.trims[i]);
43 #ifdef PCBGRUVIN9X
44 // rotary encoders
45 pind = 0;
46 if (inputs.rotenc) pind |= 0x20;
47 #endif
49 #if defined(PCBSKY9X)
50 if (inputs.rotenc) PIOB->PIO_PDSR &= ~0x40; else PIOB->PIO_PDSR |= 0x40;
51 #endif
53 #if defined(PCBTARANIS) && defined(REV9E)
54 if (inputs.rotenc) simuSetKey(KEY_ENTER, true);
55 #endif
56 #endif
58 #ifdef GETVALUES_IMPORT
59 #undef GETVALUES_IMPORT
60 memset(outputs.chans, 0, sizeof(outputs.chans));
61 for (unsigned int i=0; i<DIM(g_chans512); i++)
62 outputs.chans[i] = g_chans512[i];
63 for (int i=0; i<NUM_LOGICAL_SWITCH; i++)
64 #if defined(BOLD_FONT)
65 outputs.vsw[i] = getSwitch(SWSRC_SW1+i);
66 #else
67 outputs.vsw[i] = getSwitch(SWSRC_SW1+i, 0);
68 #endif
69 #ifdef GVAR_VALUE // defined(GVARS)
70 /* TODO it could be a good idea instead of getPhase() / getPhaseName() outputs.phase = getFlightMode(); */
71 #if defined(GVARS)
72 for (int fm=0; fm<MAX_FLIGHT_MODES; fm++) {
73 for (int gv=0; gv<MAX_GVARS; gv++) {
74 outputs.gvars[fm][gv] = GVAR_VALUE(gv, getGVarFlightPhase(fm, gv));
77 #endif
78 #endif
79 #endif //GETVALUES_IMPORT
81 #ifdef LCDCHANGED_IMPORT
82 #undef LCDCHANGED_IMPORT
83 if (lcd_refresh) {
84 lightEnable = isBacklightEnable();
85 lcd_refresh = false;
86 return true;
88 return false;
89 #endif
91 #ifdef TIMER10MS_IMPORT
92 #undef TIMER10MS_IMPORT
93 if (!main_thread_running)
94 return false;
95 per10ms();
96 return true;
97 #endif
99 #ifdef GETLCD_IMPORT
100 #undef GETLCD_IMPORT
101 return (::uint8_t *)lcd_buf;
102 #endif
104 #ifdef GETERROR_IMPORT
105 #undef GETERROR_IMPORT
106 return main_thread_error;
107 #endif
109 #ifdef SETTRAINER_IMPORT
110 #undef SETTRAINER_IMPORT
111 ppmInValid = 100;
112 g_ppmIns[inputNumber] = LIMIT< ::int16_t>(-512, value, 512);
113 #endif