10 %rename(get_version) maa_get_version();
15 %rename(Gpio) maa_gpio_context;
19 int pin; /**< the pin number, as known to the os. */
20 FILE *value_fp; /**< the file pointer to the value of the gpio */
24 %nodefault maa_gpio_context;
25 %extend maa_gpio_context {
26 maa_gpio_context(int pin, int raw=0)
29 return maa_gpio_init_raw(pin);
30 return maa_gpio_init(pin);
34 maa_gpio_close($self);
38 return maa_gpio_write($self, value);
40 int dir(gpio_dir_t dir)
42 return maa_gpio_dir($self, dir);
46 return maa_gpio_read($self);
48 int mode(gpio_mode_t mode)
50 return maa_gpio_mode($self, mode);
56 %rename(I2c) maa_i2c_context;
60 int hz; /**< frequency of communication */
61 int fh; /**< the file handle to the /dev/i2c-* device */
62 int addr; /**< the address of the i2c slave */
63 maa_gpio_context gpio;
67 %nodefault maa_i2c_context;
68 %extend maa_i2c_context {
71 return maa_i2c_init();
79 return maa_i2c_frequency($self, hz);
81 int read(char *data, int length)
83 return maa_i2c_read($self, data, length);
87 return maa_i2c_read_byte($self);
89 int write(char *data, int length)
91 return maa_i2c_write($self, data, length);
95 return maa_i2c_write_byte($self, data);
101 %rename(Pwm) maa_pwm_context;
105 int pin; /**< the pin number, as known to the os. */
106 int chipid; /**< the chip id, which the pwm resides */
107 FILE *duty_fp; /**< File pointer to duty file */
111 %nodefault maa_pwm_context;
112 %extend maa_pwm_context {
113 maa_pwm_context(int pin)
115 return maa_pwm_init(pin);
117 maa_pwm_context(int chipid, int pin)
119 return maa_pwm_init_raw(chipid, pin);
123 maa_pwm_close($self);
125 int write(float percentage)
127 return maa_pwm_write($self, percentage);
131 return maa_pwm_read($self);
133 int period(float seconds)
135 return maa_pwm_period($self, seconds);
137 int period_ms(int ms)
139 return maa_pwm_period_ms($self, ms);
141 int period_us(int us)
143 return maa_pwm_period_us($self, us);
145 int pulsewidth(float seconds)
147 return maa_pwm_pulsewidth($self, seconds);
149 int pulsewidth_ms(int ms)
151 return maa_pwm_pulsewidth($self, ms);
153 int pulsewidth_us(int us)
155 return maa_pwm_pulsewidth($self, us);
157 int enable(int enable)
159 return maa_pwm_enable($self, enable);
165 %rename(Spi) maa_spi_context;
169 int spifd; /**< File descriptor to SPI Device */
173 %nodefault maa_spi_context;
174 %extend maa_spi_context {
177 return maa_spi_init();
183 int mode(unsigned short mode)
185 return maa_spi_mode($self, mode);
187 int frequency(int hz)
189 return maa_spi_frequency($self, hz);
191 unsigned int write(unsigned int data)
193 return maa_spi_write($self, data);
199 %rename(Aio) maa_aio_context;
202 unsigned int channel;
206 %nodefault maa_aio_context;
207 %extend maa_aio_context {
208 maa_aio_context(unsigned int aio_channel)
210 return maa_aio_init(aio_channel);
214 maa_aio_close($self);
218 return maa_aio_read_u16($self);