Skip to content

Conversation

@timoteuszelle
Copy link

This PR is stacked directly on top of PR #11 (Import and Export patterns by @MidnightJava) and adds a software-oriented JSON export feature. All of the behavior from PR #11 remains unchanged.

Relationship to PR #11

  • This branch is based on the current head of PR Import and Export patterns #11.
  • All of Mark’s changes (import/export, persist checkbox, wake loop, etc.) are included as-is.
  • This PR only adds a separate JSON export path for software workflows.

That means maintainers can:

Additions in this PR

1. UI: “Export for Software” section

Below the existing Import/Export buttons, this PR adds:

  • Format options

    • Binary (0/1)
    • Grayscale (0–255) (default)
  • Layout

    • Fixed column-major layout (9 x 34), matching the physical LED matrix orientation and my icon library usage.
  • Buttons

    • Export Left (JSON)
    • Export Right (JSON)

The existing Import/Export buttons and the 39‑byte hardware pattern format from PR #11 remain exactly as implemented there.

2. JSON export format

The new buttons generate a .json file with:

  • Shape

    • 9 x 34 (outer array = columns, inner array = rows)
  • Values

    • Binary mode: 0 (off) or 1 (on)
    • Grayscale mode: 0 (off) or 255 (fully lit)

This is derived from the existing convention where matrix[row][col] === 0 means “LED on”.

Filenames follow this pattern, e.g.:

  • matrix_left_grayscale_colmajor.json
  • matrix_right_binary_colmajor.json

3. Implementation details

  • index.html

    • Adds the “Export for Software” section with:
      • A format radio group (binary vs grayscale).
      • Fixed-layout note (“fixed column-major (9x34)”).
      • Export Left/Right (JSON) buttons.
  • app.js

    • Calls initSoftwareExportOptions() in the main $(function() { ... }).
    • Adds initSoftwareExportOptions():
      • Wires #exportLeftSoftwareBtn / #exportRightSoftwareBtn to the new behavior.
      • Reads the exportFormat radio value.
    • Adds exportMatrixSoftware(matrix, side, grayscale):
      • Builds a fixed column‑major 9 x 34 array from the existing matrix_*.
      • Maps internal 0/1 cells to 0/1 or 0/255.
      • Triggers a JSON download with a descriptive filename.

Compatibility

  • No changes to the 39‑byte hardware import/export from PR Import and Export patterns #11.
  • JSON export is fully additive and only affects the new “Export for Software” UI.
  • Intended for use cases like the LED matrix monitoring project (icon libraries, grayscale icons, etc.).

Happy to adjust naming/text if you prefer different terminology for the new options.

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.

2 participants