Hi professionals,
I just started with Arduino and love it for it's easy getting start.. But unfortunate I don't familiar with C programming, as well the compiler family.. so I wish could have some clues from the following... ( I know Perl and Java, however )
I have a program to control a "7 LED" to keep count from 0-9, through a 595 Chip and have this structure to assign which lights should on and off accordingly.
byte nums[10][8] = {
{ 1,1,1,0,1,1,1,0 }, //0
{ 0,0,1,0,0,1,0,0 }, // 1
{ 1,0,1,1,1,0,1,0 }, //..
{ 1,0,1,1,0,1,1,0 },
{ 0,1,1,1,0,1,0,0 },
{ 1,1,0,1,0,1,1,0 },
{ 1,1,0,1,1,1,1,0 },
{ 1,0,1,0,0,1,0,0 },
{ 1,1,1,1,1,1,1,0 },
{ 1,1,1,1,0,1,1,0 }, // 9
};
This is quite stupid, though it works.. however, in programming
maintenance aspect, I would like to make some code like this :
byte nums[] = { 0xEE, 0x24 ... 0xF6 } ;
for ( int n = 0; n<=9; n++ ) {
byte thisNum = printf "%08b", nums[n];
char[8] light = splitEachChar ( boolToString ( thisNum ) );
sendBits ( light ); // this function suppose to send 8 bit for the 595 chip.
}
Questions :
1. I don't know if there's build-in functions for boolToString() or splitEachChar() for my purpose, even the printf()
2. it then drive me to think, which standard libs I can #inculde ( by default )? And if I got mine libs, where ( and what ) should I put those libs for my project ?
3. If I try to make my own lib, can I say if I can success compile a lib by avr-gcc, then I've grantee can run it on Arduino ?
4. Is that avr-gcc full support all the cpp style coding syntax ?
Please help me with any clues.. I feel so handicap while I can only use the most basic syntax.