Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

problem with GLCD 128x64 (pic18f452)

Status
Not open for further replies.

smallboy404

New Member
hello guys !
i'm trying to build a project which is about measurement station , in this project i use a 128x64 glcd (ks0108) . i display menu +sub-mesnu and plot graph.
this project works well on proteus ,and doesn't work well on real hardware .
i use a keypad (4 buttons (up+down+ok+return) to navigate between menus )
the problem is i dont press anything and see changes, random display of menu .

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
this is a second part of code (menu controle )
glcd_init(on); /
glcd_showimage(&image_9);


while(1){

eta1:
if(input(pin_b1)==1) / RB1 : button "up"
{
delay_ms(30);
l=l+1; /inc of variable L { from 0 to 3 } i have 4 images .
if(l>3) l=0;
}
if(input(pin_b2)==1) /RB2: Button "down"
{
delay_ms(30);
l=l-1;
if(l>3) l=3;

}
switch(l)
{
case 0:glcd_showimage(&image_0); / l=0 then show first image .

if(input(pin_b3)==1) / RB3 : Button ok .
{
s=1;
while(s=1) / button ok pressed then send data via rs232
{
glcd_fillscreen(0);

glcd_text57(20,10,rs232,1,on);

printf("%f \n\r",current);
printf("%f \n\r",press);
printf("%f \n\r",volt);
printf("%f \n\r",temp);

if(input(pin_b4)==1) { // RB4: Button "return" if its pressed bck to show first image
s=0;
goto eta1;}
}
}
break;
case 1:glcd_showimage(&image_1); //l=1 then show second image
if(input(pin_b3)==1) //if ok button pressed
{
glcd_fillscreen(0);
framevolts(5,0,125,51); //framevolts use to show a frame for plotting
n=1;

while(n=1)
{
eta2: if(input(pin_b1)==1) // up button pressed
{
delay_ms(10);
m=m+1;
if(m>4) m=0; / i do same to first menu
}
if(input(pin_b2)==1)
{
delay_ms(10);
m=m-1;
if(m>4) m=4; //
}
if(input(pin_b4)==1)
{
goto eta1;
}
switch(m)
{

case 0: glcd_showimage(&image_5);
if(input(pin_b3)==1)
{
glcd_fillscreen(0);
framevolts(5,0,125,51);
glcd_text57(48,57,tmp1,1,on);
s2=1;
while(s2=1)
{
if(input(pin_b4)==1)
{
goto eta2;
}
draw((int)current*5); //plot variable current .
delay_ms(20);


}
}
break;
case 1:
glcd_showimage(&image_6);
if(input(pin_b3)==1)
{
glcd_fillscreen(0);
framevolts(5,0,125,51);
glcd_text57(48,57,tmp,1,on);
s2=1;
while(s2=1)
{
if(input(pin_b4)==1)
{
goto eta2;
}
draw((int)volt*20);
delay_ms(10);


}
}

break;
case 2:
glcd_showimage(&image_7);
if(input(pin_b3)==1)
{
glcd_fillscreen(0);
framevolts(5,0,125,51);
glcd_text57(48,57,tmp3,1,on);
s2=1;
while(s2=1)
{
if(input(pin_b4)==1)
{
goto eta2;
}
draw((int)press);
delay_ms(10);


}
}
break;
case 3:
glcd_showimage(&image_8);
if(input(pin_b3)==1)
{
glcd_fillscreen(0);
framevolts(5,0,125,51);
glcd_text57(48,57,tmp2,1,on);
s2=1;
while(s2=1)
{
if(input(pin_b4)==1)
{
goto eta2;
}
draw((int)temp);
delay_ms(5);


}
}

break;
case 4: glcd_showimage(&image_10);
if(input(pin_b3)==1)
{
glcd_fillscreen(0);
framevolts(5,0,125,51);
glcd_text57(48,57,tmp1,1,on);
s2=1;
while(s2=1)
{
if(input(pin_b4)==1)
{
goto eta2;
}
draw((int)current*5);
delay_ms(20);


}
}
break;
}
}
}
break;
case 2:glcd_showimage(&image_2);
if(input(pin_b3)==1)
{

}
break;
case 3:glcd_showimage(&image_3);
if(input(pin_b3)==1)
{
glcd_fillscreen(0);
glcd_rect(1,1,125,50,off,on);
delay_ms(20);
glcd_rect(10,10,110,40,off,on);
delay_ms(20);
glcd_text57(3,20,contact,1,on);
delay_ms(20);
glcd_text57(15,52,web,1,on);
delay_ms(800);
}
break;
}
}
}
 
Last edited by a moderator:
That's what I thought....

You constantly use " if(input(pin_b1)==1) " that according to the schematics is OFF you'll need " if(!(input(pin_b1)==1)) " or " if(input(pin_b1)==0) " to ascertain a key press..

Secondly.... several " while() " statements are incorrect...ie..
Code:
while(s=1) / button ok pressed then send data via rs232
should be..
Code:
while(s==1) / button ok pressed then send data via rs232

Some are ok because you use the controversial "goto" command..
 
Status
Not open for further replies.

Latest threads

Back
Top