LCDInfo.com

http://www.lcdinfo.com
It is currently Thu Nov 21, 2024 22:03

All times are UTC + 2 hours




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: Wed Aug 24, 2005 16:58 
Offline

Joined: Mon Aug 22, 2005 15:09
Posts: 15
After some research and some help from u guys I have a "plot-pixel"-function ready 2 use. It is not well coded but it works :wink:
Here it is:
Code:
void Plot(int X, int Y, int mode)
{
   unsigned char pixelvalue = 0x10;
   if ((X>-1) && (X<128) && (Y>-1) && (Y<64))
   {
      if (mode==0) arrayLCD[(X>>3)+(Y<<7)] = arrayLCD[(X>>3)+(Y<<7)] & (255-(1<<(7-(X&7))));
      if (mode==1) arrayLCD[(X>>3)+(Y<<7)] = arrayLCD[(X>>3)+(Y<<7)] | 1<<(7-(X&7));
      if (mode==2) arrayLCD[(X>>3)+(Y<<7)] = arrayLCD[(X>>3)+(Y<<7)] ^ 1<<(7-(X&7));

      SetColumn(X);
      switch(Y%8)
      {
         case 0:   pixelvalue = 0x01; break;
         case 1:   pixelvalue = 0x02; break;
         case 2:   pixelvalue = 0x04; break;
         case 3:   pixelvalue = 0x08; break;
         case 4:   pixelvalue = 0x10; break;
         case 5:   pixelvalue = 0x20; break;
         case 6:   pixelvalue = 0x40; break;
         case 7:   pixelvalue = 0x80; break;
         default: pixelvalue = 0x10;
      }
      if(Y<8)
      {   SetPage(0);}
      else if(Y>=8 && Y<16)
      {    SetPage(1);}
      else if(Y>=16 && Y<24)
      {    SetPage(2);}
      else if(Y>=24 && Y<32)
      {    SetPage(3);}
      else if(Y>=32 && Y<40)
      {   SetPage(4);}
      else if(Y>=40 && Y<48)
      {    SetPage(5);}
      else if(Y>=48 && Y<56)
      {    SetPage(6);}
      else
      {    SetPage(7);}
      SendLCDData(&pixelvalue,1);
   }
}

Still I don't know if I need the array, but I think it's nice 2 have if u want 2 check if the pixel is on or off. Must say THX 2 Micheal 4 the excellent idea about "Y%8"
Note: This function is for KS0108, not tested with other controllers.
Have fun
Kneego


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 24, 2005 19:45 
Offline

Joined: Wed Aug 03, 2005 20:27
Posts: 130
Location: .fi
Might also do the trick...

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

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 9:37 
Offline

Joined: Mon Aug 22, 2005 15:09
Posts: 15
Excellent Zee!!! :)
Your code works. Much better than mine and with only one single line instead of several if and switch statements.
It's hard for me to think the numbers or codes bitwise but u done that easily.
THX Zee.
Kneego


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 26, 2005 23:41 
Offline

Joined: Mon Jun 20, 2005 23:03
Posts: 161
Location: Hong Kong
Kneego, thankx for you help
I've [almost] completed adding unicode support along with BIG5 and GB2312 support. Thats over 20000 CJK characters, from native point9 to point 24.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 27, 2005 11:05 
Offline

Joined: Mon Aug 22, 2005 15:09
Posts: 15
Glad 2 be some help. U help me I help u that's the idea. Very impressed, 20 000 characters, wow. Must be alot of work...
Keep on going...
Kneego


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

All times are UTC + 2 hours


Who is online

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