Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Version #6

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

JSON Version #6

wants to merge 3 commits into from

Conversation

carl689
Copy link

@carl689 carl689 commented Oct 6, 2024

Interact with JC-Pro_Macro-2 via JSON.

This should allow for a configuration webpage to directly communicate with the device in the following ways via web serial API. You can test with the Arduino IDE serial monitor

  • Set/Get configuration of buttons/encoder
  • Set lights
  • Reset EEPROM
  • Detect Key Presses and Encoder directly in browser

Original intent was to be able to load multiple profiles onto the device, but ran out of RAM to parse the complex JSON structure. Alternatively, the browser/script/cli can load different configs and manage "profiles" externally.

Example config

{
  "command": "SET",
  "profileID": 1,
  "generalConfig": {
    "defaultColor": [100, 100, 100]   // Default color for all buttons if none is specified
  },
  "buttons": {
    "0": {
      "action": "key",                // Type of action (e.g., key press or mouse move)
      "keys": "A",                    // Key(s) to be pressed
      "modifiers": "Ctrl",            // Optional modifiers (e.g., Ctrl, Shift)
      "x": 0,                         // X-coordinate for mouse move
      "y": 0,                         // Y-coordinate for mouse move
      "color": [255, 0, 0],           // RGB color for the button's normal state
      "colorOnPress": [0, 255, 0]     // Optional RGB color for the button's pressed state
    },
    "1": {
      "action": "mouse_move",
      "keys": "",
      "modifiers": "",
      "x": 100,
      "y": 50,
      "color": [0, 0, 255]            // Normal state color, no colorOnPress
    }
    // Continue defining buttons from 0 to 8
  },
  "encoder": {
    "increment": {
      "action": "key",               // Action for increasing
      "keys": "UpArrow",             // Key pressed when increasing
      "modifiers": "Shift"           // Optional modifiers for the increase action
    },
    "decrement": {
      "action": "key",               // Action for decreasing
      "keys": "DownArrow",           // Key pressed when decreasing
      "modifiers": "Shift"           // Optional modifiers for the decrease action
    }
  }
}

Get

{
  "command": "GET",
  "button": 2
}

Set Color

{
  "command": "SET_COLOR",
  "pixel": 4,
  "color": [255, 0, 0]
}

Reset EEPROM

{
  "command": "RESET_EEPROM"
}

@carl689
Copy link
Author

carl689 commented Oct 7, 2024

Frustratingly not enough ram to parse the config JSON on the Leonardo boards. Proof of concept works if you run the "debug" command. This loads mostly random values.

{ "command": "DEBUG" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant