Aspect Ratio

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Mast
Posts: 65
Joined: Wed Aug 29, 2007 6:24 am
Location: France

Aspect Ratio

Post by Mast » Sun Feb 01, 2009 10:16 pm

if you can test this code on an EasyPic4 you can see the problem with aspect ratio between Circle and the line. Have you a solution fot the line is inside the circle at Nord and Sud position. Thank you

Code: Select all


// if device and clock are omitted, then the compiler defaults to 
// 18F452 @ 20MHz - they are just used here for clarity...
Device = 18F452
Clock = 20

// #option GLCD_CS_COUNT = 3
// #option GLCD_SCREEN_WIDTH = 192
// #option GLCD_ASPECT_RATIO = 100

#option GLCD_SCREEN_WIDTH = 128  // Screen Width in Pixels
#option GLCD_SCREEN_HEIGHT = 64  // Screen Height in Pixels

#option GLCD_CS_COUNT = 2    // Count of CS Lines. Must be 2 or 3


// default module options - user options can override these values...
#option GLCD_DATA = PORTD        // data port
#option GLCD_RS = PORTB.2        // RS pin
#option GLCD_EN = PORTB.4        // EN pin
#option GLCD_RW = PORTB.3        // RW pin
#option GLCD_CS1 = PORTB.1       // chip select
#option GLCD_CS2 = PORTB.0       // chip select
#option GLCD_ASPECT_RATIO = 75   // aspect ratio, smaller number will squeeze y for GLCD circles and box
#option GLCD_INIT_DELAY = 100    // initialisation delay (ms)
#option GLCD_INVERT_CS = true   // invert CS lines... 
#option GLCD_RST = PORTB.5


Include "GLCD.bas"
Include "images2.bas"
Include "FixedFont.bas"
Include "ADC.bas"
Include "convert.bas"
Include "math"
////////////////////////////
Dim  ADVal, result As Word
Dim angle, X, Y, V0, V100, VR As Float 
Dim text, X_text, Y_text, angle_t As String
////////////////////////////
V0 = 0
V100 = 100
////////////////////////////


    GLCD.Cls 
  GLCD.Circle (30,30,30)
  
       Repeat 
       
pen.color = 0
  GLCD.Line (30,30,X,Y)
pen.color = 1
 GLCD.Circle (30,30,30)
          
angle = 360-((270/V100) * VR)  

X=30 + (30 * sin(angle * 0.0174533))
Y=30 + (30 * cos(angle * 0.0174533))
pen.color = 1
  GLCD.Line (30,30,X,Y)
           
            DelayMS(300)           
            VR = VR + 1
            text = FloatToStr(VR)
           
            X_text = FloatToStr(X,5)
            Y_text = FloatToStr(Y,5)
         
            angle_t = FloatToStr(angle,5)
            
GLCD.SetFont(Fixed)            
GLCD.WriteAt (70,15, text)
GLCD.WriteAt (70,25, X_text)
GLCD.WriteAt (70,35, Y_text)
GLCD.WriteAt (70,45, angle_t)


    Until VR = 100  
   

rmteo
Posts: 237
Joined: Fri Feb 29, 2008 7:02 pm
Location: Colorado, USA

Post by rmteo » Mon Feb 02, 2009 12:31 am

If you are using the GLCD that comes with the EasyPIC4, then you need to adjust this line to get a true circle (instead of an ellipse) because this display's pixels are rectangular instead of square:

Code: Select all

#option GLCD_ASPECT_RATIO = 100 

Mast
Posts: 65
Joined: Wed Aug 29, 2007 6:24 am
Location: France

Post by Mast » Mon Feb 02, 2009 7:38 am

i can't see how adjust the line with the cos and sin fonction

rmteo
Posts: 237
Joined: Fri Feb 29, 2008 7:02 pm
Location: Colorado, USA

Post by rmteo » Mon Feb 02, 2009 3:28 pm

You should not have to adjust the sin and cos function. Try including a different value for GLCD_ASPECT_RATIO and see if it solves your problem.

Post Reply