What exactly is an "LCD massage"? ;-) Sean On Tue, Mar 24, 2009 at 12:03 AM, Andre Abelian wr= ote: > Hi to all, > > I am working on 5 buttons and 2x16 LCD that has lots of > Information to display wait a few seconds etc. then questions to ask > And lots of up and downs. The way I started to write the code > I ended up too messy and now I am changing it to something like this > But I am not sure if this is the best way of doing it. Friend of mine > Said that what I did it similar to state machine. > I have a variable name STATUS_FLAG and each buttons press or condition > I update the STATUS_FLAG for example > > > STATUS_FLAG =3D 6 PrePRG# 1 > STATUS_FLAG =3D 7 PrePRG# 2 =A0 =A0 etc. > > > =A0I have 20 while loops so far > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0while (STATUS_FLAG =3D=3D 2) =A0 // run custom= program > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 // =A0 =A0 =A0 =A0Run program here > =A0 =A0 =A0 =A0 =A0 // =A0 =A0 =A0 =A0If button pressed update =A0STATUS_= FLAG > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!input(RIGHT)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0STATUS_FLAG = =3D 3; =A0 =A0 =A0 =A0 =A0 =A0// select pre > programmed > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!input(ENT)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0STATUS_FLAG = =3D 5; =A0 =A0 =A0 =A0 =A0 =A0// select Custom > program > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0lcd_putc("\f")= ; =A0 =A0 =A0 =A0 =A0 =A0 // clear screen > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0After pressing buttons while loop will exit and other while loop will > start to run > =A0My question is there any better way of doing it? Any suggestions ? > > > Thanks > > Andre > > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist