parent
b32bda8275
commit
121f36c307
Binary file not shown.
|
@ -154,10 +154,13 @@ public class PinoutLogic {
|
||||||
Object pinId = pin.get("id");
|
Object pinId = pin.get("id");
|
||||||
Object pinClass = pin.get("class");
|
Object pinClass = pin.get("class");
|
||||||
Object pinName = pin.get("pin");
|
Object pinName = pin.get("pin");
|
||||||
String pinTsName = (String) pin.get("ts_name");
|
Object pinTsName = pin.get("ts_name");
|
||||||
if (pinId == null || pinClass == null || pinTsName == null) {
|
if (pinId == null || pinClass == null || pinTsName == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (pinName != null) {
|
||||||
|
pinTsName = pinTsName.toString().replace("___", pinName.toString());
|
||||||
|
}
|
||||||
if (pinId instanceof ArrayList) {
|
if (pinId instanceof ArrayList) {
|
||||||
ArrayList<String> pinIds = (ArrayList<String>) pinId;
|
ArrayList<String> pinIds = (ArrayList<String>) pinId;
|
||||||
if (!(pinClass instanceof ArrayList))
|
if (!(pinClass instanceof ArrayList))
|
||||||
|
@ -167,14 +170,14 @@ public class PinoutLogic {
|
||||||
throw new IllegalStateException(pinName + ": id array length should match class array length: " + pinId + " vs " + pinClassArray);
|
throw new IllegalStateException(pinName + ": id array length should match class array length: " + pinId + " vs " + pinClassArray);
|
||||||
for (int i = 0; i < pinIds.size(); i++) {
|
for (int i = 0; i < pinIds.size(); i++) {
|
||||||
String id = pinIds.get(i);
|
String id = pinIds.get(i);
|
||||||
addPinToList(id, pinTsName, pinClassArray.get(i));
|
addPinToList(id, (String) pinTsName, pinClassArray.get(i));
|
||||||
}
|
}
|
||||||
} else if (pinId instanceof String) {
|
} else if (pinId instanceof String) {
|
||||||
String pinIdString = (String) pinId;
|
String pinIdString = (String) pinId;
|
||||||
if (pinIdString.length() == 0) {
|
if (pinIdString.length() == 0) {
|
||||||
throw new IllegalStateException("Unexpected empty ID field");
|
throw new IllegalStateException("Unexpected empty ID field");
|
||||||
}
|
}
|
||||||
addPinToList(pinIdString, pinTsName, (String) pinClass);
|
addPinToList(pinIdString, (String) pinTsName, (String) pinClass);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Unexpected type of ID field: " + pinId.getClass().getSimpleName());
|
throw new IllegalStateException("Unexpected type of ID field: " + pinId.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,31 @@ public class PinoutLogicIntegratedTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTemplate() throws IOException {
|
||||||
|
runPinoutTest("pins:\n" +
|
||||||
|
" - pin: 1\n" +
|
||||||
|
" id: [E11, E11]\n" +
|
||||||
|
" class: [event_inputs, switch_inputs]\n" +
|
||||||
|
" function: Digital trigger/switch input for instance Hall type CAM\n" +
|
||||||
|
" ts_name: ___ - Digital 2\n" +
|
||||||
|
" type: din",
|
||||||
|
"//DO NOT EDIT MANUALLY, let automation work hard.\n" +
|
||||||
|
"\n" +
|
||||||
|
"// auto-generated by PinoutLogic.java based on key\n" +
|
||||||
|
"#include \"pch.h\"\n" +
|
||||||
|
"\n" +
|
||||||
|
"// see comments at declaration in pin_repository.h\n" +
|
||||||
|
"const char * getBoardSpecificPinName(brain_pin_e brainPin) {\n" +
|
||||||
|
"\tswitch(brainPin) {\n" +
|
||||||
|
"\t\tcase Gpio::E11: return \"1 - Digital 2\";\n" +
|
||||||
|
"\t\tdefault: return nullptr;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\treturn nullptr;\n" +
|
||||||
|
"}\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static void runPinoutTest(String inputYaml, String expected) throws IOException {
|
private static void runPinoutTest(String inputYaml, String expected) throws IOException {
|
||||||
StringWriter testWriter = new StringWriter();
|
StringWriter testWriter = new StringWriter();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue