SetPixel like method...

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

SetPixel like method...

Postby imaginedvl » Sat Mar 01, 2008 3:55 am

Hi,

I have 2 questions:

1 - I'm trying to find a SetPixel method... I tried to use the SetPixels one but there is nothing into the documentation about it. What I want to is to Set a pixel to 1 or 0...

2 - What kind of int[] array the setDisplay method expect?
private static int SCREEN_HEIGHT = 60;
private static int SCREEN_WIDTH = 100;
private int[] fPixels = new int[SCREEN_HEIGHT * SCREEN_WIDTH];

I tried to pass this fPixels array in argument and I got a Java Exception on my NXT (Class:5, Method:2).
imaginedvl
New User
 
Posts: 4
Joined: Sat Mar 01, 2008 3:54 am

Postby gloomyandy » Sat Mar 01, 2008 9:16 am

Hi a few questions....
1. What version of leJOS are you using.
2. What is it you are trying to do...

leJOS 0.5 has a number of enhancements in the graphics area. It allows direct access to the screen buffer from Java (but you probably don't want to do that), it also has a bitBlt function, a better setPixel function and the display now auto refreshes.

I would not recommend the use of the setDisplay or setPixels. I would also avoid accessing the screen display directly as this may change in the future.

For some reason the doc for these new functions does not seem to show up in the online API doc. However if you take a look at the source for the LCD class and the graphics class I'm sure you can work it out....

http://lejos.svn.sourceforge.net/viewvc/lejos/trunk/classes/lejos/nxt/LCD.java?revision=1358&view=markup
http://lejos.svn.sourceforge.net/viewvc/lejos/trunk/classes/javax/microedition/lcdui/Graphics.java?revision=1358&view=markup

Hope this helps

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4082
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby imaginedvl » Sat Mar 01, 2008 4:15 pm

Hello Andy,

I'm using the version 0.5. In fact having access to the screen buffer from Java would be sweet for what I want to do. I'm just trying to have fun with the LCD Screen and play with pixels "switching" to simulate different gray levels. And so to have a way to display more than Black or White colors.

Anyways, thanks for your reply and I will look directly at the LCD source code, that's great. Also I found the Graphics class (javax.microedition.lcdui.Graphics) very usefull for what I want to do. My only concern is of course not having direct access to the screen for performance issues but I'll check the code in sourceforge, I did not think to that.
imaginedvl
New User
 
Posts: 4
Joined: Sat Mar 01, 2008 3:54 am

Postby gloomyandy » Sat Mar 01, 2008 6:10 pm

Hi,
Sounds interesting. Well if you are going to be trying to update the screen often then you might want to disable the automatic refresh and control the refresh yourself. I seem to remember that a dma refresh of the screen takes around 0.1 of a second so you are probably not going to be able to get much more then 10fps or so... If you are going to be updating the entire screen then you probably want to use either the new bitBlt or System.arrayCopy, bot of which use native code and are way faster for copying large chunks of data around than using Java...

All the best...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4082
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK


Return to NXJ Projects

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

more stuff