Community project

Deck De Macros Configurável

Photo of Deck De Macros Configurável
Generated with AI

Joaquim Jaques

Published November 30, 2026

Deck De Macros Configurável is a programmable macro keyboard built around an ESP32 microcontroller and a 2.4-inch ST7789 color display. The rotary encoder lets users navigate and select from six customizable macro slots, each capable of sending keyboard shortcuts with modifier keys (Ctrl, Shift, Alt, Win) to any connected computer via USB HID.

This guide provides a complete wiring diagram, parts list, and step-by-step assembly instructions. The included firmware enables web-based configuration through a local interface, allowing users to customize macro names, key assignments, and modifiers without recompiling code. Preferences are stored persistently on the ESP32, making the deck immediately ready for use after assembly.

Wiring diagram

Wiring diagram for Deck De Macros Configurável
Loading diagram…

Gather all the parts

QtyComponent
1

2.4-inch ST7789 SPI TFT

240 x 320, 3.3 V SPI breakout

1

Rotary Encoder with Switch

5-pin incremental rotary encoder with integrated push-switch: 3 pins for rotation (5 V supply + 2 quadrature outputs) and 2 pins that short when the shaft is pressed.

1

Resistor

100 Ω

Through-hole resistor (current-limiting in series with an LED)

Assemble it in 3 steps

1. Ligue a tela com o USB desligado

VCC vai ao 3V3, GND ao GND, SCL ao GPIO12 (relógio), SDA ao GPIO11 (dados), CS ao GPIO10 (seleção), DC ao GPIO6 (comando) e RST ou RES ao GPIO7 (reinício). Ligue BL ao 3V3 através do resistor de 100 Ω.

  • Use somente um módulo SPI de 3.3 V com esses sinais. Não use 5 V na tela. Confira os nomes, não a ordem dos pinos.

2. Ligue o seletor EC11

A vai ao GPIO4 e B ao GPIO5 para ler o giro. COM vai ao GND. Dos dois contatos do clique, ligue um ao GPIO15 e o outro ao GND.

3. Conecte o cabo USB de dados

Use a porta USB nativa da placa para o teclado funcionar no Windows. A porta marcada UART não envia teclas.

Review all connections

1. Connections between "tela" and "ESP32"

FunctiontelaESP32
powerVCC3V3
groundGNDGND
spiSCLGPIO 12
spiSDAGPIO 11
spiCSGPIO 10
digitalDCGPIO 6
digitalRSTGPIO 7

2. Connections between "r1" and "ESP32"

Functionr1ESP32
powerP13V3
digitalP2 → 2.4-inch ST7789 SPI TFT BLEXT

3. Connections between "seletor" and "ESP32"

FunctionseletorESP32
digitalAGPIO 4
digitalBGPIO 5
groundCOMGND
digitalSW1GPIO 15
groundSW2GND

Deploy the firmware

#include <Arduino.h>
#include <SPI.h>
#include <Adafruit_ST7789.h>
#include <USB.h>
#include <USBHIDKeyboard.h>
#include <WiFi.h>
#include <WebServer.h>
#include <Preferences.h>

Adafruit_ST7789 tft(10,6,7);
USBHIDKeyboard keyboard;
WebServer web(80);
Preferences prefs;
constexpr int N=6;
struct Slot { char name[21]; char key; uint8_t mods; };
Slot slots[N]={{"Explorador",'e',8},{"Executar",'r',8},{"Copiar",'c',1},{"Colar",'v',1},{"Salvar",'s',1},{"Desfazer",'z',1}};
int selected=0;
bool dirty=true, editing=false;
String token;
uint8_t phase(){return digitalRead(4)*2+digitalRead(5);}
bool valid(char c){return (c>='a'&&c<='z')||(c>='0'&&c<='9');}
String safe(const char* s){String out; for(;*s;++s){if(*s=='&')out+="&amp;";else if(*s=='<')out+="&lt;";else if(*s=='\"')out+="&quot;";else out+=*s;}return out;}
void page(){
 String h="<!doctype html><meta charset=utf-8><meta name=viewport content='width=device-width'><title>Mini Deck</title><h1>Mini Deck</h1><p>Use nomes sem acentos e uma letra (a-z) ou numero (0-9) por atalho.</p>";
 for(int i=0;i<N;i++){
  h+="<form method=post action=/save><p>"+String(i+1)+" <input type=hidden name=t value='"+token+"'><input type=hidden name=i value='"+String(i)+"'><input required name=n maxlength=20 value=\""+safe(slots[i].name)+"\"> <input required size=2 name=k maxlength=1 value='"+String(slots[i].key)+"'> ";
  const char* names[]={"Ctrl","Shift","Alt","Win"};
  for(int b=0;b<4;b++){h+="<label><input type=checkbox name=m"+String(b);if(slots[i].mods&(1<<b))h+=" checked";h+=">"+String(names[b])+"</label> ";}
  h+="<button>Salvar</button></p></form>";
 }
 web.send(200,"text/html; charset=utf-8",h);
}
void save(){
 String index=web.arg("i"), name=web.arg("n"), key=web.arg("k");key.toLowerCase();
 if(web.arg("t")!=token || index.length()!=1 || index[0]<'0'||index[0]>='0'+N || !name.length() || name.length()>20 || key.length()!=1 || !valid(key[0])){web.send(400,"text/plain","Dados invalidos.");return;}
 for(unsigned j=0;j<name.length();j++)if(name[j]<32||name[j]>126){web.send(400,"text/plain","Use nomes sem acentos.");return;}
 int i=index[0]-'0';Slot next{};name.toCharArray(next.name,sizeof(next.name));next.key=key[0];
 for(int b=0;b<4;b++)if(web.hasArg("m"+String(b)))next.mods|=1<<b;
 if(prefs.putBytes(("slot"+String(i)).c_str(),&next,sizeof(next))!=sizeof(next)){web.send(500,"text/plain","Nao foi possivel salvar.");return;}
 slots[i]=next;dirty=true;web.sendHeader("Location","/");web.send(303,"text/plain","");
}
void draw(){
 tft.fillScreen(ST77XX_BLACK);tft.setTextSize(2);tft.setTextColor(ST77XX_CYAN);tft.setCursor(12,12);tft.print("MINI DECK");
 for(int i=0;i<N;i++){int y=40+i*25;if(i==selected)tft.fillRect(8,y-3,304,23,0x0215);tft.setCursor(15,y);tft.setTextColor(ST77XX_WHITE);tft.print(slots[i].name);}
 tft.setTextSize(1);tft.setCursor(12,205);tft.print(editing?"Wi-Fi MiniDeck | http://192.168.4.1":"Gire e clique | Segure para configurar");
 tft.setCursor(12,220);tft.print(editing?"Senha: Deck-8264 | Segure para sair":"Use a porta USB nativa");
}
void setup(){
 pinMode(4,INPUT_PULLUP);pinMode(5,INPUT_PULLUP);pinMode(15,INPUT_PULLUP);
 keyboard.begin();USB.begin();
 SPI.begin(12,-1,11,10);tft.init(240,320);tft.setRotation(1);tft.setTextWrap(false);
 prefs.begin("minideck",false);for(int i=0;i<N;i++){String k="slot"+String(i);if(prefs.getBytesLength(k.c_str())==sizeof(Slot))prefs.getBytes(k.c_str(),&slots[i],sizeof(Slot));}
 web.on("/",HTTP_GET,page);web.on("/save",HTTP_POST,save);
}
void loop(){
 static uint8_t prev=phase();static int accum=0;static const int8_t step[]={0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
 uint8_t p=phase();if(p!=prev){if((p^prev)==3)accum=0;else accum+=step[prev*4+p];prev=p;if(abs(accum)>=4){selected=(selected+N+(accum>0?1:-1))%N;accum=0;dirty=true;}}
 static bool raw=false,pressed=false,held=false;static uint32_t change=0,down=0;uint32_t now=millis();bool r=!digitalRead(15);
 if(r!=raw){raw=r;change=now;}
 if(raw!=pressed && now-change>=25){pressed=raw;if(pressed){down=now;held=false;}else if(!held&&!editing){const auto &s=slots[selected];const uint8_t mods[]={KEY_LEFT_CTRL,KEY_LEFT_SHIFT,KEY_LEFT_ALT,KEY_LEFT_GUI};for(int i=0;i<4;i++)if(s.mods&(1<<i))keyboard.press(mods[i]);keyboard.press(s.key);delay(30);keyboard.releaseAll();}}
 if(pressed&&!held&&now-down>=900){held=true;if(editing){web.stop();WiFi.softAPdisconnect(true);editing=false;}else if(WiFi.softAP("MiniDeck","Deck-8264")){token=String(esp_random(),HEX)+String(esp_random(),HEX);web.begin();editing=true;}dirty=true;}
 if(editing)web.handleClient();if(dirty){dirty=false;draw();}delay(1);
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik