BARGRAPH improvement.Now Easy To use every Where.........

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
sygma22
Posts: 30
Joined: Tue May 27, 2008 1:47 pm
Location: FRANCE
Contact:

BARGRAPH improvement.Now Easy To use every Where.........

Post by sygma22 » Mon Jul 07, 2008 4:10 pm

My improvement of the help example of " Swordfish".
A procedure " Baragraph" Parameterized and now easy to use:

Parameters:

1) Y (ordered).
2) X (X-coordinate).
3) Resolution = Many columns.
4) Value max for Complete Bargraph.
5) Value Sent.

Merry programming .....
-------------> The declaration and Two Mains :

Const CGRAM(32) As Byte = ($00,$00,$00,$00,$00,$00,$00,$00, // base bar
$10,$10,$10,$10,$10,$10,$10,$00, // 8 x %10000 = |
$14,$14,$14,$14,$14,$14,$14,$00, // 8 x %10100 = ||
$15,$15,$15,$15,$15,$15,$15,$00) // 8 x %10101 = ||

NoInline Sub Rep(pValue, pRepValue As Byte)

Dim Index As Byte
Index = 0

While Index < pRepValue
LCD.Write(pValue)
Inc(Index)
Wend

End Sub


// display the bar...

NoInline Sub Bargraph(pLine,xLine,Max_Col_BarGraph As Byte,Max_Val_BarGraph As Word ,Bar_Value As Word)

Dim Div_Reste_Vl as word
Dim pBarValue As word
Dim BAR_WIDTH As Byte
Dim MAX_BAR_COUNT As Word

Const BASE_BAR = 0
Const FULL_BAR = 3

Dim NumberOfBars As Byte
Dim Balance As Byte
Dim BalanceChar As Byte

BAR_WIDTH = Max_Col_BarGraph
MAX_BAR_COUNT = BAR_WIDTH * FULL_BAR

pBarValue = (float(Bar_Value) / float(Max_Val_BarGraph)) * MAX_BAR_COUNT

NumberOfBars = pBarValue / FULL_BAR
Balance = pBarValue Mod FULL_BAR

MoveCursor(pLine,xLine)
Rep(FULL_BAR,NumberOfBars)
Write(Balance)
Rep(BASE_BAR,BAR_WIDTH - (NumberOfBars + Min(Balance,1)))

End Sub
My first interest is working with a PWM signal.

Motor : 24 Volts 4 or 5 A.

sygma22
Posts: 30
Joined: Tue May 27, 2008 1:47 pm
Location: FRANCE
Contact:

Forget the Invert Function !

Post by sygma22 » Fri Jul 11, 2008 1:55 pm

HEllo !

To get a DESC Bargraph Function, you just have to add at the last Parameter : MaxValue - Value sent.

For Example : Bargraph(2,1,19,Max_List,Max_List-Its) :shock: :shock:
My first interest is working with a PWM signal.

Motor : 24 Volts 4 or 5 A.

Post Reply