Add I2C device management API with HT16K33 LED matrix support#146
Open
ralphweng2023 wants to merge 1 commit intothoth-tech:mainfrom
Open
Add I2C device management API with HT16K33 LED matrix support#146ralphweng2023 wants to merge 1 commit intothoth-tech:mainfrom
ralphweng2023 wants to merge 1 commit intothoth-tech:mainfrom
Conversation
New files: - raspi_i2c.h: Header with i2c_device type and functions - raspi_i2c.cpp: Implementation following ADC pattern - unit_test_raspi_i2c.cpp: Unit tests for I2C API Core I2C functions: - open_i2c_device(): Open I2C device by name, bus, address, type - i2c_write_byte(), i2c_write_register(): Write to device - i2c_read_byte(), i2c_read_register(): Read from device - close_i2c_device(), close_all_i2c_devices(): Cleanup - has_i2c_device(), i2c_device_named(): Registry lookups HT16K33 LED Matrix helpers: - ht16k33_init(): Initialize display - ht16k33_set_brightness(): Set brightness 0-15 - ht16k33_clear(): Clear display - ht16k33_draw_pattern(): Draw 8x8 pattern - ht16k33_turn_off(): Turn off display Also: - Added I2C_DEVICE_PTR to backend_types.h - Added i2c_device_type enum to types.h - Unit tests verify registry functions and null pointer handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a new I2C device management API for Raspberry Pi GPIO, following the existing pattern established by the ADC module. It provides a higher-level abstraction for communicating with I2C devices like LED matrices.
New Features
Core I2C Device API (
raspi_i2c.h):open_i2c_device()- Open an I2C device by name, bus, address, and typei2c_write_byte(),i2c_write_register()- Write to I2C devicei2c_read_byte(),i2c_read_register()- Read from I2C deviceclose_i2c_device(),close_all_i2c_devices()- Close deviceshas_i2c_device(),i2c_device_named()- Device registry lookupsHT16K33 LED Matrix Support:
ht16k33_init()- Initialize display (oscillator on, display on)ht16k33_set_brightness()- Set brightness level (0-15)ht16k33_clear()- Clear the displayht16k33_draw_pattern()- Draw an 8x8 patternht16k33_turn_off()- Turn off the displayDevice Types:
I2C_DEVICE_GENERIC- Generic I2C deviceI2C_DEVICE_HT16K33_8X8- 8x8 LED Matrix (address 0x70)I2C_DEVICE_HT16K33_14SEG- 14-segment display (address 0x70)I2C_DEVICE_PCF8574- I/O Expander (address 0x20)Example Usage
Type of change
How Has This Been Tested?
Built and tested on macOS using CMake:
Testing Checklist
Checklist