Skip to content

Commit 355e8f9

Browse files
DriftKingTWclaude
andauthored
feat: dump current config over serial on READ_CONFIG (#16)
Add a serial command so the configuration tool can import the keymap currently on the device. When the serial input is "READ_CONFIG", print the current keyconfig.json wrapped in <<<CONFIG_BEGIN>>> / <<<CONFIG_END>>> markers instead of treating it as an incoming config to save. The existing write path (send JSON to update) is unchanged. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6e6a247 commit 355e8f9

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/main.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,19 @@ void loop() {
720720
// Accept Serial input for keyconfig.json
721721
if (Serial.available() > 0) {
722722
String jsonString = Serial.readString();
723+
jsonString.trim();
724+
725+
// Config read request: dump the current keyconfig.json (wrapped in
726+
// markers) so the configuration tool can import what's on the device.
727+
// Emit as a single write to minimize interleaving with Serial output
728+
// from tasks running on the other core.
729+
if (jsonString == "READ_CONFIG") {
730+
Serial.print("\n<<<CONFIG_BEGIN>>>\n" +
731+
loadJSONFileAsString("keyconfig") +
732+
"\n<<<CONFIG_END>>>\n");
733+
return;
734+
}
735+
723736
Serial.println("Received JSON:");
724737
Serial.println(jsonString);
725738

0 commit comments

Comments
 (0)