user_interface.cpp
Go to the documentation of this file.
1 /*
2 MIT LICENSE
3 
4 Copyright 2014-2019 Inertial Sense, Inc. - http://inertialsense.com
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
7 
8 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT, IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 */
12 
13 #include <asf.h>
14 #include "globals.h"
15 #include "sd_card_logger.h"
16 #include "communications.h"
17 #include "user_interface.h"
18 
19 
26 
29 
31 {
33 }
34 
35 
36 static void on_cfg_button_pressed()
37 {
38  // Indicate button is pressed by turning off LED
39  LED_CFG_OFF();
40 }
41 
42 static void on_cfg_button_release()
43 {
44  // Increment config
46 
47  switch(g_flashCfg->cbPreset)
48  { // Skip these configs
49 #ifndef CONF_BOARD_SPI_ATWINC_WIFI
51 #endif
52 #ifndef CONF_BOARD_SPI_UINS
54 #endif
56  }
57 
58  // Restart config
60  {
61  g_flashCfg->cbPreset = 1;
62  }
63 
69 }
70 
71 static void on_log_button_pressed()
72 {
73  // Indicate button is pressed by turning off LED
74  LED_LOG_OFF();
75 }
76 
77 static void on_log_button_release()
78 {
79  if( logger_ready() )
80  {
82  {
84  }
85 
86  // Toggle logger enable
88  }
89 }
90 
92 { // Reset uINS
94 }
95 
97 { // De-assert uINS reset
100 }
101 
102 
103 #define BUTTON_DEBOUNCE_TIME_MS 100
104 void step_user_interface(uint32_t time_ms)
105 {
106  bool cfgBtnDown = !ioport_get_pin_level(BUTTON_CFG_PIN);
107  bool logBtnDown = !ioport_get_pin_level(BUTTON_LOG_PIN);
108  static bool bothBtnsDown = false;
109  static bool cfgBtnDownLast = cfgBtnDown;
110  static bool logBtnDownLast = logBtnDown;
111  static bool bothBtnsDownLast = bothBtnsDown;
112  static uint32_t cfgBtnTimeMs = 0; // for button debouncing
113  static uint32_t logBtnTimeMs = 0;
114  static uint32_t bothBtnTimeMs = 0;
115  static bool ignoreEstopBtnRelease=false;
116  static bool ignorePauseBtnRelease=false;
117 
118  if (cfgBtnDownLast != cfgBtnDown && time_ms-cfgBtnTimeMs > BUTTON_DEBOUNCE_TIME_MS)
119  { // Button toggled
120  cfgBtnDownLast = cfgBtnDown;
121  cfgBtnTimeMs = time_ms;
122  if(cfgBtnDown)
123  {
125  }
126  else
127  {
128  if(!ignoreEstopBtnRelease)
129  {
131  }
132  ignoreEstopBtnRelease = false;
133  }
134  }
135 
136  if(logBtnDownLast != logBtnDown && time_ms-logBtnTimeMs > BUTTON_DEBOUNCE_TIME_MS)
137  { // Button toggled
138  logBtnDownLast = logBtnDown;
139  logBtnTimeMs = time_ms;
140  if(logBtnDown)
141  {
143  }
144  else
145  {
146  if(!ignorePauseBtnRelease)
147  {
149  }
150  ignorePauseBtnRelease = false;
151  }
152  }
153 
154  // Only toggle down on both down and up on both up.
155  if (bothBtnsDown)
156  {
157  if(!cfgBtnDown && !logBtnDown)
158  {
159  bothBtnsDown = false;
160  }
161  }
162  else
163  {
164  if(cfgBtnDown && logBtnDown)
165  {
166  bothBtnsDown = true;
167  }
168  }
169 
170  if(bothBtnsDownLast != bothBtnsDown && time_ms-bothBtnTimeMs > BUTTON_DEBOUNCE_TIME_MS)
171  { // Both buttons toggled
172  bothBtnsDownLast = bothBtnsDown;
173  bothBtnTimeMs = time_ms;
174  if(bothBtnsDown)
175  {
177  ignoreEstopBtnRelease = true;
178  ignorePauseBtnRelease = true;
179  }
180  else
181  {
183  }
184  }
185 
186  if( logger_ready() )
187  { // Handle logger commands via g_status.loggerMode
189  {
190  switch(g_status.loggerMode)
191  {
192  case EVB2_LOG_CMD_START: enable_logger(true); break;
193  case EVB2_LOG_CMD_STOP: enable_logger(false); break; // disable logger
194  }
196  }
197  }
198  else
199  {
200  if(g_loggerEnabled==1)
201  { // Disable logger
202  enable_logger(false);
203  }
204  }
205 }
206 
207 
209 {
216 
219 }
220 
222  VoidFuncPtrVoid fpCfgButtonPressed, VoidFuncPtrVoid fpCfgButtonRelease,
223  VoidFuncPtrVoid fpLogButtonPressed, VoidFuncPtrVoid fpLogButtonRelease,
224  VoidFuncPtrVoid fpBothButtonsPressed, VoidFuncPtrVoid fpBothButtonsRelease )
225 {
226  s_funcPtrCfgButtonPressed = fpCfgButtonPressed;
227  s_funcPtrCfgButtonRelease = fpCfgButtonRelease;
228  s_funcPtrLogButtonPressed = fpLogButtonPressed;
229  s_funcPtrLogButtonRelease = fpLogButtonRelease;
230  s_funcPtrBothButtonsPressed = fpBothButtonsPressed;
231  s_funcPtrBothButtonsRelease = fpBothButtonsRelease;
232 }
233 
235 {
236  s_funcPtrRefreshLedCfg = fpLedCfg;
237  s_funcPtrRefreshLedLog = fpLedLog;
238 }
239 
241 {
243 }
244 
246 {
248 }
249 
uint32_t bits
Definition: data_sets.h:3154
void refresh_led_cfg(void)
Definition: init.c:355
static VoidFuncPtrVoid s_funcPtrLogButtonRelease
void evbUiButtonCallbacks(VoidFuncPtrVoid fpCfgButtonPressed, VoidFuncPtrVoid fpCfgButtonRelease, VoidFuncPtrVoid fpLogButtonPressed, VoidFuncPtrVoid fpLogButtonRelease, VoidFuncPtrVoid fpBothButtonsPressed, VoidFuncPtrVoid fpBothButtonsRelease)
#define LED_LOG_OFF()
Definition: user_board.h:270
static VoidFuncPtrVoid s_funcPtrBothButtonsRelease
uint32_t evbStatus
Definition: data_sets.h:3069
static void on_both_buttons_release()
#define LED_CFG_OFF()
Definition: user_board.h:249
static void on_log_button_pressed()
static void on_cfg_button_pressed()
#define NULL
Definition: nm_bsp.h:52
static VoidFuncPtrVoid s_funcPtrRefreshLedCfg
void evbUiRefreshLedCfg()
void evbUiRefreshLedLog()
void uINS_stream_enable_PPD(void)
uint32_t flash_write_needed
Definition: globals.h:51
void(* VoidFuncPtrVoid)(void)
Definition: globals.h:36
static bool ioport_get_pin_level(ioport_pin_t pin)
Get current value of an IOPORT pin, which has been configured as an input.
Definition: ioport.h:301
static void on_cfg_button_release()
void refresh_led_log(void)
void com_bridge_apply_preset(evb_flash_cfg_t *cfg)
Definition: globals.c:147
#define INS_RESET_PIN_PIN
Definition: user_board.h:110
static void on_log_button_release()
evb_status_t g_status
Definition: globals.c:21
uint8_t cbPreset
Definition: data_sets.h:3142
static void on_both_buttons_pressed()
#define BUTTON_CFG_PIN
Definition: user_board.h:289
#define BUTTON_DEBOUNCE_TIME_MS
#define ioport_set_pin_input_mode(pin, mode, sense)
Set input mode for one single IOPORT pin. It will configure port mode and disable pin mode (but enabl...
Definition: init.c:64
evb_flash_cfg_t * g_flashCfg
Definition: globals.c:22
uint32_t flash_write_enable
Definition: globals.h:53
static VoidFuncPtrVoid s_funcPtrCfgButtonRelease
void enable_logger(bool enable)
bool g_loggerEnabled
Definition: globals.c:33
bool logger_ready()
#define ioport_set_pin_output_mode(pin, level)
Definition: user_board.h:331
void step_user_interface(uint32_t time_ms)
void evbUiLedCallbacks(VoidFuncPtrVoid fpLedCfg, VoidFuncPtrVoid fpLedLog)
static VoidFuncPtrVoid s_funcPtrLogButtonPressed
#define BUTTON_LOG_PIN
Definition: user_board.h:292
uint32_t loggerMode
Definition: data_sets.h:3072
static VoidFuncPtrVoid s_funcPtrRefreshLedLog
Autogenerated API include file for the Atmel Software Framework (ASF)
void board_IO_config(void)
Definition: init.c:376
void evbUiDefaults()
nvr_manage_t g_nvr_manage_config
Definition: globals.c:23
static VoidFuncPtrVoid s_funcPtrCfgButtonPressed
static VoidFuncPtrVoid s_funcPtrBothButtonsPressed


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:58