Discussion:
[avr-gcc-list] Syntax : how to specifiy a binary constant ?
Vincent Trouilliez
2005-09-22 23:03:27 UTC
Permalink
Hi list,


I am very new to C, and I can't find how to specify a binary constant.

I tried for example

foo = 0b11110000;

or

foo = b11110000;

but neither worked...


I am using gcc-avr 3.4.3 and avr-libc 1.2.3....


Regards,


--
Vince
Parthasaradhi Nayani
2005-09-22 23:26:46 UTC
Permalink
Hello,

GCC 3.4.3 must work for

foo = 0b11110000;
OR
foo = 0B11110000;

Are you getting compilation errors?

Nayani
Post by Vincent Trouilliez
I tried for example
foo = 0b11110000;
or
foo = b11110000;
but neither worked...
I am using gcc-avr 3.4.3 and avr-libc 1.2.3....
Regards,
--
Vince
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Vincent Trouilliez
2005-09-23 00:26:14 UTC
Permalink
Post by Parthasaradhi Nayani
GCC 3.4.3 must work for
foo = 0b11110000;
OR
foo = 0B11110000;
Are you getting compilation errors?
Nayani
Hi Nayani,

Yes, I get a compiler error in both cases.

About foo = 0b1111000; or foo = 0B11110000; it says :

main.c:92:9: invalid suffix "b11110000" on integer constant

...and about foo = b11110000; it says:

main.c:92: error: `b11110000' undeclared (first use in this function)



Regards,


--
Vince
Christopher X. Candreva
2005-09-23 00:59:52 UTC
Permalink
Post by Vincent Trouilliez
Yes, I get a compiler error in both cases.
main.c:92:9: invalid suffix "b11110000" on integer constant
main.c:92: error: `b11110000' undeclared (first use in this function)
I am fairly certain binary constants don't work, and I don't recall why.

==========================================================
Chris Candreva -- ***@westnet.com -- (914) 967-7816
WestNet Internet Services of Westchester
http://www.westnet.com/
David Kelly
2005-09-23 01:03:05 UTC
Permalink
Post by Vincent Trouilliez
Hi Nayani,
Yes, I get a compiler error in both cases.
main.c:92:9: invalid suffix "b11110000" on integer constant
main.c:92: error: `b11110000' undeclared (first use in this function)
We may make a FreeBSD user out of you yet.

Joerg included a/the patch for binary constants in the FreeBSD Ports
version of avr-gcc, which he maintains.

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? :-)

http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/ports/devel/avr-gcc/
files/patch-binary-constants?rev=1.3&content-type=text/plain

If the long URL doesn't work then start from this one, click on
"files/", then "patch-binary-constants", and the "download" link on
Revision 1.3.

Patch your avr-gcc and recompile/install.

In other words I'm also saying, "Stock gcc does not support binary
constants."

--
David Kelly N4HHE, ***@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.
Alex Wenger
2005-09-23 06:46:37 UTC
Permalink
Hi,
Post by Parthasaradhi Nayani
GCC 3.4.3 must work for
foo = 0b11110000;
OR
foo = 0B11110000;
I use a small header-file and the notation b11110000.


bin.h:

#define b00000000 0x00
#define b00000001 0x01
#define b00000010 0x02
#define b00000011 0x03
#define b00000100 0x04
#define b00000101 0x05
#define b00000110 0x06
#define b00000111 0x07
#define b00001000 0x08
#define b00001001 0x09
#define b00001010 0x0a
#define b00001011 0x0b
#define b00001100 0x0c
#define b00001101 0x0d
#define b00001110 0x0e
#define b00001111 0x0f
#define b00010000 0x10
#define b00010001 0x11
#define b00010010 0x12
#define b00010011 0x13
#define b00010100 0x14
#define b00010101 0x15
#define b00010110 0x16
#define b00010111 0x17
#define b00011000 0x18
#define b00011001 0x19
#define b00011010 0x1a
#define b00011011 0x1b
#define b00011100 0x1c
#define b00011101 0x1d
#define b00011110 0x1e
#define b00011111 0x1f
#define b00100000 0x20
#define b00100001 0x21
#define b00100010 0x22
#define b00100011 0x23
#define b00100100 0x24
#define b00100101 0x25
#define b00100110 0x26
#define b00100111 0x27
#define b00101000 0x28
#define b00101001 0x29
#define b00101010 0x2a
#define b00101011 0x2b
#define b00101100 0x2c
#define b00101101 0x2d
#define b00101110 0x2e
#define b00101111 0x2f
#define b00110000 0x30
#define b00110001 0x31
#define b00110010 0x32
#define b00110011 0x33
#define b00110100 0x34
#define b00110101 0x35
#define b00110110 0x36
#define b00110111 0x37
#define b00111000 0x38
#define b00111001 0x39
#define b00111010 0x3a
#define b00111011 0x3b
#define b00111100 0x3c
#define b00111101 0x3d
#define b00111110 0x3e
#define b00111111 0x3f
#define b01000000 0x40
#define b01000001 0x41
#define b01000010 0x42
#define b01000011 0x43
#define b01000100 0x44
#define b01000101 0x45
#define b01000110 0x46
#define b01000111 0x47
#define b01001000 0x48
#define b01001001 0x49
#define b01001010 0x4a
#define b01001011 0x4b
#define b01001100 0x4c
#define b01001101 0x4d
#define b01001110 0x4e
#define b01001111 0x4f
#define b01010000 0x50
#define b01010001 0x51
#define b01010010 0x52
#define b01010011 0x53
#define b01010100 0x54
#define b01010101 0x55
#define b01010110 0x56
#define b01010111 0x57
#define b01011000 0x58
#define b01011001 0x59
#define b01011010 0x5a
#define b01011011 0x5b
#define b01011100 0x5c
#define b01011101 0x5d
#define b01011110 0x5e
#define b01011111 0x5f
#define b01100000 0x60
#define b01100001 0x61
#define b01100010 0x62
#define b01100011 0x63
#define b01100100 0x64
#define b01100101 0x65
#define b01100110 0x66
#define b01100111 0x67
#define b01101000 0x68
#define b01101001 0x69
#define b01101010 0x6a
#define b01101011 0x6b
#define b01101100 0x6c
#define b01101101 0x6d
#define b01101110 0x6e
#define b01101111 0x6f
#define b01110000 0x70
#define b01110001 0x71
#define b01110010 0x72
#define b01110011 0x73
#define b01110100 0x74
#define b01110101 0x75
#define b01110110 0x76
#define b01110111 0x77
#define b01111000 0x78
#define b01111001 0x79
#define b01111010 0x7a
#define b01111011 0x7b
#define b01111100 0x7c
#define b01111101 0x7d
#define b01111110 0x7e
#define b01111111 0x7f
#define b10000000 0x80
#define b10000001 0x81
#define b10000010 0x82
#define b10000011 0x83
#define b10000100 0x84
#define b10000101 0x85
#define b10000110 0x86
#define b10000111 0x87
#define b10001000 0x88
#define b10001001 0x89
#define b10001010 0x8a
#define b10001011 0x8b
#define b10001100 0x8c
#define b10001101 0x8d
#define b10001110 0x8e
#define b10001111 0x8f
#define b10010000 0x90
#define b10010001 0x91
#define b10010010 0x92
#define b10010011 0x93
#define b10010100 0x94
#define b10010101 0x95
#define b10010110 0x96
#define b10010111 0x97
#define b10011000 0x98
#define b10011001 0x99
#define b10011010 0x9a
#define b10011011 0x9b
#define b10011100 0x9c
#define b10011101 0x9d
#define b10011110 0x9e
#define b10011111 0x9f
#define b10100000 0xa0
#define b10100001 0xa1
#define b10100010 0xa2
#define b10100011 0xa3
#define b10100100 0xa4
#define b10100101 0xa5
#define b10100110 0xa6
#define b10100111 0xa7
#define b10101000 0xa8
#define b10101001 0xa9
#define b10101010 0xaa
#define b10101011 0xab
#define b10101100 0xac
#define b10101101 0xad
#define b10101110 0xae
#define b10101111 0xaf
#define b10110000 0xb0
#define b10110001 0xb1
#define b10110010 0xb2
#define b10110011 0xb3
#define b10110100 0xb4
#define b10110101 0xb5
#define b10110110 0xb6
#define b10110111 0xb7
#define b10111000 0xb8
#define b10111001 0xb9
#define b10111010 0xba
#define b10111011 0xbb
#define b10111100 0xbc
#define b10111101 0xbd
#define b10111110 0xbe
#define b10111111 0xbf
#define b11000000 0xc0
#define b11000001 0xc1
#define b11000010 0xc2
#define b11000011 0xc3
#define b11000100 0xc4
#define b11000101 0xc5
#define b11000110 0xc6
#define b11000111 0xc7
#define b11001000 0xc8
#define b11001001 0xc9
#define b11001010 0xca
#define b11001011 0xcb
#define b11001100 0xcc
#define b11001101 0xcd
#define b11001110 0xce
#define b11001111 0xcf
#define b11010000 0xd0
#define b11010001 0xd1
#define b11010010 0xd2
#define b11010011 0xd3
#define b11010100 0xd4
#define b11010101 0xd5
#define b11010110 0xd6
#define b11010111 0xd7
#define b11011000 0xd8
#define b11011001 0xd9
#define b11011010 0xda
#define b11011011 0xdb
#define b11011100 0xdc
#define b11011101 0xdd
#define b11011110 0xde
#define b11011111 0xdf
#define b11100000 0xe0
#define b11100001 0xe1
#define b11100010 0xe2
#define b11100011 0xe3
#define b11100100 0xe4
#define b11100101 0xe5
#define b11100110 0xe6
#define b11100111 0xe7
#define b11101000 0xe8
#define b11101001 0xe9
#define b11101010 0xea
#define b11101011 0xeb
#define b11101100 0xec
#define b11101101 0xed
#define b11101110 0xee
#define b11101111 0xef
#define b11110000 0xf0
#define b11110001 0xf1
#define b11110010 0xf2
#define b11110011 0xf3
#define b11110100 0xf4
#define b11110101 0xf5
#define b11110110 0xf6
#define b11110111 0xf7
#define b11111000 0xf8
#define b11111001 0xf9
#define b11111010 0xfa
#define b11111011 0xfb
#define b11111100 0xfc
#define b11111101 0xfd
#define b11111110 0xfe
#define b11111111 0xff
Vincent Trouilliez
2005-09-23 07:19:03 UTC
Permalink
Post by Alex Wenger
I use a small header-file and the notation b11110000.
#define b00000000 0x00
#define b00000001 0x01
.....
#define b11111111 0xff
Simple, but clever :-)
Thanks for posting the entire table, that will save me the work, I will
just copy/paste it! :o)))


--
Vince, very lazy
Joerg Wunsch
2005-09-23 09:10:33 UTC
Permalink
Post by David Kelly
We may make a FreeBSD user out of you yet.
:-)
Post by David Kelly
Joerg included a/the patch for binary constants in the FreeBSD Ports
version of avr-gcc, which he maintains.
Just for the record, I meanwhile filed it for official inclusion:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23479
--
cheers, J"org .-.-. --... ...-- -.. . DL8DTL

http://www.sax.de/~joerg/ NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
Derric Tubbs
2005-09-23 01:00:23 UTC
Permalink
I may be wrong but I'm going to venture a guess here
that you can't write a binary literal in C. I tried a
simple example with the syntax mentioned here on
standard GCC (non-AVR) and got the same error
mentioned. I also looked around the net and found
nothing about how to do so.

It seems I remember seeing in one language or another
that you COULD represent binary literals but I've
tinkered in so many who knows which it was. Probably
Ada.

Is there some reason you can't specify your constant
as hex? Hex is always a safe bet and is almost always
represented the same way in all languages.

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.

HTH,
Tubbs

--- Vincent Trouilliez
Post by Vincent Trouilliez
Post by Parthasaradhi Nayani
GCC 3.4.3 must work for
foo = 0b11110000;
OR
foo = 0B11110000;
Are you getting compilation errors?
Nayani
Hi Nayani,
Yes, I get a compiler error in both cases.
About foo = 0b1111000; or foo = 0B11110000; it says
main.c:92:9: invalid suffix "b11110000" on integer
constant
main.c:92: error: `b11110000' undeclared (first use
in this function)
Regards,
--
Vince
_______________________________________________
AVR-GCC-list mailing list
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Vincent Trouilliez
2005-09-23 01:49:11 UTC
Permalink
Post by Derric Tubbs
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 ;-)
Post by Derric Tubbs
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.
Post by Derric Tubbs
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' ;-) ...
Post by Derric Tubbs
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 :-)
Post by Derric Tubbs
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
Rolf Ebert
2005-09-23 12:46:16 UTC
Permalink
Post by Derric Tubbs
It seems I remember seeing in one language or another
that you COULD represent binary literals but I've
tinkered in so many who knows which it was. Probably
Ada.
Yes, Ada has binary literals. (I am not sure, but I think it has literals
in any base up to base 36, strange....)

2#0101_1010# == 16#5A# == 10#90#

Rolf
Parthasaradhi Nayani
2005-09-23 01:32:09 UTC
Permalink
Hello Vincent,

I have seen the other responses to this thread. One
can use binary values in AVR GCC 3.4.3. In fact I had
used the same in some of my projects and I am not able
to make a guess on why you are getting an error. Just
a guess, have you typed zeros correctly in the
original code? (by mistake o is not typed in place of
0???)

Nayani


--- Vincent Trouilliez >
Post by Vincent Trouilliez
Yes, I get a compiler error in both cases.
About foo = 0b1111000; or foo = 0B11110000; it says
main.c:92:9: invalid suffix "b11110000" on integer
constant
main.c:92: error: `b11110000' undeclared (first use
in this function)
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
Vincent Trouilliez
2005-09-23 01:54:20 UTC
Permalink
One can use binary values in AVR GCC 3.4.3.
In fact I had used the same in some of my projects
and I am not able to make a guess on why you are
getting an error.
So the patch is already in 3.4.3 ? So I should have it then !!
GRRRR !!!! :-/
MAybe the debian package is faulty in some way (just like it appears nt
to have the "gdwarf-2" or something, option enabled !
I will try removing the package, and compiling it from source.
Just a guess, have you typed zeros correctly in the
original code? (by mistake o is not typed in place of
0???)
Yep, I made triple sure that I type ZEEEERO, BEEEEE, one one one one
zero zero zero zero, ... still no luck, ah well...


--
Vince
Kitts
2005-09-23 03:31:29 UTC
Permalink
On Friday 23 Sep 2005 7:24 am IST, Vincent Trouilliez wrote:

VT> > One can use binary values in AVR GCC 3.4.3.
VT> > In fact I had used the same in some of my projects
VT> > and I am not able to make a guess on why you are
VT> >  getting an error.
VT>
VT> So the patch is already in 3.4.3 ? So I should have it then !!
VT> GRRRR !!!! :-/
VT> MAybe the debian package is faulty in some way (just like it appears nt
VT> to have the "gdwarf-2" or something, option enabled !
VT> I will try removing the package, and compiling it from source.

You are right. the debian packages do not contain these patches. They are
not patched to generate the COFF debug patch either.

I recently built myselt the tool chain of avr-gcc, avr-libc, avr-binutils
and avrdude. I have generated .deb packages that i can share with you.
These should support binary constants and COFF debug info.
--
Cheers!
Kitts
Derric Tubbs
2005-09-23 03:48:38 UTC
Permalink
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
Post by Derric Tubbs
I believe the original poster said he was new to
programming. If so, just remember that each hex
digit
Post by Derric Tubbs
represents four binary bits/digits with decimal
values
Post by Derric Tubbs
of 0-15. It won't take long at all to get where
reading hex, both for decimal value and bit
pattern,
Post by Derric Tubbs
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 ;-)
Post by Derric Tubbs
Is there some reason you can't specify your
constant
Post by Derric Tubbs
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
Post by Derric Tubbs
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' ;-) ...
Post by Derric Tubbs
Joerg included a/the patch for binary constants in
the FreeBSD Ports
Post by Derric Tubbs
version of avr-gcc, which he maintains.
Oh, I wonder what we would become without Joerg.
Thank you for the patch
Herr Joerg :-)
Post by Derric Tubbs
If this long URL survives then it will download
the patch. You are a
Post by Derric Tubbs
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
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Vincent Trouilliez
2005-09-23 04:30:27 UTC
Permalink
Post by Derric Tubbs
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
WOW, amazing !!! Derric, you are a star ;-)

I have already archived your mail in a very safe place :o)
It's even better than binary constants, as an 'X' stands out a lot more
next to an '_' than a '1' does next to a '0' !
I think there should be an award on this list: every year, we vote for
the most useful, strange, incredible, or whatever, post of the year.
Winner wins, I don't know, an ATmegaXXX of his choice or
something ?! :o)


--
Vince, lost in Farnell.fr trying to identify the perfect graphics LCD...
it's a jungle of datasheets and specs...
Bob Paddock
2005-09-23 14:09:38 UTC
Permalink
I thought I'd try this bitmap 'trick' via copy&paste of the
#defines and code into the file I was working on, this is what I get:

Name/name.c:692: error: `sXXXXXX__' undeclared here (not in a function)
Name/name.c:692: error: initializer element is not constant
Name/name.c:692: error: (near initialization for `lcd_char_P[0]')
Name/name.c:693: error: `sX_____X_' undeclared here (not in a function)
Name/name.c:693: error: initializer element is not constant
[snip rest of the bitmap erros]

Is this 'trick' compiler or compiler option dependent?

This is usually the problem with 'tricks' they come back and
bite you at some point.
Post by Derric Tubbs
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
#define X )*2+1
#define _ )*2
#define s ((((((((0 /* 8 parens for 8 bit, 16 for 16,
etc) */
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 ;)
Dave Hansen
2005-09-23 14:42:42 UTC
Permalink
Post by Bob Paddock
I thought I'd try this bitmap 'trick' via copy&paste of the
Name/name.c:692: error: `sXXXXXX__' undeclared here (not in a function)
Name/name.c:692: error: initializer element is not constant
Name/name.c:692: error: (near initialization for `lcd_char_P[0]')
Name/name.c:693: error: `sX_____X_' undeclared here (not in a function)
Name/name.c:693: error: initializer element is not constant
[snip rest of the bitmap erros]
Is this 'trick' compiler or compiler option dependent?
[...]
Post by Bob Paddock
Post by Derric Tubbs
#define X )*2+1
#define _ )*2
#define s ((((((((0 /* 8 parens for 8 bit, 16 for 16,
etc) */
uint8_t lcd_char_P[] =
{
sXXXXXX__,
sX_____X_,
sX______X,
sX_____X_,
sXXXXXX__,
sX_______,
sX_______,
sX_______
}
I think it will work if you change the above to

uint8_t lcd_char_P[] =
{
s XXXXXX__,
s X_____X_,
s X______X,
s X_____X_,
s XXXXXX__,
s X_______,
s X_______,
s X_______
}

But I haven't tried it myself. Regards,
-=Dave
Derric Tubbs
2005-09-23 14:37:48 UTC
Permalink
Sorry about that, my bad, you have to put spaces
between all of the symbols that make up the bitmap.

Tubbs
Post by Bob Paddock
I thought I'd try this bitmap 'trick' via copy&paste
of the
#defines and code into the file I was working on,
Name/name.c:692: error: `sXXXXXX__' undeclared here
(not in a function)
Name/name.c:692: error: initializer element is not
constant
Name/name.c:692: error: (near initialization for
`lcd_char_P[0]')
Name/name.c:693: error: `sX_____X_' undeclared here
(not in a function)
Name/name.c:693: error: initializer element is not
constant
[snip rest of the bitmap erros]
Is this 'trick' compiler or compiler option
dependent?
This is usually the problem with 'tricks' they come
back and
bite you at some point.
On Thu, 22 Sep 2005 23:48:38 -0400, Derric Tubbs
Post by Derric Tubbs
Secondly, I got this little trick from the book
that
Post by Derric Tubbs
the link above points to, the book is called
"Expert C
Post by Derric Tubbs
Programming". Anyhow for an 8 bit LCD bitmap like
#define X )*2+1
#define _ )*2
#define s ((((((((0 /* 8 parens for 8 bit, 16 for
16,
Post by Derric Tubbs
etc) */
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
;)
Post by Derric Tubbs
Pretty cool little trick. Kind of extravegant but
something similar to this sure would have made
things
Post by Derric Tubbs
clearer when I was looking at some code that
defined
Post by Derric Tubbs
characters on a graphic LCD the other day ;)
Loading...