jung6717 / arduino

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

Add an API for enabling and disabling the internal pullup resistors. #246

Closed GoogleCodeExporter closed 8 years ago

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

A pullup(pin) and noPullup(pin) for enabling / disabling the internal pullup 
resistors on the pins.  
This would basically be an alias for digitalWrite(pin, HIGH) and 
digitalWrite(pin, LOW).

Why?

Because it's confusing to have to digitalWrite() to a pin to enable or disable 
its internal pullup 
resistors.

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

Not really, because digitalWrite() would still work for enabling / disabling 
the pullups.

Original issue reported on code.google.com by dmel...@gmail.com on 6 May 2010 at 6:29

GoogleCodeExporter commented 8 years ago
If this functionality is added, is the risk of someone unintentionally 
en/disabling pullups with the old-style 
"digitalWrite" method outweighed by the issues caused by eventually deprecating 
and then removing that 
approach?

Original comment by follower@gmail.com on 7 May 2010 at 2:20

GoogleCodeExporter commented 8 years ago
I've been hoping that the digitalWrite() functions can be made more efficient, 
so adding a check that disables 
them in input mode seems like the wrong way to go.  Also, doing a 
digitalWrite() while something is set as an 
output (in a world where pullup() / noPullup() exist, and so you're not trying 
to control the internal pullups) 
seems like something that can be explained clearly: "digitalWrite() only works 
properly when the pin is set as an 
output".  

Original comment by dmel...@gmail.com on 7 May 2010 at 3:32

GoogleCodeExporter commented 8 years ago
Why add additional API functions?

Why not simply add new mode options to the existing pinMode(pin, mode) function?
Simply add new modes like "INPUTPU" & "INPUTNPU" or whatever names you like,
then it is simply a small tweak to the pinMode() function in wiring_digital.c
to support the new input mode.

So:
input with    pullups: pinMode(pin, INPUTPU);
input without pullups: pinMode(pin, INPUTNPU);
 backward compability: pinMode(pin, INPUT); // default/current behavior
               output: pinMode(pin, OUTPUT);

Seems a whole like cleaner and simpler than having to having to add new and 
somewhat
parallel set of API mode functions.

It simplifies the API to 1 function to set pin modes.

Original comment by bperry...@gmail.com on 11 May 2010 at 2:37

GoogleCodeExporter commented 8 years ago
I think for new users (like me) adding this functionality could get confusing.

For now if I want to activate the pull-up resistor I need to use 
digitalWrite(pin, HIGH). So when I look at my code I know my pin is high.

But if I where to use something like pullup(pin), I could easily forget that 
this will not only activate the pull-up resistor but also make the pin HIGH.

Not a big thing......but for new users.....it could take a while to figure out 
why this damn pin is always HIGH when I nowhere in my code used 
digitalWrite(pin, HIGH)!

Not sure if my explanation is clear?

Original comment by bapcc...@gmail.com on 23 Mar 2011 at 2:34

GoogleCodeExporter commented 8 years ago

Original comment by dmel...@gmail.com on 16 Dec 2011 at 10:06

GoogleCodeExporter commented 8 years ago

Original comment by dmel...@gmail.com on 2 Jan 2012 at 3:41

GoogleCodeExporter commented 8 years ago

Original comment by paul.sto...@gmail.com on 2 Jan 2012 at 12:11

Attachments:

GoogleCodeExporter commented 8 years ago
https://github.com/arduino/Arduino/commit/76c964d32b13f1fc01e3a5b07460d96f2dcaec
d6

Original comment by dmel...@gmail.com on 2 Jan 2012 at 7:25