Amélioraition Some Functions in SWODFISH Language :

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:

Amélioraition Some Functions in SWODFISH Language :

Post by sygma22 » Tue May 27, 2008 2:18 pm

Three small routines which I have create while waiting for (impatiently) the full version of “SwordFish” which I have just bought. These routines facilitates the impression of variables or characters /ram graph on screen LCD. Example: /LCD 16 * 4:

--------------------------------------------------------
The PROGRAMM =====================

Include "Convert.bas"
Include "utils.bas"
Include "string.bas"


Const Decal_x_LCD As Byte = 4 ‘Décalage constaté (X = + 4) à partir de la 3ème ligne sur l’écran LCD

Const CGRAM(32) As Byte = (7,15,29,7,3,31,15,7, //

$10,$10,$10,$10,$10,$10,$10,$00, // 8 x

$14,$14,$14,$14,$14,$14,$14,$00, // 8 x

$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff) // 8 x




// display the bar...

Sub Print_Gra( y_y As Byte,x_x As Integer,Num1 As Byte) 'AFFICHER CARACTERE GRAPHIQUE
If x_x = 0 Then
x_x = 1
End If
If y_y = 0 Then
y_y = 1
End If

If y_y > 2 Then
x_x = x_x - Decal_x_LCD
End If
MoveCursor(y_y,x_x)
LCD.Write(Num1)
End Sub

Sub Print_Str( y_y As Byte,x_x As Integer,Carac1 As String) 'AFFICHE STRING
If x_x = 0 Then
x_x = 1
End If
If y_y = 0 Then
y_y = 1
End If

If y_y > 2 Then
x_x = x_x - Decal_x_LCD
End If
MoveCursor(y_y,x_x)
LCD.Write(Carac1)
End Sub

Sub Print_Var( y_y As Byte,x_x As Integer,Var2 As Byte, Long2 As Byte) 'AFFICHE variable : y , x et Var et Format Nbr de caract

Dim Stri2 As String
Dim Long_var2 As Byte
Dim Result2 As String

If x_x = 0 Then
x_x = 1
End If
If y_y = 0 Then
y_y = 1
End If

If y_y > 2 Then
x_x = x_x - Decal_x_LCD 'Sur Certains 4 * 16 Caractère LCD décalage de +X a partir de la troisième Ligne.
End If

Stri2 = DecToStr(Var2)
long_var2 = Length(Stri2)
Result2 = Stri2

If long2 <> 0 Then
If long2 >= long_var2 Then
Result2 = DecToStr(Var2,long2,0) 'format en rajoutant des ZERO
Else
Result2 = Right(Stri2,long2) 'Format en supprimant Longs * caractères de guauche
End If

End If

MoveCursor(y_y,x_x)
LCD.Write(Result2)

End Sub

‘ MAIN ************************************************
Cls
Write(CGRAM)



WHILE TRUE

Print_Gra(1,Index,0) ‘Affiche LE premier élément de la LCD.RAM


Print_Str(1,Index,"essais 1 ")
Print_Var(4,1,20,4) ‘ Affiche 0020, x = 1, y = 4, Longueur = 4

WEND

:roll:
My first interest is working with a PWM signal.

Motor : 24 Volts 4 or 5 A.

Post Reply