upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
joystick12.h
Go to the documentation of this file.
1 /*
2  * Author: Noel Eck <noel.eck@intel.com>
3  * Copyright (c) 2015 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #pragma once
26 
27 #include "upm.h"
28 #include "mraa/aio.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
45 typedef struct _joystick12_context {
46  /* mraa ai_x pin context */
47  mraa_aio_context ai_x;
48  /* mraa ai_y pin context */
49  mraa_aio_context ai_y;
50  /* Raw count offset - x axis */
51  float m_count_offset_x;
52  /* Raw count offset - y axis */
53  float m_count_offset_y;
54  /* Raw count scale - x axis */
55  float m_count_scale_x;
56  /* Raw count scale - y axis */
57  float m_count_scale_y;
59 
65 joystick12_context joystick12_init(int16_t apin_x, int16_t apin_y);
66 
72 
78 upm_result_t joystick12_read_data(const joystick12_context dev, int* values);
79 
87 upm_result_t joystick12_set_offset_x(const joystick12_context dev,
88  float offset);
89 
97 upm_result_t joystick12_set_offset_y(const joystick12_context dev,
98  float offset);
99 
107 upm_result_t joystick12_set_scale_x(const joystick12_context dev, float scale);
108 
116 upm_result_t joystick12_set_scale_y(const joystick12_context dev, float scale);
117 
125 upm_result_t joystick12_get_value_x(const joystick12_context dev, float *value);
126 
134 upm_result_t joystick12_get_value_y(const joystick12_context dev, float *value);
135 
141 upm_result_t joystick12_zero(const joystick12_context dev);
142 
148 upm_result_t joystick12_calibrate_x(const joystick12_context dev);
149 
155 upm_result_t joystick12_calibrate_y(const joystick12_context dev);
156 
157 #ifdef __cplusplus
158 }
159 #endif
upm_result_t joystick12_get_value_y(const joystick12_context dev, float *value)
Definition: joystick12.c:133
upm_result_t joystick12_get_value_x(const joystick12_context dev, float *value)
Definition: joystick12.c:110
upm_result_t joystick12_set_scale_y(const joystick12_context dev, float scale)
Definition: joystick12.c:104
void joystick12_close(joystick12_context dev)
Definition: joystick12.c:64
joystick12_context joystick12_init(int16_t apin_x, int16_t apin_y)
Definition: joystick12.c:30
Definition: joystick12.h:45
upm_result_t joystick12_set_scale_x(const joystick12_context dev, float scale)
Definition: joystick12.c:98
upm_result_t joystick12_calibrate_y(const joystick12_context dev)
Definition: joystick12.c:194
upm_result_t joystick12_zero(const joystick12_context dev)
Definition: joystick12.c:156
struct _joystick12_context * joystick12_context
upm_result_t joystick12_set_offset_y(const joystick12_context dev, float offset)
Definition: joystick12.c:92
upm_result_t joystick12_calibrate_x(const joystick12_context dev)
Definition: joystick12.c:172
upm_result_t joystick12_read_data(const joystick12_context dev, int *values)
Definition: joystick12.c:71
upm_result_t joystick12_set_offset_x(const joystick12_context dev, float offset)
Definition: joystick12.c:86