Invalid operands of types...

RadioReceiverPCB_with_MPU_6050.ino: In function 'void ComplementaryFilter(float*, uint16_t, float, long unsigned int)': RadioReceiverPCB_with_MPU_6050:378: error: invalid operands of types 'double' and 'float*' to binary 'operator*'

void ComplementaryFilter(float *newAngle, uint16_t newRate, float accAngle, unsigned long looptime){
  float dt = looptime / 1000.0;
  
  *newAngle += (float)(newRate / 131) * dt; 
  *newAngle = (float)(0.95 * newAngle) + (0.05 * accAngle);
}

I don't see why?

(0.95 * newAngle)

Just there.

newAngle is a pointer. A pointer multiplied by 0.95 is an interesting concept but but not very useful :)


Rob

Ohh... Missed that :p

Thanks for the help :)

This is an interesting case of parsing. since the *newAngle would make sense, it could also have complained about a missing operator.

Graynomad: A pointer multiplied by 0.95 is an interesting concept but but not very useful :)

Might come in handy if you wanted a rounded-off pointer. Less pointy and more blunty.

KeithRB: This is an interesting case of parsing. since the *newAngle would make sense, it could also have complained about a missing operator.

Nothing special with parsing a * *b, just like a - -b

Perhaps the routine meant to take a float reference rather than a pointer:

void ComplementaryFilter(float &newAngle, uint16_t newRate, float accAngle, unsigned long looptime){

You only need the generality of pointers when its an array or buffer that you are going to index, reference types are cleaner for pass-by-reference use-cases (unsurprisingly)

No but if you have a*b where b is a pointer, you can choose between two errors. Either an invalid type for multiplication, or a missing operator between two compatible types.

Less pointy and more blunty.

Good for fuzzy-logic algorithms as well, to get a value that roughly correct from an array.


Rob