diff options
| author | Damien George | 2014-01-07 15:58:30 +0000 |
|---|---|---|
| committer | Damien George | 2014-01-07 15:58:30 +0000 |
| commit | 97209d38e17a0f3cb2a2d3f03d726fd322b4808f (patch) | |
| tree | 514cc35179713b4128ec6218829d769d87d7fe70 /stm | |
| parent | d49420e74c721bb6c61925a6c9a2addbaeed3382 (diff) | |
| parent | a5a01df81d01705b9f04264cc46fbb1bc32641b3 (diff) | |
Merge branch 'cplusplus' of https://github.com/ian-v/micropython into ian-v-cplusplus
Conflicts:
py/objcomplex.c
Diffstat (limited to 'stm')
| -rw-r--r-- | stm/i2c.c | 18 | ||||
| -rw-r--r-- | stm/led.c | 12 | ||||
| -rw-r--r-- | stm/main.c | 22 | ||||
| -rw-r--r-- | stm/servo.c | 10 |
4 files changed, 32 insertions, 30 deletions
@@ -326,18 +326,20 @@ static MP_DEFINE_CONST_FUN_OBJ_1(i2c_obj_read_obj, i2c_obj_read); static MP_DEFINE_CONST_FUN_OBJ_1(i2c_obj_readAndStop_obj, i2c_obj_readAndStop); static MP_DEFINE_CONST_FUN_OBJ_1(i2c_obj_stop_obj, i2c_obj_stop); +static const mp_method_t i2c_methods[] = { + { "start", &i2c_obj_start_obj }, + { "write", &i2c_obj_write_obj }, + { "read", &i2c_obj_read_obj }, + { "readAndStop", &i2c_obj_readAndStop_obj }, + { "stop", &i2c_obj_stop_obj }, + { NULL, NULL }, +}; + static const mp_obj_type_t i2c_obj_type = { { &mp_const_type }, "I2C", .print = i2c_obj_print, - .methods = { - { "start", &i2c_obj_start_obj }, - { "write", &i2c_obj_write_obj }, - { "read", &i2c_obj_read_obj }, - { "readAndStop", &i2c_obj_readAndStop_obj }, - { "stop", &i2c_obj_stop_obj }, - { NULL, NULL }, - } + .methods = i2c_methods, }; // create the I2C object @@ -176,15 +176,17 @@ mp_obj_t led_obj_off(mp_obj_t self_in) { static MP_DEFINE_CONST_FUN_OBJ_1(led_obj_on_obj, led_obj_on); static MP_DEFINE_CONST_FUN_OBJ_1(led_obj_off_obj, led_obj_off); +static const mp_method_t led_methods[] = { + { "on", &led_obj_on_obj }, + { "off", &led_obj_off_obj }, + { NULL, NULL }, +}; + static const mp_obj_type_t led_obj_type = { { &mp_const_type }, "Led", .print = led_obj_print, - .methods = { - { "on", &led_obj_on_obj }, - { "off", &led_obj_off_obj }, - { NULL, NULL }, - } + .methods = led_methods, }; mp_obj_t pyb_Led(mp_obj_t led_id) { diff --git a/stm/main.c b/stm/main.c index 07c974eff..a038c89b7 100644 --- a/stm/main.c +++ b/stm/main.c @@ -689,22 +689,18 @@ static MP_DEFINE_CONST_FUN_OBJ_1(file_obj_close_obj, file_obj_close); // TODO gc hook to close the file if not already closed +static const mp_method_t file_methods[] = { + { "read", &file_obj_read_obj }, + { "write", &file_obj_write_obj }, + { "close", &file_obj_close_obj }, + {NULL, NULL}, +}; + static const mp_obj_type_t file_obj_type = { { &mp_const_type }, "File", - file_obj_print, // print - NULL, // make_new - NULL, // call_n - NULL, // unary_op - NULL, // binary_op - NULL, // getiter - NULL, // iternext - .methods = { - { "read", &file_obj_read_obj }, - { "write", &file_obj_write_obj }, - { "close", &file_obj_close_obj }, - {NULL, NULL}, - } + .print = file_obj_print, + .methods = file_methods, }; mp_obj_t pyb_io_open(mp_obj_t o_filename, mp_obj_t o_mode) { diff --git a/stm/servo.c b/stm/servo.c index 31190ce79..cc9633a99 100644 --- a/stm/servo.c +++ b/stm/servo.c @@ -137,14 +137,16 @@ static mp_obj_t servo_obj_angle(mp_obj_t self_in, mp_obj_t angle) { static MP_DEFINE_CONST_FUN_OBJ_2(servo_obj_angle_obj, servo_obj_angle); +static const mp_method_t servo_methods[] = { + { "angle", &servo_obj_angle_obj }, + { NULL, NULL }, +}; + static const mp_obj_type_t servo_obj_type = { { &mp_const_type }, "Servo", .print = servo_obj_print, - .methods = { - { "angle", &servo_obj_angle_obj }, - { NULL, NULL }, - } + .methods = servo_methods, }; mp_obj_t pyb_Servo(mp_obj_t servo_id) { |
