MetkuMods

OLED Technology by 4D Systems


 
Author: Aki Korhonen
Published: 25.06.2009
Product manufacturer: 4D Systems
In English In English
Suomeksi Suomeksi

ĀµOLED-32024-P1T, 2.4" OLED Module with Touch - Usage

At the time of writing, there isn't serial platform firmware available for the Picaso processor so the display can only be used with 4DGL. There was few little problems with the display module first as it came with a wrong firmware which resulted in a non-working touch panel and the 4DGL Workshop refused to download the program to the module (had to select a wrong model to load it). After some head scratching I happened to test downloading the latest firmware for this module and loaded it with the PmmC Loader and after that everything worked like they should. So if you get one of these and it doesn't work right, upgrade the firmware!

Starfield effect made with 4DGL

Yes, the same code as with the small display! Only some minor tweaks in the init function and the display dimensions are changed at the beginning where the constants are defined. And more stars of course as the resolution is way higher.

Get Flash to see this player.

The code:

#platform "uOLED-32024-P1T"

/*************************************************
* MetkuMods - http://metku.net/
*
* Filename: picaso_starfield.4dg
* Created: 2009/04/20
* Author: Aki Korhonen
* Description: Starfield for Picaso
**************************************************/

#inherit "4DGL_16bitColours.fnc"

#constant NUMBER_OF_STARS 100
#constant STAR_ARRAY_SIZE 1000 // NUMBER_OF_STARS * 5
#constant SCREEN_WIDTH 240
#constant SCREEN_HEIGHT 320

// 0 = xpos
// 1 = ypos
// 2 = zpos
// 3 = speed
var stars[STAR_ARRAY_SIZE];

func init_star(var i)
	stars[i*5+0] := RAND() % 40;
	stars[i*5+1] := RAND() % 40;
	
	stars[i*5+0] := stars[i*5+0] * 3072;
	stars[i*5+1] := stars[i*5+1] * 3072;
	
	stars[i*5+2] := i;
	stars[i*5+3] := 2 + ABS(RAND() % 3);
endfunc

func init()
	var i;
	
	i := 0;
	while(i++<NUMBER_OF_STARS)
		init_star(i);
	wend
endfunc

func main()
	var centerx, centery;
	var i, tempx, tempy;
	
	init();
	
	centerx := SCREEN_WIDTH >> 1;
	centery := SCREEN_HEIGHT >> 1;
	
	while(1)
		// Clear screen
		gfx_Cls();
		
		// Move and draw stars
		i := 0;
		while(i++<NUMBER_OF_STARS)
			stars[i*5+2] := stars[i*5+2] - stars[i*5+3];
			
			if(stars[i*5+2] <= 0)
				init_star(i);
			endif
			
			// Compute 3D position
			tempx := (stars[i*5+0] / stars[i*5+2]) + centerx;
			tempy := (stars[i*5+1] / stars[i*5+2]) + centery;
			
			// Check if a star leaves the screen
			if(tempx < 0 || tempx > SCREEN_WIDTH - 1 ||
			   tempy < 0 || tempy > SCREEN_HEIGHT - 1)
				init_star(i);
			endif
			
			gfx_PutPixel(tempx, tempy, WHITE);
		wend
        
        pause(2);
	wend
endfunc






Pages:  1 2 3 4 5 6 7 8 9 10 11 12 


 
  Content in english!
  Sisältö suomeksi!

 Google





 .:Back to top Bandwidth by Mpoli

Copyright © Metku.net, All Rights Reserved.
All content and graphics in MetkuMods are sole property of Jani Pönkkö and may not be reproduced or copied in any manner without written permission from him.
All brand names, trademarks and copyrights are the property of their respective owners.Privacy Policy