Skip to content

Commit 8547d9b

Browse files
committed
updates MicroPython version to 1.25.0 and updates the esp-idf version to 5.4.0
1 parent e2735b7 commit 8547d9b

File tree

10 files changed

+178
-302
lines changed

10 files changed

+178
-302
lines changed

builder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def get_micropython():
482482
'git submodule update --init --depth=1 -- lib/micropython',
483483
]
484484
print()
485-
print('collecting MicroPython 1.24.1')
485+
print('collecting MicroPython 1.25.0')
486486
result, _ = spawn(cmd_, spinner=True)
487487
if result != 0:
488488
sys.exit(result)

builder/esp32.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def get_espidf():
158158
]
159159
]
160160
print()
161-
print(f'collecting ESP-IDF v5.2.3')
161+
print(f'collecting ESP-IDF v5.4.0')
162162
print('this might take a while...')
163163
result, _ = spawn(cmd, spinner=True)
164164
if result != 0:
@@ -918,7 +918,7 @@ def submodules():
918918
['./install.sh', 'all']
919919
]
920920

921-
print(f'setting up ESP-IDF v5.2.3')
921+
print(f'setting up ESP-IDF v5.4.0')
922922
print('this might take a while...')
923923
env = {k: v for k, v in os.environ.items()}
924924
env['IDF_PATH'] = os.path.abspath(idf_path)

ext_mod/esp32_components.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Copyright (c) 2024 - 2025 Kevin G. Schlosser
1+

ext_mod/imu_fusion/include/fusion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
} mp_fusion_obj_t;
1616

1717

18-
extern const mp_obj_type_t mp_spi3wire_type;
18+
extern const mp_obj_type_t mp_fusion_type;
1919

2020
#endif

ext_mod/imu_fusion/src/fusion.c

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010

1111
#define FUSION_PI 3.14159265358979323846f
12+
#define FUSION_UNUSED(x) ((void)x)
1213

1314
#define FUSION_RADIANS(degree) (degree) * FUSION_PI / 180.0f
1415
#define FUSION_DEGREES(radian) (radian) * 180.0f / FUSION_PI
1516

16-
1717
#define FUSION_MAX(item1, item2) (item1) >= (item2) ? (item1) : (item2)
1818
#define FUSION_MIN(item1, item2) (item1) <= (item2) ? (item1) : (item2)
1919

@@ -38,10 +38,8 @@ static mp_obj_t fusion_make_new(const mp_obj_type_t *type, size_t n_args, size_t
3838

3939
self->beta = 0.6045997880780725842169464404f;
4040

41-
float declination;
42-
4341
if (args[ARG_declination].u_obj == mp_const_none) {
44-
self->declination = 0.0f
42+
self->declination = 0.0f;
4543
} else {
4644
self->declination = mp_obj_get_float_to_f(args[ARG_declination].u_obj);
4745
}
@@ -50,7 +48,8 @@ static mp_obj_t fusion_make_new(const mp_obj_type_t *type, size_t n_args, size_t
5048
}
5149

5250

53-
static mp_obj_t calibrate(up_obj_t self_in, mp_obj_t getxyz, mp_obj_t stopfunc):
51+
static mp_obj_t calibrate(mp_obj_t self_in, mp_obj_t getxyz, mp_obj_t stopfunc)
52+
{
5453

5554
mp_fusion_obj_t *self = MP_OBJ_TO_PTR(self_in);
5655

@@ -85,7 +84,7 @@ static mp_obj_t calibrate(up_obj_t self_in, mp_obj_t getxyz, mp_obj_t stopfunc):
8584
}
8685

8786
return mp_const_none;
88-
87+
}
8988

9089
static MP_DEFINE_CONST_FUN_OBJ_3(calibrate_obj, calibrate);
9190

@@ -95,13 +94,13 @@ static float delta_T(mp_fusion_obj_t *self)
9594
float res;
9695
uint32_t ts = mp_hal_ticks_us();
9796

98-
if (self->start_time == 0) {
97+
if (self->start_ts == 0) {
9998
res = 0.0001f;
10099
} else {
101-
res = (float)(ts - self->start_time) * 0.000001f;
100+
res = (float)(ts - self->start_ts) * 0.000001f;
102101
}
103102

104-
self->start_time = ts;
103+
self->start_ts = ts;
105104
return res;
106105
}
107106

@@ -133,10 +132,14 @@ mp_obj_t calculate(mp_fusion_obj_t *self, float accel[3], float gyro[3], float *
133132
ay *= norm;
134133
az *= norm;
135134

135+
float mx;
136+
float my;
137+
float mz;
138+
136139
if (mag != NULL) {
137-
float mx = mag[0] - self->mag_bias[0];
138-
float my = mag[1] - self->mag_bias[1];
139-
float mz = mag[2] - self->mag_bias[2];
140+
mx = mag[0] - self->mag_bias[0];
141+
my = mag[1] - self->mag_bias[1];
142+
mz = mag[2] - self->mag_bias[2];
140143

141144
// Normalise magnetometer measurement
142145
norm = sqrtf((mx * mx) + (my * my) + (mz * mz));
@@ -148,6 +151,10 @@ mp_obj_t calculate(mp_fusion_obj_t *self, float accel[3], float gyro[3], float *
148151
mx *= norm;
149152
my *= norm;
150153
mz *= norm;
154+
} else {
155+
mx = 0.0f;
156+
my = 0.0f;
157+
mz = 0.0f;
151158
}
152159

153160
float gx = FUSION_RADIANS(gyro[0]);
@@ -160,10 +167,10 @@ mp_obj_t calculate(mp_fusion_obj_t *self, float accel[3], float gyro[3], float *
160167
float q4 = self->q[3];
161168

162169
// Auxiliary variables to avoid repeated arithmetic
163-
float _2q1 = 2.0f * q1
164-
float _2q2 = 2.0f * q2
165-
float _2q3 = 2.0f * q3
166-
float _2q4 = 2.0f * q4
170+
float _2q1 = 2.0f * q1;
171+
float _2q2 = 2.0f * q2;
172+
float _2q3 = 2.0f * q3;
173+
float _2q4 = 2.0f * q4;
167174

168175
float q1sq = q1 * q1;
169176
float q2sq = q2 * q2;
@@ -261,7 +268,7 @@ mp_obj_t calculate(mp_fusion_obj_t *self, float accel[3], float gyro[3], float *
261268

262269
q1sq = q1 * q1;
263270
q2sq = q2 * q2;
264-
s3sq = s3 * s3;
271+
float s3sq = s3 * s3;
265272
q4sq = q4 * q4;
266273

267274
self->q[0] = q1;
@@ -275,6 +282,8 @@ mp_obj_t calculate(mp_fusion_obj_t *self, float accel[3], float gyro[3], float *
275282
if (mag != NULL) {
276283
yaw = FUSION_DEGREES(atan2f(2.0f * ((q2 * q3) + (q1 * q4)), q1sq + q2sq - s3sq - q4sq));
277284
yaw += self->declination;
285+
} else {
286+
yaw = 0.0f;
278287
}
279288

280289
tuple[0] = mp_obj_new_float((mp_float_t)roll);
@@ -365,7 +374,7 @@ static MP_DEFINE_CONST_DICT(fusion_globals, fusion_globals_table);
365374

366375
const mp_obj_module_t mp_module_fusion = {
367376
.base = {&mp_type_module},
368-
.globals = (mp_obj_dict_t *)fusion_globals,
377+
.globals = (mp_obj_dict_t *)&fusion_globals,
369378
};
370379

371380

ext_mod/lcd_bus/esp32_src/spi_bus.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ static mp_obj_t mp_lcd_spi_bus_make_new(const mp_obj_type_t *type, size_t n_args
151151
self->panel_io_config.flags.quad_mode = (unsigned int)args[ARG_quad].u_bool;
152152
self->panel_io_config.flags.octal_mode = (unsigned int)args[ARG_octal].u_bool;
153153

154-
if (!(spi_bus->buscfg.flags & SPICOMMON_BUSFLAG_DUAL)) self->panel_io_config.flags.sio_mode = 0;
155-
if (!(spi_bus->buscfg.flags & SPICOMMON_BUSFLAG_QUAD)) self->panel_io_config.flags.quad_mode = 0;
156-
if (!(spi_bus->buscfg.flags & SPICOMMON_BUSFLAG_OCTAL)) self->panel_io_config.flags.octal_mode = 0;
154+
if (!spi_bus->dual) self->panel_io_config.flags.sio_mode = 0;
155+
if (!spi_bus->quad) self->panel_io_config.flags.quad_mode = 0;
156+
if (!spi_bus->octal) self->panel_io_config.flags.octal_mode = 0;
157157

158158
self->panel_io_handle.del = &spi_del;
159159
self->panel_io_handle.init = &spi_init;
@@ -348,4 +348,4 @@ MP_DEFINE_CONST_OBJ_TYPE(
348348
MP_TYPE_FLAG_NONE,
349349
make_new, mp_lcd_spi_bus_make_new,
350350
locals_dict, (mp_obj_dict_t *)&mp_lcd_spi_bus_locals_dict
351-
);
351+
);

ext_mod/micropython.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/lcd_bus/micropython.cmake)
99
include(${CMAKE_CURRENT_LIST_DIR}/lvgl/micropython.cmake)
1010
include(${CMAKE_CURRENT_LIST_DIR}/lcd_utils/micropython.cmake)
1111

12-
separate_arguments(FUSION_ENV UNIX_COMMAND $ENV{FUSION})
13-
14-
if(${FUSION_ENV} EQUAL "1")
12+
if(DEFINED ENV{FUSION})
1513
include(${CMAKE_CURRENT_LIST_DIR}/imu_fusion/micropython.cmake)
1614
endif()

micropy_updates/common/mp_spi_common.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "py/obj.h"
66
#include "py/runtime.h"
7-
#include "driver/spi_master.h"
87

98
#ifndef __MP_SPI_COMMON_H__
109
#define __MP_SPI_COMMON_H__
@@ -21,8 +20,19 @@
2120
struct _mp_machine_hw_spi_bus_obj_t {
2221
mp_obj_base_t base;
2322
uint8_t host;
23+
mp_obj_t sck;
24+
mp_obj_t data0;
25+
mp_obj_t data1;
26+
mp_obj_t data2;
27+
mp_obj_t data3;
28+
mp_obj_t data4;
29+
mp_obj_t data5;
30+
mp_obj_t data6;
31+
mp_obj_t data7;
32+
bool dual;
33+
bool quad;
34+
bool octal;
2435
uint8_t device_count;
25-
spi_bus_config_t buscfg;
2636
mp_machine_hw_spi_device_obj_t **devices;
2737
mp_machine_hw_spi_state_t state;
2838
const void *user_data;
@@ -52,12 +62,7 @@
5262

5363
extern const mp_obj_type_t mp_machine_hw_spi_device_type;
5464
extern const mp_obj_type_t mp_machine_hw_spi_bus_type;
55-
extern const mp_obj_type_t mp_machine_hw_spi_dual_bus_type;
56-
extern const mp_obj_type_t mp_machine_hw_spi_quad_bus_type;
57-
extern const mp_obj_type_t mp_machine_hw_spi_octal_bus_type;
58-
5965

6066
void mp_machine_hw_spi_bus_deinit_all(void);
6167

6268
#endif /* __MP_SPI_COMMON_H__ */
63-

0 commit comments

Comments
 (0)