สอบถามขอ libraries font 16x8 (Row X Col) ภาษาไทย

Started by dreamzery, February 11, 2013, 03:05:35 PM

Previous topic - Next topic

dreamzery

สอบถามขอ libraries font 16x8 (Row X Col) ภาษาไทย

ที่ใช้กับโมดูล LCD GRAPHIC ขนาด 128 x 64 ของ ETT

พอดีผมต้องการทดลองขนาดตักอักษรกับรูปแบบฟอร์ต

ถ้าใครมีจะเป็นพระคุณมากครับ ขอบคุรครับ......

JMew

อันนี้เหรอ

http://www.youtube.com/watch?v=n5LkGSw4Bas

มีแต่ภาษาเบสิคอ่ะ แต่ชดเชยสระให้แล้ว หมุนจอได้ด้วย ส่องกลับในกระจกได้ด้วย มีแบบ 240*128 ด้วยนะ
Code ของเราเป็น scan along Y

โหลดที่นี่ http://cmu.mine.nu/teach/thaised/





$regfile = "m64def.dat"
                                      ' specify the used micro
$crystal = 16000000                                         ' used crystal frequency
                                             ' use baud rate
                                            ' default use 40 for the frame space
'some routines to control the display are in the glcdKS108.lib file
$lib "glcdKS108.lib"                                        'Include the library for the KS-108 controler
'$lib "glcdKS108.lib"
'$lib "glcdKS108.lbx"
'$lib "glcd.lib"

'First we define that we use a graphic LCD
Config Graphlcd = 128 * 64sed , Dataport = Portc , Controlport = Porta , Ce = 4 , Ce2 = 3 , Cd = 0 , Rd = 1 , Reset = 5 , Enable = 2
'Config Graphlcd = 240 * 128 , Dataport = Portb , Controlport = Portd , Ce = 0 , Cd = 1 , Wr = 2 , Rd = 3 , Reset = 4 , Fs = 5 , Mode = 6
'=== Subprocedure declarations
'SYNTAX  Lcdtest String , Xoffset , Yoffset , Inverse , Rotation
Declare Sub Lcd_text(byval S As String , Byval Xoffset As Byte , Byval Yoffset As Byte , Byval Inverse As Byte , Byval Rotation As Byte)
'* Xoffset and Yoffset is in pixels, so you can place text on every spot on the display

'SYNTAX  Set_font FontSet
Declare Sub Set_font(byval Fontset As Byte)
'* You determine yourself in the subroutine witch font belongs to the fontset

'=== Alias declarations

Th_font Alias 1

Inverted Alias 1
No_inverted Alias 0

Rotate_0 Alias 0
Rotate_90 Alias 1
Rotate_180 Alias 2
Rotate_270 Alias 3

'=== Variables declarations
Dim Row As Byte , Colums As Byte , Byte_search As Byte , Blocksize As Byte
Dim Font_adress As Word

'-----
'Cursor Off
Cls

   Set_font Th_font

'=== Your main prog here ====
Do



    Cls

   Lcd_text "áÁ¹·ÃǧâÈ¡" , 24 , 8 , 0 , 0
   Lcd_text "¾¹ÒÊÑè§" , 40 , 24 , 0 , 0
   Lcd_text "ËÅÑè§ÃÔ¹½¹" , 32 , 40 , 0 , 0




   Wait 5

   Cls

   Lcd_text "ÃÊÊؤ¹¸ì" , 40 , 8 , 0 , 0
   Lcd_text "»Ô蹨ѡÃÕ" , 40 , 24 , 0 , 0
   Lcd_text "ªÕ¾µÑ¡ÉÑÂ" , 40 , 40 , 0 , 0

  Wait 5

    Cls

   Lcd_text "¾ÃÐྪÃÃѵ¹ì" , 24 , 8 , 0 , 0
   Lcd_text "ÁÔè§ÁËÔ¹·Ãì" , 32 , 24 , 0 , 0
   Lcd_text "á¼è¹´Ô¹ä·Â" , 32 , 40 , 0 , 0

    Wait 5

    Cls

   Lcd_text "ÁÒ¨Ò¡ä»" , 32 , 8 , 0 , 0
   Lcd_text "ÅÒÅѺ" , 40 , 24 , 0 , 0
   Lcd_text "äÁè¡ÅѺ¤×¹" , 32 , 40 , 0 , 0

    Wait 5

    Cls

   Lcd_text "¢Í¾ÃÐͧ¤ì" , 32 , 8 , 0 , 0
   Lcd_text "àÊ´ç¨ÅÔèÇ" , 40 , 24 , 0 , 0
   Lcd_text "¤ÒÅÑÂÊÇÃäì" , 24 , 40 , 0 , 0

    Wait 5

    Cls

   Lcd_text "ʶԵÂìÍѹ" , 40 , 8 , 0 , 0
   Lcd_text "ÀÙÁÔÀѤ" , 48 , 24 , 0 , 0
   Lcd_text "ÃÑ¡ÉÒ¼×¹" , 40 , 40 , 0 , 0

      Wait 5

    Cls

   Lcd_text "¢Í¾ÃÐà¡ÕÂõÔ" , 24 , 8 , 0 , 0
   Lcd_text "¸ ´Óç" , 40 , 24 , 0 , 0
   Lcd_text "¤§ÂÑè§Â×¹" , 40 , 40 , 0 , 0

       Wait 5

    Cls

   Lcd_text "»¡á¼è¹¾×é¹" , 32 , 8 , 0 , 0
   Lcd_text "ÊØÇÃóÀ¾" , 32 , 24 , 0 , 0
   Lcd_text "ºÃ躨Թµì" , 32 , 40 , 0 , 0

    Wait 5


'   Set_font Font5x5_font
'   Lcdtext "0 deg.Rotation" , 10 , 10 , No_inverted , Rotate_0
'   Lcdtext "90 deg.Rotation" , 170 , 1 , No_inverted , Rotate_90
'   Lcdtext "180 deg.Rotation" , 120 , 20 , No_inverted , Rotate_180
'   Lcdtext "270 deg.Rotation" , 200 , 120 , No_inverted , Rotate_270
'   Lcdtext "Also inverted " , 150 , 80 , Inverted , Rotate_180
'   Set_font Font12_16_font
'   Lcdtext "Every font" , 150 , 100 , No_inverted , Rotate_180
'   Wait 5
'   Cls
Loop
End

'=== Sub Routines ===
Sub Set_font(byval Fontset As Byte)
Local Dummy_word As Word
   'Add or remove here fontset's that you need or not,
   'This is the name that you gave to the font, NOT the filename
   'If you dont know the name, open the font file in wordpad, and there it is,
   'right on top.
   Select Case Fontset                                      ' You may use case 1, case 2 etc insted of alias names
      Case Th_font : Font_adress = Loadlabel(th)
   End Select
   ' --- Load font info needed for Lcdtext subroutine calculations ---
   Dummy_word = Font_adress : Row = Cpeek(dummy_word)
   Incr Dummy_word : Byte_search = Cpeek(dummy_word)
   Incr Dummy_word : Blocksize = Cpeek(dummy_word)
   ' -----
   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
   Font_adress = Font_adress + 4                            'Skip first 4 bytes in fontfile
End Sub

Sub Lcd_text(byval S As String , Xoffset As Byte , Yoffset 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 , Pixels_adress As Word , Charcount As Byte
   Local Columcount As Byte , Rowcount As Byte , Stringsize As Byte
   Local Xxpos As Byte , Yypos As Byte , Pixel As Byte , Pixelcounts As Byte
   Local Dummy_word As Word
   Local Th_vowel As Byte , Pre_accent 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
     Th_vowel = 0
   For Charcount = 0 To Stringsize                          'Loop for the numbers of caracters that must be displayed
      Temp = Charcount + 1                                  'Cut the text string in seperate caracters
      Tempstring = Mid(s , Temp , 1)
      Temp = Asc(tempstring) - 32                           'Font files start with caracter 32
      Dummy_word = Blocksize * Temp
      Pixels_adress = Font_adress + Dummy_word              'Do dummie read to point to the correct line in the fontfile
      Temp = Charcount * Byte_search                        'Do first part of calculation to get the character on the correct X or Y position
      Select Case Rotation
          Case 0

           Select Case Asc(tempstring)

                        Case &HE7 To &HEE : Temp = Temp + Xoffset
                          Th_vowel = Th_vowel + 8
                           Temp = Temp - Th_vowel

                        Case &HD1 : Temp = Temp + Xoffset
                           Th_vowel = Th_vowel + 8
                            Temp = Temp - Th_vowel
                             Pre_accent = 1
                         Case &HD4 To &HD7 : Temp = Temp + Xoffset
                            Th_vowel = Th_vowel + 8
                             Temp = Temp - Th_vowel
                              Pre_accent = 1
                         Case &HDB To &HDE : Temp = Temp + Xoffset
                             Th_vowel = Th_vowel + 8
                              Temp = Temp - Th_vowel

                         Case &HD8 To &HDA : Temp = Temp + Xoffset
                               Th_vowel = Th_vowel + 8
                                Temp = Temp - Th_vowel

                        Case Else : Temp = Temp + Xoffset
                                Temp = Temp - Th_vowel
                                  Pre_accent = 0

                        End Select

                                                  '0 degrees rotation

                  For Rowcount = 0 To Row Step 8            'Loop for numbers of Row

                        Select Case Asc(tempstring)

                        Case &HE7 To &HEE : A = Rowcount + Yoffset

                         If Pre_accent = 1 Then
                         A = A - 8
                         Else
                         A = A - 5
                         End If

                               Pre_accent = 0

                        Case &HD1 : A = Rowcount + Yoffset
                         A = A - 8


                         Case &HD4 To &HD7 : A = Rowcount + Yoffset
                        A = A - 8

                         Case &HDB To &HDE : A = Rowcount + Yoffset
                        A = A - 8

                         Case &HD8 To &HDA : A = Rowcount + Yoffset
                        A = A + 8

                        Case Else : A = Rowcount + Yoffset


                        End Select

                        For Columcount = 0 To Colums        'Loop for numbers of Colums
                            Pixels = Cpeek(pixels_adress)
                            Incr Pixels_adress
                            If Inverse = 1 Then Toggle Pixels       'Read the byte from the file and if inverse = true then invert de byte
                            Xxpos = Columcount
                            Xxpos = Xxpos + Temp            'Do rest of calculation to get the character on the correct X position
                            For Pixelcounts = 0 To 7        'Loop for 8 pixels to be set or not
                              Yypos = A + Pixelcounts




                                       'Each pixel on his own spot
                              Pixel = Pixels.pixelcounts    'Set the pixel (or not)
                            If Pixel = 1 Then Pset Xxpos , Yypos , Pixel       'Finaly we can set the pixel
                            Next Pixel
                        Next Columcount
                  Next Rowcount
          Case 1                                            '90 degrees rotation
                  For Rowcount = Row To 0 Step -8           'Loop is now counting down
                        A = Rowcount + Xoffset
                        A = A - 15                          'Correction to set XXPos on Xoffset with rotation
                        For Columcount = 0 To Colums
                            Pixels = Cpeek(pixels_adress)
                            Incr Pixels_adress
                            If Inverse = 1 Then Toggle Pixels
                            Xxpos = Columcount
                            Xxpos = Xxpos + Yoffset
                            Xxpos = Xxpos + Temp            'We want that Xoffset is still Xoffset, so we need here the change from x to y
                            For Pixelcounts = 7 To 0 Step -1
                             Yypos = A + Pixelcounts
                              Pixel = Pixels.0
                              Pset Yypos , Xxpos , Pixel
                              Shift Pixels , Right
                            Next Pixel
                        Next Columcount
                  Next Rowcount
          Case 2                                            '180 degrees rotation
                  For Rowcount = Row To 0 Step -8
                        A = Rowcount + Yoffset
                        A = A - 7                           'Correction to set XXPos on Xoffset with rotation
                        For Columcount = Colums To 0 Step -1
                            Pixels = Cpeek(pixels_adress)
                            Incr Pixels_adress
                            If Inverse = 1 Then Toggle Pixels
                            Xxpos = Columcount
                            Xxpos = Xxpos - Temp
                            Xxpos = Xxpos - 8               'Correction to set XXPos on Xoffset with rotation
                            Xxpos = Xxpos + Xoffset
                            For Pixelcounts = 7 To 0 Step -1
                                Yypos = A + Pixelcounts
                                Pixel = Pixels.0
                                Pset Xxpos , Yypos , Pixel
                                Shift Pixels , Right
                            Next Pixel
                        Next Columcount
                  Next Rowcount
          Case 3                                            '270 degrees rotation
                  For Rowcount = 0 To Row Step 8
                        A = Rowcount + Xoffset
                          For Columcount = Colums To 0 Step -1
                            Pixels = Cpeek(pixels_adress)
                            Incr Pixels_adress
                            If Inverse = 1 Then Toggle Pixels
                            Xxpos = Columcount
                            Xxpos = Xxpos - Temp
                            Xxpos = Xxpos - 8               'Correction to set XXPos on Xoffset with rotation
                            Xxpos = Xxpos + Yoffset
                            For Pixelcounts = 0 To 7
                                Yypos = A + Pixelcounts
                                Pixel = Pixels.pixelcounts
                                Pset Yypos , Xxpos , Pixel
                            Next Pixel
                        Next Columcount
                  Next Rowcount
      End Select
   Next Charcount
End Sub
'End of this amazing subroutine

'=== Includes ===                                 ' Not complete font, some characters missing !!
$include "TH.font"

โครงการกะเทยท่องโลก

dreamzery

ผมรู้แต่ภาษาซีอะคับ แฮ่ๆๆๆ 
ส่วนที่ผมต้องการแค่binaryตัวอักษรภาษาไทย+พยัญชนะจาก binary to hex ด้วยคิดจากขนาด16x8(Row x Col)ใช้หลักการสแกนบนลงล่าง

ปล.ขอบคุณคับบ