LCDInfo.com

http://www.lcdinfo.com
It is currently Mon Nov 25, 2024 0:12

All times are UTC + 2 hours




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: Tue Aug 23, 2005 12:56 
Offline

Joined: Mon Aug 22, 2005 15:09
Posts: 15
Thx Michael and Zee.
If I understand right, after setting a page you have 8 vertical pixel to write, which explains the 8bits you send from the parallelport. And you have to write something, 8bits at once, no matter if it is zeros or ones.
Knowing this makes it harder to make a plot-function, because the function bepends what u write to the LCD. example: write 0x04 on position (0,0) leads to a dot on (0,1) on the LCD.
One solution I think of is to have a dynamic write-value

and plz e-mail me, I like to see the source and the driver :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 13:26 
Offline

Joined: Mon Jun 20, 2005 23:03
Posts: 161
Location: Hong Kong
Kneego wrote:
Thx Michael and Zee.
If I understand right, after setting a page you have 8 vertical pixel to write, which explains the 8bits you send from the parallelport. And you have to write something, 8bits at once, no matter if it is zeros or ones.
Knowing this makes it harder to make a plot-function, because the function bepends what u write to the LCD. example: write 0x04 on position (0,0) leads to a dot on (0,1) on the LCD.
One solution I think of is to have a dynamic write-value

and plz e-mail me, I like to see the source and the driver :)


Actually your best solution is not to write directly to the port on a per pixel basis.

Instead use a buffer and create 'setpixel()' and 'getpixel()' function to access your pixel data.
When done 'flush()' the buffer to the lcd. The flush() routine should take care of formatting the data for lcd, which means OR'ing the 8 vertical pixels to obtain the byte.
This is just a general idea of how writting to an lcd could be achieved, but certainly not the best.

Got an email address? The source is 514k without binaries.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 13:53 
Offline

Joined: Wed Aug 03, 2005 20:27
Posts: 130
Location: .fi
One more attempt for the sake of it. :)

Code:
void Plot(int X, int Y, int mode)
{
   if ((X>-1) && (X<128) && (Y>-1) && (Y<64))
   {
      if (mode==0) arrayLCD[X+((Y<<7)>>3)] = arrayLCD[X+((Y<<7)>>3)] & (255-(1<<(Y&7)));
      if (mode==1) arrayLCD[X+((Y<<7)>>3)] = arrayLCD[X+((Y<<7)>>3)] | 1<<(Y&7);
      if (mode==2) arrayLCD[X+((Y<<7)>>3)] = arrayLCD[X+((Y<<7)>>3)] ^ 1<<(Y&7);

      SetColumn(X);
      SetStartLine(Y>>3);
      SendLCDData(arrayLCD[X+((Y<<7)>>3)]);
   }
}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 14:08 
Offline

Joined: Mon Jun 20, 2005 23:03
Posts: 161
Location: Hong Kong
Zee wrote:
One more attempt for the sake of it. :)

Code:
void Plot(int X, int Y, int mode)
{
   if ((X>-1) && (X<128) && (Y>-1) && (Y<64))
   {
      if (mode==0) arrayLCD[X+((Y<<7)>>3)] = arrayLCD[X+((Y<<7)>>3)] & (255-(1<<(Y&7)));
      if (mode==1) arrayLCD[X+((Y<<7)>>3)] = arrayLCD[X+((Y<<7)>>3)] | 1<<(Y&7);
      if (mode==2) arrayLCD[X+((Y<<7)>>3)] = arrayLCD[X+((Y<<7)>>3)] ^ 1<<(Y&7);

      SetColumn(X);
      SetStartLine(Y>>3);
      SendLCDData(arrayLCD[X+((Y<<7)>>3)]);
   }
}


Zee, the 'StartLine' is used to set 'Y' offset in ram and is used to aid a scrolling effect of the LCD, it should be set to 0 at startup then forgotten about.
Replace with SetPage (y/7);


Last edited by Michael on Sat Aug 27, 2005 0:25, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 16:05 
Offline

Joined: Wed Aug 03, 2005 20:27
Posts: 130
Location: .fi
My bad...

Maybe I should try to find a KS-based display for my collection. And a way to output data fast for large displays.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 16:35 
Offline

Joined: Mon Aug 22, 2005 15:09
Posts: 15
I'm back!!! No power in the house so I went outside and took freesh air :)
First, THX GUYS, 4 helpin with this crazy plot-pixel-project, THX!!!
Using a buffer with suggested functions seems interresting, I experiment it right away!
This afternoon I was busy with making a clock 4 my LCD, it works now and the time is from system-bios :wink:


My e-mail, see my profile :wink:
Kneego


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 16:42 
Offline

Joined: Mon Aug 22, 2005 15:09
Posts: 15
Found out that Y-address increases automatic when u write anything to the LCD.
SetStartLine according the code truly sets the y position but the tricky part is SetColumn-function.
There must be a way to reset the Y-address after writing something so no offsets occur.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 16:55 
Offline

Joined: Mon Jun 20, 2005 23:03
Posts: 161
Location: Hong Kong
Zee wrote:
My bad...

Maybe I should try to find a KS-based display for my collection. And a way to output data fast for large displays.


One of the methods I use is, and perhaps you're doing this already, is instead of frame transferring the complete frame per update, transfer selective regions, ie (x,y,dx,dy). Ie, if only a block of 5,5 pixels have been modifed there is no reason to flush the complete frame to the LCD. This is easier to implement under user programmability.
Another method which I've yet to implement is to use a backbuffer; this would mean an exact copy of the LCD display output (not its memory configuration) is rendered but which is not directly accessible. It would sit between your framedata (the front buffer) and the LCD. Update the front buffer - flush to the backbuffer (which could be another thread), from there it will determine which LCD pixels actually do require updating, possibly via XOR'ing the two buffers - regions (could be a minimum of 8x8) of difference found and then flushed directly to the hardware.
This allows the software to have multiple frontbuffers (the approach I've taken) with only one backbuffer and in the process completely separating the programmer from the actual design of the hardware (the output device).


Michael


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 17:05 
Offline

Joined: Mon Jun 20, 2005 23:03
Posts: 161
Location: Hong Kong
Kneego wrote:
Found out that Y-address increases automatic when u write anything to the LCD.
SetStartLine according the code truly sets the y position but the tricky part is SetColumn-function.
There must be a way to reset the Y-address after writing something so no offsets occur.




SetStartLine does not set the y address per se, if you find that it does then it implies a problem with your code. again, use 'setpage (y mod 8)'
. the remainer of y divided by 8 determines the pixel on the page, setpage (y/8) determines which page to use, then set the x location within that page


Last edited by Michael on Sat Aug 27, 2005 0:26, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 17:24 
Offline

Joined: Mon Aug 22, 2005 15:09
Posts: 15
Want to say thanks 2 Michael 4 the library.
What I need now is time 2 study it :wink:
THX again.
This pixel-function is a thuf nut 2 crack.
Maybe I should re-write and think of drawing frames instead. Drawin frames takes time and fps will be really slow but I only want the Snake-game to work, not really play with it LOL

Thx Michael
Kneego


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 18:50 
Offline

Joined: Mon Jun 20, 2005 23:03
Posts: 161
Location: Hong Kong
Kneego wrote:
Want to say thanks 2 Michael 4 the library.
What I need now is time 2 study it :wink:
THX again.
This pixel-function is a thuf nut 2 crack.
Maybe I should re-write and think of drawing frames instead. Drawin frames takes time and fps will be really slow but I only want the Snake-game to work, not really play with it LOL

Thx Michael
Kneego


No problem, check the 'lRefresh()' functions in ks0108.c for tips on how to update your frame.
Email me the Snake game source and I'll see if I can help, if you like.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 19:00 
Offline

Joined: Wed Aug 03, 2005 20:27
Posts: 130
Location: .fi
Michael wrote:
One of the methods I use is, and perhaps you're doing this already, is instead of frame transferring the complete frame per update, transfer selective regions, ie (x,y,dx,dy). Ie, if only a block of 5,5 pixels have been modifed there is no reason to flush the complete frame to the LCD. This is easier to implement under user programmability.
Another method which I've yet to implement is to use a backbuffer; this would mean an exact copy of the LCD display output (not its memory configuration) is rendered but which is not directly accessible. It would sit between your framedata (the front buffer) and the LCD. Update the front buffer - flush to the backbuffer (which could be another thread), from there it will determine which LCD pixels actually do require updating, possibly via XOR'ing the two buffers - regions (could be a minimum of 8x8) of difference found and then flushed directly to the hardware.
This allows the software to have multiple frontbuffers (the approach I've taken) with only one backbuffer and in the process completely separating the programmer from the actual design of the hardware (the output device).


The way I'm currently using my displays requires pretty much complete update for the whole screen area as there are a lot of changes being made (some results available in the Others-section).

Perhaps when I start implementing some system-level code into my programs but currently I get enough FPS with what I'm doing with the smaller displays.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 19:15 
Offline

Joined: Mon Jun 20, 2005 23:03
Posts: 161
Location: Hong Kong
Zee wrote:
Michael wrote:
One of the methods I use is, and perhaps you're doing this already, is instead of frame transferring the complete frame per update, transfer selective regions, ie (x,y,dx,dy). Ie, if only a block of 5,5 pixels have been modifed there is no reason to flush the complete frame to the LCD. This is easier to implement under user programmability.
Another method which I've yet to implement is to use a backbuffer; this would mean an exact copy of the LCD display output (not its memory configuration) is rendered but which is not directly accessible. It would sit between your framedata (the front buffer) and the LCD. Update the front buffer - flush to the backbuffer (which could be another thread), from there it will determine which LCD pixels actually do require updating, possibly via XOR'ing the two buffers - regions (could be a minimum of 8x8) of difference found and then flushed directly to the hardware.
This allows the software to have multiple frontbuffers (the approach I've taken) with only one backbuffer and in the process completely separating the programmer from the actual design of the hardware (the output device).


The way I'm currently using my displays requires pretty much complete update for the whole screen area as there are a lot of changes being made (some results available in the Others-section).

Perhaps when I start implementing some system-level code into my programs but currently I get enough FPS with what I'm doing with the smaller displays.


Yes I saw and thought it was pretty neat.
Want to code swap? I'm interested in your drawing routines (the rendering) from the demos.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 20:45 
Offline

Joined: Wed Aug 03, 2005 20:27
Posts: 130
Location: .fi
These weren't done by myself but I find them handy sometimes.


Fast linedraw. Works on every angle and without any gaps in the line:
Code:
int sgn (long a)
{
   if (a > 0) return +1;
   else if (a < 0) return -1;
   else return 0;
}

void Line(int x1, int y1, int x2, int y2, int mode)
{
   long u,s,v,d1x,d1y,d2x,d2y,m,n;
   int i;

   u = x2-x1;
   v = y2-y1;
   d1x = sgn(u);
   d1y = sgn(v);
   d2x = sgn(u);
   d2y = 0;
   m = abs(u);
   n = abs(v);
   if (m<=n)
   {
      d2x = 0;
      d2y = sgn(v);
      m = abs(v);
      n = abs(u);
   }
   s = (int)(m / 2);
   for (i=0;i<ceil(m);i++)
   {
      Plot(x1,y1,mode);
      s += n;
      if (s >= m)
      {
         s -= m;
         x1 += d1x;
         y1 += d1y;
      }
      else
      {
         x1 += d2x;
         y1 += d2y;
      }
   }
}


And fast circledraw:

Code:
void CirclePoint(long cx,long cy,long x,long y,char mode)
{
   if (x==0)
   {
      Plot(cx,cy+y,mode);
      Plot(cx,cy-y,mode);
      Plot(cx+y,cy,mode);
      Plot(cx-y,cy,mode);
   }
   else if (x==y)
   {
      Plot(cx+x,cy+y,mode);
      Plot(cx-x,cy+y,mode);
      Plot(cx+x,cy-y,mode);
      Plot(cx-x,cy-y,mode);
   }
   else if (x<y)
   {
      Plot(cx+x,cy+y,mode);
      Plot(cx-x,cy+y,mode);
      Plot(cx+x,cy-y,mode);
      Plot(cx-x,cy-y,mode);
      Plot(cx+y,cy+x,mode);
      Plot(cx-y,cy+x,mode);
      Plot(cx+y,cy-x,mode);
      Plot(cx-y,cy-x,mode);
   }
}

void Circle(long xcenter, long ycenter, long radius, int mode)
{
   long x=0;
   long y=radius;
   long p=(5-radius*4)/4;
   CirclePoint(xcenter,ycenter,x,y,mode);
   while(x<y)
   {
      x++;
      if (p<0)
      {
         p+=2*x+1;
      }
      else
      {
         y--;p+=2*(x-y)+1;
      }
    CirclePoint(xcenter,ycenter,x,y,mode);
   }
}


I'll post some other stuff to the demo-thread.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 20:54 
Offline

Joined: Mon Jun 20, 2005 23:03
Posts: 161
Location: Hong Kong
Interesting line draw, quite different from my own:
Code:
DLLIMPORT void lDrawLine (TLCD *lcd, int x1, int y1, int x2, int y2, int style)
{
    int dx = x2-x1;
    int dy = y2-y1;

    if (dx || dy){
        if (abs(dx) >= abs(dy)){
            float y = y1+0.5;
            float dly = (float)dy/(float)dx;
         int xx;
           
            if (dx > 0){
                for (xx = x1; xx<=x2; xx++){
                    lSetPixel (lcd,xx,(int)y,style);
                    y += dly;
                }
            }else{
                for (xx = x1; xx>=x2; xx--){
                    lSetPixel (lcd,xx,(int)y,style);
                    y -= dly;
                }
         }
        }else{
              float x = x1+0.5;
              float dlx = (float)dx/(float)dy;
              int yy;

            if (dy > 0){
                  for (yy = y1; yy<=y2; yy++){
                      lSetPixel (lcd,(int)x,yy,style);
                      x += dlx;
                  }
         }else{
                for (yy = y1; yy >= y2; yy--){
                      lSetPixel (lcd,(int)x,yy,style);
                      x -= dlx;
                  }
         }
        }
    } else if (!(dx&dy))
       lSetPixel(lcd,x1,y1,style);
}


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

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 14 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