def dump(self, data, maxlen=None): value = data[self.key] if isinstance(value, str) and not self._is_text(value): if len(value) > 16: print() data_util.dump_hex(value, maxlen) elif isinstance(value, int): print("{} (0x{:X})".format(value, value)) elif maxlen is not None and len(value) > maxlen: print("{}...".format(value[:maxlen])) else: print(value)
def main(argv): parser = argparse.ArgumentParser( description="Produce PL flat VCOM calibration EEPROM binary blob") parser.add_argument('--debug', action="store_true", default=False, help="enable debug messages") parser.add_argument('--output', default='vcom-blob.bin', help="output file, default is vcom-blob.bin") parser.add_argument('--check', default=None, help="only check against existing blob file") parser.add_argument('dac_x1', action=data_util.store_hex, help="first DAC register value (hexadecimal)") parser.add_argument('dac_y1', type=int, help="VCOM voltage associated with dac_x1 in mV") parser.add_argument('dac_x2', action=data_util.store_hex, help="second DAC register value (hexadecimal)") parser.add_argument('dac_y2', type=int, help="VCOM voltage associated with dac_x2 in mV") parser.add_argument('vgpos', type=int, help="VGPOS voltage in mV") parser.add_argument('vgneg', type=int, help="VGNEG voltage in mV") parser.add_argument('ideal_vgswing', type=int, help="Ideal gate swing voltage in mV") parser.add_argument('board_type', help="board type") parser.add_argument('board_ver_maj', type=int, help="board major version number") parser.add_argument('board_ver_min', type=int, help="board minor version number") parser.add_argument('--vcom_mode', default=0, type=int, help="VCOM calibration mode") parser.add_argument('--hv_pmic', default=0, type=int, help="HV-PMIC part identifier") parser.add_argument('--vcom_dac', default=0, type=int, help="VCOM DAC part identifier") parser.add_argument('--vcom_adc', default=0, type=int, help="VCOM ADC part identifier") parser.add_argument('--io_config', default=0, type=int, help="configuration of the I/O signals") parser.add_argument('--i2c_mode', default=0, type=int, help="I2C mode") parser.add_argument('--temp_sensor', default=0, type=int, help="temperature sensor chip identifier") parser.add_argument('--frame_buffer', default=0, type=int, help="frame buffer memory identifier") parser.add_argument('--epdc', default=0, type=int, help="ePDC part reference identifier") parser.add_argument('--adc_scale_1', default=1, type=int, help="dividend of the ratio between VGSWING voltage and that measured by the ADC") parser.add_argument('--adc_scale_2', default=1, type=int, help="divisor to be used with ADC_SCALE_1") args = parser.parse_args(argv[1:]) data = { 'dac_x1': args.dac_x1, 'dac_y1': args.dac_y1, 'dac_x2': args.dac_x2, 'dac_y2': args.dac_y2, 'vgpos': args.vgpos, 'vgneg': args.vgneg, 'ideal_vgswing': args.ideal_vgswing, 'board_type': args.board_type, 'board_ver_maj': args.board_ver_maj, 'board_ver_min': args.board_ver_min, 'vcom_mode': args.vcom_mode, 'hv_pmic': args.hv_pmic, 'vcom_dac': args.vcom_dac, 'vcom_adc': args.vcom_adc, 'io_config': args.io_config, 'i2c_mode': args.i2c_mode, 'temp_sensor': args.temp_sensor, 'frame_buffer': args.frame_buffer, 'epdc_ref': args.epdc, 'adc_scale_1': args.adc_scale_1, 'adc_scale_2': args.adc_scale_2, } print("Generating VCOM EEPROM blob v{}".format(VERSION)) blob = build_blob().pack(data) print("Blob generated OK, total size: {}".format(len(blob))) if args.debug is True: data_util.dump_hex(blob) print("CRC: {:04X}".format(data['crc'])) if args.check is not None: ref_blob = open(args.check, 'rb').read() ret = build_blob().compare(ref_blob, blob) if ret: print("OK: blobs match") else: print("ERROR: blobs do not match") else: print("Saving into {}".format(args.output)) open(args.output, 'wb').write(blob) ret = True return ret