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