Update cloud build defines (#14080)
[betaflight.git] / src / main / cms / cms_menu_gps_lap_timer.c
blobe0aab8dce146e7db83e016509e3d70edb527c3fc
1 /*
2 * This file is part of Betaflight.
4 * Betaflight is free software. You can redistribute this software
5 * and/or modify this software under the terms of the GNU General
6 * Public License as published by the Free Software Foundation,
7 * either version 3 of the License, or (at your option) any later
8 * version.
10 * Betaflight 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.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this software.
19 * If not, see <http://www.gnu.org/licenses/>.
22 #include <stdbool.h>
23 #include <stdint.h>
24 #include <string.h>
25 #include <ctype.h>
27 #include "platform.h"
29 #ifdef USE_CMS_GPS_LAP_TIMER_MENU
31 #include "cli/settings.h"
33 #include "cms/cms.h"
34 #include "cms/cms_types.h"
36 #include "config/config.h"
38 #include "fc/gps_lap_timer.h"
40 static uint16_t gpsLapTimerConfig_minimumLapTimeSeconds;
41 static uint8_t gpsLapTimerConfig_gateToleranceM;
43 static const void *cms_menuGpsLapTimerOnEnter(displayPort_t *pDisp)
45 UNUSED(pDisp);
47 gpsLapTimerConfig_minimumLapTimeSeconds = gpsLapTimerConfig()->minimumLapTimeSeconds;
48 gpsLapTimerConfig_gateToleranceM = gpsLapTimerConfig()->gateToleranceM;
50 return NULL;
53 static const void *cms_menuGpsLapTimerOnExit(displayPort_t *pDisp, const OSD_Entry *self)
55 UNUSED(pDisp);
56 UNUSED(self);
58 gpsLapTimerConfigMutable()->minimumLapTimeSeconds = gpsLapTimerConfig_minimumLapTimeSeconds;
59 gpsLapTimerConfigMutable()->gateToleranceM = gpsLapTimerConfig_gateToleranceM;
61 return NULL;
64 static const void *cmsStartSetGate(displayPort_t *pDisp)
66 UNUSED(pDisp);
68 gpsLapTimerStartSetGate();
70 return NULL;
73 static const void *cmsEndSetGate(displayPort_t *pDisp, const OSD_Entry *self)
75 UNUSED(pDisp);
76 UNUSED(self);
78 gpsLapTimerEndSetGate();
80 return NULL;
83 static OSD_UINT16_t setGateCMSWaitCount = { &gpsLapTimerData.numberOfSetReadings, 0, 2000, 0 };
84 static OSD_UINT32_t setGateCMSdistCM = { &gpsLapTimerData.distToPointCM, 0, 200, 0 };
86 static const OSD_Entry cmsSetGateMenuEntries[] = {
87 {"SETTING POSITION", OME_Label, NULL, NULL},
89 {"READINGS", OME_UINT16 | DYNAMIC, NULL, &setGateCMSWaitCount},
90 {"DISTANCE(CM)", OME_UINT32 | DYNAMIC, NULL, &setGateCMSdistCM},
92 {"BACK", OME_Back, NULL, NULL},
93 { NULL, OME_END, NULL, NULL}
96 static CMS_Menu cmsSetGateMenu = {
97 #ifdef CMS_MENU_DEBUG
98 .GUARD_text = "GATESET",
99 .GUARD_type = OME_MENU,
100 #endif
101 .onEnter = cmsStartSetGate,
102 .onExit = cmsEndSetGate,
103 .onDisplayUpdate = NULL,
104 .entries = cmsSetGateMenuEntries,
107 const OSD_Entry cms_menuGpsLapTimerEntries[] =
109 {"--- GPS LAP TIMER ---", OME_Label, NULL, NULL},
111 {"SET POSITION", OME_Funcall, cmsMenuChange, &cmsSetGateMenu},
112 {"GATE RADIUS(M)", OME_UINT8, NULL, &(OSD_UINT8_t){&gpsLapTimerConfig_gateToleranceM, 1, 100, 1}},
113 {"MIN LAP SECONDS", OME_UINT16, NULL, &(OSD_UINT16_t){&gpsLapTimerConfig_minimumLapTimeSeconds, 0, 3000, 1}},
115 {"BACK", OME_Back, NULL, NULL},
116 {NULL, OME_END, NULL, NULL}};
118 CMS_Menu cms_menuGpsLapTimer = {
119 #ifdef CMS_MENU_DEBUG
120 .GUARD_text = "MENUGPSLAPTIMER",
121 .GUARD_type = OME_MENU,
122 #endif
123 .onEnter = cms_menuGpsLapTimerOnEnter,
124 .onExit = cms_menuGpsLapTimerOnExit,
125 .onDisplayUpdate = NULL,
126 .entries = cms_menuGpsLapTimerEntries,
129 #endif // CMS_GPS_LAP_TIMER_MENU