Skip to content

Commit

Permalink
pybricks/common: Guard colorlight and tools.
Browse files Browse the repository at this point in the history
Some platforms may not have these.
  • Loading branch information
laurensvalk committed Feb 5, 2024
1 parent 68828ac commit 2cb2ffb
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions bricks/cityhub/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define PYBRICKS_PY_COMMON (1)
#define PYBRICKS_PY_COMMON_BLE (1)
#define PYBRICKS_PY_COMMON_CHARGER (0)
#define PYBRICKS_PY_COMMON_COLOR_LIGHT (1)
#define PYBRICKS_PY_COMMON_CONTROL (1)
#define PYBRICKS_PY_COMMON_IMU (0)
#define PYBRICKS_PY_COMMON_KEYPAD (1)
Expand Down
1 change: 1 addition & 0 deletions bricks/debug/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define PYBRICKS_PY_COMMON (1)
#define PYBRICKS_PY_COMMON_BLE (0)
#define PYBRICKS_PY_COMMON_CHARGER (0)
#define PYBRICKS_PY_COMMON_COLOR_LIGHT (1)
#define PYBRICKS_PY_COMMON_CONTROL (0)
#define PYBRICKS_PY_COMMON_IMU (0)
#define PYBRICKS_PY_COMMON_KEYPAD (1)
Expand Down
1 change: 1 addition & 0 deletions bricks/essentialhub/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define PYBRICKS_PY_COMMON (1)
#define PYBRICKS_PY_COMMON_BLE (1)
#define PYBRICKS_PY_COMMON_CHARGER (1)
#define PYBRICKS_PY_COMMON_COLOR_LIGHT (1)
#define PYBRICKS_PY_COMMON_CONTROL (1)
#define PYBRICKS_PY_COMMON_IMU (1)
#define PYBRICKS_PY_COMMON_KEYPAD (1)
Expand Down
1 change: 1 addition & 0 deletions bricks/ev3dev/brickconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define PYBRICKS_PY_COMMON (1)
#define PYBRICKS_PY_COMMON_BLE (0)
#define PYBRICKS_PY_COMMON_CHARGER (0)
#define PYBRICKS_PY_COMMON_COLOR_LIGHT (1)
#define PYBRICKS_PY_COMMON_CONTROL (1)
#define PYBRICKS_PY_COMMON_IMU (0)
#define PYBRICKS_PY_COMMON_KEYPAD (1)
Expand Down
1 change: 1 addition & 0 deletions bricks/ev3rt/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define PYBRICKS_PY_COMMON (1)
#define PYBRICKS_PY_COMMON_BLE (0)
#define PYBRICKS_PY_COMMON_CHARGER (0)
#define PYBRICKS_PY_COMMON_COLOR_LIGHT (0)
#define PYBRICKS_PY_COMMON_CONTROL (0)
#define PYBRICKS_PY_COMMON_IMU (0)
#define PYBRICKS_PY_COMMON_KEYPAD (0)
Expand Down
1 change: 1 addition & 0 deletions bricks/movehub/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define PYBRICKS_PY_COMMON (1)
#define PYBRICKS_PY_COMMON_BLE (1)
#define PYBRICKS_PY_COMMON_CHARGER (0)
#define PYBRICKS_PY_COMMON_COLOR_LIGHT (1)
#define PYBRICKS_PY_COMMON_CONTROL (0)
#define PYBRICKS_PY_COMMON_IMU (0)
#define PYBRICKS_PY_COMMON_KEYPAD (1)
Expand Down
1 change: 1 addition & 0 deletions bricks/nxt/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define PYBRICKS_PY_COMMON (1)
#define PYBRICKS_PY_COMMON_BLE (0)
#define PYBRICKS_PY_COMMON_CHARGER (0)
#define PYBRICKS_PY_COMMON_COLOR_LIGHT (1)
#define PYBRICKS_PY_COMMON_CONTROL (1)
#define PYBRICKS_PY_COMMON_IMU (0)
#define PYBRICKS_PY_COMMON_KEYPAD (1)
Expand Down
1 change: 1 addition & 0 deletions bricks/primehub/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define PYBRICKS_PY_COMMON (1)
#define PYBRICKS_PY_COMMON_BLE (1)
#define PYBRICKS_PY_COMMON_CHARGER (1)
#define PYBRICKS_PY_COMMON_COLOR_LIGHT (1)
#define PYBRICKS_PY_COMMON_CONTROL (1)
#define PYBRICKS_PY_COMMON_IMU (1)
#define PYBRICKS_PY_COMMON_KEYPAD (1)
Expand Down
1 change: 1 addition & 0 deletions bricks/technichub/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define PYBRICKS_PY_COMMON (1)
#define PYBRICKS_PY_COMMON_BLE (1)
#define PYBRICKS_PY_COMMON_CHARGER (0)
#define PYBRICKS_PY_COMMON_COLOR_LIGHT (1)
#define PYBRICKS_PY_COMMON_CONTROL (1)
#define PYBRICKS_PY_COMMON_IMU (1)
#define PYBRICKS_PY_COMMON_KEYPAD (1)
Expand Down
1 change: 1 addition & 0 deletions bricks/virtualhub/mpconfigvariant.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define PYBRICKS_PY_COMMON (1)
#define PYBRICKS_PY_COMMON_BLE (0)
#define PYBRICKS_PY_COMMON_CHARGER (1)
#define PYBRICKS_PY_COMMON_COLOR_LIGHT (1)
#define PYBRICKS_PY_COMMON_CONTROL (1)
#define PYBRICKS_PY_COMMON_IMU (0)
#define PYBRICKS_PY_COMMON_KEYPAD (1)
Expand Down
4 changes: 2 additions & 2 deletions pybricks/common/pb_type_colorlight_external.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "py/mpconfig.h"

#if PYBRICKS_PY_COMMON
#if PYBRICKS_PY_COMMON && PYBRICKS_PY_COMMON_COLOR_LIGHT

#include <pbio/light.h>
#include <pbio/color.h>
Expand Down Expand Up @@ -64,4 +64,4 @@ mp_obj_t pb_type_ColorLight_external_obj_new(void *context, pb_type_ColorLight_o
return MP_OBJ_FROM_PTR(light);
}

#endif // PYBRICKS_PY_COMMON
#endif // PYBRICKS_PY_COMMON && PYBRICKS_PY_COMMON_COLOR_LIGHT
4 changes: 2 additions & 2 deletions pybricks/common/pb_type_colorlight_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "py/mpconfig.h"

#if PYBRICKS_PY_COMMON
#if PYBRICKS_PY_COMMON && PYBRICKS_PY_COMMON_COLOR_LIGHT

#include <stdbool.h>

Expand Down Expand Up @@ -153,4 +153,4 @@ mp_obj_t common_ColorLight_internal_obj_new(pbio_color_light_t *light) {
return MP_OBJ_FROM_PTR(self);
}

#endif // PYBRICKS_PY_COMMON
#endif // PYBRICKS_PY_COMMON && PYBRICKS_PY_COMMON_COLOR_LIGHT
4 changes: 4 additions & 0 deletions pybricks/pybricks.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ void pb_package_pybricks_init(bool import_all) {
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
// Initialize the package.
#if PYBRICKS_PY_PARAMETERS
pb_type_Color_reset();
#endif
#if PYBRICKS_PY_TOOLS
pb_module_tools_init();
#endif
// Import all if requested.
if (import_all) {
pb_package_import_all();
Expand Down

0 comments on commit 2cb2ffb

Please sign in to comment.