board-specific usability #808
This commit is contained in:
parent
0b5572d229
commit
2c844b551f
|
@ -10,3 +10,10 @@ outputs:
|
|||
TLE8888_PIN_20: "Extra Low #5"
|
||||
TLE8888_PIN_21: "Extra Low #6"
|
||||
|
||||
analog_inputs:
|
||||
EFI_ADC_2: "analog x"
|
||||
EFI_ADC_5: "analog y"
|
||||
EFI_ADC_7: "analog z"
|
||||
EFI_ADC_11: "analog whatever"
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ rem the storage section of rusefi.ini is updated as well
|
|||
rem lazy is broken - TS input is not considered a change
|
||||
rm build/config.gen
|
||||
|
||||
java -cp ../java_tools/ConfigDefinition.jar;../java_tools/configuration_definition/lib/snakeyaml.jar com.rusefi.board_generator.BoardReader -board microrusefi -firmware_path .
|
||||
java -jar ../java_tools/ConfigDefinition.jar -definition integration\rusefi_config.txt -ts_destination tunerstudio -ts_output_name rusefi_microrusefi.ini -prepend config/boards/microrusefi/temp.txt -skip build/config.gen
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -5,27 +5,58 @@ import com.rusefi.EnumsReader;
|
|||
import com.rusefi.enum_reader.Value;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class BoardReader {
|
||||
private static final String KEY_BOARD_NAME = "-board";
|
||||
private static final String KEY_FIRMWARE_PATH = "-firmware_path";
|
||||
public static final String INVALID = "INVALID";
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length < 2) {
|
||||
System.out.println("Please specify\r\n"
|
||||
+ KEY_BOARD_NAME + " x\r\n"
|
||||
+ KEY_FIRMWARE_PATH + " x\r\n"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
String boardName = null;
|
||||
String firmwarePath = "firmware";
|
||||
for (int i = 0; i < args.length - 1; i += 2) {
|
||||
String key = args[i];
|
||||
if (key.equals(KEY_BOARD_NAME)) {
|
||||
boardName = args[i + 1];
|
||||
} else if (key.equals(KEY_FIRMWARE_PATH)) {
|
||||
firmwarePath = args[i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
Yaml yaml = new Yaml();
|
||||
Map<String, Object> data = yaml.load(new FileReader("../../firmware/config/boards/microrusefi/mapping.yaml"));
|
||||
Map<String, Object> data = yaml.load(new FileReader(firmwarePath + "/config/boards/" + boardName + "/mapping.yaml"));
|
||||
System.out.println(data);
|
||||
|
||||
EnumsReader.process(new FileReader(firmwarePath + "/" + EnumToString.RELATIVE_PATH));
|
||||
|
||||
Map<String, Object> outputs = (Map<String, Object>) data.get("outputs");
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(boardName + "_prefix.txt"));
|
||||
|
||||
bw.write(processSection(data, "brain_pin_e", "outputs", "GPIO_UNASSIGNED"));
|
||||
bw.write(processSection(data, "adc_channel_e", "analog_inputs", "EFI_ADC_NONE"));
|
||||
|
||||
EnumsReader.process(new FileReader("../../firmware/" + EnumToString.RELATIVE_PATH));
|
||||
bw.close();
|
||||
}
|
||||
|
||||
Map<String, Value> s = EnumsReader.enums.get("brain_pin_e");
|
||||
private static String processSection(Map<String, Object> data, String enumName, String sectionName, String NOTHING_NAME) {
|
||||
Map<String, Object> outputs = (Map<String, Object>) data.get(sectionName);
|
||||
|
||||
Map<String, Value> s = EnumsReader.enums.get(enumName);
|
||||
System.out.println(s.size());
|
||||
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < 255; i++) {
|
||||
|
@ -37,19 +68,18 @@ public class BoardReader {
|
|||
Value v = findByOrdinal(i, s.values());
|
||||
|
||||
if (v == null) {
|
||||
code = "INVALID";
|
||||
} else if (v.getName().equals("GPIO_UNASSIGNED")) {
|
||||
code = INVALID;
|
||||
} else if (v.getName().equals(NOTHING_NAME)) {
|
||||
code = "NONE";
|
||||
} else if (outputs.containsKey(v.getName())) {
|
||||
code = (String) outputs.get(v.getName());
|
||||
} else {
|
||||
code = "INVALID";
|
||||
code = INVALID;
|
||||
}
|
||||
sb.append("\"" + code + "\"");
|
||||
}
|
||||
|
||||
System.out.println(" #define brain_pin_e_enum " + sb);
|
||||
|
||||
return " #define " + enumName + "_enum " + sb + "\r\n";
|
||||
}
|
||||
|
||||
private static Value findByOrdinal(int ordinal, Collection<Value> values) {
|
||||
|
|
Loading…
Reference in New Issue