Plotting Routines

westaust55

Moderator
Before I set out and reinvent the wheel, to create some routines to plot say lines and circles on LCD modules from mobile phones (in particular say the Nokia 3310 @ 84 x 48 pixels and the Siemens A55 @ 102 x 65 pixels),
has anyone else done such as routine or has seen something that may act as a starting point? :confused:

I know the necessary formula and have some ideas brewing.
With the pixel banking system of these monochrome LCD modules it will take a bit of thought to handle working in 8 pixel groups.
 
Last edited:

Texy

Senior Member
This is the very first picaxe code with 3310 LCD that I found on the web that displays some text and a little graph :

Code:
; Nokia LCD driver
#picaxe 18x
symbol SCLK = 0 'Display pin 2 to PICAXE out 0
symbol SDA = 5 'Display pin 3 to PICAXE out 1
symbol DC = 2 'Display pin 4 to PICAXE out 2
symbol CS = 3 'Display pin 5 to PICAXE out 3
symbol RES = 6 'Display pin 8 to PICAXE out 4
symbol Command = bit0
symbol Value = b2
symbol X = b3
symbol Y = b4
symbol GraphicData = b5
symbol Mask = b7
symbol Loop1 = b10
symbol Loop2 = b11
symbol loop3 = b12
setfreq m8
GoSub Init
GoSub PrName
GoSub Graphic
GoSub Invert
pause 500
GoSub Normal
setfreq m4
Stop
End
Graphic:
X = 10
For Loop1 = 15 To 41
read Loop1, GraphicData
Y = GraphicData / 8
loop3 = -Y * 8 + GraphicData + 7
X = X + 1
Command = 1
GoSub GotoXY
Command = 0
read loop3, Value
GoSub WriteToLCD
Next
Return
PrName:
Command = 0
For Loop1 = 43 To 65
read Loop1, Value
GoSub WriteToLCD
Next Loop1
Return
Init:
'initialisation commands
EEPROM 0,(33,197,6,19,32,12)
'powers of 2 for graphs
EEPROM 6,(0,1,2,4,8,16,32,64,128)
'sine wave lookup table
EEPROM 15,(24,26,28,30,31,33,34,36,38,39,41,42,43,44,45,46,47,47,47,47,47,47,47,46,45,44,43,42)
'some characters to display
EEPROM 43,(127,8,8,8,127,0,32,84,84,84,56,0,124,8,4,4,120,0, 72,84,84,84,32)
low SCLK
low SDA
low DC
low CS
low RES
pause 500
high RES
high CS
Command = 1
for Loop1 = 0 to 5 ` start a loop
read Loop1, Value ` read value from EEPROM
gosub WriteToLCD ` transmit to serial LCD module
Next Loop1
GoSub White
X = 0
Y = 0
GoSub GotoXY
GoSub ClearFast
GoSub Normal
Return
WriteToLCD:
high DC 'Data mode
If Command = 0 Then DataMode
low DC 'Command mode
DataMode:
low CS
For Loop2 = 1 To 8
low SCLK
Mask = Value & 128
low SDA
If Mask = 0 Then Skiphigh
high SDA
Skiphigh:
high SCLK
Value = Value * 2
Next Loop2
high CS
Return
ClearFast:
low SDA
high DC
low CS
For Loop1 = 1 To 48
For loop3 = 1 To 84
low SCLK
high SCLK
Next loop3
Next Loop1
Return
GotoXY:
Command = 1
Value = X + 128
GoSub WriteToLCD
Value = Y + 64
GoSub WriteToLCD
Return
Invert:
Command = 1
Value = 13
GoSub WriteToLCD
Return
Black:
Command = 1
Value = 9
GoSub WriteToLCD
Return
White:
Command = 1
Value = 8
GoSub WriteToLCD
Return
Normal:
Command = 1
Value = 12
GoSub WriteToLCD
Return
Might help you get started,

Texy
 

westaust55

Moderator
Thanks Texy.

I have spent much of this evening in further searching and discovered that a number of more commerical projects out there where I could access the source code are using straight blocks of data as sub-pictures to display things like compass roses rather than using any maths.

A compass with 16 headings is using 16 * 90 = 1440 bytes of data,
Not an insignificant amanout of EEPROM/memory space in a PICAXE
and its all very fixed.

A set of plot routines should enable such things as circles and lines to be drawn anywhere in the screen.
 

Mycroft2152

Senior Member
Westy,

Lines and boxes are pretty easy/. Circles usully take sine functions, tha tis unless you want tojump through hoops in calculations.

Myc
 

westaust55

Moderator
Hi MyC,

noted with thanks.

For circles I would be using other maths as not all PICAXE hav a Sine function.

(x)^2 + (y)^2 = r^2 is the formula for a circle. I had an attachment on another Thread about the actual forumla.

It is not the maths but more drivers specific to the mentioned LCD module type I was interested to see if anyone else had done something as a starting point.

But just may have to sit down and re-invent the wheel for drivers/routines to suit these LCD's.
 
Last edited:
Top