Help creating a simple C Library (Library manager)

Discuss with MikroElektronika software developers about current library development.
Post Reply
Author
Message
davegsm82
Posts: 156
Joined: 29 Mar 2011 20:35

Help creating a simple C Library (Library manager)

#1 Post by davegsm82 » 01 Dec 2015 18:15

I've been trying to get my head round the package manager but can't get it working, I want to create a new library entry which reads back the status of the LCD (HD44780) pins when data isn't being written to the screen.

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;
}

When I try to use the package installer I add 'Read_buttons.c' as the Main library file, then I add the 'Lcd' library as a dependency as it relies on the LCD data and tris pins so makes sense to have this as a dependency.

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.

User avatar
biljana.nedeljkovic
mikroElektronika team
Posts: 1043
Joined: 30 Jun 2015 15:15

Re: Help creating a simple C Library (Library manager)

#2 Post by biljana.nedeljkovic » 03 Dec 2015 16:29

Hello,

have you followed the instructions available at this link?
http://www.mikroe.com/download/eng/docu ... ibrary.htm

Also have you used Package Manager?
http://www.mikroe.com/package-manager/

You can try to include LCD pin declaration in your library as well.

Kind regards,
Biljana

Post Reply

Return to “Library Development Discussion”