aboutsummaryrefslogtreecommitdiff
path: root/stm
diff options
context:
space:
mode:
authorDamien George2014-01-07 15:58:30 +0000
committerDamien George2014-01-07 15:58:30 +0000
commit97209d38e17a0f3cb2a2d3f03d726fd322b4808f (patch)
tree514cc35179713b4128ec6218829d769d87d7fe70 /stm
parentd49420e74c721bb6c61925a6c9a2addbaeed3382 (diff)
parenta5a01df81d01705b9f04264cc46fbb1bc32641b3 (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.c18
-rw-r--r--stm/led.c12
-rw-r--r--stm/main.c22
-rw-r--r--stm/servo.c10
4 files changed, 32 insertions, 30 deletions
diff --git a/stm/i2c.c b/stm/i2c.c
index 9e25ff983..22c908566 100644
--- a/stm/i2c.c
+++ b/stm/i2c.c
@@ -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
diff --git a/stm/led.c b/stm/led.c
index d4bc0a0c8..eb7c76ef1 100644
--- a/stm/led.c
+++ b/stm/led.c
@@ -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) {