Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 00:50 18 Sep 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Scroll?

Author Message
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 01:49am 25 Nov 2015
Copy link to clipboard 
Print this post

Has anyone (@matherp, maybe?) done full or partial scroll with a ILI9341 display?

http://rittle.org

--------------
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10406
Posted: 02:45am 25 Nov 2015
Copy link to clipboard 
Print this post

  Quote  Has anyone (@matherp, maybe?) done full or partial scroll with a ILI9341 display?


Can only be done by keeping a map of what is on the display in MM memory. You can't read from the display memory on the ILI9341 when using SPI for reasons I don't understand - could be just bad implementation of MISO on the ILI9341 boards.

It does have hardware scroll of the complete screen width (page 120 ) but this is limited in what it can do but should be programmable from BasicEdited by matherp 2015-11-26
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 02:53am 25 Nov 2015
Copy link to clipboard 
Print this post

Thanks! Would you be willing to post an example for me please?
Edited by kiiid 2015-11-26
http://rittle.org

--------------
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10406
Posted: 09:30am 25 Nov 2015
Copy link to clipboard 
Print this post

Have a look at this

and this:



If the display is in landscape mode the text scrolls sideways and you can go 1 pixel at a time. This is all the hardware can do.


Code below, tested on MM+ but should also work on uM2:


'
' Demo of scrolling text in a display - constructed text
'
option explicit
option default none
const fixedspace%=21
'small
DATA "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"
DATA "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"
'tens
DATA "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"
'big
DATA "thousand", "million", "billion"
dim small(19) AS STRING length 10, tens(7) AS STRING length 10, big(2) AS STRING length 10

dim integer i,j1,j2,nextslot,scrollstart,counter=0
dim s$
FOR i = 1 TO 19
READ small(i)
NEXT
FOR i = 0 TO 7
READ tens(i)
NEXT
FOR i = 0 TO 2
READ big(i)
NEXT
open "com1:9600" as #1
cls
definescrollregion(fixedspace%,0) 'whole screen except top 21 lines, leaving 23 lines of 13 pixels
s$=chr$(0)+chr$(0)
i=controldisplay(&H37,s$) 'set the scroll area to normal
text 0,0,"Numbers"
nextslot=0
do
TEXT 0,nextslot+fixedspace%,int2text$(counter)
counter=counter+1
nextslot=nextslot+13 'add in the character height
loop while nextslot<299 'loop until the screen is full (320-fixedspace%)
do 'now loop forever each time writing to the bottom display line and scrolling
nextslot= (nextslot+13) mod 299
scrollstart=(nextslot+13) mod 299
TEXT 0,nextslot+fixedspace%,int2text$(counter)
counter=counter+1
j1=(scrollstart+fixedspace%) mod 256
j2=(scrollstart+fixedspace%) \ 256
s$=chr$(j2)+chr$(j1)
i=controldisplay(&H37,s$)
loop
end
'
sub definescrollregion(t%,b%) 'number of fixed lines at the top, number of fixed lines at the bottom
local integer t1,t2,s1,s2,b1,b2,i
local buff$
t1= t% mod 256
t2= t% \ 256
b1= b% mod 256
b2= b% \ 256
s1 = (320-t%-b%) mod 256
s2 = (320-t%-b%) \ 256
buff$=chr$(t2)+chr$(t1)+chr$(s2)+chr$(s1)+chr$(b2)+chr$(b1)
i=controldisplay(&H33,buff$)
end sub
'
CFunction controldisplay 'generic routine to send a command and a number of databytes to a ILI9341 display
00000000
3C03BF81 8C67F220 3C020661 27BDFFD8 7CE7D800 3446A053 AFB30020 AFB00014
AFBF0024 AFB2001C AFB10018 00809821 10E6006D 00A08021 8C63F220 2442A053
7C63D800 00621026 2411001C 2403002C 0062880A 3C02BF81 8C45F220 8C43F220
3C020580 3442A053 7CA5D800 00A22826 24040040 7C63D800 24421000 10620067
0085880A 2A310033 3A310001 3C129D00 8E430090 8E42001C 8064002C 0040F809
24050005 8E430090 8E42001C 8064002D 0040F809 24050005 1220003F 8E640000
3C02BF80 24030001 AC435A30 3C03BF80 AC445A20 8C625A10 30420080 1040FFFD
3C02BF80 8C425A20 3C029D00 8C430090 8C42001C 8064002C 0040F809 24050006
12000014 3C029D00 92020000 10400010 02002821 24040001 3C02BF80 12200019
90A30001 AC435A20 8C435A10 30630080 1060FFFD 3C03BF80 8C635A20 92030000
24840001 0064182A 1060FFF4 24A50001 3C029D00 8C430090 8C42001C 8064002D
0040F809 24050006 8FBF0024 8FB30020 8FB2001C 8FB10018 8FB00014 03E00008
27BD0028 AC435A20 8C435A10 30630080 1060FFFD 3C03BF80 8C635A20 92030000
24840001 0064182A 1060FFDC 24A50001 1000FFE8 3C029D00 24030001 3C02BF80
AC435830 3C02BF80 3C03BF80 AC445A20 8C625A10 30420080 1040FFFD 3C02BF80
1000FFC0 00000000 3C02BF81 8C45F220 8C43F220 3C020580 3442A053 7CA5D800
00A22826 2411002C 24040040 7C63D800 24421000 1462FF9B 0085880A 1000FF9B
24110001
End CFunction
'
FUNCTION int2Text$(number AS integer)
local num AS integer, outP AS STRING length 60, unit AS INTEGER
local tmpLng1 AS integer

IF 0 = number THEN
int2Text$ = "zero"
EXIT FUNCTION
END IF

num = ABS(number)

DO
tmpLng1 = num MOD 100
SELECT CASE tmpLng1
CASE 1 TO 19
outP = small(tmpLng1) + " " + outP
CASE 20 TO 99
SELECT CASE tmpLng1 MOD 10
CASE 0
outP = tens((tmpLng1 \ 10) - 2) + " " + outP
CASE ELSE
outP = tens((tmpLng1 \ 10) - 2) + "-" + small(tmpLng1 MOD 10) + " " + outP
END SELECT
END SELECT

tmpLng1 = (num MOD 1000) \ 100
IF tmpLng1 THEN
outP = small(tmpLng1) + " hundred " + outP
END IF

num = num \ 1000
IF num < 1 THEN EXIT DO

tmpLng1 = num MOD 1000
IF tmpLng1 THEN outP = big(unit) + " " + outP

unit = unit + 1
LOOP

IF number < 0 THEN outP = "negative " + outP
Do WHILE ASC(RIGHT$(outp,1))<=32
outp = LEFT$(outp,len(outp)-1)
loop
int2Text$ = outP
END FUNCTION


Also:


'
' Demo of scrolling text in a display - GPS monitor
'
option explicit
option default none
const fixedspace%=21
dim integer i,j1,j2,nextslot,scrollstart
DIM buff$,arg$(20) length 16
dim s$
open "com1:9600" as #1
cls
definescrollregion(fixedspace%,0) 'whole screen except top 21 lines, leaving 23 lines of 13 pixels
s$=chr$(0)+chr$(0)
i=controldisplay(&H37,s$) 'set the scroll area to normal
text 0,0,"GPS data"
nextslot=0
do
s$= GetGPSRecord$(i,arg$())
TEXT 0,nextslot+fixedspace%,s$)
nextslot=nextslot+13 'add in the character height
loop while nextslot<299 'loop until the screen is full (320-fixedspace%)
do
nextslot= (nextslot+13) mod 299
scrollstart=(nextslot+13) mod 299
s$= GetGPSRecord$(i,arg$())
TEXT 0,nextslot+fixedspace%,s$)
j1=(scrollstart+fixedspace%) mod 256
j2=(scrollstart+fixedspace%) \ 256
s$=chr$(j2)+chr$(j1)
i=controldisplay(&H37,s$)
loop
end
'
sub definescrollregion(t%,b%) 'number of fixed lines at the top, number of fixed lines at the bottom
local integer t1,t2,s1,s2,b1,b2,i
local buff$
t1= t% mod 256
t2= t% \ 256
b1= b% mod 256
b2= b% \ 256
s1 = (320-t%-b%) mod 256
s2 = (320-t%-b%) \ 256
buff$=chr$(t2)+chr$(t1)+chr$(s2)+chr$(s1)+chr$(b2)+chr$(b1)
i=controldisplay(&H33,buff$)
end sub
'
Function GetGPSRecord$(no_of_args%,arg$())
local integer i,cksum
local x$
DO
DO WHILE INPUT$(1, #1) <> "$" : LOOP ' wait for the start
GetGPSRecord$="$"
cksum=0
FOR i = 0 TO 20
arg$(i) = "" ' clear ready for data
DO ' loops until a specific exit
x$ = INPUT$(1, #1)
GetGPSRecord$=GetGPSRecord$+x$
if X$<>"*" then cksum=cksum xor asc(x$)
IF x$ = "," or X$="*" THEN EXIT DO ' new data item, new field
arg$(i) = arg$(i) + x$ ' add to the data
LOOP ' keep going
IF x$ = "*" THEN EXIT for ' end of record, so return with it
NEXT i ' increment the field
DO WHILE LOC(#1)<2:LOOP
X$=INPUT$(2,#1)
GetGPSRecord$=GetGPSRecord$+x$
LOOP WHILE X$<>HEX$(CKSUM,2)
no_of_args%=i
END function

CFunction controldisplay 'generic routine to send a caommand and a number of databytes to a ILI9341 display
00000000
3C03BF81 8C67F220 3C020661 27BDFFD8 7CE7D800 3446A053 AFB30020 AFB00014
AFBF0024 AFB2001C AFB10018 00809821 10E6006D 00A08021 8C63F220 2442A053
7C63D800 00621026 2411001C 2403002C 0062880A 3C02BF81 8C45F220 8C43F220
3C020580 3442A053 7CA5D800 00A22826 24040040 7C63D800 24421000 10620067
0085880A 2A310033 3A310001 3C129D00 8E430090 8E42001C 8064002C 0040F809
24050005 8E430090 8E42001C 8064002D 0040F809 24050005 1220003F 8E640000
3C02BF80 24030001 AC435A30 3C03BF80 AC445A20 8C625A10 30420080 1040FFFD
3C02BF80 8C425A20 3C029D00 8C430090 8C42001C 8064002C 0040F809 24050006
12000014 3C029D00 92020000 10400010 02002821 24040001 3C02BF80 12200019
90A30001 AC435A20 8C435A10 30630080 1060FFFD 3C03BF80 8C635A20 92030000
24840001 0064182A 1060FFF4 24A50001 3C029D00 8C430090 8C42001C 8064002D
0040F809 24050006 8FBF0024 8FB30020 8FB2001C 8FB10018 8FB00014 03E00008
27BD0028 AC435A20 8C435A10 30630080 1060FFFD 3C03BF80 8C635A20 92030000
24840001 0064182A 1060FFDC 24A50001 1000FFE8 3C029D00 24030001 3C02BF80
AC435830 3C02BF80 3C03BF80 AC445A20 8C625A10 30420080 1040FFFD 3C02BF80
1000FFC0 00000000 3C02BF81 8C45F220 8C43F220 3C020580 3442A053 7CA5D800
00A22826 2411002C 24040040 7C63D800 24421000 1462FF9B 0085880A 1000FF9B
24110001
End CFunction
Edited by matherp 2015-11-26
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 09:52am 25 Nov 2015
Copy link to clipboard 
Print this post

Thank you VERY MUCH!!!
That was of a great help to me. I think others 'miters may also benefit from your example.

http://rittle.org

--------------
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 07:57pm 25 Nov 2015
Copy link to clipboard 
Print this post

Yes, works on the uM2 with ILI9341 as well Peter - once again, nice job!

Greg
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1629
Posted: 10:04pm 25 Nov 2015
Copy link to clipboard 
Print this post

@Peter

thanks for the link to the manual!
It seems your code does not work (not scroll) on my mm2 (P,L mode).
(I slowed the output with an inserted pause.)
Maybe you can fix that?

But anyway thanks for your efforts!

Michael

causality ≠ correlation ≠ coincidence
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10406
Posted: 10:47pm 25 Nov 2015
Copy link to clipboard 
Print this post

  Quote  (P,L mode)
?
 
mpep
Newbie

Joined: 09/11/2014
Location: New Zealand
Posts: 29
Posted: 11:13pm 25 Nov 2015
Copy link to clipboard 
Print this post

Portrait and Landscape
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10406
Posted: 11:26pm 25 Nov 2015
Copy link to clipboard 
Print this post

  Quote  Portrait and Landscape


Possibly, but the fault report doesn't mean anything. Paceman has confirmed it works on uM2 and I have it working on MM+, i.e. it works.

However, it can only work as per the video in portrait mode (not reverse portrait, this would need different calcs of the address window) as the hardware scroll only works up and down.

In landscape mode you can use the hardware to scroll text left to right on the same line but not using the example code.

UPDATE:

Replacement Cfunction attached that tidies up one minor code issue. This has been tested with both MM+ and MM2 with screen set to Portrait mode:


CFunction controldisplay
00000000
3C03BF81 8C67F220 3C020661 27BDFFD8 7CE7D800 3446A053 AFB30020 AFB00014
AFBF0024 AFB2001C AFB10018 00809821 10E60068 00A08021 8C63F220 2442A053
7C63D800 00621026 2411001C 2403002C 0062880A 3C02BF81 8C45F220 8C43F220
3C020580 3442A053 7CA5D800 00A22826 24040040 7C63D800 24421000 10620062
0085880A 2A310033 3A310001 3C129D00 8E430090 8E42001C 8064002C 0040F809
24050005 8E430090 8E42001C 8064002D 0040F809 24050005 1220003A 8E640000
3C02BF80 24030001 AC435A30 3C03BF80 AC445A20 8C625A10 30420080 1040FFFD
3C02BF80 8C425A20 3C029D00 8C430090 8C42001C 8064002C 0040F809 24050006
12000014 3C029D00 92020000 10400010 02002821 24040001 3C02BF80 12200019
90A30001 AC435A20 8C435A10 30630080 1060FFFD 3C03BF80 8C635A20 92030000
24840001 0064182A 1060FFF4 24A50001 3C029D00 8C430090 8C42001C 8064002D
0040F809 24050006 8FBF0024 8FB30020 8FB2001C 8FB10018 8FB00014 03E00008
27BD0028 AC435820 8C435810 30630080 1060FFFD 3C03BF80 8C635820 1000FFE8
92030000 3C02BF80 24030001 AC435830 3C03BF80 AC445820 8C625810 30420080
1040FFFD 3C02BF80 8C425820 1000FFC7 3C029D00 3C02BF81 8C45F220 8C43F220
3C020580 3442A053 7CA5D800 00A22826 2411002C 24040040 7C63D800 24421000
1462FFA0 0085880A 1000FFA0 24110001
End CFunction



#define SPICON *(volatile unsigned int *)(0xbf805800)
#define SPISTAT *(volatile unsigned int *)(0xbf805810)
#define SPIBUF *(volatile unsigned int *)(0xbf805820)
#define SPIBRG *(volatile unsigned int *)(0xbf805830)
#define SPI2CON *(volatile unsigned int *)(0xbf805A00)
#define SPI2STAT *(volatile unsigned int *)(0xbf805A10)
#define SPI2BUF *(volatile unsigned int *)(0xbf805A20)
#define SPI2BRG *(volatile unsigned int *)(0xbf805A30)
#define SPIsend(a) {int j;SPIBUF=a; while((SPISTAT & 0x80)==0); j=SPIBUF;}
#define SPI2send(a) {int j;SPI2BUF=a; while((SPI2STAT & 0x80)==0); j=SPI2BUF;}

long long controldisplay(long *command, unsigned char *data){
int spi=0,k;
if(NBRPINS>50)spi=1; //decide which SPI port to use
PinSetBit(Option->LCD_CD, LATCLR);
PinSetBit(Option->LCD_CS, LATCLR);
if(spi){
SPI2BRG=1;
SPI2send(*command);
} else {
SPIBRG=1;
SPIsend(*command);
}
PinSetBit(Option->LCD_CD, LATSET);
if(data!=NULL){
for(k=1;k<=data[0];k++){
if(spi){
SPI2send(data[k]);
} else {
SPIsend(data[k]);
}
}
}
PinSetBit(Option->LCD_CS, LATSET);

}
Edited by matherp 2015-11-27
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1629
Posted: 02:59am 26 Nov 2015
Copy link to clipboard 
Print this post

Hi Peter,

I can confirm your second code works (P mode, MM2, BP170)!

Thats fantastic! And it offers new opportunities for the mites world!

Michael
causality ≠ correlation ≠ coincidence
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025