Skip to content

Conversation

@miathedev
Copy link

This pull request introduces several improvements focused on code formatting consistency, cross-platform compatibility, and code style cleanup for the LiquidCrystal_I2C library. The main changes include the addition of formatting configuration files, updates to VSCode workspace settings, and a comprehensive refactor to consistently use Allman braces and improve buffer handling for multiple platforms.

Formatting and Editor Configuration:

  • Added a .clang-format file to enforce consistent C++ code style, including indentation, brace placement, and other formatting rules.
  • Created .vscode/settings.json to align editor settings with the new formatting standards and ensure consistent formatting for C/C++ files, with special handling for .cpp and header files.

Cross-platform Buffer Handling:

  • Refactored buffer size detection in LiquidCrystal_I2C.cpp to support ESP32, ESP8266, AVR, and RP2040 platforms, ensuring the correct I2C buffer length is used based on the target architecture.

Code Style Consistency:

  • Refactored all function definitions in LiquidCrystal_I2C.cpp to use Allman-style braces and improved code readability by reformatting function bodies and comments because there was no continous style.

- Replace undefined BUFFER_LENGTH with platform-specific definitions
- Add support for ESP32/ESP8266 (uses I2C_BUFFER_LENGTH or 128 default)
- Add support for Arduino AVR platforms (32 bytes)
- Add support for Raspberry Pi Pico/RP2040 (256 bytes)
- Add compile-time error for unsupported platforms
- Resolves compilation error on ESP32 builds
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