avr-gcc-list
[Top][All Lists]

## Re: [avr-gcc-list] Trick for creating WYSIWYG bitmaps in C [was: how to

 From: Derric Tubbs Subject: Re: [avr-gcc-list] Trick for creating WYSIWYG bitmaps in C [was: how to specifiy a binary constant] Date: Thu, 22 Sep 2005 20:48:38 -0700 (PDT)

```Firstly, everyone needs to know about tinyurl.com,
which allows you to send a tiny URL like
http://tinyurl.com/92eaj to point to long URLs (open
this one and you'll see it that takes you to a book on
Amazon.com that I'm about to refer to).

Secondly, I got this little trick from the book that
the link above points to, the book is called "Expert C
Programming".  Anyhow for an 8 bit LCD bitmap like
Vincent mentioned below, do the following:

#define X )*2+1
#define _ )*2
#define s ((((((((0 /* 8 parens for 8 bit, 16 for 16,
etc) */

Then you just "draw" your bitmap as such:

uint8_t lcd_char_P[] =
{
sXXXXXX__,
sX_____X_,
sX______X,
sX_____X_,
sXXXXXX__,
sX_______,
sX_______,
sX_______
}

and then make sure you undef the X,s, and _.  Now
doesn't that look like a big P right in your code ;)

Pretty cool little trick.  Kind of extravegant but
something similar to this sure would have made things
clearer when I was looking at some code that defined
characters on a graphic LCD the other day ;)

Tubbs

--- Vincent Trouilliez

> On Thu, 2005-09-22 at 18:00 -0700, Derric Tubbs
> wrote:
> > I believe the original poster said he was new to
> > programming.  If so, just remember that each hex
> digit
> > represents four binary bits/digits with decimal
> values
> > of 0-15.  It won't take long at all to get where
> > reading hex, both for decimal value and bit
> pattern,
> > happens without thinking about it.
>
> Yeah I am fairly new to C programming (only one year
> epxerience, on
> Microchip PIC's...and that was 5 years ago !), but
> not to electronics
> engineering, so I have long got the hang of Hex
> notation ;-)
>
> > Is there some reason you can't specify your
> constant
> > as hex?
>
> It's not that I can't, it' just that in some cases,
> a binary notation is
> natural, and a hex one doesn't make sense.
>
> Typical example is when I want to define a few
> custom characters for a
> text LCD module. if you use a binary notation, it
> actually gives you a
> very convenient visual representation of each
> character, since one bit
> represents a pixel, and one byte represents one row
> for one character.
> So you can very easily define the characters,
> whereas if using a hex
> notation, it's a nightmare to define the characters,
> and you can't check
> them visually for correctness, and making
> corrections is awkward.
> That's just an example.
>
>
>
> On Thu, 2005-09-22 at 20:03 -0500, David Kelly
> wrote:
> > We may make a FreeBSD user out of you yet.
>
> Not a ray of hope in the current state of things ;-)
> I happen to have
> eventually found the perfect Linux distro for me, so
> they would have to
> go seriously wrong for to consider the hassle of
> changing 'home' ;-) ...
>
>
> > Joerg included a/the patch for binary constants in
> the FreeBSD Ports
> > version of avr-gcc, which he maintains.
> >
> Oh, I wonder what we would become without Joerg.
> Thank you for the patch
> Herr Joerg :-)
>
>
> > If this long URL survives then it will download
> the patch. You are  a
> > Linux user so you have lots of practice applying
> patches, right?  :-)
> >
> >
> You said it, I am Linux "user", not developper !!
> ;o)
> I did once try to apply a patch to some program, but
> I failed miserably,
> both because I couldn't find anywhere on the web the
> exact command line
> to use, all where suggesting different options, and
> also because the
> source code I had didn't exactly match what the
> patch was expecting.
> Tried to apply the patch by hand, but the patch and
> source code were so
> different, I really didn't know what to do with the
> patch.
> >
> I guess I will just take the easy route, and wait
> patiently for the
> patch to make it into the next stable release of
> gcc-avr ;-)
>
>
>
> --
> Vince
>
>
>
> _______________________________________________
> AVR-GCC-list mailing list