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 "user_interface.h"
17 
18 
19 static bool s_ignoreCfgButtonRelease=false;
20 static bool s_ignoreLogButtonRelease=false;
21 
22 
23 static void on_cfg_button_pressed()
24 {
25  // Indicate button is pressed by turning off LED
26  LED_CFG_OFF();
27 }
28 
29 
30 static void on_cfg_button_release()
31 {
32  // Increment config
34 
35  switch(g_flashCfg->cbPreset)
36  { // Skip these configs
37 #ifndef CONF_BOARD_SPI_ATWINC_WIFI
39 #endif
40 #ifndef CONF_BOARD_SPI_UINS
42 #endif
44  }
45 
46  // Restart config
48  {
49  g_flashCfg->cbPreset = 1;
50  }
51 
56  refresh_CFG_LED();
57 }
58 
59 
61 {
63 }
64 
65 
66 static void on_log_button_pressed()
67 {
68  // Indicate button is pressed by turning off LED
69  LED_LOG_OFF();
70 }
71 
72 
73 static void on_log_button_release()
74 {
75  if( logger_ready() )
76  {
77  // Toggle logger enable
79 // if(g_loggerEnabled){ g_enableLogger = -1; }
80 // else{ g_enableLogger = 1; }
81  }
82 }
83 
84 
86 { // Reset uINS
90 }
91 
92 
94 { // De-assert uINS reset
97 }
98 
99 
101 {
102  bool cfgButtonDown = !ioport_get_pin_level(BUTTON_CFG_PIN);
103  bool logButtonDown = !ioport_get_pin_level(BUTTON_LOG_PIN);
104  bool bothButtonsDown = cfgButtonDown && logButtonDown;
105  static bool cfgButtonDownLast = cfgButtonDown;
106  static bool logButtonDownLast = logButtonDown;
107  static bool bothButtonsDownLast = bothButtonsDown;
108 
109  if(cfgButtonDownLast != cfgButtonDown)
110  { // Button toggled
111  cfgButtonDownLast = cfgButtonDown;
112  if(cfgButtonDown)
113  {
115  }
116  else
117  {
119  {
121  }
122  s_ignoreCfgButtonRelease = false;
123  }
124  }
125 
126  if(logButtonDownLast != logButtonDown)
127  { // Button toggled
128  logButtonDownLast = logButtonDown;
129  if(logButtonDown)
130  {
132  }
133  else
134  {
136  {
138  }
139  s_ignoreLogButtonRelease = false;
140  }
141  }
142 
143  if(bothButtonsDownLast != bothButtonsDown)
144  { // Both buttons toggled
145  bothButtonsDownLast = bothButtonsDown;
146  if(bothButtonsDown){ on_both_buttons_pressed(); }
147  else{ on_both_buttons_release(); }
148  }
149 
150  if( logger_ready() )
151  { // Handle logger commands via g_status.loggerMode
153  {
154  switch(g_status.loggerMode)
155  {
156  case EVB2_LOG_CMD_START: enable_logger(true); break;
157  case EVB2_LOG_CMD_STOP: enable_logger(false); break; // disable logger
158  }
160  }
161  }
162  else
163  {
164  if(g_loggerEnabled==1)
165  { // Disable logger
166  enable_logger(false);
167  }
168  }
169 
170 }
171 
172 
173 
#define LED_LOG_OFF()
Definition: user_board.h:270
uint32_t evbStatus
Definition: data_sets.h:2952
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()
void board_IO_config(void)
Definition: init.c:393
uint32_t flash_write_needed
Definition: globals.h:49
void step_user_interface()
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 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
void refresh_CFG_LED(void)
Definition: init.c:377
uint8_t cbPreset
Definition: data_sets.h:3020
static void on_both_buttons_pressed()
#define BUTTON_CFG_PIN
Definition: user_board.h:289
static bool s_ignoreCfgButtonRelease
static bool s_ignoreLogButtonRelease
#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:88
evb_flash_cfg_t * g_flashCfg
Definition: globals.c:22
uint32_t flash_write_enable
Definition: globals.h:51
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
#define BUTTON_LOG_PIN
Definition: user_board.h:292
uint32_t loggerMode
Definition: data_sets.h:2955
Autogenerated API include file for the Atmel Software Framework (ASF)
nvr_manage_t g_nvr_manage_config
Definition: globals.c:23


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:05