// FreeCAD
void keyboard_Mode2() {
  if (key) {
    switch (key) {
      case KEYBOARD_KEY1:                                            // mute
        Consumer.write(MEDIA_VOLUME_MUTE);
        break;
      case KEYBOARD_KEY2:                                            // line
        Keyboard.print('l');
        pixels.setPixelColor(KEYBOARD_KEY2, pixels.Color(0,150,0)); 
        break;
      case KEYBOARD_KEY3:                                            // escape
        Keyboard.press(KEY_ESC);  
        pixels.setPixelColor(KEYBOARD_KEY3, pixels.Color(0,150,0)); 
        break;         
      case KEYBOARD_KEY4:                                            // zoom to 100%
        Keyboard.press(KEY_LEFT_CTRL);  
        Keyboard.print('0');
        break;
      case KEYBOARD_KEY5:                                            // vertical constraint
        pixels.setPixelColor(KEYBOARD_KEY5, pixels.Color(0,150,0)); 
        Keyboard.print('v');
        break;
      case KEYBOARD_KEY6:                                            // horizontal constraint
        Keyboard.print('h');
        pixels.setPixelColor(KEYBOARD_KEY6, pixels.Color(0,150,0)); 
        break;
      case KEYBOARD_KEY7:                                            // point constraint
        Keyboard.print('c');
        pixels.setPixelColor(KEYBOARD_KEY7, pixels.Color(0,150,0)); 
        break;
      case KEYBOARD_KEY8:                                            // tangent constraint
        Keyboard.print('t');
        pixels.setPixelColor(KEYBOARD_KEY8, pixels.Color(0,150,0)); 
        break;
      case KEYBOARD_KEY9:                                            // vertical length constraint
        Keyboard.press(KEY_LEFT_SHIFT);  
        Keyboard.print('v');
        pixels.setPixelColor(KEYBOARD_KEY9, pixels.Color(0,150,0)); 
        break;    
      case KEYBOARD_KEYA:                                            // horizontal length constraint
        Keyboard.press(KEY_LEFT_SHIFT);  
        Keyboard.print('h');
        pixels.setPixelColor(KEYBOARD_KEYA, pixels.Color(0,150,0)); 
        break;
      case KEYBOARD_KEYB:                                            // ortogonal constraint
        Keyboard.press(KEY_LEFT_SHIFT);  
        Keyboard.print('o');
        pixels.setPixelColor(KEYBOARD_KEYB, pixels.Color(0,150,0)); 
        break;
      case KEYBOARD_KEYC:                                            // symmetry constraint
        Keyboard.print('o');
        pixels.setPixelColor(KEYBOARD_KEYC, pixels.Color(0,150,0)); 
        break;
    }
    pixels.show();
    delay(100);
    Keyboard.releaseAll();
    colorUpdate = 1;
  }
}

void colors_Mode2() {
  if (colorUpdate == 1) {
    pixels.setPixelColor(KEYBOARD_KEY0, pixels.Color(  0,   0,   0)); // off
    pixels.setPixelColor(KEYBOARD_KEY1, pixels.Color(  0,   0,   0)); // off
    pixels.setPixelColor(KEYBOARD_KEY2, pixels.Color( 15,  15,  15)); // white
    pixels.setPixelColor(KEYBOARD_KEY3, pixels.Color(  0,   0,   0)); // off
    pixels.setPixelColor(KEYBOARD_KEY4, pixels.Color(  0,   0,   0)); // off
    pixels.setPixelColor(KEYBOARD_KEY5, pixels.Color( 15,   0,   0)); // red
    pixels.setPixelColor(KEYBOARD_KEY6, pixels.Color( 15,   0,   0)); // red
    pixels.setPixelColor(KEYBOARD_KEY7, pixels.Color( 15,   0,   0)); // red
    pixels.setPixelColor(KEYBOARD_KEY8, pixels.Color( 15,   0,   0)); // red
    pixels.setPixelColor(KEYBOARD_KEY9, pixels.Color( 63,   0,   0)); // red
    pixels.setPixelColor(KEYBOARD_KEYA, pixels.Color( 63,   0,   0)); // red
    pixels.setPixelColor(KEYBOARD_KEYB, pixels.Color( 15,   0,   0)); // red
    pixels.setPixelColor(KEYBOARD_KEYC, pixels.Color( 15,   0,   0)); // red

    pixels.show(); 
    
    colorUpdate = 0;
  }
}

void encoderA_Mode2(){
  long newPos = RotaryEncoderA.read()/ROTARY_SENSITIVITY; 
  if (newPos != positionEncoderA && newPos < positionEncoderA) {
    positionEncoderA = newPos;
    Consumer.write(MEDIA_VOLUME_UP);
  }

  if (newPos != positionEncoderA && newPos > positionEncoderA) {
    positionEncoderA = newPos;
    Consumer.write(MEDIA_VOLUME_DOWN);
  }
}

void encoderB_Mode2(){
  long newPos = RotaryEncoderB.read()/ROTARY_SENSITIVITY; 
  if (newPos != positionEncoderB && newPos < positionEncoderB) {
    positionEncoderB = newPos;
    Keyboard.press(KEY_RIGHT_CTRL);
    Mouse.move(0, 0, 1);
    Keyboard.release(KEY_RIGHT_CTRL);
  }

  if (newPos != positionEncoderB && newPos > positionEncoderB) {
    positionEncoderB = newPos;
    Keyboard.press(KEY_RIGHT_CTRL);
    Mouse.move(0, 0, -1);
    Keyboard.release(KEY_RIGHT_CTRL);
  }
}

void display_Mode2() { 
}      
