2014-04-28 18:10:12 +01:00
|
|
|
%module(docstring="Python interface to libmaa") pymaa
|
|
|
|
|
|
2014-05-01 15:27:34 +01:00
|
|
|
%feature("autodoc", "3");
|
2014-04-29 16:33:15 +01:00
|
|
|
|
|
|
|
|
#ifdef DOXYGEN
|
2014-04-30 10:50:44 +01:00
|
|
|
%include ../maa_doc.i
|
|
|
|
|
%include ../gpio_doc.i
|
|
|
|
|
%include ../i2c_doc.i
|
|
|
|
|
%include ../pwm_doc.i
|
2014-04-29 16:33:15 +01:00
|
|
|
#endif
|
|
|
|
|
|
2014-04-10 11:05:40 +01:00
|
|
|
%include ../maa.i
|
2014-05-01 15:27:34 +01:00
|
|
|
|
|
|
|
|
#### GPIO ####
|
|
|
|
|
|
|
|
|
|
%rename(Gpio) maa_gpio_context;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
/*@{*/
|
|
|
|
|
int pin; /**< the pin number, as known to the os. */
|
|
|
|
|
FILE *value_fp; /**< the file pointer to the value of the gpio */
|
|
|
|
|
/*@}*/
|
|
|
|
|
} maa_gpio_context;
|
|
|
|
|
|
|
|
|
|
%nodefault maa_gpio_context;
|
|
|
|
|
%extend maa_gpio_context {
|
|
|
|
|
maa_gpio_context(int pin)
|
|
|
|
|
{
|
|
|
|
|
return maa_gpio_init(pin);
|
|
|
|
|
}
|
|
|
|
|
~maa_gpio_context()
|
|
|
|
|
{
|
|
|
|
|
maa_gpio_close($self);
|
|
|
|
|
}
|
|
|
|
|
int write(int value)
|
|
|
|
|
{
|
|
|
|
|
return maa_gpio_write($self, value);
|
|
|
|
|
}
|
|
|
|
|
int dir(gpio_dir_t dir)
|
|
|
|
|
{
|
|
|
|
|
return maa_gpio_dir($self, dir);
|
|
|
|
|
}
|
|
|
|
|
int read()
|
|
|
|
|
{
|
|
|
|
|
return maa_gpio_read($self);
|
|
|
|
|
}
|
|
|
|
|
int mode(gpio_mode_t mode)
|
|
|
|
|
{
|
|
|
|
|
return maa_gpio_mode($self, mode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#### i2c ####
|
|
|
|
|
|
|
|
|
|
%rename(I2c) maa_i2c_context;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
/*@{*/
|
|
|
|
|
int hz; /**< frequency of communication */
|
|
|
|
|
int fh; /**< the file handle to the /dev/i2c-* device */
|
|
|
|
|
int addr; /**< the address of the i2c slave */
|
|
|
|
|
maa_gpio_context gpio;
|
|
|
|
|
/*@}*/
|
|
|
|
|
} maa_i2c_context;
|
|
|
|
|
|
|
|
|
|
%nodefault maa_i2c_context;
|
|
|
|
|
%extend maa_i2c_context {
|
|
|
|
|
maa_i2c_context()
|
|
|
|
|
{
|
|
|
|
|
return maa_i2c_init();
|
|
|
|
|
}
|
|
|
|
|
~maa_i2c_context()
|
|
|
|
|
{
|
|
|
|
|
maa_i2c_stop($self);
|
|
|
|
|
}
|
|
|
|
|
int frequency(int hz)
|
|
|
|
|
{
|
|
|
|
|
return maa_i2c_frequency($self, hz);
|
|
|
|
|
}
|
|
|
|
|
int read(char *data, int length)
|
|
|
|
|
{
|
|
|
|
|
return maa_i2c_read($self, data, length);
|
|
|
|
|
}
|
|
|
|
|
int read()
|
|
|
|
|
{
|
|
|
|
|
return maa_i2c_read_byte($self);
|
|
|
|
|
}
|
|
|
|
|
int write(char *data, int length)
|
|
|
|
|
{
|
|
|
|
|
return maa_i2c_write($self, data, length);
|
|
|
|
|
}
|
|
|
|
|
int write(int data)
|
|
|
|
|
{
|
|
|
|
|
return maa_i2c_write_byte($self, data);
|
|
|
|
|
}
|
|
|
|
|
}
|