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.

Reusing library from arduino to another mcu

Status
Not open for further replies.

MacIntoshCZ

Active Member
Hi,
i would like to reuse library for 1602 display in non-arduino project.
My first question is what are those hex values written after defining function in library file .h?
1619887665900.png

So far i need only to change lines which are using command from Arduino.h library am i right?
1619887874280.png

Its better to use already writed library but this is just for learning purpose.
 
#define Places an identifier instead of the binary command... ie.. Send 0x1 to the display and it clears the display and sets the cursor to home.

Then instead of remembering the code in binary.
LCD_COMMAND(0x01);
you can use English ( or whatever you like )
LCD_COMMAND(LCD_CLEARDISPLAY); make it more readable..
 
#define Places an identifier instead of the binary command... ie.. Send 0x1 to the display and it clears the display and sets the cursor to home.

Then instead of remembering the code in binary.
LCD_COMMAND(0x01);
you can use English ( or whatever you like )
LCD_COMMAND(LCD_CLEARDISPLAY); make it more readable..
Thanks i forgot that. Now i remember.
 
Can i redefine something in main.c? There are defined ports in HD44780_settings.h . If i use #define again in main.c will it overwrite it? I
1619968837911.png
 
No... When you define a variable its not possible to redefine.. You can, however, define two lables to one constant..

BUT!! I think it has to be global...
What compiler routine looks like? Does compiler check for #define in main.c first? If so i could change define to ifndef?
 
I just want to assign mcu pins to lcd pins. Is better to setup port in main.c or in added library?
I though that this library has as default assigned pins on port D and i can redefin them.
 
What undefined reference means?
I included "HD44780.h" which cointains these functions.

1620036020943.png

Its MIT licence so i gues i can upload it here. I have these files in my project folder. Even Atmel studio itself shows help when writing these functions.
 

Attachments

  • HD44780.c
    11.9 KB · Views: 217
  • HD44780.h
    2.6 KB · Views: 209
  • HD44780_Settings.h
    1.3 KB · Views: 243
  • IO_Macros.h
    1.9 KB · Views: 223
Last edited:
Okay!...

#include "HD44780.H" implies that the header and C file are in the same directory as your "main" C file..

Also make sure HD44780.C is in the build.. I'm not familiar with your IDE so I need to understand what the linker is doing... BUT!! this error is weird, because if the header cant be found, a different error would occur.

What compile are you using?
 
In the HD44780.C there are a number of incorrect lines... Arduino specific functions... Including digitalWrite(); and bitCheck();

This makes me believe that the C file isn't being compiled..
I though that was corrected with IO_macros.h
 
#include "HD44780.H" implies that the header and C file are in the same directory as your "main" C file..
yes they are in same folder
Also make sure HD44780.C is in the build..
Ok i will check that.

I believe its avr-gcc becouse of build output
....Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe.....
invoking: AVR/GNU C Compiler : 5.4.0
 
This is weird. On new project i added util/delay.h library and it says F_CPU is not defined. With added #define in main.c it says its redefined
I dont think its supposed to edit cpu frequency in delay.h.
1620047378910.png

location of previous definition:
1620047526229.png

Is this just for calculations?
 
Ok i think i know why its not working. The reason is becouse its not working.
Atmel STUDIO is dead. It disapears from internet. You cant download it anymore (i mean officialy, but there are old version still avaible in microchip archives). On one forum i found it stops working with one W10 update and they just close it.
nice...
What i should use for AVR then? Visual studio code and link compiler?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top