Author Topic: HD7780 AVR Library  (Read 6047 times)

0 Members and 1 Guest are viewing this topic.

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17816
  • 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: 17816
  • 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: 17816
  • 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: 17816
  • 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: 17816
  • 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: 17816
  • 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.....
 

Offline 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: 17816
  • 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.
 

Offline 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: 17816
  • 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: 17816
  • 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: 3240
  • 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: 17816
  • 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: 17816
  • 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: 17816
  • 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: 17816
  • 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.....
 

Offline 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.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #25 on: November 01, 2017, 09:22:33 am »
well I've used it for some time but I've kept everything in the project folder which means it just works but then I am constantly copying stuff.
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: HD7780 AVR Library
« Reply #26 on: November 01, 2017, 10:17:21 am »
well I've used it for some time but I've kept everything in the project folder which means it just works but then I am constantly copying stuff.
This is why I prefer git submodules. Project folder does contain copies of dependencies for the sake of the complex IDEs and source distributions, but in the source control everything appears only once.
 

Offline alank2

  • Super Contributor
  • ***
  • Posts: 2185
Re: HD7780 AVR Library
« Reply #27 on: November 01, 2017, 12:02:56 pm »
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....

I hated AS7 when I first started using it.  Then I used Atollic TrueStudio and that takes confusing and non-intuitive to a whole new level.

Glad you got it working!
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #28 on: November 09, 2017, 08:46:37 am »
OK so I have the library working (well no more compilation errors involving it or my own headers and C files). I am writing my program but I don't see a way of putting a variable on the screen. Is there a way to do this? what I am trying to do is measure a sensor and then after some simple calculations that extract a meaningful number put that number on screen. I don't see this described in the instruction text, only how to "put character"
« Last Edit: November 09, 2017, 08:48:31 am by Simon »
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: HD7780 AVR Library
« Reply #29 on: November 09, 2017, 09:04:34 am »
OK so I have the library working (well no more compilation errors involving it or my own headers and C files). I am writing my program but I don't see a way of putting a variable on the screen. Is there a way to do this? what I am trying to do is measure a sensor and then after some simple calculations that extract a meaningful number put that number on screen. I don't see this described in the instruction text, only how to "put character"

Quite simply you use a function such as ftoa() or itoa() to convert a number to a string, and then print the string.  If you want to do fancy string formatting then use sprintf(), though be aware of the code size and run time overheads.

The other option is to add some optimised LCD print functions into your library to deal with numbers.
« Last Edit: November 09, 2017, 09:08:45 am by mikerj »
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #30 on: November 09, 2017, 09:14:26 am »
I see, what are the functions atof() and atoi() part of ? are they part of the GCC for AVR libraries ?


I'm also getting this error: character constant too long for its type
for: lcd_putc('Flow too LOW');
so I guess that was meant for one character at a time. that will be painful for one character at a time but doable
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #31 on: November 09, 2017, 09:21:04 am »
atof() and atoi()  seem to do the opposite, convert text to number format variables. I'll have a dig around
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: HD7780 AVR Library
« Reply #32 on: November 09, 2017, 10:55:34 am »
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #33 on: November 09, 2017, 11:29:25 am »
ok but how does printf() help with another function that does not know of it's existence? (My knowledge of C is limited), I'm going on the help file that tells me how to use the LCD library, if it's is not written to cope with my situation how do I get it to work with printf()
« Last Edit: November 09, 2017, 11:31:09 am by Simon »
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: HD7780 AVR Library
« Reply #34 on: November 09, 2017, 11:48:33 am »
atof() and atoi()  seem to do the opposite, convert text to number format variables. I'll have a dig around

ftoa() and itoa().  You must have read my post just after I submitted it as I accidentally put the wrong functions in and then edited it.

printf() calls a function putch() to output a character.  The default behaviour of putch() varies, but it can be overridden by defining your own version of putch().  This allows you to use printf to write to any character based device, but again you must be aware of the memory and runtime overhead of printf (and sprintf) which can be very significant on a small 8 bit micro, especially when working with floating point values.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #35 on: November 09, 2017, 12:18:38 pm »
Ah I see, I tried googling the variable to charachter but drew a blank, now have named those functiontions information is plentiful.

I have had a look through the source files for the library and think i have found a put string function that should do the trick and avoid me having to call putc many many times:

Code: [Select]
/*************************************************************************
Display string
Input:    string to be displayed
Returns:  none
*************************************************************************/
void lcd_puts(const char *s)
  {
    register char c;

    while ((c=*s++))
      lcd_putc(c);
  }
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: HD7780 AVR Library
« Reply #36 on: November 09, 2017, 12:19:07 pm »
You need to waste some time to learn

 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #37 on: November 09, 2017, 12:21:54 pm »
indeed which is one reason for doing this project in C instead of Arduino, I need to make something and don't quite know how to do it but it's an excuse to learn.

puts is not working as hoped.
 

Offline alank2

  • Super Contributor
  • ***
  • Posts: 2185
Re: HD7780 AVR Library
« Reply #38 on: November 09, 2017, 01:03:41 pm »
There are three functions (take a look in the H file):

void lcd_putc(char c);
void lcd_puts(const char *s);
void lcd_puts_P(const char *progmem_s);

lcd_putc is designed to put one character - lcd_putc('A');
lcd_puts is designed to put a null terminated string in sram to the display lcd_puts("Hello"); or lcd_puts(s1); where s1 is defined as char s1[20]; or similar.
lcd_puts_P is designed to put a null terminated string in flash to the display:

#include "avr/pgmspace.h"
const char MsgPounds                                                 [] PROGMEM = "Pounds";
lcd_puts_P(MsgPounds);

In the case of lcd_puts, you have to render the string first using a function like sprintf.  I typically create a global string like char s1[80]; or something and use it like this:
sprintf(s1,"%d",i1); //i1 is an integer
lcd_puts(s1);


You have to understand that the "%d" string above (3 bytes) is wasting your sram as well. That is why there is a sprintf_P function that allows you to replace the "%d" with a flash PROGMEM string:

const char MsgPercentUMinutes                                        [] PROGMEM = "%u Minutes";
sprintf_P(s1,MsgPercentUMinutes,15+currentsetting*15);
lcd_puts(s1);

Now the "%u Minutes" is in flash (taking no sram up), s1 is in sram and is reusable across many functions, and lcd_puts will put the results of s1 to the display.

Good luck!
« Last Edit: November 09, 2017, 01:06:59 pm by alank2 »
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #39 on: November 09, 2017, 01:07:04 pm »
aha, wrong type of quote marks.....
 

Offline alank2

  • Super Contributor
  • ***
  • Posts: 2185
Re: HD7780 AVR Library
« Reply #40 on: November 09, 2017, 01:11:57 pm »
Single quotes are for a character (or byte):

lcd_putc(65);
lcd_putc('A');  //same thing

Double quotes create a null terminated string:

lcd_puts("Hello");

becomes H e l l o <0> in memory, 5 bytes for each letter and 1 byte for the null terminator.  What is sent to the function is not the 6 bytes, but a pointer to the 6 bytes which is why it is defined as having a char* type argument.  The * means pointer.  char argument = single character, char* argument = pointer to one or more characters.

 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: HD7780 AVR Library
« Reply #41 on: November 09, 2017, 01:21:39 pm »
atof() and atoi()  seem to do the opposite, convert text to number format variables. I'll have a dig around

ftoa() and itoa().  You must have read my post just after I submitted it as I accidentally put the wrong functions in and then edited it.

printf() calls a function putch() to output a character.  The default behaviour of putch() varies, but it can be overridden by defining your own version of putch().  This allows you to use printf to write to any character based device, but again you must be aware of the memory and runtime overhead of printf (and sprintf) which can be very significant on a small 8 bit micro, especially when working with floating point values.
Depending on libc implementation, putch() may call something else further down the line. The version of newlib included in ARM's distribution of GCC chains the calls eventually to _write(). For my STM32 HD44780 driver library I just implemented _write (in fact I have the file handle mechanism and the call dispatcher in place, but still the same story) and calls to fprintf() or write() can go straight to the LCD.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: HD7780 AVR Library
« Reply #42 on: November 09, 2017, 04:35:58 pm »
well AS seems to quite like sprintf(s1,"%d",i1);
 

Offline alank2

  • Super Contributor
  • ***
  • Posts: 2185
Re: HD7780 AVR Library
« Reply #43 on: November 09, 2017, 04:39:37 pm »
well AS seems to quite like sprintf(s1,"%d",i1);

It will, but consider that "%d" is burning 3 bytes of sram AND flash when it really only needed to use 3 bytes of flash.  That is what the PROGMEM and _P version of the function allow.  Not a big deal for 3 bytes, but get an entire project full of constant strings and it becomes a big deal very quickly.
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: HD7780 AVR Library
« Reply #44 on: November 09, 2017, 06:29:18 pm »
well AS seems to quite like sprintf(s1,"%d",i1);

It will, but consider that "%d" is burning 3 bytes of sram AND flash when it really only needed to use 3 bytes of flash.  That is what the PROGMEM and _P version of the function allow.  Not a big deal for 3 bytes, but get an entire project full of constant strings and it becomes a big deal very quickly.

A clever linker can squash all identical constant strings into one instance. Although if your code contains a lot of different strings you still run out of resources fast.
 

Offline apurvdate

  • Contributor
  • Posts: 43
  • Country: in
Re: HD7780 AVR Library
« Reply #45 on: November 10, 2017, 12:12:40 pm »
There used to be a "Watch" or "Quick Watch" functionality in AS6. When in debug mode you can see value in watch window. Its a no go if u want real time value display though..
I hope its there in AS7 also. FYI I haven't used AS for 2 years...

edit: posted reply n then understood your query.. silly me  :palm:
« Last Edit: November 10, 2017, 12:16:31 pm by apurvdate »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8172
  • Country: fi
Re: HD7780 AVR Library
« Reply #46 on: November 11, 2017, 11:47:40 am »
HD44780 is a prime example of technology which is implemented so simply and in "directly usable" way that, usually, it takes a lot more time to find a library, find out how it works, assess whether it's usable at all (libraries often tend to be completely broken by design), and then, finally, be able to do something with it - than what it takes just to directly write your code - call it a library if you want, but it's usually just a few lines.

This is not surprising: HD44780 is an old school "bus" device that directly accepts data and just does what you tell it to do, so kinda plug&play. At that time, it wasn't common to think in the modern stupid "hardware abstraction middleware driver blah blah" way ;). With today's complexity often requiring that, we have forgotten it doesn't always need to be that way.

As a semi-noob, when I first time interfaced with HD44780 in 2005, I spent only one (1) HOUR to actually write everything myself. This is because HD44780 interfacing is about 10 to 20 lines of code, all extremely trivial and well documented. I found this a lot easier than basic MCU things like intializing an AVR timer/counter to produce PWM, which took several hours the first time to get right  ::).
« Last Edit: November 11, 2017, 11:51:13 am by Siwastaja »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf