Scroll doesn't work in Microdot Script


#1

Hi there,

I have a Problem with my Python script on my Raspberry Zero.
All worked fine, except the scoll-function at the end, the display is empty:
#!/usr/bin/env python

import datetime
import time
import math
import subprocess

from microdotphat import write_string, show, scroll, set_decimal, set_pixel, clear

print("""Press Ctrl+C to exit.""")

scrolltext = subprocess.Popen(['mpc', 'current'], stdout=subprocess.PIPE).stdout.read().strip().decode('utf-8')

write_string(scrolltext, offset_x=0)

# Intro Sinuswelle fuer 10Sekunden
t1 = time.time() + 10
while time.time() < t1:
    clear()
    t = time.time() * 10
    for x in range(45):
        y = int((math.sin(t + (x/2.5)) + 1) * 3.5)
        set_pixel(x, y, 1)
    show()
    time.sleep(0.01)

# Zeit fuer 10Sekunden
while True:
    t2 = time.time() + 10
    while time.time() < t2:
        clear()
        t = datetime.datetime.now()
        if t.second % 2 == 0:
            set_decimal(3, 1)
        else:
            set_decimal(3, 0)
        write_string(t.strftime(' ''%H%M'), kerning=False)
        show()
        time.sleep(0.05)

# Datum fuer 4Sekunden
    t3 = time.time() + 4
    while time.time() < t3:
        clear()
        write_string(t.strftime('%d%m%y'), kerning=False)
        set_decimal(2, 1)
        set_decimal(4, 1)
        show()
        time.sleep(0.05)

# Interpret fuer 4 Sekunden
    t4 = time.time() + 4
    while time.time() < t4:
        clear()
        scroll()
        show()
        time.sleep(0.05)

BUT, a script just with the basic function will work:
#!/usr/bin/env python

import time
import subprocess

from microdotphat import write_string, scroll, show


scrolltext = subprocess.Popen(['mpc', 'current'], stdout=subprocess.PIPE).stdout.read().strip().decode('utf-8')

write_string(scrolltext, offset_x=0)

while True:
    scroll()
    show()
    time.sleep(0.05)

If I replaced the scroll() with somethink like set_pixel(x, y, 1) for example - it works. I dont know why the scroll function make me so much trouble.


#2

your code clears the buffer, so there is nothing to scroll.


#3

Thank you very much! That will help me a lot.