Advice creating an ESPHome custom component for Alphanumeric LED display

Adafruit sell an I2C 4-digit alphanumeric LED display which I’d like to use with ESPHome. I’d need to create a custom component for it as it’s not currently supported, but I’m not sure where to start.


The I2C custom component examples given in the ESPHome docs are very brief, and say to read up on the custom sensor component. Most of that makes sense to me, but I’m not sure how to adapt it for a display component.

There is an existing Arduino library for this display, in fact the library also caters for a number of LED displays (dot matrix, bargraph, 7-segment) that all use the same HT16K33 I2C interface IC.

How difficult would this be? Should I just put in a new feature request for it, or is it something that I could do with a few pointers / guidance? I do have some python and C programming skills, but a bit rusty on OOP! - Thanks!

This is what I’ve tried so far, but it won’t compile

yaml:

esphome:
  name: quad_alpha_display_custom
  platform: ESP32
  board: esp32doit-devkit-v1
  includes:
    - quad_alpha_display_custom/quad_alpha_custom.h
.
.
.
i2c:
  sda: GPIO21
  scl: GPIO22

display:
  - platform: custom
    lambda: |-
      auto custom_quad_alpha = new CustomQuadAlpha();
      App.register_component(custom_quad_alpha);
      return {custom_quad_alpha};
      it.print("ABCD");

and in “quad_alpha_custom.h”.

#include "esphome.h"

class CustomQuadAlpha : public Component {
 public:
  void setup() override {
    Wire.begin();
  }
   void loop() override {
    // Example: write the value 0x42 to register 0x78 of device with address 0x70
    Wire.beginTransmission(0x70);
    Wire.write(0x78);
    Wire.write(0x42);
    Wire.endTransmission();
  }
};

I know the class definition isn’t correct, pretty sure I need something after public Component, but not sure what. Basically needs to accept the characters from the it.print("") statement. I also know I need to expand the loop code, but just trying to get the structure correct first.

Any help would be greatly appreciated!

Thanks to @ssieb who has created a custom component for this.
https://github.com/ssieb/custom_components/tree/master/lcd_ht16k33

I will try and test it on the weekend.

the link has changed to

I’ve been using it for years and still going strong!