Hi Vlad,
Aaron has done a great job of identifying some of the problems. I just imported your code, made these changes, and added some more to make it allcompile ok. Here is the result:
PlayStationController
Note, just because it compiles, that doesn't mean it does the right thing!
Here are the main changes I made:
I moved gameByte() earlier in the main.cpp file so it is defined by the time it is used, and changed the return type from void to char.
There was a function (or macro) named _BV(n), which doesn't exist. A little google suggests this is a bit setting macro (probably "Bit Value" or something), but the logic is basically:
1 << n;
It doesn't seem to save much typing, but I guess people might like to wrap it up. So I just quickly added this to get that working:
int _BV(int bit) {
return 1 << bit;
}
These sort of things are often defined as Macros, which are basically a text substitution by a C pre-processor before compiling. I'd encourage defining them as function, as it helps the compiler give you better error reports, type checking etc. Macros are like someone coming in, changing your code, then talking back to you in what it was translated to. People will tell you "it is not as efficient", which in some cases will be true, but in a lot of cases it won't make any difference and you can even encourage the compiler to "inline" functions meaning you get exactly the same result (I'll do a post about this sometime perhaps). But i'm getting of track here...
The printf() statements needed a little modification, from:
case 0:
pc.printf("case 0: ");
pc.printf(data0);
break;
to:
case 0:
pc.printf("case 0: %d\n", data0);
break;
Also, the program didn't have a main() function, and every C program needs one of these. My guess is this code is based on the arduino convention of a hidden main that calls setup then loop, so you need to add:
int main() {
startup();
while(1) {
loop();
}
}
There were probably a few tweaks more, but this was the main crux to get it to compile!
Now, you'll have to start looking at the logical bugs... :)
Simon
Hello,
I have mannaged to get a wireless guitar to work with the arduino using arduino code. It has worked great and i've started to port over the code for the mbed. I have done most of it but there are a few errors that I do not know how to get rid of.
Here is the code as I have it so far:
PlayStationController
The problems I am having is with the last function called gameByte, there are a few variable that I have no idea what they would correspond to in mbed language and I was wondering if anyone has any idea of what to do to get it to compile.
Thanks so much, more information about the project is here: Second Life Rock Band