diff options
Diffstat (limited to 'templates')
-rw-r--r-- | templates/arduino-uno.py | 4 | ||||
-rw-r--r-- | templates/intel-quark-d2000.py | 3 | ||||
-rw-r--r-- | templates/nodemcu-arduino.py | 65 | ||||
-rw-r--r-- | templates/nodemcu.py | 19 |
4 files changed, 69 insertions, 22 deletions
diff --git a/templates/arduino-uno.py b/templates/arduino-uno.py index a7b4ec7..ada59a3 100644 --- a/templates/arduino-uno.py +++ b/templates/arduino-uno.py @@ -4,7 +4,7 @@ generateHeader.println(""" namespace schematic { """) -usages = generateHeader.netlist.find_usages_of(generateHeader.ref) +usages = generateHeader.netlist.find_nets_using_ref(generateHeader.ref) for usage in usages: node = usage.node_for_ref(generateHeader.ref) @@ -12,7 +12,7 @@ for usage in usages: if 7 <= node.pin <= 12: generateHeader.println("static const int ANALOG_" + usage.name + " = " + str(node.pin - 7) + ";") elif 13 <= node.pin <= 26: - generateHeader.println("static const int ANALOG_" + usage.name + " = " + str(node.pin - 13) + ";") + generateHeader.println("static const int " + usage.name + " = " + str(node.pin - 13) + ";") generateHeader.println(""" } // namespace schematic diff --git a/templates/intel-quark-d2000.py b/templates/intel-quark-d2000.py index 85572c5..5bc69e0 100644 --- a/templates/intel-quark-d2000.py +++ b/templates/intel-quark-d2000.py @@ -1,4 +1,5 @@ global generateHeader + gpio_map = { 2: '10', 3: '11', @@ -40,7 +41,7 @@ enum schematic_direction { }; """) -usages = generateHeader.netlist.find_usages_of(generateHeader.ref) +usages = generateHeader.netlist.find_nets_using_ref(generateHeader.ref) for usage in usages: node = usage.node_for_ref(generateHeader.ref) diff --git a/templates/nodemcu-arduino.py b/templates/nodemcu-arduino.py new file mode 100644 index 0000000..1f258e6 --- /dev/null +++ b/templates/nodemcu-arduino.py @@ -0,0 +1,65 @@ +global generateHeader + +gpio_map = { + # Left side + 1: None, # Vin + 2: None, # GND + 3: None, # RST + 4: None, # EN + 5: None, # 3V3 + 6: None, # GND + 7: None, # CLK + 8: None, # SD0 + 9: None, # CMD + 10: None, # SD1 + 11: '9', # SD2 + 12: '10', # SD3 + 13: None, # RSV + 14: None, # RSV + 15: '0', # A0 + + # Right side + 16: '16', + 17: '5', + 18: '4', + 19: '0', + 20: '2', + 21: None, # 3V3 + 22: None, # Gnd + 23: '14', + 24: '12', + 25: '13', + 26: '15', + 27: '3', + 28: '1', + 29: None, # GND + 30: None, # 3V3 +} + +usages = generateHeader.netlist.find_nets_using_ref(generateHeader.ref) + +entries = [] + +for usage in usages: + if usage.name is None: + continue + + node = usage.node_for_ref(generateHeader.ref) + + name = gpio_map.get(node.pin) + + if name is None: + continue + + entries.append([usage.name, name]) + +generateHeader.println(""" +namespace schematic { +""") + +for x in sorted(entries, key=lambda e: e[0]): + generateHeader.println("static const int " + x[0]+ " = " + x[1] + ";") + +generateHeader.println(""" +} // namespace schematic +""") diff --git a/templates/nodemcu.py b/templates/nodemcu.py deleted file mode 100644 index a7b4ec7..0000000 --- a/templates/nodemcu.py +++ /dev/null @@ -1,19 +0,0 @@ -global generateHeader - -generateHeader.println(""" -namespace schematic { -""") - -usages = generateHeader.netlist.find_usages_of(generateHeader.ref) - -for usage in usages: - node = usage.node_for_ref(generateHeader.ref) - - if 7 <= node.pin <= 12: - generateHeader.println("static const int ANALOG_" + usage.name + " = " + str(node.pin - 7) + ";") - elif 13 <= node.pin <= 26: - generateHeader.println("static const int ANALOG_" + usage.name + " = " + str(node.pin - 13) + ";") - -generateHeader.println(""" -} // namespace schematic -""") |