Lambda, LED Matrix and Text, Oh My

I have no clue what I am doing. After about 10 days of cutting and pasting, poke and hope I have it working, but…

It scrolls the text from right to left fine, but when it starts and when it loops it is at top left so to speak. It does not begin scrolling from the right so I have to pad my message with stuff like asterisk dash asterisk -- Welcome to my home ! If I do not pad it Welcome scrolls away before you can read it. I tried changing the code to TOP_RIGHT but that did not work.

Anyone have a suggestion?
Thanks,
Grey

# mosquitto_pub -h mqtthost -t text/text -m "Hi there!"
substitutions:
  devicename: leggedlamp  
  xscrollpadding: "4" # in pix

esphome:
  name: btfmatrix
  platform: ESP8266
  board: nodemcuv2
  
  on_boot:
    priority: -10
    then: # stop the flickering
      - lambda: |-
            fastled_base_fastledlightoutput->get_controller()->setDither(0);


wifi:
  networks:
  - ssid: "****"
    password: "****"
  - ssid: "***"
    password: ""

  manual_ip:
    static_ip: 192.168.1.49
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    dns1: 192.168.1.1
    
mqtt:
  id: mqtt_client
  broker: 192.168.1.50
  username: "****" 
  password: "****"

text_sensor:
  - platform: mqtt_subscribe
    name: "Text4"
    id: extratext
    topic: text/text4
    
# Enable logging
logger: 
#  level: VERBOSE

# Enable Home Assistant API
api:

ota:

font:
  - id: tinyfont
    file: "DejaVuSans-Bold.ttf"
    size: 9
    glyphs: '♡Ωäöüß!"%()+,-_.:*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'

time:
  - platform: sntp
    id: rtctime

light:
  - platform: fastled_clockless
    chipset: WS2812B
    pin: GPIO2
    num_leds: 256
    rgb_order: GRB
#    rgb_order: GRB 
    name: "led_matrix"
    id: led_matrix_32x8
    default_transition_length: 0s
    color_correct: [30%, 30%, 30%]
    restore_mode: ALWAYS_ON
    
  

display:
  - platform: addressable_light

    addressable_light_id: led_matrix_32x8
    width: 32
    height: 8
    pixel_mapper: |-
      if (x % 2 == 0) {
        return (x * 8) + y;
      }
      return (x * 8) + (7 - y);
    rotation: 0°


    update_interval: 50ms
    lambda: |-
          static uint16_t xpos = 0;
          const char * text = id(extratext).state.c_str();     
          int x_start, y_start;
          int width, height;
              
          it.get_text_bounds(0, 0, text, id(tinyfont), 
              TextAlign::TOP_LEFT, &x_start, &y_start, &width, &height); 
          
          it.print(-(xpos % (width + $xscrollpadding)), -2, 
          id(tinyfont), Color(0xFFFF00), 
            TextAlign::TOP_LEFT, text); 
          xpos++;
        
1 Like

This sounds awesome! Do you have any videos or pictures you can share?

See if this works. Found a grid to print on thingverse and mounted to a board

Hi!
How to change code to scroll text (not MQTT) and sensor state?

I have not found any other good code for it. I can’t find the link now for what I am using, but it crashes/resets randomly and I am not happy with it. It uses wifi, not esphome or hassio

What is this mean?
const char * text = id(extratext).state.c_str();

No clue. Like I said at the start I found stuff and cut a pasted.
This one is pretty slick, but like I said it reboots on me
It will work if you make the changes I list in issues, but is neat if you upload an old version of colorpicker.js to the littlefs on the board

Hi,
i like the idea of using a 8x32 matrix to display informations from home assistant. So i programmed a solution based of esphome. till now it has 66 github stars so i think the idea wasn’t that bad.

Here are the details to my way of showing text.

Greetings