Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 14:43 05 May 2024 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 : MM2: Full colour graphics teaser

Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 10:38am 10 Dec 2014
Copy link to clipboard 
Print this post

Not fully worked yet but already much faster than Arduino.



 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 11:21am 10 Dec 2014
Copy link to clipboard 
Print this post

Holy Crap! That's exciting!!!! and faster than arduino, even better yet!
 
basicchip

Newbie

Joined: 25/11/2014
Location: United States
Posts: 9
Posted: 12:20pm 10 Dec 2014
Copy link to clipboard 
Print this post

Which display is that? I assume touch screen too.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 12:48pm 10 Dec 2014
Copy link to clipboard 
Print this post

Don't know where I got "Minimite" from duh...

This is the

Display :
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9066
Posted: 12:49pm 10 Dec 2014
Copy link to clipboard 
Print this post

That's exciting. Keep up the fantastic work!
Smoke makes things work. When the smoke gets out, it stops!
 
micronut
Newbie

Joined: 03/09/2014
Location: United States
Posts: 37
Posted: 01:12pm 10 Dec 2014
Copy link to clipboard 
Print this post

Peter, you never cease to amaze me! I spent 2 weeks trying to get my SEEED Studio TFT V1.0 to work with the Micromite and gave up. It uses the ST7781 as well. Please post your code when you get it working.Edited by micronut 2014-12-11
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 02:17pm 10 Dec 2014
Copy link to clipboard 
Print this post

Boom! That is fantastic! Can't wait to play with this.
My Propeller/Micromite mini-computer project.
 
retepsnikrep

Senior Member

Joined: 31/12/2007
Location: United Kingdom
Posts: 131
Posted: 05:49pm 10 Dec 2014
Copy link to clipboard 
Print this post

I ordered one as soon as I saw this in anticipation. Great work.
Gen1 Honda Insights.
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 07:53pm 10 Dec 2014
Copy link to clipboard 
Print this post

Matherp,

Wow,

I love it and at 1.99 GBP that is less than $4AUD


Crikey..

Will the 3.2" displays work just as well?

What sort of interface are you using?

I assume you use CFunctions.

Sorry for the inrush of questions, I feel excited but this.

Mick


Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 04:31am 11 Dec 2014
Copy link to clipboard 
Print this post

OK this code is about ready, hopefully it follows G8JCF's library standards but I await feedback

First some information:

This code has been tested on a display with the ST7783 controller chip. This seems to be the controller used for the 2.4" displays. I haven't got a 2.8" or 3.2" display but I suspect these use a slightly different controller variant. The basics for driving all these displays is the same, however, there may be slightly different sets of "magic" numbers needed to initialise them. The easiest way to find the magic numbers is to find working code from another source and duplicate the initialisation routine.

The displays use a 13-pin interface, 5 control lines and an 8-bit parallel data bus. The screens have 240 x 320 pixels, each of which can be updated with a 16 bit number to set the colour. The format of the number is &Brrrrrggggggbbbbb, i.e. 5bits for the red intensity, 6 for green and 5 for blue. This is known as RGB565.
So, to write the complete display we need to send 260*320*2 bytes of information which is something over 153,000 bytes!

In order to do this in a reasonable time the write software needs to be highly optimised. The attached code can write the complete screen in just 42msecs.

HOWEVER, this means there are constraints on which pins can be used. It is essential that the 8 bit parallel data bus is connected to contiguous pins based on the organisation of the PIC itself and not the pin numbering. Unfortunately using the 28-pin PICMX170 this means that the connection to the display must use the pins for both the i2c connections and the comm1 connections - there is no way round this. The attached code is hardwired to use pins 17,18,21,22,23,24,25 and 26 for the data bus (RB8-RB15 on the PIC). It is also hardwired to use 4,5,6 and 7 for the 4 main control pins. These could be changed in the cFunctions with only a minor impact on performace. Pin 14 is used as a reset line to the display from Basic and can be changed easily.

On a 44-pin Micromite, the problem is much eased. We can use the RC0-RC7 PIC pins for the data bus. These do not conflict with any of the critical Micromite I/O functions. I haven't got a 44-pin chip at the moment but will post revised cFunctions for this when I get one.

These limitations are no different to those on the Arduino where the display plugs into the Arduino and the pins used are completely pre-determined.

Other than the limitation on the pins, the code works well. It uses the same drawing primitives as my other graphics routines except these are now enhanced with a "colour" parameter. Character drawing needs two colours, one for the character itself and one for the background.

I haven't yet played with the touchscreen capability of the display. The lines to the touchscreen share pins with the display itself so you can either be checking for a "touch" or writing to the display but not both at the same time.

Anyway - enough waffle, the code contains the usual complete test harness to check all the functions and demonstrate usage.

2014-12-11_142958_colourscreen.zip



Edited by matherp 2014-12-12
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 05:54am 11 Dec 2014
Copy link to clipboard 
Print this post

Peter

This is just so impressive ! Your productivity is incredible

I really do like the way you've named the variables. One little trick is that MMBasic allows '.', ie period, to be used as part of variable names (David Hall showed us that trick !), and what that means is that one can get an almost object oriented feel/style, eg TFT.Init, Dim TFT.Params(3) etc. to MMBasic code.

The other thing is that when DIM is used, even inside a SUB/FUNCTION, DIM always declares a Global variable, so
dim integer AddrOfFont, TFT_params(3)
AddrOfFont=PEEK(CFunAddr FONT)


should be moved inside SUB TFT_Init().

The Global Constants unfortunately have to remain outside TFT_Init because if one declares Constants INSIDE a SUB/FUNCTION they only have scope within that Sub/Function. For that reason, I tend to not use the Const construct in Libraries, but use DIM instead - practically in terms of storage and performance, it seems to make no difference - eg DIM Integer TFT.Black=&H0000. Then these constants can be declared inside TFT_Init. The whole idea being to make the Library as self-contained as possible.

I think TFT is a bit too generic, so I would change TFT_ to 7753_ so that it is very clear which chipset this library deals with, then we'd have libraries for 7753, 3110, 5110 all written by yourself, and all with the same set of primitives - ah, which of course militates for NOT having chip specific naming, (allowing end users to simply swap in a library without having to change their MMBasic code) hmm ..... Perhaps all your display libraries should have a common naming convention, eg TFT.

I haven't got one of these displays so I can't try out your code sadly

I'm nearly done with editing your 3110 library (I do have one of those displays so I can make sure that whatever I do doesn't break your library).

I hope that my comments are helpful and constructive, and once again, your output rate is just fantastic (you are getting some sleep aren't you ), and you are pushing the boundaries of uMite forward single-handedly.

Peter
The only Konstant is Change
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 07:24am 11 Dec 2014
Copy link to clipboard 
Print this post

Peter

Modded as per your suggestions. I've used TFT.xxx for the function names and TFT_xxx for the variable names. As far as I'm concerned this is now ready for the library. Do we know where/what it is yet and how to get things in?

2014-12-11_172211_TFT.zip


' V1.0
' Graphics library with drivers for ST7753 TFT display
'
' drawing primitives assume a graphics display where top left is point 0, 0
'
' set screen orientation: sub TFT.setrot(x) ;TFT_normal=normal, TFT_inverse=invert, TFT_rt_right=rotate right, TFT_rt_left=rotate left
' draw circle: sub TFT.dcirc(x0, y0, r, colour) ;x, y coordinates of centre, radius, colour
' draw filled circle: sub TFT.fcirc(x0, y0, r, colour) ;x, y coordinates of centre, radius, colour
' draw triangle: sub TFT.dtri(x0, y0, x1, y1, x2, y2, colour) ;three coordinate pairs, colour
' draw filled triangle sub TFT.ftri (x0, y0, x1, y1, x2, y2, colour) ;three coordinate pairs, colour
' print string: sub TFT.pstring(xx0, yy0, text$, sz, orientation, forecolour, backcolour) ;x, y coordinates of top left of first character, text string, size, character orientation, foreground colour, background colour
' draw line: sub TFT.dline(xx0, yy0, xx1, yy1, colour) ;x, y of start line, x, y of end line, colour
' draw rectangle: sub TFT.drect(x, y, w, h, colour) ;x, y coordinate of top left, width, height, colour
' draw filled rectangle: sub TFT.frect(x, y, w, h, colour) ;x, y coordinate of top left, width, height, colour
' draw rounded rectangle: sub TFT.drndrect(x, y, w, h, r, colour) ;x, y coordinates of top left, width, height, radius of corner, colour
' draw filled rounded rectangle: sub TFT.frndrect(x, y, w, h, r, colour) ;x, y coordinates of top left, width, height, radius of corner, colour
'
option explicit
option default NONE
cpu 48
'
TFT_initialise
do
TFT_test
loop
end
'
' ST7783 specific routines
'
sub TFT.initdisplay
'
'Global "Constants"
'
dim integer TFT_CS=4 'b0
dim integer TFT_CD=5 'b1
dim integer TFT_WR=6 'b2
dim integer TFT_RD=7 'b3
dim integer TFT_RESET= 14 'b5
dim integer TFT_D0=17
dim integer TFT_D1=18
dim integer TFT_D2=21
dim integer TFT_D3=22
dim integer TFT_D4=23
dim integer TFT_D5=24
dim integer TFT_D6=25
dim integer TFT_D7=26
dim integer BLACK = &H0000 ' Color definitions: 16 bit (RGB565) colour palette so these are just examples
dim integer BLUE = &H001F
dim integer RED = &HF800
dim integer GREEN = &H07E0
dim integer CYAN = &H07FF
dim integer MAGENTA=&HF81F
dim integer YELLOW= &HFFE0
dim integer WHITE = &HFFFF
dim integer TFT.pix=0
dim integer TFT.ffr=1
dim integer TFT.drawchar=2
dim integer TFT.drawline=3
dim integer TFT.writecommand=4
dim integer TFT.writedata=5
dim integer TFT.fastfillscreen=6
dim integer TFT_width=0 'location of width parameter in params array
dim integer TFT_height=1 'location of height parameter in params array
dim integer TFT_rotation=2 'location of rotation parameter in params array
dim integer TFT_normal=0
dim integer TFT_inverse=1
dim integer TFT_rt_right=2
dim integer TFT_rt_left=3
'
' Global variables
'
dim integer TFT_AddrOfFont, TFT_params(3) ' Global variables
TFT_AddrOfFont=PEEK(CFunAddr FONT)
'
local integer i
TFT_params(TFT_width)=240
TFT_params(TFT_height)=320
pin(TFT_CS)=1
setpin TFT_CS, DOUT
pin(TFT_CD)=1
setpin TFT_CD, DOUT
pin(TFT_WR)=1
setpin TFT_WR, DOUT
pin(TFT_RD)=1
setpin TFT_RD, DOUT
pin(TFT_RESET)=1
setpin TFT_RESET, DOUT' Reset the display
TFT.setwrite
pin(TFT_RESET)=0
pause 100
pin(TFT_RESET)=1
pause 100
TFT.wreg(&HFF, 1)
TFT.wreg(&HF3, 8)
i=TFTdraw(TFT.writecommand, &HF3)
TFT.wreg(1, &H100)
TFT.wreg(2, &H700)
TFT.wreg(3, &H1030)
TFT.wreg(8, &H302)
TFT.wreg(9, 0)
TFT.wreg(&H10, 0)
TFT.wreg(&H11, 7)
TFT.wreg(&H12, 0)
TFT.wreg(&H13, 0)
pause 20
TFT.wreg(&H10, &H14B0)
pause 10
TFT.wreg(&H11, 7)
pause 10
TFT.wreg(&H12, &H8E)
TFT.wreg(&H13, &HC00)
TFT.wreg(&H29, &H15)
pause 10
TFT.wreg(&H30, 0)
TFT.wreg(&H31, &H107)
TFT.wreg(&H32, 0)
TFT.wreg(&H35, &H203)
TFT.wreg(&H36, &H402)
TFT.wreg(&H37, 0)
TFT.wreg(&H38, &H207)
TFT.wreg(&H39, 0)
TFT.wreg(&H3C, &H203)
TFT.wreg(&H3D, &H403)
TFT.wreg(&H50, 0)
TFT.wreg(&H51, &HEF)
TFT.wreg(&H52, 0)
TFT.wreg(&H53, &H13F)
TFT.wreg(&H60, &HA700)
TFT.wreg(&H61, 1)
TFT.wreg(&H90, &H29)
TFT.wreg(7, &H133)
pause 50
i=TFTdraw(TFT.writecommand, &H22)
end sub
'
sub TFT.wreg(register as integer, databyte as integer)
local integer i
i=TFTdraw(TFT.writecommand, register)
i=TFTdraw(TFT.writedata, databyte)
end sub
'
function TFT.rreg(register as integer) as integer
local integer i
i=TFTdraw(TFT.writecommand, register)
TFT.setread
TFT.rreg= TFT.readdata()
TFT.setwrite
end function
'
sub TFT_fillscreen(scol as integer)
local integer i=TFTdraw(TFT.fastfillscreen, scol, TFT_params())
end sub
'
end sub
'
function TFT.readdata() as integer
local integer i
pin(TFT_CS)=0
PIN(TFT_CD)=1
pin(TFT_WR)=1
pin(TFT_RD)=0
pause 1
i=(port(17, 2, 21, 6))<<8
pin(TFT_RD)=1
pin(TFT_RD)=0
pause 1
i=i+port(17, 2, 21, 6)
pin(TFT_RD)=1
pin(TFT_CS)=1
TFT.readdata=i
end function
'
sub TFT.setwrite
setpin TFT_D0, dout
setpin TFT_D1, dout
setpin TFT_D2, dout
setpin TFT_D3, dout
setpin TFT_D4, dout
setpin TFT_D5, dout
setpin TFT_D6, dout
setpin TFT_D7, dout
end sub
'
sub TFT.setread
setpin TFT_D0, din
setpin TFT_D1, din
setpin TFT_D2, din
setpin TFT_D3, din
setpin TFT_D4, din
setpin TFT_D5, din
setpin TFT_D6, din
setpin TFT_D7, din
end sub
'
' Generic drawing routines
'
sub TFT.dcirc(x0 as integer, y0 as integer, r as integer, colour as integer) 'x, y coordinates of centre, radius
local integer f=1-r, ddF_x=1, ddF_y=-2 * r, x=0, y=r, dp
dp=TFTdraw(TFT.pix, colour, x0, y0+r, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0, y0-r, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0+r, y0, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0-r, y0, TFT_params())
do while (x<y)
if f>=0 then
y=y-1
ddF_y=ddF_y+2
f=f+ddF_y
endif
x=x+1
ddF_x=ddF_x+2
f=f+ddF_x
dp=TFTdraw(TFT.pix, colour, x0+x, y0+y, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0-x, y0+y, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0+x, y0-y, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0-x, y0-y, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0+y, y0+x, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0-y, y0+x, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0+y, y0-x, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0-y, y0-x, TFT_params())
loop
end sub
'
sub TFT.dtri(x0 as integer, y0 as integer, x1 as integer, y1 as integer, x2 as integer, y2 as integer, colour as integer) 'three coordinate pairs
TFT.dline(x0, y0, x1, y1, colour)
TFT.dline(x1, y1, x2, y2, colour)
TFT.dline(x2, y2, x0, y0, colour)
end sub
'
sub TFT.ftri (x0 as integer, y0 as integer, x1 as integer, y1 as integer, x2 as integer, y2 as integer, colour as integer) 'three coordinate pairs
local integer a, b, y, dp, last
if (y0>y1) then
swap(y0, y1)
swap(x0, x1)
endif
if (y1>y2) then
swap(y2, y1)
swap(x2, x1)
endif
if (y0>y1) then
swap(y0, y1)
swap(x0, x1)
endif
if(y0=y2) then ' Handle awkward all-on-same-line case as its own thing
a=x0
b=x0
if(x1<a) then
a=x1
else
if(x1>b) then b=x1
endif
if(x2<a) then
a=x2
else
if(x2>b) then b=x2
endif
dp=TFTdraw(TFT.ffr, colour, a, y0, 1, b-a+1, TFT_params())
exit sub
endif
local integer dx01=x1-x0, dy01=y1-y0, dx02=x2-x0, dy02=y2-y0, dx12=x2-x1, dy12=y2-y1, sa=0, sb=0
if(y1=y2) then
last=y1 'Include y1 scanline
else
last=y1-1 ' Skip it
endif
for y=y0 to last
a=x0+sa \ dy01
b=x0+sb \ dy02
sa=sa+dx01
sb=sb+dx02
a=x0+(x1-x0) * (y-y0) \ (y1-y0)
b=x0+(x2-x0) * (y-y0) \ (y2-y0)
if(a>b) then swap(a, b)
dp=TFTdraw(TFT.ffr, colour, a, y, b-a+1, 1, TFT_params())
next y
sa=dx12 * (y-y1)
sb=dx02 * (y-y0)
do while y<=y2
a=x1+sa \ dy12
b=x0+sb \ dy02
sa=sa+dx12
sb=sb+dx02
a=x1+(x2-x1) * (y-y1) \ (y2-y1)
b=x0+(x2-x0) * (y-y0) \ (y2-y0)
if(a>b) then swap(a, b)
dp=TFTdraw(TFT.ffr, colour, a, y, b-a+1, 1, TFT_params())
y=y+1
loop
end sub
'
sub TFT.pstring(xx0 as integer, yy0 as integer, text$, sz as integer, orientation as integer, fontcolour as integer, backgroundcolour as integer) 'x, y coordinates of top left of first character, text string, size, orientation
local integer i, c, x=xx0, y=yy0, chr0, dp
for i=1 to len(text$)
c=asc(mid$(text$, i, 1))
chr0=TFT.Getchar(c) 'loads the character
dp=TFTdraw(TFT.drawchar, chr0, fontcolour, backgroundcolour, x, y, sz, orientation, TFT_params())
on orientation+1 goto pTFT_normal, pinvert, prtright, prtleft
pTFT_normal:
x=x+(6*sz)
goto pcontinue
pinvert:
x=x-(6*sz)
goto pcontinue
prtright:
y=y+(6*sz)
goto pcontinue
prtleft:
y=y-(6*sz)
pcontinue:
next i
xx0=x
yy0=y
end sub
'
sub TFT.dline(xx0 as integer, yy0 as integer, xx1 as integer, yy1 as integer, colour as integer) ' x, y of start line, x, y of end line
local integer dp=TFTdraw(TFT.drawline, colour, xx0, yy0, xx1, yy1, TFT_params())
end sub
'
sub swap (a% , b% )
local t%
t%=b%
b%=a%
a%=t%
end sub
'
sub TFT.drect(x as integer, y as integer, w as integer, h as integer, rcolour as integer) 'x, y coordinate of top left, wi, ht
local integer a, dp
dp=TFTdraw(TFT.ffr, rcolour, x, y, w, 1, TFT_params())
a=y+h-1
dp=TFTdraw(TFT.ffr, rcolour, x, a, w, 1, TFT_params())
dp=TFTdraw(TFT.ffr, rcolour, x, y, 1, h, TFT_params())
a=x+w-1
dp=TFTdraw(TFT.ffr, rcolour, a, y, 1, h, TFT_params())
end sub
'
sub TFT.frect(x as integer, y as integer, w as integer, h as integer, rcolour as integer) 'x, y coordinate of top left, width, height
local integer dp
dp=TFTdraw(TFT.ffr, rcolour, x, y, w, h, TFT_params())
end sub
'
FUNCTION TFT.Getchar(char as integer) as integer
local integer i=char<<3
TFT.Getchar=PEEK(WORD TFT_AddrOfFont+i)+(PEEK(WORD TFT_AddrOfFont+i+4)<<32)
END FUNCTION
'
sub TFT.fcirc(x0 as integer, y0 as integer, r as integer, ccolour as integer) 'x, y coordinates of centre, radius
local integer dp
dp=TFTdraw(TFT.ffr, ccolour, x0, y0-r, 1, 2*r+1, TFT_params())
TFT.fcircH(x0, y0, r, 3, 0, ccolour);
end sub
'
sub TFT.drndrect(x as integer, y as integer, w as integer, h as integer, r as integer, rcolour as integer) 'x, y coordinates of top left, width, height, radius of corner
local integer dp
dp=TFTdraw(TFT.ffr, rcolour, x+r, y, w-2*r, 1, TFT_params())
dp=TFTdraw(TFT.ffr, rcolour, x+r, y+h-1, w-2*r, 1, TFT_params())
dp=TFTdraw(TFT.ffr, rcolour, x, y+r, 1, h-2*r, TFT_params())
dp=TFTdraw(TFT.ffr, rcolour, x+w-1, y+r, 1, h-2*r, TFT_params())
TFT.dcircH(x+r, y+r, r, 1, rcolour)
TFT.dcircH(x+w-r-1, y+r, r, 2, rcolour)
TFT.dcircH(x+w-r-1, y+h-r-1, r, 4, rcolour)
TFT.dcircH(x+r, y+h-r-1, r, 8, rcolour)
end sub
'
sub TFT.dcircH( x0 as integer , y0 as integer , r as integer , cn as integer, colour as integer )
local integer f=1-r, ddF_x=1, ddF_y=-2 * r, x=0, y=r, dp
do while (x<y)
if (f>=0) then
y=y-1
ddF_y=ddF_y+2
f=f+ddF_y
endif
x=x+1
ddF_x=ddF_x+2
f=f+ddF_x
if (cn and 4) then
dp=TFTdraw(TFT.pix, colour, x0+x, y0+y, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0+y, y0+x, TFT_params())
endif
if (cn and 2) then
dp=TFTdraw(TFT.pix, colour, x0+x, y0-y, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0+y, y0-x, TFT_params())
endif
if (cn and 8) then
dp=TFTdraw(TFT.pix, colour, x0-y, y0+x, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0-x, y0+y, TFT_params())
endif
if (cn and 1) then
dp=TFTdraw(TFT.pix, colour, x0-y, y0-x, TFT_params())
dp=TFTdraw(TFT.pix, colour, x0-x, y0-y, TFT_params())
endif
loop
end sub
'
sub TFT.fcircH(x0 as integer, y0 as integer, r as integer, cn as integer, delta as integer, colour as integer)
local integer dp, f=1-r, ddF_x=1, ddF_y=-2 * r, x=0, y=r
do while x<y
if f>=0 then
y=y-1
ddF_y=ddF_y+2
f=f+ddF_y
endif
x=x+1
ddF_x=ddF_x+2
f=f+ddF_x
if (cn and 1) then
dp=TFTdraw(TFT.ffr, colour, x0+x, y0-y, 1, 2*y+1+delta, TFT_params())
dp=TFTdraw(TFT.ffr, colour, x0+y, y0-x, 1, 2*x+1+delta, TFT_params())
endif
if (cn and 2) then
dp=TFTdraw(TFT.ffr, colour, x0-x, y0-y, 1, 2*y+1+delta, TFT_params())
dp=TFTdraw(TFT.ffr, colour, x0-y, y0-x, 1, 2*x+1+delta, TFT_params())
endif
loop
end sub
'
sub TFT.frndrect(x as integer, y as integer, w as integer, h as integer, r as integer, colour as integer) 'x, y coordinates of top left, width, height, radius of corner
local integer dp
dp=TFTdraw(TFT.ffr, colour, x+r, y, w-2*r, h, TFT_params())
TFT.fcircH(x+w-r-1, y+r, r, 1, h-2*r-1, colour)
TFT.fcircH(x+r, y+r, r, 2, h-2*r-1, colour)
end sub
'
sub TFT.setrot(x%) 'sets screen rotation: 0=TFT_normal, 1=invert, 2=rotate right, 3-rotate left
TFT_params(TFT_rotation)=(x% and 3)
end sub
'
'D:\Peter\MPLABXProjects\TFT.X\dist\default\production\TFTdr aw.bas
'
'TFTdraw 2014-12-11 10:59:39 CFuncGen Ver 1.0.21 by user=Peter
'
CFunction TFTdraw
'TFT.writecommand
00000577
3c02bf88 24060001 ac466134 24030002 ac436134 24030004 ac436138 24050008
ac456138 ac436134 8c456130 30a500ff ac456130 8c456130 3087ff00 00e52825
ac456130 3c05bf81 8ca7f220 ac436138 8ca7f220 ac436134 8c476130 30e700ff
ac476130 8c476130 00042200 3084ffff 00872025 ac446130 8ca4f220 ac436138
ac466138 03e00008 00000000

'TFT.writedata
3c02bf88 24060001 ac466134 24030002 ac436138
24030004 ac436138 24050008 ac456138 ac436134 8c456130 30a500ff ac456130
8c456130 3087ff00 00e52825 ac456130 3c05bf81 8ca7f220 ac436138 8ca7f220
ac436134 8c476130 30e700ff ac476130 8c476130 00042200 3084ffff 00872025
ac446130 8ca4f220 ac436138 ac466138 03e00008 00000000

'TFT.fastfillscreen
27bdffe0 afbf001c
afb20018 afb10014 afb00010 3091ff00 00048200 3210ffff 8cb20000 8ca20008
72429002 24040020 0411FFAD 00000000 00002021 0411FFCD 00000000 24040021
0411FFA7 00000000 00002021 0411FFC7 00000000 24040022 0411FFA1 00000000
3c02bf88 24030001 ac436134 24030002 ac436138 24030004 ac436138 24030008
ac436138 1240001a 2652ffff 24030004 3c04bf81 2406ffff ac436134 8c456130
30a500ff ac456130 8c456130 02252825 ac456130 8c85f220 ac436138 8c85f220
ac436134 8c456130 30a500ff ac456130 8c456130 02052825 ac456130 8c85f220
ac436138 2652ffff 1646ffeb 00000000 24030001 3c02bf88 ac436138 8fbf001c
8fb20018 8fb10014 8fb00010 03e00008 27bd0020

'localfastfillrect
27bdffa8 afbf0054 afbe0050
afb7004c afb60048 afb50044 afb40040 afb3003c afb20038 afb10034 afb00030
8faa0068 8fa9006c 8fac0070 8faf0074 8fad0078 8fae007c 8fa30080 8c6b0000
8c780008 8c680010 3096ff00 00042200 15000033 3095ffff 04e00005 00002021
1487012e 00cb102b 1040012d 00001021 24c2ffff 0046282b 24e3ffff 00a32821
004c1821 0062102b 00af2821 00451021 afa30018 04400008 0040a021 14820004
2562ffff 006b182b 14600003 00000000 afa20018 0000a021 05200005 00002021
1489011b 0158102b 1040011a 00001021 2542ffff 004a282b 2523ffff 00a32821
004d1821 0062102b 00ae2821 00451021 afa30028 0440012d afa20010 54820005
2703ffff 0078182b 54600129 01401021 2703ffff afa30018 10000124 0000a021
24030001 15030030 24030002 00063027 00073827 00cb5821 0166302b 00c73021
afab0018 00c0a021 00001021 00001821 afa20020 04c00107 afa30024 000a5027
00094827 0158c021 030a502b 01495021 afb80028 054000f3 afaa0010 24020001
004c6023 004c102b 00c23023 018b5821 016c602b 00cf7823 018f2021 00041fc3
00033827 000747c3 01681024 00402821 24020001 004d6823 004d102b 01425023
01b8c021 030d682b 014e7023 01ae1821 00033fc3 00074827 000957c3 030a3024
10000073 00c01021 1503003b 000a2027 00091827 008b1021 0044202b 00831821
afa20018 04600009 0060a021 14600005 2563ffff 004b102b 14400005 24020001
2563ffff afa30018 0000a021 24020001 004d2023 0044102b 02821023 8fa50018
00851821 0064c82b 004e1023 00602821 03222021 00041fc3 00038827 001197c3
00b21024 00402821 04e00005 00002021 148700b8 00d8102b 104000b7 00001021
24c2ffff 0046c82b 24e3ffff 0323c821 004c1821 0062102b 032fc821 00591021
afa30028 0440000b afa20010 54820005 2702ffff 0078182b 54600007 00c01021
2702ffff afa20028 afa00010 10000002 00c01021 00c01021 24030003 55030035
8fa30010 05200005 00001021 1449009e 014b182b 1060009d 00001821 2543ffff
006a282b 2524ffff 00a42021 006d6821 01a3182b 008e7021 006e1821 afad0018
04600009 0060a021 54430005 256bffff 01ab682b 55a00005 00063027 256bffff
afab0018 0000a021 00063027 00073827 00d8c021 0306302b 00c73821 afb80028
afa70010 00001021 00001821 afa20020 04e00080 afa30024 24020001 004c6023
004c102b 00e23823 0198c021 030c602b 00ef7823 03001021 018f1821 04610004
01402821 01402821 1000000a 0000f021 8fa30010 04600055 0040f021 54600006
afa50014 8fa30028 0062102b 54400050 afb70020 afa50014 00009821 0293902a
24100004 8fa20018 0045282b afa5002c 24040020 0411FE72 00000000 8fb10014
02202021 0411FE91 00000000 24040021 0411FE6B 00000000 03c02021 0411FE8B
00000000 24040022 0411FE65 00000000 3c02bf88 24030001 ac436134 24030002
ac436138 24030004 ac436138 24030008 ac436138 56400022 24030001 16740004
3c02bf88 8fa5002c 14a0001e 24030001 3c03bf81 ac506134 8c446130 308400ff
ac446130 8c446130 02c42025 ac446130 8c64f220 ac506138 8c64f220 ac506134
8c446130 308400ff ac446130 8c446130 02a42025 ac446130 8c77f220 ac506138
16400006 26310001 1674ffea 8fa50018 00b1202b 1080ffe7 00000000 24030001
3c02bf88 ac436138 8fa30010 04600007 27de0001 1663ffbf 24040020 8fa50028
00be102b 1040ffbb 00000000 afb70020 00001821 10000017 afa30024 00001021
00001821 afa20020 10000012 afa30024 00001021 00001821 afa20020 1000000d
afa30024 00001821 afa20020 10000009 afa30024 00001021 00001821 afa20020
10000004 afa30024 00001821 afa20020 afa30024 8fa20020 8fa30024 8fbf0054
8fbe0050 8fb7004c 8fb60048 8fb50044 8fb40040 8fb3003c 8fb20038 8fb10034
8fb00030 03e00008 27bd0058 01401021 1000ff49 00c02821

'localdrawTFT.pixel
27bdffe0 afbf001c
afb20018 afb10014 afb00010 00808021 8fa80030 8fa40038 8c890000 8c8a0008
8c840010 14800006 8fa50034 00c08821 00e01021 01009021 10000019 00a01821
240b0001 148b000c 240b0002 00063027 00073827 00c98821 0226302b 00c71021
00084027 00052827 010a9021 0248402b 10000014 01051821 148b000a 240b0003
00c09021 00e01821 00084027 00052827 01098821 0228402b 1000000a 01051021
240b0003 148b0007 00063027 00073827 00ca9021 0246302b 00c71821 01008821
00a01021 14400004 24040001 0229482b 15200003 308400ff 00002021 308400ff
5080001f 00002021 14600004 24020001 024a502b 15400003 304200ff 00001021
304200ff 50400016 00002021 24040020 0411FDBB 00000000 02202021 0411FDDB
00000000 24040021 0411FDB5 00000000 02402021 0411FDD5 00000000 24040022
0411FDAF 00000000 02002021 0411FDCF 00000000 02202021 10000002 02402821
00002821 00801021 00a01821 8fbf001c 8fb20018 8fb10014 8fb00010 03e00008
27bd0020

'TFT.drawline
27bdffb8 afbf0044 afbe0040 afb7003c afb60038 afb50034 afb40030
afb3002c afb20028 afb10024 afb00020 afa40048 afa5004c 8fa20058 8fa30060
8fa40068 8fb60070 00c08021 00409021 00609821 0044a02a 00822823 00443823
00f4280a 00a0a021 00c3402a 00663823 00c32823 00e8280b 00b4a02a 12800005
0080a821 00809821 0060a821 00408021 00c09021 0270102a 10400008 0255102a
02401021 02a09021 0040a821 02001021 02608021 00409821 0255102a 10400007
0270b823 02b2a823 00178fc2 02378821 00118843 10000006 241e0001 0255a823
00178fc2 02378821 00118843 241effff 0270102a 14400020 8fbf0044 5280000d
afb20010 afb00010 001017c3 afa20014 afb60018 8fa40048 8fa5004c 02403021
00123fc3 0411FF54 00000000 1000000b 02358823 001217c3 afa20014 afb60018
8fa40048 8fa5004c 02003021 00103fc3 0411FF49 00000000 02358823 06210003
26100001 025e9021 02378821 0270102a 1040ffe2 8fbf0044 8fbe0040 8fb7003c
8fb60038 8fb50034 8fb40030 8fb3002c 8fb20028 8fb10024 8fb00020 03e00008
27bd0048

'TFT.drawchar
27bdff58 afbf00a4 afbe00a0 afb7009c afb60098 afb50094 afb40090
afb3008c afb20088 afb10084 afb00080 afa600b0 afa700b4 8fa200c0 afa20050
8fa300c4 afa30058 8fa600c8 afa6005c 8fa200cc afa20060 8fb000d0 8fb400d4
8fa300d8 afa30068 8fa600dc afa60070 afa40030 00661025 14400084 afa50034
8fa30050 24620005 0043182b afa20044 8fa40058 00641821 afa3004c 27b50030
24050005 afa50048 0200b021 0280b821 0200f021 10000060 afb40054 92a20000
02021007 30420001 10400022 24050001 24060001 57c60010 afb10010 8fa20054
5440000d afb10010 afb20010 afb40014 8fa300e0 afa30018 8fa400b0 8fa500b4
8fa60044 8fa7004c 0411FEF3 00000000 1000002f 26100001 afb30014 afb60018
afb7001c afb60020 afb70024 8fa400e0 afa40028 8fa400b0 8fa500b4 8fa6003c
8fa70040 0411FD73 00000000 10000020 26100001 57c50010 afb10010 8fa60054
54c0000d afb10010 afb20010 afb40014 8fa200e0 afa20018 8fa400b8 8fa500bc
8fa60044 8fa7004c 0411FED3 00000000 1000000f 26100001 afb30014 afb60018
afb7001c afb60020 afb70024 8fa300e0 afa30028 8fa400b8 8fa500bc 8fa6003c
8fa70040 0411FD53 00000000 26100001 02361021 0051182b 02779821 00408821
00739821 26420001 0052182b 00409021 24040008 1604ffb1 0074a021 8fa50048
24a5ffff afa50048 8fa60044 24c2ffff 0046202b 8fa5004c 24a3ffff afa20044
00831821 afa3004c 8fa60048 2402ffff 10c200be 26b50001 8fa40048 009e0019
00001012 00001810 8fa50054 70a43002 00c31821 8fa50050 00452021 0082282b
8fa60058 00661021 afa4003c 00a21021 afa20040 8fb2005c 8fb40060 02408821
02809821 1000ff8d 00008021 24020001 8fa30068 146200a9 24020002 8fa40070
148000a6 00142023 00101023 0002182b afa20074 00832023 afa40078 8fa50050
24a20001 0045202b 8fa60058 00862021 00501823 0043102b 00942023 afa30054
00822023 afa40064 afa50048 afa6004c 27b60035 27a2002f afa20038 8fa3005c
2463fff9 afa3006c 8fa4005c 24820001 0044182b 8fa50060 00651821 0050a823
0055102b 00741823 00621823 afa30044 8fbe00e0 1000006f 02009021 92c20000
02021007 30420001 10400028 00000000 1657000e 02120019 1680000d 00001012
afb10010 afb30014 afbe0018 8fa400b0 8fa500b4 8fa60048 8fa7004c 0411FE56
00000000 1000003f 2610ffff 00001012 00001810 72902002 00831821 02a22023
02a4282b 8fa60044 00c31023 00452823 afa40010 afa50014 afb20018 afb4001c
afb20020 afb40024 afbe0028 8fa400b0 8fa500b4 8fa6003c 8fa70040 0411FCCD
00000000 10000027 2610ffff 1657000e 02120019 1680000d 00001012 afb10010
afb30014 afbe0018 8fa400b8 8fa500bc 8fa60048 8fa7004c 0411FE2F 00000000
10000018 2610ffff 00001012 00001810 72902002 00831821 02a22023 02a4282b
8fa60044 00c31023 00452823 afa40010 afa50014 afb20018 afb4001c afb20020
afb40024 afbe0028 8fa400b8 8fa500bc 8fa6003c 8fa70040 0411FCA6 00000000
2610ffff 26220001 0051182b 00408821 2402ffff 1602ffa9 00739821 8fa30054
8fa40074 00641021 0043182b 8fa50064 8fa60078 00a62021 afa20054 00642021
afa40064 8fa30048 2462ffff 0043182b 8fa5004c 24a4ffff afa20048 00642021
afa4004c 26d6ffff 8fa60038 52c600a6 02408021 8fa20054 afa2003c 8fa30064
afa30040 8fa4006c 8fa5005c 0085982b 8fa60060 24c2ffff 00808821 02629821
24100007 1000ff85 24170001 03c08021 8fb40054 24020002 8fa30068 14620093
24020003 8fa40070 14800091 8fa30068 00101023 0002182b 00142023 afa20064
00832023 afa40068 8fa50050 24a20001 0045202b 8fa60058 00862021 00501823
0043102b 00942023 afa30048 00822023 afa4004c afa00044 0200b021 0280b821
27a2002f afa20038 0200f021 10000069 afb40054 92020000 02a21024 50400022
24020001 24030001 57c30010 afb10010 8fa40054 5480000d afb10010 afb20010
afb40014 8fa500e0 afa50018 8fa400b0 8fa500b4 8fa60050 8fa70058 0411FDB6
00000000 1000002f 2610ffff afb30014 afb60018 afb7001c afb60020 afb70024
8fa600e0 afa60028 8fa400b0 8fa500b4 8fa6003c 8fa70040 0411FC36 00000000
10000020 2610ffff 57c20010 afb10010 8fa30054 5460000d afb10010 afb20010
afb40014 8fa400e0 afa40018 8fa400b8 8fa500bc 8fa60050 8fa70058 0411FD96
00000000 1000000f 2610ffff afb30014 afb60018 afb7001c afb60020 afb70024
8fa500e0 afa50028 8fa400b8 8fa500bc 8fa6003c 8fa70040 0411FC16 00000000
2610ffff 02361021 0051182b 02779821 00408821 00739821 26420001 0052182b
00409021 8fa60038 1606ffb2 0074a021 8fa20044 24420001 afa20044 8fa30048
8fa40064 00641021 0043202b 8fa5004c 8fa60068 00a61821 afa20048 00831821
afa3004c 8fa30050 2462ffff 0043202b 8fa50058 24a3ffff afa20050 00831821
afa30058 8fa60044 24020008 10c200d0 8fbf00a4 24030001 8fa40044 0083a804
8fa50048 afa5003c 8fa6004c afa60040 27b00035 8fb1005c 8fb30060 02209021
1000ff8c 0260a021 24020003 8fa30068 146200be 8fa40070 148000bc 00101023
0002182b 00142023 afa2006c 00832023 afa40070 00101742 001418c0 00431825
001020c0 00901023 0082202b 00741823 00641823 8fa50050 00452021 0082102b
8fa60058 00661821 afa4004c 00431821 afa30054 24a20007 0045182b afa20044
00661821 afa30058 24020007 afa20048 8fa3005c 24620001 0043282b 8fa40060
00a42821 00101823 0003202b 00143023 00c42023 00033782 00042080 00c43025
00032080 00901821 0064202b 00d43021 00862021 000337c2 00042040 00c42025
00031840 00431821 afa30064 0062102b 00a41821 00431821 afa30074 8fa5005c
24a5fffb afa50068 8fa6005c 00a6182b 8fa40060 2482ffff 00621021 afa2005c
0280b021 10000068 0200a021 92020000 02e21024 10400021 24030001 24050001
5685000f afb10010 56c0000d afb10010 afb20010 afb50014 8fa600e0 afa60018
8fa400b0 8fa500b4 8fa60044 8fa70058 0411FCF9 00000000 1000002e 26100001
afb30014 afb40018 afb6001c afb40020 afb60024 8fa200e0 afa20028 8fa400b0
8fa500b4 8fa60040 8fa70050 0411FB79 00000000 1000001f 26100001 5683000f
afb10010 56c0000d afb10010 afb20010 afb50014 8fa400e0 afa40018 8fa400b8
8fa500bc 8fa60044 8fa70058 0411FCDA 00000000 1000000f 26100001 afb30014
afb40018 afb6001c afb40020 afb60024 8fa500e0 afa50028 8fa400b8 8fa500bc
8fa60040 8fa70050 0411FB5A 00000000 26100001 023e1021 0051182b 8fa6003c
02669821 00408821 00739821 26420001 0052182b 00409021 8fa20038 1602ffb3
0075a821 8fa30048 2463ffff afa30048 8fa4004c 8fa5006c 00851021 0044202b
8fa60054 8fa50070 00c51821 afa2004c 00831821 afa30054 8fa60044 24c2ffff
0046202b 8fa50058 24a3ffff afa20044 00831821 afa30058 2402ffff 8fa60048
10c20013 8fbf00a4 24170001 8fa20048 0057b804 8fa3004c afa30040 8fa40054
afa40050 27b00030 0280f021 afb6003c 8fb10064 8fb30074 8fb20068 8fb5005c
27a50036 1000ff89 afa50038 8fbf00a4 8fbe00a0 8fb7009c 8fb60098 8fb50094
8fb40090 8fb3008c 8fb20088 8fb10084 8fb00080 03e00008 27bd00a8

'main
27bdffb8
afbf0044 afb00040 00808021 00e05821 8faa0058 8fa9005c 8c820000 8c830004
00432025 14800010 8fa80060 8ca50000 8cc20000 8ce30000 afa30010 00031fc3
afa30014 afaa0018 00a02021 00052fc3 00403021 00023fc3 0411FC6F 00000000
10000078 8fbf0044 24040001 14440018 24040002 14600016 00000000 8ca40000
8ca50004 8cc70004 8cc60000 8d620000 8d630004 afa20010 afa30014 8d420000
8d430004 afa20018 afa3001c 8d220000 8d230004 afa20020 afa30024 afa80028
0411FAE4 00000000 1000005e 8fbf0044 14440023 24040003 14600021 00000000
8ca40000 8ca50004 8cc70004 8cc60000 8d620000 afa20010 000217c3 afa20014
8d420000 afa20018 000217c3 afa2001c 8d220000 afa20020 000217c3 afa20024
8d020000 afa20028 000217c3 afa2002c 8fa20064 8c420000 afa20030 000217c3
afa20034 8fa20068 afa20038 0411FCFD 00000000 8e020000 10000039 8e030004
14440019 24040004 14600017 00000000 8ca40000 8ca50004 8cc70004 8cc60000
8d620000 afa20010 000217c3 afa20014 8d420000 afa20018 000217c3 afa2001c
8d220000 afa20020 000217c3 afa20024 afa80028 0411FC7B 00000000 8e020000
1000001f 8e030004 14440009 24040005 14600007 00000000 8ca40000 0411FA10
00000000 8e020000 10000015 8e030004 14440009 24040006 14600007 00000000
8ca40000 0411FA29 00000000 8e020000 1000000b 8e030004 1444000a 8fbf0044
54600009 8fb00040 8ca40000 00c02821 0411FA41 00000000 8e020000 8e030004
8fbf0044 8fb00040 03e00008 27bd0048
End CFunction
'
CFunction font
00000000
00000000 00000000 4f5b3e00 00003e5b 4f6b3e00 00003e6b 7c3e1c00 00001c3e
7e3c1800 0000183c 7d571c00 00001c57 7f5e1c00 00001c5e 3c180000 00000018
c3e7ff00 0000ffe7 24180000 00000018 dbe7ff00 0000ffe7 3a060e00 00003048
79292600 00002629 05050700 0000407f 05253f00 0000407f e73c5a00 00005a3c
1c1c0800 00007f3e 1c3e7f00 0000081c 7f221400 00001422 005f5f00 00005f5f
7f017f00 00000609 89956a00 00000066 60606000 00006060 ffa29400 000094a2
7e040800 00000804 7e201000 00001020 2a1c0800 00000808 2a080800 0000081c
10101000 00001e10 0c1e0c00 00000c1e 3e383000 00003038 3e0e0600 0000060e
00000000 00000000 5f000000 00000000 00070000 00000007 147f1400 0000147f
7f2a1200 0000242a 08646200 00002313 56205000 00003649 07030000 00000008
22410000 0000001c 221c0000 00000041 7f1c2a00 00002a1c 3e080800 00000808
70300000 00000080 08080800 00000808 60600000 00000000 08040200 00002010
49453e00 00003e51 7f400000 00000042 49494600 00007249 494d3300 00002141
127f1000 00001814 45453900 00002745 49493100 00003c4a 11090700 00004121
49493600 00003649 49291e00 00004649 14000000 00000000 34000000 00000040
14224100 00000008 14141400 00001414 22140800 00000041 59090600 00000201
5d594e00 00003e41 11127c00 00007c12 49493600 00007f49 41412200 00003e41
41413e00 00007f41 49494100 00007f49 09090100 00007f09 41517300 00003e41
08087f00 00007f08 7f410000 00000041 413f0100 00002040 14224100 00007f08
40404000 00007f40 1c027f00 00007f02 08107f00 00007f04 41413e00 00003e41
09090600 00007f09 51215e00 00003e41 19294600 00007f09 49493200 00002649
7f010300 00000301 40403f00 00003f40 40201f00 00001f20 38403f00 00003f40
08146300 00006314 78040300 00000304 494d4300 00006159 41414100 0000007f
08102000 00000204 41417f00 00000041 01020400 00000402 40404000 00004040
07080000 00000003 54784000 00002054 44443800 00007f28 44442800 00003844
44287f00 00003844 54541800 00003854 7e090200 00000008 a49c7800 000018a4
04047800 00007f08 7d400000 00000044 403d0000 00002040 28440000 00007f10
7f400000 00000041 78047800 00007c04 04047800 00007c08 44443800 00003844
24241800 0000fc18 2418fc00 00001824 04040800 00007c08 54542400 00004854
3f442400 00000404 40207c00 00003c40 40201c00 00001c20 30403c00 00003c40
10284400 00004428 90907c00 00004c90 544c4400 00004464 36410000 00000008
77000000 00000000 36080000 00000041 02040200 00000201 23263c00 00003c26
a1611200 00001ea1 40207a00 00003a40 54555900 00003854 55794100 00002155
54784200 00002254 54784000 00002155 55794000 00002054 52721200 00000c1e
55555900 00003955 54545900 00003954 54545800 00003955 457c4100 00000000
457d4200 00000002 457c4000 00000001 11127d00 00007d12 2528f000 0000f028
55450000 00007c54 547c5400 00002054 097f4900 00007c0a 49493200 00003249
44443a00 00003a44 48483000 0000324a 41217a00 00003a41 40207800 00003a42
a0a07d00 0000009d 42423d00 00003d42 40403d00 00003d40 ff242400 00003c24
49436600 0000487e fc2f2b00 00002b2f 29f62000 0000ff09 7e090300 0000c088
54794100 00002054 447d4100 00000000 484a3200 00003048 40227a00 00003840
0a0a7200 0000007a 19317d00 00007d0d 292f2800 00002629 29292600 00002629
4d402000 00003048 08080800 00003808 08083800 00000808 c8acba00 00002f10
2834fa00 00002f10 7b000000 00000000 2a142200 00000814 2a140800 00002214
5500aa00 0000aa00 aa55aa00 0000aa55 00ff0000 00000000 10ff0000 00001010
14ff0000 00001414 ff00ff00 00001010 f010f000 00001010 14fc0000 00001414
f700ff00 00001414 ff00ff00 00000000 f404fc00 00001414 17101f00 00001414
1f101f00 00001010 141f0000 00001414 10f00000 00001010 001f1000 00000000
101f1000 00001010 10f01000 00001010 00ff1000 00000000 10101000 00001010
10ff1000 00001010 00ff1400 00000000 ff00ff00 00000000 1f101700 00000000
fc04f400 00000000 17101700 00001414 f404f400 00001414 ff00f700 00000000
14141400 00001414 f700f700 00001414 14171400 00001414 1f101f00 00001010
14f41400 00001414 f010f000 00001010 1f101f00 00000000 001f1400 00000000
00fc1400 00000000 f010f000 00000000 ff10ff00 00001010 14ff1400 00001414
101f0000 00001010 00f01000 00000000 ffffff00 0000ffff f0f0f000 0000f0f0
ff000000 0000ffff 00ffff00 00000000 0f0f0f00 00000f0f 44384400 00003844
4a4a3400 0000fc4a 02060600 00007e02 027e0200 0000027e 49416300 00006355
443c0400 00003844 201e2000 0000407e 7e020200 00000602 e7a59900 000099a5
492a1c00 00001c2a 01724c00 00004c72 4d4d3000 0000304a 78483000 00003048
5a463d00 0000bc62 49490000 00003e49 01017e00 00007e01 2a2a2a00 00002a2a
5f444400 00004444 4a444000 00004051 4a514000 00004044 ff010300 00000000
ff000000 0000e080 6b6b0800 00000808 36243600 00003612 090f0600 0000060f
18180000 00000000 10100000 00000000 ff010100 00003040 01011e00 0000001f
1d171200 00000019 3c3c3c00 0000003c 00000000 00000000
End CFunction
'
sub TFT_initialise
TFT.initdisplay
print "Controller type :", hex$(TFT.rreg(0), 4)
end sub
'
sub TFT_test
local integer i, xfs, yfs, x0, y0, x1, y1, wi, ht, sz
local float tn
TFT.setrot(0)
wi= TFT_params(0)
ht= TFT_params(1)
TFT_fillscreen(black)
TFT.pstring(40, 40, "Welcome to the", 2, 0, green, black)
TFT.pstring(5, 70, "Micromite MK2", 3, 0, red, black)
TFT.pstring(60, 120, "in colour", 2, 0, yellow, black)
pause 2000
' demo fast line draw
TFT.setrot(TFT_normal)
TFT_fillscreen(black)
x0=0:y0=0:y1=ht-1
for i=0 to 45 step 5
tn=tan(rad(i))
x1=wi*tn
TFT.dline(x0, y0, x1, y1, red)
next i
x1=wi-1
for i=0 to 40 step 5
tn=tan(rad(i))
y1=ht*tn
TFT.dline(x0, y0, x1, y1, red)
next i
TFT.drect(0, 00, wi, ht, blue)
pause 2000
TFT_fillscreen(black)
'demo fast text write
TFT.setrot(TFT_rt_right)
for i=0 to wi-8 step 8
TFT.pstring(0, i, "Hello world:Bye world:Hello world:Bye world:Hello world:Bye world", 1, TFT_normal, green, black)
next i
TFT.setrot(TFT_normal)
pause 2000
TFT_fillscreen(black)
for i=ht-1 to 15 step -16
TFT.pstring(wi-1, i, "Micromite MK2:Micromite MK2", 2, TFT_inverse, red, black)
next i
pause 2000
TFT_fillscreen(black)
for i=24 to wi step 24
TFT.pstring(i, 0, "Rotate right:Rotate right", 3, TFT_rt_right, yellow, black)
next i
pause 2000
TFT_fillscreen(black)
for i=wi-32 to 0 step -32
TFT.pstring(i, ht-1, "Rotate Left:Rotate Left", 4, TFT_rt_left, blue, black)
next i
pause 2000
TFT_fillscreen(black)
' test drawing rectangles
for i=0 to 3
TFT.setrot(i)
TFT.frect(5, 5, 10, 15, blue)
TFT.drect(2, 2, 16, 21, red)
next i
pause 2000
' test drawing rounded rectangles
TFT_fillscreen(black)
for i=0 to 3
TFT.setrot(i)
TFT.frndrect(5, 5, 10, 15, 4, blue)
TFT.drndrect(2, 2, 16, 21, 6, red)
next i
pause 2000
TFT_fillscreen(black)
' test drawing circles
for i=0 to 3
TFT.setrot(i)
TFT.fcirc(10, 10, 7, blue)
TFT.dcirc(10, 10, 9, red)
next i
pause 2000
' test drawing triangles and line drawing
TFT_fillscreen(black)
for i=0 to 3
TFT.setrot(i)
TFT.ftri(4, 4, 20, 6, 12, 14, blue)
TFT.dtri(1, 2, 24, 4, 12, 17, red)
next i
pause 2000
' test character output and string output at all orientations
for sz=1 to 3
TFT_fillscreen(black)
TFT.setrot(TFT_normal)
TFT.pstring(wi/2, ht/2, "N", 3, TFT_normal, white, black)
TFT.pstring(0, 0, "TFT_normal", sz, TFT_normal, red, black)
TFT.pstring(wi-1, ht-1, "Inverted", sz, TFT_inverse, blue, black)
TFT.pstring(wi-1, 0, "Rotated right", sz, TFT_rt_right, green, black)
TFT.pstring(0, ht-1, "Rotated left", sz, TFT_rt_left, yellow, black)
pause 2000
TFT_fillscreen(black)
TFT.setrot(TFT_inverse)
TFT.pstring(wi/2, ht/2, "I", 3, TFT_inverse, white, black)
TFT.pstring(0, 0, "TFT_normal", sz, TFT_normal, red, black)
TFT.pstring(wi-1, ht-1, "Inverted", sz, TFT_inverse, blue, black)
TFT.pstring(wi-1, 0, "Rotated right", sz, TFT_rt_right, green, black)
TFT.pstring(0, ht-1, "Rotated left", sz, TFT_rt_left, yellow, black)
pause 2000
TFT_fillscreen(black)
TFT.setrot(TFT_rt_right)
TFT.pstring(ht/2, wi/2, "R", 3, TFT_rt_left, white, black)
TFT.pstring(0, 0, "TFT_normal", sz, TFT_normal, red, black)
TFT.pstring(ht-1, wi-1, "Inverted", sz, TFT_inverse, blue, black)
TFT.pstring(ht-1, 0, "Rotated right", sz, TFT_rt_right, green, black)
TFT.pstring(0, wi-1, "Rotated left", sz, TFT_rt_left, yellow, black)
pause 2000
TFT_fillscreen(black)
TFT.setrot(TFT_rt_left)
TFT.pstring(ht/2, wi/2, "L", 3, TFT_rt_right, white, black)
TFT.pstring(0, 0, "TFT_normal", sz, TFT_normal, red, black)
TFT.pstring(ht-1, wi-1, "Inverted", sz, TFT_inverse, blue, black)
TFT.pstring(ht-1, 0, "Rotated right", sz, TFT_rt_right, green, black)
TFT.pstring(0, wi-1, "Rotated left", sz, TFT_rt_left, yellow, black)
pause 2000
next sz
end sub
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 07:49am 11 Dec 2014
Copy link to clipboard 
Print this post

Hi Peter

Looking nice !

Re the Library - there have been several different suggestions for hosting

1) To use David Hall's MMReference site
2) To use TBS
3) To use http://www.g8jcf.dyndns.org/MMBasicIILib/ and mirror that on a nightly batch basis onto other sites, eg CircuitGizmo, atmega8 and whoever else wants to act as a mirror

My site does NOT use any active content, eg PHP/PERL/ASPX, ie just pure HTML, so it should be very easy to mirror and not unduly load the mirror.

Until it is decided by the community definitively what's to be done, I'll continue as I have been doing.

Looking through your code above, I can see a set of good coding conventions emerging for Libraries.

1) SUB/FUNCTIONs should be preceded by the library name with a period, eg TFT.Init

2) Global Variables should be preceded by the library name with an underscore, eg TFT_I2CAddr

3) Global Constants should be preceded by the library name with an underscore and capitalised, TFT_BLACK

4) Every library should contain an libraryname.Init function, eg TFT.Init which must be called first and which
o Declares All Global Constants
o Declares All Global Variables
o Initialises Variables
o Initialises Hardware

5) Logically, every library should also contain an libraryname.Close function, eg TFT.Close which will terminate library operations, ie Release H/W, & Erase variables, but given the nature and use of embedded code, this function is normally unnecessary.

It may seem to some people that these proposed guidelines/standards/conventions are unnecessary and overly-restrictive, but, if end-users are to be able to just pick up and drop a library into their projects, then we have to "componentise" the software, thus minimising the need to go delving about inside the code to find conflicts for example.

Peter




The only Konstant is Change
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 10:25am 11 Dec 2014
Copy link to clipboard 
Print this post

Hi Peter

Here is the "edited" version of your SSD1306 Library. Please review and let me know your thoughts. I am hoping that this LIB can be used as the benchmark for how to create Libraries. I've done my best to NOT needlessly alter your original code.

OPTION EXPLICIT

'Go run the TestSuite
TestSuite()

END

'*********************************************************** **************************
'
' Peter Mather (edited by Peter Carnegie)
'
' V1.1
' 2014-12-11
'
' Monochrome Port of Adafruit graphics library with drivers for i2c SSD1306 display
'
' Initialise Display Library
' You MUST call TFT.Init BEFORE any other call to this library
' SUB TFT.Init(I2C_adr,I2C_Speed,wi,ht,nr)
'
' In : I2C_adr : I2C address of the display
' I2C_speed : [optional] Speed in KHz of the I2C bus, default 400
' wi : [optional] width in pixels of the display, default 128
' ht : [optional] height in pixels, default 64
' nr : [optional] number of rows, default=ht\8
'
' TFT.Init declares the following externally usable constants
' TFT_ON=1
' TFT_OFF=0
' TFT_RT_RIGHT=2 Rotate Right
' TFT_RT_LEFT=3 Rotate Left
' TFT_NORMAL=0 Normal Aspect
' TFT_INVERSE=1 Upside Down Aspect

' The Drawing Primitives assume a graphics display where top left is point 0,0
' The Drawing Primitives just update the memory image of the display
' To actually update the physical display call SUB S_Refresh

' Set screen orientation
' SUB TFT.SetRot(x)
' In : X 0=normal,1=invert,2=rotate right,3-rotate left

' Draw circle
' SUB TFT.DCirc(x0,y0,r)
' In : x,y coordinates of centre,radius

' Draw filled circle, ie a disc
' SUB TFT.FCirc(x0,y0,r)
' In: x,y coordinates of centre,r=radius

' Draw triangle
' SUB TFT.DTri(x0,y0, x1,y1, x2,y2)
' In: three coordinate pairs representing each vertex

' Draw filled triangle
' SUB TFT.FTri (x0,y0, x1,y1, x2,y2)
' In: three coordinate pairs representing each vertex

' Print string
' SUB TFT.PString(xx0,yy0,text$,sz,orientation)
' In: x,y, Coordinates of top left of first character,
' text$, String to display
' sz, Size of Text to display
' orientation Orientation of displayed text

' Draw line
' SUB TFT.DLine(xx0,yy0,xx1,yy1)
' In: x0,y0 start of line
' x1,y1 end of line

' Draw rectangle
' SUB TFT.DRect(x,y,w,h)
' In: x,y Coordinate of top left corner
' width Width
' height Height

' Draw filled rectangle
' SUB TFT.FRect(x,y,w,h)
' In: x,y Coordinate of top left corner
' width Width
' height Height

' Clear rectangluar area
' SUB TFT.CRect(x,y,w,h)
' In: x,y Coordinate of top left corner
' width Width
' height Height

' Draw rounded rectangle
' SUB TFT.DRndRect(x,y,w,h,r)
' In: x,y Coordinate of top left corner
' width Width
' height Height
' radius Radius of corners

' Draw filled rounded rectangle
' SUB TFT.FRndRect(x,y,w,h,r)
' In: x,y Coordinate of top left corner
' width Width
' height Height
' radius Radius of corners

' Update the physical display
' SUB TFT.Refresh
' In: N/A

' Clear the physical display and internal memory map
' SUB TFT.Cls
' In: N/A

'
' Initialise Display Library
' You MUST call TFT.Init BEFORE any other call to this library
' SUB TFT.Init(I2C_adr,I2C_Speed,wi,ht,nr)
'
' In : I2C_adr : I2C address of the display
' I2C_speed : [optional] Speed in KHz of the I2C bus, default 400
' wi : [optional] width in pixels of the display, default 128
' ht : [optional] height in pixels, default 64
' nr : [optional] number of rows, default=ht\8
'
' TFT.Init declares the following externally usable constants
' TFT_ON=1
' TFT_OFF=0
' TFT_RT_RIGHT=2 Rotate Right
' TFT_RT_LEFT=3 Rotate Left
' TFT_NORMAL=0 Normal Aspect
' TFT_INVERSE=1 Upside Down Aspect
'
SUB TFT.Init(I2C_adr,I2C_Speed,wi,ht,nr)
IF I2C_Speed=0 THEN I2C_Speed=400
IF wi=0 THEN wi=128
IF ht=0 THEN ht=64
IF nr=0 THEN nr=ht\8

' Global variables
DIM INTEGER TFT_w1,TFT_ht,TFT_nr,TFT_i2caddr,TFT_rot_ht,TFT_rot_wi,TFT_r ot,TFT_FontPtr

'set up arrays for screen map to mimic display
DIM INTEGER TFT_sc(wi),TFT_dd(wi)

'Global Constants
'CFunction DRAW function Indexes [sic]
DIM Integer TFT_PIX=0,TFT_FFR=1,TFT_DRAWCHAR=2,TFT_DRAWLINE=3

'Used by User program in calls to drawing primitives
DIM Integer TFT_ON=1,TFT_OFF=0
DIM Integer TFT_NORMAL=0,TFT_INVERSE=1,TFT_RT_RIGHT=2,TFT_RT_LEFT=3

TFT_FontPtr=PEEK(CFunAddr TFT_FONT)
TFT_i2caddr=I2C_adr
TFT_w1=wi
TFT_ht=ht
TFT_nr=nr

LOCAL i%

'Open up the I2C Bus if not already open
IF TFT.isI2COpen()<>1 THEN
I2C OPEN I2C_Speed,1000
ENDIF

TFT.SCmd(&HAE)'DISPLAYOFF)
TFT.SCmd(&HD5)'DISPLAYCLOCKDIV
TFT.SCmd(&H80)'the suggested ratio &H80
TFT.SCmd(&HA8)'MULTIPLEX
TFT.SCmd(&H3F)'
TFT.SCmd(&HD3)'DISPLAYOFFSET
TFT.SCmd(&H0)'no offset
TFT.SCmd(&H40)'STARTLINE
TFT.SCmd(&H8D)'CHARGEPUMP
TFT.SCmd(&H14)
TFT.SCmd(&H20)'MEMORYMODE
TFT.SCmd(&H00)'&H0 act like ks0108
TFT.SCmd(&HA1)'SEGREMAP OR 1
TFT.SCmd(&HC8)'COMSCANDEC
TFT.SCmd(&HDA)'COMPINS
TFT.SCmd(&H12)
TFT.SCmd(&H81)'SETCONTRAST
TFT.SCmd(&HCF)
TFT.SCmd(&Hd9)'SETPRECHARGE
TFT.SCmd(&HF1)
TFT.SCmd(&HDB)'VCOMDETECT
TFT.SCmd(&H40)
TFT.SCmd(&HA4)'DISPLAYALLON_RESUME
TFT.SCmd(&HA6)'NORMALDISPLAY
TFT.SCmd(&HAF)'DISPLAYON

FOR i%=0 TO TFT_w1-1 'force the whole screen to be re-written at the next refresh
TFT_dd(i%)= -1 '&HFFFFFFFFFFFFFFFF
TFT_sc(i%)=0
NEXT i%

TFT.Refresh

END SUB

SUB TFT.SCmd(Comnd%)
I2C WRITE TFT_i2caddr,0,2,&H00,Comnd%
END SUB


SUB TFT.Refresh()
LOCAL StartRow%,StartCol%,R%
LOCAL OutChar$ length 130
TFT.SCz(0,0)
DO
R%=TFT.SGetNextUpdate(OutChar$,StartCol%,StartRow%,TFT_w1,TF T_nr,TFT_sc(),TFT_dd())
IF R%<>0 THEN
TFT.SCz(StartCol%,StartRow%)
I2C WRITE TFT_i2caddr,0,LEN(OutChar$),OutChar$
ENDIF
LOOP WHILE R%<>0
END SUB

'Clear Screen
SUB TFT.Cls
LOCAL i
FOR i=0 TO TFT_w1-1
TFT_sc(i)=0
NEXT i
TFT.Refresh
END SUB


SUB TFT.SCz(x%,y%)
TFT.SCmd(&HB0+y%) 'set page address
TFT.SCmd(&H10+(x%>>4 AND &H0F)) 'set high col address
TFT.SCmd(&H00+(x% AND &H0f)) 'set low col address
END SUB

'
' Generic drawing routines
'
SUB TFT.DCirc(x0 AS Integer,y0 AS Integer,r AS Integer) 'x,y coordinates of centre,radius
LOCAL Integer f=1-r,ddF_x=1,ddF_y=-2*r,x=0,y=r,dp
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0,y0+r,TFT_rot,TFT_w1,T FT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0,y0-r,TFT_rot,TFT_w1,T FT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0+r,y0,TFT_rot,TFT_w1,T FT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0-r,y0,TFT_rot,TFT_w1,T FT_ht)
DO WHILE (x<y)
IF f>=0 THEN
y=y-1
ddF_y=ddF_y+2
f=f+ddF_y
ENDIF
x=x+1
ddF_x=ddF_x+2
f=f+ddF_x
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0+x,y0+y,TFT_rot,TFT_w1 ,TFT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0-x,y0+y,TFT_rot,TFT_w1 ,TFT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0+x,y0-y,TFT_rot,TFT_w1 ,TFT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0-x,y0-y,TFT_rot,TFT_w1 ,TFT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0+y,y0+x,TFT_rot,TFT_w1 ,TFT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0-y,y0+x,TFT_rot,TFT_w1 ,TFT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0+y,y0-x,TFT_rot,TFT_w1 ,TFT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0-y,y0-x,TFT_rot,TFT_w1 ,TFT_ht)
LOOP
END SUB


SUB TFT.DTri(x0 AS Integer,y0 AS Integer,x1 AS Integer,y1 AS Integer,x2 AS Integer,y2 AS Integer) 'three coordinate pairs
TFT.DLine(x0,y0,x1,y1)
TFT.DLine(x1,y1,x2,y2)
TFT.DLine(x2,y2,x0,y0)
END SUB


SUB TFT.FTri (x0 AS Integer,y0 AS Integer,x1 AS Integer,y1 AS Integer,x2 AS Integer,y2 AS Integer) 'three coordinate pairs
LOCAL Integer a,b,y,dp,last
IF (y0>y1) THEN
TFT.Swap(y0,y1)
TFT.Swap(x0,x1)
ENDIF
IF (y1>y2) THEN
TFT.Swap(y2,y1)
TFT.Swap(x2,x1)
ENDIF
IF (y0>y1) THEN
TFT.Swap(y0,y1)
TFT.Swap(x0,x1)
ENDIF
IF(y0=y2) THEN ' Handle awkward all-on-same-line case as its own thing
a=x0
b=x0
IF(x1<a) THEN
a=x1
ELSE
IF(x1>b) THEN b=x1
ENDIF
IF(x2<a) THEN
a=x2
ELSE
IF(x2>b) THEN b=x2
ENDIF
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,a,y0,1,b-a+1,TFT_rot,TFT _w1,TFT_ht)
EXIT SUB
ENDIF

LOCAL Integer dx01=x1-x0, dy01=y1-y0, dx02=x2-x0, dy02=y2-y0,dx12=x2-x1, dy12=y2-y1, sa=0,sb=0

IF(y1=y2) THEN
last=y1 'Include y1 scanline
ELSE
last=y1-1 ' Skip it
ENDIF

FOR y=y0 TO last
a=x0+sa \ dy01
b=x0+sb \ dy02
sa=sa+dx01
sb=sb+dx02
a=x0+(x1-x0) * (y-y0) \ (y1-y0)
b=x0+(x2-x0) * (y-y0) \ (y2-y0)
IF(a>b) THEN TFT.Swap(a,b)
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,a,y,b-a+1,1,TFT_rot,TFT_ w1,TFT_ht)
NEXT y

sa=dx12 * (y-y1)
sb=dx02 * (y-y0)

DO WHILE y<=y2
a=x1+sa \ dy12
b=x0+sb \ dy02
sa=sa+dx12
sb=sb+dx02
a=x1+(x2-x1) * (y-y1) \ (y2-y1)
b=x0+(x2-x0) * (y-y0) \ (y2-y0)
IF(a>b) THEN TFT.Swap(a,b)
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,a,y,b-a+1,1,TFT_rot,TFT_ w1,TFT_ht)
y=y+1
LOOP
END SUB


SUB TFT.PString(xx0%,yy0%,text$,sz%,orientation%) 'x,y coordinates of top left of first character,text string,size,orientation
LOCAL i%,c%,x%=xx0%,y%=yy0%,chr0%,dp%
FOR i%=1 TO LEN(text$)
c%=ASC(MID$(text$,i%,1))
chr0%=TFT.GetChar(c%) 'loads the character
'CONST drawchar=2
dp%=TFT.Draw(2,TFT_sc(),chr0%,x%,y%,sz%,orientation%,TFT_rot ,TFT_w1,TFT_ht)
c%=6*sz%
SELECT CASE orientation%
CASE 0
x%=x%+c%
CASE 1
x%=x%-c%
CASE 2
y%=y%+c%
CASE 3
y%=y%-c%
END SELECT
' ON orientation%+1 GOTO pnormal,pinvert,prtright,prtleft
'pnormal:
' x%=x%+c% '(6*sz%)
' GOTO pcontinue
'pinvert:
' x%=x%-c% '(6*sz%)
' GOTO pcontinue
'prtright:
' y%=y%+c% '(6*sz%)
' GOTO pcontinue
'prtleft:
' y%=y%-c% '(6*sz%)
'pcontinue:
NEXT i%
'xx0=x
'yy0=y
END SUB


SUB TFT.DLine(xx0%,yy0%,xx1%,yy1%) ' x,y of start line,x,y of end line
'CONST drawline=3
LOCAL dp%=TFT.Draw(3,TFT_sc(),TFT_ON,xx0%,yy0%,xx1%,yy1%,TFT_rot,T FT_w1,TFT_ht)
END SUB


SUB TFT.Swap(a%,b%)
LOCAL t%
t%=b%
b%=a%
a%=t%
END SUB


SUB TFT.DRect(x AS integer,y AS integer,w AS integer,h AS integer ) 'x,y coordinate of top left,TFT_w1,TFT_ht
LOCAL Integer a,dp
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x,y,w,1,TFT_rot,TFT_w1,T FT_ht)
a=y+h-1
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x,a,w,1,TFT_rot,TFT_w1,T FT_ht)
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x,y,1,h,TFT_rot,TFT_w1,T FT_ht)
a=x+w-1
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,a,y,1,h,TFT_rot,TFT_w1,T FT_ht)
END SUB


SUB TFT.FRect(x AS integer,y AS integer,w AS integer,h AS integer ) 'x,y coordinate of top left,width,height
LOCAL Integer dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x,y,w,h,TFT_rot,TFT_w1,T FT_ht)
END SUB


SUB TFT.CRect(x AS integer,y AS integer,w AS integer,h AS integer) 'x,y coordinate of top left,width,height
LOCAL Integer dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_OFF,x,y,w,h,TFT_rot,TFT_w1, TFT_ht)
END SUB


FUNCTION TFT.GetChar(char AS integer ) AS Integer
LOCAL i%=char<<3
TFT.GetChar=PEEK(WORD TFT_FontPtr+i%)+(PEEK(WORD TFT_FontPtr+i%+4)<<32)
END FUNCTION


SUB TFT.FCirc(x0%,y0%,r%) 'x,y coordinates of centre,radius
LOCAL dp%=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x0%,y0%-r%,1,2*r%+1,TFT _rot,TFT_w1,TFT_ht)
TFT.FCircH(x0%,y0%,r%,3,0);
END SUB


SUB TFT.DRndRect(x AS integer,y AS integer,w AS integer,h AS integer,r AS integer ) 'x,y coordinates of top left,width,height,radius of corner
LOCAL Integer dp
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x+r,y,w-2*r,1,TFT_rot,TF T_w1,TFT_ht)
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x+r,y+h-1,w-2*r,1,TFT_ro t,TFT_w1,TFT_ht)
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x,y+r,1,h-2*r,TFT_rot,TF T_w1,TFT_ht)
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x+w-1,y+r,1,h-2*r,TFT_ro t,TFT_w1,TFT_ht)
TFT.DCircH(x+r,y+r,r,1)
TFT.DCircH(x+w-r-1,y+r,r,2)
TFT.DCircH(x+w-r-1,y+h-r-1,r,4)
TFT.DCircH(x+r,y+h-r-1,r,8)
END SUB


SUB TFT.DCircH(x0 AS integer,y0 AS integer,r AS integer,cn AS integer)
LOCAL Integer f=1-r,ddF_x=1,ddF_y=-2*r,x=0,y=r,dp
DO WHILE (x<y)
IF (f>=0) THEN
y=y-1
ddF_y=ddF_y+2
f=f+ddF_y
ENDIF
x=x+1
ddF_x=ddF_x+2
f=f+ddF_x
IF (cn AND 4) THEN
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0+x,y0+y,TFT_rot,TFT_w1 ,TFT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0+y,y0+x,TFT_rot,TFT_w1 ,TFT_ht)
ENDIF
IF (cn AND 2) THEN
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0+x,y0-y,TFT_rot,TFT_w1 ,TFT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0+y,y0-x,TFT_rot,TFT_w1 ,TFT_ht)
ENDIF
IF (cn AND 8) THEN
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0-y,y0+x,TFT_rot,TFT_w1 ,TFT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0-x,y0+y,TFT_rot,TFT_w1 ,TFT_ht)
ENDIF
IF (cn AND 1) THEN
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0-y,y0-x,TFT_rot,TFT_w1 ,TFT_ht)
dp=TFT.Draw(TFT_PIX,TFT_sc(),TFT_ON,x0-x,y0-y,TFT_rot,TFT_w1 ,TFT_ht)
ENDIF
LOOP
END SUB


SUB TFT.FCircH(x0 AS integer,y0 AS integer,r AS integer,cn AS integer,delta AS integer)
LOCAL Integer dp,f=1-r,ddF_x=1,ddF_y=-2 * r,x=0,y=r
DO WHILE x<y
IF f>=0 THEN
y=y-1
ddF_y=ddF_y+2
f=f+ddF_y
ENDIF
x=x+1
ddF_x=ddF_x+2
f=f+ddF_x
IF (cn AND 1) THEN
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x0+x,y0-y,1,2*y+1+delta, TFT_rot,TFT_w1,TFT_ht)
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x0+y,y0-x,1,2*x+1+delta, TFT_rot,TFT_w1,TFT_ht)
ENDIF
IF (cn AND 2) THEN
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x0-x,y0-y,1,2*y+1+delta, TFT_rot,TFT_w1,TFT_ht)
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x0-y,y0-x,1,2*x+1+delta, TFT_rot,TFT_w1,TFT_ht)
ENDIF
LOOP
END SUB


SUB TFT.FRndRect(x AS integer,y AS integer,w AS integer,h AS integer,r AS integer) 'x,y coordinates of top left,width,height,radius of corner
LOCAL Integer dp
dp=TFT.Draw(TFT_FFR,TFT_sc(),TFT_ON,x+r,y,w-2*r,h,TFT_rot,TF T_w1,TFT_ht)
TFT.FCircH(x+w-r-1,y+r,r,1,h-2*r-1)
TFT.FCircH(x+r,y+r,r,2,h-2*r-1)
END SUB


SUB TFT.SetRot(x%) 'sets screen rotation: 0=normal,1=invert,2=rotate right,3-rotate left
TFT_rot=(x% AND 3)
TFT_rot_wi=TFT_w1
TFT_rot_ht=TFT_ht
IF x%>=2 THEN
TFT_rot_wi=TFT_ht
TFT_rot_ht=TFT_w1
ENDIF
END SUB

'
' CFunctions
'
CFUNCTION TFT.SGetNextUpdate
00000000
27bdffa8 afb00054 8fb80068 8faf006c 8fae0070 24020040 a0820001 8f090000
1120000b 00001021 00094880 2403ffff 27aa0010 01424021 ad030000 27b00030
02024021 24420004 1449fffa ad030000 8ce20000 1040002a 00004021 8f190000
00005821 240dffff 000840c0 01e81021 8c430004 8c420000 afa20000 afa30004
01c84021 8d020000 8d030004 afa20008 13200016 afa3000c 8f0c0000 27a30010
27a80030 00001021 03a25021 27b00008 02024821 914a0000 91290000 51490007
24420001 8c690000 552d0003 ad0b0000 ac6b0000 ad0b0000 24420001 24630004
004c482b 1520fff0 25080004 256b0001 8ce20000 0162102b 1440ffdb 01604021
8f020000 2442ffff 00004021 04400036 00004821 00021880 27a70010 00e31821
240bffff 2408ffff 8c670000 00e83826 0047580b 2442ffff 0441fffb 2463fffc
00004021 2402ffff 11620027 00004821 000b1080 03a21021 8c4a0010 acaa0000
8c4d0030 01aa102a 1440001b 24070001 000a28c0 01e57821 01c52821 03ab6021
8de20000 8de30004 afa20000 afa30004 8ca20000 8ca30004 afa20008 afa3000c
24e70001 91820000 a1820008 00871821 a0620000 8fa20008 8fa3000c aca20000
aca30004 254a0001 25ef0008 01aa102a 1040ffeb 24a50008 accb0000 a0870000
00e04021 00074fc3 01001021 01201821 8fb00054 03e00008 27bd0058
END CFUNCTION

CFUNCTION TFT.Draw
'localfastfillrect
000006B4
27bdffa0 afbe005c afb70058 afb60054 afb50050 afb4004c afb30048 afb20044
afb10040 afb0003c 8fb80070 8fae0074 8fb10078 8fb9007c 8fb40080 8fb50084
8fa90088 afa90028 8fb6008c 8fad0090 8faf0094 8fb20098 8fa9009c 8fb300a0
8fb000a4 2417ffff a3b70008 241efffe a3be0009 241efffc a3be000a 241efff8
a3be000b 241efff0 a3be000c 241effe0 a3be000d 241effc0 a3be000e 241eff80
a3be000f 241e0001 a3be0010 241e0003 a3be0011 241e0007 a3be0012 241e000f
a3be0013 241e001f a3be0014 241e003f a3be0015 241e007f a3be0016 a3b70017
01afb825 56e0003d 24170001 01c9102a 14400007 2702ffff 152e01d3 00001021
0312102b 104001d0 00001021 2702ffff 0058282b 25c3ffff 00a32821 00541821
0062102b 00b52821 00451021 00402821 0049102a 1440000a 00606021 55250005
264cffff 0072182b 14600006 0330102a 264cffff 0192282b 2522ffff 00a22821
0330102a 14400007 2622ffff 161901b6 00001021 0233102b 104001b3 00001021
2622ffff 0051402b 2723ffff 01034021 8faa0028 004a1821 0062102b 01164021
00481021 00404021 0050102a 144001a8 afa30020 56080005 266cffff 0073182b
546001a4 02201021 266cffff 0193282b 2602ffff 1000019e 00a22821 55b70035
24170002 55e00033 24170002 0018c027 000e7027 03129021 0258c02b 01c94821
03094821 02406021 0520018e 01202821 00118827 0019c827 02339821 0271882b
03308021 02308021 afb30020 06000185 02004021 24020001 0054a023 0054102b
01224823 02929021 0254a02b 0135a823 02955021 000a1fc3 00037827 000fc7c3
02581024 01581824 00405821 00605021 24020001 8fad0028 004d4823 0049102b
02028023 01339821 0269482b 0216b023 01366821 000d7fc3 000fc827 001987c3
02707024 01b07824 01c01021 1000008e 01e01821 55b7004f 24170003 55e0004d
24170003 00111827 00192827 00721021 0043182b 00a92821 00651821 00602821
0069182a 1460000a 00406021 55250005 264cffff 0052102b 14400006 24020001
264cffff 0192282b 2522ffff 00a22821 24020001 8faa0028 004a4023 0048102b
00a21023 010c1821 0068402b 00561023 00605821 01025021 000a47c3 000a1827
afa30030 00084027 afa80034 00081fc3 afa30020 afa30024 01631024 01431824
00405821 01d0102a 14400006 00605021 160e0135 00001021 0313102b 10400132
00001021 2702ffff 0058402b 25c3ffff 01034021 00541821 0062102b 01154021
00481021 00404021 0050102a 1440000e afa30020 16080005 2662ffff 0073182b
5460000a 03001021 2662ffff 0053402b 2603ffff afa20020 01034021 03001021
10000003 01c01821 03001021 01c01821 24170003 55b7003d 0003c7c3 55e0003b
0003c7c3 0329102a 14400007 2622ffff 1539010d 00001021 0232102b 1040010a
00001021 2622ffff 0051282b 2723ffff 00a32821 8faa0028 004a1821 0062102b
00b6b021 00561021 00402821 0049102a 1440000a 00606021 55250005 264cffff
0072182b 54600006 0018c027 264cffff 0192282b 2529ffff 00a92821 0018c027
000e7027 03139821 0278c02b 01d08021 03108021 afb30020 060000ea 02004021
24020001 0054a023 0054102b 02028023 02939821 0274a02b 0215a823 02954821
02601021 05200004 01201821 02205821 10000005 03205021 02205821 03205021
00001021 00001821 0003c7c3 33180007 0302a021 0298c02b 0303c021 00184f40
0014a0c2 0134a025 0018c0c3 0280c821 00086fc3 31ad0007 8faf0020 01af4821
012d682b 01a84021 00086f40 000948c2 01a94825 0008b0c3 01208821 02c0f021
0014a0c0 0054a023 000948c0 01e94823 17310038 afa90020 17160037 27350001
00aa102a 14400035 02b9b82b 15450004 000b68c0 018b102b 14400031 02f8b821
008d6821 01607021 01407821 00c7b825 03b98021 8fa20020 03a2a821 03b49821
01a09021 8da20000 8da30004 afa20000 12e00008 afa30004 92a30010 92620008
00621024 92030000 00431025 10000008 a2020000 92a30010 92620008 00621024
00021027 92030000 00431024 a2020000 8fa80000 8fa90004 ae480000 ae490004
25c20001 004e702b 01cf1821 00407021 00607821 00a3182a 14600006 25ad0008
15e5ffe0 01a09021 0182102b 5040ffde 8da20000 27350001 02b9b82b 02f8b821
02a06821 02d7102a 14400041 02e0c021 16fe0005 00aa102a 0235102b 5440003d
02f6b02a 00aa102a 5440003a 02f6b02a 15450004 000b18c0 018b102b 54400035
02f6b02a 00831821 01607021 01407821 00c79025 03b91021 03b4a021 03b1c821
8fa80020 03a89821 00608021 8c680000 8c690004 afa80000 1240000a afa90004
92890008 90480000 01284025 a0480000 92690010 93280000 01284025 1000000b
a3280000 92880008 00084027 90490000 01094024 a0480000 92680010 00084027
93290000 01094024 a3280000 8fa80000 8fa90004 ae080000 ae090004 25c80001
010e702b 01cf4821 01007021 01207821 00a9482a 15200006 24630008 15e5ffdb
00608021 0188402b 5100ffd9 8c680000 02f6b02a 56c00006 03b5a821 57d80042
8fbe005c 02b1102b 10400034 03b5a821 00aa782a 000b10c0 00822021 00c73025
2407ffff 10000023 018bc82b 01008021 8d020000 8d030004 afa20000 10c00003
afa30004 10000002 a2a70000 a2a00000 8fa20000 8fa30004 ae020000 ae030004
25220001 0049482b 012e1821 00404821 00607021 00a3182a 14600006 25080008
15c5ffeb 01008021 0182102b 5040ffe9 8d020000 25a20001 004d182b 00406821
0078c021 14510003 26b50001 531e0016 8fbe005c 15e0fff8 25a20001 55450004
00804021 1720fff5 004d182b 00804021 01604821 1000ffd5 01407021 1000000a
8fbe005c 00001021 10000006 00001821 02201021 03201821 03005821 1000fee4
01c05021 8fbe005c 8fb70058 8fb60054 8fb50050 8fb4004c 8fb30048 8fb20044
8fb10040 8fb0003c 03e00008 27bd0060

'localdrawPixel
27bdfff8 afb10004 afb00000 8fb80018
8faf001c 8fae0020 8fad0024 8fa30028 8fab002c 8fb00030 8faa0034 8fb10038
006bc825 17200006 8fac003c 03004821 01e01021 01c04021 10000020 01a02821
24190001 14790010 24190002 1560000e 00000000 0018c027 000f7827 03104821
0138c02b 01ea7821 030f1021 000e7027 000d6827 01d14021 010e702b 01ac6821
1000001a 01cd2821 1479000d 24190003 1560000b 00000000 03004021 01e02821
000e7027 000d6827 01d04821 012e702b 01aa6821 1000000d 01cd1021 24190003
5479000b 004a582b 15600008 0018c027 000f7827 03114021 0118c02b 01ec7821
030f2821 01c04821 01a01021 004a582b 15600007 24030001 55420005 00001821
0130802b 16000003 306300ff 00001821 306300ff 1060003a 00ac182b 14600007
24020001 55850005 00001021 0111882b 16200003 304200ff 00001021 304200ff
1040002f 00c73025 10c00015 00001021 14a00008 00001821 14a00004 24050001
2d050020 10a00004 24050001 10000003 01051004 24050001 01051804 000928c0
00852021 8c850000 00a22825 ac850000 8c850004 00a32825 10000016 ac850004
54a00009 24050001 14a00003 24050001 2d020020 10400005 01052804 00051027
10000004 2403ffff 01052804 00051827 2402ffff 000928c0 00852021 8c850000
00a22824 ac850000 8c850004 00a32824 ac850004 01202021 10000003 01002821
00002021 00002821 00801021 00a01821 8fb10004 8fb00000 03e00008 27bd0008

'drawline
27bdffa0 afbf005c afbe0058 afb70054 afb60050 afb5004c afb40048 afb30044
afb20040 afb1003c afb00038 0080a821 afa60068 afa7006c 8fa20070 8fa30078
8fa40080 8fa50088 00408021 00609021 00809821 0065a02a 00a33023 00653823
00f4300a 00c0a021 0044402a 00823823 00443023 00e8300b 00d4a02a 12800005
00a0b021 00a09821 0080b021 00608021 00409021 0270102a 10400008 0256102a
02401021 02c09021 0040b021 02001021 02608021 00409821 0256102a 10400007
0270b823 02d2b023 00178fc2 02378821 00118843 10000006 241e0001 0256b023
00178fc2 02378821 00118843 241effff 0270102a 1440003a 8fbf005c 5280001a
afb00010 afb20010 001217c3 afa20014 afb00018 001017c3 afa2001c 8fa20090
8fa30094 afa20020 afa30024 8fa60098 8fa7009c afa60028 afa7002c 8fa200a0
8fa300a4 afa20030 afa30034 02a02021 8fa60068 8fa7006c 0411FF1D 00000000
10000018 02368823 001017c3 afa20014 afb20018 001217c3 afa2001c 8fa60090
8fa70094 afa60020 afa70024 8fa20098 8fa3009c afa20028 afa3002c 8fa600a0
8fa700a4 afa60030 afa70034 02a02021 8fa60068 8fa7006c 0411FF05 00000000
02368823 06210003 26100001 025e9021 02378821 0270102a 1040ffc8 8fbf005c
8fbe0058 8fb70054 8fb60050 8fb5004c 8fb40048 8fb30044 8fb20040 8fb1003c
8fb00038 03e00008 27bd0060

'drawchar
27bdff40 afbf00bc afbe00b8 afb700b4 afb600b0
afb500ac afb400a8 afb300a4 afb200a0 afb1009c afb00098 afa400c0 8fa200d0
afa20068 8fa300d4 afa30070 8fa400d8 afa40074 8fa500dc afa50078 8fb000e0
8fb400e4 8fa200e8 afa20080 8fa300ec afa30088 afa60048 00431025 144000b7
afa7004c 8fa50068 24a20005 0045182b afa2005c 8fa60070 00661821 afa30064
27b50048 24020005 afa20060 0200b021 0280b821 0200f021 10000093 afb4006c
92a20000 02021007 30420001 1040003b 24030001 17c3001d 8fa30054 8fa4006c
5480001b afa30010 8fa5005c afa50010 8fa60064 afa60014 afb20018 afb4001c
8fa200f0 8fa300f4 afa20020 afa30024 8fa400f8 8fa500fc afa40028 afa5002c
8fa20100 8fa30104 afa20030 afa30034 8fa400c0 24060001 00003821 0411FEA4
00000000 10000056 26100001 afa30010 8fa40058 afa40014 afb10018 afb3001c
afb60020 afb70024 afb60028 afb7002c 8fa200f0 8fa300f4 afa20030 afa30034
8fa400f8 8fa500fc afa40038 afa5003c 8fa20100 8fa30104 afa20040 afa30044
8fa400c0 24060001 00003821 0411FC64 00000000 1000003a 26100001 17c3001d
8fa30054 8fa4006c 5480001b afa30010 8fa5005c afa50010 8fa60064 afa60014
afb20018 afb4001c 8fa200f0 8fa300f4 afa20020 afa30024 8fa400f8 8fa500fc
afa40028 afa5002c 8fa20100 8fa30104 afa20030 afa30034 8fa400c0 00003021
00003821 0411FE6A 00000000 1000001c 26100001 afa30010 8fa40058 afa40014
afb10018 afb3001c afb60020 afb70024 afb60028 afb7002c 8fa200f0 8fa300f4
afa20030 afa30034 8fa400f8 8fa500fc afa40038 afa5003c 8fa20100 8fa30104
afa20040 afa30044 8fa400c0 00003021 00003821 0411FC2A 00000000 26100001
02361021 0051182b 02779821 00408821 00739821 26420001 0052182b 0074a021
24030008 1603ff7e 00409021 8fa40060 2484ffff afa40060 8fa5005c 24a2ffff
0045202b 8fa60064 24c3ffff afa2005c 00831821 afa30064 8fa20060 2403ffff
104300f6 26b50001 8fa40060 009e0019 00001012 00001810 8fa5006c 70a43002
00c31821 8fa50068 00452021 0082282b 8fa60070 00661021 afa40054 00a21021
afa20058 8fb20074 8fb40078 02408821 02809821 1000ff5a 00008021 24020001
8fa30080 146200e1 24020002 8fa40088 148000de 00142023 00101023 0002182b
afa2008c 00832023 afa40090 8fa50068 24a20001 0045202b 8fa60070 00862021
00501823 0043102b 00942023 afa3006c 00822023 afa4007c afa50060 afa60064
27b6004d 27a20047 afa20050 8fa30074 2463fff9 afa30084 8fa40074 24820001
0044182b 8fa50078 00651821 0050a823 0055102b 00741823 00621823 afa3005c
8fbe00c0 100000a7 02009021 92c20000 02021007 30420001 10400044 00000000
1657001c 8fa50054 5680001b afa50010 8fa60060 afa60010 8fa20064 afa20014
afb10018 afb3001c 8fa400f0 8fa500f4 afa40020 afa50024 8fa200f8 8fa300fc
afa20028 afa3002c 8fa40100 8fa50104 afa40030 afa50034 03c02021 24060001
00003821 0411FDD2 00000000 10000069 2610ffff afa50010 8fa60058 afa60014
02120019 00001012 00001810 72902002 00831821 02a22023 02a4282b 8fa6005c
00c31023 00452823 afa40018 afa5001c afb20020 afb40024 afb20028 afb4002c
8fa200f0 8fa300f4 afa20030 afa30034 8fa400f8 8fa500fc afa40038 afa5003c
8fa20100 8fa30104 afa20040 afa30044 03c02021 24060001 00003821 0411FB88
00000000 10000043 2610ffff 1657001c 8fa30054 5680001b afa30010 8fa30060
afa30010 8fa40064 afa40014 afb10018 afb3001c 8fa200f0 8fa300f4 afa20020
afa30024 8fa400f8 8fa500fc afa40028 afa5002c 8fa20100 8fa30104 afa20030
afa30034 03c02021 00003021 00003821 0411FD8F 00000000 10000026 2610ffff
afa30010 8fa40058 afa40014 02120019 00001012 00001810 72902002 00831821
02a22023 02a4282b 8fa6005c 00c31023 00452823 afa40018 afa5001c afb20020
afb40024 afb20028 afb4002c 8fa200f0 8fa300f4 afa20030 afa30034 8fa400f8
8fa500fc afa40038 afa5003c 8fa20100 8fa30104 afa20040 afa30044 03c02021
00003021 00003821 0411FB45 00000000 2610ffff 26220001 0051182b 00408821
2402ffff 1602ff71 00739821 8fa3006c 8fa4008c 00641021 0043182b 8fa5007c
8fa60090 00a62021 afa2006c 00642021 afa4007c 8fa30060 2462ffff 0043182b
8fa50064 24a4ffff afa20060 00642021 afa40064 26d6ffff 8fa60050 52c600d9
02408021 8fa2006c afa20054 8fa3007c afa30058 8fa40084 8fa50074 0085982b
8fa60078 24c2ffff 00808821 02629821 24100007 1000ff4d 24170001 03c08021
8fb4006c 24020002 8fa30080 146200c6 24020003 8fa40088 148000c4 8fa30080
00101023 0002182b 00142023 afa2007c 00832023 afa40080 8fa50068 24a20001
0045202b 8fa60070 00862021 00501823 0043102b 00942023 afa30060 00822023
afa40064 afa0005c 0200b021 0280b821 27a20047 afa20050 0200f021 1000009c
afb4006c 92020000 02a21024 1040003b 24030001 17c3001d 8fa30054 8fa4006c
5480001b afa30010 8fa50068 afa50010 8fa60070 afa60014 afb20018 afb4001c
8fa200f0 8fa300f4 afa20020 afa30024 8fa400f8 8fa500fc afa40028 afa5002c
8fa20100 8fa30104 afa20030 afa30034 8fa400c0 24060001 00003821 0411FCFC
00000000 10000056 2610ffff afa30010 8fa40058 afa40014 afb10018 afb3001c
afb60020 afb70024 afb60028 afb7002c 8fa200f0 8fa300f4 afa20030 afa30034
8fa400f8 8fa500fc afa40038 afa5003c 8fa20100 8fa30104 afa20040 afa30044
8fa400c0 24060001 00003821 0411FABC 00000000 1000003a 2610ffff 17c3001d
8fa30054 8fa4006c 5480001b afa30010 8fa50068 afa50010 8fa60070 afa60014
afb20018 afb4001c 8fa200f0 8fa300f4 afa20020 afa30024 8fa400f8 8fa500fc
afa40028 afa5002c 8fa20100 8fa30104 afa20030 afa30034 8fa400c0 00003021
00003821 0411FCC2 00000000 1000001c 2610ffff afa30010 8fa40058 afa40014
afb10018 afb3001c afb60020 afb70024 afb60028 afb7002c 8fa200f0 8fa300f4
afa20030 afa30034 8fa400f8 8fa500fc afa40038 afa5003c 8fa20100 8fa30104
afa20040 afa30044 8fa400c0 00003021 00003821 0411FA82 00000000 2610ffff
02361021 0051182b 02779821 00408821 00739821 26420001 0052182b 0074a021
8fa30050 1603ff7f 00409021 8fa4005c 24840001 afa4005c 8fa50060 8fa6007c
00a61021 0045202b 8fa50064 8fa60080 00a61821 afa20060 00831821 afa30064
8fa30068 2462ffff 0043202b 8fa50070 24a3ffff afa20068 00831821 afa30070
8fa6005c 24020008 10c20104 8fa20048 24030001 8fa4005c 0083a804 8fa50060
afa50054 8fa60064 afa60058 27b0004d 8fb20074 8fb40078 02408821 1000ff59
02809821 24020003 8fa30080 146200f2 8fa40088 148000f0 00101023 0002182b
00142023 afa20084 00832023 afa40088 00101742 001418c0 00431825 001020c0
00901023 0082202b 00741823 00641823 8fa50068 00452021 0082102b 8fa60070
00661821 afa40064 00431821 afa3006c 24a20007 0045182b afa2005c 00661821
afa30070 24020007 afa20060 8fa30074 24620001 0043282b 8fa40078 00a42821
00101823 0003202b 00143023 00c42023 00033782 00042080 00c43025 00032080
00901821 0064202b 00d43021 00862021 000337c2 00042040 00c42025 00031840
00431821 afa3007c 0062102b 00a41821 00431821 afa3008c 8fa50074 24a5fffb
afa50080 8fa60074 00a6182b 8fa40078 2482ffff 00621021 afa20074 0280b021
1000009c 0200a021 92020000 02e21024 1040003b 24030001 24050001 1685001c
8fa50058 56c0001b afa50010 8fa6005c afa60010 8fa20070 afa20014 afb20018
afb5001c 8fa400f0 8fa500f4 afa40020 afa50024 8fa200f8 8fa300fc afa20028
afa3002c 8fa40100 8fa50104 afa40030 afa50034 8fa400c0 24060001 00003821
0411FC0B 00000000 10000055 26100001 afa50010 8fa60068 afa60014 afb10018
afb3001c afb40020 afb60024 afb40028 afb6002c 8fa200f0 8fa300f4 afa20030
afa30034 8fa400f8 8fa500fc afa40038 afa5003c 8fa20100 8fa30104 afa20040
afa30044 8fa400c0 24060001 00003821 0411F9CB 00000000 10000039 26100001
1683001c 8fa30058 56c0001b afa30010 8fa4005c afa40010 8fa50070 afa50014
afb20018 afb5001c 8fa200f0 8fa300f4 afa20020 afa30024 8fa400f8 8fa500fc
afa40028 afa5002c 8fa20100 8fa30104 afa20030 afa30034 8fa400c0 00003021
00003821 0411FBD2 00000000 1000001c 26100001 afa30010 8fa40068 afa40014
afb10018 afb3001c afb40020 afb60024 afb40028 afb6002c 8fa200f0 8fa300f4
afa20030 afa30034 8fa400f8 8fa500fc afa40038 afa5003c 8fa20100 8fa30104
afa20040 afa30044 8fa400c0 00003021 00003821 0411F992 00000000 26100001
023e1021 0051182b 8fa40054 02649821 00408821 00739821 26420001 0052182b
00409021 8fa50050 1605ff7f 0075a821 8fa60060 24c6ffff afa60060 8fa30064
8fa40084 00641021 0043202b 8fa5006c 8fa60088 00a61821 afa20064 00831821
afa3006c 8fa3005c 2462ffff 0043202b 8fa50070 24a3ffff afa2005c 00831821
afa30070 2402ffff 8fa60060 10c20013 8fa20048 24170001 8fa20060 0057b804
8fa30064 afa30058 8fa4006c afa40068 27b00048 0280f021 afb60054 8fb1007c
8fb3008c 8fb20080 8fb50074 27a5004e 1000ff55 afa50050 8fa20048 8fa3004c
8fbf00bc 8fbe00b8 8fb700b4 8fb600b0 8fb500ac 8fb400a8 8fb300a4 8fb200a0
8fb1009c 8fb00098 03e00008 27bd00c0

'main
27bdffb0 afbf004c 00e06021 8fab0060
8faa0064 8fa90068 8fa8006c 8fae0070 8c820000 8c830004 00432025 1480001d
8fad0074 8cc20000 8ce30000 afa30010 00031fc3 afa30014 8d630000 afa30018
00031fc3 afa3001c 8d430000 afa30020 00031fc3 afa30024 8d230000 afa30028
00031fc3 afa3002c 8d030000 afa30030 00031fc3 afa30034 00a02021 00403021
00023fc3 0411FB4A 00000000 10000076 8fbf004c 24040001 14440027 24040002
14600025 00000000 8cc20000 8ce30000 afa30010 00031fc3 afa30014 8d630000
afa30018 00031fc3 afa3001c 8d430000 afa30020 00031fc3 afa30024 8d230000
afa30028 00031fc3 afa3002c 8d030000 afa30030 00031fc3 afa30034 8dc30000
afa30038 00031fc3 afa3003c 8da30000 afa30040 00031fc3 afa30044 00a02021
00403021 00023fc3 0411F8FD 00000000 1000004d 8fbf004c 14440026 24040003
14600024 00000000 8cc70004 8cc60000 8d820000 afa20010 000217c3 afa20014
8d620000 afa20018 000217c3 afa2001c 8d420000 afa20020 000217c3 afa20024
8d220000 afa20028 000217c3 afa2002c 8d020000 afa20030 000217c3 afa20034
8dc20000 afa20038 000217c3 afa2003c 8da20000 afa20040 000217c3 afa20044
00a02021 0411FC09 00000000 10000026 8fbf004c 14440024 8fbf004c 14600022
00a02021 8cc70004 8cc60000 8d820000 afa20010 000217c3 afa20014 8d620000
afa20018 000217c3 afa2001c 8d420000 afa20020 000217c3 afa20024 8d220000
afa20028 000217c3 afa2002c 8d020000 afa20030 000217c3 afa20034 8dc20000
afa20038 000217c3 afa2003c 8da20000 afa20040 000217c3 afa20044 0411FB60
00000000 8fbf004c 03e00008 27bd0050
END CFUNCTION

CFUNCTION TFT_Font
00000000
00000000 00000000 4f5b3e00 00003e5b 4f6b3e00 00003e6b 7c3e1c00 00001c3e
7e3c1800 0000183c 7d571c00 00001c57 7f5e1c00 00001c5e 3c180000 00000018
c3e7ff00 0000ffe7 24180000 00000018 dbe7ff00 0000ffe7 3a060e00 00003048
79292600 00002629 05050700 0000407f 05253f00 0000407f e73c5a00 00005a3c
1c1c0800 00007f3e 1c3e7f00 0000081c 7f221400 00001422 005f5f00 00005f5f
7f017f00 00000609 89956a00 00000066 60606000 00006060 ffa29400 000094a2
7e040800 00000804 7e201000 00001020 2a1c0800 00000808 2a080800 0000081c
10101000 00001e10 0c1e0c00 00000c1e 3e383000 00003038 3e0e0600 0000060e
00000000 00000000 5f000000 00000000 00070000 00000007 147f1400 0000147f
7f2a1200 0000242a 08646200 00002313 56205000 00003649 07030000 00000008
22410000 0000001c 221c0000 00000041 7f1c2a00 00002a1c 3e080800 00000808
70300000 00000080 08080800 00000808 60600000 00000000 08040200 00002010
49453e00 00003e51 7f400000 00000042 49494600 00007249 494d3300 00002141
127f1000 00001814 45453900 00002745 49493100 00003c4a 11090700 00004121
49493600 00003649 49291e00 00004649 14000000 00000000 34000000 00000040
14224100 00000008 14141400 00001414 22140800 00000041 59090600 00000201
5d594e00 00003e41 11127c00 00007c12 49493600 00007f49 41412200 00003e41
41413e00 00007f41 49494100 00007f49 09090100 00007f09 41517300 00003e41
08087f00 00007f08 7f410000 00000041 413f0100 00002040 14224100 00007f08
40404000 00007f40 1c027f00 00007f02 08107f00 00007f04 41413e00 00003e41
09090600 00007f09 51215e00 00003e41 19294600 00007f09 49493200 00002649
7f010300 00000301 40403f00 00003f40 40201f00 00001f20 38403f00 00003f40
08146300 00006314 78040300 00000304 494d4300 00006159 41414100 0000007f
08102000 00000204 41417f00 00000041 01020400 00000402 40404000 00004040
07080000 00000003 54784000 00002054 44443800 00007f28 44442800 00003844
44287f00 00003844 54541800 00003854 7e090200 00000008 a49c7800 000018a4
04047800 00007f08 7d400000 00000044 403d0000 00002040 28440000 00007f10
7f400000 00000041 78047800 00007c04 04047800 00007c08 44443800 00003844
24241800 0000fc18 2418fc00 00001824 04040800 00007c08 54542400 00004854
3f442400 00000404 40207c00 00003c40 40201c00 00001c20 30403c00 00003c40
10284400 00004428 90907c00 00004c90 544c4400 00004464 36410000 00000008
77000000 00000000 36080000 00000041 02040200 00000201 23263c00 00003c26
a1611200 00001ea1 40207a00 00003a40 54555900 00003854 55794100 00002155
54784200 00002254 54784000 00002155 55794000 00002054 52721200 00000c1e
55555900 00003955 54545900 00003954 54545800 00003955 457c4100 00000000
457d4200 00000002 457c4000 00000001 11127d00 00007d12 2528f000 0000f028
55450000 00007c54 547c5400 00002054 097f4900 00007c0a 49493200 00003249
44443a00 00003a44 48483000 0000324a 41217a00 00003a41 40207800 00003a42
a0a07d00 0000009d 42423d00 00003d42 40403d00 00003d40 ff242400 00003c24
49436600 0000487e fc2f2b00 00002b2f 29f62000 0000ff09 7e090300 0000c088
54794100 00002054 447d4100 00000000 484a3200 00003048 40227a00 00003840
0a0a7200 0000007a 19317d00 00007d0d 292f2800 00002629 29292600 00002629
4d402000 00003048 08080800 00003808 08083800 00000808 c8acba00 00002f10
2834fa00 00002f10 7b000000 00000000 2a142200 00000814 2a140800 00002214
5500aa00 0000aa00 aa55aa00 0000aa55 00ff0000 00000000 10ff0000 00001010
14ff0000 00001414 ff00ff00 00001010 f010f000 00001010 14fc0000 00001414
f700ff00 00001414 ff00ff00 00000000 f404fc00 00001414 17101f00 00001414
1f101f00 00001010 141f0000 00001414 10f00000 00001010 001f1000 00000000
101f1000 00001010 10f01000 00001010 00ff1000 00000000 10101000 00001010
10ff1000 00001010 00ff1400 00000000 ff00ff00 00000000 1f101700 00000000
fc04f400 00000000 17101700 00001414 f404f400 00001414 ff00f700 00000000
14141400 00001414 f700f700 00001414 14171400 00001414 1f101f00 00001010
14f41400 00001414 f010f000 00001010 1f101f00 00000000 001f1400 00000000
00fc1400 00000000 f010f000 00000000 ff10ff00 00001010 14ff1400 00001414
101f0000 00001010 00f01000 00000000 ffffff00 0000ffff f0f0f000 0000f0f0
ff000000 0000ffff 00ffff00 00000000 0f0f0f00 00000f0f 44384400 00003844
4a4a3400 0000fc4a 02060600 00007e02 027e0200 0000027e 49416300 00006355
443c0400 00003844 201e2000 0000407e 7e020200 00000602 e7a59900 000099a5
492a1c00 00001c2a 01724c00 00004c72 4d4d3000 0000304a 78483000 00003048
5a463d00 0000bc62 49490000 00003e49 01017e00 00007e01 2a2a2a00 00002a2a
5f444400 00004444 4a444000 00004051 4a514000 00004044 ff010300 00000000
ff000000 0000e080 6b6b0800 00000808 36243600 00003612 090f0600 0000060f
18180000 00000000 10100000 00000000 ff010100 00003040 01011e00 0000001f
1d171200 00000019 3c3c3c00 0000003c 00000000 00000000
END CFUNCTION

'
'isI2COpen 2014-12-08 12:34:39 CFuncGen Ver 1.0.21 by user=Peter
'
' Returns 1 if I2C Bus is OPEN, 0 otherwise
'
CFUNCTION TFT.isI2COpen
00000000
3c02bf80 8c425000 7c4203c0 03e00008 00001821
END CFUNCTION

'-------------------Delete ALL text below when using Library in your own programs


SUB TestSuite

CPU 48

CONST i2caddr=&H3C

PRINT "Starting initialisation"
PRINT "Using SSD1306"

'initialise the display
TFT.Init i2caddr,400

PRINT "starting main"
'Variables for use in main
LOCAL Integer i,xfs,yfs,x0=0,y0=0,x1,y1=63
LOCAL FLOAT tn
LOCAL Integer Sz

DO

' demo fast line draw
TFT.SetRot(TFT_NORMAL)
TFT.Cls
FOR i=0 TO 45 STEP 5
tn=TAN(RAD(i))
x1=TFT_w1*tn
TFT.DLine(x0,y0,x1,y1)
NEXT i

x1=127
FOR i=0 TO 40 STEP 5
tn=TAN(RAD(i))
y1=TFT_ht*tn
TFT.DLine(x0,y0,x1,y1)
NEXT i
TFT.Refresh
PAUSE 4000
TFT.Cls

'demo fast text write
FOR i=0 TO 56 STEP 8
TFT.PString(0,i,"Hello world:Bye world",1,TFT_NORMAL)
NEXT i
TFT.Refresh
PAUSE 4000
TFT.Cls

FOR i=63 TO 15 STEP -16
TFT.PString(127,i,"Micromite2",2,TFT_INVERSE)
NEXT i
TFT.Refresh
PAUSE 4000
TFT.Cls

FOR i=16 TO 128 STEP 16
TFT.PString(i,0,"RIGHT",2,TFT_RT_RIGHT)
NEXT i
TFT.Refresh
PAUSE 4000
TFT.Cls

FOR i=104 TO 0 STEP -24
TFT.PString(i,63,"LEFT",3,TFT_RT_LEFT)
NEXT i
TFT.Refresh
PAUSE 4000
TFT.Cls

' test drawing rectangles
FOR i=0 TO 3
TFT.SetRot(i)
TFT.FRect(5,5,10,15)
TFT.DRect(2,2,16,21)
NEXT i
TFT.Refresh
PAUSE 2000
TFT.Cls

' test drawing rounded rectangles
FOR i=0 TO 3
TFT.SetRot(i)
TFT.FRndrect(5,5,10,15,4)
TFT.DRndrect(2,2,16,21,6)
NEXT i
TFT.Refresh
PAUSE 2000
TFT.Cls

' test drawing circles
FOR i=0 TO 3
TFT.SetRot(i)
TFT.FCirc(10,10,7)
TFT.DCirc(10,10,9)
NEXT i
TFT.Refresh
PAUSE 2000
TFT.Cls

' test drawing triangles and line drawing
FOR i=0 TO 3
TFT.SetRot(i)
TFT.FTri(4,4,20,6,12,14)
TFT.DTri(1,2,24,4,12,17)
NEXT i
TFT.Refresh
PAUSE 2000

' test character output and string output at all orientations
FOR sz=1 TO 3
TFT.Cls
TFT.SetRot(TFT_NORMAL)
xfs=0
yfs=0
TFT.PString(xfs,yfs,"TFT_nr",sz,TFT_NORMAL)
TFT.PString(xfs,yfs,"g",sz,TFT_NORMAL)
TFT.PString(TFT_rot_wi-1,TFT_rot_ht-1,"Iv",sz,TFT_INVERSE)
TFT.PString(TFT_rot_wi-1,0,"Rr",sz,TFT_RT_RIGHT)
TFT.PString(0,TFT_rot_ht-1,"Rl",sz,TFT_RT_LEFT)
TFT.Refresh
PAUSE 2000
TFT.Cls
TFT.SetRot(TFT_INVERSE)
xfs=0
yfs=0
TFT.PString(xfs,yfs,"TFT_nr",sz,TFT_NORMAL)
TFT.PString(xfs,yfs,"g",sz,TFT_NORMAL)
TFT.PString(TFT_rot_wi-1,TFT_rot_ht-1,"Iv",sz,TFT_INVERSE)
TFT.PString(TFT_rot_wi-1,0,"Rr",sz,TFT_RT_RIGHT)
TFT.PString(0,TFT_rot_ht-1,"Rl",sz,TFT_RT_LEFT)
TFT.Refresh
PAUSE 2000
TFT.Cls
TFT.SetRot(TFT_RT_RIGHT)
xfs=0
yfs=0
TFT.PString(xfs,yfs,"TFT_nr",sz,TFT_NORMAL)
TFT.PString(xfs,yfs,"g",sz,TFT_NORMAL)
TFT.PString(TFT_rot_wi-1,TFT_rot_ht-1,"Iv",sz,TFT_INVERSE)
TFT.PString(TFT_rot_wi-1,0,"Rr",sz,TFT_RT_RIGHT)
TFT.PString(0,TFT_rot_ht-1,"Rl",sz,TFT_RT_LEFT)
TFT.Refresh
PAUSE 2000
TFT.Cls
TFT.SetRot(TFT_RT_LEFT)
xfs=0
yfs=0
TFT.PString(xfs,yfs,"TFT_nr",sz,TFT_NORMAL)
TFT.PString(xfs,yfs,"g",sz,TFT_NORMAL)
TFT.PString(TFT_rot_wi-1,TFT_rot_ht-1,"Iv",sz,TFT_INVERSE)
TFT.PString(TFT_rot_wi-1,0,"Rr",sz,TFT_RT_RIGHT)
TFT.PString(0,TFT_rot_ht-1,"Rl",sz,TFT_RT_LEFT)
TFT.Refresh
PAUSE 2000
NEXT sz
LOOP

END SUB


Peter
The only Konstant is Change
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 12:36am 12 Dec 2014
Copy link to clipboard 
Print this post

Hi Peter

This looks very good from my perspective. The only comment I would make is related to the complexity of this particular example.

There are actually two separate libraries in this code. There is the graphics primitives library and the display drivers library. The graphics primitives are fully transportable to any other type of monochrome display of less than 64 bits in height.

The NOKIA5110 code uses exactly the same graphics primitives. For this reason I kept the SGetNextUpdate cFunction completely separate from the TFT.draw cFunction
routines.

The code for the ST7783 is different to this as the display driving routines are embedded in the graphics primitives to get the speed and because the size of the display makes it impossible to maintain a memory "image" in the micromite. However, even in this case, it is likely that other similar displays will be able to use the primitives but with a separate initialisation library so again there are probably two libraries.

Let me have your thoughts.

Peter


Edited by matherp 2014-12-13
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 08:12am 12 Dec 2014
Copy link to clipboard 
Print this post

Hi Peter

The same thought struck me, and in fact there is a 3rd library in use in this code - 'isI2COpen()'. However, unless everybody is willing to consider using something like a pre-processor and MMEdit so that one can #include file contents into the code being downloaded to the uMite, I can't see any easy answer. (also a lot of uMite'ers seem to use LINUX which rules out MMEdit - well at least the version with all the features required)

I think that what we are coming across is the inherent difference between a compiled environment and an interpreted environment in the MCU world. For embedded MCUs, the development environment, eg compiler, linker, library files etc, must be hosted and executed on another platform, eg Windows/LINUX PC, because the target is just too small to be useful, but with an interpreted environment, there is (in principle at least) no need for a separate 'development environment' because the target MCU is powerful enough to provide the development environment required, ie text entry. MMEdit on a Windows PC, coupled with something like MCPP, enables developers to gain some of the capabilities of a full IDE.

There is some virtue (at the expense of repetition, and version staleness) to having a single insertable entity, and that is simplicity. Also #include/using and the like are 'foreign' to most interpreted BASICs.

Because of these and other factors, the burden falls on the Library developer(s) to do the legwork to produce a simple component for end-users which is in-keeping with the spirit of BASIC - this is partly why I feel that a library 'Editor' is required who does more than collect, store, catalogue, and publish.

So in short, I think we are where we are, and not much more can be done to improve matters significantly :(

It would be interesting and useful to hear from potential library users as to what they need.

If it's OK with you I'll publish the revised 1306 Lib

Peter

PS I've always wanted #include to be able to take a URL as well as just a file path !
The only Konstant is Change
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5913
Posted: 10:53am 12 Dec 2014
Copy link to clipboard 
Print this post

  G8JCF said   (also a lot of uMite'ers seem to use LINUX which rules out MMEdit - well at least the version with all the features required)

MMEdit runs happily under Wine for most Linux users.
I know there are many Linux users who have an aversion to Wine, but the option is there.

I will get back to MMEdit2 once the micromite Mk2 has settled down. I have a lot of catching up to do with it.

  G8JCF said  
PS I've always wanted #include to be able to take a URL as well as just a file path !


In a perfect world, URL's are a great idea but there is no way I would trust unseen code from the big bad world without at least some attempt to verify it first.

The benefit of plain Basic is, it can be read before running.
We have to 'trust' CFunction authors a bit more but even then, manually downloading the files gives you a chance to assess the risks.

Jim
VK7JH
MMedit   MMBasic Help
 
halldave

Senior Member

Joined: 04/05/2014
Location: Australia
Posts: 121
Posted: 11:08am 12 Dec 2014
Copy link to clipboard 
Print this post

When it come to CFunctions I would like to think that in all cases the C Source code is provided so that we can see what is being done

 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 11:49am 12 Dec 2014
Copy link to clipboard 
Print this post

Hi Jim

That's great news that LINUX users can run the latest and greatest version of MMEdit.

Peter
The only Konstant is Change
 
Print this page


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

© JAQ Software 2024