Reference.Static History

Hide minor edits - Show changes to markup

June 03, 2010, at 04:25 PM by Equipo Traduccion -
Changed line 16 from:
  • El máximo va a un bucle controlado por el parámetro "setpsize".
to:
  • El máximo está controlado por el parámetro "stepsize".
Changed line 18 from:
  • Esta técnica es conocida como "pink noise" (ruido rosa) y "drunken walk".
to:
  • Esta técnica es conocida como "pink noise" y "drunken walk".
Changed line 48 from:
    place = place + (randomWalkLowRange - place);     // modifica el número a una dirección poisitiva 
to:
    place = place + (randomWalkLowRange - place);     // modifica el número a una dirección positiva 
June 03, 2010, at 04:23 PM by Equipo Traduccion -
June 03, 2010, at 04:22 PM by Equipo Traduccion -
Changed lines 15-19 from:
  • 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".
to:
  • RandomWalk salta aleatoriamente entre 2 puntos de salida
  • El máximo va a un bucle controlado por el parámetro "setpsize".
  • Una variable estática es incrementada o decrementada aleatoriamente.
  • Esta técnica es conocida como "pink noise" (ruido rosa) y "drunken walk".
Changed lines 42-44 from:
  static int  place;     // variable estática
                         // los valores se conservaron entre las siguientes llamadas a la función. Ninguna otra función puede cambiar su valor
to:
  static int  place;     // variable estática  los valores se conservaron entre las siguientes
                         // llamadas a la función. Ninguna otra función puede cambiar su valor
June 03, 2010, at 04:17 PM by Equipo Traduccion -
Changed line 49 from:
    place = place + (randomWalkLowRange - place);     // reflect number back in positive direction
to:
    place = place + (randomWalkLowRange - place);     // modifica el número a una dirección poisitiva 
Changed line 52 from:
    place = place - (place - randomWalkHighRange);     // reflect number back in negative direction
to:
    place = place - (place - randomWalkHighRange);     // modifica el número a una dirección negativa
June 03, 2010, at 04:16 PM by Equipo Traduccion -
Changed lines 3-9 from:

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

to:

La palabra reservada static se utiliza para crear variables estáticas, estas variables tienen la peculiaridad de que no se crean y se destruyen cada vez que se llama al bloque de código en el que está definidas, sino que su valor se guarda para las sucesivas llamadas.

Las variables que se declaran como estáticas sólo se crearan e inicializarán la primera vez que se ejecute el bloque de código en el que están contenidas.

Ejemplo

Changed line 35 from:

{ // tetst randomWalk function

to:

{ // lanzamos la función randomWalk

Changed lines 43-45 from:
  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
to:
  static int  place;     // variable estática
                         // los valores se conservaron entre las siguientes llamadas a la función. Ninguna otra función puede cambiar su valor
Changed line 48 from:
  if (place < randomWalkLowRange){                    // check lower and upper limits
to:
  if (place < randomWalkLowRange){                    // comprueba el límite mayor y el menor
October 26, 2008, at 02:03 PM by Paul Badger -
Changed lines 14-21 from:
 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".

 */
to:
  • 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".
  • /
May 15, 2007, at 09:53 PM by Paul Badger -
Deleted line 31:
  Serial.println("start ");
May 15, 2007, at 09:53 PM by Paul Badger -
Changed lines 39-43 from:
  total += thisTime;                  // aggregate values to see if function is really random
  Serial.print(thisTime);
  Serial.print("  ");
  Serial.println(total);
  delay(10);
to:
  Serial.println(thisTime);
   delay(10);
May 15, 2007, at 09:51 PM by Paul Badger -
Changed lines 48-49 from:
                         // values in between function calls, but no other functions can mess with its value
to:
                         // values in between function calls, but no other functions can change its value
May 15, 2007, at 09:50 PM by Paul Badger -
Changed lines 15-16 from:
 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".
to:
 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".

May 15, 2007, at 09:49 PM by Paul Badger -
Added lines 12-60:

/* 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".
 */

  1. define randomWalkLowRange -20
  2. define randomWalkHighRange 20

int stepsize;

int thisTime; int total;

void setup() {

  Serial.begin(9600);
  Serial.println("start ");

}

void loop() { // tetst randomWalk function

  stepsize = 5;
  thisTime = randomWalk(stepsize);
  total += thisTime;                  // aggregate values to see if function is really random
  Serial.print(thisTime);
  Serial.print("  ");
  Serial.println(total);
  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 mess with 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;

}

@]

May 15, 2007, at 09:46 PM by Paul Badger -
Added lines 1-11:

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

[@

Share