Here is working Analogue meter for VU, Power, SWR, Signal or
whatever...



--
-----------------------------------------------------------------------------
--          Create a meter scale with 10 divisions
--             40 to 140 degree scale
--             width is automatically calculated as 2.5 times the
height
--
-----------------------------------------------------------------------------
procedure DrawMeterFace(byte in xOrg, byte in yOrg, byte in height,
bit in ink)is
var  sword faceDots, radius
var sword xCoord, yCoord, xS, yS
    radius = (sword(height)*5) /4
    DrawButton (xOrg,yOrg,radius*2, height, ink)    -- draw frame
    faceDots = -140
    For 101 loop
        PolarToCartesian (radius, faceDots,xCoord,yCoord )
        PlotPixel (byte(sword(xOrg)+radius + xCoord), byte(sword(yOrg)
+ yCoord+radius+2), ink)
        PolarToCartesian (radius/2, faceDots,xCoord,yCoord )
        PlotPixel (byte(sword(xOrg)+radius + xCoord), byte(sword(yOrg)
+ yCoord+radius+2), ink)
        faceDots = faceDots + 1
    end loop
    -- draw hour squares
    faceDots = -140
    For 11 loop
        PolarToCartesian (radius, faceDots,xCoord,yCoord )
        PolarToCartesian (radius-3, faceDots,xS,yS )
        Drawline (byte(sword(xOrg)+radius +xS), byte(sword(yOrg)
+radius +2 +yS),
              byte(sword(xOrg)+radius+xCoord), byte(sword(yOrg)+radius
+2+yCoord), ink)
        faceDots = faceDots + 10
    end loop
End procedure

--
-----------------------------------------------------------------------------
--          Add a needle to the meter scale
--         0 to 101 input value, 100 is full scale
--        draw with ink off and old value, then draw with ink on and
new value
--        invert ink if face was drawn inverted
--
-----------------------------------------------------------------------------
procedure DrawMeterNeedle(byte in xOrg, byte in yOrg, byte in height,
byte in reading, bit in ink) is
var sword radius
var sword xCoord, yCoord, xS, yS
    if reading > 101 then
       reading = 101
    end if
    radius = (sword(height)*5) /4
    PolarToCartesian (radius-4, sword(reading) -140,xCoord,yCoord )
    PolarToCartesian (radius/2 +1, sword(reading) -140,xS,yS )
    Drawline (byte(sword(xOrg)+radius +xS), byte(sword(yOrg)+radius +2
+yS),
              byte(sword(xOrg)+radius+xCoord), byte(sword(yOrg)+radius
+2+yCoord), ink)
End procedure



The meter "panel" uses my Drawbutton routine used for pictures of
keypads or touch GUIs.
-- ToDo: make the middle of button filled with !ink   Change loop
variables to be calculated once
-- Draws a rectangle with a drop shadow.
procedure  DrawButton(byte in px , byte in py , byte in wx , byte in
wy, bit in ink ) is
var byte ind
   wy = wy -1
    For wx using ind loop
        PlotPixel ( ind+px, py, ink)
        PlotPixel ( ind+px, py + wy, ink)
        PlotPixel ( ind+px + 1, py + wy+1, ink)
    end loop
    wx = wx -1
    For wy using ind loop
        PlotPixel ( px, ind+py, ink)
        PlotPixel ( px + wx, ind+py, ink)
        PlotPixel ( px + wx+1, ind +py+1, ink)
    end loop
end procedure

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to