Interstate 75w Slow with Text Scrolling?

Afternoon all,

I have been adapting some code that runs on the Galatic Unicron (an MQTT message scroller)

For the Interstate 75w - it all works but the when a long message comes in (around 3 lines of text) it really slows down. I’m using the same libraires, almost the same code but on a 32x64 matix.

Has anyone got any experience of the interstate75 here? Is it just the number of pixels vs the Picow?

Andy

I have an Interstate 75 here, with two 64x32 panels setup for 64x64. I’m displaying text but not scrolling text. I am far from any kind of expert but I’d be more than happy to run code on mine as a comparison. Or just give your code a look see.
If you use the preformatted text option, the </> button, if will retain your code’s format / layout. It retains all the indents etc.

That would be great! its a script that listens to an open mqtt feed - there are three files that go to the pipico - config.py (just add your wifi details), mqtt_as.py and interstatescrollbutslow.py
https://finchamweather.co.uk/mqttscroll.zip
It listens for an mqtt feed which gets the time, news and the weather over 5 mins - time will work fine, bbc news and the weather seem very slow…

You will need to edit the main file accordingly for the size of your matrix…

Andy :)

1 Like

I will give this a try over the weekend, probably tomorrow / Saturday. To much on the go to do it tonight. ;)

1 Like

One issue for me is, while its physically 64x64, code wise its 128x32.
i75 = Interstate75(display=Interstate75.DISPLAY_INTERSTATE75_128X32)
What I’ll probably do is go 64x32 and see what happens?
Thinking back, I was down this road before, scrolling text wise. My port / code is in this thread.
Interstate 75 with multiple HUB-75 LED matrix panels - Support - Pimoroni Buccaneers

Aw i used your code to port mine :)

Andy

1 Like

I haven’t forgotten about this, some family related stuff messed up and took up most of my day yesterday. =(
I do have every intension of playing around with your / our ;) code today for sure. I have a nice long custom USB cable for mine that lets me plug it in to my PC without having to move anything. It’s hanging on a wall and viewable from my PC.

Not working for me? I did the config.py edit. If I run interstatemqttworksbutslow.py I get no errors, but also nothing on the RGB matrix. If I click stop thorny throws up an error and I have to reset the i75 to reconnect.
Running the wifi test file from here
Connecting to the Internet with Raspberry Pi Pico W
Gets me the following, wifi is working.

>>> %Run -c $EDITOR_CONTENT

MPY: soft reboot
connected
ip = 192.168.2.48
>>> 

It should connect to the MQTT broker and then its blank until a message comes in - approx every 3 mins?

Ok, I’ll just let it run and see what happens.

Nope, not seeing anything displayed?

ok no worries - thanks for trying, I’m assuming you left the mqtt in the config file?

Andy

Yes, all I changed was the WIFI SSID and Password.

Just tried it again here and it works with the MQTT on port 1883 - its open so no need for user names etc. Its still painfully slow with long text. Thanks for trying btw…

An updated version with vertical scrolling text and a smaller outline on the font - this works well - use the config.py and mqtt_as.py from further up the thread. It should say Checking WiFi integrity.
Got reliable connection
Connecting to broker.
Connected to broker.

Messages then come in every three minutes or so…

from interstate75 import Interstate75, SWITCH_A, SWITCH_B
from mqtt_as import MQTTClient, config
from config import wifi_led, blue_led
import uasyncio as asyncio
import machine
import time

# Constants for controlling scrolling text
BACKGROUND_COLOUR = (0, 0, 0)  # Black background to turn off the screen
HOLD_TIME = 2.0
BLANK_SCREEN_TIME = 5.0
BUFFER_PIXELS = 2  # Increased buffer to ensure full scroll off
SCROLL_SPEED_LEVEL = 7  # Set the desired scrolling speed level (1 to 10)
SCROLL_SPEED = 1 / SCROLL_SPEED_LEVEL  # Convert to a delay in seconds

# State constants
STATE_PRE_SCROLL = 0
STATE_SCROLLING = 1
STATE_POST_SCROLL = 2
STATE_BLANK_SCREEN = 3

# Create Interstate75 object and graphics surface for drawing
i75 = Interstate75(display=Interstate75.DISPLAY_INTERSTATE75_64X32)
graphics = i75.display
width = i75.width
height = i75.height

# Display-related functions
def set_background(color):
    graphics.set_pen(graphics.create_pen(*color))
    graphics.clear()

def draw_text_with_outline_multiline(text, x, y, scale=1, text_color=(255, 255, 255), outline_color=(0, 0, 0), line_height=8):
    graphics.set_font("bitmap8")
    lines = text.split('\n')
    for line_num, line in enumerate(lines):
        y_offset = y + (line_num * line_height * scale)
        
        # Draw the outline by drawing the text with minimal offsets
        graphics.set_pen(graphics.create_pen(*outline_color))
        offsets = [(-1, 0), (1, 0), (0, -1), (0, 1)]
        for dx, dy in offsets:
            graphics.text(line, x + dx, y_offset + dy, -1, scale)
        
        # Draw the main text
        graphics.set_pen(graphics.create_pen(*text_color))
        graphics.text(line, x, y_offset, -1, scale)

# MQTT Message Subscription and Display
def sub_cb(topic, msg, retained):
    global STATE_PRE_SCROLL, STATE_SCROLLING, STATE_POST_SCROLL, STATE_BLANK_SCREEN, width, height
    print(f'Topic: "{topic.decode()}" Message: "{msg.decode()}" Retained: {retained}')
    state = STATE_PRE_SCROLL
    shift = 0
    scroll = 0
    DATA = msg.decode('utf-8')
    MESSAGE = "     " + DATA + "     "
    
    # Split the message into lines
    words = MESSAGE.split()
    lines = []
    current_line = ""
    for word in words:
        if graphics.measure_text(current_line + " " + word, 1) <= width - 2 * (BUFFER_PIXELS + 1):
            current_line += " " + word
        else:
            lines.append(current_line.strip())
            current_line = word
    if current_line:
        lines.append(current_line.strip())
    
    message_lines = "\n".join(lines)
    num_lines = len(lines)
    line_height = 8  # Font height for scale 1
    
    last_time = time.ticks_ms()
    
    while True:
        time_ms = time.ticks_ms()
        
        if state == STATE_PRE_SCROLL and time_ms - last_time > HOLD_TIME * 1000:
            state = STATE_SCROLLING
            last_time = time_ms
        
        if state == STATE_SCROLLING and time_ms - last_time > SCROLL_SPEED * 1000:
            scroll += 1
            if scroll >= num_lines * line_height + height + BUFFER_PIXELS + 1:
                state = STATE_POST_SCROLL
                last_time = time.ticks_ms()
            last_time = time.ticks_ms()
        
        if state == STATE_POST_SCROLL and time.ticks_ms() - last_time > HOLD_TIME * 1000:
            state = STATE_BLANK_SCREEN
            last_time = time.ticks_ms()
        
        if state == STATE_BLANK_SCREEN and time.ticks_ms() - last_time > BLANK_SCREEN_TIME * 1000:
            set_background(BACKGROUND_COLOUR)
            i75.update(graphics)
            break

        set_background(BACKGROUND_COLOUR)
        
        if "Time" in MESSAGE:
            set_background((255, 255, 0))
        elif "News" in MESSAGE:
            set_background((255, 0, 0))
        elif "Weather" in MESSAGE:
            set_background((0, 255, 255))
        
        draw_text_with_outline_multiline(message_lines, x=BUFFER_PIXELS + 1, y=height - scroll + BUFFER_PIXELS, scale=1)
        
        i75.update(graphics)
        time.sleep(0.001)

# Demonstrate scheduler is operational.
async def heartbeat():
    s = True
    while True:
        await asyncio.sleep_ms(500)
        blue_led(s)
        s = not s

async def wifi_han(state):
    wifi_led(not state)
    print('Wifi is ', 'up' if state else 'down')
    await asyncio.sleep(1)

# If you connect with clean_session True, must re-subscribe (MQTT spec 3.1.2.4)
async def conn_han(client):
    # MQTT Subscribe Topic
    await client.subscribe('personal/ucfnaps/led/#', 1)

async def main(client):
    try:
        await client.connect()
    except OSError:
        print('Connection failed.')
        machine.reset()
        return
    while True:
        await asyncio.sleep(5)

# Define configuration
config['subs_cb'] = sub_cb
config['wifi_coro'] = wifi_han
config['connect_coro'] = conn_han
config['clean'] = True

# Set up client
MQTTClient.DEBUG = True  # Optional
client = MQTTClient(config)

asyncio.create_task(heartbeat())

try:
    asyncio.run(main(client))
finally:
    client.close()  # Prevent LmacRxBlk:1 errors
    asyncio.new_event_loop()

Nice, I’ll have a look see when I get a chance.

Where is the MQTT Client located? Is it yours on your network or on the World Wide Web?

It’s open on the web to read under port 1883….

Andy

Ok, still not seeing anything on screen.

How odd - I’m running it at the moment over my mobile network so it def works - do you get :

Got reliable connection
Connecting to broker.
Connected to broker.

With your config.py including - its open so does not need username/password?

config[‘server’] = ‘mqtt.cetools.org’ # Your MQTT Server

config[‘server’] = ‘test.mosquitto.org

config [‘port’] = 1883 #Your MQTT Port
config[‘user’] =‘’ #Your MQTT User Name (
config [‘password’] =‘’ # Your MQTT Password

and mqtt_as copied over?

Andy