pybricks/hubs/PrimeHub: require light grid enabled
Reduce complexity of having a lot of #if statements.
#if PYBRICKS_PY_HUBS && PYBRICKS_HUB_PRIMEHUB
+#if !PYBRICKS_PY_COMMON_LIGHTGRID
+#error "PYBRICKS_PY_COMMON_LIGHTGRID must be enabled if PYBRICKS_HUB_PRIMEHUB is enabled."
+#endif
+
#include <pbsys/sys.h>
#include <pybricks/common.h>
typedef struct _hubs_PrimeHub_obj_t {
mp_obj_base_t base;
mp_obj_t light;
- #if PYBRICKS_PY_COMMON_LIGHTGRID
mp_obj_t grid;
- #endif
} hubs_PrimeHub_obj_t;
STATIC mp_obj_t hubs_PrimeHub_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
hubs_PrimeHub_obj_t *self = m_new_obj(hubs_PrimeHub_obj_t);
self->base.type = (mp_obj_type_t *)type;
self->light = common_ColorLight_internal_obj_make_new();
- #if PYBRICKS_PY_COMMON_LIGHTGRID
self->grid = common_LightGrid_obj_make_new(5);
- #endif
return MP_OBJ_FROM_PTR(self);
}
STATIC const mp_rom_map_elem_t hubs_PrimeHub_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_battery), MP_ROM_PTR(&pb_module_battery) },
{ MP_ROM_QSTR(MP_QSTR_light), MP_ROM_ATTRIBUTE_OFFSET(hubs_PrimeHub_obj_t, light) },
- #if PYBRICKS_PY_COMMON_LIGHTGRID
{ MP_ROM_QSTR(MP_QSTR_grid), MP_ROM_ATTRIBUTE_OFFSET(hubs_PrimeHub_obj_t, grid) },
- #endif
};
STATIC MP_DEFINE_CONST_DICT(hubs_PrimeHub_locals_dict, hubs_PrimeHub_locals_dict_table);
