Author Topic: HD7780 AVR Library  (Read 6023 times)

0 Members and 1 Guest are viewing this topic.

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
HD7780 AVR Library
« on: October 30, 2017, 09:48:14 am »
I had a look for a library for the HD44780 display on AVR and came across http://community.atmel.com/projects/hd44780-library but if I try and compile having linked the library I get told that -lhd44780.c can't be found even though the file is called hd44780.c and I can't see how to get round it, I'm also struggliung to get AS7 to put the file where the rest of my library files are in the project so I'm a bit confused. Has anyone used this library or are there any others that are properly documented that I can use without having to reverse engineer them first.

I could do what I want to do in arduino but I'm trying to do straight C (on the arduino board to save me the hassle of making something).
« Last Edit: October 30, 2017, 09:57:18 am by Simon »
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: HD7780 AVR Library
« Reply #1 on: October 30, 2017, 10:00:23 am »
How did you declare?
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #2 on: October 30, 2017, 10:01:40 am »
As described I included the header file and added the C to my project
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #3 on: October 30, 2017, 10:03:17 am »
Code: [Select]
#define CPU_F 16000000UL //Processor frequency in Hz, amend as appropriate.

#include "atmega328.h"
#include "hd44780.h"
#include "hd44780_settings.h"


int main(void)
{

    while(1)
    {
        //TODO:: Please write your application code
    }
}

the "C" file is listed under "solution items"
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: HD7780 AVR Library
« Reply #4 on: October 30, 2017, 10:03:43 am »
You need to do something like that

#include "yourlib.h"

This will not work

#include <yourlib.h>
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: HD7780 AVR Library
« Reply #5 on: October 30, 2017, 10:06:02 am »
Are you using Atmel studio?
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #6 on: October 30, 2017, 10:08:38 am »
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: HD7780 AVR Library
« Reply #7 on: October 30, 2017, 10:10:53 am »
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #8 on: October 30, 2017, 10:39:55 am »
Yes I already had the path setup as i already have a body of custom libraries of my own there. It's this one in particular that is not playing ball and the first time I try to use a library that is not mine.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #9 on: October 30, 2017, 12:52:32 pm »
This is just not working, I have tried setting a path for all of my header files and have put the address of these into anything I can find in the toolchain that wants custom locations and still nothing. It's nuts, it feels like one of those things made over complicated for no reason, it's pretty simple really, I have some files in this location that I'd like the program to know about but it ignores them just the same.....
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: HD7780 AVR Library
« Reply #10 on: October 30, 2017, 03:18:13 pm »
[...]I get told that -lhd44780.c can't be found even though the file is called hd44780.c [...]
It would seem that the source file has been added to the project as a library, and the linker is trying to directly link "hd44780.c" to the binary.
That's doomed to fail, even if it could find the file in its libraries paths.

Remove the file from the project, and add it back again as a regular source file.
It will then be compiled to an object and linked as the other source files are.
(Maybe clean up the other paths/options that have been modified).

HTH

Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: HD7780 AVR Library
« Reply #11 on: October 30, 2017, 08:08:38 pm »
If the library is given to you as source files (instead of a separate library project or target) you should drop them into your project along with other project files. (Personally I create one folder for each source-style library I used.)
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #12 on: October 30, 2017, 09:43:16 pm »
Yes the thing is that it won't work like that, as i am working from a constant template I decided to do as suggested in the video above and use the master copy as the one location for all my libraries (C and H files) but now nothing works it's a right mess and I'm very unimpressed with atmel studio as frankly i feel I've got it right.
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: HD7780 AVR Library
« Reply #13 on: October 30, 2017, 10:30:27 pm »
Yes the thing is that it won't work like that, as i am working from a constant template I decided to do as suggested in the video above and use the master copy as the one location for all my libraries (C and H files) but now nothing works it's a right mess and I'm very unimpressed with atmel studio as frankly i feel I've got it right.
This is likely a Visual Studio problem, not just an Atmel Studio problem.

Personally I think this is where the submodule feature in git comes in handy. In the central storage there is one repository for each template and each optional library. Each instance of the template and the libraries are their own set of files in local project folders, yet they are tagged and referenced by version only instead of copied in the central storage. Something like the following:

Code: [Select]
git init
git submodule add git://git.maxcrib.info/cmsis.git cmsis
git submodule add git://git.maxcrib.info/startup-stm32f303.git platform
git submodule add git://git.maxcrib.info/libusb_stm32.git contrib/libusb_stm32

After this I get three submodules in my project folder. They can be used as if they are local files.
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: HD7780 AVR Library
« Reply #14 on: October 30, 2017, 11:14:56 pm »
Quote
This is likely a Visual Studio problem, not just an Atmel Studio problem.
Let's say it's the way VS works. There is no real problem here with VS, and also Eclipse is very similar.
The real issue is that the video shows only how to add include paths, as the  "library" the YouTuber was using had to be included as a .c file; why would one want to do that is beyond me, in the general case, but maybe it's an Arduinish thing. :-//

If that were the case, everything would have worked.

The library Simon is using is provided instead as a set of include (.h) and source (.c) files, as most sane reusable C code is.
There are clear usage instructions on the library site.

In some cases the library can be pre-compiled (to a .a or .lib file, using a separate project), the includes placed in the common include directory and the library added to the Libs folder, since I see a setting.h file, I would expect this is not an option.

What's impossible to do is linking a .c as a compiled library: probably something has been messed up in the various attempts made, hence my suggestion to start over.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: HD7780 AVR Library
« Reply #15 on: October 31, 2017, 04:03:40 am »
Quote
This is likely a Visual Studio problem, not just an Atmel Studio problem.
Let's say it's the way VS works. There is no real problem here with VS, and also Eclipse is very similar.
Eclipse will pick up files dropped into project folder directly with a quick refresh in the project explorer. Way too often I just create the project and dropping in a few submodules before start coding.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #16 on: October 31, 2017, 12:45:51 pm »
Quote
This is likely a Visual Studio problem, not just an Atmel Studio problem.
Let's say it's the way VS works. There is no real problem here with VS, and also Eclipse is very similar.
The real issue is that the video shows only how to add include paths, as the  "library" the YouTuber was using had to be included as a .c file; why would one want to do that is beyond me, in the general case, but maybe it's an Arduinish thing. :-//

If that were the case, everything would have worked.

The library Simon is using is provided instead as a set of include (.h) and source (.c) files, as most sane reusable C code is.
There are clear usage instructions on the library site.

In some cases the library can be pre-compiled (to a .a or .lib file, using a separate project), the includes placed in the common include directory and the library added to the Libs folder, since I see a setting.h file, I would expect this is not an option.

What's impossible to do is linking a .c as a compiled library: probably something has been messed up in the various attempts made, hence my suggestion to start over.


I tried putting the files in the same location as the rest of my libraries and including them as i normally do but AS7 would not play ball. So after the advice here i setup a path to a seperate libraries folder and now my existing .h files cannot be found, I don't think there is anything wrong with the library, it looks more like AS7 does not want to work. I have told the program where to find libraries, I have tried <file.h> and "file.h" but neither work.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #17 on: October 31, 2017, 09:40:13 pm »
Can anyone recommend another free AVR IDE, Atmel studio seems over complicated with 0 documentation, in brief i have had enough, i used it stupidly and it worked, now i try to use it intelligently and it won't work, clear conclusion, stupid program......
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3238
  • Country: gb
Re: HD7780 AVR Library
« Reply #18 on: October 31, 2017, 10:24:19 pm »
Yes the thing is that it won't work like that, as i am working from a constant template I decided to do as suggested in the video above and use the master copy as the one location for all my libraries (C and H files) but now nothing works it's a right mess and I'm very unimpressed with atmel studio as frankly i feel I've got it right.

The point you are missing is that you don't have a library file, yet you are telling the linker to include it as a library file.  This is neither an Atmel or a Visual Studio problem.

A library file is an object file, it's pre-compiled code in a handy single file that the linker can use.  You have source code, so you have to add it to your project as such.
 
The following users thanked this post: Ian.M, newbrain

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #19 on: October 31, 2017, 10:30:49 pm »
right so when i do

Code: [Select]
#include <header.h>

or

Code: [Select]
#include "header.h"

what am I doing? and where are these files supposed to be and how i i tell it a fixed location of my choice? why can't hd44780.c be found when ir has been added ? or atmega328.h be found when it is included ?
 

Offline alank2

  • Super Contributor
  • ***
  • Posts: 2185
Re: HD7780 AVR Library
« Reply #20 on: November 01, 2017, 03:36:03 am »
This is actually my library from a few years ago.

In AVR Studio 7 just right click the project name (below the solution, above Dependencies in the Solution Explorer) and choose Add -> Existing (Shift-Alt-A) and add hd44780.c to the project.  It will then show up as one of the .c filenames along probably main.c and any others you have.  You can use it by #include "hd4780.h" in any C files that you want to be able to call functions to it from.  Make sure you copy hd44780_settings_example.h --> hd44780_settings.h and alter its settings for the ports/pins/configuration you need.

You don't need to #include the hd44780_settings.h, the #include "hd44780.h" will do it for you.

It is a "library" in that it a code to do a particular task, in this case control an hd44780 type display.  It is not compiled into a .lib or anything like that.  hd44780.c is the source code and would need to be added to your project like other source code would be.
« Last Edit: November 01, 2017, 03:39:56 am by alank2 »
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #21 on: November 01, 2017, 06:55:55 am »
Ok, well congratulations on the documentation, many don't bother. This has turned into a problem of how do I manage all of my reusable code without copying it into each new project. Added to the fact I use 2 computers and Dropbox but the paths are identical anyway.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #22 on: November 01, 2017, 07:46:56 am »
Yes and if I "add existing" it still can't find it! this is stupid, and IDE is supposed to make life easier, this is just being so complicated it defeats the object....
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #23 on: November 01, 2017, 07:48:53 am »
ok working now.....
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: HD7780 AVR Library
« Reply #24 on: November 01, 2017, 09:19:58 am »
 :-+
Glad to hear it's working.
Complex IDEs are...well, complex.
Especially if one is coming from the Arduino not-really-an-IDE toy (but it has its merits, for a complete beginner), there's some learning curve.

I'm at ease with VS (and derived, as Atmel Studio), and even know a good number of Open Source advocates that like it over other alternatives: it's a very powerful tool, well organized and helpful, while I find all Eclipse derived stuff confusing.

That said, IDEs are a very personal choice.
If one wants a lighter, simpler but at the same time powerful enough alternative, setting up VS Code (or Sublime Text or Atom, though I never tried these two) for your specific development is not overly complicated.
Nandemo wa shiranai wa yo, shitteru koto dake.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf