{{ 4D Systems (c) 2007 All rights reserved Authors: Atilla Aknar Steve McManus uOLED-96-PROP GRAPHICS Object demo. Demonstrates the use of the Graphics and Screen primative methods contained in the uOLED-96-PROP Object. A single method call from your SPIN program can put a colored pixel on the display screen at a location of your choosing. NO SERIAL COMMS REQUIRED The Propeller chip is controlling the display hardware directly and quickly. Other Graphics Methods for Line, Rectangle, etc. have been implemented in the accompanying Object. It is intended that the user will use these primitive methods to build more complex methods to develope a full suite of graphics commands such as Circle, Triangle, Polygon, etc. }} CON _CLKMODE = XTAL1 + PLL16X _XINFREQ = 8_000_000 dSlow = 50 dFast = 20 OBJ OLED : "uOLED-96-Prop_V4" DELAY : "Clock" PUB Demo DELAY.Init(8_000_000) OLED.InitOLED OLED.CLS REPEAT Splash Scroll Pixels PropLines PropWedge Rectangles AniRectangles MovingLines TextString PUB Splash oled.putChar ("4", 1,1,1, 255,255,255) oled.putChar ("D", 2,1,1, 255,255,255) oled.putChar ("S", 4,1,1, 255,255,255) oled.putChar ("y", 5,1,1, 255,255,255) oled.putChar ("s", 6,1,1, 255,255,255) oled.putChar ("t", 7,1,1, 255,255,255) oled.putChar ("e", 8,1,1, 255,255,255) oled.putChar ("m", 9,1,1, 255,255,255) oled.putChar ("s", 10,1,1,255,255,255) oled.putChar ("u", 2,3,1, 255,255,255) oled.putChar ("O", 3,3,1, 255,0,0) oled.putChar ("L", 4,3,1, 0,255,0) oled.putChar ("E", 5,3,1, 0,0,255) oled.putChar ("D", 6,3,1, 255,255,0) oled.putChar ("-", 7,3,1, 255,255,255) oled.putChar ("9", 8,3,1, 255,255,255) oled.putChar ("6", 9,3,1, 255,255,255) oled.putChar ("P", 4,5,1, 255,0,0) oled.putChar ("R", 5,5,1, 255,0,0) oled.putChar ("O", 6,5,1, 255,0,0) oled.putChar ("P", 7,5,1, 255,0,0) oled.putChar ("4", 3,7,0, 255,255,255) oled.putChar ("D", 4,7,0, 255,255,255) oled.putChar ("(", 5,7,0, 255,255,255) oled.putChar ("c", 6,7,0, 255,255,255) oled.putChar (")", 7,7,0, 255,255,255) oled.putChar ("2", 9,7,0, 255,255,255) oled.putChar ("0", 10,7,0, 255,255,255) oled.putChar ("0", 11,7,0, 255,255,255) oled.putChar ("7", 12,7,0, 255,255,255) delay.PauseSec(2) PUB Scroll '' The following is an example of writing directly to the display's registers from a user program '' without building a Method in the Object to do the task oled.Write_cmd ($27) ' Scroll control register (from controller datasheet) oled.Write_cmd (0) ' Horizontal - # of columns (0 = no Horizontal scroll) oled.Write_cmd (0) ' Start line oled.Write_cmd (64) ' Lines to scroll oled.Write_cmd (63) ' Vertical - # of rows (0 = no Vertical scroll) oled.Write_cmd (1) ' Interval (speed) 0:3 0=fast, 3=slow oled.Write_cmd ($2F) ' Scroll Start delay.PauseSec(8) oled.Write_cmd ($2E) ' Scroll Stop delay.PauseSec(3) oled.cls delay.PauseSec(1) '' Or you could have called the Object method '' oled.ScrollSetup (0, 0, 64, 63, 1) 'Vertical scroll PUB Pixels OLED.PutPixel(0,0, 255,255,255) ' Put a WHITE pixel at x:0, y:0 DELAY.PauseSec(1) OLED.PutPixel(95,0, 255,0,0) ' Put a RED pixel at x:95, y:0 DELAY.PauseSec(1) OLED.PutPixel(95,63, 0,0,255) ' Put a BLUE pixel at x:95, y:63 DELAY.PauseSec(1) OLED.PutPixel(0,63, 0,255,0) ' Put a GREEN pixel at x:0, y:63 DELAY.PauseSec(1) PUB PropLines |Temp repeat Temp from 0 to 47 OLED.Line (Temp,0,47,31, 255,255,255) ' Draw White line top-left to center of screen delay.pausemsec(20) OLED.Line (Temp,0,47,31, 0,0,0) OLED.Line (47,0,47,31, 255,255,255) DELAY.PauseSec(1) repeat Temp from 0 to 31 OLED.Line (95,Temp,47,31, 255,0,0) ' Draw Red line from top-right to center of screen delay.pausemsec(20) OLED.Line (95,Temp,47,31, 0,0,0) OLED.Line (95,31,47,31, 255,0,0) DELAY.PauseSec(1) repeat Temp from 95 to 47 OLED.Line (Temp,63,47,31, 0,0,255) ' Draw Blue line from bottom-right to center of screen delay.pausemsec(20) OLED.Line (Temp,63,47,31, 0,0,0) OLED.Line (47,63,47,31, 0,0,255) DELAY.PauseSec(1) repeat Temp from 63 to 31 OLED.Line (0,Temp,47,31, 0,255,0) ' Draw Green line bottom-left to center of screen delay.pausemsec(20) OLED.Line (0,Temp,47,31, 0,0,0) OLED.Line (0,31,47,31, 0,255,0) DELAY.PauseSec(1) OLED.CLS DELAY.PauseSec(1) PUB PropWedge |Temp repeat Temp from 0 to 47 OLED.Line (Temp,0,47,31, 255,255,255) ' Draw White line top-left to center of screen delay.pausemsec(20) DELAY.PauseSec(1) repeat Temp from 0 to 31 OLED.Line (95,Temp,47,31, 255,0,0) ' Draw Red line from top-right to center of screen delay.pausemsec(20) DELAY.PauseSec(1) repeat Temp from 95 to 47 OLED.Line (Temp,63,47,31, 0,0,255) ' Draw Blue line from bottom-right to center of screen delay.pausemsec(20) DELAY.PauseSec(1) repeat Temp from 63 to 31 OLED.Line (0,Temp,47,31, 0,255,0) ' Draw Green line bottom-left to center of screen delay.pausemsec(20) DELAY.PauseSec(1) OLED.CLS DELAY.PauseSec(1) PUB Rectangles OLED.Rectangle (0,0,31,63,0, 255,0,0) ' Draw a solid red rectangle covering left 1/3 of screen DELAY.PauseSec(1) OLED.Rectangle (32,0,63,63,0, 0,255,0) ' Draw a solid green rectangle covering middle 1/3 of screen DELAY.PauseSec(1) OLED.Rectangle (64,0,95,63,0, 0,0,255) ' Draw a solid blue rectangle covering right 1/3 of screen DELAY.PauseSec(1) OLED.CLS DELAY.PauseSec(1) PUB AniRectangles | Temp REPEAT Temp from 1 to 30 oled.cls oled.rectangle (Temp,Temp, (Temp * 2), (Temp * 2) ,0, 255,0,0) delay.pausemsec(dSlow) delay.PauseSec(1) oled.cls PUB MovingLines | Temp, Spd Spd := 20 repeat 3 repeat Temp from 0 to 63 oled.line (0,Temp, 95,Temp, 0,0,255) ' blue line delay.pauseMSec(Spd) oled.line (0,Temp, 95,Temp, 0,0,0) ' erase line repeat Temp from 63 to 0 oled.line (0,Temp, 95,Temp, 255,0,0) ' red line delay.pauseMSec(Spd) oled.line (0,Temp, 95,Temp, 0,0,0) ' erase line repeat Temp from 0 to 63 oled.line (0,Temp, 95,Temp, 0,255,0) ' green line delay.pauseMSec(Spd) oled.line (0,Temp, 95,Temp, 0,0,0) ' erase line repeat Temp from 63 to 0 oled.line (0,Temp, 95,Temp, 255,255,0) ' yellow line delay.pauseMSec(Spd) oled.line (0,Temp, 95,Temp, 0,0,0) ' erase line Spd := Spd - 10 delay.PauseSec(2) oled.cls PUB TextString oled.PutText (1,0,0, 255,255,0, string("Font 0 5x7")) oled.PutText (0,3,0, 255,255,255, string("This is just a long string in FONT 0 text to test the PutText function. ")) delay.PauseSec(5) oled.cls oled.PutText (0,0,1, 255,255,255, string("Font 1 8x8")) oled.PutText (0,3,1, 255,255,0, string("This is just a long string in FONT 1 text to test the PutText function. ")) delay.PauseSec(5) oled.cls delay.PauseSec(3)