159 lines
6.6 KiB
C++
159 lines
6.6 KiB
C++
// Linux commands
|
|
void keyboard_Mode0() {
|
|
if (key) {
|
|
switch (key) {
|
|
case KEYBOARD_KEY1:
|
|
Consumer.write(MEDIA_VOLUME_MUTE);
|
|
break;
|
|
case KEYBOARD_KEY2:
|
|
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.print("firefox"); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.press(KEY_RETURN); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_RETURN);
|
|
pixels.setPixelColor(KEYBOARD_KEY2, pixels.Color( 0, 127, 0));
|
|
break;
|
|
case KEYBOARD_KEY3:
|
|
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.print("spotify"); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.press(KEY_RETURN);
|
|
pixels.setPixelColor(KEYBOARD_KEY3, pixels.Color( 0, 127, 0));
|
|
break;
|
|
case KEYBOARD_KEY4:
|
|
Consumer.write(MEDIA_PLAY_PAUSE);
|
|
break;
|
|
case KEYBOARD_KEY5:
|
|
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.println("keepassxc"); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.press(KEY_ENTER);
|
|
pixels.setPixelColor(KEYBOARD_KEY5, pixels.Color( 0, 127, 0));
|
|
break;
|
|
case KEYBOARD_KEY6:
|
|
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.print("kicad"); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.press(KEY_RETURN);
|
|
pixels.setPixelColor(KEYBOARD_KEY6, pixels.Color( 0, 127, 0));
|
|
break;
|
|
case KEYBOARD_KEY7:
|
|
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.print("inkscape"); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.press(KEY_RETURN);
|
|
pixels.setPixelColor(KEYBOARD_KEY7, pixels.Color( 0, 127, 0));
|
|
break;
|
|
case KEYBOARD_KEY8:
|
|
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.print("freecad"); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.press(KEY_RETURN);
|
|
pixels.setPixelColor(KEYBOARD_KEY8, pixels.Color( 0, 127, 0));
|
|
break;
|
|
case KEYBOARD_KEY9:
|
|
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.print("screenshot"); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.press(KEY_RETURN);
|
|
pixels.setPixelColor(KEYBOARD_KEY9, pixels.Color( 0, 127, 0));
|
|
break;
|
|
case KEYBOARD_KEYA:
|
|
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.print("calculator"); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.press(KEY_RETURN);
|
|
pixels.setPixelColor(KEYBOARD_KEYA, pixels.Color( 0, 127, 0));
|
|
break;
|
|
case KEYBOARD_KEYB:
|
|
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.print("lightburn"); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.press(KEY_RETURN);
|
|
pixels.setPixelColor(KEYBOARD_KEYB, pixels.Color( 0, 127, 0));
|
|
break;
|
|
case KEYBOARD_KEYC:
|
|
Keyboard.press(KEY_LEFT_GUI); delay(SYSTEM_KEY_WAIT); Keyboard.release(KEY_LEFT_GUI); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.print("prusa"); delay(SYSTEM_GUI_WAIT);
|
|
Keyboard.press(KEY_RETURN);
|
|
pixels.setPixelColor(KEYBOARD_KEYC, pixels.Color( 0, 127, 0));
|
|
break;
|
|
}
|
|
pixels.show();
|
|
delay(SYSTEM_KEY_WAIT);
|
|
Keyboard.releaseAll();
|
|
colorUpdate = 1;
|
|
}
|
|
}
|
|
|
|
void colors_Mode0() {
|
|
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( 127, 31, 0)); // orange
|
|
pixels.setPixelColor(KEYBOARD_KEY3, pixels.Color( 0, 63, 0)); // green
|
|
pixels.setPixelColor(KEYBOARD_KEY4, pixels.Color( 0, 0, 0)); // off
|
|
pixels.setPixelColor(KEYBOARD_KEY5, pixels.Color( 0, 127, 0)); // green
|
|
pixels.setPixelColor(KEYBOARD_KEY6, pixels.Color( 127, 63, 0)); // yellow
|
|
pixels.setPixelColor(KEYBOARD_KEY7, pixels.Color( 63, 63, 127)); // cyan
|
|
pixels.setPixelColor(KEYBOARD_KEY8, pixels.Color( 31, 31, 63)); // gray
|
|
pixels.setPixelColor(KEYBOARD_KEY9, pixels.Color( 15, 15, 127)); // blue
|
|
pixels.setPixelColor(KEYBOARD_KEYA, pixels.Color( 127, 31, 0)); // orange
|
|
pixels.setPixelColor(KEYBOARD_KEYB, pixels.Color( 127, 0, 0)); // red
|
|
pixels.setPixelColor(KEYBOARD_KEYC, pixels.Color( 127, 31, 0)); // orange
|
|
|
|
pixels.show();
|
|
|
|
colorUpdate = 0;
|
|
}
|
|
}
|
|
|
|
void encoderA_Mode0(){
|
|
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_Mode1(){
|
|
long newPos = RotaryEncoderB.read()/ROTARY_SENSITIVITY;
|
|
if (newPos != positionEncoderB && newPos < positionEncoderB) {
|
|
positionEncoderB = newPos;
|
|
Consumer.write(MEDIA_NEXT);
|
|
}
|
|
|
|
if (newPos != positionEncoderB && newPos > positionEncoderB) {
|
|
positionEncoderB = newPos;
|
|
Consumer.write(MEDIA_PREVIOUS);
|
|
}
|
|
}
|
|
|
|
void display_Mode0() {
|
|
unsigned long currentMillis = millis();
|
|
if (currentMillis - previousMillis >= 3000) { // if the elasped time greater than 3 seconds
|
|
previousMillis = currentMillis; // save the last time you checked the interval
|
|
switch (updateLCD_flag) {
|
|
case 0:
|
|
lcd.clear();
|
|
lcd.setCursor(0, 0); lcd.print("1: empty");
|
|
lcd.setCursor(0, 1); lcd.print("2: Terminal");
|
|
lcd.setCursor(0, 2); lcd.print("3: Firefox");
|
|
lcd.setCursor(0, 3); lcd.print("4: alt+F4");
|
|
updateLCD_flag = 1;
|
|
break;
|
|
case 1:
|
|
lcd.clear();
|
|
lcd.setCursor(0, 0); lcd.print("5: empty");
|
|
lcd.setCursor(0, 1); lcd.print("6: KiCAD");
|
|
lcd.setCursor(0, 2); lcd.print("7: Inkscape");
|
|
lcd.setCursor(0, 3); lcd.print("8: FreeCAD");
|
|
updateLCD_flag = 2;
|
|
break;
|
|
case 2:
|
|
lcd.clear();
|
|
lcd.setCursor(0, 0); lcd.print(" 9: empty");
|
|
lcd.setCursor(0, 1); lcd.print("SYSTEM_KEY_WAIT: empty");
|
|
lcd.setCursor(0, 2); lcd.print("11: LightBurn");
|
|
lcd.setCursor(0, 3); lcd.print("12: PrusaSlicer");
|
|
updateLCD_flag = 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|