You call the function "Read_buttons()" and it returns an INT depending on the value of the lower 4 bits of (in this case) port B of a PIC18F2520.
The idea is you can have 4 buttons connected to the data line, these are fed from an inverting transistor connected to the control line 'EN' on the display, so when 'EN' is low, the buttons are active.
This works perfectly in the function seen below when in the main body of the code;
Code: Select all
int read_buttons(){
int temp_tris = 0x00;
int temp_portb = 0x00;
int button_result = 0x00;
LCD_RS = 0;
LCD_EN = 0;
LCD_D4 = 0;
LCD_D5 = 0;
LCD_D6 = 0;
LCD_D7 = 0;
LCD_RS_Direction = 0;
LCD_EN_Direction = 0;
LCD_D4_Direction = 0;
LCD_D5_Direction = 0;
LCD_D6_Direction = 0;
LCD_D7_Direction = 0;
button_result.b3 = LCD_D4 ;
button_result.b2 = LCD_D5 ;
button_result.b1 = LCD_D6 ;
button_result.b0 = LCD_D7 ;
latb = temp_portb;
trisb = temp_tris;
return button_result;
}
If I edit out the above code that was inline, then click the checkbox which appears in the 'Library manager' for LCD_Buttons - read_buttons, when I try to compile I get the 'read_buttons.c' box popping open in the code window and 12 errors stating 'Undeclared identifier LCD_RS' etc etc (6 for all I/O pins and 6 for TRIS) plus a host of errors such as 'operator '.' is not applicable to these operands 'button_result' etc etc etc.
Can someone help me see where I've gone wrong?
Thanks, Dave.