/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Horizontal/vertical line subroutines for the LCD

Username:     
Password:     
             

Forum
  • Index
  •  » circleOS
  •  » Horizontal/vertical line subroutines for the LCD

# 1   2007-10-26 01:35:05 Horizontal/vertical line subroutines for the LCD

dalewheat
Member
From: Dallas TX USA
Registered: 2007-10-10
Posts: 43
Website

Horizontal/vertical line subroutines for the LCD

I wrote some simple horizontal and vertical line subroutines for CircleOS.  Perhaps they could be incorporated into a later release.  The complete source code is available from my web site:

http://dalewheat.com/Str8Line.c

Create a new CircleOS application program using RIDE7, remove the generated file 'Application.c' and then add Str8Line.c.  It compiles as a standard CircleOS application and can be executed from the main menu.  All it does is a short demo drawing horizontal then vertical lines and then waits for you to press the button to return to the menu.

This isn't really a complete 'project' so I'm not posting it as such.

There are two subroutines:

DRAW_HLine ( u8 x0, u8 y, u8 x1, u16 color )
DRAW_VLine (u8 x, u8 y0, u8 y1, u16 color )

To draw a horizontal line with endpoints (x0,y0) and (x1,y1) call DRAW_HLine like so:

DRAW_HLine ( x0, y0, x1, RGB_BLACK );

Remember that on a horizontal line, y0=y1. 'RGB_BLACK' could be any color you want.

The same thing for DRAW_VLine, except that x0=x1.

I will eventually code up the Bresenham line routines for lines of arbitrary angle.  These routines will still come in handy for the horizontal and vertical cases as they are a lot faster from an I/O standpoint.

If you have any questions, please let me know.

Enjoy!

Dale Wheat

Offline

 

# 2   2007-10-26 22:46:28 Horizontal/vertical line subroutines for the LCD

dalewheat
Member
From: Dallas TX USA
Registered: 2007-10-10
Posts: 43
Website

Re: Horizontal/vertical line subroutines for the LCD

I added two more graphics functions:  DRAW_Pixel() and DRAW_Rectangle().

Can you guess what they do?  smile

The location of the file remains the same:  http://dalewheat.com/Str8Line.c

The only detail that you might overlook is that DRAW_Rectangle() draws a *filled* rectangle instead of just an outline.

DRAW_Rectangle() also has some smarts so that if you give it any 'special case' rectangles, such as a single point or a single-pixel-wide line, it just calls DRAW_Pixel or the appropriate line function.

As before, it doesn't matter what order you specify any of the endpoints.

Questions?  Comments?  Let me know!

Enjoy!

Dale Wheat

Offline

 

# 3   2007-10-27 23:24:50 Horizontal/vertical line subroutines for the LCD

dalewheat
Member
From: Dallas TX USA
Registered: 2007-10-10
Posts: 43
Website

Re: Horizontal/vertical line subroutines for the LCD

Again with the updates:

I needed a separate filled and unfilled rectangle drawing routine for my current project and so I added a DRAW_RectangleFilled() function that works the same way as before.  The original DRAW_Rectangle() routine now simply draws a single-pixel border around a rectangular area without filling it in.

I've also added DRAW_DisplayStringCenter() that takes a Y coordinate and a pointer to a string.  It helps take the guesswork out of centering text on the LCD, and takes the character magnification factor into account.

Available from the same exact location as always:

http://dalewheat.com/Str8Line.c


Enjoy!

Thanks,

Dale Wheat

Offline

 

# 4   2007-10-28 14:19:02 Horizontal/vertical line subroutines for the LCD

dalewheat
Member
From: Dallas TX USA
Registered: 2007-10-10
Posts: 43
Website

Re: Horizontal/vertical line subroutines for the LCD

Guess what I found in the "lcd.c" file?  That's right!  Pretty much everything I was needing with the exception of the line functions.  I'll move on to the Bresenham lines & circles now...

Offline

 

# 5   2007-10-29 08:08:59 Horizontal/vertical line subroutines for the LCD

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: Horizontal/vertical line subroutines for the LCD

The  Bresenham lines exist in the tutorial (Cubic). But the circles are missing.

Offline

 

  • Index
  •  » circleOS
  •  » Horizontal/vertical line subroutines for the LCD

Board footer