5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
23 uint8_t storageDirtyMsk
;
24 tmr10ms_t storageDirtyTime10ms
;
26 #if defined(RAMBACKUP)
27 uint8_t rambackupDirtyMsk
;
28 tmr10ms_t rambackupDirtyTime10ms
;
31 void storageDirty(uint8_t msk
)
33 storageDirtyMsk
|= msk
;
34 storageDirtyTime10ms
= get_tmr10ms();
36 #if defined(RAMBACKUP)
37 rambackupDirtyMsk
= storageDirtyMsk
;
38 rambackupDirtyTime10ms
= storageDirtyTime10ms
;
45 watchdogSuspend(500/*5s*/);
52 if (pulsesStarted()) {
56 pauseMixerCalculations();
58 #if defined(PCBTARANIS) || defined(PCBHORUS)
59 static void fixUpModel()
61 // Ensure that when rfProtocol is RF_PROTO_OFF the type of the module is MODULE_TYPE_NONE
62 if (g_model
.moduleData
[INTERNAL_MODULE
].type
== MODULE_TYPE_XJT
&& g_model
.moduleData
[INTERNAL_MODULE
].rfProtocol
== RF_PROTO_OFF
)
63 g_model
.moduleData
[INTERNAL_MODULE
].type
= MODULE_TYPE_NONE
;
67 void postModelLoad(bool alarms
)
69 #if defined(PCBTARANIS) || defined(PCBHORUS)
75 customFunctionsReset();
80 for (int i
=0; i
<MAX_TELEMETRY_SENSORS
; i
++) {
81 TelemetrySensor
& sensor
= g_model
.telemetrySensors
[i
];
82 if (sensor
.type
== TELEM_TYPE_CALCULATED
&& sensor
.persistent
) {
83 telemetryItems
[i
].value
= sensor
.persistentValue
;
84 telemetryItems
[i
].lastReceived
= TELEMETRY_VALUE_OLD
; // #3595: make value visible even before the first new value is received)
91 resumeMixerCalculations();
92 if (pulsesStarted()) {
102 #if defined(TELEMETRY_FRSKY)
106 #if defined(CPUARM) && defined(SDCARD)
107 referenceModelAudioFiles();
110 #if defined(PCBHORUS)
115 LUA_LOAD_MODEL_SCRIPTS();
119 void storageFlushCurrentModel()
124 for (int i
=0; i
<MAX_TELEMETRY_SENSORS
; i
++) {
125 TelemetrySensor
& sensor
= g_model
.telemetrySensors
[i
];
126 if (sensor
.type
== TELEM_TYPE_CALCULATED
&& sensor
.persistent
&& sensor
.persistentValue
!= telemetryItems
[i
].value
) {
127 sensor
.persistentValue
= telemetryItems
[i
].value
;
128 storageDirty(EE_MODEL
);
134 if (g_model
.potsWarnMode
== POTS_WARN_AUTO
) {
135 for (int i
=0; i
<NUM_POTS
+NUM_SLIDERS
; i
++) {
136 if (!(g_model
.potsWarnEnabled
& (1 << i
))) {
137 SAVE_POT_POSITION(i
);
140 storageDirty(EE_MODEL
);