Hi jgu1,
( ) - Parentheses.
Parentheses are used the same way as when doing basic calculation in math.
2 * ( 3 + 1 ) = 2 * 4 = 8
= <> -Equal to, Not equal to
Note1: I know Flowcode allows you to use '=' but it's actually '==' in C
Note2: I never tried '<>' in C, I always use '!='
These operation will return a boolean. If used in an if-statement:
if ( 1 == 0 ) -> This will give a value of 0 or false. The if value will not be executed.
if ( 1 != 0 ) -> This will give you a value of 1 or true. This if statement will be executed.
It should be the same if used in a calculation box.
+ - * / MOD - Addition, Subtraction, Multiplication, Division & Modulus.
+, -, * and / are pretty straight forward I think.
MOD (or '%') on the other hand is something not everyone knows how to use.
MOD returns the rest of a division.
Here's an example with
integers :
2 / 2 = 1
2 MOD 2 = 0, because 2 - 2 * 1 = 0
3 / 2 = 1
3 MOD 2 = 1, because 3 - 2 * 1 = 1
10 / 3 = 3
10 MOD 3 = 1, because 10 - 3 * 3 = 1
< <= > >= - Less than, Less than or equal to, Greater than, Greater than or equal to.
This can be put together with the 'equal' or 'not equal' operations.
Some examples:
if (A > 10) -> This means that if A is ranged between ]-infinite; 10], this if statement will not be executed
On the other hand, if A is ranged between ]10; +infinite[, it will be executed.
]10; +infinite[ or [11; +infinite[ is the same if talking about integers.
Same thing applies to the other operations.
Also, these operations returns a boolean.
>> << - Shift right, Shift left.
This one is really useful when programming microcontrollers.
If you want to set or clear a bit on PORTX, you'll could use this operator to select which bit you want to set/clear.
Anyways, these shift registers are easy to use.
The easiest way to explain this would be a step by step on what happens when you use the shift operators.
A = 1 << 4 = 16
1 or 0000 0001 -> shift one time to the left -> 2 or 0000 0010 -> again -> 0000 0100 -> again -> 0000 1000 -> shift 4th time to the left -> 0001 000 or 16
Of course you can do this with other values than 1, but this is just an example.
NOT AND OR XOR - NOT(inversion), AND, OR, Exclusive OR
These are bitwise operators. They work just like when applying the same gates to a 1 or 2 bit input, but on a larger scale (8 / 16 bits).
NOT(1) = 254
0x0F AND 0xF0 = 0x00
0x0F OR 0xF0 = 0xFF
0x0F XOR 0x1F = 0x10
NEXTBIT = LASTBIT >> 2 & MASK
This is a combination of above operations, if you know how they work you can mask out some bits from a PORT or something like that.
Basic stuff when programming microcontrollers in C.
When reading an input or setting an output, Flowcode will do something like that. Check the C code if you're curious on how it's done.
Floating point functions
I'm not going to write an example for each one of them. You'll know what they do by reading the comment/text next to the function.
Just replace each float by a floating point variable and that's pretty much it.
Just to demonstrate :
float sub, value1 = 1.3, value2 = 3.5
sub = fsub(value2, value1) -> 3.5 - 1.3 = 2.2
Note: For the random function to work, you'll need to include the math header.
Hope this helps,
Nicolas