Код:
Код: Выделить всё
#include // For media key support
// Slider definitions
const int NUM_SLIDERS = 4;
const int analogInputs[NUM_SLIDERS] = { A0, A1, A2, A3 };
int analogSliderValues[NUM_SLIDERS];
// Button definitions
#define BUTTON_PIN1 3
#define BUTTON_PIN2 10
#define BUTTON_PIN3 6
#define BUTTON_PIN4 16
#define BUTTON_PIN5 7 // Mode toggle button now
#define BUTTON_PIN6 14
#define BUTTON_PIN7 4
#define BUTTON_PIN8 15
const uint8_t NumButtons = 8;
const uint8_t ledPin = 17;
// Toggle button for switching modes
const uint8_t toggleButtonPin = 7; // Changed to Button 5 (Pin 7)
bool mode = 0; // 0 = Function Keys (F13-F20), 1 = Media Control Keys
bool lastToggleState = HIGH;
// Define function keys (F13-F20)
#define BUTTON_KEY1 KEY_F13
#define BUTTON_KEY2 KEY_F14
#define BUTTON_KEY3 KEY_F15
#define BUTTON_KEY4 KEY_F16
#define BUTTON_KEY5 KEY_F17
#define BUTTON_KEY6 KEY_F18
#define BUTTON_KEY7 KEY_F19
#define BUTTON_KEY8 KEY_F20
// Media key definitions (without volume control keys)
const int mediaKeys[8] = {
MEDIA_PLAY_PAUSE,
MEDIA_STOP,
MEDIA_PREVIOUS,
MEDIA_NEXT,
};
// Button helper class for handling press/release and debouncing
class button {
public:
const uint8_t pin;
button(uint8_t p) : pin(p) {}
// Overload the press method to handle both function keys and media keys
void press(boolean state, uint8_t key) {
if (state == pressed || (millis() - lastPressed = KEY_F13 && key = KEY_F13 && key
Подробнее здесь: [url]https://stackoverflow.com/questions/79289351/deej-macro-buttons-f-key-issues[/url]