aldweb

Close I. aldweb

Close II. PC Freeware

Close III. Palm Freeware

Close IV. Palm Shareware

Close V. iziBasic Palm

Close VI. Palm Knowledge

Close VII. Pocket Computer

Close VIII. miniPortail

Special !



Mobile version of
the aldweb Site

m.aldweb.com


Neither French, nor English?

Try one of these flags then:
[de] [es] [it] [pt]
Search




Weather / Spam / www

Lyon Weather


aldweb against spam


Newsletter
To receive news about this website, consider subscribing to our Newsletter.
Subscribe
Unsubscribe
298 Subscribers
Family's web sites

Webmaster - Infos
Friends News
Visits

   visitors

   visitors online

Poll
What do you think of the new design of the aldweb Site?
 
Great !
Beautiful
Average
So ugly...
Results
forum.gifForum - iziBasic - Topic #1032

Forum - Forum
iziBasic - iziBasic


Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257

active  Topic # 1032  Is there a "PENMOVE" event?

05/01/2005 @ 04:44
by Jim

Anonymous



I am using the latest full version 4 of IziBasic (I purchased it tonight!!) and it seems to have all the elements required to create a simple drawing app, but it seems to be missing a "penmove" event.

Has anyone been able to code a simple app that would let you "draw" on the screen? I can do this in Plua and PocketC, but I can't seem to get it to work with IziBasic.

I have been able to set the screen, recognize a PENDOWN event, and even PSET a pixel, but I can't figure out how to get IziBasic do smoothly draw.

Any suggestions?

by the way, GREAT app! Combined with SrcEdit, this is truely an all-in-one, onboard development environment!

Thanks!

-Jim
jimstips.com
  Post an answer  Top

[]   

StartPrevious [ 1 2 3 ] NextEnd

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 1
--------
05/01/2005 @ 12:37
by aldweb

Anonymous

visitor
Hello Jim,

Events, like pen events, are trapped with a DOEVENTS or WAITEVENT function.
If either of these two functions returns the 1000 value, then a pen event occured.
Now, you just have to find out what happened.

If the PENDOWN function returned 1 (meaning true) the previous time a pen event had occured, and if it is still returning true, then the pen is still down and it is very probable that it moved.
If it just returned 0 (meaning false) and you had trapped that it was down before, then the pen was just lifted and you know that you have to stop drawing.

If one of the two PENX and PENY returns a different value than previously (meaning during the last event returning 1000), then the pen moved to the new (x,y) position returned by PENX and PENY.

So, to sum up:
1. track if a pen event occured with DOEVENTS or WAITEVENT
2. check if the pen is down or up with PENDOWN
3. check the position of the pen with PENX and PENY
4. compare returned values of PENDOWN, PENX and PENY with the values returned the last time a pen event has occured and code accordingly to what you want to do.

iBChristmas and NekoCat are two sample applications shipped with iziBasic and they do use these functions. So, you might want to give a look to their source codes.

And, if you want, I could give you a quick dirty source code here (the one I used to check that these functions work well!) to build a drawing application

Cheers

@+
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 2
--------
05/01/2005 @ 13:35
by Jim

Anonymous

visitor
aldweb,

Thanks for the info! That makes sense. If you want to post an example, that would be great. When I get something coded, I'll post it.

Thanks again!
Write to Jim   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 3
--------
05/01/2005 @ 16:59
by Jim

Anonymous

visitor
OK, my goal is simple: Create a very simple "drawing program" that would let me do "freehand" sketches with the pen. I first started by creating the following very simple program:

' -----
{CreatorID "jwb1"}
{Version "1.0"}
BEGIN
REPEAT
a=DOEVENTS
IF a = 1000 THEN
IF p=1 THEN
x=PENX
y=PENY
PSET x,y
END IF
END IF
UNTIL a<0
END
' -----

When run, this simply draws a pixel AT THE POSITION WHERE THE PEN GOES DOWN. Nothing more, nothing less. Great for drawing a bunch of dots, but not great for freehand drawing.

Next, I created a simple "line draw" program by adding the LINE function to the above:

' -----
{CreatorID "jwb2"}
{Version "1.0"}
BEGIN
REPEAT
a=DOEVENTS
IF a = 1000 THEN
IF p=1 THEN
x=PENX
y=PENY
PSET x,y
END IF
IF p=0 THEN
w=PENX
z=PENY
LINE x,y TO w,z
END IF
END IF
UNTIL a<0
END
' -----

This captures the starting point on a PENDOWN event and draws a line to the point where the pen is lifted. We're getting closer, but it still requires you to lift the pen before anything draws.

OK, so far so good. But now what I cannot figure out is how to get IziBasic to return updated PENX or PENY values AS THE PEN IS DOWN AND MOVING. Being able to do this would let me develop a "freehand draw" function.

The v4.0 documentation states on page 45 for PENDOWN, PENX, and PENY that the fucntions are "...trapped during a DOLOOP or a WAITEVENT call (return value of pen event is 1000)" Could this be the problem?

After reviewing the "iBChristmas" and "NekoCat" applications, it seems that while these apps only react to the PENDOWN event, not actual pen movement.

In other words, I can get IziBasic to respond to "taps" but not "strokes". So, does anyone have any suggestions on how to retrieve dynamically updating PENX and PENY values while the pen is moving? If this is not curently possible in IziBasic, could this be a feature request for a future version?
Write to Jim   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 4
--------
05/01/2005 @ 17:23
by Jim

Anonymous

visitor
Correction:

The seceond code listing should read:

-----
{CreatorID "jwb2"}
{Version "1.0"}
BEGIN
REPEAT
a=DOEVENTS
IF a = 1000 THEN
p=PENDOWN
IF p=1 THEN
x=PENX
y=PENY
PSET x,y
END IF
IF p=0 THEN
w=PENX
z=PENY
LINE x,y TO w,z
END IF
END IF
UNTIL a<0
END
' -----
I omitted the "p=PENDOWN" line...
Write to Jim   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 5
--------
05/01/2005 @ 19:05
by aldweb

Anonymous

visitor
Indeed, this listing is not very effective!

Rather do something like (sorry, no guaranty, I cannot test anything because I just broke the screen of my Tungsten C this morning and I am left without any device... bad luck!):
' Draw.ibas
{CREATORID "JWB2"}
{VERSION "1.0"}

BEGIN
REPEAT
a=DOEVENTS
IF a=1000 THEN
p=PENDOWN
IF p=1 IF q=0 LET x=PENX : y=PENY : PSET x,y
IF p=1 IF q=1 LET x=PENX : y=PENY : LINETO x,y
q=p
ENDIF
UNTIL a<0
END


Additional comment: don't use lowercase only CreatorIDs, these are reserved by Palm OS.

Cheers

@+
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 6
--------
05/01/2005 @ 22:33
by Jim

Anonymous

visitor
aldweb,

You broke your T3 screen?!? OUCH!!! Huge bummer!

I tried out your code, and it still only generates "pixels" for each tap. Maybe when you get a working unit, you can try it out...

Also, I downloaded and played with the BIRD resource editor, and it is VERY cool! I "duplicated" the iBChristmas.rsrc file creating a new one, and used it as a template creating new images with the onboard editor. Very nice. It's tedious work, but I was able to create new icons and images specific to my app. Very nice.!

Now, if I can just get this "pen move" concept working...
Write to Jim   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 7
--------
05/01/2005 @ 22:49
by aldweb

Anonymous

visitor
Jim,

This is a Tungsten C, a great device with its keyboard for quick source code writing directly on the device
I have put a scan of my device, showing the screen crash result in the News area of this site...

You asked me for a PenMove simulation, so I built a source code that would plot a pixel when taping with the pen on the screen. Now, if you keep the pen down and move around, you will see lines being drawn.
And all of this was done with very few lines of code as you could see... isn't that great and poweful?
Would you wish to draw a line between two taps, you may adapt my source code of course

Cheers

@+
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 8
--------
06/01/2005 @ 15:46
by Jim

Anonymous

visitor
aldweb,

Thank you for your help. I hope you can replace yout Tungsten C soon!


I am still having a problem with iziBasic and "drawing".

I entered your code and played with it for a while testing changes here and there.

I can code a program so when I tap, iziBasic draws single pixels, one per tap at the location of the tap.

I can code a program so when I tap and then tap again, iziBasic draws a line between the two points I tapped.

My problem is that I cannot seem to get iziBasic to draw CONTINUOUSLY while the pen is held down and moved across the screen from one location to another.

I wrote a simple modification to your code and included some "debug" labels that display the contents of several variables. When I run this, the variables properly update on each "pen down" or "pen up" action, but nothing updates while I drag the pen across the screen. What I'm looking for is a way to return an updated location of the pen as it is dragged across the screen. Any suggestions?

Here is the code I created:

'test.ibas
{CreatorID "JWB8"}
{Version "1.0"}
BEGIN
color 0
screen 4
let x = 0
let y = 0
let p = 0
let q = 0

'init debug labels
label #10,"X: ",50,0
A$­­=str$­­(x,0) : label #11,A$­­,60,0
label #20,"Y: ",80,0
A$­­=str$­­(y,0) : label #21,A$­­,90,0
label #30,"P: ",110,0
A$­­=str$­­(p,0) : label #31,A$­­,120,0
label #40,"Q: ",140,0
A$­­=str$­­(q,0) : label #41,A$­­,150,0

'event loop
repeat
a=doevents

'trap pen event
IF a=1000 THEN
p=PENDOWN
IF p=1 THEN
x=penx
y=peny
'aldweb code
IF p=1 IF q=0 PSET x,y
IF p=1 IF q=1 LINETO x,y
q=p
END IF

'update debug labels
A$­­=str$­­(x,0) : updatelabel #11,A$­­
A$­­=str$­­(y,0) : updatelabel #21,A$­­
A$­­=str$­­(p,0) : updatelabel #31,A$­­
A$­­=str$­­(q,0) : updatelabel #41,A$­­
end if
until a<0
END
Write to Jim   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 9
--------
06/01/2005 @ 17:29
by aldweb

Anonymous

visitor
Hello Jim,

You succeeded to make me doubt of my source code, so I tested it in my wife's device (and she was not happy that I steal her device for the 10 minutes required to install iziBasic and this source code in a Memo).
And I confirm that my source code DOES DRAW CONTINUOUSLY while the pen is down as you initially requested.

The way you modified it, indeed, leads to not draw continuously!

Your error is in the IF p=1 THEN test that you added right after the p=PENDOWN line. Then, something happens only when p is equal to 1 and q can only be refreshed to the 1 value in your algorithm... so it is useless!


Sorry, but this is a coding mistake, nothing related to iziBasic's capabilities...

Another quick comment, for your information: no need to initiate the x,y, p and q variables as you did at the begining of your source code. They are initiated automatically by iziBasic to the 0 value

Cheers

@+
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 10
--------
06/01/2005 @ 19:48
by Jim

Anonymous

visitor
aldweb,

Again, thanks for your help and patience...

For some reason, I still cannot get the program you posted to draw continuously. It only draws "dots" when I tap. I know I must be missing something. I'm running it on a Tungsten C. I even did a hard reset and ran it just to see if I was running anything else that might conflict, but it behaved the same. Here is the code I am using that I copied directly from your posting:

' Draw.ibas
{CREATORID "JWB2"}
{VERSION "1.0"}
BEGIN
REPEAT
a=DOEVENTS
IF a=1000 THEN
p=PENDOWN
IF p=1 IF q=0 LET x=PENX : y=PENY : PSET x,y
IF p=1 IF q=1 LET x=PENX : y=PENY : LINETO x,y
q=p
ENDIF
UNTIL a<0
END


I know I must be missing something...
Write to Jim   Post an answer  Top
StartPrevious [ 1 2 3 ] NextEnd
active topic active   closed topic closed   Sticky Sticky   New New message   -   Correct Correct message   Close Close topic   Make sticky Make sticky
[]
Forum Topic  Forum 



 
^ Top ^