LCDInfo.com

http://www.lcdinfo.com
It is currently Fri Nov 22, 2024 11:22

All times are UTC + 2 hours




Post new topic Reply to topic  [ 163 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 11  Next
Author Message
 Post subject: VB .NET Code translation
PostPosted: Wed Feb 19, 2003 23:54 
Offline

Joined: Fri Feb 07, 2003 16:37
Posts: 60
Location: SaNT QUiRZe, ||*|| CaTaLoNiA ||*||
This is the code that Henri posted few days ago:


The DLPortIO declarations with .NET
Code:
 Public Declare Function DlPortReadPortUchar Lib "dlportio.dll" ( _
           ByVal Port As Integer) As Byte

    Public Declare Function DlPortReadPortUshort Lib "dlportio.dll" ( _
            ByVal Port As Integer) As Short

    Public Declare Function DlPortReadPortUlong Lib "dlportio.dll" ( _
            ByVal Port As Integer) As Integer

    Public Declare Sub DlPortReadPortBufferUchar Lib "dlportio.dll" ( _
            ByVal Port As Integer, _
           <System.Runtime.InteropServices.MarshalAs (Runtime.InteropServices.UnmanagedType.AsAny)> ByVal Buffer As Object, _
            ByVal Count As Integer)

    Public Declare Sub DlPortReadPortBufferUshort Lib "dlportio.dll" ( _
            ByVal Port As Integer, _
            <System.Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.AsAny)> ByVal Buffer As Object, _
            ByVal Count As Integer)

    Public Declare Sub DlPortReadPortBufferUlong Lib "dlportio.dll" ( _
            ByVal Port As Integer, _
           <System.Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.AsAny)> ByVal Buffer As Object, _
            ByVal Count As Integer)

    Public Declare Sub DlPortWritePortUchar Lib "dlportio.dll" ( _
            ByVal Port As Integer, _
            ByVal Value As Byte)

    Public Declare Sub DlPortWritePortUshort Lib "dlportio.dll" ( _
            ByVal Port As Integer, _
            ByVal Value As Short)

    Public Declare Sub DlPortWritePortUlong Lib "dlportio.dll" ( _
            ByVal Port As Integer, _
            ByVal Value As Integer)

    Public Declare Sub DlPortWritePortBufferUchar Lib "dlportio.dll" ( _
             ByVal Port As Integer, _
             <System.Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.AsAny)> ByVal Buffer As Object, _
             ByVal Count As Integer)

    Public Declare Sub DlPortWritePortBufferUshort Lib "dlportio.dll" ( _
             ByVal Port As Integer, _
             <System.Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.AsAny)> ByVal Buffer As Object, _
              ByVal Count As Integer)

    Public Declare Sub DlPortWritePortBufferUlong Lib "dlportio.dll" ( _
              ByVal Port As Integer, _
              <System.Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.AsAny)> ByVal Buffer As Object, _
              ByVal Count As Integer)

_________________
Nuestra única limitación es la imaginación


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 19, 2003 23:56 
Offline

Joined: Fri Feb 07, 2003 16:37
Posts: 60
Location: SaNT QUiRZe, ||*|| CaTaLoNiA ||*||
Code:
    Public Sub WaitDisplayReady()
        Dim shtTemp As Short

        shtTemp = DlPortReadPortUshort(BASE_DADES + &H402)
        shtTemp = shtTemp And &H1F
        shtTemp = shtTemp Or &H20
        DlPortWritePortUshort(BASE_DADES + &H402, shtTemp)

        Do
            DlPortWritePortUshort(BASE_DADES + 2, &H20 + 4 + 2)     
            DlPortWritePortUshort(BASE_DADES + 2, &H20 + 4 + 2 + 8) 
            shtTemp = DlPortReadPortUshort(BASE_DADES)
            DlPortWritePortUshort(BASE_DADES + 2, &H20 + 4 + 2)     
        Loop While ((shtTemp And 3) <> 3)
        DlPortWritePortUshort(BASE_DADES + 2, 0)
    End Sub

_________________
Nuestra única limitación es la imaginación


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 19, 2003 23:58 
Offline

Joined: Fri Feb 07, 2003 16:37
Posts: 60
Location: SaNT QUiRZe, ||*|| CaTaLoNiA ||*||
Code:
Public Sub WriteData(ByVal pvshtData As Short)
        DlPortWritePortUshort(BASE_DADES + 2, &HC) 
        DlPortWritePortUshort(BASE_DADES + 2, &H8)
        DlPortWritePortUshort(BASE_DADES, pvshtData)
        DlPortWritePortUshort(BASE_DADES + 2, &H9)
        DlPortWritePortUshort(BASE_DADES + 2, &H8)
        DlPortWritePortUshort(BASE_DADES + 2, &HC)
    End Sub

    Public Sub WriteCtrl(ByVal pvshtCommand As Short)
        DlPortWritePortUshort(BASE_DADES + 2, &H4)
        DlPortWritePortUshort(BASE_DADES + 2, &H0)
        DlPortWritePortUshort(BASE_DADES, pvshtCommand)
        DlPortWritePortUshort(BASE_DADES + 2, &H1) 
        DlPortWritePortUshort(BASE_DADES + 2, &H0) 
        DlPortWritePortUshort(BASE_DADES + 2, &HC)
    End Sub

_________________
Nuestra única limitación es la imaginación


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 20, 2003 0:00 
Offline

Joined: Fri Feb 07, 2003 16:37
Posts: 60
Location: SaNT QUiRZe, ||*|| CaTaLoNiA ||*||
Code:
Public Sub InitLCD()
        WriteData(T_BASE And &HFF)
        WriteData(RShiftLong(T_BASE, 8))
        WriteCtrl(&H40)

        WriteData(BYTES_PER_ROW)
        WriteData(0)
        WriteCtrl(&H41)

        WriteData(G_BASE And &HFF)
        WriteData(RShiftLong(G_BASE, 8))
        WriteCtrl(&H42)

        WriteData(BYTES_PER_ROW)
        WriteData(0)
        WriteCtrl(&H43)

        WriteCtrl(&H80)
        WriteCtrl(&HA7)
        WriteData(&H0)   
        WriteData(&H0) 
        WriteCtrl(&H21)

        WriteCtrl(&H9D)
    End Sub

_________________
Nuestra única limitación es la imaginación


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 20, 2003 0:03 
Offline

Joined: Fri Feb 07, 2003 16:37
Posts: 60
Location: SaNT QUiRZe, ||*|| CaTaLoNiA ||*||
Code:
Public Sub SetLCDXY(ByVal pvshtX As Short, _
                                ByVal pvshtY As Short)
        Dim shtAdreça As Short

        shtAdreça = T_BASE + (pvshtY * BYTES_PER_ROW) + pvshtX
        WriteData(shtAdreça And &HFF)
        WriteData(RShiftLong(shtAdreça, 8))
        WriteCtrl(&H24)
End Sub

Public Sub SetLCDCursor(ByVal pvshtX As Short, _
                                      ByVal pvshtY As Short)

        WriteData(pvshtX)
        WriteData(pvshtY)
        WriteCtrl(&H21)
End Sub

Public Sub ClearLCDText()
        Dim shtCont As Short

        WriteData(T_BASE And &HFF)
        WriteData(RShiftLong(T_BASE, 8))
        WriteCtrl(&H24)

        For shtCont = 0 To 640 - 1
            WriteData(0)
            WriteCtrl(&HC0)
        Next
End Sub

Public Sub ClearLCDGraph()
        Dim shtCont As Short

        WriteData(G_BASE And &HFF)
        WriteData(RShiftLong(G_BASE, 8))
        WriteCtrl(&H24)

        For shtCont = 0 To NUM_PIXELS - 1 'shtCont < 5120
            WriteData(0)
            WriteCtrl(&HC0) 'write data and inc ptr
        Next
    End Sub

Public Sub SetLCDPixel(ByVal pvshtX As Short, _
                                  ByVal pvshtY As Short)
        Dim shtAdreça As Short

        shtAdreça = G_BASE + (pvshtY * BYTES_PER_ROW) + (pvshtX / 6)
        WriteData(shtAdreça And &HFF)
        WriteData(RShiftLong(shtAdreça, 8))
        WriteCtrl(&H24)
        WriteCtrl(&HF8 Or (5 - (pvshtX Mod 6)))
End Sub

Public Sub ClearLCDPixel(ByVal pvshtX As Short, _
                                      ByVal pvshtY As Short)
        Dim shtAdreça As Short

        shtAdreça = G_BASE + (pvshtY * BYTES_PER_ROW) + (pvshtX / 6)
        WriteData(shtAdreça And &HFF)
        WriteData(RShiftLong(shtAdreça, 8))
        WriteCtrl(&H24)
        WriteCtrl(&HF0 Or (5 - (pvshtX Mod 6)))
End Sub

_________________
Nuestra única limitación es la imaginación


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 20, 2003 0:04 
Offline

Joined: Fri Feb 07, 2003 16:37
Posts: 60
Location: SaNT QUiRZe, ||*|| CaTaLoNiA ||*||
Code:
Public Sub PrintLCDText(ByVal pvstrTexte As String)
    Dim bytLletra As Byte
    Dim shtCont As Short

    For shtCont = 0 To pvstrTexte.Length - 1
        bytLletra = AscW(pvstrTexte.Chars(shtCont)) - &H20
        If bytLletra < 0 Then bytLletra = 0
        WriteData(bytLletra)
        WriteCtrl(&HC0)
    Next
End Sub

_________________
Nuestra única limitación es la imaginación


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 20, 2003 0:07 
Offline

Joined: Fri Feb 07, 2003 16:37
Posts: 60
Location: SaNT QUiRZe, ||*|| CaTaLoNiA ||*||
The constants for all this functions:

Code:
Public Const G_BASE As Short = &H300 'Graphic address
Public Const T_BASE As Short = &H0     'Text Address
Public Const BYTES_PER_ROW As Short = 40           'Bytes x row
Public Const BASE_DADES As Short = &H378   'Data port of LCD
Public Const NUM_PIXELS As Short = 5120

_________________
Nuestra única limitación es la imaginación


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 20, 2003 10:12 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
Thanks for the code, Marc. :D

I'm sure it will be helpful.


Top
 Profile  
 
 Post subject: True Type fonts
PostPosted: Thu Feb 20, 2003 13:21 
Offline

Joined: Fri Feb 07, 2003 16:37
Posts: 60
Location: SaNT QUiRZe, ||*|| CaTaLoNiA ||*||
How do you do to show True Type fonts ¿?

I tryed a lot of things, but I can't.

Thanks

_________________
Nuestra única limitación es la imaginación


Top
 Profile  
 
 Post subject: Re: True Type fonts
PostPosted: Thu Feb 20, 2003 13:32 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
Marc wrote:
How do you do to show True Type fonts ¿?

I'm just drawing the font to a bitmap in the program and then drawing the bitmap to the screen. I think there should be something similar in .NET.

Is there some specific area where you would need help in this ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 20, 2003 15:00 
Offline

Joined: Fri Feb 07, 2003 16:37
Posts: 60
Location: SaNT QUiRZe, ||*|| CaTaLoNiA ||*||
Ok, when you show bitmaps, the LCD draws the bitmap inmediatly ¿? or it delays ??

I will say if you draw a bitmap, it appears instantly (less than 0,1 seconds) in the LCD, or the image is showing slowly, (more than 0,5 secs.) ¿?

_________________
Nuestra única limitación es la imaginación


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 20, 2003 15:13 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
Marc wrote:
Ok, when you show bitmaps, the LCD draws the bitmap inmediatly ¿? or it delays ??

That depends of the size of the bitmap you draw to the display. If you are writing one word using small font the bitmap could be 8x60 pixels so it's written very fast to the display.

I'm able to write fullscreen bitmaps to 240x128 T6963C display at 18 FPS, so you can't really notice even if you update the whole screen every time but of course writing full screens takes CPU time.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 20, 2003 15:27 
Offline

Joined: Fri Feb 07, 2003 16:37
Posts: 60
Location: SaNT QUiRZe, ||*|| CaTaLoNiA ||*||
How do you that ¿? Because i have a notable delay showing bitmaps.

Thanks

_________________
Nuestra única limitación es la imaginación


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 20, 2003 17:21 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
I have a buffer: unsigned char LCDBuffer[3840] that has the image and then the bytes are written to the LCD using auto write mode.

Could you post some of your bitmap code so maybe I could tell how to make it faster ? How are you storing the bitmap and how do you read the bitmap and how do you write it to the display ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 20, 2003 22:49 
Offline

Joined: Fri Feb 07, 2003 16:37
Posts: 60
Location: SaNT QUiRZe, ||*|| CaTaLoNiA ||*||
Hi Henri.

I use this code for display a botmap that is in a PictureBox control :

Code:
Public Sub sbrDibuixaLCDBMP(picPicBox As PictureBox, _
                            intX As Integer, _
                            intY As Integer)
               
   Dim intAddr As Integer
   Dim intI As Integer
   Dim intJ As Integer
   Dim intK As Integer
   Dim lngLCDValue As Integer
   Dim intTmp As Integer

   For intI = 0 To 127
      'set address pointer to beginning of row
      intAddr = G_BASE + ((intY + intI) * BYTES_PER_ROW) + (intX / 6)
      Call sbrEscriuData(intAddr And 255)
      Call sbrEscriuData(fnclngDesplaçarBitsDreta(intAddr, 8))
      Call sbrEscriuCtrl(36)
     
      Call sbrEscriuCtrl(176) 'auto write mode on

      For intJ = 0 To 127
         lngLCDValue = 0

         'build the byte to send to display
         For intK = 0 To 4 'add all bits except last one
            If picPicBox.Point(6 * intJ + intK, intI) <> 0 Then
               intTmp = 0
            Else
               intTmp = 1
            End If
   
            lngLCDValue = lngLCDValue Or intTmp
            lngLCDValue = fnclngDesplaçarBitsEsquerra(lngLCDValue, 1)
         Next intK

         If picPicBox.Point(6 * intJ + 5, intI) <> 0 Then
            intTmp = 0
         Else
            intTmp = 1
         End If

         lngLCDValue = lngLCDValue Or intTmp 'addlast bit to byte

         Call sbrEscriuData(lngLCDValue)
      Next intJ
      Call sbrEscriuCtrl(178) 'auto write mode off
   Next intI
End Sub


I think that this code can be optimized, but i don't know how to solve the delay problem.

Thanks

_________________
Nuestra única limitación es la imaginación


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 163 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 11  Next

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 58 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group