Manual draw on a graphical LCD following mouse movement
Sirs
Glad to use Scott Edward's G12032 LCD with a PAK6 for manual drawing on the
LCD following a mouse movement. Basically the code is
BLACK = color of drawing
L=draw line code in G12032.
Loop:
get x2 & y2
Serout pin0,n9600,[noparse][[/noparse]ESC,"I",BLACK,ESC,"L",x1+CUT0,y1+CUT0, x2+CUT0, y2+CUT0]
pause 50
x1=x2 'update old x position
y1=y2 'update old y position
goto Loop
'x1 y1 the previous position
'x2 y2 the present position
'CUT0=64
As a step forward, I want to create a mouse cursor like the one in our PC,
it can be an arrow or a fat finger like that in Mac. However, that needs a
"draw-redraw" routine that covers the "hidden" area of the LCD as the cursor
moves over a certain area. I am thinking of using a custom graphics of a
small cursor shape to be saved as a custom ASC code character, and repeatly
load it by following the present x2 y2 position. Not sure if it works. I
would be grateful if anybody could give me an advice on that. Any idea is
welcome.
John
Glad to use Scott Edward's G12032 LCD with a PAK6 for manual drawing on the
LCD following a mouse movement. Basically the code is
BLACK = color of drawing
L=draw line code in G12032.
Loop:
get x2 & y2
Serout pin0,n9600,[noparse][[/noparse]ESC,"I",BLACK,ESC,"L",x1+CUT0,y1+CUT0, x2+CUT0, y2+CUT0]
pause 50
x1=x2 'update old x position
y1=y2 'update old y position
goto Loop
'x1 y1 the previous position
'x2 y2 the present position
'CUT0=64
As a step forward, I want to create a mouse cursor like the one in our PC,
it can be an arrow or a fat finger like that in Mac. However, that needs a
"draw-redraw" routine that covers the "hidden" area of the LCD as the cursor
moves over a certain area. I am thinking of using a custom graphics of a
small cursor shape to be saved as a custom ASC code character, and repeatly
load it by following the present x2 y2 position. Not sure if it works. I
would be grateful if anybody could give me an advice on that. Any idea is
welcome.
John
Comments
Sounds like a nice project. The SEETRON LCD has an XOR mode just for
this purpose. You set it using ESC M 1. Then drawing a white pixel will
invert whatever is there already. I'm assuming ESC M 0 resets the mode
although the docs say it goes to OR mode which would not be normal
drawing (but I think he really means to say XOR mode off).
So here's the deal:
1) Turn on XOR mode
2) Draw your cursor at the current location
3) Wait for the mouse to move
4) Draw your cursor again at the same location as step 2
5) Goto step 2
Of course, this assumes you aren't drawing. You'd do any drawing between
step 4 and 5 (and then jump back to step 1 instead of 2 since your
drawing code will reset XOR mode).
The logic here is the first time you draw the cursor will definitely be
visible no matter what the background color is. The second time you draw
the cursor at the same spot it will restore the display to its original
condition.
I'm not sure, but I think someone actually has a ridiculous patent on
this algorithm. It has been used for decades.
Good luck!
Al Williams
AWC
* 8 channels of PWM
http://www.al-williams.com/awce/pak5.htm
>
Original Message
> From: John Leung [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Grr2czcx_iWYwHbHhbvDZYi9iODJ7DeC80wue6t4sWDRFkPWx0yqTUFqDsBaipQ_NpSZQVeK2GYzKPPyWgMe]jleung00@n...[/url
> Sent: Saturday, December 01, 2001 3:55 AM
> To: basicstamps@yahoogroups.com
> Subject: Re: [noparse][[/noparse]basicstamps] Re: Manual draw on a graphical LCD
> following mouse movement
>
>
> Sirs
>
> Glad to use Scott Edward's G12032 LCD with a PAK6 for manual
> drawing on the LCD following a mouse movement. Basically the code is
>
> BLACK = color of drawing
> L=draw line code in G12032.
>
> Loop:
> get x2 & y2
> Serout pin0,n9600,[noparse][[/noparse]ESC,"I",BLACK,ESC,"L",x1+CUT0,y1+CUT0,
> x2+CUT0, y2+CUT0] pause 50
> x1=x2 'update old x position
> y1=y2 'update old y position
> goto Loop
>
> 'x1 y1 the previous position
> 'x2 y2 the present position
> 'CUT0=64
>
> As a step forward, I want to create a mouse cursor like the
> one in our PC, it can be an arrow or a fat finger like that
> in Mac. However, that needs a "draw-redraw" routine that
> covers the "hidden" area of the LCD as the cursor moves over
> a certain area. I am thinking of using a custom graphics of a
> small cursor shape to be saved as a custom ASC code
> character, and repeatly load it by following the present x2
> y2 position. Not sure if it works. I would be grateful if
> anybody could give me an advice on that. Any idea is welcome.
>
> John
>
>
>
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
> Subject and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
Thanks for your advice. You gave me valuable information.
John
Original Message
From: Al Williams <alw@a...>
To: <basicstamps@yahoogroups.com>
Sent: Saturday, December 01, 2001 9:30 PM
Subject: RE: [noparse][[/noparse]basicstamps] Re: Manual draw on a graphical LCD following
mouse movement
> Hi John,
>
> Sounds like a nice project. The SEETRON LCD has an XOR mode just for
> this purpose. You set it using ESC M 1. Then drawing a white pixel will
> invert whatever is there already. I'm assuming ESC M 0 resets the mode
> although the docs say it goes to OR mode which would not be normal
> drawing (but I think he really means to say XOR mode off).
>
> So here's the deal:
> 1) Turn on XOR mode
> 2) Draw your cursor at the current location
> 3) Wait for the mouse to move
> 4) Draw your cursor again at the same location as step 2
> 5) Goto step 2
>
> Of course, this assumes you aren't drawing. You'd do any drawing between
> step 4 and 5 (and then jump back to step 1 instead of 2 since your
> drawing code will reset XOR mode).
>
> The logic here is the first time you draw the cursor will definitely be
> visible no matter what the background color is. The second time you draw
> the cursor at the same spot it will restore the display to its original
> condition.
>
> I'm not sure, but I think someone actually has a ridiculous patent on
> this algorithm. It has been used for decades.
>
> Good luck!
>
> Al Williams
> AWC
> * 8 channels of PWM
> http://www.al-williams.com/awce/pak5.htm
>
> >
Original Message
> > From: John Leung [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=J_NfFA7--mdokxOHDVDz1ULKvqevCFf9AaHa7mx8q2B97zF1injxt6-Soh1hZo5rGHOFjEM_OaeG-NtmTS_1]jleung00@n...[/url
> > Sent: Saturday, December 01, 2001 3:55 AM
> > To: basicstamps@yahoogroups.com
> > Subject: Re: [noparse][[/noparse]basicstamps] Re: Manual draw on a graphical LCD
> > following mouse movement
> >
> >
> > Sirs
> >
> > Glad to use Scott Edward's G12032 LCD with a PAK6 for manual
> > drawing on the LCD following a mouse movement. Basically the code is
> >
> > BLACK = color of drawing
> > L=draw line code in G12032.
> >
> > Loop:
> > get x2 & y2
> > Serout pin0,n9600,[noparse][[/noparse]ESC,"I",BLACK,ESC,"L",x1+CUT0,y1+CUT0,
> > x2+CUT0, y2+CUT0] pause 50
> > x1=x2 'update old x position
> > y1=y2 'update old y position
> > goto Loop
> >
> > 'x1 y1 the previous position
> > 'x2 y2 the present position
> > 'CUT0=64
> >
> > As a step forward, I want to create a mouse cursor like the
> > one in our PC, it can be an arrow or a fat finger like that
> > in Mac. However, that needs a "draw-redraw" routine that
> > covers the "hidden" area of the LCD as the cursor moves over
> > a certain area. I am thinking of using a custom graphics of a
> > small cursor shape to be saved as a custom ASC code
> > character, and repeatly load it by following the present x2
> > y2 position. Not sure if it works. I would be grateful if
> > anybody could give me an advice on that. Any idea is welcome.
> >
> > John
> >
> >
> >
> >
> >
> >
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@yahoogroups.com
> > from the same email address that you subscribed. Text in the
> > Subject and Body of the message will be ignored.
> >
> >
> > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> >
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.295 / Virus Database: 159 - Release Date: 11/1/01
Still working on the captioned project. By following your line of thought, I
wrote the following:
**********************************************************
....
Cursor con 129 'define cursor as a custom character as ASCII value
129
....
GetMousePos 'sub-routine to get current position x, y
Serout pin0, n9600, [noparse][[/noparse]ESC, "M", 65] 'turn on XOR mode
DrawCursor:
Serout pin0, n9600, [noparse][[/noparse]Cursor(x,y)] 'draw cursor as a function
of position x,y
**********************************************************
Hey, hold! Is there any command to position a particular custom character in
EEPROM according to x,y position? I search over the graphical LCD manual but
there doesn't seem to be one.
So I need to work out how to "draw" a cursor as follow:
+++++++++++++++++++++++++++++++++++++++++++++++++++
Cursor var byte(6) 'define the cursor to be a bin pattern of
6x8
Idx var nib 'x index
Idy var nib 'y index
'x, y being the current cursor position
Serout pin0, n9600, [noparse][[/noparse]ESC, "M", 65] 'turn on XOR mode
FOR Idx=0 TO 5
FOR Idy=0 TO 7
Serout pin0, n9600, [noparse][[/noparse]ESC, "I", Cursor, P, x+Idx, y+Idy] 'draw
bit-pattern of Cursor according to its relative position to x,y
NEXT Idy
NEXT Idx
++++++++++++++++++++++++++++++++++++++++++++++++++++
This code doesn't work because cursor is an array. My problem is that I
don't know how to extract the bit-wise information inside Cursor and put it
into the serout command. Maybe this code is totally wrong, I don't know. Any
suggestion would be very helpful.
Thanks a lot.
John
Original Message
From: Al Williams <alw@a...>
To: <basicstamps@yahoogroups.com>
Sent: Saturday, December 01, 2001 9:30 PM
Subject: RE: [noparse][[/noparse]basicstamps] Re: Manual draw on a graphical LCD following
mouse movement
> Hi John,
>
> Sounds like a nice project. The SEETRON LCD has an XOR mode just for
> this purpose. You set it using ESC M 1. Then drawing a white pixel will
> invert whatever is there already. I'm assuming ESC M 0 resets the mode
> although the docs say it goes to OR mode which would not be normal
> drawing (but I think he really means to say XOR mode off).
>
> So here's the deal:
> 1) Turn on XOR mode
> 2) Draw your cursor at the current location
> 3) Wait for the mouse to move
> 4) Draw your cursor again at the same location as step 2
> 5) Goto step 2
>
> Of course, this assumes you aren't drawing. You'd do any drawing between
> step 4 and 5 (and then jump back to step 1 instead of 2 since your
> drawing code will reset XOR mode).
>
> The logic here is the first time you draw the cursor will definitely be
> visible no matter what the background color is. The second time you draw
> the cursor at the same spot it will restore the display to its original
> condition.
>
> I'm not sure, but I think someone actually has a ridiculous patent on
> this algorithm. It has been used for decades.
>
> Good luck!
>
> Al Williams
> AWC
> * 8 channels of PWM
> http://www.al-williams.com/awce/pak5.htm
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.295 / Virus Database: 159 - Release Date: 11/1/01
can use a character with the XOR mode, nor can you position the
characters at arbitrary X/Y positions. You'll need to literally plot a
cross or something using the plot functions.
Al Williams
AWC
* 8 channels of PWM
http://www.al-williams.com/awce/pak5.htm
>
Original Message
> From: John Leung [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=lwAnPGnFrXPcoWcVV0g8L29akeEYed0el13sBvdp9tOUOyGZvVBpbxGz8pMAOL-Lz6We_oJ6T2M7kRYCKafm9E0]jleung00@n...[/url
> Sent: Saturday, December 01, 2001 1:08 PM
> To: basicstamps@yahoogroups.com
> Subject: Re: [noparse][[/noparse]basicstamps] Re: Manual draw on a graphical LCD
> following mouse movement
>
>
> Hi Williams
>
> Still working on the captioned project. By following your
> line of thought, I wrote the following:
> **********************************************************
> ....
> Cursor con 129 'define cursor as a custom character
> as ASCII value
> 129
> ....
> GetMousePos 'sub-routine to get current position x, y
>
> Serout pin0, n9600, [noparse][[/noparse]ESC, "M", 65] 'turn on XOR mode
>
> DrawCursor:
> Serout pin0, n9600, [noparse][[/noparse]Cursor(x,y)] 'draw cursor
> as a function
> of position x,y
> **********************************************************
> Hey, hold! Is there any command to position a particular
> custom character in EEPROM according to x,y position? I
> search over the graphical LCD manual but there doesn't seem to be one.
>
> So I need to work out how to "draw" a cursor as follow:
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Cursor var byte(6) 'define the cursor to be a
> bin pattern of
> 6x8
> Idx var nib 'x index
> Idy var nib 'y index
> 'x, y being the current cursor position
>
> Serout pin0, n9600, [noparse][[/noparse]ESC, "M", 65] 'turn on XOR mode
>
> FOR Idx=0 TO 5
> FOR Idy=0 TO 7
> Serout pin0, n9600, [noparse][[/noparse]ESC, "I", Cursor, P, x+Idx, y+Idy] 'draw
> bit-pattern of Cursor according to its relative position to x,y
> NEXT Idy
> NEXT Idx
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++
> This code doesn't work because cursor is an array. My problem
> is that I don't know how to extract the bit-wise information
> inside Cursor and put it into the serout command. Maybe this
> code is totally wrong, I don't know. Any suggestion would be
> very helpful.
>
> Thanks a lot.
>
> John
>
>
>
Original Message
> From: Al Williams <alw@a...>
> To: <basicstamps@yahoogroups.com>
> Sent: Saturday, December 01, 2001 9:30 PM
> Subject: RE: [noparse][[/noparse]basicstamps] Re: Manual draw on a graphical LCD
> following mouse movement
>
>
> > Hi John,
> >
> > Sounds like a nice project. The SEETRON LCD has an XOR mode
> just for
> > this purpose. You set it using ESC M 1. Then drawing a white pixel
> > will invert whatever is there already. I'm assuming ESC M 0
> resets the
> > mode although the docs say it goes to OR mode which would not be
> > normal drawing (but I think he really means to say XOR mode off).
> >
> > So here's the deal:
> > 1) Turn on XOR mode
> > 2) Draw your cursor at the current location
> > 3) Wait for the mouse to move
> > 4) Draw your cursor again at the same location as step 2
> > 5) Goto step 2
> >
> > Of course, this assumes you aren't drawing. You'd do any drawing
> > between step 4 and 5 (and then jump back to step 1 instead
> of 2 since
> > your drawing code will reset XOR mode).
> >
> > The logic here is the first time you draw the cursor will
> definitely
> > be visible no matter what the background color is. The
> second time you
> > draw the cursor at the same spot it will restore the display to its
> > original condition.
> >
> > I'm not sure, but I think someone actually has a ridiculous
> patent on
> > this algorithm. It has been used for decades.
> >
> > Good luck!
> >
> > Al Williams
> > AWC
> > * 8 channels of PWM
> > http://www.al-williams.com/awce/pak5.htm
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.295 / Virus Database: 159 - Release Date: 11/1/01
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
> Subject and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>