2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
29 #ifdef USE_PERSISTENT_STATS
32 #include "cms/cms_types.h"
33 #include "cms/cms_menu_persistent_stats.h"
35 #include "config/config.h"
38 uint32_t stats_total_flights
;
39 uint32_t stats_total_time_s
;
40 uint32_t stats_total_dist_m
;
41 int8_t stats_min_armed_time_s
;
43 static const void *cmsx_PersistentStats_onEnter(displayPort_t
*pDisp
)
47 stats_total_flights
= statsConfig()->stats_total_flights
;
48 stats_total_time_s
= statsConfig()->stats_total_time_s
;
49 stats_total_dist_m
= statsConfig()->stats_total_dist_m
;
50 stats_min_armed_time_s
= statsConfig()->stats_min_armed_time_s
;
55 static const void *cmsx_PersistentStats_onExit(displayPort_t
*pDisp
, const OSD_Entry
*self
)
60 statsConfigMutable()->stats_total_flights
= stats_total_flights
;
61 statsConfigMutable()->stats_total_time_s
= stats_total_time_s
;
62 statsConfigMutable()->stats_total_dist_m
= stats_total_dist_m
;
63 statsConfigMutable()->stats_min_armed_time_s
= stats_min_armed_time_s
;
68 static const void *cmsx_ResetStats(displayPort_t
*pDisplay
, const void *ptr
)
72 stats_total_flights
= 0;
73 stats_total_time_s
= 0;
74 stats_total_dist_m
= 0;
76 displayClearScreen(pDisplay
);
77 displayRedraw(pDisplay
);
82 static const OSD_Entry cmsx_menuPersistentStatsEntries
[] =
84 {"-- PERSISTENT STATS --", OME_Label
, NULL
, NULL
},
85 {"FLIGHTS", OME_UINT32
, NULL
, &(OSD_UINT32_t
){ &stats_total_flights
, 0, UINT32_MAX
, 1}},
86 {"TIME(sec)", OME_UINT32
, NULL
, &(OSD_UINT32_t
){ &stats_total_time_s
, 0, UINT32_MAX
, 1}},
87 {"DIST(m)", OME_UINT32
, NULL
, &(OSD_UINT32_t
){ &stats_total_dist_m
, 0, UINT32_MAX
, 1}},
88 {"RESET STATS", OME_Funcall
, cmsx_ResetStats
, NULL
},
89 {"--- SETTINGS ---", OME_Label
, NULL
, NULL
},
90 {"MIN ARMED TIME(sec)", OME_INT8
, NULL
, &(OSD_INT8_t
){ &stats_min_armed_time_s
, -1, INT8_MAX
, 1}},
92 {"BACK", OME_Back
, NULL
, NULL
},
93 { NULL
, OME_END
, NULL
, NULL
}
96 CMS_Menu cmsx_menuPersistentStats
= {
98 .GUARD_text
= "PRESSTATS",
99 .GUARD_type
= OME_MENU
,
101 .onEnter
= cmsx_PersistentStats_onEnter
,
102 .onExit
= cmsx_PersistentStats_onExit
,
103 .onDisplayUpdate
= NULL
,
104 .entries
= cmsx_menuPersistentStatsEntries