aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/arduino/static.rst
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@mit.edu>2010-12-21 10:27:37 -0500
committerMarti Bolivar <mbolivar@mit.edu>2010-12-21 10:27:37 -0500
commitc45bccad44187da27505cf5808424e709e3f54a1 (patch)
tree18a459a50f8d0551ba046e30462c93999d982725 /docs/source/arduino/static.rst
parent84fd2532a7f23d20354ff590790b3f892cb7e7d7 (diff)
parentd5ad2a27f4e69e6cc9324331945937c983c30366 (diff)
downloadlibrambutan-c45bccad44187da27505cf5808424e709e3f54a1.tar.gz
librambutan-c45bccad44187da27505cf5808424e709e3f54a1.zip
Merge branch 'master' into debug-serialusb.
Chose debug-serialusb version in cases of conflict. Conflicts: libmaple/usb/usb_callbacks.c
Diffstat (limited to 'docs/source/arduino/static.rst')
-rw-r--r--docs/source/arduino/static.rst71
1 files changed, 0 insertions, 71 deletions
diff --git a/docs/source/arduino/static.rst b/docs/source/arduino/static.rst
deleted file mode 100644
index 1c0340e..0000000
--- a/docs/source/arduino/static.rst
+++ /dev/null
@@ -1,71 +0,0 @@
-.. _arduino-static:
-
-Static
-======
-
-The static keyword is used to create variables that are visible to
-only one function. However unlike local variables that get created
-and destroyed every time a function is called, static variables
-persist beyond the function call, preserving their data between
-function calls.
-
-
-
-Variables declared as static will only be created and initialized
-the first time a function is called.
-
-
-
-Example
--------
-
-::
-
-
-
- /* RandomWalk
- * Paul Badger 2007
- * RandomWalk wanders up and down randomly between two
- * endpoints. The maximum move in one loop is governed by
- * the parameter "stepsize".
- * A static variable is moved up and down a random amount.
- * This technique is also known as "pink noise" and "drunken walk".
- */
-
- #define randomWalkLowRange -20
- #define randomWalkHighRange 20
- int stepsize;
-
- int thisTime;
- int total;
-
- void setup()
- {
- Serial.begin(9600);
- }
-
- void loop()
- { // tetst randomWalk function
- stepsize = 5;
- thisTime = randomWalk(stepsize);
- Serial.println(thisTime);
- delay(10);
- }
-
- int randomWalk(int moveSize){
- static int place; // variable to store value in random walk - declared static so that it stores
- // values in between function calls, but no other functions can change its value
-
- place = place + (random(-moveSize, moveSize + 1));
-
- if (place < randomWalkLowRange){ // check lower and upper limits
- place = place + (randomWalkLowRange - place); // reflect number back in positive direction
- }
- else if(place > randomWalkHighRange){
- place = place - (place - randomWalkHighRange); // reflect number back in negative direction
- }
-
- return place;
- }
-
-