File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 25
25
*/
26
26
27
27
#include " main.h"
28
+ #include " microbithal.h"
28
29
#include " MicroBitDevice.h"
29
30
#include " neopixel.h"
30
31
31
32
#define HAL_ARRAY_SIZE (a ) (sizeof (a) / sizeof ((a)[0 ]))
32
33
34
+ // It's not possible to include the CODAL header file that defines the SFX_DEFAULT_xxx
35
+ // constants in C code, because that CODAL header file is C++. Instead we define our
36
+ // own MICROBIT_HAL_SFX_DEFAULT_xxx versions of the constants in a C-compatible header
37
+ // file, and assert here that they have the same value as the CODAL constants.
38
+ static_assert (MICROBIT_HAL_SFX_DEFAULT_VIBRATO_PARAM == SFX_DEFAULT_VIBRATO_PARAM, " " );
39
+ static_assert (MICROBIT_HAL_SFX_DEFAULT_VIBRATO_STEPS == SFX_DEFAULT_VIBRATO_STEPS, " " );
40
+ static_assert (MICROBIT_HAL_SFX_DEFAULT_TREMOLO_PARAM == SFX_DEFAULT_TREMOLO_PARAM, " " );
41
+ static_assert (MICROBIT_HAL_SFX_DEFAULT_TREMOLO_STEPS == SFX_DEFAULT_TREMOLO_STEPS, " " );
42
+ static_assert (MICROBIT_HAL_SFX_DEFAULT_WARBLE_PARAM == SFX_DEFAULT_WARBLE_PARAM, " " );
43
+ static_assert (MICROBIT_HAL_SFX_DEFAULT_WARBLE_STEPS == SFX_DEFAULT_WARBLE_STEPS, " " );
44
+
33
45
NRF52Pin *const pin_obj[] = {
34
46
&uBit.io .P0 ,
35
47
&uBit.io .P1 ,
@@ -83,8 +95,6 @@ static uint16_t button_state[2];
83
95
84
96
extern " C" {
85
97
86
- #include " microbithal.h"
87
-
88
98
void microbit_hal_background_processing (void ) {
89
99
// This call takes about 200us.
90
100
Event (DEVICE_ID_SCHEDULER, DEVICE_SCHEDULER_EVT_IDLE);
Original file line number Diff line number Diff line change @@ -103,6 +103,14 @@ extern "C" {
103
103
#define MICROBIT_HAL_LOG_TIMESTAMP_HOURS (36000)
104
104
#define MICROBIT_HAL_LOG_TIMESTAMP_DAYS (864000)
105
105
106
+ // These default fx values are the same as defined by CODAL, but here in a C-compatible header.
107
+ #define MICROBIT_HAL_SFX_DEFAULT_VIBRATO_PARAM (2)
108
+ #define MICROBIT_HAL_SFX_DEFAULT_VIBRATO_STEPS (512)
109
+ #define MICROBIT_HAL_SFX_DEFAULT_TREMOLO_PARAM (3)
110
+ #define MICROBIT_HAL_SFX_DEFAULT_TREMOLO_STEPS (900)
111
+ #define MICROBIT_HAL_SFX_DEFAULT_WARBLE_PARAM (2)
112
+ #define MICROBIT_HAL_SFX_DEFAULT_WARBLE_STEPS (700)
113
+
106
114
void microbit_hal_idle (void );
107
115
108
116
__attribute__((noreturn )) void microbit_hal_reset (void );
You can’t perform that action at this time.
0 commit comments