-         
Ergebnis 1 bis 3 von 3

Thema: Grafikfonts von Evert Dekker über Variable?

  1. #1
    Neuer Benutzer Öfters hier
    Registriert seit
    14.05.2008
    Beiträge
    11

    Grafikfonts von Evert Dekker über Variable?

    Anzeige

    Habe mich riesig gefreut als ich den Code von Ever Dekker zum laufen brachte
    Jetzt habe ich größere Grafikfonts für den Controller T6963 für das Display
    240X128.
    In den Zeilen : Lcdtext "....." werden nur die Texte in "." angezeigt.
    Wenn ich dort eine Variable eingebe egal welche Art kommt eine Fehlermeldung.
    Ist es in diesem Code überhaupt möglich eine Variable auszugeben?
    Als Anfänger bin ich ratlos!
    Habe den Code etwas gekürzt.
    Code:
    '------------------------------------------------------------------
    '                           GRAPHIC FONT
    '     Use the Bascom font file's for all the graphic display's,
    '              include inverted and/or rotated text.
    '        By Evert Dekker 2007 GraphicFont@Evertdekker dotje com
    '                   Created with Bascom-Avr: 1.11.8.8
    '------------------------------------------------------------------
    
    $regfile = "m32def.DAT"
    $crystal = 1000000
    $baud = 4800 
    $loadersize = 512
    $hwstack = 100
    $swstack = 120
    $ramesize = 100
    
    
    
    
    Config Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portd , Ce = 5 , Cd = 2 , Wr = 4 , Rd = 3 , Reset = 6 , Fs = 7 , Mode = 6
    
    Dim Z As String * 10
    
    Cls
    
    Cursor Off
    
    
    Declare Sub Lcdtext(byval S As String , Byval Xoffset As Byte , Byval Yoffset As Byte , Byval Fontset As Byte , Byval Inverse As Byte , Byval Rotation As Byte)
    'SYNTAX  Lcdtest String , Xoffset , Yoffset , Fontset , Inverse , Rotation
    '
    '* Xoffset and Yoffset is in pixels, so you can place text on every spot on the display
    '* You determin yourself in the subroutine witch font belongs to the fontset
    
    '=== Your main prog here ====
    Do
    
    Z = 1234
    
    
    'Lcdtext "5X5 Font" , 20 , 2 , 4 , 0 , 0
    'Lcdtext "6X8 Font" , 20 , 20 , 3 , 0 , 0
    'Lcdtext "8X8 Font" , 20 , 40 , 1 , 0 , 0
    Lcdtext "16X16 FONT" , 18 , 64 , 2 , 0 , 0
    
    Lcdtext Z , 18 , 20 , 2 , 0 , 0
    
    'Lcdtext "If you can't read this then incr. Swstack" , 20 , 120 , 4 , 0 , 0
    Wait 3
    Cls
    
    Loop
    End
    
    
    
    '=== Sub Routines ===
    Sub Lcdtext(byval S As String , Xoffset As Byte , Yoffset As Byte , Fontset As Byte , Inverse As Byte , Rotation As Byte)
    Local Tempstring As String * 1 , Temp As Byte               'Dim local the variables
    Local A As Byte , Pixels As Byte , Count As Byte , Carcount As Byte , Lus As Byte
    Local Row As Byte , Byteseach As Byte , Blocksize As Byte , Dummy As Byte
    Local Colums As Byte , Columcount As Byte , Rowcount As Byte , Stringsize As Byte
    Local Xpos As Byte , Ypos As Byte , Pixel As Byte , Pixelcount As Byte
    If Inverse > 1 Then Inverse = 0                             'Inverse can't be greater then 1
    If Rotation > 3 Then Rotation = 0                           'There are only 4 rotation's
    Stringsize = Len(s) - 1                                     'Size of the text string -1 because we must start with 0
    For Carcount = 0 To Stringsize                              'Loop for the numbers of caracters that must be displayed
    
     'If Fontset = 1 Then Restore Font8x8                        'Add or remove here fontset's that you need or not,
     If Fontset = 2 Then Restore Font16x16                      'this is the name that you gave to the font, NOT the filename
     'If Fontset = 3 Then Restore Font6x8                        'If you dont know the name, open the font file in wordpad, and there it is,
     'If Fontset = 4 Then Restore Font5x5
                                                                 'right on top.
    
     Temp = Carcount + 1                                        'Cut the text string in seperate caracters
    Tempstring = Mid(s , Temp , 1)
    Read Row : Read Byteseach : Read Blocksize : Read Dummy     'Read the first 4 bytes from the font file
    Temp = Asc(tempstring) - 32                                 'Font files start with caracter 32
    For Lus = 1 To Temp                                         'Do dummie read to point to the correct line in the fontfile
       For Count = 1 To Blocksize
        Read Pixels
       Next Count
    Next Lus
    Colums = Blocksize / Row                                    'Calculate the numbers of colums
    Row = Row * 8                                               'Row is always 8 pixels high = 1 byte, so working with row in steps of 8.
    Row = Row - 1                                               'Want to start with row=0 instead of 1
    Colums = Colums - 1                                         'Same for the colums
    Select Case Rotation
        Case 0                                                  '0 degrees rotation
                For Rowcount = 0 To Row Step 8                  'Loop for numbers of rows
                      A = Rowcount + Yoffset
                      For Columcount = 0 To Colums              'Loop for numbers of Colums
                          Read Pixels : If Inverse = 1 Then Toggle Pixels       'Read the byte from the file and if inverse = true then invert de byte
                          Xpos = Columcount                     'Do some calculation to get the caracter on the correct Xposition
                          Temp = Carcount * Byteseach
                          Xpos = Xpos + Temp
                          Xpos = Xpos + Xoffset
                              For Pixelcount = 0 To 7           'Loop for 8 pixels to be set or not
                                 Ypos = A + Pixelcount          'Each pixel on his own spot
                                 Pixel = Pixels.0               'Set the pixel (or not)
                                 Pset Xpos , Ypos , Pixel       'Finaly we can set the pixel
                                 Shift Pixels , Right           'Shift the byte 1 bit to the right so the next pixel comes availible
                              Next Pixel
                      Next Columcount
                Next Rowcount
    End Select
    Next Carcount
    End Sub                                                     'End of this amazing subroutine
    
    
    '=== Includes ===
    '$include "Font8x8.font"                                     'Includes here your font files
    $include "Font16x16.font"                                   'If you don't need the files in your program, don't include them,
    '$include "Font6x8.font"                                     'these are flash memory eaters.
    '$include "Font5x5.font"

  2. #2
    Erfahrener Benutzer Robotik Einstein
    Registriert seit
    22.05.2005
    Ort
    12°29´ O, 48°38´ N
    Beiträge
    2.731
    Hallo,

    Was kommt den für ein Fehler ?

    Versuch mal Anführungszeichen drumrum zu machen:
    Z = "1234"
    denn das ist ein String und kein Integer o.ä.

  3. #3
    Neuer Benutzer Öfters hier
    Registriert seit
    14.05.2008
    Beiträge
    11
    Oh welch ein Wunder. Eine Stringvariable braucht tatsächlich " ".
    Besten Dank für die Hilfe
    Gruß Willi

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •