2727#include " ../Memory/mem.h"
2828#include " ../Utils/macros.h"
2929#include " ../Utils/util.h"
30- #include " primitives.h"
3130#include " Mindstorms/Motor.h"
3231#include " Mindstorms/uart_sensor.h"
32+ #include " primitives.h"
3333
3434#define OBB_PRIMITIVES 0
3535#ifdef CONFIG_BOARD_STM32L496G_DISCO
36- #define OBB_PRIMITIVES 6
36+ #define OBB_PRIMITIVES 6
3737#endif
3838#define ALL_PRIMITIVES OBB_PRIMITIVES + 6
3939
@@ -304,18 +304,19 @@ MotorEncoder *encoders[] = {new MotorEncoder(specs[51], specs[50], "Port A"),
304304 new MotorEncoder (specs[17 ], specs[13 ], " Port C" ),
305305 new MotorEncoder (specs[27 ], specs[26 ], " Port D" )};
306306
307- #define PWM_SPEC_GETTER (node_id, prop, idx ) PWM_DT_SPEC_GET_BY_IDX(DT_PATH(zephyr_user), idx)
308- struct pwm_dt_spec pwm_specs[] = {
309- DT_FOREACH_PROP_ELEM_SEP (DT_PATH (zephyr_user), pwms,
310- PWM_SPEC_GETTER, (,))
311- };
307+ #define PWM_SPEC_GETTER (node_id, prop, idx ) \
308+ PWM_DT_SPEC_GET_BY_IDX (DT_PATH(zephyr_user), idx)
309+ struct pwm_dt_spec pwm_specs[] = {DT_FOREACH_PROP_ELEM_SEP (
310+ DT_PATH (zephyr_user), pwms, PWM_SPEC_GETTER, (, ))};
312311
313312std::optional<Motor> get_motor (uint32_t motor_index) {
314- if (motor_index > sizeof (encoders)/ sizeof (*encoders)) {
313+ if (motor_index > sizeof (encoders) / sizeof (*encoders)) {
315314 return {};
316315 }
317316
318- return std::make_optional<Motor>(pwm_specs[motor_index * 2 + 1 ], pwm_specs[motor_index * 2 ], encoders[motor_index]);
317+ return std::make_optional<Motor>(pwm_specs[motor_index * 2 + 1 ],
318+ pwm_specs[motor_index * 2 ],
319+ encoders[motor_index]);
319320}
320321
321322def_prim (drive_motor, twoToNoneU32) {
@@ -364,17 +365,20 @@ def_prim(drive_motor_ms, threeToNoneU32) {
364365 return false ;
365366}
366367
367- bool drive_motor_degrees_absolute (uint32_t motor_index, int32_t degrees, int32_t speed) {
368+ bool drive_motor_degrees_absolute (uint32_t motor_index, int32_t degrees,
369+ int32_t speed) {
368370 if (auto motor = get_motor (motor_index)) {
369371 motor->drive_to_angle (speed, degrees);
370372 return true ;
371373 }
372374 return false ;
373375}
374376
375- bool drive_motor_degrees_relative (uint32_t motor_index, int32_t degrees, int32_t speed) {
377+ bool drive_motor_degrees_relative (uint32_t motor_index, int32_t degrees,
378+ int32_t speed) {
376379 MotorEncoder *encoder = encoders[motor_index];
377- return drive_motor_degrees_absolute (motor_index, encoder->get_target_angle () + degrees, speed);
380+ return drive_motor_degrees_absolute (
381+ motor_index, encoder->get_target_angle () + degrees, speed);
378382}
379383
380384def_prim (drive_motor_degrees, threeToNoneU32) {
@@ -398,7 +402,8 @@ def_prim_reverse(drive_motor_degrees) {
398402 // primitives instead of after and just not restore io when
399403 // restoring the last snapshot and transfer overrides from a future
400404 // snapshot when doing forward execution.
401- drive_motor_degrees_absolute (motor_index, (int32_t ) state.value , motor_index == 0 ? 10000 : 2000 );
405+ drive_motor_degrees_absolute (motor_index, (int32_t )state.value ,
406+ motor_index == 0 ? 10000 : 2000 );
402407 }
403408 }
404409}
@@ -414,7 +419,7 @@ def_prim_serialize(drive_motor_degrees) {
414419}
415420
416421static const struct device *const uart_dev =
417- DEVICE_DT_GET (DT_PROP(DT_PATH(zephyr_user), warduino_uarts));
422+ DEVICE_DT_GET (DT_PROP(DT_PATH(zephyr_user), warduino_uarts));
418423
419424UartSensor sensor (uart_dev);
420425
@@ -439,9 +444,7 @@ def_prim(color_sensor, oneToOneU32) {
439444
440445extern void read_debug_messages ();
441446
442- void debug_work_handler (struct k_work *work) {
443- read_debug_messages ();
444- }
447+ void debug_work_handler (struct k_work *work) { read_debug_messages (); }
445448
446449K_WORK_DEFINE (debug_work, debug_work_handler);
447450
0 commit comments