def yield_devices(cls, config): """ Search for usable devices, yield one at a time :param config: spreads configuration :type config: spreads.confit.ConfigView """ SPECIAL_CASES = { # noqa # (idVendor, idProduct): SpecialClass (0x4a9, 0x31ef): QualityFix, # not r47, but has the same bug (0x4a9, 0x3218): QualityFix, (0x4a9, 0x3223): A3300, (0x4a9, 0x3224): QualityFix, (0x4a9, 0x3225): QualityFix, (0x4a9, 0x3226): QualityFix, (0x4a9, 0x3227): QualityFix, (0x4a9, 0x3228): QualityFix, (0x4a9, 0x3229): QualityFix, (0x4a9, 0x322a): QualityFix, (0x4a9, 0x322b): QualityFix, (0x4a9, 0x322c): QualityFix, } for info in chdkptp.list_devices(): ids = (info.vendor_id, info.product_id) if ids in SPECIAL_CASES: yield SPECIAL_CASES[ids](config, chdkptp.ChdkDevice(info)) else: yield cls(config, chdkptp.ChdkDevice(info))
def initCamera(self, button): try: device = chdkptp.list_devices() self.camera = chdkptp.ChdkDevice(device[0]) except: self.text_line.setText('Error: camera not connected') return self.camera.switch_mode('record') self.camera.lua_execute('set_backlight(0)') self.setWindowTitle(self.camera.info.model_name) purge_files(self.camera) self.text_line.setText('Camera connected') self.connect.setEnabled(False) self.iso.setEnabled(True) self.shutter.setEnabled(True) self.pics.setEnabled(True) self.shoot.setEnabled(True) self.video.setEnabled(True) self.live.setEnabled(True) self.iso.setCurrentIndex(get_iso(self.camera)) self.shutter.setText(str(get_camera_shutter_time(self.camera))) self.pics.setText('1') self.initFocuser()
def __init__(self, info, config): # Tungsten whitebalance for most cameras is 3 self.whitebalance = 3 if info.product_id == 12970: # Tungsten whitebalance for ELPH 160 cameras is 4 self.whitebalance = 4 self.device = chdkptp.ChdkDevice(info) self.serial = info.serial_num self.zoom_steps = None self.config = config self.isReady = False self.message = '' self.position = 'odd'
def erase_ok(widget): try: device=chdkptp.list_devices() self.camera=chdkptp.ChdkDevice(device[0]) except: self.status_label.set_text('Error: camera not connected') return self.camera.switch_mode('record') self.camera.lua_execute('set_backlight(0)') self.camera.lua_execute('call_event_proc("UI.CreatePublic")') self.purge_files() self.status_label.set_text('Camera connected') self.connect_button.set_enabled(False) self.iso_menu.set_enabled(True) self.shutter_value.set_enabled(True) self.pics_value.set_enabled(True) self.shoot_button.set_enabled(True) self.video_button.set_enabled(True) self.live_view_check.set_enabled(True) self.lua_value.set_enabled(True) self.iso_menu.set_value(self.get_iso()) self.shutter_value.set_value(str(self.get_camera_shutter_time())) self.pics_value.set_value('1') if self.camera.lua_execute('get_drive_mode()') == 1: if float(self.shutter_value.get_value()) < 1: self.time_value.set_enabled(True) self.time_value.set_value('0') else: self.time_value.set_value('0') self.temperature_label.set_text('Temp (\xb0C): '+str(self.camera.lua_execute('get_temperature(1)'))) self.battery_label.set_text('Batt (V): '+str(self.camera.lua_execute('get_vbatt()')/1000.))
import logging import os import tempfile import chdkptp logging.basicConfig(level=logging.DEBUG) tmp_dir = tempfile.mkdtemp() dev = chdkptp.ChdkDevice(chdkptp.list_devices()[0]) print("Test files can be found under {0}".format(tmp_dir)) print("Checking connectivity") assert dev.is_connected print("Checking mode switch") if dev.mode == 'record': dev.switch_mode('play') assert dev.mode == 'play' dev.switch_mode('record') assert dev.mode == 'record' for fmt_type in ('ppm', 'jpg', 'png'): print("Checking get {} viewport frames".format(fmt_type)) c = 0 for imgdata in dev.get_frames(format=fmt_type): if c > 5: break c += 1