flotulopex
- 31st August 2022, 15:00
Hello there,
I'm trying to make my 8x8 LED matrix display (1 module) to smoothly scroll horizontally text (or simply letters) from right to left.
I started thanks to PBPBeginner and his example (http://www.picbasic.co.uk/forum/showthread.php?t=15735&p=109506#post109506).
Unfortunately, the example does "scroll" (shift) one caracter after the other meaning there is no close link between the displayed caracters and the next one; they shift from right to left one at the time.
I think there must be a way or an algorythm to calculate how to "append" the next caracter (or frame) to the currently display and make everything move from right to left.
For my tests, I designed two simple caracters here (https://xantorohara.github.io/led-matrix-editor/#) and to save my day, I designed all intermediate frames - but this is obvioulsy the wrong way to go and a huge waist of time.
9268 9269
Letter A
HEX 0024243c24241800
DEC 0, 36, 36, 60, 36, 36, 24, 0
Letter B
HEX 001c24241c241c00
DEC 0, 28, 36, 36, 28, 36, 28, 0
Does anyone have an example or point me on how I must calculate the transition steps please?
In a perfect world, I even should be able to trim some vertical empty lines of the frames to make the caracters appear close one to the other....
But I would appreciate a first simple start method to calculate this data to scroll.
'======= FUSES ================================================== ==================================
' PIC 16F690 Fuses
' Internal oscillator (activate OSCCON register)
@ __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_INTRC_OSC_NOCLKOUT &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF
@ ERRORLEVEL -306
@ ERRORLEVEL -202
'-------------------------------------------------------------------------------
' Registers 76543210
OPTION_REG = %10000000 'PORT A&B Pull-Ups disabled (look WPUA & WPUB)
OSCCON = %01110000 'Internal RC set to 8Mhz
ANSEL = %00000000 'Analog inputs Channels 0 to 7
ANSELH = %00000000 'Analog inputs Channels 8 to 11
WPUA = %00000000 'Weak pull-ups
WPUB = %00000000 'Weak pull-ups
ADCON0 = %00000000 'A/D Module (OFF)
CM1CON0 = %00000000 'Comparator1 Module (OFF)
CM2CON0 = %00000000 'Comparator2 Module (OFF)
INTCON = %00000000 'INTerrupts CONtrol
TRISA = %00000000 'Set Input/Output (0 to 5)
PORTA = %00000000 'Ports High/Low (0 to 5)
TRISB = %00000000 'Set Input/Output (4 to 7)
PORTB = %00000000 'Ports High/Low (4 to 7)
TRISC = %00000000 'Set Input/Output (0 to 7)
PORTC = %00000000 'Ports High/Low (0 to 7)
' ====== DEFINES ================================================== ================================
define OSC 8
DEFINE NO_CLRWDT 1
' ====== VARIABLES ================================================== ==============================
ADDRESS var word ' display's address
DATAREG var word ' display's data register
Y VAR BYTE ' just a counter
X var BYTE ' horizontal scroll steps counter
DES VAR BYTE
ScrollSpeed var word ' pause time
Letter_Cnt VAR BYTE ' caracter to be displayed
CLK VAR PORTB.4 ' connected to module's CLK
LOAD VAR PORTB.5 ' connected to module's CS
DAT VAR PORTB.6 ' connected to module's DIN
' ====== INITIALIZE ================================================== =============================
low clk
low dat
low load 'CS
ScrollSpeed = 400
Letter_Cnt = 1
' ====== MAX7219 SETUP ================================================== ==========================
ADDRESS = $0C : DATAREG = $01 : gosub MaxWrite ' SHUTDOWN=0, NORMAL OPERATION=1
ADDRESS = $09 : DATAREG = $00 : gosub MaxWrite ' DECODE-MODE, NO DECODE
ADDRESS = $0A : DATAREG = $00 : gosub MaxWrite ' LEDS INTENSITY MIN=0, MAX=F
ADDRESS = $0B : DATAREG = $07 : gosub MaxWrite ' NUMBER OF DISPLAYED LINES
ADDRESS = $0F : DATAREG = $00 : gosub MaxWrite ' DISPLAY-TEST (0=OFF, 1=ON)
GOSUB CLEAR_ALL
' ====== PROGRAM ================================================== ================================
INIT:
'FOR Letter_Cnt = 1 to 2
' FOR Y = 0 TO 7
' IF Letter_Cnt = 1 THEN lookup y,[ 0, 36, 36, 60, 36, 36, 24, 0],datareg ' A
' IF Letter_Cnt = 2 THEN lookup y,[ 0, 28, 36, 36, 28, 36, 28, 0],datareg ' B
' ADDRESS = Y + 1
' GOSUB MAXWRITE
' PAUSE 10
' NEXT Y
' PAUSE ScrollSpeed
'NEXT Letter_Cnt
'GOTO INIT
des = 0
for x = 0 to 6
for y = 0 to 6
lookup y,[ 0, 36, 36, 60, 36, 36, 24, 0],datareg ' A
address = y+1
datareg = datareg >> des
gosub maxwrite
pause 10
next y
pause ScrollSpeed
des = des + 1
next x
des = 0
for x = 0 to 6
for y = 0 to 6
lookup y,[ 0, 28, 36, 36, 28, 36, 28, 0],datareg ' B
address = y+1
datareg = datareg >> des
gosub maxwrite
pause 10
next y
pause ScrollSpeed
des = des + 1
next x
GOSUB CLEAR_ALL
GOTO INIT
END
' ====== SUBROUTINES ================================================== ============================
MaxWrite:
shiftout DAT,CLK,1,[ADDRESS,DATAREG] 'Shift out the data to the 'MAX7219 'first the address, then data.
pulsout LOAD,1 'load the data into the MAX7219
PAUSE 10
return
CLEAR_ALL:
for Y = 1 to 7 'write $0F (blank) to all digits
ADDRESS = Y
DATAREG = $00
gosub MaxWrite
next Y
return
'Letter A single dots (HEX 0024243c24241800)
' 0, 36, 36, 60, 36, 36, 24, 0
'Letter B single dots (HEX 001c24241c241c00)
' 0, 28, 36, 36, 28, 36, 28, 0
'Letter C single dots (HEX 0018240404241800)
' 0, 24, 36, 4, 4, 36, 24, 0
I'm trying to make my 8x8 LED matrix display (1 module) to smoothly scroll horizontally text (or simply letters) from right to left.
I started thanks to PBPBeginner and his example (http://www.picbasic.co.uk/forum/showthread.php?t=15735&p=109506#post109506).
Unfortunately, the example does "scroll" (shift) one caracter after the other meaning there is no close link between the displayed caracters and the next one; they shift from right to left one at the time.
I think there must be a way or an algorythm to calculate how to "append" the next caracter (or frame) to the currently display and make everything move from right to left.
For my tests, I designed two simple caracters here (https://xantorohara.github.io/led-matrix-editor/#) and to save my day, I designed all intermediate frames - but this is obvioulsy the wrong way to go and a huge waist of time.
9268 9269
Letter A
HEX 0024243c24241800
DEC 0, 36, 36, 60, 36, 36, 24, 0
Letter B
HEX 001c24241c241c00
DEC 0, 28, 36, 36, 28, 36, 28, 0
Does anyone have an example or point me on how I must calculate the transition steps please?
In a perfect world, I even should be able to trim some vertical empty lines of the frames to make the caracters appear close one to the other....
But I would appreciate a first simple start method to calculate this data to scroll.
'======= FUSES ================================================== ==================================
' PIC 16F690 Fuses
' Internal oscillator (activate OSCCON register)
@ __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_INTRC_OSC_NOCLKOUT &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF
@ ERRORLEVEL -306
@ ERRORLEVEL -202
'-------------------------------------------------------------------------------
' Registers 76543210
OPTION_REG = %10000000 'PORT A&B Pull-Ups disabled (look WPUA & WPUB)
OSCCON = %01110000 'Internal RC set to 8Mhz
ANSEL = %00000000 'Analog inputs Channels 0 to 7
ANSELH = %00000000 'Analog inputs Channels 8 to 11
WPUA = %00000000 'Weak pull-ups
WPUB = %00000000 'Weak pull-ups
ADCON0 = %00000000 'A/D Module (OFF)
CM1CON0 = %00000000 'Comparator1 Module (OFF)
CM2CON0 = %00000000 'Comparator2 Module (OFF)
INTCON = %00000000 'INTerrupts CONtrol
TRISA = %00000000 'Set Input/Output (0 to 5)
PORTA = %00000000 'Ports High/Low (0 to 5)
TRISB = %00000000 'Set Input/Output (4 to 7)
PORTB = %00000000 'Ports High/Low (4 to 7)
TRISC = %00000000 'Set Input/Output (0 to 7)
PORTC = %00000000 'Ports High/Low (0 to 7)
' ====== DEFINES ================================================== ================================
define OSC 8
DEFINE NO_CLRWDT 1
' ====== VARIABLES ================================================== ==============================
ADDRESS var word ' display's address
DATAREG var word ' display's data register
Y VAR BYTE ' just a counter
X var BYTE ' horizontal scroll steps counter
DES VAR BYTE
ScrollSpeed var word ' pause time
Letter_Cnt VAR BYTE ' caracter to be displayed
CLK VAR PORTB.4 ' connected to module's CLK
LOAD VAR PORTB.5 ' connected to module's CS
DAT VAR PORTB.6 ' connected to module's DIN
' ====== INITIALIZE ================================================== =============================
low clk
low dat
low load 'CS
ScrollSpeed = 400
Letter_Cnt = 1
' ====== MAX7219 SETUP ================================================== ==========================
ADDRESS = $0C : DATAREG = $01 : gosub MaxWrite ' SHUTDOWN=0, NORMAL OPERATION=1
ADDRESS = $09 : DATAREG = $00 : gosub MaxWrite ' DECODE-MODE, NO DECODE
ADDRESS = $0A : DATAREG = $00 : gosub MaxWrite ' LEDS INTENSITY MIN=0, MAX=F
ADDRESS = $0B : DATAREG = $07 : gosub MaxWrite ' NUMBER OF DISPLAYED LINES
ADDRESS = $0F : DATAREG = $00 : gosub MaxWrite ' DISPLAY-TEST (0=OFF, 1=ON)
GOSUB CLEAR_ALL
' ====== PROGRAM ================================================== ================================
INIT:
'FOR Letter_Cnt = 1 to 2
' FOR Y = 0 TO 7
' IF Letter_Cnt = 1 THEN lookup y,[ 0, 36, 36, 60, 36, 36, 24, 0],datareg ' A
' IF Letter_Cnt = 2 THEN lookup y,[ 0, 28, 36, 36, 28, 36, 28, 0],datareg ' B
' ADDRESS = Y + 1
' GOSUB MAXWRITE
' PAUSE 10
' NEXT Y
' PAUSE ScrollSpeed
'NEXT Letter_Cnt
'GOTO INIT
des = 0
for x = 0 to 6
for y = 0 to 6
lookup y,[ 0, 36, 36, 60, 36, 36, 24, 0],datareg ' A
address = y+1
datareg = datareg >> des
gosub maxwrite
pause 10
next y
pause ScrollSpeed
des = des + 1
next x
des = 0
for x = 0 to 6
for y = 0 to 6
lookup y,[ 0, 28, 36, 36, 28, 36, 28, 0],datareg ' B
address = y+1
datareg = datareg >> des
gosub maxwrite
pause 10
next y
pause ScrollSpeed
des = des + 1
next x
GOSUB CLEAR_ALL
GOTO INIT
END
' ====== SUBROUTINES ================================================== ============================
MaxWrite:
shiftout DAT,CLK,1,[ADDRESS,DATAREG] 'Shift out the data to the 'MAX7219 'first the address, then data.
pulsout LOAD,1 'load the data into the MAX7219
PAUSE 10
return
CLEAR_ALL:
for Y = 1 to 7 'write $0F (blank) to all digits
ADDRESS = Y
DATAREG = $00
gosub MaxWrite
next Y
return
'Letter A single dots (HEX 0024243c24241800)
' 0, 36, 36, 60, 36, 36, 24, 0
'Letter B single dots (HEX 001c24241c241c00)
' 0, 28, 36, 36, 28, 36, 28, 0
'Letter C single dots (HEX 0018240404241800)
' 0, 24, 36, 4, 4, 36, 24, 0