Skip to content

M5Stack StickS3 - New Tab5 - driver modules#516

Open
Shadowtrance wants to merge 7 commits intoTactilityProject:mainfrom
Shadowtrance:driver-modules
Open

M5Stack StickS3 - New Tab5 - driver modules#516
Shadowtrance wants to merge 7 commits intoTactilityProject:mainfrom
Shadowtrance:driver-modules

Conversation

@Shadowtrance
Copy link
Contributor

@Shadowtrance Shadowtrance commented Mar 18, 2026

Font size set to 18 for 800x480 displays
Fix web server dashboard not rendering when sdcard isn't present

Added new driver modules

  • BM8563 RTC
  • RX8130CE RTC
  • MPU6886 IMU
  • QMI8658 IMU
  • M5PM1 Power Management Chip

Applied the above modules to applicable devicetrees.

Added new device: M5Stack StickS3

Added new M5Stack Tab5 St7123 variant.

ButtonControl changed to use interupts and xQueue, added AppClose action.

And some bonus symbols of course, the apps are hungry for symbols.

Summary by CodeRabbit

  • New Features

    • Added M5Stack StickS3 device support and multiple new sensor/PMIC/RTC drivers; Tab5 gains alternate ST7123 touch/display support.
  • Bug Fixes

    • Safer storage handling in dashboard to avoid display errors when storage info is missing.
    • Improved display initialization and cleanup paths for more robust behavior.
  • Configuration Updates

    • Standardized LVGL fontSize=18 across several device profiles; new device tree/dependency entries for added hardware.
  • Refactor

    • Button input moved to interrupt-driven, queued processing for more reliable responsiveness.

Font size set to 18 for 800x480 displays
Fix web server dashboard not rendering when sdcard isn't present

Added new driver modules for BM8563 RTC, RX8130CE RTC, MPU6886 IMU, QMI8658 IMU.
Applied the above modules to applicable devicetrees.

Added driver module for the M5Stack M5PM1 Power Management Chip.
Added new device: M5Stack StickS3

Added new M5Stack Tab5 St7123 variant.

ButtonControl changed to use interupts and xQueue, added AppClose action.

And some bonus symbols of course, the apps are hungry for symbols.
@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds multiple new sensor and peripheral drivers and bindings (bm8563, mpu6886, qmi8658, rx8130ce, m5pm1) with public headers, driver implementations, module symbols, and devicetree metadata. Introduces M5Stack StickS3 device support (DTS, devicetree.yaml, device.properties, display and power implementations, CMake, module). Extends several M5Stack device trees with additional I2C peripherals (BMI270, MPU6886, BM8563, QMI8658). Adds ST7123 display and touch support with Tab5 variant detection and init data. Refactors ButtonControl to an interrupt-driven queued model and adds EspLcdConfiguration flags (swRotate, buffSpiram) plus LVGL symbol exports.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.99% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: adding M5Stack StickS3 support, Tab5 enhancements, and new driver modules.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🧹 Nitpick comments (9)
Drivers/bm8563-module/LICENSE-Apache-2.0.md (1)

1-1: Avoid rewriting license boilerplate; suppress markdown heading rules for this file.

Line 7 and subsequent section headings trigger MD001/MD003, but reformatting canonical license text is unnecessary risk. Prefer file-level markdownlint suppression for these rules.

Proposed non-invasive fix
+<!-- markdownlint-disable MD001 MD003 -->
 Apache License
 ==============
@@
     limitations under the License.
+
+<!-- markdownlint-enable MD001 MD003 -->
Drivers/rx8130ce-module/CMakeLists.txt (1)

5-5: Prefer reconfigure-aware source discovery for GLOB_RECURSE.

Line [5] uses file(GLOB_RECURSE ...) without CONFIGURE_DEPENDS, which can miss newly added source files until CMake is re-run manually. Consider adding CONFIGURE_DEPENDS (or explicitly listing sources).

Suggested change
-file(GLOB_RECURSE SOURCE_FILES "source/*.c*")
+file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS "source/*.c*")
Devices/m5stack-tab5/Source/devices/st7123_init_data.h (1)

28-28: Minor inconsistency: length parameter uses hex notation.

This line uses 0x04 for the length parameter while all other entries use decimal notation. Consider using 4 for consistency with the rest of the array.

✏️ Suggested fix
-    {0xB7, (uint8_t[]){0x00, 0x00, 0x73, 0x73}, 0x04, 0},
+    {0xB7, (uint8_t[]){0x00, 0x00, 0x73, 0x73}, 4, 0},
Drivers/mpu6886-module/include/drivers/mpu6886.h (1)

7-11: Consider moving the forward declaration inside the extern "C" block.

The struct Device forward declaration on line 7 is outside the extern "C" block. For consistency and to avoid potential linkage issues in mixed C/C++ compilation, consider moving it inside:

♻️ Suggested refactor
-struct Device;
-
 `#ifdef` __cplusplus
 extern "C" {
 `#endif`

+struct Device;
+
 struct Mpu6886Config {
Devices/m5stack-sticks3/Source/devices/Display.h (1)

16-16: Consider documenting the LV_COLOR_DEPTH dependency.

LCD_SPI_TRANSFER_SIZE_LIMIT depends on LV_COLOR_DEPTH, which must be defined before this header is included. If this header is ever included without the LVGL configuration in scope, compilation will fail. This is likely fine given the project structure, but adding a comment or an include guard could clarify the dependency.

Devices/m5stack-tab5/Source/devices/Display.cpp (1)

62-67: Prefer GPIO enum over raw literal for the GT911 workaround pin.

Using GPIO_NUM_23 here keeps this aligned with the rest of the file and reduces pin drift risk.

♻️ Proposed tweak
-        tt::hal::gpio::configure(23, tt::hal::gpio::Mode::Output, true, false);
-        tt::hal::gpio::setLevel(23, false);
+        tt::hal::gpio::configure(GPIO_NUM_23, tt::hal::gpio::Mode::Output, true, false);
+        tt::hal::gpio::setLevel(GPIO_NUM_23, false);
Drivers/m5pm1-module/source/m5pm1.cpp (1)

185-212: Consider adding a brief delay before the first poll.

The ADC conversion is started, then immediately polled. While the loop has vTaskDelay(5) at the start of each iteration, the first poll occurs after only 5ms. If the chip typically needs more time, this burns a few unnecessary I2C transactions.

Devices/m5stack-sticks3/Source/devices/Power.cpp (1)

53-66: Note: Linear battery percentage mapping is a simplification.

The current implementation uses a linear mapping between 3300–4200 mV for charge level percentage. Li-ion batteries have a non-linear discharge curve (relatively flat in the middle, steep drops at extremes). This is acceptable for a basic implementation, but could be refined with a lookup table or polynomial approximation if more accurate percentage reporting is desired in the future.

Drivers/bm8563-module/source/bm8563.cpp (1)

97-97: Don't hard-code weekday to Sunday.

Line 97 writes 0 into the weekday register on every set_datetime() call. The BM8563 calendar includes a weekday counter, and weekday alarms use that register, so the RTC state is inconsistent for 6 out of 7 dates after every write. Compute weekday from year/month/day before programming register 0x06. (makerguides.com)


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1f041fc2-7a78-4421-860f-399ff60181e7

📥 Commits

Reviewing files that changed from the base of the PR and between e560cc7 and ad653e0.

📒 Files selected for processing (110)
  • Data/data/webserver/dashboard.html
  • Devices/btt-panda-touch/device.properties
  • Devices/cyd-8048s043c/device.properties
  • Devices/elecrow-crowpanel-advance-50/device.properties
  • Devices/elecrow-crowpanel-basic-50/device.properties
  • Devices/guition-jc8048w550c/device.properties
  • Devices/m5stack-cardputer-adv/devicetree.yaml
  • Devices/m5stack-cardputer-adv/m5stack,cardputer-adv.dts
  • Devices/m5stack-core2/devicetree.yaml
  • Devices/m5stack-core2/m5stack,core2.dts
  • Devices/m5stack-cores3/devicetree.yaml
  • Devices/m5stack-cores3/m5stack,cores3.dts
  • Devices/m5stack-papers3/devicetree.yaml
  • Devices/m5stack-papers3/m5stack,papers3.dts
  • Devices/m5stack-stickc-plus/devicetree.yaml
  • Devices/m5stack-stickc-plus/m5stack,stickc-plus.dts
  • Devices/m5stack-stickc-plus2/devicetree.yaml
  • Devices/m5stack-stickc-plus2/m5stack,stickc-plus2.dts
  • Devices/m5stack-sticks3/CMakeLists.txt
  • Devices/m5stack-sticks3/Source/Configuration.cpp
  • Devices/m5stack-sticks3/Source/devices/Display.cpp
  • Devices/m5stack-sticks3/Source/devices/Display.h
  • Devices/m5stack-sticks3/Source/devices/Power.cpp
  • Devices/m5stack-sticks3/Source/devices/Power.h
  • Devices/m5stack-sticks3/Source/module.cpp
  • Devices/m5stack-sticks3/device.properties
  • Devices/m5stack-sticks3/devicetree.yaml
  • Devices/m5stack-sticks3/m5stack,sticks3.dts
  • Devices/m5stack-tab5/CMakeLists.txt
  • Devices/m5stack-tab5/Source/devices/Detect.cpp
  • Devices/m5stack-tab5/Source/devices/Detect.h
  • Devices/m5stack-tab5/Source/devices/Display.cpp
  • Devices/m5stack-tab5/Source/devices/Ili9881cDisplay.cpp
  • Devices/m5stack-tab5/Source/devices/St7123Display.cpp
  • Devices/m5stack-tab5/Source/devices/St7123Display.h
  • Devices/m5stack-tab5/Source/devices/St7123Touch.cpp
  • Devices/m5stack-tab5/Source/devices/St7123Touch.h
  • Devices/m5stack-tab5/Source/devices/ili9881_init_data.h
  • Devices/m5stack-tab5/Source/devices/st7123_init_data.h
  • Devices/m5stack-tab5/devicetree.yaml
  • Devices/m5stack-tab5/m5stack,tab5.dts
  • Devices/waveshare-s3-lcd-13/devicetree.yaml
  • Devices/waveshare-s3-lcd-13/waveshare,s3-lcd-13.dts
  • Devices/waveshare-s3-touch-lcd-128/devicetree.yaml
  • Devices/waveshare-s3-touch-lcd-128/waveshare,s3-touch-lcd-128.dts
  • Documentation/ideas.md
  • Drivers/ButtonControl/Source/ButtonControl.cpp
  • Drivers/ButtonControl/Source/ButtonControl.h
  • Drivers/EspLcdCompat/Source/EspLcdDisplayV2.cpp
  • Drivers/EspLcdCompat/Source/EspLcdDisplayV2.h
  • Drivers/bm8563-module/CMakeLists.txt
  • Drivers/bm8563-module/LICENSE-Apache-2.0.md
  • Drivers/bm8563-module/README.md
  • Drivers/bm8563-module/bindings/belling,bm8563.yaml
  • Drivers/bm8563-module/devicetree.yaml
  • Drivers/bm8563-module/include/bindings/bm8563.h
  • Drivers/bm8563-module/include/bm8563_module.h
  • Drivers/bm8563-module/include/drivers/bm8563.h
  • Drivers/bm8563-module/source/bm8563.cpp
  • Drivers/bm8563-module/source/module.cpp
  • Drivers/bm8563-module/source/symbols.c
  • Drivers/bmi270-module/source/bmi270.cpp
  • Drivers/m5pm1-module/CMakeLists.txt
  • Drivers/m5pm1-module/LICENSE-Apache-2.0.md
  • Drivers/m5pm1-module/README.md
  • Drivers/m5pm1-module/bindings/m5stack,m5pm1.yaml
  • Drivers/m5pm1-module/devicetree.yaml
  • Drivers/m5pm1-module/include/bindings/m5pm1.h
  • Drivers/m5pm1-module/include/drivers/m5pm1.h
  • Drivers/m5pm1-module/include/m5pm1_module.h
  • Drivers/m5pm1-module/source/m5pm1.cpp
  • Drivers/m5pm1-module/source/module.cpp
  • Drivers/m5pm1-module/source/symbols.c
  • Drivers/mpu6886-module/CMakeLists.txt
  • Drivers/mpu6886-module/LICENSE-Apache-2.0.md
  • Drivers/mpu6886-module/README.md
  • Drivers/mpu6886-module/bindings/invensense,mpu6886.yaml
  • Drivers/mpu6886-module/devicetree.yaml
  • Drivers/mpu6886-module/include/bindings/mpu6886.h
  • Drivers/mpu6886-module/include/drivers/mpu6886.h
  • Drivers/mpu6886-module/include/mpu6886_module.h
  • Drivers/mpu6886-module/source/module.cpp
  • Drivers/mpu6886-module/source/mpu6886.cpp
  • Drivers/mpu6886-module/source/symbols.c
  • Drivers/qmi8658-module/CMakeLists.txt
  • Drivers/qmi8658-module/LICENSE-Apache-2.0.md
  • Drivers/qmi8658-module/README.md
  • Drivers/qmi8658-module/bindings/qst,qmi8658.yaml
  • Drivers/qmi8658-module/devicetree.yaml
  • Drivers/qmi8658-module/include/bindings/qmi8658.h
  • Drivers/qmi8658-module/include/drivers/qmi8658.h
  • Drivers/qmi8658-module/include/qmi8658_module.h
  • Drivers/qmi8658-module/source/module.cpp
  • Drivers/qmi8658-module/source/qmi8658.cpp
  • Drivers/qmi8658-module/source/symbols.c
  • Drivers/rx8130ce-module/CMakeLists.txt
  • Drivers/rx8130ce-module/LICENSE-Apache-2.0.md
  • Drivers/rx8130ce-module/README.md
  • Drivers/rx8130ce-module/bindings/epson,rx8130ce.yaml
  • Drivers/rx8130ce-module/devicetree.yaml
  • Drivers/rx8130ce-module/include/bindings/rx8130ce.h
  • Drivers/rx8130ce-module/include/drivers/rx8130ce.h
  • Drivers/rx8130ce-module/include/rx8130ce_module.h
  • Drivers/rx8130ce-module/source/module.cpp
  • Drivers/rx8130ce-module/source/rx8130ce.cpp
  • Drivers/rx8130ce-module/source/symbols.c
  • Firmware/idf_component.yml
  • Modules/lvgl-module/source/symbols.c
  • TactilityC/Source/symbols/gcc_soft_float_p4.cpp
  • TactilityC/Source/tt_init.cpp
💤 Files with no reviewable changes (1)
  • Documentation/ideas.md

Device detection retry
Added check() after each acquire
Added VLF read; returns ERROR_INVALID_STATE if set
Added month/day/hour/minute/second range checks
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Devices/m5stack-tab5/Source/Configuration.cpp (1)

121-122: ⚠️ Potential issue | 🟠 Major

Fix inverted pin directions for IP2326 charge control pins.

The directions are swapped: ip2326_charge_state_led_pin should be INPUT (reads status from IC), and ip2326_charge_enable_pin should be OUTPUT (controls charging from MCU). The current configuration prevents charging enable from functioning. The charge enable pin is never read or written, confirming the misconfiguration.

Required fix
-    gpio_descriptor_set_flags(ip2326_charge_state_led_pin, GPIO_FLAG_DIRECTION_OUTPUT);
-    gpio_descriptor_set_flags(ip2326_charge_enable_pin, GPIO_FLAG_DIRECTION_INPUT | GPIO_FLAG_PULL_UP);
+    gpio_descriptor_set_flags(ip2326_charge_state_led_pin, GPIO_FLAG_DIRECTION_INPUT);
+    gpio_descriptor_set_flags(ip2326_charge_enable_pin, GPIO_FLAG_DIRECTION_OUTPUT);
🧹 Nitpick comments (1)
Drivers/mpu6886-module/source/mpu6886.cpp (1)

124-136: Consider adding I2C controller type validation for consistency.

The start() and stop() functions validate that the parent device is an I2C controller, but mpu6886_read() does not. While the lifecycle ensures start() succeeds before reads occur, adding the check here would provide consistent defensive behavior and clearer error messages if misused.

That said, given the Linux kernel style preference to avoid defensive checks in internal APIs (per project learnings), this is purely optional.

♻️ Optional: Add validation for consistency
 error_t mpu6886_read(Device* device, Mpu6886Data* data) {
     auto* i2c_controller = device_get_parent(device);
+    if (device_get_type(i2c_controller) != &I2C_CONTROLLER_TYPE) {
+        return ERROR_RESOURCE;
+    }
     auto address = GET_CONFIG(device)->address;

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0b7a6a48-7156-449a-a1c9-2f4b5dd9c26d

📥 Commits

Reviewing files that changed from the base of the PR and between ad653e0 and d3e0bca.

📒 Files selected for processing (12)
  • Devices/m5stack-tab5/Source/Configuration.cpp
  • Devices/m5stack-tab5/Source/devices/Detect.cpp
  • Devices/m5stack-tab5/Source/devices/Ili9881cDisplay.cpp
  • Devices/m5stack-tab5/Source/devices/St7123Display.cpp
  • Drivers/bm8563-module/include/drivers/bm8563.h
  • Drivers/bm8563-module/source/bm8563.cpp
  • Drivers/bmi270-module/source/bmi270.cpp
  • Drivers/m5pm1-module/source/module.cpp
  • Drivers/mpu6886-module/source/mpu6886.cpp
  • Drivers/qmi8658-module/source/module.cpp
  • Drivers/rx8130ce-module/include/drivers/rx8130ce.h
  • Drivers/rx8130ce-module/source/rx8130ce.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • Drivers/bmi270-module/source/bmi270.cpp

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
Devices/m5stack-tab5/Source/devices/St7123Display.cpp (1)

132-135: ⚠️ Potential issue | 🟠 Major

Incomplete cleanup on panel creation failure.

When esp_lcd_new_panel_st7123 fails, the function returns false but mipiDsiBus and ldoChannel remain allocated. The base class start() will delete ioHandle but won't release the DSI bus resources—they stay live until object destruction. This keeps the PHY powered and may make clean retries unreliable.

Possible fix to clean up DSI resources on failure
     if (esp_lcd_new_panel_st7123(ioHandle, &mutable_panel_config, &panelHandle) != ESP_OK) {
         LOGGER.error("Failed to create panel");
+        // Note: ioHandle cleanup is handled by base class, but we need to release DSI bus
+        esp_lcd_del_dsi_bus(mipiDsiBus);
+        mipiDsiBus = nullptr;
+        esp_ldo_release_channel(ldoChannel);
+        ldoChannel = nullptr;
         return false;
     }
🧹 Nitpick comments (1)
Devices/m5stack-tab5/Source/devices/St7123Display.cpp (1)

9-19: Acknowledge the cleanup ordering concern noted in the TODO.

The destructor serves as a fallback for releasing DSI bus resources, but if stop() is not called before destruction, panelHandle (a base class member) may still internally reference mipiDsiBus when it's deleted here. While this is an architectural limitation of the base class (as your TODO notes), consider documenting that callers must call stop() before destruction for clean resource release.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b7bceb87-04c6-45a5-93dc-d2628a85cae0

📥 Commits

Reviewing files that changed from the base of the PR and between d3e0bca and bc8f699.

📒 Files selected for processing (3)
  • Devices/m5stack-tab5/Source/devices/Ili9881cDisplay.cpp
  • Devices/m5stack-tab5/Source/devices/St7123Display.cpp
  • Drivers/rx8130ce-module/source/rx8130ce.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • Devices/m5stack-tab5/Source/devices/Ili9881cDisplay.cpp

Copy link
Contributor

@KenVanHoeylandt KenVanHoeylandt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! I have surprisingly little feedback for the amount of changes.

Keep in mind that any of my "minor" or "nitpick"-prefixed comments are suggestions and you can ignore them if you don't feel like processing them.

constexpr auto LCD_VERTICAL_RESOLUTION = 240;
constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 3;
constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT;
constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused / can be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. i think a lot of devices may need cleaning up stuff like this but I'll check what is and isn't used in this device. I copied one of the other sticks as a starting point.


case IsCharging: {
uint8_t gpio_in = 0;
if (!tt::hal::i2c::masterReadRegister(M5PM1_I2C_PORT, M5PM1_ADDR, REG_GPIO_IN, &gpio_in, 1)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use the m5pm1 driver here. The constructor of Power can accept it as a ::Device* m5mp1Device.
You can find it by name from the tree via device_find_by_name("m5pm1")

A proper driver for the M5PM1 would be even better, but I don't mind to keep it in here as-is for now.

// GPIO 23 has a pull-up resistor to 3V3, so INT is high at reset → GT911 uses 0x5D (primary)
// It may also appear at 0x14 (backup) if the pin happened to be driven low
if (tt::hal::i2c::masterHasDeviceAtAddress(I2C_NUM_0, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS) ||
tt::hal::i2c::masterHasDeviceAtAddress(I2C_NUM_0, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather see i2c_controller_has_device_at_address() being used.
tt::hal::i2c::* is deprecated - I just forgot to mark it as such.

#pragma once
#include <esp_lcd_st7123.h>

static const st7123_lcd_init_cmd_t st7123_init_data[] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this copied from somewhere? If so, we should probably attribute it. If not, then just resolve this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably put refer to its repo and its MIT license in the file, just in case.
https://github.com/m5stack/M5Tab5-UserDemo/blob/main/LICENSE

if (err != ERROR_NONE) return err;
*out = static_cast<uint16_t>(buf[0] | (buf[1] << 8));
return ERROR_NONE;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind moving this to TactilityKernel/source/drivers/i2c_controller.cpp and rename it to i2c_controller_register16le_get()?
Seems like it could be very useful for other drivers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If decide to move it, don't forget to rename Device* i2c to Device* device and addr to address, so that it's consistent with the other functions 😅

// Enable DATA_RDY interrupt
if (i2c_controller_register8_set(i2c_controller, address, REG_INT_ENABLE, 0x01, I2C_TIMEOUT_TICKS) != ERROR_NONE) return ERROR_RESOURCE;

vTaskDelay(pdMS_TO_TICKS(100));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you see errors without this delay?
If not, I'd remove it as there's a reasonable chance that no-one uses the device in that timeframe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. I only tested it with the cardputer and the m5stack IMU unit module (which is the mpu6886), i don't have any devices with it built-in.

// Enable accel + gyro
if (i2c_controller_register8_set(i2c_controller, address, REG_CTRL7, CTRL7_ENABLE, I2C_TIMEOUT_TICKS) != ERROR_NONE) return ERROR_RESOURCE;

vTaskDelay(pdMS_TO_TICKS(10));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: if it's not causing errors, we can remove it.


// Clear VLF and other status flags
uint8_t flag = 0x00;
if (i2c_controller_write_register(i2c_controller, address, REG_FLAG, &flag, 1, I2C_TIMEOUT_TICKS) != ERROR_NONE) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably use i2c_controller_register8_set() here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants