+ Reply to Thread
Results 1 to 28 of 28
  1. #1
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default 2x16 LCD Graphics :)

    Hi Guys,
    I know the odometer effect has been done, also the bargraph,
    but both use single isolated custom chars as up to eight screen buffers drawn all over the place.

    Has anyone considered making a frame buffer array in RAM, and then copying out
    the bytes to all of the eight custom characters for every frame?



    It's probably five years too late with the price of gfx LCDs now,
    but I think a nice exercise, and think the rotating 3D cube is doable.
    I was thinking do a real 23x17 frame buffer, and just accept that the
    inbetween lines are invisible pixels, so long as the display is animated.



    Most of the points on the cube are duplicates of another with different initial 2D offsets.
    I can't do the point rotation without trig, but can use another program to generate the
    pre rotated list of points of 36 or so different angles around each axis.
    The lines should be right to draw locally since they only need square root.
    Also proper balls bouncing off walls at inverted angles should be ok locally.

    Pixel resolution horizontal scrolling should be also possible on an 8x1 display.

    Any ideas suggestions? Has someone done this?
    Last edited by Art; - 10th October 2013 at 13:42.

  2. #2
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    Having to send the command to change lines halfway though the drawing is a tragedy,
    and so is setting the LCD home, but the latter doesn't interrupt drawing halfway through.
    It would be better to waste the same amount of time between sending every character.

  3. #3
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    Ok, now I can set pixel coordinates, and no longer have to think about custom characters

    ...

    It was hard because each line for a custom char is still a byte, but only five bits of it are used,
    and the LCD wants them in the least significant bits, but my framebuffer is a continuous stream of bits.
    I'll try the line drawing, and calculating proper angles for balls.
    A smaller (single pixel) ball works better in the small space, but didn't make for a good video.
    Last edited by Demon; - 13th October 2013 at 15:08. Reason: video removed at user's request - Robert

  4. #4
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    Line drawing (almost) :

    ...
    Last edited by Demon; - 13th October 2013 at 15:07. Reason: video removed at user's request - Robert

  5. #5
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    One more:

    ....
    Last edited by Demon; - 13th October 2013 at 15:07. Reason: video removed at user's request - Robert

  6. #6
    Join Date
    Nov 2003
    Location
    Sao Paulo - Brazil
    Posts
    79

    Default Re: 2x16 LCD Graphics :)

    Impressive ! .... Really.
    Last edited by srspinho; - 12th October 2013 at 16:18. Reason: Error

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    1,734

    Default Re: 2x16 LCD Graphics :)

    Very!

    Robert

  8. #8
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    Thanks Guys,
    I am having some trouble with diagonal lines and circles.
    When you use a real gfx display with PBP, is it usually the display that
    handles the lines and circles, or is it done in PBP?

    I'm finding the algorithms are usually in C, and all seem to want to look
    for values below zero (signed integer variables), where one of these
    variables would wrap back to 0xFF if you decremented from zero using PBP

    For the only diagonal lines in the video, I was able to do a trick and
    check a value is above #128, pretending that value is zero.
    This is so far only working if the destination point of the line has higher
    x and y coordinates than the start point..
    (ie. I can draw a line at any angle from x-0,y-0, to anywhere).

    Here is the difference in the code.

    Code:
    x0 = 3 : y0 = 3
    x1 = 21 : y1 = 11
    gosub drawline

    Code:
    drawline:
    	stepx = 0
    	stepy = 0
    	frac = 0
    	'a line is x0,y0 to x1,y1.
    	dy = y1 - y0
    	dx = x1 - x0
    
    	IF dy > 128 THEN
    	dy = dy - 1
    	stepy = stepy - 1
    	ELSE
    	stepy = 1
    	ENDIF
    
    	IF dx > 128 THEN
    	dx = dx - 1
    	stepx = stepx - 1
    	ELSE
    	stepx = 1
    	ENDIF
    
    	dy = dy << 1
    	dx = dx << 1
    
        'draw pixel
    	px = x0 : py = y0
    	gosub setpixel
        
    	IF (dx > dy || dx > 128) THEN
    
        frac = dy - (dx >> 1)
        WHILE x0 != x1
        IF (frac < 128) THEN
    	y0 = y0 + stepy
     	frac = frac - dx
    	ENDIF
        x0 = x0 + stepx
        frac = frac + dy
        'draw pixel
      	px = x0 : py = y0
    	gosub setpixel
        WEND
    
    	ELSE
    
        frac = dx - (dy >> 1)
        WHILE y0 != y1
        IF (frac < 128) THEN 
    	x0 = x0 + stepx
    	frac = frac - dy
    	ENDIF
        y0 = y0 + stepy
        frac = frac + dx
        'draw pixel
    	px = x0 : py = y0
    	gosub setpixel
        WEND
    
    	ENDIF
    
    return
    ... and the original C

    Code:
    static void drawLine(int x0, int y0, int x1, int y1, int color, Color* destination, int width)
    {
    	int dy = y1 - y0;
    	int dx = x1 - x0;
    	int stepx, stepy;
    	
    	if (dy < 0) { dy = -dy;  stepy = -width; } else { stepy = width; }
    	if (dx < 0) { dx = -dx;  stepx = -1; } else { stepx = 1; }
    	dy <<= 1;
    	dx <<= 1;
    	
    	y0 *= width;
    	y1 *= width;
    	destination[x0+y0] = color;
    	if (dx > dy) {
    		int fraction = dy - (dx >> 1);
    		while (x0 != x1) {
    			if (fraction >= 0) {
    				y0 += stepy;
    				fraction -= dx;
    			}
    			x0 += stepx;
    			fraction += dy;
    			destination[x0+y0] = color;
    		}
    	} else {
    		int fraction = dx - (dy >> 1);
    		while (y0 != y1) {
    			if (fraction >= 0) {
    				x0 += stepx;
    				fraction -= dy;
    			}
    			y0 += stepy;
    			fraction += dx;
    			destination[x0+y0] = color;
    		}
    	}
    }
    I wonder what of the C compilers that are for 16F pics.
    Maybe they don't do signed integers either?
    If I could compile the original C source in a pic C compiler,
    and then disassemble it, I could have the result in RISC asm.
    Last edited by Art; - 13th October 2013 at 03:19.

  9. #9
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    768

    Default Re: 2x16 LCD Graphics :)

    Quote Originally Posted by Art View Post
    I am having some trouble with diagonal lines and circles.
    When you use a real gfx display with PBP, is it usually the display that
    handles the lines and circles, or is it done in PBP?
    In a real graphic LCD, it is the user who draws the lines / circles using Bresenhams algorithm or a variant. PBP, C or ASM is just a matter of choice.

    I am curious to know why you want to use a character lcd this way other than for the thrill of doing it. You only get 8 programmable characters which is about a 4th of the 16x2 display. Your demos too show repeated patterns. It is much more challenging and fun to get a graphic lcd come upto video speed (20fps and more).

  10. #10
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    It is for the thrill.. and I figure the work is not wasted, because these LCDs do still get use.
    I already did an LED matrix display with games, scroller etc., and I don't think it is getting any faster.
    Also, I have not written for pics in some time, and needed something to get going.
    There is room to duplicate the graphics screen, but for a practical application,
    I figure the rest of the screen would have some text on it.

    I have solved the line drawing, but if you have a way to draw circles in PBP it
    would be appreciated At the moment my circles are perfect squares of the
    correct radius, but I'm keeping that for squares since it beats defining all the corner coordinates

    I would not buy a gfx LCD if I couldn't do the graphics, so it's a good way to come up with
    the routines now. I would still like to do my own hardware/software mapping GPS one day.

    I do plan to give it away when it's finished and cleaned up.


    ps to mods, it would be great if you could delete every video posted here
    (can seem to delete/edit my posts)
    I've done the C-64/Amiga style Megademo
    Last edited by Art; - 13th October 2013 at 06:22.

  11. #11
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    1,734

    Default Re: 2x16 LCD Graphics :)

    Videos removed.

    Robert
    Robert
    Not as dumb as yesterday, but stupider than tomorrow!

  12. #12
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    Thanks Robert, I combined everything into one retro demo:



    I robbed the circle drawing from a GLCD code sample here, and added a bit more.
    There are 10 sections to the demo, but they only last a few seconds each.
    The trick at the end is what I should have started with to trick people to thinking
    I had the entire display

    It is almost ready to go, I just have to make sense of the source for others.
    Last time I released a project, there were three different revisions of matching
    hardware and software improvements with schematics,
    and although others got it working, it caused confusion, and years of follow up for me.
    Being mindful of that this time round, the schematic is in the PBP manual



    The only differences are this is a 16F628A (instead of 16F84/A in the manual),
    the LCD backlight is powered by the pic (RB6) for the strobe effect in the video,
    and the pic is driven with an 8MHz crystal to match the speed in the video.
    The clock speed is not critical though.
    The serial Rx pin in the familiar looking diagram is not implemented.

    If you make a board for this, it's still tentative.
    LCD R/W pin may need to be accessed later, so it might pay to wire
    it to somewhere accessible before wiring it to ground to mod later
    (I heard you can rip all of the character graphics from the LCD itself).
    It should also get a couple of buttons.
    Cheers, Art.

  13. #13
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    1,734

    Default Re: 2x16 LCD Graphics :)

    WARNING: Video may trigger epyleptic seizure in some viewers.

    Use 3D glasses under welding goggles as protection.



    Awesome stuff Art.

    Robert
    Robert
    Not as dumb as yesterday, but stupider than tomorrow!

  14. #14
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    Here it is:
    http://www.freewebs.com/defxev/LC2D.zip


    Hi, we are pleased to see that you are using our forum.

    We'd like you to become a member of our community. Membership is FREE, please REGISTER and view our forums without these annoying reminders!

    Once registered you may post on the forums, download from the file areas and use the WIKI without interruption.






    Interestingly... I realised this is one of the two LCDs I bought off Melanie here ages ago:
    http://www.picbasic.co.uk/forum/show...=2298#post2298
    Funny that. There was not much fancier at the time, but now the options are endless.

    I always get that last little nice feature working AFTER the distribution

  15. #15
    Join Date
    Aug 2006
    Location
    Look behind you.
    Posts
    2,601

    Default Re: 2x16 LCD Graphics :)

    Pretty fancy stuff there Art, He He Imagine that display on the bank's ATM machine, make a good video.
    Anti virus software seems a little like hiring the Mafia to protect you.

    Moderators are just regular members empowered to drop the hammer on a SPAMMER



  16. #16
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    Forgot this:

    Credit to Centrex of Whirlpool forum (Australia).
    Suitable for this, and whatever logging LCD circuit based on the PBP manual LCDOUT example circuit.

    I will do a more bare source code, more intended for people using their own programs,
    and am also getting an 8x1 or 8x2 LCD so I either get a whole line or a whole display to work with.
    The reason being, I hear by connecting the LCD R/W line to an IO pin, you can access the
    LCD's CGROM, and rip the character set. That would be great for the pixel perfect text scroller.

    Up until now, the character data has been stored on EEPROM or on-chip EEPROM for these sort of tricks.

  17. #17
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,246

    Default Re: 2x16 LCD Graphics :)

    You are kidding me, right?

    Unbelievable graphics on this LCDs!!! Wow, Art. Supercalifragilisticexpialidocious!

    Ioannis

  18. #18
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    Quote Originally Posted by Ioannis View Post
    You are kidding me, right?

    Unbelievable graphics on this LCDs!!! Wow, Art. Supercalifragilisticexpialidocious!

    Ioannis
    Thanks

    I always get that last little nice feature working AFTER the distribution
    Happens every time on every platform.
    I suggest, if you would like some cool new feature in a program you write,
    that you upload a distribution, and give it away to the public.
    Then within a day or two, you have changed the way you think about it,
    and have a moment of insight Oh, and the implementation is a breeze also.

  19. #19
    Join Date
    Aug 2006
    Location
    Look behind you.
    Posts
    2,601

    Default Re: 2x16 LCD Graphics :)

    CONGRATULATIONS ART:
    You have been featured on Hackaday
    http://hackaday.com/2013/10/16/teach...s/#more-105170
    Anti virus software seems a little like hiring the Mafia to protect you.

    Moderators are just regular members empowered to drop the hammer on a SPAMMER



  20. #20
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    1,734

    Default Re: 2x16 LCD Graphics :)

    Congrats Art!

  21. #21
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    100

    Default Re: 2x16 LCD Graphics :)

    Been following this thread with interest. Congrats on an awesome job AND your HackaDay feature!
    "I have noticed that even those who assert that everything is predestined and that
    we can change nothing about it still look both ways before they cross the street"


    -Stephen Hawking

  22. #22
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    Thanks Guys
    I finally joined their forum, they would have got it from that.
    I've been watching H-A-D for years... certainly some interesting stuff.
    My 144 LED game ended up there too back when I was doing that.

    Anyways that'll be some nice traffic for ya!

    It makes me wish I'd waited tho
    I'll have to do a version 2.

  23. #23
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)



    Changes for LC2D Version 2 - 18/10/13

    Base code:
    Reduced program memory, and RAM consumption
    (approximately ten more bytes of RAM are freed).
    This leaves more RAM in BANK0 for the user program.
    Performance win on base code
    (first version is still on the site for comparison).
    When the demo program is removed,
    there's much more resource for your program.

    Demo User Program:
    Extra resource freed by improved base code is consumed
    by the new demo. Now has fifteen demo sections!
    The first demo sections are identical, except that the first
    demo section inverts the LCD on it's first cycle for LCD test.
    The new demo sections expand on a trick appearing to
    control the entire LCD display when run on a 2x16 LCD.
    Fixed graphic invader animation frame B sprite (legs).

    Classic Rolling Odometer Effect
    One of the new demo sections is the rolling odometer
    effect that also moves around the display.
    It looks like a penalty, but is not. It's delayed because it
    is the most prone to messing up the display with lag trails
    when run on slow LCDs such as the one in the video.
    The user program doesn't have to move it around,
    or delay any sprite drawing routines.
    I ran out of memory in the process of making it able
    to reverse direction properly for counting backwards.
    Currently, the variable must be incrementing by one.

    New Notes:
    Pic run at 8MHz telling PBP compiler it's running at 4MHz
    results in only 600ms pause time for LCD start up delay.
    PBP manual suggests PAUSE 1000 delay to accomodate
    slower starting LCDs. If your LCD doesn't start, change to
    PAUSE 2200 before compiling the program, or insert the
    pic into the socket after powering the circuit with the LCD.

    Sloppy bounds checking on demo user program demonstrates
    crash proofing in base code. The user program is allowed to
    draw off screen. Base code does not check bounds on the
    individual X,Y coords, rather that their calculated destination
    in the first frame buffer is within bounds of the array.
    Crazy shape or line drawing could still have consequence.
    I don't know what those routines will do in unusual circumstances.

    http://www.freewebs.com/defxev/LC2D.htm

    Enjoy
    Last edited by Art; - 18th October 2013 at 03:14.

  24. #24
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    I had to write an iPhone simulator App to do the vector rotation on the 3D cube but got it:



    It takes sixteen bytes per frame to store a list of coordinates in lookup tables
    not compressed in any way. The pic still has to look up the points, and draw lines between them.
    This makes a more simple to understand user program.
    Now it's produced, it's very simple. The pic program just looks up sixteen bytes and
    draws lines between those coordinates for every frame. I took out anything fancy.

    If you calculate vector rotation on another platform is it still 3D graphics?

  25. #25
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    3D Point Rotation Demo:




    Who said you only get eight custom characters?

    LCD Freedom - World's First HD44780 POV!


  26. #26
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    127

    Default Re: 2x16 LCD Graphics :)

    Wow, awesome job Art! Quite impressive!
    Shawn

  27. #27
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    Thanks
    It took a 20MHz clock to control the entire display, with all four cubes different,
    but I could make videos forever
    Since the video framerate is not synced to the pic's clock in any way,
    and therefore the LCD backlight strobe frequency, it looks better here than the video comes up.

  28. #28
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    550

    Default Re: 2x16 LCD Graphics :)

    Normally, Noritake will provide you with a dot matrix VFD sample to play with,
    but only if you live in US or Canada:

    http://www.noritake-elec.com/evalkit-sample.php

    That's really quite nice, so ppl should be aware of that.

    Suspecting that POV will work great with VFD, I promised a great demo including
    their logo, in return for them sending me some 2x16 character modules.
    They have replied with a suggestion display which is a HD44780, so it looks good

    I don't think I'm finished with them.
    I think it's possible to do greyscale graphics on a monochrome dot matrix VFD.

Similar Threads

  1. Need advice with LCD 2x16
    By fratello in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th April 2011, 06:58
  2. 2x16 lcd problem
    By k3v1nP in forum mel PIC BASIC
    Replies: 11
    Last Post: - 30th October 2008, 04:46
  3. graphics lcd with lcdout style serial??
    By reaper0995 in forum Serial
    Replies: 4
    Last Post: - 27th March 2008, 19:57
  4. small 2X16 LCD
    By Ron Marcus in forum Off Topic
    Replies: 2
    Last Post: - 26th October 2007, 20:37
  5. OT: KS0108 Graphics LCD control question
    By Archilochus in forum General
    Replies: 2
    Last Post: - 18th December 2004, 18:23

Members who have read this thread : 51

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts