Skip to content

Commit 7bf4c8a

Browse files
committed
pbio/drv/sound/sound_ev3: Create stub sound driver
1 parent 3e51095 commit 7bf4c8a

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

bricks/_common/sources.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ PBIO_SRC_C = $(addprefix lib/pbio/,\
176176
drv/reset/reset_ev3.c \
177177
drv/resistor_ladder/resistor_ladder.c \
178178
drv/sound/beep_sampled.c \
179+
drv/sound/sound_ev3.c \
179180
drv/sound/sound_nxt.c \
180181
drv/sound/sound_stm32_hal_dac.c \
181182
drv/stack/stack_embedded.c \

lib/pbio/drv/sound/sound_ev3.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: MIT
2+
// Copyright (c) 2025 The Pybricks Authors
3+
4+
#include <pbdrv/config.h>
5+
6+
#if PBDRV_CONFIG_SOUND_EV3
7+
8+
#include <stdint.h>
9+
10+
void pbdrv_sound_stop() {
11+
12+
}
13+
14+
void pbdrv_beep_start(uint32_t frequency, uint16_t sample_attenuator) {
15+
16+
}
17+
18+
void pbdrv_sound_init() {
19+
20+
}
21+
22+
#endif // PBDRV_CONFIG_SOUND_EV3

lib/pbio/platform/ev3/pbdrvconfig.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
#define PBDRV_CONFIG_RESET (1)
7272
#define PBDRV_CONFIG_RESET_EV3 (1)
7373

74+
#define PBDRV_CONFIG_SOUND (1)
75+
#define PBDRV_CONFIG_SOUND_EV3 (1)
76+
7477
#define PBDRV_CONFIG_UART (1)
7578
#define PBDRV_CONFIG_UART_DEBUG_FIRST_PORT (1)
7679
#define PBDRV_CONFIG_UART_EV3 (1)

pybricks/hubs/pb_type_ev3brick.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ typedef struct _hubs_EV3Brick_obj_t {
2020
mp_obj_t buttons;
2121
mp_obj_t light;
2222
mp_obj_t screen;
23+
mp_obj_t speaker;
2324
mp_obj_t system;
2425
} hubs_EV3Brick_obj_t;
2526

@@ -53,6 +54,7 @@ static mp_obj_t hubs_EV3Brick_make_new(const mp_obj_type_t *type, size_t n_args,
5354
self->buttons = pb_type_Keypad_obj_new(pb_type_ev3brick_button_pressed);
5455
self->light = common_ColorLight_internal_obj_new(pbsys_status_light_main);
5556
self->screen = pb_type_Image_display_obj_new();
57+
self->speaker = mp_call_function_0(MP_OBJ_FROM_PTR(&pb_type_Speaker));
5658
self->system = MP_OBJ_FROM_PTR(&pb_type_System);
5759

5860
return MP_OBJ_FROM_PTR(self);
@@ -63,6 +65,7 @@ static const pb_attr_dict_entry_t hubs_EV3Brick_attr_dict[] = {
6365
PB_DEFINE_CONST_ATTR_RO(MP_QSTR_buttons, hubs_EV3Brick_obj_t, buttons),
6466
PB_DEFINE_CONST_ATTR_RO(MP_QSTR_light, hubs_EV3Brick_obj_t, light),
6567
PB_DEFINE_CONST_ATTR_RO(MP_QSTR_screen, hubs_EV3Brick_obj_t, screen),
68+
PB_DEFINE_CONST_ATTR_RO(MP_QSTR_speaker, hubs_EV3Brick_obj_t, speaker),
6669
PB_DEFINE_CONST_ATTR_RO(MP_QSTR_system, hubs_EV3Brick_obj_t, system),
6770
PB_ATTR_DICT_SENTINEL
6871
};

0 commit comments

Comments
 (0)