def __init__(self): # Let Qt and PyQt run their init first. super().__init__() self.setupUi(self) # Store portlist, which is used several times. self.portlist = enumeratePic24Ports() self.portlist.insert(0, 'Device port / pin')
def genTablesFromTemplate(csvFileName, destFileName): portlist = enumeratePic24Ports() # Read in the CSV containing device information. with open(csvFileName, "r") as csvFile: csv_dict_reader = csv.DictReader(csvFile).__iter__() # Open the output file. with open(destFileName, "w") as outFile: # Write the header outFile.write(c_license_header) outFile.write( '/// \\brief Define device-specific mappings from Rxy to RPy, ANn, and CNm pins.\n\n#if 0\n' ) # Walk through the file while True: # Read three rows try: RPy = csv_dict_reader.next() ANn = csv_dict_reader.next() CNm = csv_dict_reader.next() except StopIteration: break # Gather processor information. Make sure all three rows refer to the same processors and to the expected ports. processors, port = splitProcessorNames(RPy) assert port == 'RPy' # Check: all processors in this group should be unique. if len(processors) > len(set(processors)): print(" ".join(processors) + " contains duplicates.") assert False processors_temp, port = splitProcessorNames(ANn) assert processors == processors_temp assert port == 'ANn' processors_temp, port = splitProcessorNames(CNm) assert processors == processors_temp assert port == 'CNm' # Write out processor information. outFile.write('\n#elif defined(__' + '__) || \\\n defined(__'.join(processors) + '__)\n') # Walk through each Rxy on this processor for Rxy in portlist: # Get the specific values for this Rxy. _RPy = RPy[Rxy] _ANn = ANn[Rxy] _CNm = CNm[Rxy] if _RPy: outFile.write('# define R%s_RP %s\n' % (Rxy, _RPy)) if _ANn: outFile.write('# define R%s_AN %s\n' % (Rxy, _ANn)) if _CNm: outFile.write('# define R%s_CN %s\n' % (Rxy, _CNm)) # Write footer outFile.write( '#else\n# error "Port information not defined."\n#endif\n')
def genConfigFromTemplate(templateFileName, destFileName): # Read in the template. with open(templateFileName, "r", encoding='utf-8', newline='') as templateFile: template = Template(templateFile.read()) # Open the output file. with open(destFileName, "w", encoding='utf-8', newline='') as outFile: # Write the header outFile.write(c_license_header) outFile.write('/// \\brief Define GPIO configuration macros for all pins of a device.\n' + '/// See pic24_ports.h for more details.\n\n\n'); # Iterate over every port portlist = enumeratePic24Ports() # Add in some extra ports for unit testing portlist.extend(['T1', 'T2', 'T3']) for Rxy in portlist: # Evaluate the template for this port/pin. outFile.write(template.substitute({'x' : Rxy}))