Go Down

Topic: Developer Request: Sketch Require Hardware (Read 2 times) previous topic - next topic

AlphaBeta

Maybe we could have a  way to ensure a certain platform from the sketch?
Or possibly to explicity disallow a platform.

Something like:
Code: [Select]

/*
 Serial echo server for the Arduino Mega

 Uses Serial1

 @require Mega
*/

void setup()
{
  Serial1.begin(9600);
}

void loop()
{
 // if we get a valid byte, read analog ins:
 if (Serial1.available() > 0) {
   Serial1.print( Serial1.read() );
 }
}


Mike Murdock

AlphaBeta,

I think you could do that now by checking the #define'd processor type.  To make it easy, you could define a macro that says, "if processor != desired_type generate compile error"

Regards,

-Mike

AlphaBeta

#2
Feb 16, 2010, 01:29 am Last Edit: Feb 16, 2010, 01:46 pm by AlphaBeta Reason: 1
Oh.. I know I could do it. 8-) Hehe...

But if I where to share that Sketch with a nonprogrammer, I think I would've gotten some questions about all the #ifndef stuff.


Just an idea to keep things simple and self explanatory.

[edit]Oh the shame! ;)
Wayoda's post below made me realize I could not do it, even if I used all the preprocessor directives available.[/edit]

wayoda

Quote

I think you could do that now by checking the #define'd processor type.  

No you can't. For instance the Duemilanove and the Nano board both have a 328p processor, but  only the Nano board supports the analog inputs A6 and A7.

Eberhard

Mike Murdock

wayoda,

Excellent point.  Maybe the request could be to #define a board type, if the IDE doesn't already do this.

Regards,

-Mike

Go Up