gForceSDK
DeviceSetting.h
Go to the documentation of this file.
1 /*
2 * Copyright 2017, OYMotion Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28 * DAMAGE.
29 *
30 */
38 #pragma once
39 
40 #include "gfTypes.h"
41 #include <cstdio>
42 #include <functional>
43 
44 namespace gf
45 {
46  enum class ResponseResult : GF_UINT32 {
47  RREST_SUCCESS,
48  RREST_NOT_SUPPORT,
49  RREST_BAD_PARAM,
50  RREST_FAILED,
51  RREST_TIMEOUT,
52  };
53 
61  {
62  public:
64  // description
65  virtual GF_RET_CODE getProtocolVer(std::function<void(ResponseResult res, tstring version)> cb) = 0;
66  virtual GF_RET_CODE getFeatureMap(std::function<void(ResponseResult res, GF_UINT32 featureMap)> cb) = 0;
67  virtual GF_RET_CODE getDeviceName(std::function<void(ResponseResult res, tstring name)> cb) = 0;
68  virtual GF_RET_CODE getModelNumber(std::function<void(ResponseResult res, tstring modelNumber)> cb) = 0;
69  virtual GF_RET_CODE getSerialNumber(std::function<void(ResponseResult res, tstring serialNumber)> cb) = 0;
70  virtual GF_RET_CODE getHWRevision(std::function<void(ResponseResult res, tstring version)> cb) = 0;
71  virtual GF_RET_CODE getFWRevision(std::function<void(ResponseResult res, tstring version)> cb) = 0;
72  virtual GF_RET_CODE getManufacturerName(std::function<void(ResponseResult res, tstring name)> cb) = 0;
73  virtual GF_RET_CODE getBootloaderVer(std::function<void(ResponseResult res, tstring version)> cb) = 0;
74 
75  public:
77  // control
78  virtual GF_RET_CODE powerOff() = 0;
79  virtual GF_RET_CODE swithToOAD() = 0;
80  virtual GF_RET_CODE systemReset() = 0;
81 
82  enum class DeviceService : GF_UINT32 {
84  HID_Joystick = 0x1,
86  HID_Mouse = 0x2,
88  HID_Vendor = 0x3,
89  };
90  // C.2
91  virtual GF_RET_CODE switchService(DeviceService service) = 0;
92  virtual GF_RET_CODE oadUpgrade(FILE* file, std::function<void(ResponseResult res, GF_UINT32 percentage)> progress) = 0;
93 
94  public:
96  // config
97  // C.6
98  virtual GF_RET_CODE sendTrainingModelData(GF_UINT32 length, GF_UINT8 data[], std::function<void(ResponseResult res, GF_UINT32 percentage)> progress) = 0;
99 
102  DNF_OFF = 0x00000000,
104  DNF_ACCELERATE = 0x00000001,
106  DNF_GYROSCOPE = 0x00000002,
108  DNF_MAGNETOMETER = 0x00000004,
110  DNF_EULERANGLE = 0x00000008,
112  DNF_QUATERNION = 0x00000010,
114  DNF_ROTATIONMATRIX = 0x00000020,
116  DNF_EMG_GESTURE = 0x00000040,
118  DNF_EMG_RAW = 0x00000080,
120  DNF_HID_MOUSE = 0x00000100,
122  DNF_HID_JOYSTICK = 0x00000200,
124  DNF_DEVICE_STATUS = 0x00000400,
126  DNF_ALL = 0xFFFFFFFF,
127  };
128  virtual GF_RET_CODE setDataNotifSwitch(DataNotifFlags flags, std::function<void(ResponseResult res)> cb) = 0;
129 
131  virtual GF_RET_CODE getBatteryLevel( std::function<void(ResponseResult res, GF_UINT32 percentage)> cb) = 0;
132  // C.1
133  virtual GF_RET_CODE getTemperature(std::function<void(ResponseResult res, GF_UINT32 temperature)> cb) = 0;
134 
135  enum class SWOLogLevel : GF_UINT32 {
137  All = 0x00,
139  Debug = 0x01,
141  Info = 0x02,
143  Warn = 0x03,
145  Error = 0x04,
147  Fatal = 0x05,
149  None = 0xFF,
150  };
151  // C.3
152  virtual GF_RET_CODE setLogLevel(SWOLogLevel level, std::function<void(ResponseResult res)> cb) = 0;
153 
156  SWO_MODULE_NONE = 0x00000000,
158  SWO_MODULE_NPI = 0x00000001,
160  SWO_MODULE_IMU = 0x00000002,
162  SWO_MODULE_RTOS = 0x00000004,
164  SWO_MODULE_ADC = 0x00000008,
166  SWO_MODULE_PROFILE = 0x00000010,
168  SWO_MODULE_APP = 0x00000020,
170  SWO_MODULE_ALL = 0xFFFFFFFF,
171  };
172  // C.3
173  virtual GF_RET_CODE setLogModuleEnabled(SWOModule modules, std::function<void(ResponseResult res)> cb) = 0;
174 
175  enum class KernelMsgType : GF_UINT8 {
177  TaskList = 0x00,
179  RuntimeState = 0x01,
180  };
181  // C.3
182  virtual GF_RET_CODE printKernelMsg(KernelMsgType type, std::function<void(ResponseResult res)> cb) = 0;
183 
186  Off = 0x00,
188  On = 0x01,
190  Disable = 0x02,
192  Enable = 0x03,
193  };
194  // C.4
195  virtual GF_RET_CODE vibrateControl(VibrateControlType type, std::function<void(ResponseResult res)> cb) = 0;
196 
199  Off = 0x00,
201  On = 0x01,
202  };
203  // C.5
204  virtual GF_RET_CODE ledControlTest(LedControlTestType type, std::function<void(ResponseResult res)> cb) = 0;
205 
208  Disable = 0x00,
210  Enable = 0x01,
211  };
212  virtual GF_RET_CODE packageIdControl(PackageControlType type, std::function<void(ResponseResult res)> cb) = 0;
213 
214  // C.7
215  virtual GF_RET_CODE getAccelerateCap(std::function<void(ResponseResult res, GF_UINT16 maxSampleRateHz,
216  GF_UINT8 maxScaleRange_g, GF_UINT8 maxPackageDataLength)> cb) = 0;
217  virtual GF_RET_CODE setAccelerateConfig(GF_UINT16 sampleRateHz,
218  GF_UINT8 fullScaleRange_g, GF_UINT8 packageDataLength, std::function<void(ResponseResult res)> cb) = 0;
219  // C.8
220  virtual GF_RET_CODE getGyroscopeCap(std::function<void(ResponseResult res, GF_UINT16 maxSampleRateHz,
221  GF_UINT16 maxScaleRange_dps, GF_UINT8 maxPackageDataLength)> cb) = 0;
222  virtual GF_RET_CODE setGyroscopeConfig(GF_UINT16 sampleRateHz,
223  GF_UINT16 fullScaleRange_dps, GF_UINT8 packageDataLength, std::function<void(ResponseResult res)> cb) = 0;
224  // C.9
225  virtual GF_RET_CODE getMagnetometerCap(std::function<void(ResponseResult res, GF_UINT16 maxSampleRateHz,
226  GF_UINT16 maxScaleRange_uT, GF_UINT8 maxPackageDataLength)> cb) = 0;
227  virtual GF_RET_CODE setMagnetometerConfig(GF_UINT16 sampleRateHz,
228  GF_UINT16 fullScaleRange_uT, GF_UINT8 packageDataLength, std::function<void(ResponseResult res)> cb) = 0;
229  // C.10
230  virtual GF_RET_CODE getEulerangleCap(std::function<void(ResponseResult res, GF_UINT16 maxSampleRateHz)> cb) = 0;
231  virtual GF_RET_CODE setEulerangleConfig(GF_UINT16 sampleRateHz, std::function<void(ResponseResult res)> cb) = 0;
232  // C.11
233  virtual GF_RET_CODE getQuaternionCap(std::function<void(ResponseResult res, GF_UINT16 maxSampleRateHz)> cb) = 0;
234  virtual GF_RET_CODE setQuaternionConfig(GF_UINT16 sampleRateHz, std::function<void(ResponseResult res)> cb) = 0;
235  // C.12
236  virtual GF_RET_CODE getRotationMatrixCap(std::function<void(ResponseResult res, GF_UINT16 maxSampleRateHz)> cb) = 0;
237  virtual GF_RET_CODE setRotationMatrixConfig(GF_UINT16 sampleRateHz, std::function<void(ResponseResult res)> cb) = 0;
238  // C.13
239  virtual GF_RET_CODE getGestureCap(std::function<void(ResponseResult res, GF_SIZE number, const Gesture supportedGestures[])> cb) = 0;
240  virtual GF_RET_CODE setGestureConfig(GF_UINT32 number, Gesture interestingGesture[], std::function<void(ResponseResult res)> cb) = 0;
241 
243  ERDC_CHANNEL_NONE = 0x0000,
244  ERDC_CHANNEL0 = 0x0001,
245  ERDC_CHANNEL1 = 0x0002,
246  ERDC_CHANNEL2 = 0x0004,
247  ERDC_CHANNEL3 = 0x0008,
248  ERDC_CHANNEL4 = 0x0010,
249  ERDC_CHANNEL5 = 0x0020,
250  ERDC_CHANNEL6 = 0x0040,
251  ERDC_CHANNEL7 = 0x0080,
252  ERDC_CHANNEL8 = 0x0100,
253  ERDC_CHANNEL9 = 0x0200,
254  ERDC_CHANNEL10 = 0x0400,
255  ERDC_CHANNEL11 = 0x0800,
256  ERDC_CHANNEL12 = 0x1000,
257  ERDC_CHANNEL13 = 0x2000,
258  ERDC_CHANNEL14 = 0x4000,
259  ERDC_CHANNEL15 = 0x8000,
260  ERDC_CHANNEL_ALL = 0xFFFF,
261  };
262  // C.14
263  virtual GF_RET_CODE getEMGRawDataCap(std::function<void(ResponseResult res, GF_UINT16 maxSampleRateHz,
264  EMGRowDataChannels supportedChannels, GF_UINT8 maxPackageDataLength)> cb) = 0;
265  virtual GF_RET_CODE setEMGRawDataConfig(GF_UINT16 sampleRateHz,
266  EMGRowDataChannels interestingChannels, GF_UINT8 packageDataLength, GF_UINT8 adcResolution,
267  std::function<void(ResponseResult res)> cb) = 0;
268  // C.15
269  virtual GF_RET_CODE getMouseDataCap(std::function<void(ResponseResult res, GF_UINT16 maxSampleRateHz)> cb) = 0;
270  virtual GF_RET_CODE setMouseDataConfig(GF_UINT16 sampleRateHz, std::function<void(ResponseResult res)> cb) = 0;
271  // C.16
272  virtual GF_RET_CODE getJoystickDataCap(std::function<void(ResponseResult res, GF_UINT16 maxSampleRateHz)> cb) = 0;
273  virtual GF_RET_CODE setJoystickDataConfig(GF_UINT16 sampleRateHz, std::function<void(ResponseResult res)> cb) = 0;
274 
277  DSF_NONE = 0x0000,
279  DSF_RECENTER = 0x0001,
281  DSF_USBSTATUS = 0x0002,
283  DSF_MOTIONLESS = 0x0004,
284  };
285  // C.17
286  virtual GF_RET_CODE getDeviceStatusCap(std::function<void(ResponseResult res, DeviceStatusFlags flags)> cb) = 0;
287  virtual GF_RET_CODE setDeviceStatusConfig(DeviceStatusFlags flags, std::function<void(ResponseResult res)> cb) = 0;
288 
289  protected:
292  virtual ~DeviceSetting()
293  {
294  }
295  };
296 
297 }
Motionless Status Event supported.
Definition: DeviceSetting.h:283
None Module Enable.
Definition: DeviceSetting.h:156
Re-center Status Event supported.
Definition: DeviceSetting.h:279
USB plug/unplug Event supported.
Definition: DeviceSetting.h:281
Data Notify All Off.
Definition: DeviceSetting.h:102
Channel 2 supported.
Definition: DeviceSetting.h:247
Channel 1 supported.
Definition: DeviceSetting.h:246
All Modules Enable.
Definition: DeviceSetting.h:170
Magnetometer On(C.9)
Definition: DeviceSetting.h:108
unsigned short GF_UINT16
type definition
Definition: gfTypes.h:69
Channel 13 supported.
Definition: DeviceSetting.h:258
IMU Module Enable.
Definition: DeviceSetting.h:160
Euler Angle On(C.10)
Definition: DeviceSetting.h:110
Data Notify All On.
Definition: DeviceSetting.h:126
Channel 9 supported.
Definition: DeviceSetting.h:254
HID Joystick On(C.16)
Definition: DeviceSetting.h:122
Channel 10 supported.
Definition: DeviceSetting.h:255
RTOS Module Enable.
Definition: DeviceSetting.h:162
Channel 12 supported.
Definition: DeviceSetting.h:257
Channel 4 supported.
Definition: DeviceSetting.h:249
Gyroscope On(C.8)
Definition: DeviceSetting.h:106
EMG Raw Data On(C.14)
Definition: DeviceSetting.h:118
Gesture
Gesture types predefined in the gForce device.
Definition: gfTypes.h:163
Channel 14 supported.
Definition: DeviceSetting.h:259
std::string tstring
std::string type definition for ANSI/UNICODE convenience
Definition: gfTypes.h:98
App Module Enable.
Definition: DeviceSetting.h:168
unsigned int GF_UINT32
type definition
Definition: gfTypes.h:73
The namespace in which all of the gForceSDK project definitions are contained.
Definition: Device.h:42
Npi Module Enable.
Definition: DeviceSetting.h:158
Quaternion On(C.11)
Definition: DeviceSetting.h:112
None Channel supported.
Definition: DeviceSetting.h:244
size_t GF_SIZE
type definition
Definition: gfTypes.h:78
DeviceService
Definition: DeviceSetting.h:82
Channel 5 supported.
Definition: DeviceSetting.h:250
virtual ~DeviceSetting()
Virtual deconstructor.
Definition: DeviceSetting.h:292
Profile Module Enable.
Definition: DeviceSetting.h:166
ADC Module Enable.
Definition: DeviceSetting.h:164
SWOModule
Definition: DeviceSetting.h:154
DataNotifFlags
Definition: DeviceSetting.h:100
None Status Event supported.
Definition: DeviceSetting.h:277
Channel 15 supported.
Definition: DeviceSetting.h:260
Channel 11 supported.
Definition: DeviceSetting.h:256
EMGRowDataChannels
Definition: DeviceSetting.h:242
Channel 6 supported.
Definition: DeviceSetting.h:251
LedControlTestType
Definition: DeviceSetting.h:197
SWOLogLevel
Definition: DeviceSetting.h:135
EMG Gesture On(C.13)
Definition: DeviceSetting.h:116
KernelMsgType
Definition: DeviceSetting.h:175
Accelerate On(C.7)
Definition: DeviceSetting.h:104
Rotation Matrix On(C.12)
Definition: DeviceSetting.h:114
GF_RET_CODE
Defines possible return values of methods.
Definition: gfTypes.h:138
HID Mouse On(C.15)
Definition: DeviceSetting.h:120
Device Status On(C.17)
Definition: DeviceSetting.h:124
Channel 7 supported.
Definition: DeviceSetting.h:252
DeviceStatusFlags
Definition: DeviceSetting.h:275
Channel 8 supported.
Definition: DeviceSetting.h:253
The abstract of the device setting handler of a gForce device.
Definition: DeviceSetting.h:60
Channel 0 supported.
Definition: DeviceSetting.h:245
PackageControlType
Definition: DeviceSetting.h:206
VibrateControlType
Definition: DeviceSetting.h:184
The basic type definitions using in gForceSDK.
Channel 3 supported.
Definition: DeviceSetting.h:248
unsigned char GF_UINT8
type definition
Definition: gfTypes.h:65