NicoHood/HID

Psudeo bricking - ATmega32U4 (Rotary encoder volume control)

Closed this issue · 1 comments

https://github.com/alxsch/mymacrokeyboard/blob/main/src/main.cpp

I'm using the platformio extension in vscode.

There are no fatal compile errors but the board's bootloader needs to be reflashed when the code is uploaded to the board.

Here is a snippet where I try to add volume control to a rotary encoder:

...
void encoderA(){
  long newPos = RotaryEncoderA.read()/4; //When the encoder lands on a valley, this is an increment of 4.
  
  if (newPos != positionEncoderA && newPos > positionEncoderA) {
    positionEncoderA = newPos;
    // Serial.write(positionEncoderA);
    Keyboard.press(KEY_VOLUME_DOWN);
    Keyboard.release(KEY_VOLUME_DOWN);
    ;  }

  if (newPos != positionEncoderA && newPos < positionEncoderA) {
    positionEncoderA = newPos;
    // Serial.write(positionEncoderA);
    Keyboard.press(KEY_VOLUME_UP);
    Keyboard.release(KEY_VOLUME_UP);
    ;  }
}
...

Why reflashed? I guess the MCU hangs because of a problem with the PC. You need to enter bootloader mode, to reflash the mcu, but no need to reflash the whole bootloader.

Try the consumer device, not the keyboard.