Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

glcd draw circle and convert bitmap

Status
Not open for further replies.

andy40185

Member level 5
Joined
Sep 30, 2011
Messages
80
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,810
Hi all,

I am designing a picture to display on lcd. Have any software can support this and convert to a bitmap?
Also, I have a function to draw a circle on lcd but it does not work and something are missing, can anyone help me to modify it?

Code:
// Purpose:       Draw a circle on a graphic LCD 
// Inputs:        (x,y) - the center of the circle 
//                radius - the radius of the circle 
//                fill - YES or NO 
//                color - ON or OFF
void glcd_circle(int x, int y, int radius, int1 fill, int1 color) 
{ 
   signed int a, b, P; 
   a = 0; 
   b = radius; 
   P = 1 - radius; 
 
   do 
   { 
      if(fill) 
      { 
         glcd_line(x-a, y+b, x+a, y+b, color); 
         glcd_line(x-a, y-b, x+a, y-b, color); 
         glcd_line(x-b, y+a, x+b, y+a, color); 
         glcd_line(x-b, y-a, x+b, y-a, color); 
      } 
      else 
      { 
         glcd_pixel(a+x, b+y, color); 
         glcd_pixel(b+x, a+y, color); 
         glcd_pixel(x-a, b+y, color); 
         glcd_pixel(x-b, a+y, color); 
         glcd_pixel(b+x, y-a, color); 
         glcd_pixel(a+x, y-b, color); 
         glcd_pixel(x-a, y-b, color); 
         glcd_pixel(x-b, y-a, color); 
      } 
 
      if(P  0) 
         P+= 3 + 2*a++; 
      else 
         P+= 5 + 2*(a++ - b--); 
    } while(a = b); 
}
Code:
void glcd_line(int x1, int y1, int x2, int y2, int1 color) 
{ 
   signed int  x, y, addx, addy, dx, dy; 
   signed long P; 
   int i; 
   dx = abs((signed int)(x2 - x1)); 
   dy = abs((signed int)(y2 - y1)); 
   x = x1; 
   y = y1; 
 
   if(x1 > x2) 
      addx = -1; 
   else 
      addx = 1; 
   if(y1 > y2) 
      addy = -1; 
   else 
      addy = 1; 
 
   if(dx >= dy) 
   { 
      P = 2*dy - dx; 
 
     do 
      { 
         glcd_pixel(x, y, color); 
 
         if(P<0) 
         { 
            P += 2*dy; 
            x += addx; 
         } 
         else 
         { 
            P += 2*dy - 2*dx; 
            x += addx; 
            y += addy; 
         } 
      } while(x!=x2);
   } 
   else 
   { 
      P = 2*dx - dy; 
 
      do
      { 
         glcd_pixel(x, y, color); 
 
         if(P>0) 
         { 
            P += 2*dx; 
            y += addy; 
         } 
         else 
         { 
            P += 2*dx - 2*dy; 
            x += addx; 
            y += addy; 
         } 
      } while(y!=y2);
   } 
}
Code:
// Purpose:       Turn a pixel on a graphic LCD on or off 
// Inputs:        x - the x coordinate of the pixel 
//                y - the y coordinate of the pixel 
//                color - ON or OFF 
// Output:        1 if coordinate out of range, 0 if in range 
void glcd_pixel(int x, int y, int1 color) 
{ 
   BYTE data; 
   BYTE chip = GLCD_CS1;  // Stores which chip to use on the LCD 
 
   if(x > 63)  // Check for first or second display area 
   { 
      x -= 64; 
      chip = GLCD_CS2; 
   } 
 
   output_low(GLCD_DI);                                     // Set for instruction 
   bit_clear(x,7);                                          // Clear the MSB. Part of an instruction code 
   bit_set(x,6);                                            // Set bit 6. Also part of an instruction code 
   glcd_writeByte(chip, x);                                 // Set the horizontal address 
   glcd_writeByte(chip, (y/8 & 0b10111111) | 0b10111000);   // Set the vertical page address 
   output_high(GLCD_DI);                                    // Set for data 
   data = glcd_readByte(chip); 
 
   if(color == ON) 
      bit_set(data, y%8);        // Turn the pixel on 
   else                          // or 
      bit_clear(data, y%8);      // turn the pixel off 
   output_low(GLCD_DI);          // Set for instruction 
   glcd_writeByte(chip, x);      // Set the horizontal address 
   output_high(GLCD_DI);         // Set for data 
   glcd_writeByte(chip, data);   // Write the pixel data 
}
 
Last edited:

thanks srizbf, I have seen these site before. I want you know that my issue is how to create a circle on glcd and the function have 2 type circle simular to the above function
(fill = 1 or 0). You can see the above glcd_circle function including a blank (if(P 0)). I do not distinguish which the operand should be put on it or the whole glcd_circle function is failure.
The second question is: I want a software to offer me to draw and convert to bitmap. I have remember to use a glcd-simulator to do this but I have delete it and cannot find it now. Thus, any suggestion software(please ensure a download link since many site no longer to upload the free version) or glcd-simulator?

p.s: I have tested the function of glcd_line and glcd_pixel and it's work.
 

i dont know whether you are referring glcd simulator written by the second link site.

anyway , you can generate in image or paint whatever you want with painting software(say, microsoft paint).
save the file as bitmap file.

then download 'lcdassistant' from
https://en.radzio.dxp.pl/bitmap_converter/LCDAssistant.zip

the above sw can write c file comaptible to many glcds.
you can gothrough the software lcdassistant and see whether it is of use to you.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top