taweili / ardublock

ArduBlock is a Block Programming Language for Arduino.
GNU General Public License v3.0
414 stars 292 forks source link

missing float variable type #78

Closed bri-huang closed 10 years ago

bri-huang commented 10 years ago

Under the math functions, there are sin(), cos(), and tan() functions. However - these return a float. Is there a way to create a floating type variable? We'd also need a way to glue a float onto a string to print this to the Serial Monitor -- for showing and calibrating sensors.

TonyCallear commented 10 years ago

Adding a 'float' is easy but (for myself) I’d be much more tempted to remove the sin(), cos(), and tan() functions. How are you using these, sounds interesting?

I use Ardublock with students who are just starting to program - explaining different variable sizes is a problem. I'd much rather stick to integers but timing things came up so often I had to add a 'long variable'. Perhaps there's a way to make selecting to the correct variable type transparent to the user?

As I type I’m thinking it might be better to put the different variable types into the menu system where they are needed and not all in the same “variables/constants” box.

I think what you’re suggesting is easy to program but more of a problem to arrange things in a clear and consistent way for the user. Any ideas?

taweili commented 10 years ago

Tony has put in an implementation of double variable! That's awesome!

untitled

double _ABVAR_1_foo = 0.0 ;

void setup()
{
}

void loop()
{
  _ABVAR_1_foo = sin( 3.1415927 ) ;
}