RE: Graphics Dial Improvements
schwiegjc
Posts: 41
I recently took the Coil_Demo Code that displays a graphics dial on the TV. I used the TV Code to display the output of a rate sensor (ASCII Data Stream). It worked good. The problem is that the dial graphics are late seventy quality. Is there any propellar code that has a higher quality graphics dial that·I could use?·
Comments
The returned variables ranges are:
roll is 0 to 450
pitch is 0 to 450
rolldir is 0(clockwise) or 1(counterclockwize)
pitchdir is 0(clockwise) or 1(counterclockwize)
heading is 0 to 360
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
_stack = ($3000 + $3000 + 100) >> 2 'accomodate display memory and stack
x_tiles = 16
y_tiles = 12
paramcount = 14
bitmap_base = $2000
display_base = $5000
lines = 5
thickness = 2
COMPASS_RX = 2
VAR
long tv_status '0/1/2 = off/visible/invisible read-only
long tv_enable '0/? = off/on write-only
long tv_pins '%ppmmm = pins write-only
long tv_mode '%ccinp = chroma,interlace,ntsc/pal,swap write-only
long tv_screen 'pointer to screen (words) write-only
long tv_colors 'pointer to colors (longs) write-only
long tv_hc 'horizontal cells write-only
long tv_vc 'vertical cells write-only
long tv_hx 'horizontal cell expansion write-only
long tv_vx 'vertical cell expansion write-only
long tv_ho 'horizontal offset write-only
long tv_vo 'vertical offset write-only
long tv_broadcast 'broadcast frequency (Hz) write-only
long tv_auralcog 'aural fm cog write-only
long colors[noparse][[/noparse]64]
word screen[noparse][[/noparse]x_tiles * y_tiles]
byte x[noparse][[/noparse]lines]
byte y[noparse][[/noparse]lines]
byte xs[noparse][[/noparse]lines]
byte ys[noparse][[/noparse]lines]
Byte DataIn[noparse][[/noparse]50]
long IntegerTemp
long roll
long pitch
long heading
byte rolldir
byte pitchdir,k,i
OBJ
tv : "tv"
gr : "graphics"
sensor : "Maretron_Object_3"
PUB start | j,dx,dy
'start tv
longmove(@tv_status, @tvparams, paramcount)
tv_screen := @screen
tv_colors := @colors
tv.start(@tv_status)
sensor.BS2_Start (30,31)
dira[noparse][[/noparse]31]~
'init colors
repeat i from 0 to 64
colors := $00001010 * (i+4) & $F + $2B060C02
'init tile screen
repeat dx from 0 to tv_hc - 1
repeat dy from 0 to tv_vc - 1
screen[noparse][[/noparse]dy * tv_hc + dx] := display_base >> 6 + dy + dx * tv_vc + ((dy & $3F) << 10)
'start and setup graphics
gr.start
gr.setup(16, 12, 128, 96, bitmap_base)
dira[noparse][[/noparse]16..23]~~
sensor.BEATStart(23) 'Blink LEDs
repeat
'clear bitmap
gr.clear
gr.text(52,15,string("ROLL"))
gr.text(-55,15,string("PITCH"))
gr.text(-125,22,string("0"))
gr.text(115,22,string("45"))
gr.text(40,-100,string("HEADING"))
'draw mouse pointer
gr.width(0)
sensor.Serin_Wait(COMPASS_RX,@DataIn,"T",4800,1,8)
sensor.EXTRACT_ROLL_PITCH_INFO(@roll,@rolldir,@pitch,@pitchdir)
sensor.IntString(roll,roll,rolldir,pitch,pitchdir,@DataIn)
gr.text(45,80,@DataIn)
sensor.IntString(pitch,roll,rolldir,pitch,pitchdir,@DataIn)
gr.text(-75,80,@DataIn)
'display analog meter
gr.color(2)
gr.width(0)
gr.arc(60, 30, 50, 50, 0, 409, 11, 3)
gr.arc(60, 30, 45, 45, 204, 409, 10, 3)
gr.color(0)
gr.width(2)
gr.arc(60, 30, 42, 42, 0, 204, 21, 3)
gr.color(1)
gr.width(0)
roll := roll/10
if roll>45
roll := 45
if rolldir==1
gr.arc(60, 30, 40, 40, 4096-(((45+roll)*4096)/90) ,1, 1, 3)
gr.arc(60, 30, 40, 40, 4096-(((roll)*4096)/90) ,1, 1, 3)
gr.arc(60, 30, 40, 40, 4096-(((90+roll)*4096)/90) ,1, 1, 3)
else
gr.arc(60, 30, 40, 40, 4096-(((45-roll)*4096)/90) ,1, 1, 3)
gr.arc(60, 30, 40, 40, 4096-(((360-roll)*4096)/90) ,1, 1, 3)
gr.arc(60, 30, 40, 40, 4096-(((90-roll)*4096)/90) ,1, 1, 3)
'display analog meter
gr.color(2)
gr.width(0)
gr.arc(-60, 30, 50, 50, 0, 409, 11, 3)
gr.arc(-60, 30, 45, 45, 204, 409, 10, 3)
gr.color(0)
gr.width(2)
gr.arc(-60, 30, 42, 42, 0, 204, 21, 3)
gr.color(1)
gr.width(0)
pitch := pitch/10
if pitch>45
pitch := 45
if pitchdir==1
gr.arc(-60, 30, 40, 40, 4096-(((pitch)*4096)/180) ,1, 1, 3)
gr.arc(-60, 30, 40, 40, 4096-(((270+pitch)*4096)/180) ,1, 1, 3)
gr.arc(-60, 30, 40, 40, 4096-(((90+pitch)*4096)/180) ,1, 1, 3)
else
gr.arc(-60, 30, 40, 40, 4096-(((360-pitch)*4096)/180) ,1, 1, 3)
gr.arc(-60, 30, 40, 40, 4096-(((270-pitch)*4096)/180) ,1, 1, 3)
gr.arc(-60, 30, 40, 40, 4096-(((90-pitch)*4096)/180) ,1, 1, 3)
'arc(x, y, xr, yr, angle, anglestep, steps, arcmode)
sensor.Serin_Wait(COMPASS_RX,@DataIn,"H",4800,1,8)
sensor.EXTRACT_HEADING_INFO(@heading)
sensor.IntString(heading,roll,rolldir,pitch,pitchdir,@DataIn)
gr.text(-12,0,@DataIn)
gr.color(2)
gr.width(0)
gr.arc(0, -50, 50, 50, 0, 409, 40, 3)
gr.arc(0, -50, 45, 45, 204, 409, 40, 3)
gr.color(0)
gr.width(2)
gr.arc(0, -50, 42, 42, 0, 204, 40, 3)
gr.arc(0, -50, 42, 42, 0, 204, 40, 3)
gr.color(1)
gr.width(0)
gr.arc(0, -50, 40, 40, (4096-(((heading/10)+90)*4096)/180) ,1, 1, 3)
gr.arc(0, -50, 40, 40, (4096-(((heading/10))*4096)/180) ,1, 1, 3)
gr.arc(0, -50, 40, 40, (4096-(((heading/10)+180)*4096)/180) ,1, 1, 3)
'copy bitmap to display
gr.copy(display_base)
!outa[noparse][[/noparse]19]
DAT
tvparams long 0 'status
long 1 'enable
'long %011_0000 'pins Old Board
long %001_0101 'pins New Board
long %0000 'mode
long 0 'screen
long 0 'colors
long x_tiles 'hc
long y_tiles 'vc
long 10 'hx
long 1 'vx
long 0 'ho
long 0 'vo
long 60_000_000'_xinfreq<<4 'broadcast
long 0 'auralcog
{{