Go Down

Topic: I create an int called "speed" and it turns orange like a command (Read 343 times) previous topic - next topic

Glennphillips

I create an integer called "speed" and it turns orange like a command.  I have looked all over, but cannot find such a command.

Code: [Select]
void MoveWheels(WheelDirection (dir), int speed) {

    if (MotorOff) return;

    if (speed > 255) speed = 255;

    else if (speed < 0) speed = 0;

    if (dir == DIR_STOP) {

        digitalWrite(ahi, HIGH);      //set ahi and bhi osmc
        digitalWrite(bhi, HIGH);
        digitalWrite(dis, LOW);
        digitalWrite(ali, LOW);
        digitalWrite(bli, LOW);

    } else if (dir == DIR_FORWARD) {

        digitalWrite(ahi, HIGH);      //set ahi and bhi osmc
        digitalWrite(bhi, HIGH);
        digitalWrite(dis, LOW);
        digitalWrite(ali, LOW);
        analogWrite(bli, speed);

Arrch

It's probably defined in a keywords.txt for one of your libraries.

majenko

It's in the Stepper library:

Code: [Select]

$ grep -r speed * | grep keywords.txt
libraries/Stepper/keywords.txt:speed KEYWORD2


Yet one more failing of the IDE - it should only take note of keywords for libraries you actually have included.

PaulS

Quote
Yet one more failing of the IDE - it should only take note of keywords for libraries you actually have included.

I think that it is more a failing of the Stepper library author. Keywords are supposed to be just that. Key words that mean something to the class, like method names. The words direction and speed are not methods of the Stepper library, while setSpeed and step are. It is reasonable that setSpeed and step are in the keywords file. It is not reasonable that speed and direction are.

The whole color-coding stuff is silly, though. The word step should only be colored if it is a method(). It is not rocket science to recognize .step( and ->step( as distinct from // We need to step until...

Glennphillips

Ah, got it.  It worked so i left it alone.  I don't mind these little anomalies when we have a help resource so smart, so fast and so free.

thanks a lot!!

glenn

Go Up