Skip to content

Commit 0aa9969

Browse files
committed
pybricks/common: drop separate motor header
Stay closer to the actual common module in the Pybricks API.
1 parent 9164d0b commit 0aa9969

34 files changed

+47
-89
lines changed

pybricks/common/common.h

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
#if PYBRICKS_PY_COMMON
1010

11-
#include <pbio/control.h>
12-
#include <pbio/servo.h>
13-
1411
#include "util_pb/pb_device.h"
1512

1613
#include "py/obj.h"
@@ -29,6 +26,45 @@ const mp_obj_module_t pb_module_buttons;
2926
// pybricks._common.Battery()
3027
const mp_obj_module_t pb_module_battery;
3128

29+
30+
#if PYBRICKS_PY_COMMON_MOTORS
31+
32+
#include <pbio/control.h>
33+
#include <pbio/servo.h>
34+
35+
// pybricks._common.Control()
36+
const mp_obj_type_t pb_type_Control;
37+
mp_obj_t common_Control_obj_make_new(pbio_control_t *control);
38+
39+
// pybricks._common.Logger()
40+
mp_obj_t logger_obj_make_new(pbio_log_t *log);
41+
42+
// pybricks._common.Motor()
43+
typedef struct _common_Motor_obj_t {
44+
mp_obj_base_t base;
45+
pbio_servo_t *srv;
46+
mp_obj_t logger;
47+
mp_obj_t control;
48+
} common_Motor_obj_t;
49+
50+
const mp_obj_type_t pb_type_Motor;
51+
52+
// pybricks._common.DCMotor()
53+
typedef struct _common_DCMotor_obj_t {
54+
mp_obj_base_t base;
55+
pbio_dcmotor_t *dcmotor;
56+
} common_DCMotor_obj_t;
57+
58+
const mp_obj_type_t pb_type_DCMotor;
59+
60+
// Nonstatic objects shared between Motor and DCMotor
61+
void common_DCMotor_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind);
62+
const mp_obj_fun_builtin_var_t common_DCMotor_duty_obj;
63+
const mp_obj_fun_builtin_fixed_t common_DCMotor_stop_obj;
64+
const mp_obj_fun_builtin_fixed_t common_DCMotor_brake_obj;
65+
66+
#endif // PYBRICKS_PY_COMMON_MOTORS
67+
3268
#endif // PYBRICKS_PY_COMMON
3369

3470
#endif // PYBRICKS_INCLUDED_PYBRICKS_COMMON_H

pybricks/common/common_motors.h

Lines changed: 0 additions & 53 deletions
This file was deleted.

pybricks/common/pb_type_control.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
#if PYBRICKS_PY_COMMON_MOTORS
77

8-
#include "common/common_motors.h"
9-
8+
#include "common/common.h"
109
#include <pbio/control.h>
1110

1211
#include "py/obj.h"

pybricks/common/pb_type_dcmotor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "py/mphal.h"
1111

12-
#include "common/common_motors.h"
12+
#include "common/common.h"
1313
#include "parameters/parameters.h"
1414

1515
#include "util_pb/pb_error.h"

pybricks/common/pb_type_motor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "py/mphal.h"
1414
#include "py/obj.h"
1515

16-
#include "common/common_motors.h"
16+
#include "common/common.h"
1717
#include "parameters/parameters.h"
1818

1919
#include "util_pb/pb_error.h"

pybricks/ev3devices/pb_module_ev3devices.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "py/mphal.h"
99
#include "py/runtime.h"
1010

11-
#include "common/common_motors.h"
11+
#include "common/common.h"
1212
#include "ev3devices/ev3devices.h"
1313

1414
STATIC const mp_rom_map_elem_t ev3devices_globals_table[] = {

pybricks/ev3devices/pb_type_ev3devices_colorsensor.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <pbio/button.h>
1919

2020
#include "common/common.h"
21-
#include "common/common_motors.h"
2221
#include "ev3devices/ev3devices.h"
2322

2423
#include "parameters/parameters.h"

pybricks/ev3devices/pb_type_ev3devices_gyrosensor.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <pbio/button.h>
1919

2020
#include "common/common.h"
21-
#include "common/common_motors.h"
2221
#include "ev3devices/ev3devices.h"
2322

2423
#include "parameters/parameters.h"

pybricks/ev3devices/pb_type_ev3devices_infraredsensor.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <pbio/button.h>
1919

2020
#include "common/common.h"
21-
#include "common/common_motors.h"
2221
#include "ev3devices/ev3devices.h"
2322

2423
#include "parameters/parameters.h"

pybricks/ev3devices/pb_type_ev3devices_touchsensor.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <pbio/button.h>
1919

2020
#include "common/common.h"
21-
#include "common/common_motors.h"
2221
#include "ev3devices/ev3devices.h"
2322

2423
#include "parameters/parameters.h"

0 commit comments

Comments
 (0)