UIntTable

From Wiring

Jump to: navigation, search
Name UIntTable
Description Constant data type for a read-only array of unsigned ints. These data types are not located in RAM memory saving memory space for other data. Use these data types to store constant data (data which will not change during the whole life of the program). The data types include: ByteTable (store bytes), CharTable (store chars), UCharTable (store unsigned chars), IntTable (store integers), UIntTable (store unsigned ints), LongTable (store longs), ULongTable (store unsigned longs), FloatTable (store floats) and DoubleTable (store doubles).
Syntax
UIntTable var = IntTable(val1, val2, ...);
Methods
count() Returns the number of elements stored in the table
Constructor
UIntTable(data)
Parameters
var unknown datatype variable name referencing the value
valx unsigned int numbers to store in the table, comma separated
Returns
Example
// ...
 
  IntTable sine_table = IntTable(
  0,6,12,18,25,31,37,43,49,56,62,68,74,80,86,92,97,103,109,115,120,126,131,136,142,
  147,152,157,162,167,171,176,181,185,189,193,197,201,205,209,212,216,219,222,225,
  228,231,234,236,238,241,243,244,246,248,249,251,252,253,254,254,255,255,255,256,
  255,255,255,254,254,253,252,251,249,248,246,244,243,241,238,236,234,231,228,225,
  222,219,216,212,209,205,201,197,193,189,185,181,176,171,167,162,157,152,147,142,
  136,131,126,120,115,109,103,97,92,86,80,74,68,62,56,49,43,37,31,25,18,12,6,0,-6,
  -12,-18,-25,-31,-37,-43,-49,-56,-62,-68,-74,-80,-86,-92,-97,-103,-109,-115,-120,
  -126,-131,-136,-142,-147,-152,-157,-162,-167,-171,-176,-181,-185,-189,-193,-197,
  -201,-205,-209,-212,-216,-219,-222,-225,-228,-231,-234,-236,-238,-241,-243,-244,
  -246,-248,-249,-251,-252,-253,-254,-254,-255,-255,-255,-256,-255,-255,-255,-254,
  -254,-253,-252,-251,-249,-248,-246,-244,-243,-241,-238,-236,-234,-231,-228,-225,
  -222,-219,-216,-212,-209,-205,-201,-197,-193,-189,-185,-181,-176,-171,-167,-162,
  -157,-152,-147,-142,-136,-131,-126,-120,-115,-109,-103,-97,-92,-86,-80,-74,-68,
  -62,-56,-49,-43,-37,-31,-25,-18,-12,-6,-6,-12,-18,-25,-31,-37,-43,-49,-56,-62,
  -68,-74,-80,-86,-92,-97,-103,-109,-115,-120,-126,-131,-136,-142,-147,-152,-157,
  -162,-167,-171,-176,-181,-185,-189,-193,-197,-201,-205,-209,-212,-216,-219,-222,
  -225,-228,-231,-234,-236,-238,-241,-243,-244,-246,-248,-249,-251,-252,-253,-254,
  -254,-255,-255,-255,-256,-255,-255,-255,-254,-254,-253,-252,-251,-249,-248,-246,
  -244,-243,-241,-238,-236,-234,-231,-228,-225,-222,-219,-216,-212,-209,-205,-201,
  -197,-193,-189,-185,-181,-176,-171,-167,-162,-157,-152,-147,-142,-136,-131,-126,
  -120,-115,-109,-103,-97,-92,-86,-80,-74,-68,-62,-56,-49,-43,-37,-31,-25,-18,-12,-6);
 
  Serial.println(Constant("The sine table is ")); 
  for (int i = 0; i < sine_table.count(); ++i)
    Serial.println(sine_table[i]);
 
  // Determine the size of the array
  Serial.print(Constant("The sine array contains ")); 
  Serial.print(sine_table.count()); 
  Serial.println(Constant(" integers."));
  Serial.print(Constant("But the RAM used by the sine array is only ")); 
  Serial.println(sizeof(sine_table));
 
  // Access individual elements of the array using [] notation
  int maximum = sine_table[0];
  for (int i = 1; i < sine_table.count(); ++i)
    if (sine_table[i] > maximum)
      maximum = sine_table[i];
  Serial.print(Constant("The peak value of the sine wave is ")); 
  Serial.println(maximum);
 
// ...
Related Constant, ConstantString, ByteTable, CharTable, UCharTable, IntTable, LongTable, ULongTable, FloatTable, DoubleTable
Language: English  • EspaƱol
Personal tools