// TEXT LABEL maker for wokwi.com daigram.json
// Edit the "TEXT" below. Copy/paste serial output into diagram.json. MIND THE COMMA OR LACK OF COMMA
char textLabel[] = "TEXT"; // textIndex will be appended to this text as well as the "txt" identifier.
int textIndex = 1; // edit if you want more than one label... or just copy/paste on the GUI.
void setup() {
Serial.begin(115200);
printText(textLabel, textIndex);
}
void loop() {}
void printText(char text[], int num) {
int index = 3;
for (int i = 0; i < num; i++) {
Serial.println(); // moves text down one row for copying
Serial.print(" {");
Serial.print(" \"type\": \"wokwi-text\",");
Serial.print(" \"id\": \"txt");
Serial.print(i);
Serial.print("\",");
Serial.print(" \"top\": ");
Serial.print(100 + i * 20);
Serial.print(",");
Serial.print(" \"left\": ");
Serial.print(100 + i * 10);
Serial.print(",");
Serial.print(" \"attrs\": { \"text\": \"");
Serial.print(text);
Serial.print(" ");
Serial.print(i);
Serial.print("\" }");
Serial.print(" }");
if (i != num)
Serial.println(",\n");
else
Serial.println();
}
}
/* EXAMPLE
{
"type": "wokwi-text",
"id": "txt0",
"top": -76.8,
"left": 96,
"attrs": { "text": "TEXT 0" }
},
*/