Author Topic: Error on using existing Encoder code  (Read 1307 times)

reinier

  • Newbie
  • *
  • Posts: 10
    • View Profile
Error on using existing Encoder code
« on: November 17, 2014, 03:13:36 PM »
Hi,

I would like to use this peace of code.
I get this error message in my program Mega_prototype

Mega_prototype.ino: In function 'void leftEncoder()':
Mega_prototype.ino:82:27: error: expected ')' before '::' token

The program don't like leftEncoder1::IsSet() and leftEncoder1::Number - 1

What have I forgot to include?


void leftEncoder() {
  static uint8_t old_AB = 0;
  old_AB <<= 2; // Remember previous state
  old_AB |= (leftEncoder1::IsSet() >> (leftEncoder1::Number - 1)) | (leftEncoder2::IsSet() >> leftEncoder2::Number);
  leftCounter += enc_states[ old_AB & 0x0F ];
}

Regards, Reinier

Lauszus

  • Administrator
  • Full Member
  • *****
  • Posts: 132
    • View Profile
Re: Error on using existing Encoder code
« Reply #1 on: November 18, 2014, 03:13:58 AM »
Hi Reinier,

You will have to include the following file from the USB Host library: https://github.com/felis/USB_Host_Shield_2.0/blob/master/avrpins.h.

You can read more about why here: https://github.com/TKJElectronics/Balanduino/blob/master/Firmware/Balanduino/Balanduino.h#L53-L56.

Regards
Lauszus

reinier

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Error on using existing Encoder code
« Reply #2 on: November 22, 2014, 12:25:24 PM »
Hi Lauszus,

Thank you for your help.

Regards, Reinier