10 %rename(get_version) maa_get_version();
11 const char * maa_get_version();
12 %rename(init) maa_init();
18 MAA_GPIO_STRONG = 0, /**< Default. Strong high and low */
19 MAA_GPIO_PULLUP = 1, /**< Resistive High */
20 MAA_GPIO_PULLDOWN = 2, /**< Resistive Low */
21 MAA_GPIO_HIZ = 3 /**< High Z State */
25 MAA_GPIO_OUT = 0, /**< Output. A Mode can also be set */
26 MAA_GPIO_IN = 1 /**< Input. */
29 %nodefault maa_gpio_context;
30 %rename(Gpio) maa_gpio_context;
33 %feature("autodoc") maa_gpio_context "
34 Create a Gpio object and export it. Depending on your board the correct GPIO
35 value will be used. If raw is true then the pin that will be initialised will
36 be the hardcoded pin value in the kernel. Please see your board IO
37 documentation to understand exactly what will happen.
40 * pin: pin number read from the board, i.e IO3 is 3
41 * raw: set to True to use real pin value from the kernel";
44 int pin; /**< the pin number, as known to the os. */
45 FILE *value_fp; /**< the file pointer to the value of the gpio */
49 %extend maa_gpio_context {
50 maa_gpio_context(int pin, int raw=0)
53 return maa_gpio_init_raw(pin);
54 return maa_gpio_init(pin);
58 maa_gpio_unexport($self);
60 %feature("autodoc") write "
61 Write a value to a GPIO pin
64 * value: value to write to GPIO";
67 return maa_gpio_write($self, value);
69 %feature("autodoc") dir "
70 Set the gpio direction
73 * dir: GPIO direction";
74 int dir(gpio_dir_t dir)
76 return maa_gpio_dir($self, dir);
78 %feature("autodoc") read "
79 Read the value of a GPIO
85 return maa_gpio_read($self);
87 %feature("autodoc") mode "
91 * mode: GPIO mode to set";
92 int mode(gpio_mode_t mode)
94 return maa_gpio_mode($self, mode);
100 %nodefault maa_i2c_context;
101 %rename(I2c) maa_i2c_context;
106 int hz; /**< frequency of communication */
107 int fh; /**< the file handle to the /dev/i2c-* device */
108 int addr; /**< the address of the i2c slave */
109 maa_gpio_context gpio;
113 %nodefault maa_i2c_context;
114 %extend maa_i2c_context {
117 return maa_i2c_init();
122 int frequency(int hz)
124 return maa_i2c_frequency($self, hz);
126 int read(char *data, int length)
128 return maa_i2c_read($self, data, length);
132 return maa_i2c_read_byte($self);
134 int write(char *data, int length)
136 return maa_i2c_write($self, data, length);
140 return maa_i2c_write_byte($self, data);
146 %rename(Pwm) maa_pwm_context;
151 int pin; /**< the pin number, as known to the os. */
152 int chipid; /**< the chip id, which the pwm resides */
153 FILE *duty_fp; /**< File pointer to duty file */
157 %nodefault maa_pwm_context;
158 %extend maa_pwm_context {
159 maa_pwm_context(int pin)
161 return maa_pwm_init(pin);
163 maa_pwm_context(int chipid, int pin)
165 return maa_pwm_init_raw(chipid, pin);
169 maa_pwm_unexport($self);
171 int write(float percentage)
173 return maa_pwm_write($self, percentage);
177 return maa_pwm_read($self);
179 int period(float seconds)
181 return maa_pwm_period($self, seconds);
183 int period_ms(int ms)
185 return maa_pwm_period_ms($self, ms);
187 int period_us(int us)
189 return maa_pwm_period_us($self, us);
191 int pulsewidth(float seconds)
193 return maa_pwm_pulsewidth($self, seconds);
195 int pulsewidth_ms(int ms)
197 return maa_pwm_pulsewidth($self, ms);
199 int pulsewidth_us(int us)
201 return maa_pwm_pulsewidth($self, us);
203 int enable(int enable)
205 return maa_pwm_enable($self, enable);
211 %rename(Spi) maa_spi_context;
216 int spifd; /**< File descriptor to SPI Device */
220 %nodefault maa_spi_context;
221 %extend maa_spi_context {
224 return maa_spi_init();
229 int mode(unsigned short mode)
231 return maa_spi_mode($self, mode);
233 int frequency(int hz)
235 return maa_spi_frequency($self, hz);
237 unsigned int write(unsigned int data)
239 return maa_spi_write($self, data);
245 %rename(Aio) maa_aio_context;
249 unsigned int channel;
253 %nodefault maa_aio_context;
254 %extend maa_aio_context {
255 maa_aio_context(unsigned int aio_channel)
257 return maa_aio_init(aio_channel);
264 return maa_aio_read_u16($self);