diff options
-rw-r--r-- | docs/source/arduino/float.rst | 58 | ||||
-rw-r--r-- | docs/source/arduino/scope.rst | 62 | ||||
-rw-r--r-- | docs/source/arduino/sin.rst | 28 | ||||
-rw-r--r-- | docs/source/arduino/stringclass.rst | 9 | ||||
-rw-r--r-- | docs/source/arduino/tan.rst | 38 | ||||
-rw-r--r-- | docs/source/arduino/unsignedchar.rst | 44 | ||||
-rw-r--r-- | docs/source/arduino/unsignedint.rst | 80 | ||||
-rw-r--r-- | docs/source/arduino/unsignedlong.rst | 66 | ||||
-rw-r--r-- | docs/source/arduino/variables.rst | 191 | ||||
-rw-r--r-- | docs/source/arduino/word.rst | 32 | ||||
-rw-r--r-- | docs/source/arduino/wordcast.rst | 54 | ||||
-rw-r--r-- | docs/source/bootloader.rst | 51 | ||||
-rw-r--r-- | docs/source/external-interrupts.rst | 2 | ||||
-rw-r--r-- | docs/source/foo.rst | 122 | ||||
-rw-r--r-- | docs/source/ide.rst | 12 | ||||
-rw-r--r-- | docs/source/index.rst | 16 | ||||
-rw-r--r-- | docs/source/lang/abs.rst (renamed from docs/source/arduino/abs.rst) | 4 | ||||
-rw-r--r-- | docs/source/lang/analogread.rst (renamed from docs/source/arduino/analogread.rst) | 16 | ||||
-rw-r--r-- | docs/source/lang/analogwrite.rst (renamed from docs/source/arduino/analogwrite.rst) | 28 | ||||
-rw-r--r-- | docs/source/lang/arithmetic.rst (renamed from docs/source/arduino/arithmetic.rst) | 16 | ||||
-rw-r--r-- | docs/source/lang/arithmeticcompound.rst (renamed from docs/source/arduino/arithmeticcompound.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/array.rst (renamed from docs/source/arduino/array.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/assignment.rst (renamed from docs/source/arduino/assignment.rst) | 4 | ||||
-rw-r--r-- | docs/source/lang/attachinterrupt.rst (renamed from docs/source/arduino/attachinterrupt.rst) | 10 | ||||
-rw-r--r-- | docs/source/lang/bit.rst (renamed from docs/source/arduino/bit.rst) | 12 | ||||
-rw-r--r-- | docs/source/lang/bitclear.rst (renamed from docs/source/arduino/bitclear.rst) | 12 | ||||
-rw-r--r-- | docs/source/lang/bitread.rst (renamed from docs/source/arduino/bitread.rst) | 12 | ||||
-rw-r--r-- | docs/source/lang/bitset.rst (renamed from docs/source/arduino/bitset.rst) | 12 | ||||
-rw-r--r-- | docs/source/lang/bitshift.rst (renamed from docs/source/arduino/bitshift.rst) | 18 | ||||
-rw-r--r-- | docs/source/lang/bitwisecompound.rst (renamed from docs/source/arduino/bitwisecompound.rst) | 36 | ||||
-rw-r--r-- | docs/source/lang/bitwisemath.rst (renamed from docs/source/arduino/bitwisemath.rst) | 14 | ||||
-rw-r--r-- | docs/source/lang/bitwrite.rst (renamed from docs/source/arduino/bitwrite.rst) | 12 | ||||
-rw-r--r-- | docs/source/lang/boolean.rst (renamed from docs/source/arduino/boolean.rst) | 26 | ||||
-rw-r--r-- | docs/source/lang/booleanvariables.rst (renamed from docs/source/arduino/booleanvariables.rst) | 12 | ||||
-rw-r--r-- | docs/source/lang/braces.rst (renamed from docs/source/arduino/braces.rst) | 22 | ||||
-rw-r--r-- | docs/source/lang/break.rst (renamed from docs/source/arduino/break.rst) | 8 | ||||
-rw-r--r-- | docs/source/lang/byte.rst (renamed from docs/source/arduino/byte.rst) | 8 | ||||
-rw-r--r-- | docs/source/lang/bytecast.rst (renamed from docs/source/arduino/bytecast.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/cc-attribution.txt (renamed from docs/source/arduino/cc-attribution.txt) | 0 | ||||
-rw-r--r-- | docs/source/lang/char.rst (renamed from docs/source/arduino/char.rst) | 15 | ||||
-rw-r--r-- | docs/source/lang/charcast.rst (renamed from docs/source/arduino/charcast.rst) | 8 | ||||
-rw-r--r-- | docs/source/lang/comments.rst (renamed from docs/source/arduino/comments.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/comparison.rst (renamed from docs/source/arduino/comparison.rst) | 16 | ||||
-rw-r--r-- | docs/source/lang/const.rst (renamed from docs/source/arduino/const.rst) | 12 | ||||
-rw-r--r-- | docs/source/lang/constants.rst (renamed from docs/source/arduino/constants.rst) | 32 | ||||
-rw-r--r-- | docs/source/lang/constrain.rst (renamed from docs/source/arduino/constrain.rst) | 8 | ||||
-rw-r--r-- | docs/source/lang/continue.rst (renamed from docs/source/arduino/continue.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/cos.rst (renamed from docs/source/arduino/cos.rst) | 19 | ||||
-rw-r--r-- | docs/source/lang/define.rst (renamed from docs/source/arduino/define.rst) | 8 | ||||
-rw-r--r-- | docs/source/lang/delay.rst (renamed from docs/source/arduino/delay.rst) | 30 | ||||
-rw-r--r-- | docs/source/lang/delaymicroseconds.rst (renamed from docs/source/arduino/delaymicroseconds.rst) | 10 | ||||
-rw-r--r-- | docs/source/lang/detachinterrupt.rst (renamed from docs/source/arduino/detachinterrupt.rst) | 10 | ||||
-rw-r--r-- | docs/source/lang/digitalread.rst (renamed from docs/source/arduino/digitalread.rst) | 14 | ||||
-rw-r--r-- | docs/source/lang/digitalwrite.rst (renamed from docs/source/arduino/digitalwrite.rst) | 10 | ||||
-rw-r--r-- | docs/source/lang/double.rst (renamed from docs/source/arduino/double.rst) | 24 | ||||
-rw-r--r-- | docs/source/lang/doublecast.rst (renamed from docs/source/arduino/doublecast.rst) | 12 | ||||
-rw-r--r-- | docs/source/lang/dowhile.rst (renamed from docs/source/arduino/dowhile.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/else.rst (renamed from docs/source/arduino/else.rst) | 14 | ||||
-rw-r--r-- | docs/source/lang/enum.rst | 8 | ||||
-rw-r--r-- | docs/source/lang/float.rst | 53 | ||||
-rw-r--r-- | docs/source/lang/floatcast.rst (renamed from docs/source/arduino/floatcast.rst) | 14 | ||||
-rw-r--r-- | docs/source/lang/for.rst (renamed from docs/source/arduino/for.rst) | 34 | ||||
-rw-r--r-- | docs/source/lang/goto.rst (renamed from docs/source/arduino/goto.rst) | 14 | ||||
-rw-r--r-- | docs/source/lang/highbyte.rst (renamed from docs/source/arduino/highbyte.rst) | 4 | ||||
-rw-r--r-- | docs/source/lang/if.rst (renamed from docs/source/arduino/if.rst) | 18 | ||||
-rw-r--r-- | docs/source/lang/include.rst (renamed from docs/source/arduino/include.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/increment.rst (renamed from docs/source/arduino/increment.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/int.rst (renamed from docs/source/arduino/int.rst) | 33 | ||||
-rw-r--r-- | docs/source/lang/intcast.rst (renamed from docs/source/arduino/intcast.rst) | 10 | ||||
-rw-r--r-- | docs/source/lang/interrupts.rst (renamed from docs/source/arduino/interrupts.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/keywords.rst | 11 | ||||
-rw-r--r-- | docs/source/lang/long.rst (renamed from docs/source/arduino/long.rst) | 34 | ||||
-rw-r--r-- | docs/source/lang/longcast.rst (renamed from docs/source/arduino/longcast.rst) | 10 | ||||
-rw-r--r-- | docs/source/lang/loop.rst (renamed from docs/source/arduino/loop.rst) | 8 | ||||
-rw-r--r-- | docs/source/lang/lowbyte.rst (renamed from docs/source/arduino/lowbyte.rst) | 4 | ||||
-rw-r--r-- | docs/source/lang/map.rst (renamed from docs/source/arduino/map.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/max.rst (renamed from docs/source/arduino/max.rst) | 10 | ||||
-rw-r--r-- | docs/source/lang/micros.rst (renamed from docs/source/arduino/micros.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/millis.rst (renamed from docs/source/arduino/millis.rst) | 2 | ||||
-rw-r--r-- | docs/source/lang/min.rst (renamed from docs/source/arduino/min.rst) | 8 | ||||
-rw-r--r-- | docs/source/lang/modulo.rst (renamed from docs/source/arduino/modulo.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/nointerrupts.rst (renamed from docs/source/arduino/nointerrupts.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/notone.rst (renamed from docs/source/arduino/notone.rst) | 4 | ||||
-rw-r--r-- | docs/source/lang/pinmode.rst (renamed from docs/source/arduino/pinmode.rst) | 24 | ||||
-rw-r--r-- | docs/source/lang/pointer.rst (renamed from docs/source/arduino/pointer.rst) | 4 | ||||
-rw-r--r-- | docs/source/lang/pow.rst (renamed from docs/source/arduino/pow.rst) | 10 | ||||
-rw-r--r-- | docs/source/lang/pulsein.rst (renamed from docs/source/arduino/pulsein.rst) | 12 | ||||
-rw-r--r-- | docs/source/lang/pwmwrite.rst (renamed from docs/source/wirish/pwmwrite.rst) | 2 | ||||
-rw-r--r-- | docs/source/lang/random.rst (renamed from docs/source/arduino/random.rst) | 16 | ||||
-rw-r--r-- | docs/source/lang/randomseed.rst (renamed from docs/source/arduino/randomseed.rst) | 10 | ||||
-rw-r--r-- | docs/source/lang/return.rst (renamed from docs/source/arduino/return.rst) | 8 | ||||
-rw-r--r-- | docs/source/lang/scope.rst | 120 | ||||
-rw-r--r-- | docs/source/lang/semicolon.rst (renamed from docs/source/arduino/semicolon.rst) | 4 | ||||
-rw-r--r-- | docs/source/lang/serial.rst (renamed from docs/source/arduino/serial.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/serialusb.rst (renamed from docs/source/wirish/serialusb.rst) | 4 | ||||
-rw-r--r-- | docs/source/lang/setup.rst (renamed from docs/source/arduino/setup.rst) | 2 | ||||
-rw-r--r-- | docs/source/lang/shiftout.rst (renamed from docs/source/arduino/shiftout.rst) | 26 | ||||
-rw-r--r-- | docs/source/lang/sin.rst | 32 | ||||
-rw-r--r-- | docs/source/lang/sizeof.rst (renamed from docs/source/arduino/sizeof.rst) | 4 | ||||
-rw-r--r-- | docs/source/lang/sq.rst (renamed from docs/source/arduino/sq.rst) | 4 | ||||
-rw-r--r-- | docs/source/lang/sqrt.rst (renamed from docs/source/arduino/sqrt.rst) | 8 | ||||
-rw-r--r-- | docs/source/lang/static.rst (renamed from docs/source/arduino/static.rst) | 2 | ||||
-rw-r--r-- | docs/source/lang/string.rst (renamed from docs/source/arduino/string.rst) | 12 | ||||
-rw-r--r-- | docs/source/lang/stringclass.rst | 9 | ||||
-rw-r--r-- | docs/source/lang/stringobject.rst (renamed from docs/source/arduino/stringobject.rst) | 4 | ||||
-rw-r--r-- | docs/source/lang/switchcase.rst (renamed from docs/source/arduino/switchcase.rst) | 18 | ||||
-rw-r--r-- | docs/source/lang/tan.rst | 31 | ||||
-rw-r--r-- | docs/source/lang/tone.rst (renamed from docs/source/arduino/tone.rst) | 6 | ||||
-rw-r--r-- | docs/source/lang/types.rst | 7 | ||||
-rw-r--r-- | docs/source/lang/unsignedchar.rst | 36 | ||||
-rw-r--r-- | docs/source/lang/unsignedint.rst | 58 | ||||
-rw-r--r-- | docs/source/lang/unsignedlong.rst | 44 | ||||
-rw-r--r-- | docs/source/lang/variables.rst | 170 | ||||
-rw-r--r-- | docs/source/lang/void.rst (renamed from docs/source/arduino/void.rst) | 2 | ||||
-rw-r--r-- | docs/source/lang/volatile.rst (renamed from docs/source/arduino/volatile.rst) | 2 | ||||
-rw-r--r-- | docs/source/lang/while.rst (renamed from docs/source/arduino/while.rst) | 4 | ||||
-rw-r--r-- | docs/source/language-index.rst | 131 | ||||
-rw-r--r-- | docs/source/language.rst | 320 | ||||
-rw-r--r-- | docs/source/wirish.rst | 10 | ||||
-rw-r--r-- | docs/source/wirish/types.rst | 6 |
120 files changed, 1437 insertions, 1477 deletions
diff --git a/docs/source/arduino/float.rst b/docs/source/arduino/float.rst deleted file mode 100644 index aa3bd99..0000000 --- a/docs/source/arduino/float.rst +++ /dev/null @@ -1,58 +0,0 @@ -.. highlight:: cpp - -.. _arduino-float: - -float -===== - -.. TODO move all the useful examples over to arduino/double.rst. We -.. want to discourage using floats, since most of the common cmath -.. functions are only declared with doubles. - -Description ------------ - -Single-precision floating point number. ``float`` values can be as -large as 3.4028235E+38 and as low as -3.4028235E+38. They are stored -as 32 bits (4 bytes) of information. - -``float``\ s have only 6-7 decimal digits of precision. That means the total -number of digits, not the number to the right of the decimal point. -You can get more precision by using a :ref:`double <arduino-double>` -(which has a precision of about 16 decimal digits). - -The following example declares a ``float`` value named ``myfloat``:: - - float myfloat; - -This example declares a ``float`` value named ``sensorCalibrate``, -with value 1.117:: - - float sensorCalibrate = 1.117; - -The general syntax for declaring a float named ``var`` with value -``val`` is:: - - float var = val; - -Here is a more extended example involving a :ref:`float cast -<arduino-floatcast>`:: - - int x; - int y; - float z; - - x = 1; - y = x / 2; // y now contains 0, ints can't hold fractions - z = float(x) / 2; // z now contains .5 - -See Also --------- - -- :ref:`int <arduino-int>` -- :ref:`double <arduino-double>` -- :ref:`Variables <arduino-variables>` - - - -.. include:: cc-attribution.txt
\ No newline at end of file diff --git a/docs/source/arduino/scope.rst b/docs/source/arduino/scope.rst deleted file mode 100644 index 5974825..0000000 --- a/docs/source/arduino/scope.rst +++ /dev/null @@ -1,62 +0,0 @@ -.. highlight:: cpp - -.. _arduino-scope: - -Variable Scope -============== - -Variables in the C++ programming language, which Maple uses (all of -your sketches are C++ programs in disguise), have a property called -*scope*. This is in contrast to languages such as BASIC where every -variable is a *global* variable. - -A global variable is one that can be "seen" by every function in a -program. Local variables are only usable within the function in which -they are declared. In the :ref:`Maple IDE <ide>`, any variable -declared outside of a function (like :ref:`setup() <arduino-setup>`, -:ref:`loop() <arduino-loop>`, etc.), is a global variable. - -When programs start to get larger and more complex, local variables -are a useful way to ensure that a function has exclusive access to its -own variables. This prevents programming errors when one function -inadvertently modifies variables used by another function. - -It is also sometimes useful to declare and initialize a variable -inside a :ref:`for <arduino-for>` loop. This creates a variable that -can only be accessed from inside the loop body. - -Scope in C++ is actually a fairly complex topic. More information is -available in the `C++ programming Wikibook -<http://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Statements/Scope>`_. - -Example: --------- - -:: - - int globalVar; // any function will see this variable - - void setup() { - // ... - } - - void loop() { - int i; // "i" is only "visible" inside of "loop" - float f; // "f" is only "visible" inside of "loop" - // ... - - for (int j = 0; j <100; j++){ - // variable j can only be accessed inside the for-loop brackets - i = j * j; - } - i = globalVar; // globalVar can be accessed from anywhere, including loop() - } - -See Also --------- - -- `C++ programming Wikibook <http://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Statements/Scope>`_. -- Wikipedia article on `scope <http://en.wikipedia.org/wiki/Scope_%28programming%29>`_ - - -.. include:: cc-attribution.txt
\ No newline at end of file diff --git a/docs/source/arduino/sin.rst b/docs/source/arduino/sin.rst deleted file mode 100644 index b117f5f..0000000 --- a/docs/source/arduino/sin.rst +++ /dev/null @@ -1,28 +0,0 @@ -.. _arduino-sin: - -sin() -===== - -Calculates the `sine <http://en.wikipedia.org/wiki/Sine>`_ of an angle -(in radians). - -Library Documentation ---------------------- - -.. doxygenfunction:: sin - -Arduino Compatibility ---------------------- - -The Maple versino of ``sin()`` is compatible with Arduino. - -See Also --------- - -- :ref:`cos <arduino-cos>` -- :ref:`tan <arduino-tan>` -- :ref:`float <arduino-float>` -- :ref:`double <arduino-double>` - - -.. include:: cc-attribution.txt
\ No newline at end of file diff --git a/docs/source/arduino/stringclass.rst b/docs/source/arduino/stringclass.rst deleted file mode 100644 index ce508e7..0000000 --- a/docs/source/arduino/stringclass.rst +++ /dev/null @@ -1,9 +0,0 @@ -.. _arduino-stringclass: - -String Class -============ - -Stub. - - -.. include:: cc-attribution.txt
\ No newline at end of file diff --git a/docs/source/arduino/tan.rst b/docs/source/arduino/tan.rst deleted file mode 100644 index f17ffcc..0000000 --- a/docs/source/arduino/tan.rst +++ /dev/null @@ -1,38 +0,0 @@ -.. _arduino-tan: - -tan(rad) -======== - -Description ------------ - -Calculates the tangent of an angle (in radians). The result will be -between negative infinity and infinity. - - - -Parameters ----------- - -rad: the angle in radians (*float*) - - - -Returns -------- - -The tangent of the angle (*double*) - - - -See also --------- - - -- `sin <http://arduino.cc/en/Reference/Sin>`_\ () -- `cos <http://arduino.cc/en/Reference/Cos>`_\ () -- `float <http://arduino.cc/en/Reference/Float>`_ -- `double <http://arduino.cc/en/Reference/Double>`_ - - -.. include:: cc-attribution.txt
\ No newline at end of file diff --git a/docs/source/arduino/unsignedchar.rst b/docs/source/arduino/unsignedchar.rst deleted file mode 100644 index 5c26d17..0000000 --- a/docs/source/arduino/unsignedchar.rst +++ /dev/null @@ -1,44 +0,0 @@ -.. _arduino-unsignedchar: - -unsigned char -============= - -Description ------------ - -An unsigned data type that occupies 1 byte of memory. Same as the -`byte <http://arduino.cc/en/Reference/Byte>`_ datatype. - - - -The unsigned char datatype encodes numbers from 0 to 255. - - - -For consistency of Arduino programming style, the *byte* data type -is to be preferred. - - - -Example -------- - -:: - - unsigned char myChar = 240; - - - -See also --------- - - -- `byte <http://arduino.cc/en/Reference/Byte>`_ -- `int <http://arduino.cc/en/Reference/Int>`_ -- `array <http://arduino.cc/en/Reference/Array>`_ -- `Serial.println <http://arduino.cc/en/Serial/Println>`_ - - - - -.. include:: cc-attribution.txt diff --git a/docs/source/arduino/unsignedint.rst b/docs/source/arduino/unsignedint.rst deleted file mode 100644 index 11412b1..0000000 --- a/docs/source/arduino/unsignedint.rst +++ /dev/null @@ -1,80 +0,0 @@ -.. _arduino-unsignedint: - -unsigned int -============ - -Description ------------ - -Unsigned ints (unsigned integers) are the same as ints in that they -store a 2 byte value. Instead of storing negative numbers however -they only store positive values, yielding a useful range of 0 to -65,535 (2^16) - 1). - - - -The difference between unsigned ints and (signed) ints, lies in the -way the highest bit, sometimes refered to as the "sign" bit, is -interpreted. In the Arduino int type (which is signed), if the high -bit is a "1", the number is interpreted as a negative number, and -the other 15 bits are interpreted with -`2's complement math. <http://en.wikipedia.org/wiki/2's_complement>`_ - - - -Example -------- - -:: - - unsigned int ledPin = 13; - - - -Syntax ------- - -:: - - unsigned int var = val; - - - - -- var - your unsigned int variable name -- val - the value you assign to that variable - - - -Coding Tip ----------- - -When variables are made to exceed their maximum capacity they "roll -over" back to their minimum capacitiy, note that this happens in -both directions - - - -:: - - unsigned int x - x = 0; - x = x - 1; // x now contains 65535 - rolls over in neg direction - x = x + 1; // x now contains 0 - rolls over - - - -See Also --------- - - -- `byte <http://arduino.cc/en/Reference/Byte>`_ -- `int <http://arduino.cc/en/Reference/Int>`_ -- `long <http://arduino.cc/en/Reference/Long>`_ -- `unsigned long <http://arduino.cc/en/Reference/UnsignedLong>`_ -- `Variable Declaration <http://arduino.cc/en/Reference/VariableDeclaration>`_ - - - - -.. include:: cc-attribution.txt
\ No newline at end of file diff --git a/docs/source/arduino/unsignedlong.rst b/docs/source/arduino/unsignedlong.rst deleted file mode 100644 index c493c40..0000000 --- a/docs/source/arduino/unsignedlong.rst +++ /dev/null @@ -1,66 +0,0 @@ -.. _arduino-unsignedlong: - -unsigned long -============= - -Description ------------ - -Unsigned long variables are extended size variables for number -storage, and store 32 bits (4 bytes). Unlike standard longs -unsigned longs won't store negative numbers, making their range -from 0 to 4,294,967,295 (2^32 - 1). - - - -Example -------- - -:: - - unsigned long time; - - void setup() - { - Serial.begin(9600); - } - - void loop() - { - Serial.print("Time: "); - time = millis(); - //prints time since program started - Serial.println(time); - // wait a second so as not to send massive amounts of data - delay(1000); - } - -Syntax ------- - -:: - - unsigned long var = val; - - - - -- var - your long variable name -- val - the value you assign to that variable - - - -See Also --------- - - -- `byte <http://arduino.cc/en/Reference/Byte>`_ -- `int <http://arduino.cc/en/Reference/Int>`_ -- `unsigned int <http://arduino.cc/en/Reference/UnsignedInt>`_ -- `long <http://arduino.cc/en/Reference/Long>`_ -- `Variable Declaration <http://arduino.cc/en/Reference/VariableDeclaration>`_ - - - - -.. include:: cc-attribution.txt
\ No newline at end of file diff --git a/docs/source/arduino/variables.rst b/docs/source/arduino/variables.rst deleted file mode 100644 index 0720041..0000000 --- a/docs/source/arduino/variables.rst +++ /dev/null @@ -1,191 +0,0 @@ -.. highlight:: cpp - -.. _arduino-variables: - -Variables ---------- - -A variable is a way of naming and storing a value for later use by -the program, such as data from a sensor or an intermediate value -used in a calculation. - -.. _arduino-variables-declaring: - -Declaring Variables -^^^^^^^^^^^^^^^^^^^ - -Before they are used, all variables have to be declared. Declaring -a variable means defining its type, and optionally, setting an -initial value (initializing the variable). Variables do not have to -be initialized (assigned a value) when they are declared, but it is -often useful. - - - -:: - - int inputVariable1; - int inputVariable2 = 0; // both are correct - - - -Programmers should consider the size of the numbers they wish to -store in choosing variable types. Variables will -`roll over <#VariableRollover>`_ when the value stored exceeds the -space assigned to store it. See below for an example. - -.. _arduino-variables-scope: - -Variable Scope -^^^^^^^^^^^^^^ - -Another important choice that programmers face is where to declare -variables. The specific place that variables are declared -influences how various functions in a program will *see* the -variable. This is called variable -`scope <http://arduino.cc/en/Reference/Scope>`_. - -.. _arduino-variables-initializing: - -Initializing Variables -^^^^^^^^^^^^^^^^^^^^^^ - -Variables may be *initialized* (assigned a starting value) when -they are declared or not. It is always good programming practice -however to double check that a variable has valid data in it, -before it is accessed for some other purpose. - - - -Example: - -:: - - int calibrationVal = 17; // declare calibrationVal and set initial value - -.. _arduino-variables-rollover: - -Variable Rollover -^^^^^^^^^^^^^^^^^ - -When variables are made to exceed their maximum capacity they "roll -over" back to their minimum capacity, note that this happens in -both directions. - - - -:: - - int x - x = -32,768; - x = x - 1; // x now contains 32,767 - rolls over in neg. direction - - - -:: - - x = 32,767; - x = x + 1; // x now contains -32,768 - rolls over - - - -Using Variables -^^^^^^^^^^^^^^^ - -Once variables have been declared, they are used by setting the -variable equal to the value one wishes to store with the -`assignment operator <http://arduino.cc/en/Reference/Assignment>`_ -(single equal sign). The assignment operator tells the program to -put whatever is on the right side of the equal sign into the -variable on the left side. - - - -:: - - inputVariable1 = 7; // sets the variable named inputVariable1 to 7 - inputVariable2 = analogRead(2); // sets the variable named inputVariable2 to the - // (digitized) input voltage read from analog pin #2 - - - -Examples -^^^^^^^^ - -:: - - int lightSensVal; - char currentLetter; - unsigned long speedOfLight = 186000UL; - char errorMessage = {"choose another option"}; // see string - - - -Once a variable has been set (assigned a value), you can test its -value to see if it meets certain conditions, or you can use its -value directly. For instance, the following code tests whether the -inputVariable2 is less than 100, then sets a delay based on -inputVariable2 which is a minimum of 100: - - - -:: - - if (inputVariable2 < 100) - { - inputVariable2 = 100; - } - - delay(inputVariable2); - - - -This example shows all three useful operations with variables. It -tests the variable ( ``if (inputVariable2 < 100)`` ), it sets the -variable if it passes the test ( ``inputVariable2 = 100`` ), and it -uses the value of the variable as an input parameter to the delay() -function (``delay(inputVariable2)`` ) - - - -**Style Note:** You should give your variables descriptive names, -so as to make your code more readable. Variable names like -**tiltSensor** or **pushButton** help you (and anyone else reading -your code) understand what the variable represents. Variable names -like **var** or **value**, on the other hand, do little to make -your code readable. - - - -You can name a variable any word that is not already one of the -`keywords <http://arduino.cc/en/Reference/Keywords?action=edit>`_`? <http://arduino.cc/en/Reference/Keywords?action=edit>`_ -in Arduino. Avoid beginning variable names with numeral -characters. - - - -Some variable types -^^^^^^^^^^^^^^^^^^^ - - -- `char <http://arduino.cc/en/Reference/Char>`_ -- `byte <http://arduino.cc/en/Reference/Byte>`_ -- `int <http://arduino.cc/en/Reference/Int>`_ -- `unsigned int <http://arduino.cc/en/Reference/UnsignedInt>`_ -- `long <http://arduino.cc/en/Reference/Long>`_ -- `unsigned long <http://arduino.cc/en/Reference/UnsignedLong>`_ -- `float <http://arduino.cc/en/Reference/Float>`_ -- `double <http://arduino.cc/en/Reference/Double>`_ - - - -Variable Scope -^^^^^^^^^^^^^^ - - -- `Variable Scope <http://arduino.cc/en/Reference/scope>`_ - - - - -.. include:: cc-attribution.txt diff --git a/docs/source/arduino/word.rst b/docs/source/arduino/word.rst deleted file mode 100644 index 32506b8..0000000 --- a/docs/source/arduino/word.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. _arduino-word: - -word -==== - -Description ------------ - -A word stores a 16-bit unsigned number, from 0 to 65535. Same as an -unsigned int. - - - -Example -------- - -:: - - word w = 10000; - - - -See also --------- - - -- `byte <http://arduino.cc/en/Reference/Byte>`_ -- `word <http://arduino.cc/en/Reference/WordCast>`_\ () - - - -.. include:: cc-attribution.txt
\ No newline at end of file diff --git a/docs/source/arduino/wordcast.rst b/docs/source/arduino/wordcast.rst deleted file mode 100644 index 1e854ba..0000000 --- a/docs/source/arduino/wordcast.rst +++ /dev/null @@ -1,54 +0,0 @@ -.. _arduino-wordcast: - -word() -====== - -Description ------------ - -Convert a value to the -`word <http://arduino.cc/en/Reference/Word>`_ data type or create a -word from two bytes. - - - -Syntax ------- - -word(x) -word(h, l) - - - -Parameters ----------- - -x: a value of any type - - - -h: the high-order (leftmost) byte of the word - - - -l: the low-order (rightmost) byte of the word - - - -Returns -------- - -word - - - -See also --------- - - -- `word <http://arduino.cc/en/Reference/Word>`_ - - - - -.. include:: cc-attribution.txt
\ No newline at end of file diff --git a/docs/source/bootloader.rst b/docs/source/bootloader.rst index 46c2cf0..6cb9ece 100644 --- a/docs/source/bootloader.rst +++ b/docs/source/bootloader.rst @@ -226,12 +226,12 @@ A bootloader packet is composed of a sequence of fields, as follows. - 1 - 0--0xFF - Queries and responses must have the same sequence number; rolls - over to 0 after 0xFF. + over to 0 after 0xFF * - MESSAGE_SIZE - 2 - 0--0xFFFF - - Size of message body, currently limited to a 1024B maximum + - Size of message body, currently limited to a 1024B=1KB maximum * - TOKEN - 1 @@ -241,14 +241,32 @@ A bootloader packet is composed of a sequence of fields, as follows. * - MESSAGE_BODY - Variable, determined by MESSAGE_SIZE field - Command query or response - - See next section + - See :ref:`next section <bootloader-commands>` * - CHECKSUM - 4 - XOR of all other 32-bit words in packet - - Words are checksummed little-endian; however, like all - multi-byte fields, the CHECKSUM is transmitted between PC and - device in network (big-endian) order. + - See :ref:`below <bootloader-checksum>` + +.. _bootloader-checksum: + +.. highlight:: cpp + +.. note:: When computing the checksum, the words in a packet are + interpreted big-endian (as if the packet were a sequence of 32-bit, + big-endian unsigned integers). If the end of the MESSAGE_BODY is + not aligned with a four-byte boundary, then the checksum will treat + it as if it was padded with zero bytes to a four-byte boundary. + + As a concrete example, an entire GET_INFO query (see :ref:`below + <bootloader-get-info>`), including the packet structure, is + comprised of the byte sequence :: + + {0x1B, 0x7F, 0x00, 0x01, 0x7F, 0x00, 0x64, 0x7F, 0x00, 0x01} + + The SEQUENCE_NUM of this query is 0x7F. + +.. highlight:: sh .. _bootloader-commands: @@ -256,15 +274,16 @@ Commands ^^^^^^^^ The packet structure overhead is for reliability. The actual queries -and responses are transacted inside of the message body. Following in -the footsteps of the STK-500 protocol, each query or response begins -with the single byte CMD field. For each query, the resultant response -must begin with the same CMD byte. For each type of CMD, the structure -of queries and responses is of fixed size. Following STK-500, fields -longer than 1 byte are transmitted MSB first (big-endian). However, -READ and WRITE commands operate byte-wise (not word-wise); it is up to -the host PC to ensure that alignment and ordering issues are handled -appropriately. +and responses are transacted inside of the message body. Following +the STK-500 protocol, each query or response begins with the single +byte command field. For each query, the resultant response must begin +with the same CMD byte. For each type of command, the structure of +queries and responses is of fixed size. + +Also following STK-500, fields longer than 1 byte are transmitted MSB +first (big-endian). However, READ and WRITE commands operate byte-wise +(not word-wise); it is up to the host PC to ensure that alignment and +ordering issues are handled appropriately. .. _bootloader-get-info: @@ -447,7 +466,7 @@ READ_BYTES query: * - LENGTH - 2 - Maximum number of bytes to read (currently, this may be at most - 512). Must be a multiple of 4. + 1024 = 1KB). Must be a multiple of 4. READ_BYTES response: diff --git a/docs/source/external-interrupts.rst b/docs/source/external-interrupts.rst index 39828e3..79492ef 100644 --- a/docs/source/external-interrupts.rst +++ b/docs/source/external-interrupts.rst @@ -76,7 +76,7 @@ The following table shows which pins can be used on which lines. .. note:: - You should set the :ref:`pin mode <arduino-pinmode>` of your + You should set the :ref:`pin mode <lang-pinmode>` of your desired pin to an input mode (e.g ``INPUT`` or ``INPUT_FLOATING``, ``INPUT_PULLUP``, ``INPUT_PULLDOWN``). diff --git a/docs/source/foo.rst b/docs/source/foo.rst deleted file mode 100644 index 1da021c..0000000 --- a/docs/source/foo.rst +++ /dev/null @@ -1,122 +0,0 @@ -.. _foo: - -================================== -[temporary] Converted Arduino docs -================================== - -This is the index of the imported Arduino docs. - -Finished: - -.. toctree:: - :maxdepth: 1 - - abs() <arduino/abs> - analogRead() <arduino/analogread> - pinMode() <arduino/pinmode> - Arithmetic <arduino/arithmetic> - Arrays <arduino/array> - Assignment <arduino/assignment> - attachInterrupt() <arduino/attachinterrupt> - bit() <arduino/bit> - bitClear() <arduino/bitclear> - bitRead() <arduino/bitread> - bitSet() <arduino/bitset> - arduino/bitshift - arduino/analogwrite - arduino/bitwisemath - arduino/bitwisecompound - bitWrite() <arduino/bitwrite> - arduino/boolean - arduino/booleanvariables - arduino/braces - arduino/break - arduino/byte - arduino/bytecast - arduino/char - arduino/charcast - arduino/comments - arduino/const - constrain() <arduino/constrain> - arduino/continue - cos() <arduino/cos> - #define <arduino/define> - arduino/delay - arduino/delaymicroseconds - arduino/detachinterrupt - arduino/digitalread - arduino/double - arduino/doublecast - arduino/dowhile - arduino/else - arduino/float - arduino/floatcast - arduino/for - arduino/goto - arduino/highbyte - arduino/if - arduino/comparison - arduino/include - arduino/increment - arduino/arithmeticcompound - arduino/int - arduino/intcast - arduino/long - arduino/longcast - arduino/loop - arduino/max - arduino/min - arduino/modulo - arduino/pointer - arduino/pow - arduino/return - arduino/scope - arduino/semicolon - arduino/sin - arduino/sizeof - arduino/sqrt - arduino/sq - arduino/static - arduino/string - -Unfinished; straightforward to convert: - -.. toctree:: - :maxdepth: 1 - - arduino/switchcase - arduino/tan - arduino/unsignedchar - arduino/unsignedint - arduino/unsignedlong - arduino/variables - arduino/void - arduino/volatile - arduino/while - -Unfinished, requires libmaple/Arduino knowledge: - -.. toctree:: - :maxdepth: 1 - - arduino/word - arduino/wordcast - arduino/constants - arduino/digitalwrite - arduino/notone - arduino/serial - arduino/interrupts - analogWrite() <arduino/analogwrite> - arduino/nointerrupts - arduino/pulsein - arduino/stringobject - arduino/tone - arduino/random - arduino/randomseed - arduino/setup - arduino/map - arduino/shiftout - arduino/micros - arduino/millis - arduino/lowbyte - arduino/stringclass diff --git a/docs/source/ide.rst b/docs/source/ide.rst index c8dbd74..00dcf03 100644 --- a/docs/source/ide.rst +++ b/docs/source/ide.rst @@ -5,7 +5,19 @@ Maple IDE Documentation Stub. +.. TODO stub sections for all the other buttons, etc. + .. _ide-serial-monitor: Serial Monitor -------------- + +.. _ide-verify: + +Verify +------ + +.. _ide-upload: + +Upload +------ diff --git a/docs/source/index.rst b/docs/source/index.rst index ac91c4f..32fa28f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -3,17 +3,22 @@ Maple Documentation Index ========================= -Welcome! This is the documentation index for programming your Maple. -It contains tutorials, quickstarts, and technical documentation. +Welcome! This is the Maple documentation index. It contains +tutorials, quickstarts, and technical documentation. If you just got a new Maple, you probably want to begin with the :ref:`quickstart <maple-quickstart>`. You can then move on to reading about the programming language you use with the Maple at the -:ref:`language reference <language>`. Good luck, and have fun! +:ref:`language reference <language>`. + +If you're having problems, you might want to visit the +:ref:`troubleshooting <troubleshooting>` and :ref:`known problems +<errata>` pages. Finally, you can always hit the `forums +<http://forums.leaflabs.com/>`_ to ask questions to the LeafLabs team +and other Maple users. Good luck, and have fun! Table of contents: -.. TODO: be more Pythonic with a "parts of the documentation" thing .. toctree:: :maxdepth: 1 @@ -29,8 +34,7 @@ Table of contents: External Interrupts <external-interrupts> Bootloader <bootloader> Known Problems <errata> - [Temporary] Arduino docs TOC <foo> - [Temporary] Wirish-only docs TOC <wirish> + Language Reference Index <language-index> Indices and tables ================== diff --git a/docs/source/arduino/abs.rst b/docs/source/lang/abs.rst index 0ec6b47..ed95e6f 100644 --- a/docs/source/arduino/abs.rst +++ b/docs/source/lang/abs.rst @@ -1,4 +1,4 @@ -.. _arduino-abs: +.. _lang-abs: abs(x) ====== @@ -39,4 +39,4 @@ Arduino Compatibility Maple's implementation of ``abs()`` is compatible with Arduino. -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/analogread.rst b/docs/source/lang/analogread.rst index cd18567..0c93650 100644 --- a/docs/source/arduino/analogread.rst +++ b/docs/source/lang/analogread.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-analogread: +.. _lang-analogread: analogRead() ============ @@ -27,8 +27,8 @@ interfere with getting full accuracy and precision. For more information, see :ref:`adc`. Before calling analogRead() on a pin, that pin must first be -configured for analog input, using :ref:`arduino-pinMode` (you only -have to do this once, so it's usually done in :ref:`arduino-setup`\ ). +configured for analog input, using :ref:`lang-pinMode` (you only +have to do this once, so it's usually done in :ref:`lang-setup`\ ). It takes about 0.8 microseconds (.0000008 seconds) to read an analog input, so the maximum sample rate using this function is approximately @@ -62,16 +62,16 @@ Example :: - + int analogPin = 3; // potentiometer wiper (middle terminal) connected // to analog pin 3. outside leads to ground and +3.3V int val = 0; // variable to store the value read - + void setup() { pinMode(analogPin, INPUT_ANALOG); // set up pin for analog input SerialUSB.begin(); // set up usb virtual COM port } - + void loop() { val = analogRead(analogPin); // read the input pin SerialUSB.println(val); // print the value, for debugging with @@ -94,7 +94,7 @@ This yields a theoretical resolution between readings of: 5 volts / is larger, and thus less precise, than Maple's 0.0008 volts (0.8 mV). If your program expects Arduino-style 10-bit ADC, you can :ref:`right -shift <arduino-bitshift>` the value of a Maple readout by 2, like so:: +shift <lang-bitshift>` the value of a Maple readout by 2, like so:: // right shift means that the result will be between 0 and 1023; // be aware that you're losing a lot of precision if you do this @@ -149,4 +149,4 @@ See also <stm32-adc-oversampling>`_. -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/analogwrite.rst b/docs/source/lang/analogwrite.rst index a1057ab..d30d4d9 100644 --- a/docs/source/arduino/analogwrite.rst +++ b/docs/source/lang/analogwrite.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-analogwrite: +.. _lang-analogwrite: analogWrite() ============= @@ -8,19 +8,19 @@ analogWrite() .. note:: On the Maple, calling analogWrite() is the same as calling - :ref:`wirish-pwmwrite`\ ; see that function's documentation for more + :ref:`lang-pwmwrite`\ ; see that function's documentation for more information. This is because PWM is not true analog output (i.e., is not the output of a `DAC <http://en.wikipedia.org/wiki/Digital-to-analog_converter>`_\ ), so the function is badly named. For instance, **analogWrite() has - absolutely nothing to do with** :ref:`arduino-analogread`\ , which - is potentially confusing. + absolutely nothing to do with** :ref:`lang-analogread`\ , which is + potentially confusing. The alias of analogWrite() to pwmWrite() is provided (sigh) for the sake of compatibility with Arduino, but we recommend using - :ref:`wirish-pwmwrite` when writing new software, for clarity. + :ref:`lang-pwmwrite` when writing new software, for clarity. .. contents:: Contents :local: @@ -30,7 +30,7 @@ Arduino Compatibility There are a few important differences between Arduino's `analogWrite() <http://arduino.cc/en/Reference/AnalogWrite>`_ and Maple's -:ref:`wirish-pwmwrite` that you should keep in mind. In each case, we +:ref:`lang-pwmwrite` that you should keep in mind. In each case, we have some recommendations you can use to help converting from Arduino to Maple. @@ -47,7 +47,7 @@ This is a good thing! The greater range of values on the Maple gives you much more precise control over the duty cycle of your PWM output. If you're porting code from the Arduino and want a quick-and-dirty -fix, one solution is to :ref:`map <arduino-map>` the argument to +fix, one solution is to :ref:`map <lang-map>` the argument to analogWrite into the right range:: // Arduino code: @@ -67,26 +67,26 @@ pin you're using, then set that Timer's overflow to 255. Subsequent calls to analogWrite() should work as on the Arduino (with the same loss of precision). Note, however, that that affects the overflow for the **entire timer**, so other code relying on that timer (such as any -:ref:`interrupts <arduino-attachinterrupt>` the timer controls) will +:ref:`interrupts <lang-attachinterrupt>` the timer controls) will likely need to be modified as well. Difference 2: You must use pinMode() to set up PWM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The second difference is that on the Maple, you **must** set up the pin -for PWM output using :ref:`arduino-pinmode`\ , with argument ``PWM``. +for PWM output using :ref:`lang-pinmode`\ , with argument ``PWM``. This should just be one extra line of code in your -:ref:`arduino-setup` function. Example:: +:ref:`lang-setup` function. Example:: void setup() { // set up pin 9 for PWM pinMode(9, PWM); } -This also means that you can't later call :ref:`arduino-digitalread` -or :ref:`arduino-digitalwrite` on that pin (unless some time in +This also means that you can't later call :ref:`lang-digitalread` +or :ref:`lang-digitalwrite` on that pin (unless some time in between, you use pinMode() to reconfigure that pin for ``INPUT`` or -``OUTPUT``; see the :ref:`arduino-pinmode` page for more information). +``OUTPUT``; see the :ref:`lang-pinmode` page for more information). Difference 3: No PWM on pin 10 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -161,4 +161,4 @@ See also integer with size 2 bytes can hold the values between 0 and 65,535. -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/arithmetic.rst b/docs/source/lang/arithmetic.rst index 69cf166..9f21627 100644 --- a/docs/source/arduino/arithmetic.rst +++ b/docs/source/lang/arithmetic.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-arithmetic: +.. _lang-arithmetic: Addition, Subtraction, Multiplication, & Division ================================================= @@ -14,15 +14,15 @@ Description These operators return the sum, difference, product, or quotient (respectively) of the two operands. The operation is conducted using the data type of the operands, so, for example, ``9 / 4`` gives ``2`` -since 9 and 4 are :ref:`int variables <arduino-int>`. +since 9 and 4 are :ref:`int variables <lang-int>`. This also means that the operation can overflow if the result is larger than that which can be stored in the data type (e.g. adding 1 -to an :ref:`arduino-int` with the value 2147483647 gives +to an :ref:`lang-int` with the value 2147483647 gives -2147483648). If the operands are of different types, the "larger" type is used for the calculation. -.. _arduino-arithmetic-typeconversion: +.. _lang-arithmetic-typeconversion: .. note:: The specifics of these rules are beyond the scope of this documentation; for more information, see `The C++ Programming @@ -71,8 +71,8 @@ Parameters Programming Tips ---------------- -- Know that :ref:`integer constants <arduino-constants-integers>` - default to :ref:`int <arduino-int>`, so some constant calculations +- Know that :ref:`integer constants <lang-constants-integers>` + default to :ref:`int <lang-int>`, so some constant calculations may overflow (e.g., 200000 * 5000000 will yield a negative result). - Choose variable sizes that are large enough to hold the largest @@ -102,7 +102,7 @@ into overflow issues. The following table summarizes the sizes and ranges of integer datatypes on the Maple (the ranges of long long types are approximate): -.. _arduino-arithmetic-int-sizes: +.. _lang-arithmetic-int-sizes: .. csv-table:: :header: Datatype, Unsigned range, Signed range, Size (bytes) @@ -123,7 +123,7 @@ See Also <http://github.com/leaflabs/libmaple/blob/master/libmaple/libmaple_types.h>`_\ . -- :ref:`sizeof <arduino-sizeof>`\ () +- :ref:`sizeof <lang-sizeof>`\ () .. include:: cc-attribution.txt diff --git a/docs/source/arduino/arithmeticcompound.rst b/docs/source/lang/arithmeticcompound.rst index 734ef9d..aa0dc18 100644 --- a/docs/source/arduino/arithmeticcompound.rst +++ b/docs/source/lang/arithmeticcompound.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-arithmeticcompound: +.. _lang-arithmeticcompound: Compound Arithmetic Operators (``+=`` , ``-=``, ``*=``, ``/=``) =============================================================== @@ -40,7 +40,7 @@ number). See Also -------- -- :ref:`Arithmetic operators <arduino-arithmetic>` +- :ref:`Arithmetic operators <lang-arithmetic>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/array.rst b/docs/source/lang/array.rst index e49cc18..30a818f 100644 --- a/docs/source/arduino/array.rst +++ b/docs/source/lang/array.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-array: +.. _lang-array: Arrays ====== @@ -89,7 +89,7 @@ To retrieve a value from an array Arrays and ``for`` Loops ------------------------ -Arrays are often manipulated inside :ref:`for loops <arduino-for>`, where +Arrays are often manipulated inside :ref:`for loops <lang-for>`, where the loop counter is used as the index for each array element. For example, to print the elements of an array over the serial port, you could do something like this:: @@ -120,4 +120,4 @@ See also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/assignment.rst b/docs/source/lang/assignment.rst index 4907473..16f0bf4 100644 --- a/docs/source/arduino/assignment.rst +++ b/docs/source/lang/assignment.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-assignment: +.. _lang-assignment: = assignment operator (single equal sign) ========================================= @@ -67,4 +67,4 @@ See Also for more information. -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/attachinterrupt.rst b/docs/source/lang/attachinterrupt.rst index 3714709..0b8907f 100644 --- a/docs/source/arduino/attachinterrupt.rst +++ b/docs/source/lang/attachinterrupt.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-attachinterrupt: +.. _lang-attachinterrupt: attachInterrupt() ================= @@ -25,8 +25,8 @@ Discussion ---------- Because the function will run in interrupt context, inside of it, -:ref:`arduino-delay` won't work, and the value returned by -:ref:`arduino-millis` will not increment. Serial data received while +:ref:`lang-delay` won't work, and the value returned by +:ref:`lang-millis` will not increment. Serial data received while in the function may be lost. You should declare as ``volatile`` any global variables that you modify within the attached function. @@ -94,9 +94,9 @@ See also -------- -- :ref:`detachInterrupt <arduino-detachinterrupt>` +- :ref:`detachInterrupt <lang-detachinterrupt>` - :ref:`external-interrupts` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/bit.rst b/docs/source/lang/bit.rst index f25236c..c342fdd 100644 --- a/docs/source/arduino/bit.rst +++ b/docs/source/lang/bit.rst @@ -1,4 +1,4 @@ -.. _arduino-bit: +.. _lang-bit: bit() ===== @@ -39,10 +39,10 @@ See also -------- -- :ref:`arduino-bitread` -- :ref:`arduino-bitwrite` -- :ref:`arduino-bitset` -- :ref:`arduino-bitclear` +- :ref:`lang-bitread` +- :ref:`lang-bitwrite` +- :ref:`lang-bitset` +- :ref:`lang-bitclear` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/bitclear.rst b/docs/source/lang/bitclear.rst index 14261a6..5d1eb95 100644 --- a/docs/source/arduino/bitclear.rst +++ b/docs/source/lang/bitclear.rst @@ -1,4 +1,4 @@ -.. _arduino-bitclear: +.. _lang-bitclear: bitClear() ========== @@ -38,10 +38,10 @@ This implementation is compatible with that of Arduino. See also -------- -- :ref:`bit <arduino-bit>`\ () -- :ref:`bitRead <arduino-bitread>`\ () -- :ref:`bitWrite <arduino-bitwrite>`\ () -- :ref:`bitSet <arduino-bitset>`\ () +- :ref:`bit <lang-bit>`\ () +- :ref:`bitRead <lang-bitread>`\ () +- :ref:`bitWrite <lang-bitwrite>`\ () +- :ref:`bitSet <lang-bitset>`\ () -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/bitread.rst b/docs/source/lang/bitread.rst index f2cb037..9f885cf 100644 --- a/docs/source/arduino/bitread.rst +++ b/docs/source/lang/bitread.rst @@ -1,4 +1,4 @@ -.. _arduino-bitread: +.. _lang-bitread: bitRead() ========= @@ -40,10 +40,10 @@ See also -------- -- :ref:`arduino-bit` -- :ref:`arduino-bitwrite` -- :ref:`arduino-bitset` -- :ref:`arduino-bitclear` +- :ref:`lang-bit` +- :ref:`lang-bitwrite` +- :ref:`lang-bitset` +- :ref:`lang-bitclear` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/bitset.rst b/docs/source/lang/bitset.rst index b6964a0..502c1b6 100644 --- a/docs/source/arduino/bitset.rst +++ b/docs/source/lang/bitset.rst @@ -1,4 +1,4 @@ -.. _arduino-bitset: +.. _lang-bitset: bitSet() ======== @@ -39,11 +39,11 @@ The Maple implementation of bitSet is compatible with Arduino. See Also -------- -- :ref:`arduino-bit` -- :ref:`arduino-bitread` -- :ref:`arduino-bitwrite` -- :ref:`arduino-bitclear` +- :ref:`lang-bit` +- :ref:`lang-bitread` +- :ref:`lang-bitwrite` +- :ref:`lang-bitclear` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/bitshift.rst b/docs/source/lang/bitshift.rst index 00c466f..f05d49e 100644 --- a/docs/source/arduino/bitshift.rst +++ b/docs/source/lang/bitshift.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-bitshift: +.. _lang-bitshift: Bit shift left (``<<``), bit shift right (``>>``) ================================================= @@ -42,7 +42,7 @@ Parameters sizeof(variable)`` (so ``number_of_bits`` can be at most 32 for ``int`` values, at most ``8`` for ``char`` values, etc.; the various integer sizes are summarized :ref:`in this table - <arduino-arithmetic-int-sizes>`\ ). + <lang-arithmetic-int-sizes>`\ ). @@ -82,7 +82,7 @@ powers of 2, the following expressions can be employed:: 1 << 10 == 1024 ... -.. _arduino-bitshift-signbit-gotcha: +.. _lang-bitshift-signbit-gotcha: When you shift x right by y bits (``x >> y``), and the highest bit in x is a 1, the behavior depends on the exact data type of x. If x is of @@ -132,17 +132,17 @@ means that you can shift left, like ``x << y``, with bigger values of To calculate the number of bits of an integer type on the Maple, multiply its size in bytes (see :ref:`this table -<arduino-arithmetic-int-sizes>` for these) by 8, since there are 8 +<lang-arithmetic-int-sizes>` for these) by 8, since there are 8 bits in 1 byte. For example, a ``short`` takes up 2 bytes of memory, or 2 * 8 = 16 bits. See Also -------- -- :ref:`arduino-bit` -- :ref:`arduino-bitread` -- :ref:`arduino-bitwrite` -- :ref:`arduino-bitclear` +- :ref:`lang-bit` +- :ref:`lang-bitread` +- :ref:`lang-bitwrite` +- :ref:`lang-bitclear` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/bitwisecompound.rst b/docs/source/lang/bitwisecompound.rst index 92f3fdd..2b0fe2f 100644 --- a/docs/source/arduino/bitwisecompound.rst +++ b/docs/source/lang/bitwisecompound.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-bitwisecompound: +.. _lang-bitwisecompound: Compound bitwise and (&=), or (\|=), XOR (^=) ============================================= @@ -9,13 +9,13 @@ The compound bitwise operators perform their calculations at the bit level of variables. They are often used to clear and set specific bits of a variable. -See the :ref:`bitwise math tutorial <arduino-bitwisemath>` for more +See the :ref:`bitwise math tutorial <lang-bitwisemath>` for more information on bitwise operators. .. contents:: Contents :local: -.. _arduino-bitwisecompound-and: +.. _lang-bitwisecompound-and: Compound bitwise AND (&=) ------------------------- @@ -33,7 +33,7 @@ value of ``y``:: You can use any integer variable for ``x`` (i.e., any variable of type ``int``, ``long``, ``char``, ``byte``, etc.). You can use either an integer variable or any :ref:`integer value -<arduino-constants-integers>` (like ``3`` or ``0x20``) for ``y``. +<lang-constants-integers>` (like ``3`` or ``0x20``) for ``y``. Before doing an example of ``&=``, let's first review the Bitwise AND (``&``) operator:: @@ -48,16 +48,16 @@ bits that are "bitwise ANDed" with 1 are left unchanged. So, if ``b`` is a ``byte`` variable, then ``b & B00000000`` equals zero, and ``b & B11111111`` equals ``b``. -.. _arduino-bitwisecompound-binconst: +.. _lang-bitwisecompound-binconst: .. note:: The above uses :ref:`binary constants - <arduino-constants-integers-bin>`\ . The numbers are still the same + <lang-constants-integers-bin>`\ . The numbers are still the same value in other representations, they just might not be as easy to understand. Normally, in C and C++ code, :ref:`hexadecimal - <arduino-constants-integers-hex>` or :ref:`octal - <arduino-constants-integers-oct>` are used when we're interested in + <lang-constants-integers-hex>` or :ref:`octal + <lang-constants-integers-oct>` are used when we're interested in an integer's bits, rather than its value as a number. While hexadecimal and octal literals might be harder to understand @@ -101,7 +101,7 @@ then we will have :: b == B10101000; // B10101000 == 0xA8 -.. _arduino-bitwisecompound-or: +.. _lang-bitwisecompound-or: Compound bitwise OR (\|=) ------------------------- @@ -118,7 +118,7 @@ You can use any integer variable for ``x`` (i.e., any variable of type ``int``, ``long``, ``char``, ``byte``, etc.). You can use either an integer variable or any integer value (like ``3`` or ``0x20``) for ``y``. (This works the same way as :ref:`compound bitwise AND -<arduino-bitwisecompound-and>`\ , ``&=``). +<lang-bitwisecompound-and>`\ , ``&=``). Before doing an example of ``|=``, let's first review the Bitwise OR (``|``) operator:: @@ -132,7 +132,7 @@ Bits that are "bitwise ORed" with 0 are unchanged, while bits that are "bitwise ORed" with 1 are set to 1. So if ``b`` is a ``byte`` variable, then ``b | B00000000`` equals ``b``, and ``b & B11111111`` equals ``B11111111`` (here we've used binary constants; see the -:ref:`note <arduino-bitwisecompound-binconst>` above). +:ref:`note <lang-bitwisecompound-binconst>` above). So, to set bits 0 and 1 of a one-byte variable, while leaving the rest of the variable unchanged, use the compound bitwise OR operator @@ -164,7 +164,7 @@ then we will have :: b == B10101011; // B10101011 == 0xAB -.. _arduino-bitwisecompound-xor: +.. _lang-bitwisecompound-xor: Compound bitwise XOR (\^=) -------------------------- @@ -181,8 +181,8 @@ You can use any integer variable for ``x`` (i.e., any variable of type ``int``, ``long``, ``char``, ``byte``, etc.). You can use either an integer variable or any integer value (like ``3`` or ``0x20``) for ``y``. (This works the same way as :ref:`&= -<arduino-bitwisecompound-and>` and :ref:`\|= -<arduino-bitwisecompound-or>`; in fact, these three operators all +<lang-bitwisecompound-and>` and :ref:`\|= +<lang-bitwisecompound-or>`; in fact, these three operators all work the same in this way). Before doing an example of ``^=``, let's first review the Bitwise @@ -203,7 +203,7 @@ toggle) its value, while if you XOR a bit with 0, it stays the same. So, to toggle bits 0 and 1 of a one-byte variable, while leaving the rest of the variable unchanged, use the compound bitwise XOR operator ``^=`` with the constant ``B00000011`` (hexadecimal ``0x3``\ ; see -:ref:`note <arduino-bitwisecompound-binconst>` above):: +:ref:`note <lang-bitwisecompound-binconst>` above):: 1 0 1 0 1 0 1 0 variable 0 0 0 0 0 0 1 1 mask @@ -224,8 +224,8 @@ then we will have :: See Also -------- -- :ref:`Boolean operations <arduino-boolean>` (``&&``, ``||``) -- :ref:`Bitwise operators <arduino-bitwisemath>` (``&``, ``|``, ``^``, ``~``) +- :ref:`Boolean operations <lang-boolean>` (``&&``, ``||``) +- :ref:`Bitwise operators <lang-bitwisemath>` (``&``, ``|``, ``^``, ``~``) -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/bitwisemath.rst b/docs/source/lang/bitwisemath.rst index 40c3d7a..30e8873 100644 --- a/docs/source/arduino/bitwisemath.rst +++ b/docs/source/lang/bitwisemath.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-bitwisemath: +.. _lang-bitwisemath: Bitwise AND (&), OR (\|), XOR (^), NOT (~) ========================================== @@ -20,7 +20,7 @@ Below are descriptions and syntax for all of the operators. .. contents:: Contents :local: -.. _arduino-bitwisemath-and: +.. _lang-bitwisemath-and: Bitwise AND (&) --------------- @@ -52,7 +52,7 @@ AND, and all 32 resulting bits are stored in ``c``, resulting in the value 1000100 in binary, which is 68 in decimal. -.. _arduino-bitwisemath-or: +.. _lang-bitwisemath-or: Bitwise OR (\|) --------------- @@ -76,7 +76,7 @@ uses 32):: char b = 101; // in binary: 01100101 char c = a | b; // result: 01111101, or 125 in decimal. -.. _arduino-bitwisemath-xor: +.. _lang-bitwisemath-xor: Bitwise XOR (^) --------------- @@ -127,7 +127,7 @@ program to blink digital pin 13 (the LED pin on Maple):: delay(100); } -.. _arduino-bitwisemath-not: +.. _lang-bitwisemath-not: Bitwise NOT (~) --------------- @@ -178,8 +178,8 @@ glory, you could do much worse than to get yourself a copy of See Also -------- -- :ref:`Boolean operations <arduino-boolean>` (``&&``, ``||``) -- :ref:`Compound bitwise operations <arduino-bitwisecompound>` (``&=``, +- :ref:`Boolean operations <lang-boolean>` (``&&``, ``||``) +- :ref:`Compound bitwise operations <lang-bitwisecompound>` (``&=``, ``|=``, ``^=``). diff --git a/docs/source/arduino/bitwrite.rst b/docs/source/lang/bitwrite.rst index 0e57cc4..86df26e 100644 --- a/docs/source/arduino/bitwrite.rst +++ b/docs/source/lang/bitwrite.rst @@ -1,4 +1,4 @@ -.. _arduino-bitwrite: +.. _lang-bitwrite: bitWrite(x, n, b) ================= @@ -31,10 +31,10 @@ Maple's version of ``bitWrite()`` is compatible with Arduino. See also -------- -- :ref:`bit() <arduino-bit>` -- :ref:`bitRead() <arduino-bitRead>` -- :ref:`bitSet() <arduino-bitSet>` -- :ref:`bitClear() <arduino-bitClear>` +- :ref:`bit() <lang-bit>` +- :ref:`bitRead() <lang-bitRead>` +- :ref:`bitSet() <lang-bitSet>` +- :ref:`bitClear() <lang-bitClear>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/boolean.rst b/docs/source/lang/boolean.rst index 1d834d3..6ff4097 100644 --- a/docs/source/arduino/boolean.rst +++ b/docs/source/lang/boolean.rst @@ -1,18 +1,18 @@ .. highlight:: cpp -.. _arduino-boolean: +.. _lang-boolean: Boolean Operators ================= -These can be used inside the condition of an :ref:`if <arduino-if>` -statement. Evaluate to :ref:`true <arduino-constants-true>` or -:ref:`false <arduino-constants-false>`. +These can be used inside the condition of an :ref:`if <lang-if>` +statement. Evaluate to :ref:`true <lang-constants-true>` or +:ref:`false <lang-constants-false>`. .. contents:: Contents :local: -.. _arduino-boolean-and: +.. _lang-boolean-and: && (logical and) ---------------- @@ -33,7 +33,7 @@ using ``a >= 10``, then test whether ``a`` is at most 20 using ``a <= 20``, then combine the results using ``&&``. -.. _arduino-boolean-or: +.. _lang-boolean-or: \|\| (logical or) ----------------- @@ -46,7 +46,7 @@ True if either operand is true. For example:: is true if either ``x`` or ``y`` is greater than 0. -.. _arduino-boolean-not: +.. _lang-boolean-not: ! (logical not) --------------- @@ -66,14 +66,14 @@ Some Advice Make sure you don't mistake the boolean AND operator ``&&`` (double ampersand) for the :ref:`bitwise AND operator - <arduino-bitwisemath-and>` ``&`` (single ampersand). They are + <lang-bitwisemath-and>` ``&`` (single ampersand). They are entirely different beasts. Similarly, do not confuse the boolean OR operator ``||`` (double - pipe) with the :ref:`bitwise OR operator <arduino-bitwisemath-or>` + pipe) with the :ref:`bitwise OR operator <lang-bitwisemath-or>` ``|`` (single pipe). - The :ref:`bitwise NOT operator <arduino-bitwisemath-not>` ``~`` + The :ref:`bitwise NOT operator <lang-bitwisemath-not>` ``~`` (tilde) looks much different than the boolean not operator ``!`` (exclamation point, or "bang", as some programmers say), but you still have to be sure which one you want. @@ -82,10 +82,10 @@ Some Advice See Also -------- -- :ref:`Bitwise operators <arduino-bitwisemath>` (``&``, ``|``, ``^``, ``~``) -- :ref:`Compound bitwise operators <arduino-bitwisecompound>` (``&=``, +- :ref:`Bitwise operators <lang-bitwisemath>` (``&``, ``|``, ``^``, ``~``) +- :ref:`Compound bitwise operators <lang-bitwisecompound>` (``&=``, ``|=``, ``^=``). -- :ref:`if statement <arduino-if>` +- :ref:`if statement <lang-if>` .. include:: cc-attribution.txt diff --git a/docs/source/arduino/booleanvariables.rst b/docs/source/lang/booleanvariables.rst index a5f2c51..9d0e992 100644 --- a/docs/source/arduino/booleanvariables.rst +++ b/docs/source/lang/booleanvariables.rst @@ -1,12 +1,12 @@ .. highlight:: cpp -.. _arduino-booleanvariables: +.. _lang-booleanvariables: Booleans ======== A **boolean** holds one of two values, :ref:`true -<arduino-constants-true>` or :ref:`false <arduino-constants-false>`. +<lang-constants-true>` or :ref:`false <lang-constants-false>`. On a Maple, each boolean variable occupies one byte of memory, and has type ``bool``. @@ -47,9 +47,9 @@ See also -------- -- :ref:`Boolean constants <arduino-constants-bool>` -- :ref:`Boolean operators <arduino-boolean>` -- :ref:`Variables <arduino-variables>` +- :ref:`Boolean constants <lang-constants-bool>` +- :ref:`Boolean operators <lang-boolean>` +- :ref:`Variables <lang-variables>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/braces.rst b/docs/source/lang/braces.rst index 04518b3..229ad8c 100644 --- a/docs/source/arduino/braces.rst +++ b/docs/source/lang/braces.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-braces: +.. _lang-braces: Curly Braces ({}) ================= @@ -46,12 +46,12 @@ The main uses of curly braces **Functions**:: // a function body needs braces around it - void myfunction(datatype argument) { + void myFunction(datatype argument) { // ... function body goes in here ... } -**Loops** (see the :ref:`while <arduino-while>`\ , :ref:`for -<arduino-for>`\ , and :ref:`do/while <arduino-dowhile>` loop reference +**Loops** (see the :ref:`while <lang-while>`\ , :ref:`for +<lang-for>`\ , and :ref:`do/while <lang-dowhile>` loop reference pages for more information):: // you should put braces around the body of a loop: @@ -69,7 +69,7 @@ pages for more information):: } while (boolean expression); -**Conditional statements** (see the :ref:`if statement <arduino-if>` +**Conditional statements** (see the :ref:`if statement <lang-if>` reference page for more information):: // you should put braces around the body of an "if", "else if", @@ -85,6 +85,18 @@ reference page for more information):: // code inside the "else" } +**Switch statements** (see the :ref:`switch statement +<lang-switchcase>` reference page for more information):: + + switch (var) { + case 1: + doThing1(); + break; + case 2: + doThing2(); + break; + } + .. rubric:: Footnotes .. TODO remove this once IDE 0.1.0 released diff --git a/docs/source/arduino/break.rst b/docs/source/lang/break.rst index 3e1e9ee..dc50b5f 100644 --- a/docs/source/arduino/break.rst +++ b/docs/source/lang/break.rst @@ -1,14 +1,14 @@ .. highlight:: cpp -.. _arduino-break: +.. _lang-break: break ===== -``break`` is used to exit from a :ref:`while <arduino-while>`\ , -:ref:`for <arduino-for>`\ , or :ref:`do/while <arduino-dowhile>` loop, +``break`` is used to exit from a :ref:`while <lang-while>`\ , +:ref:`for <lang-for>`\ , or :ref:`do/while <lang-dowhile>` loop, bypassing the normal loop condition. It is also used to exit from a -:ref:`switch <arduino-switchcase>` statement. +:ref:`switch <lang-switchcase>` statement. Example diff --git a/docs/source/arduino/byte.rst b/docs/source/lang/byte.rst index 8478d0b..45c9d5f 100644 --- a/docs/source/arduino/byte.rst +++ b/docs/source/lang/byte.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-byte: +.. _lang-byte: byte ==== @@ -27,8 +27,8 @@ Example See Also -------- -- :ref:`byte() <arduino-bytecast>` (casting a value to a byte) -- :ref:`Variables <arduino-variables>` +- :ref:`byte() <lang-bytecast>` (casting a value to a byte) +- :ref:`Variables <lang-variables>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/bytecast.rst b/docs/source/lang/bytecast.rst index 348c9fb..4ad2a89 100644 --- a/docs/source/arduino/bytecast.rst +++ b/docs/source/lang/bytecast.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-bytecast: +.. _lang-bytecast: byte() (cast) ============= @@ -8,7 +8,7 @@ byte() (cast) Description ----------- -Converts a value to the :ref:`byte <arduino-byte>` data type. +Converts a value to the :ref:`byte <lang-byte>` data type. .. note:: @@ -45,7 +45,7 @@ the results might be strange and unexpected. See Also -------- -- :ref:`arduino-byte` +- :ref:`lang-byte` diff --git a/docs/source/arduino/cc-attribution.txt b/docs/source/lang/cc-attribution.txt index e100140..e100140 100644 --- a/docs/source/arduino/cc-attribution.txt +++ b/docs/source/lang/cc-attribution.txt diff --git a/docs/source/arduino/char.rst b/docs/source/lang/char.rst index 72d5ef2..8c6dadf 100644 --- a/docs/source/arduino/char.rst +++ b/docs/source/lang/char.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-char: +.. _lang-char: char ==== @@ -21,7 +21,7 @@ numbers. You can see the specific encoding in the `ASCII chart which the ASCII value of the character is used (e.g. ``'A' + 1`` has the decimal value 66, since the ASCII value of the capital letter A in decimal is 65). See the :ref:`Serial.println() -<arduino-serial-println>` documentation for more information about how +<lang-serial-println>` documentation for more information about how characters are converted into numbers. The ``char`` datatype is a signed type, meaning that it encodes @@ -34,7 +34,8 @@ Example :: - // the following two lines are equivalent: + // the following two lines are equivalent, using the ASCII + // character encoding: char c = 'A'; char c = 65; @@ -43,10 +44,10 @@ See also -------- -- :ref:`arduino-int` -- :ref:`arduino-array` (a string is just an array of ``char``\ s) -- :ref:`Serial.println() <arduino-serial-println>` +- :ref:`lang-int` +- :ref:`lang-array` (a string is just an array of ``char``\ s) +- :ref:`Serial.println() <lang-serial-println>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/charcast.rst b/docs/source/lang/charcast.rst index 91a0f8f..844dd58 100644 --- a/docs/source/arduino/charcast.rst +++ b/docs/source/lang/charcast.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-charcast: +.. _lang-charcast: char() (cast) ============= @@ -8,7 +8,7 @@ char() (cast) Description ----------- -Converts a value to the :ref:`char <arduino-char>` data type. +Converts a value to the :ref:`char <lang-char>` data type. Syntax ------ @@ -33,7 +33,7 @@ might be strange and unexpected. See Also -------- -- :ref:`char <arduino-char>` +- :ref:`char <lang-char>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/comments.rst b/docs/source/lang/comments.rst index b50aa0f..c5f118a 100644 --- a/docs/source/arduino/comments.rst +++ b/docs/source/lang/comments.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-comments: +.. _lang-comments: Comments ======== @@ -14,14 +14,14 @@ One use for comments is to help you understand (or remember) how your program works, or to inform others how your program works. There are two different ways of making comments. -.. _arduino-comments-singleline: +.. _lang-comments-singleline: **Single line comment**: Anything following two slashes, ``//``, until the end of the line, is a comment:: x = 5; // the rest of this line is a comment -.. _arduino-comments-multiline: +.. _lang-comments-multiline: **Multi-line comment**: Anything in between a pair of ``/*`` and ``*/`` is a comment:: diff --git a/docs/source/arduino/comparison.rst b/docs/source/lang/comparison.rst index e5e92d7..8873256 100644 --- a/docs/source/arduino/comparison.rst +++ b/docs/source/lang/comparison.rst @@ -1,14 +1,14 @@ .. highlight:: cpp -.. _arduino-comparison: +.. _lang-comparison: Comparison Operators ==================== The comparison operators ``==``, ``!=``, ``<``, ``>``, ``<=``, and ``>=`` are used to compare two numbers. They are :ref:`true -<arduino-constants-true>` when the comparison is true, and :ref:`false -<arduino-constants-false>` otherwise. They are based on the symbols +<lang-constants-true>` when the comparison is true, and :ref:`false +<lang-constants-false>` otherwise. They are based on the symbols =, ≠, <, >, ≤, and ≥ from mathematics. Here are some examples, with their meaning in comments:: @@ -42,8 +42,8 @@ Uses ---- Comparison operators, along with :ref:`boolean operators -<arduino-boolean>`, are useful inside the conditionals of :ref:`if -<arduino-if>` statements. Here's one example:: +<lang-boolean>`, are useful inside the conditionals of :ref:`if +<lang-if>` statements. Here's one example:: if (x < 50) { // only execute these lines if x is less than 50 @@ -70,9 +70,9 @@ Comparison operators, along with :ref:`boolean operators This is because C evaluates the statement ``if (x=10)`` as follows: 10 is assigned to x (remember that the single equal sign is the - :ref:`assignment operator <arduino-assignment>`), so x now + :ref:`assignment operator <lang-assignment>`), so x now contains 10. Then the 'if' conditional evaluates 10, which evaluates - to :ref:`true <arduino-constants-true>`, since any non-zero number + to :ref:`true <lang-constants-true>`, since any non-zero number evaluates to ``true``. Consequently, the conditional of an ``if`` statement like ``if (x = @@ -84,4 +84,4 @@ Comparison operators, along with :ref:`boolean operators Be careful to know what you mean.) -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/const.rst b/docs/source/lang/const.rst index b008144..1658e6d 100644 --- a/docs/source/arduino/const.rst +++ b/docs/source/lang/const.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-const: +.. _lang-const: const Keyword ============= @@ -13,9 +13,9 @@ changed. You will get a compiler error if you try to assign a value to a ``const`` variable. Constants defined with the ``const`` keyword obey the same rules of -:ref:`variable scoping <arduino-scope>` that govern other +:ref:`variable scoping <lang-scope>` that govern other variables. This, and the pitfalls of using :ref:`#define -<arduino-define>`, often makes using the ``const`` keyword a superior +<lang-define>`, often makes using the ``const`` keyword a superior method for defining constants than ``#define``. Example @@ -38,15 +38,15 @@ Example ------------------------ You can use either ``const`` or ``#define`` for creating numeric or -string constants. For :ref:`arrays <arduino-array>`\ , you will need +string constants. For :ref:`arrays <lang-array>`\ , you will need to use ``const``. In general, ``const`` is preferred over ``#define`` for defining constants. See Also -------- -- :ref:`#define <arduino-define>` -- :ref:`volatile <arduino-volatile>` +- :ref:`#define <lang-define>` +- :ref:`volatile <lang-volatile>` .. include:: cc-attribution.txt diff --git a/docs/source/arduino/constants.rst b/docs/source/lang/constants.rst index e841c9b..b7521ed 100644 --- a/docs/source/arduino/constants.rst +++ b/docs/source/lang/constants.rst @@ -1,4 +1,4 @@ -.. _arduino-constants: +.. _lang-constants: constants ========= @@ -10,7 +10,7 @@ in groups. .. contents:: Contents :local: -.. _arduino-constants-bool: +.. _lang-constants-bool: Boolean Constants ----------------- @@ -18,7 +18,7 @@ Boolean Constants There are two constants used to represent truth and falsity in the Arduino language: **true**, and **false**. -.. _arduino-constants-false: +.. _lang-constants-false: false ^^^^^ @@ -26,7 +26,7 @@ false false is the easier of the two to define. false is defined as 0 (zero). -.. _arduino-constants-true: +.. _lang-constants-true: true ^^^^ @@ -47,7 +47,7 @@ Defining Pin Levels, HIGH and LOW When reading or writing to a digital pin there are only two possible values a pin can take/be-set-to: **HIGH** and **LOW**. -.. _arduino-constants-high: +.. _lang-constants-high: **HIGH** @@ -74,7 +74,7 @@ with digitalWrite, the pin is at 5 volts. In this state it can series resistor to ground, or to another pin configured as an output, and set to LOW. -.. _arduino-constants-low: +.. _lang-constants-low: **LOW** @@ -103,7 +103,7 @@ Digital pins can be used either as **INPUT** or **OUTPUT**. Changing a pin from INPUT TO OUTPUT with pinMode() drastically changes the electrical behavior of the pin. -.. _arduino-constants-input: +.. _lang-constants-input: Pins Configured as Inputs ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -115,7 +115,7 @@ circuit that they are sampling, say equivalent to a series resistor of 100 Megohms in front of the pin. This makes them useful for reading a sensor, but not powering an LED. -.. _arduino-constants-output: +.. _lang-constants-output: Pins Configured as Outputs ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -132,7 +132,7 @@ of current provided by an Atmega pin is also not enough to power most relays or motors, and some interface circuitry will be required. -.. _arduino-constants-fp: +.. _lang-constants-fp: Floating-Point Constants ------------------------ @@ -143,7 +143,7 @@ compile time for the value to which the expression evaluates. .. TODO explain that floating point literals are doubles -.. _arduino-constants-fp-f: +.. _lang-constants-fp-f: .. TODO f modifiers @@ -165,7 +165,7 @@ exponent indicators. 2.34E5 2.34 * 10^5 234000 67e-12 67.0 * 10^-12 .000000000067 -.. _arduino-constants-integers: +.. _lang-constants-integers: Integer Constants ----------------- @@ -196,7 +196,7 @@ numbers in other bases. 16 (hexadecimal) 0x7B leading "0x" characters 0-9, A-F, a-f valid -.. _arduino-constants-integers-dec: +.. _lang-constants-integers-dec: **Decimal** is base 10. This is the common-sense math with which you are acquainted. Constants without other prefixes are assumed to @@ -209,7 +209,7 @@ Example: 101 // same as 101 decimal ((1 * 10^2) + (0 * 10^1) + 1) -.. _arduino-constants-integers-bin: +.. _lang-constants-integers-bin: **Binary** is base two. Only characters 0 and 1 are valid. @@ -230,7 +230,7 @@ in binary form you can do it a two-step procedure such as: myInt = (B11001100 * 256) + B10101010; // B11001100 is the high byte -.. _arduino-constants-integers-oct: +.. _lang-constants-integers-oct: **Octal** is base eight. Only characters 0 through 7 are valid. Octal values are indicated by the prefix "0". @@ -246,7 +246,7 @@ It is possible to generate a hard-to-find bug by (unintentionally) including a leading zero before a constant and having the compiler unintentionally interpret your constant as octal. -.. _arduino-constants-integers-hex: +.. _lang-constants-integers-hex: **Hexadecimal (or hex)** is base sixteen. Valid characters are 0 through 9 and letters A through F; A has the value 10, B is 11, up @@ -261,7 +261,7 @@ Example: 0x101 // same as 257 decimal ((1 * 16^2) + (0 * 16^1) + 1) -.. _arduino-constants-integers-u-l: +.. _lang-constants-integers-u-l: U & L formatters ^^^^^^^^^^^^^^^^ diff --git a/docs/source/arduino/constrain.rst b/docs/source/lang/constrain.rst index a43b8f8..297a2d4 100644 --- a/docs/source/arduino/constrain.rst +++ b/docs/source/lang/constrain.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-constrain: +.. _lang-constrain: constrain(x, a, b) ================== @@ -58,8 +58,8 @@ Maple's implementation of ``constrain()`` is compatible with Arduino. See also -------- -- :ref:`min() <arduino-min>` -- :ref:`max() <arduino-max>` +- :ref:`min() <lang-min>` +- :ref:`max() <lang-max>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/continue.rst b/docs/source/lang/continue.rst index bda1c95..21b3984 100644 --- a/docs/source/arduino/continue.rst +++ b/docs/source/lang/continue.rst @@ -1,14 +1,14 @@ .. highlight:: cpp -.. _arduino-continue: +.. _lang-continue: ========== continue ========== The ``continue`` keyword skips the rest of the current iteration of a -:ref:`while <arduino-while>`\ , :ref:`for <arduino-for>`\ , or -:ref:`do/while <arduino-dowhile>` loop. It continues by checking the +:ref:`while <lang-while>`\ , :ref:`for <lang-for>`\ , or +:ref:`do/while <lang-dowhile>` loop. It continues by checking the conditional expression of the loop, and proceeding with any subsequent iterations. diff --git a/docs/source/arduino/cos.rst b/docs/source/lang/cos.rst index e1188d0..3fbb0af 100644 --- a/docs/source/arduino/cos.rst +++ b/docs/source/lang/cos.rst @@ -1,16 +1,15 @@ -.. _arduino-cos: +.. _lang-cos: -cos(rad) -======== +cos() +===== -Calculate the cosine of an angle (in radians). +Calculates the cosine of an angle. Library Documentation --------------------- .. doxygenfunction:: cos - Arduino Compatibility --------------------- @@ -24,10 +23,10 @@ See also -------- -- :ref:`sin() <arduino-sin>` -- :ref:`tan() <arduino-tan>` -- :ref:`float <arduino-float>` -- :ref:`double <arduino-double>` +- :ref:`sin() <lang-sin>` +- :ref:`tan() <lang-tan>` +- :ref:`float <lang-float>` +- :ref:`double <lang-double>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/define.rst b/docs/source/lang/define.rst index 6a403d4..30738ec 100644 --- a/docs/source/arduino/define.rst +++ b/docs/source/lang/define.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-define: +.. _lang-define: #define ======= @@ -11,7 +11,7 @@ The compiler will replace references to these constants with the defined value at compile time. This can have some unwanted side effects. In general, the :ref:`const -<arduino-const>` keyword is preferred for defining constants. +<lang-const>` keyword is preferred for defining constants. Syntax @@ -50,7 +50,7 @@ Example See Also -------- -- :ref:`const <arduino-const>` +- :ref:`const <lang-const>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/delay.rst b/docs/source/lang/delay.rst index 64d78aa..90ca268 100644 --- a/docs/source/arduino/delay.rst +++ b/docs/source/lang/delay.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-delay: +.. _lang-delay: delay() ======= @@ -23,18 +23,18 @@ debouncing, the use of ``delay()`` in a sketch has significant drawbacks. No other reading of sensors, mathematical calculations, or pin manipulation can go on during the delay function, so in effect, it brings most other activity to a halt. For alternative approaches to -controlling timing see the :ref:`millis() <arduino-millis>` function +controlling timing see the :ref:`millis() <lang-millis>` function and the "Blink Without Delay" sketch cited :ref:`below -<arduino-delay-seealso>`\ . More knowledgeable programmers usually +<lang-delay-seealso>`\ . More knowledgeable programmers usually avoid the use of ``delay()`` for timing of events longer than tens of milliseconds, unless the sketch is very simple. Certain things *do* go on while the ``delay()`` function is controlling the STM32 chip, however, because the delay function does not disable interrupts. Serial communication that appears at the RX -pin is recorded, PWM (see :ref:`pwmWrite() <wirish-pwmwrite>`\ ) -values and pin states are maintained, and :ref:`interrupts -<arduino-attachinterrupt>` will work as they should. +pin is recorded, PWM (see :ref:`pwmWrite() <lang-pwmwrite>`\ ) values +and pin states are maintained, and :ref:`interrupts +<lang-attachinterrupt>` will work as they should. Example @@ -43,11 +43,11 @@ Example :: int ledPin = 13; // LED connected to pin 13 - + void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin as output } - + void loop() { digitalWrite(ledPin, HIGH); // sets the LED on delay(1000); // waits for a second @@ -55,16 +55,18 @@ Example delay(1000); // waits for a second } -.. _arduino-delay-seealso: +.. _lang-delay-seealso: See also -------- -- :ref:`millis() <arduino-millis>` -- :ref:`micros() <arduino-micros>` -- :ref:`delayMicroseconds() <arduino-delayMicroseconds>` -- (Arduino) `Blink Without Delay <http://arduino.cc/en/Tutorial/BlinkWithoutDelay>`_ example (works unmodified on Maple) +- :ref:`millis() <lang-millis>` +- :ref:`micros() <lang-micros>` +- :ref:`delayMicroseconds() <lang-delayMicroseconds>` +- (Arduino) `Blink Without Delay + <http://arduino.cc/en/Tutorial/BlinkWithoutDelay>`_ example (works + unmodified on Maple) -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/delaymicroseconds.rst b/docs/source/lang/delaymicroseconds.rst index d1016f1..24a8286 100644 --- a/docs/source/arduino/delaymicroseconds.rst +++ b/docs/source/lang/delaymicroseconds.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-delaymicroseconds: +.. _lang-delaymicroseconds: delayMicroseconds() =================== @@ -42,7 +42,7 @@ Caveats and Known Issues The longest time ``delayMicroseconds()`` can delay is bounded by its argument type and the STM32 clock rate to be (2^32 - 1) / 12 microseconds, or less than 6 minutes. For longer pauses, use of -:ref:`arduino-delay` is possible. +:ref:`lang-delay` is possible. Arduino Compatibility --------------------- @@ -55,9 +55,9 @@ especially for smaller values of ``us``. See Also -------- -- :ref:`millis <arduino-millis>` -- :ref:`micros <arduino-micros>` -- :ref:`delay <arduino-delay>` +- :ref:`millis <lang-millis>` +- :ref:`micros <lang-micros>` +- :ref:`delay <lang-delay>` diff --git a/docs/source/arduino/detachinterrupt.rst b/docs/source/lang/detachinterrupt.rst index 6e037e6..adb2439 100644 --- a/docs/source/arduino/detachinterrupt.rst +++ b/docs/source/lang/detachinterrupt.rst @@ -1,10 +1,10 @@ -.. _arduino-detachinterrupt: +.. _lang-detachinterrupt: detachInterrupt() ================= Used to disable an interrupt specified with -:ref:`arduino-attachinterrupt`\ . +:ref:`lang-attachinterrupt`\ . Library Documentation @@ -22,16 +22,16 @@ attached, while on the Arduino, the argument is the *interrupt number*, which is different from the pin the interrupt is enabled on. If you're calling this function, you've already called -:ref:`arduino-attachinterrupt` to set up your interrupt handler, so +:ref:`lang-attachinterrupt` to set up your interrupt handler, so just call ``detachInterrupt()`` with the same pin argument you gave to ``attachInterrupt()``. See Also -------- -- :ref:`attachInterrupt() <arduino-attachInterrupt>` +- :ref:`attachInterrupt() <lang-attachInterrupt>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/digitalread.rst b/docs/source/lang/digitalread.rst index daf04f8..71583ca 100644 --- a/docs/source/arduino/digitalread.rst +++ b/docs/source/lang/digitalread.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-digitalread: +.. _lang-digitalread: digitalRead() ============= @@ -9,7 +9,7 @@ Description ----------- Reads the value from a specified digital pin, either :ref:`HIGH -<arduino-constants-high>` or :ref:`LOW <arduino-constants-low>`. +<lang-constants-high>` or :ref:`LOW <lang-constants-low>`. Library Documentation @@ -25,12 +25,12 @@ The following example turns the LED on when the button is pressed:: int ledPin = 13; // LED connected to Maple pin 13 int buttonPin = 38; // BUT connected to Maple pin 38 - + void setup() { pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT); } - + void loop() { int val = digitalRead(buttonPin); // reads the input pin digitalWrite(ledPin, val); @@ -51,11 +51,11 @@ The Maple version of ``digitalRead()`` is compatible with Arduino. See Also -------- -- :ref:`pinMode <arduino-pinMode>` -- :ref:`digitalWrite <arduino-digitalWrite>` +- :ref:`pinMode <lang-pinMode>` +- :ref:`digitalWrite <lang-digitalWrite>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/digitalwrite.rst b/docs/source/lang/digitalwrite.rst index b80d5c6..419ef3a 100644 --- a/docs/source/arduino/digitalwrite.rst +++ b/docs/source/lang/digitalwrite.rst @@ -1,4 +1,4 @@ -.. _arduino-digitalwrite: +.. _lang-digitalwrite: digitalWrite() ============== @@ -71,14 +71,14 @@ Example :: - + int ledPin = 13; // LED connected to digital pin 13 - + void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin as output } - + void loop() { digitalWrite(ledPin, HIGH); // sets the LED on @@ -113,4 +113,4 @@ See also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/double.rst b/docs/source/lang/double.rst index d1c1076..b4a1219 100644 --- a/docs/source/arduino/double.rst +++ b/docs/source/lang/double.rst @@ -1,4 +1,4 @@ -.. _arduino-double: +.. _lang-double: double ====== @@ -6,7 +6,10 @@ double Description ----------- -Double precision floating point number. Occupies 8 bytes. +Double precision floating point number. Occupies 8 bytes. On Maple, +the ``double`` type has a range of approximately -1.79769×10^308 to +1.79769×10^308; the ``double`` type subject to the same :ref:`overflow +issues <lang-variables-rollover>` as any numeric data type. Floating point numbers are not exact, and may yield strange results when compared. For example ``6.0 / 3.0`` may not equal ``2.0``. You @@ -19,8 +22,8 @@ has to run at top speed for a critical timing function. Programmers often go to some lengths to convert floating point calculations to integer math to increase speed. -For more information about floating point math, see the `Wikipedia -article <http://en.wikipedia.org/wiki/Floating_point>`_\ . +For more information, see the `Wikipedia article on floating point +math <http://en.wikipedia.org/wiki/Floating_point>`_\ . Floating-point numbers represent numbers with "decimal point", unlike integral types, which always represent whole numbers. Floating-point @@ -28,22 +31,21 @@ numbers are often used to approximate analog and continuous values because they have greater resolution than integers. The double implementation on the Maple uses twice the number of bytes -as a :ref:`float <arduino-float>`, with the corresponding gains in +as a :ref:`float <lang-float>`, with the corresponding gains in precision. Tip --- -Users who borrow code from other sources that includes double -variables may wish to examine the code to see if the implied -precision is different from that actually achieved on the Maple. - +Users who borrow code from other sources that includes ``double`` +variables may wish to examine the code to see if the implied range and +precision are different from that actually achieved on the Maple. See Also -------- -- :ref:`float <arduino-float>` +- :ref:`float <lang-float>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/doublecast.rst b/docs/source/lang/doublecast.rst index 9aaf12c..4ea1776 100644 --- a/docs/source/arduino/doublecast.rst +++ b/docs/source/lang/doublecast.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-doublecast: +.. _lang-doublecast: double() (cast) =============== @@ -8,7 +8,7 @@ double() (cast) Description ----------- -Converts a value to the :ref:`double <arduino-double>` floating point +Converts a value to the :ref:`double <lang-double>` floating point data type. Here is an example:: int x = 2; @@ -17,14 +17,14 @@ data type. Here is an example:: The value ``x`` can be of any type. However, if ``x`` is not a number (like an ``int`` or ``long``), you will get strange results. -See the :ref:`double <arduino-double>` reference for details about the +See the :ref:`double <lang-double>` reference for details about the precision and limitations of ``double`` values on the Maple. See Also -------- -- :ref:`double <arduino-double>` -- :ref:`float <arduino-float>` -- :ref:`float() <arduino-floatcast>` +- :ref:`double <lang-double>` +- :ref:`float <lang-float>` +- :ref:`float() <lang-floatcast>` .. include:: cc-attribution.txt diff --git a/docs/source/arduino/dowhile.rst b/docs/source/lang/dowhile.rst index 7dffe50..77e02a3 100644 --- a/docs/source/arduino/dowhile.rst +++ b/docs/source/lang/dowhile.rst @@ -1,12 +1,12 @@ .. highlight:: cpp -.. _arduino-dowhile: +.. _lang-dowhile: do/while Loop ============= A ``do`` loop works in the same manner as a :ref:`while -<arduino-while>` loop, with the exception that the condition is tested +<lang-while>` loop, with the exception that the condition is tested at the end of the loop, so the ``do`` loop will *always* run at least once. @@ -24,4 +24,4 @@ Example:: } while (x < 100); -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/else.rst b/docs/source/lang/else.rst index 9345e8a..863f21b 100644 --- a/docs/source/arduino/else.rst +++ b/docs/source/lang/else.rst @@ -1,14 +1,14 @@ .. highlight:: cpp -.. _arduino-else: +.. _lang-else: if/else ======= ``if``/\ ``else`` allows greater control over the flow of code than -the basic :ref:`if <arduino-if>` statement, by allowing multiple tests +the basic :ref:`if <lang-if>` statement, by allowing multiple tests to be grouped together. For example, an :ref:`analog input -<arduino-analogread>` could be tested, with one action taken if the +<lang-analogread>` could be tested, with one action taken if the input was less than 500, and another action taken if the input was 500 or greater. The code would look like this:: @@ -42,13 +42,13 @@ such ``else if`` branches is allowed. Here is a code example:: } Another way to express branching, mutually exclusive tests, is with a -:ref:`switch/case <arduino-switchcase>` statement. +:ref:`switch/case <lang-switchcase>` statement. See Also -------- -- :ref:`if <arduino-if>` -- :ref:`switch/case <arduino-switchcase>` +- :ref:`if <lang-if>` +- :ref:`switch/case <lang-switchcase>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/lang/enum.rst b/docs/source/lang/enum.rst new file mode 100644 index 0000000..5ecd99c --- /dev/null +++ b/docs/source/lang/enum.rst @@ -0,0 +1,8 @@ +.. _lang-enum: + +enum +==== + +Stub. + +Reference this from language.rst diff --git a/docs/source/lang/float.rst b/docs/source/lang/float.rst new file mode 100644 index 0000000..ef1a339 --- /dev/null +++ b/docs/source/lang/float.rst @@ -0,0 +1,53 @@ +.. highlight:: cpp + +.. _lang-float: + +float +===== + +Description +----------- + +Single-precision floating point number. Occupies 4 bytes. On Maple, +the ``float`` type has a range of approximately -3.40282×10^38 to +3.40282×10^38; the ``float`` type is subject to the same +:ref:`overflow issues <lang-variables-rollover>` as any numeric data +type. + +``float``\ s have only 6-7 decimal digits of precision. That means the +total number of digits, not the number to the right of the decimal +point. You can get more precision by using a :ref:`double +<lang-double>` (which has a precision of about 16 decimal digits). + +The following example declares a ``float`` value named ``myfloat``:: + + float myfloat; + +This example declares a ``float`` value named ``sensorCalibrate``, +with value 1.117:: + + float sensorCalibrate = 1.117; + +The general syntax for declaring a float named ``var`` with value +``val`` is:: + + float var = val; + +Here is a more extended example involving a :ref:`float cast +<lang-floatcast>`:: + + int x; + int y; + float z; + + x = 1; + y = x / 2; // y now contains 0, ints can't hold fractions + z = float(x) / 2; // z now contains .5 + +See Also +-------- + +- :ref:`double <lang-double>` +- :ref:`Variables <lang-variables>` + +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/floatcast.rst b/docs/source/lang/floatcast.rst index a8d1113..7476188 100644 --- a/docs/source/arduino/floatcast.rst +++ b/docs/source/lang/floatcast.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-floatcast: +.. _lang-floatcast: float() (cast) ============== @@ -8,9 +8,9 @@ float() (cast) Description ----------- -Converts a value to the :ref:`float <arduino-float>` data type. Here +Converts a value to the :ref:`float <lang-float>` data type. Here is an example (see the :ref:`constants reference -<arduino-constants-fp-f>` for an explanation of the "2.0f"):: +<lang-constants-fp-f>` for an explanation of the "2.0f"):: int x = 2; float f = float(x); // f now holds 2.0f, a float value @@ -18,14 +18,14 @@ is an example (see the :ref:`constants reference The value ``x`` can be of any type. However, if ``x`` is not a number (like an ``int``), you will get strange results. -See the :ref:`float <arduino-float>` reference for details about the +See the :ref:`float <lang-float>` reference for details about the precision and limitations of ``float`` values on the Maple. See Also -------- -- :ref:`float <arduino-float>` -- :ref:`double <arduino-double>` -- :ref:`double() <arduino-doublecast>` +- :ref:`float <lang-float>` +- :ref:`double <lang-double>` +- :ref:`double() <lang-doublecast>` .. include:: cc-attribution.txt diff --git a/docs/source/arduino/for.rst b/docs/source/lang/for.rst index 43b82fa..6b00d7a 100644 --- a/docs/source/arduino/for.rst +++ b/docs/source/lang/for.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-for: +.. _lang-for: for Loops ========= @@ -14,7 +14,7 @@ Description A ``for`` loop is used to repeat a block of statements enclosed in curly braces. ``for`` loops are useful for performing repetitive operations, and are often used in combination with :ref:`arrays -<arduino-array>` to operate on collections of data or multiple +<lang-array>` to operate on collections of data or multiple :ref:`pins <gpio>`. A ``for`` loop is composed of two parts: first, a *header*, which sets up the for loop, and then a *body*, which is made up of lines of code enclosed in curly braces. @@ -34,7 +34,7 @@ expression. The general syntax looks like this:: (Note that there is no semicolon after the post-loop). The initialization happens first and exactly once, before the loop begins. Each time through the loop, the condition is tested. The condition is -a :ref:`boolean arduino-boolean` expression. If it is true, then the +a :ref:`boolean <lang-boolean>` expression. If it is true, then the list of statements inside the curly braces are executed. Next, the post-loop is executed. The loop then begins again by evaluating the condition again, entering the loop body if it is true. This proceeds @@ -59,16 +59,16 @@ Here's an example:: } } -There is a ``for`` loop In the :ref:`loop() <arduino-loop>` function -of the above example. This loop starts by declaring an ``int`` -variable named ``i``, whose value starts out at zero. The loop -proceeds by checking if ``i`` is less than or equal to 65535. Since -``i`` is zero, this is true, and so the calls to :ref:`pwmWrite() -<wirish-pwmwrite>` and :ref:`arduino-delay` happen next. At this +There is a ``for`` loop In the :ref:`loop() <lang-loop>` function of +the above example. This loop starts by declaring an ``int`` variable +named ``i``, whose value starts out at zero. The loop proceeds by +checking if ``i`` is less than or equal to 65535. Since ``i`` is +zero, this is true, and so the calls to :ref:`pwmWrite() +<lang-pwmwrite>` and :ref:`delay() <lang-delay>` happen next. At this point, the post-loop expression ``i++`` is evaluated, which -:ref:`increments <arduino-increment>` ``i``, so that ``i`` becomes -one. That concludes the first time through the loop. Each "time -through the loop" is referred to as an *iteration*. +:ref:`increments <lang-increment>` ``i``, so that ``i`` becomes one. +That concludes the first time through the loop. Each "time through +the loop" is referred to as an *iteration*. The loop then jumps back to the beginning, checking the condition as the beginning of its second iteration (initialization is skipped, @@ -79,7 +79,7 @@ reaches 65536. At that point, the condition is no longer true, so the loop stops executing, and the ``loop()`` function returns. Here's another example, using a ``for`` loop to brighten and fade an -LED (see the :ref:`pwmWrite() <wirish-pwmwrite>` reference for more +LED (see the :ref:`pwmWrite() <lang-pwmwrite>` reference for more information):: int pwmPin = 9; // hook up the LED to pin 9 @@ -102,7 +102,7 @@ other computer languages, including BASIC. Any or all of the three header elements may be left blank, although the semicolons are required. Also the statements for initialization, condition, and post-loop can be any valid C statements, and use any C datatypes, -including :ref:`floating point numbers <arduino-double>`. These types +including :ref:`floating point numbers <lang-double>`. These types of unusual ``for`` loops sometimes provide solutions to less-common programming problems. @@ -126,8 +126,8 @@ questions (answers are in footnote [#fanswers]_\ ): See also -------- -- :ref:`while <arduino-while>` loops -- :ref:`do <arduino-dowhile>` loops +- :ref:`while <lang-while>` loops +- :ref:`do <lang-dowhile>` loops .. rubric:: Footnotes @@ -139,4 +139,4 @@ See also false, and the loop stops. -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/goto.rst b/docs/source/lang/goto.rst index 2901913..96a6262 100644 --- a/docs/source/arduino/goto.rst +++ b/docs/source/lang/goto.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-goto: +.. _lang-goto: Labels and goto =============== @@ -25,7 +25,7 @@ Using Labels and goto Labels and ``goto`` are probably best explained through example. Let's start with an example of how to label lines. The first line -(``int x = analogRead(some_pin);``) in the :ref:`loop <arduino-loop>` +(``int x = analogRead(some_pin);``) in the :ref:`loop <lang-loop>` function below has label ``readpin``. The third line (``delay(x);``) has label ``startdelay``. The second line (``SerialUSB.println(x);``) does not have a label:: @@ -39,7 +39,7 @@ does not have a label:: // ... more code ... } -Anything which can be a :ref:`variable <arduino-variables>` name can +Anything which can be a :ref:`variable <lang-variables>` name can be a label. Let's say that we wanted to print ``x`` only if it was very large, say @@ -62,7 +62,7 @@ a longer wait than usual. We can accomplish this through the use of a } In this modified program, whenever ``x`` is less than 2000, the body -of the :ref:`if <arduino-if>` statement in the second line is +of the :ref:`if <lang-if>` statement in the second line is executed. The ``goto`` statement inside the ``if`` body skips straight to the line labeled ``startdelay``, passing over the line doing the printing. @@ -86,7 +86,7 @@ As mentioned above, use of ``goto`` is `generally discouraged <http://en.wikipedia.org/wiki/Goto#Criticism_and_decline>`_. However, when used with care, ``goto`` can simplify certain programs. One important use case for ``goto`` is breaking out of deeply nested -:ref:`for <arduino-for>` loops or :ref:`if <arduino-if>` logic blocks. +:ref:`for <lang-for>` loops or :ref:`if <lang-if>` logic blocks. Here's an example:: for(int r = 0; r < 255; r++) { @@ -104,10 +104,10 @@ Here's an example:: // more code here In the above example, whenever the :ref:`analog reading -<arduino-analogread>` on pin 0 was greater than 250, the program would +<lang-analogread>` on pin 0 was greater than 250, the program would jump to the line labeled ``bailout``, exiting all three loops at once. -While there is already a :ref:`break <arduino-break>` keyword for +While there is already a :ref:`break <lang-break>` keyword for breaking out of a loop, it will only break out of the *innermost* loop. So, if instead of saying "``goto bailout;``", there was a "``break;``" instead, the program would only exit from the loop with diff --git a/docs/source/arduino/highbyte.rst b/docs/source/lang/highbyte.rst index 5b1c24e..af0bfcd 100644 --- a/docs/source/arduino/highbyte.rst +++ b/docs/source/lang/highbyte.rst @@ -1,4 +1,4 @@ -.. _arduino-highbyte: +.. _lang-highbyte: highByte(x) =========== @@ -44,7 +44,7 @@ The Maple version of ``highByte()`` is compatible with Arduino. See Also -------- -- :ref:`lowByte() <arduino-lowbyte>` +- :ref:`lowByte() <lang-lowbyte>` diff --git a/docs/source/arduino/if.rst b/docs/source/lang/if.rst index 89af166..02ba1e7 100644 --- a/docs/source/arduino/if.rst +++ b/docs/source/lang/if.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-if: +.. _lang-if: if Statements ============= @@ -15,7 +15,7 @@ are met. The general syntax for an ``if`` statement is:: An ``if`` statement first tests whether its *condition* is true (such as an input being above a certain number). If the condition is true, the ``if`` statement executes its *body*, which is made up of lines of -code inside :ref:`curly braces <arduino-braces>`. If the condition is +code inside :ref:`curly braces <lang-braces>`. If the condition is false, the body is not executed. Here's a more concrete example:: if (someVariable > 50) { @@ -25,15 +25,15 @@ false, the body is not executed. Here's a more concrete example:: The program tests to see if ``someVariable`` is greater than 50. If it is, the program executes every line in the curly braces (which in the above example does nothing, since the body is just the :ref:`comment -<arduino-comments>` line "``// do something here``"). +<lang-comments>` line "``// do something here``"). Put another way, if the statement in parentheses is true, the statements inside the braces are run. If not, the program skips over the code. An ``if`` statement's condition (which is inside the parentheses after -``if``) often uses one or more :ref:`boolean <arduino-boolean>` or -:ref:`comparison <arduino-comparison>` operators. +``if``) often uses one or more :ref:`boolean <lang-boolean>` or +:ref:`comparison <lang-comparison>` operators. Writing the if Body ------------------- @@ -73,9 +73,9 @@ missing, only the first line is in the ``if`` body. See Also -------- -- :ref:`boolean operators <arduino-boolean>` -- :ref:`comparison operators <arduino-comparison>` -- :ref:`else <arduino-else>` +- :ref:`boolean operators <lang-boolean>` +- :ref:`comparison operators <lang-comparison>` +- :ref:`else <lang-else>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/include.rst b/docs/source/lang/include.rst index 37553f4..a8bc74c 100644 --- a/docs/source/arduino/include.rst +++ b/docs/source/lang/include.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-include: +.. _lang-include: #include ======== @@ -38,7 +38,7 @@ that is used to control :ref:`LCD displays <liquid-crystal>`:: lcd.print(millis()/1000); } -Note that a ``#include`` line, like :ref:`#define <arduino-define>`, +Note that a ``#include`` line, like :ref:`#define <lang-define>`, has **no semicolon**. The compiler will print strange error messages if you add one. @@ -68,4 +68,4 @@ root <http://en.wikipedia.org/wiki/Cube_root>`_ of a number:: -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/increment.rst b/docs/source/lang/increment.rst index 38dee6c..5536a0a 100644 --- a/docs/source/arduino/increment.rst +++ b/docs/source/lang/increment.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-increment: +.. _lang-increment: Increment (``++``) and Decrement (``--``) ========================================= @@ -38,7 +38,7 @@ etc.). See also -------- -- :ref:`Compound arithmetic operators <arduino-arithmeticcompound>` +- :ref:`Compound arithmetic operators <lang-arithmeticcompound>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/int.rst b/docs/source/lang/int.rst index 690deb8..ac2f16a 100644 --- a/docs/source/arduino/int.rst +++ b/docs/source/lang/int.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-int: +.. _lang-int: int === @@ -23,9 +23,9 @@ two's complement for more information). The Maple takes care of dealing with negative numbers for you, so that arithmetic operations work mostly as you'd expect. There can be an -:ref:`unexpected complication <arduino-bitshift-signbit-gotcha>` in +:ref:`unexpected complication <lang-bitshift-signbit-gotcha>` in dealing with the :ref:`bitshift right operator (>>) -<arduino-bitshift>`, however. +<lang-bitshift>`, however. Here is an example of declaring an ``int`` variable named ``ledPin``, then giving it value 13:: @@ -37,16 +37,14 @@ then giving it value ``val``, looks like:: int var = val; -.. _arduino-int-overflow: +.. _lang-int-overflow: Integer Overflow ---------------- -When ``int`` variables leave the range specified above, they "roll -over" in the other direction. It's like in the game *Pac-Man* -- when -Pac-Man goes past the right edge of the screen, he reappears on the -left, and when he goes past the left side of the screen, he reappears -on the right. Here are some examples:: +When ``int`` variables leave the range specified above, they +:ref:`roll over <lang-variable-rollover>` in the other direction. +Here are some examples:: int x; x = -2,147,483,648; @@ -58,13 +56,12 @@ on the right. Here are some examples:: See Also -------- -- :ref:`unsigned int <arduino-unsignedint>` -- :ref:`char <arduino-char>` -- :ref:`unsigned char <arduino-unsignedchar>` -- :ref:`long <arduino-long>` -- :ref:`unsigned long <arduino-unsignedlong>` -- :ref:`Integer Constants <arduino-constants-integers>` -- :ref:`Variables <arduino-variables>` +- :ref:`unsigned int <lang-unsignedint>` +- :ref:`char <lang-char>` +- :ref:`unsigned char <lang-unsignedchar>` +- :ref:`long <lang-long>` +- :ref:`unsigned long <lang-unsignedlong>` +- :ref:`Integer Constants <lang-constants-integers>` +- :ref:`Variables <lang-variables>` - -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/intcast.rst b/docs/source/lang/intcast.rst index 0b34a39..03c0c07 100644 --- a/docs/source/arduino/intcast.rst +++ b/docs/source/lang/intcast.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-intcast: +.. _lang-intcast: int() ===== @@ -8,7 +8,7 @@ int() Description ----------- -Converts a value to the :ref:`int <arduino-int>` data type. Here is +Converts a value to the :ref:`int <lang-int>` data type. Here is an example:: double d = 2.5; @@ -18,15 +18,15 @@ The value inside of the parentheses (``int(...)``) can be of any type. However, if it is not a numeric type (like ``double``, ``char``, etc.), you will get strange results. -See the :ref:`int <arduino-int>` reference for details about the +See the :ref:`int <lang-int>` reference for details about the precision and limitations of ``int`` variables on the Maple. See Also -------- -- :ref:`int <arduino-int>` +- :ref:`int <lang-int>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/interrupts.rst b/docs/source/lang/interrupts.rst index b9c95b1..5ca7041 100644 --- a/docs/source/arduino/interrupts.rst +++ b/docs/source/lang/interrupts.rst @@ -1,4 +1,4 @@ -.. _arduino-interrupts: +.. _lang-interrupts: interrupts() ============ @@ -37,7 +37,7 @@ Example :: void setup() {} - + void loop() { noInterrupts(); @@ -59,4 +59,4 @@ See Also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/lang/keywords.rst b/docs/source/lang/keywords.rst new file mode 100644 index 0000000..451701e --- /dev/null +++ b/docs/source/lang/keywords.rst @@ -0,0 +1,11 @@ +.. _lang-keywords: + +Keywords +======== + +Stub. + +Include list of all C++ keywords, with links to internal documentation +as appropriate. + +Reference this page from language.rst diff --git a/docs/source/arduino/long.rst b/docs/source/lang/long.rst index cae659a..8a19b2b 100644 --- a/docs/source/arduino/long.rst +++ b/docs/source/lang/long.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-long: +.. _lang-long: long ==== @@ -10,15 +10,17 @@ Description The ``long`` data type stores extended size integer values. You can use a ``long`` when your values are too large to fit into an :ref:`int -<arduino-int>`. A ``long`` occupies 8 bytes of memory. This yields a +<lang-int>`. A ``long`` occupies 8 bytes of memory. This yields a range of approximately -9.2×10^18 to 9.2×10^18 (that's 9.2 billion billion, or about 92 million times the number of stars in the Milky Way galaxy). The exact range of a ``long`` on the Maple is from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807, or -2^63 to -(2^63-1). +(2^63-1). A ``long`` it is subject to the same :ref:`overflow issues +<lang-variables-rollover>` as any numeric data type. Here's an example of declaring a long (see :ref:`integer constants -<arduino-constants-u-l>` for explanation of the 'L'):: +<lang-constants-u-l>` for an explanation of the "L" at the end of the +number):: // Speed of light in nanometers per second (approximate). long c = 299792458000000000L; @@ -32,24 +34,22 @@ This is identical to the ``int`` syntax, with ``long`` replacing ``int``. Note that ``long`` values will still :ref:`overflow -<arduino-int-overflow>`, just like ``int`` values, but their much +<lang-int-overflow>`, just like ``int`` values, but their much larger range makes this less likely to happen. The downside to using a ``long`` instead of an ``int`` (besides the -extra storage) is that :ref:`arithmetic <arduino-arithmetic>` -operations on ``long``\ s will take longer than on ``int``\ s. +extra storage) is that :ref:`arithmetic <lang-arithmetic>` operations +on ``long``\ s will take slightly longer than on ``int``\ s. See Also -------- -- :ref:`char <arduino-char>` -- :ref:`unsigned char <arduino-unsignedchar>` -- :ref:`int <arduino-int>` -- :ref:`unsigned int <arduino-unsignedint>` -- :ref:`unsigned long <arduino-unsignedlong>` -- :ref:`Integer Constants <arduino-constants-integers>` -- :ref:`Variables <arduino-variables>` +- :ref:`char <lang-char>` +- :ref:`unsigned char <lang-unsignedchar>` +- :ref:`int <lang-int>` +- :ref:`unsigned int <lang-unsignedint>` +- :ref:`unsigned long <lang-unsignedlong>` +- :ref:`Integer Constants <lang-constants-integers>` +- :ref:`Variables <lang-variables>` - - -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/longcast.rst b/docs/source/lang/longcast.rst index f247dae..16d7582 100644 --- a/docs/source/arduino/longcast.rst +++ b/docs/source/lang/longcast.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-longcast: +.. _lang-longcast: long() ====== @@ -8,7 +8,7 @@ long() Description ----------- -Converts a value to the :ref:`long <arduino-long>` data type. Here is +Converts a value to the :ref:`long <lang-long>` data type. Here is an example:: double d = 2.5; @@ -18,13 +18,13 @@ The value inside of the parentheses (``long(...)``) can be of any type. However, if it is not a numeric type (like ``double``, ``char``, etc.), you will get strange results. -See the :ref:`long <arduino-long>` reference for details about the +See the :ref:`long <lang-long>` reference for details about the precision and limitations of ``long`` variables on the Maple. See Also -------- -- :ref:`long <arduino-long>` +- :ref:`long <lang-long>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/loop.rst b/docs/source/lang/loop.rst index 4383ab6..d8f6183 100644 --- a/docs/source/arduino/loop.rst +++ b/docs/source/lang/loop.rst @@ -1,11 +1,11 @@ .. highlight:: cpp -.. _arduino-loop: +.. _lang-loop: loop() ====== -After creating a :ref:`setup() <arduino-setup>` function, which +After creating a :ref:`setup() <lang-setup>` function, which initializes your sketch, the ``loop()`` function gets called repeatedly, allowing your program to change and respond. Use it to actively control your Maple board. @@ -39,7 +39,7 @@ Example See Also -------- -- :ref:`setup() <arduino-setup>` +- :ref:`setup() <lang-setup>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/lowbyte.rst b/docs/source/lang/lowbyte.rst index 9331181..f9fb711 100644 --- a/docs/source/arduino/lowbyte.rst +++ b/docs/source/lang/lowbyte.rst @@ -1,4 +1,4 @@ -.. _arduino-lowbyte: +.. _lang-lowbyte: lowByte() ========= @@ -42,4 +42,4 @@ See also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/map.rst b/docs/source/lang/map.rst index 61aa626..40b12a8 100644 --- a/docs/source/arduino/map.rst +++ b/docs/source/lang/map.rst @@ -1,4 +1,4 @@ -.. _arduino-map: +.. _lang-map: map(value, fromLow, fromHigh, toLow, toHigh) ============================================ @@ -86,7 +86,7 @@ Example /* Map an analog value to 8 bits (0 to 255) */ void setup() {} - + void loop() { int val = analogRead(0); @@ -119,4 +119,4 @@ See Also - `constrain <http://arduino.cc/en/Reference/Constrain>`_\ () -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/max.rst b/docs/source/lang/max.rst index a80c421..7dbf6a7 100644 --- a/docs/source/arduino/max.rst +++ b/docs/source/lang/max.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-max: +.. _lang-max: max(x, y) ========= @@ -35,7 +35,7 @@ Example .. note:: Perhaps counter-intuitively, max() is often used to constrain the lower end of a variable's range, while :ref:`min() - <arduino-min>` is used to constrain the upper end of the range. + <lang-min>` is used to constrain the upper end of the range. Warning ------- @@ -56,8 +56,8 @@ The Maple version of ``max()`` is compatible with Arduino. See Also -------- -- :ref:`min() <arduino-min>` -- :ref:`constrain() <arduino-constrain>` +- :ref:`min() <lang-min>` +- :ref:`constrain() <lang-constrain>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/micros.rst b/docs/source/lang/micros.rst index bd8b926..711c013 100644 --- a/docs/source/arduino/micros.rst +++ b/docs/source/lang/micros.rst @@ -1,4 +1,4 @@ -.. _arduino-micros: +.. _lang-micros: micros() ======== @@ -41,7 +41,7 @@ Example :: unsigned long time; - + void setup(){ Serial.begin(9600); } @@ -66,4 +66,4 @@ See also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/millis.rst b/docs/source/lang/millis.rst index f52d396..6ebfff5 100644 --- a/docs/source/arduino/millis.rst +++ b/docs/source/lang/millis.rst @@ -1,4 +1,4 @@ -.. _arduino-millis: +.. _lang-millis: millis() ======== diff --git a/docs/source/arduino/min.rst b/docs/source/lang/min.rst index efe78ca..ffbf1ee 100644 --- a/docs/source/arduino/min.rst +++ b/docs/source/lang/min.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-min: +.. _lang-min: min(x, y) ========= @@ -59,8 +59,8 @@ The Maple version of ``min()`` is compatible with Arduino. See Also -------- -- :ref:`max() <arduino-max>` -- :ref:`constrain() <arduino-constrain>` +- :ref:`max() <lang-max>` +- :ref:`constrain() <lang-constrain>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/modulo.rst b/docs/source/lang/modulo.rst index bb65600..9e0dabd 100644 --- a/docs/source/arduino/modulo.rst +++ b/docs/source/lang/modulo.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-modulo: +.. _lang-modulo: % (modulo) ========== @@ -71,7 +71,7 @@ the C standard library function `fmod() See Also -------- -- :ref:`Arithmetic <arduino-arithmetic>` +- :ref:`Arithmetic <lang-arithmetic>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/nointerrupts.rst b/docs/source/lang/nointerrupts.rst index 8711ebb..2043c91 100644 --- a/docs/source/arduino/nointerrupts.rst +++ b/docs/source/lang/nointerrupts.rst @@ -1,4 +1,4 @@ -.. _arduino-nointerrupts: +.. _lang-nointerrupts: noInterrupts() ============== @@ -36,7 +36,7 @@ Example :: void setup() {} - + void loop() { noInterrupts(); @@ -56,4 +56,4 @@ See Also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/notone.rst b/docs/source/lang/notone.rst index 9e59065..22432e2 100644 --- a/docs/source/arduino/notone.rst +++ b/docs/source/lang/notone.rst @@ -1,4 +1,4 @@ -.. _arduino-notone: +.. _lang-notone: noTone() ======== @@ -47,4 +47,4 @@ See also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/pinmode.rst b/docs/source/lang/pinmode.rst index e84e1e6..aed23d6 100644 --- a/docs/source/arduino/pinmode.rst +++ b/docs/source/lang/pinmode.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-pinmode: +.. _lang-pinmode: pinMode() ========= @@ -18,8 +18,8 @@ Library Documentation Discussion ---------- -pinMode() is usually called within :ref:`arduino-setup` in order to -configure a pin for a certain usage (although it may be called +pinMode() is usually called within :ref:`lang-setup` in order to +configure a pin for a certain usage (although it may be called anywhere). @@ -28,14 +28,14 @@ Example :: - + int ledPin = 13; // LED connected to digital pin 13 - + void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin as output } - + void loop() { digitalWrite(ledPin, HIGH); // sets the LED on @@ -55,9 +55,9 @@ modes with a meaning identical to that of the Arduino function. INPUT_ANALOG and PWM modes were added because the Maple does not distinguish between analog and digital pins the same way the Arduino does. Unlike the Arduino, you **must call pinMode**\ () to set up a pin -for these purposes before a call to, e.g., :ref:`arduino-analogRead`. +for these purposes before a call to, e.g., :ref:`lang-analogRead`. In practice, this should only add a few lines of pinMode() calls to -your :ref:`arduino-setup` function. +your :ref:`lang-setup` function. OUTPUT_OPEN_DRAIN, INPUT_PULLUP, INPUT_PULLDOWN, and PWM_OPEN_DRAIN modes represent functionality not currently available on Arduino @@ -66,11 +66,11 @@ boards. See also -------- -- :ref:`arduino-constants` -- :ref:`arduino-digitalwrite` -- :ref:`arduino-digitalread` +- :ref:`lang-constants` +- :ref:`lang-digitalwrite` +- :ref:`lang-digitalread` - Maple :ref:`GPIO <gpio>` reference page -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/pointer.rst b/docs/source/lang/pointer.rst index efc81ca..bc48d7d 100644 --- a/docs/source/arduino/pointer.rst +++ b/docs/source/lang/pointer.rst @@ -1,4 +1,4 @@ -.. _arduino-pointer: +.. _lang-pointer: The pointer operators: & (reference) and \* (dereference) ========================================================= @@ -25,4 +25,4 @@ See Also - http://xkcd.com/138/ -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/pow.rst b/docs/source/lang/pow.rst index 0a7355c..dbe89b6 100644 --- a/docs/source/arduino/pow.rst +++ b/docs/source/lang/pow.rst @@ -1,4 +1,4 @@ -.. _arduino-pow: +.. _lang-pow: pow(base, exponent) =================== @@ -21,9 +21,9 @@ function in the Arduino playground for more on this. See Also -------- -- :ref:`sqrt() <arduino-sqrt>` -- :ref:`float <arduino-float>` -- :ref:`double <arduino-double>` +- :ref:`sqrt() <lang-sqrt>` +- :ref:`float <lang-float>` +- :ref:`double <lang-double>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/pulsein.rst b/docs/source/lang/pulsein.rst index f26f754..7bbe84c 100644 --- a/docs/source/arduino/pulsein.rst +++ b/docs/source/lang/pulsein.rst @@ -1,4 +1,4 @@ -.. _arduino-pulsein: +.. _lang-pulsein: pulseIn() ========= @@ -61,16 +61,16 @@ Example :: - - + + int pin = 7; unsigned long duration; - + void setup() { pinMode(pin, INPUT); } - + void loop() { duration = pulseIn(pin, HIGH); @@ -79,4 +79,4 @@ Example -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/wirish/pwmwrite.rst b/docs/source/lang/pwmwrite.rst index 7667a72..acc0240 100644 --- a/docs/source/wirish/pwmwrite.rst +++ b/docs/source/lang/pwmwrite.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _wirish-pwmwrite: +.. _lang-pwmwrite: pwmWrite() ========== diff --git a/docs/source/arduino/random.rst b/docs/source/lang/random.rst index 8da92b0..51bee67 100644 --- a/docs/source/arduino/random.rst +++ b/docs/source/lang/random.rst @@ -1,4 +1,4 @@ -.. _arduino-random: +.. _lang-random: random() ======== @@ -59,26 +59,26 @@ Example :: long randNumber; - + void setup(){ Serial.begin(9600); - + // if analog input pin 0 is unconnected, random analog // noise will cause the call to randomSeed() to generate // different seed numbers each time the sketch runs. // randomSeed() will then shuffle the random function. randomSeed(analogRead(0)); } - + void loop() { // print a random number from 0 to 299 randNumber = random(300); - Serial.println(randNumber); - + Serial.println(randNumber); + // print a random number from 10 to 19 randNumber = random(10, 20); Serial.println(randNumber); - + delay(50); } @@ -92,4 +92,4 @@ See also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/randomseed.rst b/docs/source/lang/randomseed.rst index 983c66d..3dcf4db 100644 --- a/docs/source/arduino/randomseed.rst +++ b/docs/source/lang/randomseed.rst @@ -1,4 +1,4 @@ -.. _arduino-randomseed: +.. _lang-randomseed: randomSeed(seed) ================ @@ -46,16 +46,16 @@ Example :: long randNumber; - + void setup(){ Serial.begin(9600); randomSeed(analogRead(0)); } - + void loop(){ randNumber = random(300); Serial.println(randNumber); - + delay(50); } @@ -70,4 +70,4 @@ See also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/return.rst b/docs/source/lang/return.rst index fd1493d..e1b2924 100644 --- a/docs/source/arduino/return.rst +++ b/docs/source/lang/return.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-return: +.. _lang-return: return ====== @@ -22,7 +22,7 @@ Syntax: In the second case, ``value`` should have a type which is the same as the return type of the function, or be convertible to it (like an ``int`` to a ``long``, etc.; see :ref:`this note -<arduino-arithmetic-typeconversion>` for some references). +<lang-arithmetic-typeconversion>` for some references). Examples: --------- @@ -55,7 +55,7 @@ like so:: See Also -------- -- :ref:`comments <arduino-comments>` +- :ref:`comments <lang-comments>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/lang/scope.rst b/docs/source/lang/scope.rst new file mode 100644 index 0000000..8e8bb13 --- /dev/null +++ b/docs/source/lang/scope.rst @@ -0,0 +1,120 @@ +.. highlight:: cpp + +.. _lang-scope: + +Variable Scope +============== + +Variables in the C++ programming language, which Maple uses (all of +your sketches are C++ programs in disguise), have a property called +*scope*. Simply put, a variable's scope is made up of all of the +lines where the variable can be used. + +Scope in C++ is a fairly complex topic, so we won't try to describe it +in full here. Instead, we present a simplified view, describing two +different kinds of scopes, *global* and *local*. For more detailed +information, consult a C++ reference. + +Global and Local Variables +-------------------------- + +A global variable is one that can be "seen" by every function in a +program. In the :ref:`Maple IDE <ide>`, any variable declared outside +of a function (like :ref:`setup() <lang-setup>` and :ref:`loop() +<lang-loop>`) is a global variable. + +A local variable can only be "seen" inside of a particular function. +You can declare a variable to be local to a function by declaring it +inside of the :ref:`curly braces <lang-braces>` which enclose that +function. + +When programs start to get larger and more complex, local variables +are a useful way to ensure that a function has exclusive access to its +own variables. This prevents programming errors when one function +mistakenly modifies variables used by another function. + +It is also sometimes useful to declare and initialize a variable +inside a :ref:`for <lang-for>` loop. This creates a variable that +can only be accessed from inside the loop body. + +Example +------- + +Here is an example sketch (which you can copy into the Maple IDE and +run on your Maple) that illustrates the use of global and local +variables, as well as declaring variables inside of a ``for`` loop. +Be sure to open a :ref:`serial monitor <ide-serial-monitor>` after you +:ref:`verify <ide-verify>` and :ref:`upload <ide-upload>` the sketch:: + + int globalVar; // any function will see this variable + + void setup() { + // since "globalVar" is declared outside of any function, + // every function can "see" and use it: + globalVar = 50; + + // the variables "i" and "d" declared inside the "loop" function + // can't be seen here. see what happens when you uncomment the + // following lines, and try to Verify (compile) the sketch: + // + // i = 16; + // SerialUSB.print("i = "); + // SerialUSB.println(i); + // d = 26.5; + // SerialUSB.print("d = "); + // SerialUSB.println(d); + } + + void loop() { + // since "i" and "d" are declared inside of the "loop" function, + // they can only be seen and used from inside of it: + int i; + double d; + + for (int j = 0; j < 5; j++) { + // variable i can be used anywhere inside the "loop" function; + // variable j can only be accessed inside the for-loop brackets: + i = j * j; + SerialUSB.print("i = "); + SerialUSB.println(i); + } + + // globalVar can be accessed from anywhere. note how even + // though we set globalVar = 50 in the "setup" function, we can + // see that value here: + SerialUSB.print("globalVar = "); + SerialUSB.println(globalVar); + + // d can be accessed from anywhere inside the "loop" function: + d = 26.5; + SerialUSB.print("d = "); + SerialUSB.print(d); + SerialUSB.println(" (before separateFunction())"); + + separateFunction(); + + // notice how even though separateFunction() has a variable + // named "d", it didn't touch our (local) variable which has + // the same name: + SerialUSB.print("d = "); + SerialUSB.print(d); + SerialUSB.println(" (after separateFunction())"); + } + + void separateFunction() { + // variable "d" here has the same name as variable "d" inside of + // the "loop" function, but since they're both _local_ + // variables, they don't affect each other: + double d = 30.5; + SerialUSB.print("d = "); + SerialUSB.print(d); + SerialUSB.println(" (inside of separateFunction())"); + } + +See Also +-------- + +- `C++ programming Wikibook <http://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Statements/Scope>`_. +- Wikipedia article on `scope <http://en.wikipedia.org/wiki/Scope_%28programming%29>`_ + +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/semicolon.rst b/docs/source/lang/semicolon.rst index b90d925..4cf7b9f 100644 --- a/docs/source/arduino/semicolon.rst +++ b/docs/source/lang/semicolon.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-semicolon: +.. _lang-semicolon: Semicolon (;) ============= @@ -22,4 +22,4 @@ which the compiler complained. -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/serial.rst b/docs/source/lang/serial.rst index 1bcd28d..743f921 100644 --- a/docs/source/arduino/serial.rst +++ b/docs/source/lang/serial.rst @@ -1,4 +1,4 @@ -.. _arduino-serial: +.. _lang-serial: Serial ====== @@ -44,7 +44,7 @@ Functions - `flush <http://arduino.cc/en/Serial/Flush>`_\ () - `print <http://arduino.cc/en/Serial/Print>`_\ () -.. _arduino-serial-println: +.. _lang-serial-println: - `println <http://arduino.cc/en/Serial/Println>`_\ () - `write <http://arduino.cc/en/Serial/Write>`_\ () @@ -65,4 +65,4 @@ Examples -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/wirish/serialusb.rst b/docs/source/lang/serialusb.rst index d0eac98..730fb07 100644 --- a/docs/source/wirish/serialusb.rst +++ b/docs/source/lang/serialusb.rst @@ -1,6 +1,8 @@ -.. _wirish-serialusb: +.. _lang-serialusb: Serial over USB Communications ============================== +.. _lang-serialusb-println: + Stub. diff --git a/docs/source/arduino/setup.rst b/docs/source/lang/setup.rst index 9cc96d4..6b142d2 100644 --- a/docs/source/arduino/setup.rst +++ b/docs/source/lang/setup.rst @@ -1,4 +1,4 @@ -.. _arduino-setup: +.. _lang-setup: setup() ======= diff --git a/docs/source/arduino/shiftout.rst b/docs/source/lang/shiftout.rst index 3815dc5..e76cc01 100644 --- a/docs/source/arduino/shiftout.rst +++ b/docs/source/lang/shiftout.rst @@ -1,4 +1,4 @@ -.. _arduino-shiftout: +.. _lang-shiftout: shiftOut() ========== @@ -72,16 +72,16 @@ requires a two step operation to output values larger than 255. // Do this for MSBFIRST serial int data = 500; // shift out highbyte - shiftOut(dataPin, clock, MSBFIRST, (data >> 8)); + shiftOut(dataPin, clock, MSBFIRST, (data >> 8)); // shift out lowbyte shiftOut(data, clock, MSBFIRST, data); - + // Or do this for LSBFIRST serial data = 500; // shift out lowbyte - shiftOut(dataPin, clock, LSBFIRST, data); - // shift out highbyte - shiftOut(dataPin, clock, LSBFIRST, (data >> 8)); + shiftOut(dataPin, clock, LSBFIRST, data); + // shift out highbyte + shiftOut(dataPin, clock, LSBFIRST, (data >> 8)); @@ -102,35 +102,35 @@ Example // Notes : Code for using a 74HC595 Shift Register // // : to count from 0 to 255 // //**************************************************************** - + //Pin connected to ST_CP of 74HC595 int latchPin = 8; //Pin connected to SH_CP of 74HC595 int clockPin = 12; ////Pin connected to DS of 74HC595 int dataPin = 11; - + void setup() { //set pins to output because they are addressed in the main loop pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); } - + void loop() { //count up routine for (int j = 0; j < 256; j++) { //ground latchPin and hold low for as long as you are transmitting digitalWrite(latchPin, LOW); - shiftOut(dataPin, clockPin, LSBFIRST, j); - //return the latch pin high to signal chip that it + shiftOut(dataPin, clockPin, LSBFIRST, j); + //return the latch pin high to signal chip that it //no longer needs to listen for information digitalWrite(latchPin, HIGH); delay(1000); } - } + } -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/lang/sin.rst b/docs/source/lang/sin.rst new file mode 100644 index 0000000..398b8f3 --- /dev/null +++ b/docs/source/lang/sin.rst @@ -0,0 +1,32 @@ +.. _lang-sin: + +sin() +===== + +Calculates the `sine <http://en.wikipedia.org/wiki/Sine>`_ of an +angle. + +Library Documentation +--------------------- + +.. doxygenfunction:: sin + +Arduino Compatibility +--------------------- + +The Maple version of ``sin()`` is compatible with Arduino. + +Note that the Maple implementation comes from `newlib +<http://sourceware.org/newlib/>`_\ , while Arduino's is that of +`avr-libc <http://avr-libc.nongnu.org/>`_\ . + +See Also +-------- + +- :ref:`cos <lang-cos>` +- :ref:`tan <lang-tan>` +- :ref:`float <lang-float>` +- :ref:`double <lang-double>` + + +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/sizeof.rst b/docs/source/lang/sizeof.rst index 7c31809..409a6d7 100644 --- a/docs/source/arduino/sizeof.rst +++ b/docs/source/lang/sizeof.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-sizeof: +.. _lang-sizeof: sizeof() ======== @@ -44,7 +44,7 @@ changing the text phrase:: Note that ``sizeof`` returns the total number of bytes. So for larger -variable types such as ``int``, the :ref:`for loop <arduino-for>` +variable types such as ``int``, the :ref:`for loop <lang-for>` would look something like this:: for (i = 0; i < (sizeof(myInts)/sizeof(int)) - 1; i++) { diff --git a/docs/source/arduino/sq.rst b/docs/source/lang/sq.rst index c918d50..a14817f 100644 --- a/docs/source/arduino/sq.rst +++ b/docs/source/lang/sq.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-sq: +.. _lang-sq: sq(a) ===== @@ -39,4 +39,4 @@ Arduino Compatibility Maple's implementation of ``sq()`` is compatible with Arduino. -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/sqrt.rst b/docs/source/lang/sqrt.rst index f93908e..956a754 100644 --- a/docs/source/arduino/sqrt.rst +++ b/docs/source/lang/sqrt.rst @@ -1,4 +1,4 @@ -.. _arduino-sqrt: +.. _lang-sqrt: sqrt() ====== @@ -18,8 +18,8 @@ The Maple versino of ``sqrt()`` is compatible with Arduino. See Also -------- -- :ref:`pow <arduino-pow>` -- :ref:`sq <arduino-sq>` +- :ref:`pow <lang-pow>` +- :ref:`sq <lang-sq>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/static.rst b/docs/source/lang/static.rst index 01f3dbf..4646db1 100644 --- a/docs/source/arduino/static.rst +++ b/docs/source/lang/static.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-static: +.. _lang-static: Static ====== diff --git a/docs/source/arduino/string.rst b/docs/source/lang/string.rst index 528e7de..92c3f69 100644 --- a/docs/source/arduino/string.rst +++ b/docs/source/lang/string.rst @@ -1,6 +1,6 @@ .. highlight:: cpp -.. _arduino-string: +.. _lang-string: Strings ======= @@ -10,11 +10,11 @@ Description Text strings can be represented in two ways. You can -1. Use the :ref:`String <arduino-stringclass>` data type, which is +1. Use the :ref:`String <lang-stringclass>` data type, which is part of the core as of version 0.0.9, or 2. You can make a string out of an array of type :ref:`char -<arduino-char>` and null-terminate it. +<lang-char>` and null-terminate it. This page describes the second method. @@ -123,9 +123,9 @@ use them effectively here:: See Also -------- -- :ref:`array <arduino-array>` +- :ref:`array <lang-array>` - :ref:`__attribute__ <arm-gcc-attribute-flash>` -- :ref:`Variables <arduino-variables>` +- :ref:`Variables <lang-variables>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/lang/stringclass.rst b/docs/source/lang/stringclass.rst new file mode 100644 index 0000000..5e53f08 --- /dev/null +++ b/docs/source/lang/stringclass.rst @@ -0,0 +1,9 @@ +.. _lang-stringclass: + +String Class +============ + +Stub. + + +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/stringobject.rst b/docs/source/lang/stringobject.rst index 1844266..d7f287c 100644 --- a/docs/source/arduino/stringobject.rst +++ b/docs/source/lang/stringobject.rst @@ -1,4 +1,4 @@ -.. _arduino-stringobject: +.. _lang-stringobject: String ====== @@ -88,4 +88,4 @@ See Also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/switchcase.rst b/docs/source/lang/switchcase.rst index 9f66d0a..46c47d8 100644 --- a/docs/source/arduino/switchcase.rst +++ b/docs/source/lang/switchcase.rst @@ -1,11 +1,11 @@ .. highlight:: cpp -.. _arduino-switchcase: +.. _lang-switchcase: switch / case statements ======================== -Like :ref:`if/else <arduino-else>` blocks, A ``switch`` statement +Like :ref:`if/else <lang-else>` blocks, A ``switch`` statement controls program flow by allowing you to specify different code that should be executed under various cases. @@ -49,14 +49,14 @@ Here's a more concrete example:: afterTheSwitch(); In the above example, if ``var == 1``, then the code beginning on the -line after ``case 1:`` gets executed. That is, if ``var`` is one, -``doThing1()`` gets called first, and then the ``break`` statement -gets executed. +line after ``case 1`` gets executed. That is, if ``var`` is one, +``doThing1()`` gets called first, and then the ``break`` statement is +executed. The ``break`` keyword exits the ``switch`` statement, and is typically used at the end of each ``case``. Since there is a ``break`` at the -end of ``case 1:``, the ``switch`` statement gets exited, and the next -line to be run is the one which calls ``afterTheSwitch()``. +end of ``case 1``, the ``switch`` statement exits, and the next line +to be run is the one which calls ``afterTheSwitch()``. Without a ``break``, the ``switch`` statement will continue executing the following ``case`` expressions ("falling-through") until a @@ -102,7 +102,7 @@ If ``var`` is one, then ``doThing1()`` gets called. If ``var`` is two, ``doThing2()`` gets called. If ``var`` is anything else, ``doSomethingElse()`` gets called. As stated above, a ``default`` is optional. If you're missing one and none of the ``case`` statements -match, the ``switch`` does nothing at all, as if it wasn't there. +match, the ``switch`` does nothing at all, as if it weren't there. ``switch`` statements are often used with an ``enum`` value as the variable to compare. In this case, you can write down all of the @@ -112,6 +112,6 @@ covered all the possibilities. See also: --------- -- :ref:`if...else <arduino-else>` +- :ref:`if...else <lang-else>` .. include:: cc-attribution.txt diff --git a/docs/source/lang/tan.rst b/docs/source/lang/tan.rst new file mode 100644 index 0000000..4bbe0db --- /dev/null +++ b/docs/source/lang/tan.rst @@ -0,0 +1,31 @@ +.. _lang-tan: + +tan() +===== + +Calculates the tangent of an angle. + +Library Documentation +--------------------- + +.. doxygenfunction:: tan + +Arduino Compatibility +--------------------- + +The Maple version of ``tan()`` is compatible with Arduino. + +Note that the Maple implementation comes from `newlib +<http://sourceware.org/newlib/>`_\ , while Arduino's is that of +`avr-libc <http://avr-libc.nongnu.org/>`_\ . + +See Also +-------- + + +- :ref:`sin <lang-sin>` +- :ref:`cos <lang-cos>` +- :ref:`float <lang-float>` +- :ref:`double <lang-double>` + +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/tone.rst b/docs/source/lang/tone.rst index 8252804..96f0a7c 100644 --- a/docs/source/arduino/tone.rst +++ b/docs/source/lang/tone.rst @@ -1,4 +1,4 @@ -.. _arduino-tone: +.. _lang-tone: tone() ====== @@ -72,10 +72,10 @@ See also - `Tutorial:Pitch follower <http://arduino.cc/en/Tutorial/Tone2>`_ - `Tutorial:Simple Keyboard <http://arduino.cc/en/Tutorial/Tone3>`_ - `Tutorial: multiple tones <http://arduino.cc/en/Tutorial/Tone4>`_ - + - `Tutorial: PWM <http://arduino.cc/en/Tutorial/PWM>`_ -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/lang/types.rst b/docs/source/lang/types.rst new file mode 100644 index 0000000..d095da1 --- /dev/null +++ b/docs/source/lang/types.rst @@ -0,0 +1,7 @@ +.. _lang-types: + +Built-in types +============== + +Stub. (explain all built-in integral and floating-point types, +including ``uint8`` style ones). diff --git a/docs/source/lang/unsignedchar.rst b/docs/source/lang/unsignedchar.rst new file mode 100644 index 0000000..c49690d --- /dev/null +++ b/docs/source/lang/unsignedchar.rst @@ -0,0 +1,36 @@ +.. highlight:: cpp + +.. _lang-unsignedchar: + +unsigned char +============= + +Description +----------- + +An unsigned version of the :ref:`char <lang-char>` data type. An +``unsigned char`` occupies 1 byte of memory; it stores an integer from +0 to 255. + +Like an :ref:`unsigned int <lang-unsignedint>`, an ``unsigned char`` +won't store negative numbers; it is also subject to the same +:ref:`overflow issues <lang-int-overflow>` as any integral data type. + +Example +------- + +:: + + unsigned char c = 240; + +See Also +-------- + + +- :ref:`byte <lang-byte>` +- :ref:`int <lang-int>` +- :ref:`array <lang-array>` +- :ref:`SerialUSB.println() <lang-serialusb-println>` +- :ref:`Serial.println() <lang-serial-println>` + +.. include:: cc-attribution.txt diff --git a/docs/source/lang/unsignedint.rst b/docs/source/lang/unsignedint.rst new file mode 100644 index 0000000..aa5cc1b --- /dev/null +++ b/docs/source/lang/unsignedint.rst @@ -0,0 +1,58 @@ +.. highlight:: cpp + +.. _lang-unsignedint: + +unsigned int +============ + +Description +----------- + +An ``unsigned int`` (unsigned integer) is the same as an :ref:`int +<lang-int>` in that it stores a 4 byte integer value. However, +Instead of storing both negative and positive numbers, an ``unsigned +int`` can only store nonnegative values, yielding a range of 0 to +4,294,967,295 (the positive value is 2^32 - 1). + +The difference between an ``unsigned int`` and a (signed) ``int`` lies +in the way the highest bit, sometimes referred to as the "sign" bit, +is interpreted. In the case of the Maple ``int`` type (which is +signed), if the high bit is a "1", the number is interpreted as a +negative number, using a technique known as `two's complement math +<http://en.wikipedia.org/wiki/Two%27s_complement#Explanation>`_. The +bits in an an ``unsigned int`` are interpreted according to the usual +rules for converting `binary to decimal +<http://en.wikipedia.org/wiki/Binary_numeral_system#Counting_in_binary>`_. + +An ``unsigned int`` is subject to the same :ref:`overflow issues +<lang-int-overflow>` as a regular ``int``; the only difference is +that an ``unsigned int`` will "underflow" at 0, and "overflow" at +4,294,967,295. Here is some example code which illustrates this:: + + unsigned int x; + x = 0; + x--; // x now contains 4,294,967,295; rolled over "left to right" + x++; // x now contains 0; rolled over "right to left" + +Here is an example of declaring an ``unsigned int`` variable named +``ledPin``, then giving it value 13:: + + unsigned int ledPin = 13; + +The general syntax for declaring an ``unsigned int`` variable named +``var``, then giving it value ``val``, looks like:: + + unsigned int var = val; + +See Also +-------- + +- :ref:`int <lang-int>` +- :ref:`char <lang-char>` +- :ref:`unsigned char <lang-unsignedchar>` +- :ref:`long <lang-long>` +- :ref:`unsigned long <lang-unsignedlong>` +- :ref:`Integer Constants <lang-constants-integers>` +- :ref:`Variables <lang-variables>` + +.. include:: cc-attribution.txt diff --git a/docs/source/lang/unsignedlong.rst b/docs/source/lang/unsignedlong.rst new file mode 100644 index 0000000..2ca49f8 --- /dev/null +++ b/docs/source/lang/unsignedlong.rst @@ -0,0 +1,44 @@ +.. highlight:: cpp + +.. _lang-unsignedlong: + +unsigned long +============= + +Description +----------- + +An unsigned version of the :ref:`long <lang-long>` data type. An +``unsigned long`` occupies 8 bytes of memory; it stores an integer +from 0 to 2^64-1, which is approximately 1.8×10^19 (18 quintillion, or +18 billion billion). + +Like an :ref:`unsigned int <lang-unsignedint>`, an ``unsigned long`` +won't store negative numbers; it is also subject to the same +:ref:`overflow issues <lang-int-overflow>` as any integral data type. + +Here is an example of declaring an ``unsigned long`` variable named +``c``, then giving it value 299,792,458,000,000,000 (see :ref:`integer +constants <lang-constants-u-l>` for an explanation of the "L" at the +end of the number):: + + // Speed of light in nanometers per second (approximate). + unsigned long c = 299792458000000000L; + +The general syntax for declaring an ``unsigned long`` variable named +``var``, then giving it value ``val``, looks like:: + + unsigned long var = val; + +See Also +-------- + +- :ref:`long <lang-long>` +- :ref:`int <lang-int>` +- :ref:`unsigned <lang-unsignedint>` +- :ref:`char <lang-char>` +- :ref:`unsigned char <lang-unsignedchar>` +- :ref:`Integer Constants <lang-constants-integers>` +- :ref:`Variables <lang-variables>` + +.. include:: cc-attribution.txt diff --git a/docs/source/lang/variables.rst b/docs/source/lang/variables.rst new file mode 100644 index 0000000..05a4f96 --- /dev/null +++ b/docs/source/lang/variables.rst @@ -0,0 +1,170 @@ +.. highlight:: cpp + +.. _lang-variables: + +Variables +========= + +A variable is a way of naming and storing a value for later use by +the program, such as data from a sensor or an intermediate value +used in a calculation. + +.. contents:: Contents + :local: + +.. _lang-variables-declaring: + +Declaring Variables +------------------- + +Before they are used, all variables have to be *declared*. Declaring a +variable means defining its type, giving it a name, and (optionally) +giving it an initial value (this is often referred to as +*initializing* the variable). Variables do not have to be initialized +(given a value) when they are declared, but it is good style to give +them an initial value whenever possible. + +Here is an example of declaring a variable named ``inputVariable1`` +with type :ref:`int <lang-int>` (the ``int`` type is used to store +integers, like -2, -1, 0, 1, etc.):: + + int inputVariable1; + +In the above declaration, we did not give the variable an initial +value. Here is another example, where we declare an ``int`` variable +named ``inputVariable2``, with an initial value of ``0``:: + + int inputVariable2 = 0; + +The Maple environment comes ready to use with many useful types of +variables. See the :ref:`built-in types <lang-types>` page for more +information. + +Here are a few examples of declaring variables of different types:: + + int lightSensVal; + char currentLetter; + unsigned long speedOfLight = 186000UL; + char errorMessage = {"choose another option"}; // see string + +Naming Variables +---------------- + +The rules for naming a variable are simple. Names for variables can +contain letters, numbers, and underscores (the underscore is the +:kbd:`_` character), and cannot begin with a number. So +``temperature_reading``, ``tempReading``, ``tempReading1``, and +``tempReading2`` are all valid variable names, but ``4_temp_readings`` +is not, because it begins with a number. + +You cannot choose a name for a variable that is one of the C++ +:ref:`keywords <lang-keywords>`. + +Variable names are case-sensitive, so "tempreading" and "tempReading" +are different variables. However, it is very bad style to write code +that chooses variables which are the same up to case. + +You should give your variables descriptive names, so as to make your +code more readable. Variable names like ``tiltSensor`` or +``pushButton`` help you (and anyone else reading your code) understand +what the variable represents. Variable names like ``var`` or +``value``, on the other hand, do little to make your code readable. + +.. _lang-variables-scope: + +Variable Scope +-------------- + +An important choice that programmers face is where (in the program +text) to declare variables. The specific place that variables are +declared influences how various functions in a program will "see" the +variable. This is called variable *scope*. See the :ref:`scope +reference <lang-scope>` for more information. + +.. _lang-variables-initializing: + +Initializing Variables +---------------------- + +Variables may be *initialized* (assigned a starting value) when they +are declared or not. It is always good programming practice however to +double check that a variable has valid data in it before it is used. +Using a variable before you give it a value is a common source of +bugs. + +.. _lang-variables-rollover: + +Variable Rollover +----------------- + +Every (numeric) type has a valid *range*. The range of a type is the +smallest and largest value that a variable of that type can store. +For example, the :ref:`int <lang-int>` type has a range of +-2,147,483,648 to 2,147,483,647 [#frange]_. + +When variables are made to exceed their range's maximum value, they +"roll over" back to their minimum value. Note that this happens in +both directions. It's like in the game *Pac-Man* -- when Pac-Man goes +past the right edge of the screen, he reappears on the left, and when +he goes past the left side of the screen, he reappears on the right:: + + int x; + x = -2,147,483,648; + x = x - 1; // x now contains -2,147,483,647; rolled over "left to right" + + x = 2,147,483,647; + x = x + 1; // x now contains -2,147,483,648; rolled over "right to left" + +Each numeric type's reference page includes its range. See the +:ref:`built-in types <lang-types>` reference for links to each type's +reference page. + +Using Variables +--------------- + +Once variables have been declared, they are given values using the +:ref:`assignment operator <lang-assignment>`, which is a single equals +sign, ``=``. The assignment operator tells the program to store the +value on the right side of the equals sign into the variable on the +left side:: + + inputVariable1 = 7; // sets variable named inputVariable1 to 7 + inputVariable2 = analogRead(2); // sets variable named inputVariable2 to + // the (digitized) input voltage read from + // analog pin #2 + +Once a variable has been set (assigned a value), you can test its +value to see if it meets certain conditions, or you can use its value +directly. For instance, the following code tests whether the +inputVariable2 is less than 100, then sets a delay based on +inputVariable2 (which, at that point, is at least 100):: + + if (inputVariable2 < 100) { + inputVariable2 = 100; + } + + delay(inputVariable2); + +See Also +-------- + +- :ref:`lang-scope` +- :ref:`lang-types` + +.. rubric:: Footnotes + +.. [#frange] This range might seem a little weird at first. The + reasons for this range of values have to do with the fact that an + ``int`` occupies 32 bits of memory, and the facts :: + + 2^31 = -2,147,483,648 + 2^31 - 1 = 2,147,483,647 + + + Why 2^31 instead of 2^32? Well, that has to do with `how ints are + (usually) stored + <http://en.wikipedia.org/wiki/Two%27s_complement>`_ on computers. + + +.. include:: cc-attribution.txt + diff --git a/docs/source/arduino/void.rst b/docs/source/lang/void.rst index 82f9606..bc7a3dc 100644 --- a/docs/source/arduino/void.rst +++ b/docs/source/lang/void.rst @@ -1,4 +1,4 @@ -.. _arduino-void: +.. _lang-void: void ==== diff --git a/docs/source/arduino/volatile.rst b/docs/source/lang/volatile.rst index fc02081..a0ef671 100644 --- a/docs/source/arduino/volatile.rst +++ b/docs/source/lang/volatile.rst @@ -1,4 +1,4 @@ -.. _arduino-volatile: +.. _lang-volatile: volatile keyword ================ diff --git a/docs/source/arduino/while.rst b/docs/source/lang/while.rst index e8167bd..be1ea14 100644 --- a/docs/source/arduino/while.rst +++ b/docs/source/lang/while.rst @@ -1,4 +1,4 @@ -.. _arduino-while: +.. _lang-while: while Loops =========== @@ -46,4 +46,4 @@ Example -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/language-index.rst b/docs/source/language-index.rst new file mode 100644 index 0000000..90b3d79 --- /dev/null +++ b/docs/source/language-index.rst @@ -0,0 +1,131 @@ +.. _language-index: + +Language Reference Index +======================== + +This is the index of the :ref:`language reference <language>` +documentation. + +Not converted Arduino docs: + +.. toctree:: + :maxdepth: 1 + + lang/pwmwrite + lang/types + lang/serialusb + +Finished: + +.. toctree:: + :maxdepth: 1 + + lang/abs + lang/analogread + lang/pinmode + lang/arithmetic + lang/array + lang/assignment + lang/attachinterrupt + lang/bit + lang/bitclear + lang/bitread + lang/bitset + lang/bitshift + lang/analogwrite + lang/bitwisemath + lang/bitwisecompound + lang/bitwrite + lang/boolean + lang/booleanvariables + lang/braces + lang/break + lang/byte + lang/bytecast + lang/char + lang/charcast + lang/comments + lang/const + lang/constrain + lang/continue + lang/cos + lang/define + lang/delay + lang/delaymicroseconds + lang/detachinterrupt + lang/digitalread + lang/double + lang/doublecast + lang/dowhile + lang/else + lang/float + lang/floatcast + lang/for + lang/goto + lang/highbyte + lang/if + lang/comparison + lang/include + lang/increment + lang/arithmeticcompound + lang/int + lang/intcast + lang/long + lang/longcast + lang/loop + lang/max + lang/min + lang/modulo + lang/pointer + lang/pow + lang/return + lang/scope + lang/semicolon + lang/sin + lang/sizeof + lang/sqrt + lang/sq + lang/static + lang/string + lang/switchcase + lang/tan + lang/unsignedchar + lang/unsignedint + lang/unsignedlong + lang/variables + +Unfinished; straightforward to convert: + +.. toctree:: + :maxdepth: 1 + + lang/void + lang/volatile + lang/while + lang/keywords + lang/enum + +Unfinished, requires libmaple/Arduino knowledge: + +.. toctree:: + :maxdepth: 1 + + lang/constants + lang/digitalwrite + lang/notone + lang/serial + lang/interrupts + lang/analogwrite + lang/nointerrupts + lang/pulsein + lang/stringobject + lang/tone + lang/random + lang/randomseed + lang/setup + lang/map + lang/shiftout + lang/micros + lang/millis + lang/lowbyte + lang/stringclass diff --git a/docs/source/language.rst b/docs/source/language.rst index bbdbf90..0a79fb0 100644 --- a/docs/source/language.rst +++ b/docs/source/language.rst @@ -42,174 +42,174 @@ Unique Maple Additions #define DEBUG_LEVEL DEBUG_NONE - before including either wirish or libmaple. In this case, all + before including either wirish.h or libmaple.h. In this case, all assertions will pass without any lost clock cycles. Note that this will **not work in the IDE**; even with this definition, assertions will still be enabled. -.. _language-arduino-docs: +.. _language-lang-docs: Maple Language Reference ------------------------ -+-------------------------------------------------+----------------------------------------------+---------------------------------------------------+ -| Structure | Variables | Functions | -| | | | -+=================================================+==============================================+===================================================+ -|* :ref:`setup() <arduino-setup>` |**Constants** |**Digital I/O** | -| | | | -|* :ref:`loop() <arduino-loop>` |* :ref:`HIGH <arduino-constants-high>` | |* :ref:`pinMode() <arduino-pinmode>` | -| | :ref:`LOW <arduino-constants-low>` | | -| | |* :ref:`digitalWrite() <arduino-digitalwrite>` | -|**Control Structures** |* :ref:`INPUT <arduino-constants-input>` | | | -| | :ref:`OUTPUT <arduino-constants-output>` |* :ref:`digitalRead() <arduino-digitalread>` | -|* :ref:`if <arduino-if>` | | | -| |* :ref:`true <arduino-constants-true>` | | | -|* :ref:`if...else <arduino-else>` | :ref:`false <arduino-constants-false>` |**Analog I/O** | -| | | | -|* :ref:`for <arduino-for>` |* :ref:`integer constants |* :ref:`analogRead() <arduino-analogread>` | -| | <arduino-constants-integers>` | | -|* :ref:`switch/case <arduino-switchcase>` | |* :ref:`pwmWrite() <wirish-pwmwrite>` | -| |* :ref:`floating point constants | (:ref:`analogWrite() <arduino-analogwrite>` is | -|* :ref:`while <arduino-while>` | <arduino-constants-fp>` | also available, though its use is discouraged) | -| | | | -|* :ref:`do...while <arduino-dowhile>` | | | -| |**Data Types** |**Advanced I/O** | -|* :ref:`break <arduino-break>` | | | -| | The size of each datatype, in bytes, is |* tone(): TODO | -|* :ref:`continue <arduino-continue>` | given in parentheses where appropriate. | | -| | |* noTone(): TODO | -|* :ref:`return <arduino-return>` | *Note*: The ``word`` type is (deliberately) | | -| | :ref:`not supported <language-no-word>`. |* shiftOut(): TODO | -|* :ref:`goto <arduino-goto>` | | | -| |* :ref:`void <arduino-void>` |* pulseIn(): TODO | -| | | | -|**Further syntax** |* :ref:`boolean <arduino-boolean>` (1 byte) | | -| | |**Time** | -|* :ref:`; <arduino-semicolon>` (semicolon) |* :ref:`char <arduino-char>` (1 byte) | | -| | |* :ref:`millis() <arduino-millis>` | -|* :ref:`{} <arduino-braces>` (curly braces) |* :ref:`unsigned char | | -| | <arduino-unsignedchar>` (1 byte) |* :ref:`micros() <arduino-micros>` | -|* :ref:`// <arduino-comments-singleline>` | | | -| (single line comment) |* :ref:`byte <arduino-byte>` (1 byte) |* :ref:`delay() <arduino-delay>` | -| | | | -|* :ref:`/\* \*/ |* :ref:`int <arduino-int>` (4 bytes) |* :ref:`delayMicroseconds() | -| <arduino-comments-multiline>` | | <arduino-delaymicroseconds>` | -| (multi-line comment) |* :ref:`unsigned int <arduino-unsignedint>` | | -| | (4 bytes) | | -|* :ref:`#define <arduino-define>` | |**Math** | -| |* :ref:`long <arduino-long>` (8 bytes) | | -|* :ref:`#include <arduino-include>` | |* :ref:`min() <arduino-min>` | -| |* :ref:`unsigned long <arduino-unsignedlong>` | | -| | (8 bytes) |* :ref:`max() <arduino-max>` | -|**Arithmetic Operators** | | | -| |* :ref:`float <arduino-float>` (4 bytes) |* :ref:`abs() <arduino-abs>` | -|* :ref:`= <arduino-assignment>` | | | -| (assignment operator) |* :ref:`double <arduino-double>` (8 bytes) |* :ref:`constrain() <arduino-constrain>` | -| | | | -|* :ref:`+ <arduino-arithmetic>` (addition) |* :ref:`string <arduino-string>` |* :ref:`map() <arduino-constrain>` | -| | | | -|* :ref:`- <arduino-arithmetic>` |* :ref:`array <arduino-array>` |* :ref:`pow() <arduino-pow>` | -| (subtraction) | | | -| |* Also provided: ``int8``, ``int16``, |* :ref:`sqrt() <arduino-sqrt>` | -|* :ref:`* <arduino-arithmetic>` | ``int32``, ``int64``, and their unsigned | | -| (multiplication) | counterparts ``uint8``, ``uint16``, | | -| | ``uint32``, ``uint64``. |**Trigonometry** | -|* :ref:`/ <arduino-arithmetic>` (division) | | | -| | |* :ref:`sin() <arduino-sin>` | -|* :ref:`% <arduino-modulo>` (modulo) |**Conversion** | | -| | |* :ref:`cos() <arduino-cos>` | -| |* :ref:`char() <arduino-charcast>` | | -|**Comparison Operators** | |* :ref:`tan() <arduino-tan>` | -| |* :ref:`byte() <arduino-bytecast>` | | -|* :ref:`== <arduino-comparison>` (equal to) | | | -| |* :ref:`int() <arduino-intcast>` |**Random Numbers** | -|* :ref:`\!= <arduino-comparison>` | | | -| (not equal to) |* :ref:`long() <arduino-longcast>` |* :ref:`randomSeed() <arduino-randomseed>` | -| | | | -|* :ref:`< <arduino-comparison>` (less than) |* :ref:`float() <arduino-floatcast>` |* :ref:`random() <arduino-random>` | -| | | | -|* :ref:`> <arduino-comparison>` |* :ref:`double() <arduino-doublecast>` | | -| (greater than) | |**Bits and Bytes** | -| | | | -|* :ref:`<= <arduino-comparison>` |**Variable Scope & Qualifiers** |* :ref:`lowByte() <arduino-lowbyte>` | -| (less than or equal to) | | | -| |* :ref:`variables <arduino-variables>`, |* :ref:`highByte() <arduino-highbyte>` is | -|* :ref:`>= <arduino-comparison>` | :ref:`scope <arduino-variables-scope>` | provided, though its use is discouraged. | -| (greater than or equal to) | | | -| |* :ref:`static <arduino-static>` |* :ref:`bitRead() <arduino-bitread>` | -| | | | -|**Boolean Operators** |* :ref:`volatile <arduino-volatile>` |* :ref:`bitWrite() <arduino-bitwrite>` | -| | | | -|* :ref:`&& <arduino-boolean-and>` (and) |* :ref:`const <arduino-const>` |* :ref:`bitSet() <arduino-bitset>` | -| | | | -|* :ref:`|| <arduino-boolean-or>` (or) | |* :ref:`bitClear() <arduino-bitclear>` | -| |**Utilities** | | -|* :ref:`\! <arduino-boolean-not>` (not) | |* :ref:`bit() <arduino-bit>` | -| |* :ref:`sizeof() <arduino-sizeof>` | | -| | (``sizeof`` operator) | | -|**Pointer Access Operators** | |**External Interrupts** | -| | | | -|* :ref:`* dereference operator | |* :ref:`Reference Page <external-interrupts>` | -| <arduino-pointer>` | | | -| | |* :ref:`attachInterrupt() | -|* :ref:`& reference operator | | <arduino-attachinterrupt>` | -| <arduino-pointer>` | | | -| | |* :ref:`detachInterrupt() | -| | | <arduino-detachinterrupt>` | -|**Bitwise Operators** | | | -| | | | -|* :ref:`& <arduino-bitwisemath-and>` | |**Interrupts** | -| (bitwise and) | | | -| | |* interrupts(): TODO | -|* :ref:`| <arduino-bitwisemath-or>` | | | -| (bitwise or) | |* noInterrupts(): TODO | -| | | | -|* :ref:`^ <arduino-bitwisemath-xor>` | | | -| (bitwise xor) | |**Communication** | -| | | | -|* :ref:`~ <arduino-bitwisemath-not>` | |* :ref:`SerialUSB <wirish-serialusb>` | -| (bitwise not) | | | -| | |* :ref:`Serial <arduino-serial>` | -|* :ref:`\<\< <arduino-bitshift>` | | | -| (shift left) | |**Looking for something else?** | -| | | | -|* :ref:`>> <arduino-bitshift>` | | See the :ref:`libraries` page for interfacing with| -| (shift right) | | particular types of hardware. Try the list of | -| | | `community-contributed code` . Maple links | -| | | against `newlib` and allows the use of any of its | -|**Compound Operators** | | functions; see its documentation for more details.| -| | | | -|* :ref:`++ <arduino-increment>` | | | -| (increment) | | | -| | | | -|* :ref:`- - <arduino-increment>` | | | -| (decrement) | | | -| | | | -|* :ref:`+= <arduino-arithmeticcompound>` | | | -| (compound add) | | | -| | | | -|* :ref:`-= | | | -| <arduino-arithmeticcompound>` (compound | | | -| subtract) | | | -| | | | -|* :ref:`*= | | | -| <arduino-arithmeticcompound>` (compound | | | -| multiply) | | | -| | | | -|* :ref:`/= | | | -| <arduino-arithmeticcompound>` (compound | | | -| divide) | | | -| | | | -|* :ref:`&= | | | -| <arduino-arithmeticcompound>` (compound | | | -| bitwise and) | | | -| | | | -|* :ref:`|= | | | -| <arduino-arithmeticcompound>` (compound | | | -| bitwise or) | | | -| | | | -+-------------------------------------------------+----------------------------------------------+---------------------------------------------------+ ++--------------------------------------------+----------------------------------------------+---------------------------------------------------+ +| Structure | Variables | Functions | +| | | | ++============================================+==============================================+===================================================+ +|* :ref:`setup() <lang-setup>` |**Constants** |**Digital I/O** | +| | | | +|* :ref:`loop() <lang-loop>` |* :ref:`HIGH <lang-constants-high>` | |* :ref:`pinMode() <lang-pinmode>` | +| | :ref:`LOW <lang-constants-low>` | | +| | |* :ref:`digitalWrite() <lang-digitalwrite>` | +|**Control Structures** |* :ref:`INPUT <lang-constants-input>` | | | +| | :ref:`OUTPUT <lang-constants-output>` |* :ref:`digitalRead() <lang-digitalread>` | +|* :ref:`if <lang-if>` | | | +| |* :ref:`true <lang-constants-true>` | | | +|* :ref:`if...else <lang-else>` | :ref:`false <lang-constants-false>` |**Analog I/O** | +| | | | +|* :ref:`for <lang-for>` |* :ref:`integer constants |* :ref:`analogRead() <lang-analogread>` | +| | <lang-constants-integers>` | | +|* :ref:`switch/case <lang-switchcase>` | |* :ref:`pwmWrite() <lang-pwmwrite>` | +| |* :ref:`floating point constants | (:ref:`analogWrite() <lang-analogwrite>` is | +|* :ref:`while <lang-while>` | <lang-constants-fp>` | also available, though its use is discouraged) | +| | | | +|* :ref:`do...while <lang-dowhile>` | | | +| |**Data Types** |**Advanced I/O** | +|* :ref:`break <lang-break>` | | | +| | The size of each datatype, in bytes, is |* tone(): TODO | +|* :ref:`continue <lang-continue>` | given in parentheses where appropriate. | | +| | |* noTone(): TODO | +|* :ref:`return <lang-return>` | *Note*: The ``word`` type is (deliberately) | | +| | :ref:`not supported <language-no-word>`. |* shiftOut(): TODO | +|* :ref:`goto <lang-goto>` | | | +| |* :ref:`void <lang-void>` |* pulseIn(): TODO | +| | | | +|**Further syntax** |* :ref:`boolean <lang-boolean>` (1 byte) | | +| | |**Time** | +|* :ref:`; (semicolon) <lang-semicolon>` |* :ref:`char <lang-char>` (1 byte) | | +| | |* :ref:`millis() <lang-millis>` | +|* :ref:`{} (curly braces) <lang-braces>` |* :ref:`unsigned char | | +| | <lang-unsignedchar>` (1 byte) |* :ref:`micros() <lang-micros>` | +|* :ref:`// (single-line comment) | | | +| <lang-comments-singleline>` |* :ref:`byte <lang-byte>` (1 byte) |* :ref:`delay() <lang-delay>` | +| | | | +|* :ref:`/\* \*/ (multi-line comment) |* :ref:`int <lang-int>` (4 bytes) |* :ref:`delayMicroseconds() | +| <lang-comments-multiline>` | | <lang-delaymicroseconds>` | +| |* :ref:`unsigned int <lang-unsignedint>` | | +|* :ref:`#define <lang-define>` | (4 bytes) | | +| | |**Math** | +|* :ref:`#include <lang-include>` |* :ref:`long <lang-long>` (8 bytes) | | +| | |* :ref:`min() <lang-min>` | +| |* :ref:`unsigned long <lang-unsignedlong>` | | +|**Arithmetic Operators** | (8 bytes) |* :ref:`max() <lang-max>` | +| | | | +|* :ref:`= <lang-assignment>` |* :ref:`float <lang-float>` (4 bytes) |* :ref:`abs() <lang-abs>` | +| (assignment operator) | | | +| |* :ref:`double <lang-double>` (8 bytes) |* :ref:`constrain() <lang-constrain>` | +|* :ref:`+ <lang-arithmetic>` (addition) | | | +| |* :ref:`string <lang-string>` |* :ref:`map() <lang-constrain>` | +|* :ref:`- <lang-arithmetic>` | | | +| (subtraction) |* :ref:`array <lang-array>` |* :ref:`pow() <lang-pow>` | +| | | | +|* :ref:`* <lang-arithmetic>` |* See also: :ref:`built-in types reference |* :ref:`sqrt() <lang-sqrt>` | +| (multiplication) | <lang-types>`. | | +| | | | +|* :ref:`/ <lang-arithmetic>` (division) | |**Trigonometry** | +| |**Conversion** | | +|* :ref:`% <lang-modulo>` (modulo) | |* :ref:`sin() <lang-sin>` | +| |* :ref:`char() <lang-charcast>` | | +| | |* :ref:`cos() <lang-cos>` | +|**Comparison Operators** |* :ref:`byte() <lang-bytecast>` | | +| | |* :ref:`tan() <lang-tan>` | +|* :ref:`== <lang-comparison>` (equal to) |* :ref:`int() <lang-intcast>` | | +| | | | +|* :ref:`\!= <lang-comparison>` |* :ref:`long() <lang-longcast>` |**Random Numbers** | +| (not equal to) | | | +| |* :ref:`float() <lang-floatcast>` |* :ref:`randomSeed() <lang-randomseed>` | +|* :ref:`< <lang-comparison>` (less than) | | | +| |* :ref:`double() <lang-doublecast>` |* :ref:`random() <lang-random>` | +|* :ref:`> <lang-comparison>` | | | +| (greater than) | | | +| |**Variable Scope & Qualifiers** |**Bits and Bytes** | +|* :ref:`<= <lang-comparison>` | | | +| (less than or equal to) |* :ref:`variables <lang-variables>`, |* :ref:`lowByte() <lang-lowbyte>` | +| | :ref:`scope <lang-variables-scope>` | | +|* :ref:`>= <lang-comparison>` | |* :ref:`highByte() <lang-highbyte>` is | +| (greater than or equal to) |* :ref:`static <lang-static>` | provided, though its use is discouraged. | +| | | | +| |* :ref:`volatile <lang-volatile>` |* :ref:`bitRead() <lang-bitread>` | +|**Boolean Operators** | | | +| |* :ref:`const <lang-const>` |* :ref:`bitWrite() <lang-bitwrite>` | +|* :ref:`&& <lang-boolean-and>` (and) | | | +| | |* :ref:`bitSet() <lang-bitset>` | +|* :ref:`|| <lang-boolean-or>` (or) |**Utilities** | | +| | |* :ref:`bitClear() <lang-bitclear>` | +|* :ref:`\! <lang-boolean-not>` (not) |* :ref:`sizeof() <lang-sizeof>` | | +| | (``sizeof`` operator) |* :ref:`bit() <lang-bit>` | +| | | | +|**Pointer Operators** | | | +| | |**External Interrupts** | +|* :ref:`* dereference operator | | | +| <lang-pointer>` | |* :ref:`Reference Page <external-interrupts>` | +| | | | +|* :ref:`& reference operator | |* :ref:`attachInterrupt() | +| <lang-pointer>` | | <lang-attachinterrupt>` | +| | | | +| | |* :ref:`detachInterrupt() | +|**Bitwise Operators** | | <lang-detachinterrupt>` | +| | | | +|* :ref:`& <lang-bitwisemath-and>` | | | +| (bitwise and) | |**Interrupts** | +| | | | +|* :ref:`| <lang-bitwisemath-or>` | |* interrupts(): TODO | +| (bitwise or) | | | +| | |* noInterrupts(): TODO | +|* :ref:`^ <lang-bitwisemath-xor>` | | | +| (bitwise xor) | | | +| | |**Communication** | +|* :ref:`~ <lang-bitwisemath-not>` | | | +| (bitwise not) | |* :ref:`SerialUSB <lang-serialusb>` | +| | | | +|* :ref:`\<\< <lang-bitshift>` | |* :ref:`Serial <lang-serial>` | +| (shift left) | | | +| | |**Looking for something else?** | +|* :ref:`>> <lang-bitshift>` | | | +| (shift right) | | See the :ref:`libraries` page for interfacing with| +| | | particular types of hardware. Maple links | +| | | against `newlib <http://sourceware.org/newlib/>`_ | +|**Compound Operators** | | and allows the use of any of its functions; see | +| | | its documentation for more details. | +|* :ref:`++ <lang-increment>` | | | +| (increment) | | | +| | | | +|* :ref:`- - <lang-increment>` | | | +| (decrement) | | | +| | | | +|* :ref:`+= <lang-arithmeticcompound>` | | | +| (compound add) | | | +| | | | +|* :ref:`-= | | | +| <lang-arithmeticcompound>` (compound | | | +| subtract) | | | +| | | | +|* :ref:`*= | | | +| <lang-arithmeticcompound>` (compound | | | +| multiply) | | | +| | | | +|* :ref:`/= | | | +| <lang-arithmeticcompound>` (compound | | | +| divide) | | | +| | | | +|* :ref:`&= | | | +| <lang-arithmeticcompound>` (compound | | | +| bitwise and) | | | +| | | | +|* :ref:`|= | | | +| <lang-arithmeticcompound>` (compound | | | +| bitwise or) | | | +| | | | +| | | | ++--------------------------------------------+----------------------------------------------+---------------------------------------------------+ .. _language-missing-features: diff --git a/docs/source/wirish.rst b/docs/source/wirish.rst deleted file mode 100644 index e8e608e..0000000 --- a/docs/source/wirish.rst +++ /dev/null @@ -1,10 +0,0 @@ - -[temporary] Wirish Functions -============================ - -.. toctree:: - :maxdepth: 2 - - wirish/pwmwrite - wirish/types - wirish/serialusb diff --git a/docs/source/wirish/types.rst b/docs/source/wirish/types.rst deleted file mode 100644 index 0b78d01..0000000 --- a/docs/source/wirish/types.rst +++ /dev/null @@ -1,6 +0,0 @@ -.. _wirish-types: - -Standard types -============== - -Stub. (uint8, uint64, etc.) |