LCDInfo.com

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

All times are UTC + 2 hours




Post new topic Reply to topic  [ 163 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11  Next
Author Message
 Post subject:
PostPosted: Thu Oct 30, 2003 12:54 
Offline

Joined: Wed Oct 29, 2003 12:05
Posts: 4
Hi Emil,

What information do you need ?
The current problem is that every pixel I write, takes about 6 pixels on the lcd. So it shifts 6 positions to the right in stead of 1...

PS: I also wanted to try your code with the hex-converted bmp's. But were can I find the code of these functions ?:

GetByteArray(cntrl.hdc, cntrl.Image, 1, b8())
Convert8BitTo6Bit(b8(), b6(), DEFAULT_GRAPH_SPALTE)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2003 14:11 
Offline

Joined: Fri Feb 21, 2003 5:41
Posts: 43
Hi JohnVanBeton

I wouldn't like to publish this Function

You this Function sends me your source code and I build there one.

Greetings Emil


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2003 18:19 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
Here's some C code for the 8 to 6 pixel conversion. Using this code I've been able to write full screen animations at speeds up to 30FPS in my tests.

The conversion is very simple so with some thinking it should be possible to convert to VB (and if someone converts it to VB I wouldn't mind if the converted code was posted here to help others ;) ).

Code:
void WriteBuffer(unsigned char *LcdData[])
{
   unsigned char byte1, byte2, byte3, lcdbyte1, lcdbyte2, lcdbyte3, lcdbyte4;
   int addr;
   
   if(font_width == 6)
   {
      for(int y = 0 ; y < ypixels; y++)
      {
         addr =  G_BASE + (y * BYTES_PER_ROW_GFX);
         WriteData(addr % 256);
         WriteData(addr >> 8);
         WriteCtrl(0x24);

         WriteCtrl(0xb0);

         for(int i=0;i<buffer_bytes_per_row;i+=3)
         {
            byte1 = (*LcdData)[y*buffer_bytes_per_row+i];
            byte2 = (*LcdData)[y*buffer_bytes_per_row+i+1];
            byte3 = (*LcdData)[y*buffer_bytes_per_row+i+2];

            lcdbyte1 = (byte1 >> 2) & 0x3F;
            WriteData(lcdbyte1);

            lcdbyte2 = (((byte1 << 4) | ((byte2 >> 4) & 0xF)) & 0x3F);
            WriteData(lcdbyte2);

            lcdbyte3 = (((byte2 << 2) | ((byte3 >> 6) & 0x3)) & 0x3F);
            WriteData(lcdbyte3);

            lcdbyte4 = (byte3 & 0x3F);
            WriteData(lcdbyte4);
         }
         WriteCtrl(0xb2);
      }
   }
   else if(font_width == 8)
   // following 8x8 font code haven't been tested yet
   // so expect some stupid mistake there
   {
      for(int y = 0 ; y < ypixels; y++)
      {
         addr =  G_BASE + (y * BYTES_PER_ROW_GFX);
         WriteData(addr % 256);
         WriteData(addr >> 8);
         WriteCtrl(0x24);

         WriteCtrl(0xb0);

         for(int i=0;i<buffer_bytes_per_row;i++)
         {
            WriteData((*LcdData)[y*buffer_bytes_per_row+i]);
         }
         WriteCtrl(0xb2);
      }
   }
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2003 21:26 
Offline

Joined: Fri Feb 21, 2003 5:41
Posts: 43
Hi Henri

Quote:
Using this code I've been able to write full screen animations at speeds up to 30FPS in my tests.


With which processor (MHZ)

I have a AMD Athlon XP2000+ (1675 MHZ)

You loaded 30 Image with 1 Sec.????

( This is Realtime Movie)
I cannot believe this

Send me a simple Sample as EXE! I will check this.

Greetings Emil


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2003 21:47 
Offline

Joined: Fri Feb 21, 2003 5:41
Posts: 43
Hi

I have translate it (not self checked)

Code:
Option Explicit

Private OnBits(0 To 31) As Long

Public Sub WriteBuffer(LcdData() As Byte, font_width As Integer, ypixels As Long)

Dim byte1      As Byte
Dim byte2      As Byte
Dim byte3      As Byte
Dim lcdbyte1   As Byte
Dim lcdbyte2   As Byte
Dim lcdbyte3   As Byte
Dim lcdbyte4   As Byte
Dim addr       As Integer
Dim Y            As Integer
Dim I            As Integer
   
    If font_width = 6 Then
        For Y = 0 To ypixels
            addr = G_BASE + (Y * BYTES_PER_ROW_GFX)
            Call WriteData(addr And 256)
            Call WriteData(RShiftLong(addr, 8))
            Call WriteCtrl(&H24)

            Call WriteCtrl(176) 'auto write mode on

            For I = 0 To buffer_bytes_per_row + 3
                byte1 = LcdData(Y * buffer_bytes_per_row + I)
                byte2 = LcdData(Y * buffer_bytes_per_row + I + 1)
                byte3 = LcdData(Y * buffer_bytes_per_row + I + 2)

                lcdbyte1 = (RShiftLong(byte1, 2)) And &H3F
                Call WriteData(lcdbyte1)

                lcdbyte2 = (((LShiftLong(byte1, 4)) Or ((RShiftLong(byte2, 4)) And &HF)) And &H3F)
                Call WriteData(lcdbyte2)

                lcdbyte3 = (((LShiftLong(byte2, 2)) Or ((RShiftLong(byte3, 6)) And &H3)) & &H3F)
                Call WriteData(lcdbyte3)

                lcdbyte4 = (byte3 And &H3F)
                Call WriteData(lcdbyte4)
            Next I
            Call WriteCtrl(178)  'auto write mode off
        Next Y

    ElseIf font_width = 8 Then
        '// following 8x8 font code haven't been tested yet
        '// so expect some stupid mistake there
        For Y = 0 To ypixels

            addr = G_BASE + (Y * BYTES_PER_ROW_GFX)
            Call WriteData(addr And 256)
            Call WriteData(RShiftLong(addr, 8))
            Call WriteCtrl(&H24)

            Call WriteCtrl(176) 'auto write mode on

            For I = 0 To buffer_bytes_per_row
                Call WriteData((LcdData(Y * buffer_bytes_per_row + I)))
            Next I
            Call WriteCtrl(178)  'auto write mode off
        Next Y
    End If

End Sub

Public Function LShiftLong(ByVal Value As Long, _
                           ByVal Shift As Integer) As Long

        Call MakeOnBits
        If (Value And (2 ^ (31 - Shift))) Then GoTo OverFlow
        LShiftLong = ((Value And OnBits(31 - Shift)) * (2 ^ Shift))
        Exit Function

OverFlow:
        LShiftLong = ((Value And OnBits(31 - (Shift + 1))) * (2 ^ (Shift))) Or &H80000000

End Function

Public Function RShiftLong(ByVal Value As Long, _
                           ByVal Shift As Integer) As Long

        Dim hi As Long
        Call MakeOnBits
        If (Value And &H80000000) Then hi = &H40000000

        RShiftLong = (Value And &H7FFFFFFE) \ (2 ^ Shift)
        RShiftLong = (RShiftLong Or (hi \ (2 ^ (Shift - 1))))

End Function

Private Sub MakeOnBits()

        Dim j As Integer
        Dim v As Long
        For j = 0 To 30
            v = v + (2 ^ j)
            OnBits(j) = v
        Next j
        OnBits(j) = v + &H80000000

End Sub



Which data are submitted here 'LcdData()'
Which data are submitted here 'buffer_bytes_per_row'

Greetings Emil


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2003 0:34 
Offline

Joined: Wed Oct 29, 2003 12:05
Posts: 4
hi


Last edited by JohnVanBeton on Mon Nov 10, 2003 14:37, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 01, 2003 17:03 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
Emil Weiss wrote:
Which data are submitted here 'LcdData()'
Which data are submitted here 'buffer_bytes_per_row'

LcdData is an array that has the bitmap data.
buffer_bytes_per_row is the number of bytes per bitmap row

For example 240x128 bitmap:
buffer_bytes_per_row = 240/8 = 30
and LcdData is array of 30*128 bytes = 3840 bytes


I'll send you some sample exe to test but first I'll have to find the sources and test them with some T6963C display myself. I think the tests I mentioned were done in early January maybe and I should have the sources still somewhere. The processor used was 1200MHz Athlon.
It might have been that the 30fps was with 240x64 display so with 240x128 display it would be 15fps only. But in the next couple days you should be able to test it yourself when I have something to send you.
Which wiring are you using ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 02, 2003 2:13 
Offline

Joined: Fri Feb 21, 2003 5:41
Posts: 43
@Henri

Thanks for the answer.
My wiring is:

WR = 1
CE = 16
CD = 17
RD = 14


Greetings Emil


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 28, 2003 19:17 
Offline

Joined: Fri Nov 28, 2003 19:09
Posts: 4
Location: Belgium, Gent
Emil Weiss wrote:
Use this

Code:

Public Function RShiftLong(ByVal Value As Long, _
                           ByVal Shift As Integer) As Long

Dim hi As Long

    MakeOnBits
    If (Value And &H80000000) Then hi = &H40000000

    RShiftLong = (Value And &H7FFFFFFE) \ (2 ^ Shift)
    RShiftLong = (RShiftLong Or (hi \ (2 ^ (Shift - 1))))

End Function



Code:
Private Sub MakeOnBits()

Dim j As Integer, _
        v As Long

    For j = 0 To 30

        v = v + (2 ^ j)
        OnBits(j) = v

    Next j

    OnBits(j) = v + &H80000000

End Sub


Code:
Public Function LShiftLong(ByVal Value As Long, _
                           ByVal Shift As Integer) As Long

    MakeOnBits

    If (Value And (2 ^ (31 - Shift))) Then Exit Function

    LShiftLong = ((Value And OnBits(31 - Shift)) * (2 ^ Shift))

End Function


Greetings Emil


Hi Emil,

Can you please tell me how I have to declare "onbits" in VBNet 2002 because I still get an error on this one. I can't declare it global.


Greets

Suge


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 28, 2003 20:04 
Offline

Joined: Fri Feb 21, 2003 5:41
Posts: 43
hi

you must set "Private OnBits(0 To 31) As Long" as array

With VB6 'i use not vbnet 2002'

Greetings Emil


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 29, 2003 0:39 
Offline

Joined: Thu Jul 24, 2003 19:00
Posts: 16
[dutch mode] Hallo suge ik ben ook van belgie west vlaanderen :p
maar ga even in engels typen ;) [/dutch mode]

I have vb .net 2003 and you can use the >> and the << just like in C
don't know if they work for 2002 but i'm 99% sure

so for example:
This is in vb 6.0 and earlier:
Call WriteData(RShiftLong(addr, 8))

This is for vb .net
Call WriteData(addr >> 8)

So:
RShiftLong = >>
LShiftLong = <<

(i don't write Call but you may if you want to :p)

I switched from vb 6.0 to vb .net a few months back and i must say i love it more then 6.0 ;)

Also a little note:
Don't use Integer i did it in the beginning and nothing worked i just changed everything that is Integer to Short and all works now.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 29, 2003 1:05 
Offline

Joined: Thu Jul 24, 2003 19:00
Posts: 16
Hello again,

i have a question:
How can bitmap data be placed in an LcdData array ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 07, 2003 1:12 
Offline

Joined: Thu Jul 24, 2003 19:00
Posts: 16
somebody that can help ??


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 9:42 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
You can just read the bitmap data from bmp file and put it in the LcdData array. There are BMP file specifications and file header information available somewhere in net. Then you can read from the header the picture dimensions and also the position at where the picture data itself starts in the file. Then just seek to the correct position and read the picture data to the array.

Something to remember is that every scanline in the bmp file is aligned at 4 bytes. Let's say you have a 100x100 picture. You need 13 bytes to represent one scanline data. But as every scanline is padded to 4 byte boundary there will be 3 extra empty bytes that you need to ignore. So the total length for the scanline data will be 16 bytes and after that the next scanline data begins.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 13:21 
Offline

Joined: Fri Nov 28, 2003 19:09
Posts: 4
Location: Belgium, Gent
Hi

Can someone please help me with showing a bmp on my 240*128-lcd.

I'm using the following function to draw the bmp:

Code:
Public Function DisplayBMP(Picture As PictureBox, ByVal X As Integer, ByVal Y As Integer)
   Dim Adres As Integer
   Dim LCDwaarde As Long
   Dim I As Long
   Dim J As Long

   For I = 0 To 127
      Adres = G_BASE + ((Y + I) * BYTES_PER_ROW) + (X / 6)
      WriteData (Adres And &HFF)
      WriteData (RShiftLong(Adres, 8))
      WriteCtrl (&H24)

      WriteCtrl (&HB0)

      For J = 0 To 239
         If Picture.Point(J, I) = 0 Then
            WriteData (1)
         Else 'Puntje = wit of andere kleur
            WriteData (0)
         End If
      Next J

      WriteCtrl (&HC0)
   Next I
End Function


and I use the followint to call the function:
Code:
Call DisplayBMP(Picture1, 0, 0)


But I just can't let it work :?

Anyone an idea?

Suge


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 163 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11  Next

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 19 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:  
Powered by phpBB® Forum Software © phpBB Group