![]() | ![]() | ![]() |
| | #76 |
|
i meant like the project files. Like can you post a zip or something with all files in that folder so i can see how everything is setup
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #77 |
|
Here is my project files and schematic
| |
| |
| | #78 |
|
You are using MikroC ? Or MikroC Pro?
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #79 |
|
mikroC PRO sorry didnt realise there was a difference
| |
| |
| | #80 |
|
Try This pal: Code: //REV2
#define MENU 2
#define UP 3
#define DOWN 4
// LCD connections definitions
sbit LCD_RS at RA0_bit;
sbit LCD_EN at RA1_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISA0_bit;
sbit LCD_EN_Direction at TRISA1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD connections definitions
unsigned char MainMenuLIST[3][16] = {
{"Option A"},
{"Option B"},
{"Option C"}
};
unsigned char WaitForInput(void){
unsigned char done = 0; //DONE Var will determine if done and hold key
while(!done){ //while done == 0
if (Button(&PORTA, MENU, 1, 0))
done = MENU;
if (Button(&PORTA, UP, 1, 0))
done = UP;
if (Button(&PORTA, DOWN, 1, 0))
done = DOWN;
}
return done; //Return our done/key var
}
void MainMenu(void){
unsigned char POS = 0; //Used for cursor ONLY!
unsigned char done = 0;
unsigned char x;
unsigned char ITEM=0;
unsigned char PAGE=0;
Lcd_Cmd(_LCD_CLEAR);
while(!done){
for(x=0;x<2;x++){
if(x == POS)
Lcd_Out((x+1),1,">");
else
Lcd_Out((x+1),1," ");
Lcd_Out((x+1),2,MainMenuLIST[(x+PAGE)]);
}
switch(WaitForInput()){
case UP:
if(POS>0){
POS--;
ITEM--;
} else {
if(PAGE>0){
POS++;
ITEM++;
PAGE=0;
}
}
break;
case DOWN:
if(POS<1){
POS++;
ITEM++;
} else {
if(PAGE<1){
PAGE = 1;
POS--;
ITEM--;
}
}
break;
case MENU:
done = 0xFF;
break;
}
}
// ITEM contains what item is selected
// POS isnt used incase larger then 2 menu...
ITEM+=PAGE;
switch(ITEM){
case 0:
Delay_ms(2000);
break;
case 1:
Delay_ms(2000);
break;
}
}
void main() {
CMCON |= 7; // Disable Comparators
TRISA = 0b00011100; // RA5,RA4,RA3,RA2 are set to input
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear LCD
Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off
Lcd_Out(1, 3, "Waiting");
do {
switch(WaitForInput()){
case MENU:
Delay_ms(100);
MainMenu();
break;
}
} while (1);
}
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 25th October 2009 at 06:55 PM. | |
| |
| | #81 |
|
hey i just edited the above code. Use the one with Code: //REV2
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #82 |
|
That last one now produces: ">Option A" "Option B" "Option B" ">Option C" so it misses Option B | |
| |
| | #83 |
|
i has to be your hardware then. I have that code working flawless in Proteus. Ill post a video... using mikroC pro and proteus to test it
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #84 |
|
I had a look and noticed there was no delay for switch presses I have now added in a delay for each press and it is working ![]() Thanks for all the help. | |
| |
| | #85 |
|
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #86 |
|
heh no problem you are right tho: Code: unsigned char WaitForInput(void){
unsigned char done = 0; //DONE Var will determine if done and hold key
while(!done){ //while done == 0
if (Button(&PORTA, MENU, 1, 0)){
Delay_ms(10);
done = MENU;
}
if (Button(&PORTA, UP, 1, 0)){
Delay_ms(10);
done = UP;
}
if (Button(&PORTA, DOWN, 1, 0)){
Delay_ms(10);
done = DOWN;
}
}
return done; //Return our done/key var
}
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #87 |
|
Yea thats how it now works with the delays
| |
| |
| | #88 |
|
just one more problem, when i combine it to my temp sensor code it waits for the button then wats ti read temp then there is delays in temp before it comes back round to wait for MENU to be pressed so you have to get the timing right when pressing it. here is the code: Code: do {
switch(WaitForInput()){
case MENU:
Delay_ms(100);
MainMenu();
break;
}
read_temp();
} while (1);
| |
| |
| | #89 |
|
The best way is with interrupts. But thats not my strong point heh you can ask around for that. I can barely do it in C18 i can imagin MikroC is simpler but i would have to learn it more
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #90 |
|
also interrupts are on PORTRB line.. If you want to test another way is to check the MENU button with the temp code itself. Like through in: Code: if (Button(&PORTA, MENU, 1, 0))
MainMenu();
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
|
| Tags |
| lcd, menu |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| LCD menu in C? | picstudent | Micro Controllers | 1 | 13th September 2009 04:48 AM |
| LCD+keypad interface -> menu structure. Concepts sought. Assembly. PIC. | astronomerroyal | Micro Controllers | 23 | 29th August 2008 04:59 AM |
| LG CRT Repair and servce menu. | dark666 | General Electronics Chat | 0 | 7th June 2008 06:17 PM |
| Electronic Music Menu | cyprio7 | General Electronics Chat | 0 | 11th April 2008 04:50 PM |
| One menu, multiple pages. Anyone good at websites? | ThermalRunaway | Chit-Chat | 6 | 25th June 2006 11:45 AM |