hthang1988 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Aliases SDA,SCL,LED,MOSI,MISO,SCLK,SS #275

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What change would like to see?

Aliases added to WProgram.h for SDA, SCL, LED, MOSI, MISO, SCLK, and SS.

Why?

These 7 functions are commonly used.  Defining aliases allows sketches and 
libraries to use them by their names.

Sketches written for Duemilanove using these names would automatically adapt to 
the correct pins when used on an Arduino Mega, or other 3rd party boards, and 
future Arduino boards.

By having them defined in WProgram.h (together with A0, A1, A2...), they can 
automatically update with the correct pin numbers for the board the user has 
selected from the Tools->Boards menu.  Only the core is selectable by the 
Tools->Boards menu.

As more official arduino and 3rd party boards are created, having pin 
definitions in 1 place makes code maintenance easier.  If new cores are created 
(or new 3rd party cores), having the definitions in WProgram.h, right next to 
the A0, A1, etc will make it easy for those new cores to define these names as 
appropriate.

Would this cause any incompatibilities with previous versions?  If so, how
can these be mitigated?

If sketches already use these 7 names, a conflict can orrur.  If the sketch 
uses them as #define, the original values from the sketch will still be used.  
If they're defined as variables, a conflict can occur, but a meaningful error 
message should result.  It should be pretty easy to modify such sketches to 
just use these names.

Original issue reported on code.google.com by paul.sto...@gmail.com on 12 Jun 2010 at 5:09

GoogleCodeExporter commented 9 years ago
Here is a patch to add the aliases

Original comment by paul.sto...@gmail.com on 12 Jun 2010 at 5:18

Attachments:

GoogleCodeExporter commented 9 years ago
Here is a patch for build/shared/examples, to update all the examples.

Original comment by paul.sto...@gmail.com on 12 Jun 2010 at 5:20

Attachments:

GoogleCodeExporter commented 9 years ago
https://github.com/arduino/Arduino/commit/f14fd94d0eb52e75b3e295e10496b1782a4c8d
f5

Original comment by dmel...@gmail.com on 12 Aug 2011 at 9:01