diff --git a/src/M5CoreS3.h b/src/M5CoreS3.h index 909f83a..69dad31 100644 --- a/src/M5CoreS3.h +++ b/src/M5CoreS3.h @@ -1,6 +1,14 @@ #ifndef _M5CORES3_H_ #define _M5CORES3_H_ +#if ARDUINO_USB_CDC_ON_BOOT + #define USBSerial Serial +#else + #include + // the warning produced by using the 'inline' keyword is a necessary evil as (HWCDC)USBSerial is declared extern and can't be casted as static + inline HWCDC USBSerial; +#endif + #include #include #include "FS.h" @@ -40,4 +48,4 @@ extern M5CoreS3 M5; #define imu IMU #define Imu IMU -#endif \ No newline at end of file +#endif diff --git a/src/utility/I2C_IMU.cpp b/src/utility/I2C_IMU.cpp index 0bc5422..0fdccc3 100644 --- a/src/utility/I2C_IMU.cpp +++ b/src/utility/I2C_IMU.cpp @@ -7,7 +7,7 @@ bool bmm150_init_flag = false; // FIXME: dirty code I2C_IMU::I2C_IMU() { Wire1.begin(12, 11, 100000UL); - USBSerial.begin(115200); + //USBSerial.begin(115200); // wut? } I2C_IMU::~I2C_IMU() { @@ -93,7 +93,7 @@ void I2C_IMU::Init() { /* Map data ready interrupt to interrupt pin. */ ret = bmi2_map_data_int(BMI2_DRDY_INT, BMI2_INT1, &aux_bmi2_dev); - USBSerial.printf("Valid BMM150 (Aux) sensor - Chip ID : 0x%x\r\n", + printf("Valid BMM150 (Aux) sensor - Chip ID : 0x%x\r\n", aux_bmm150_dev.chip_id); if (aux_bmm150_dev.chip_id == BMM150_CHIP_ID) { @@ -270,4 +270,4 @@ float I2C_IMU::lsb_to_dps(int16_t val, float dps, uint8_t bit_width) { float half_scale = ((float)(1 << bit_width) / 2.0f); return (dps / ((half_scale))) * (val); -} \ No newline at end of file +}