Why won’t this work:
sparki.moveRight(-45.0);
Should be equivalent to moveLeft(45.0), right?
Why won’t this work:
sparki.moveRight(-45.0);
Should be equivalent to moveLeft(45.0), right?
What actually happens with moveRight and MoveLeft is that the amount of time necessary to turn the requested degrees is calculated and Sparki is rotated for that amount of time. There is no check for negative degrees so the requested delay() is negative or effectively zero and Sparki does not turn.
From sparki.cpp:
[code]void SparkiClass::moveRight(float deg)
{
float turn = 21.388888*deg;
if( (deg == -1) || (deg == 0) ){
moveRight();
}
else{
moveRight();
delay(long(turn));
moveStop();
}
}
void SparkiClass::moveRight()
{
motorRotate(MOTOR_LEFT, DIR_CCW, 100);
motorRotate(MOTOR_RIGHT, DIR_CCW, 100);
}[/code]
Something like this works well enough and you could write it into your own turn function.
if (angle < 0)
{
sparki.moveLeft(angle * -1);
}
else
{
spark.moveRight(angle);
}
I also realized from the code that telling Sparki to moveLeft() or moveRight() either 0 or -1 degrees starts rotating and doesn’t stop until another move command overrides it. It rarely comes up but it really should be checked for to prevent unwanted rotation.
That negative number in the delay function just makes it go into an infinite turn as far as I can tell.
Why would anyone want turn 0 to run until stopped though?
Seems like it would be better to modify the move routines to take any number including 0. If you want it to run until stopped, you’d be using the function without arguments anyway.
[quote=“jle”]That negative number in the delay function just makes it go into an infinite turn as far as I can tell.
[/quote]
You are mostly correct. It seems that delay() takes an unsigned long so passing it a negative number is actually a very large positive number. Not infinite but long enough.
Why not just use left for left & right for right 
Point taken, but I was doing something that was calculating an angle needed. It makes it more complex to have to split it into right/left.
For instance, if you wanted to draw a sine wave:
sparki.moveRight(10.0*sin(i*0.1));
sparki.moveForward(1);
i++;
The other reason is that anyone that’s familiar with logo/turtle graphics expects to be able to either go backwards by a positive number OR go forward by a negative number to get the same result.
Not saying it has to be fixed, but I don’t think I’m the only one that’s going to expect to be able to use negative distances and turn angles…
Fair enough. That makes sense. With my limited knowledge I didn’t see a need for negatives. Thanks for explaining.
I think changing it so that negative moves in the other direction is a fine addition, I’ll make the change! 
0 is meant to go infinitely, as that’s the default value in miniBloq (and why would someone use turn 0 otherwise?).