当前位置: 首页>>代码示例>>Python>>正文


Python ABE_helpers.ABEHelpers类代码示例

本文整理汇总了Python中ABE_helpers.ABEHelpers的典型用法代码示例。如果您正苦于以下问题:Python ABEHelpers类的具体用法?Python ABEHelpers怎么用?Python ABEHelpers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ABEHelpers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, datasocket=None):
     threading.Thread.__init__(self)
     if datasocket is not None:
         self.datasocket = datasocket
     else:
         self.datasocket = None    
     self.measured_voltage = 0
     self.filament = {}
     port = '/dev/serial/by-id/usb-TTI_CPX400_Series_PSU_C2F952E5-if00'
     self.filament['device'] = CPX.CPX400DPDriver(1, device=port)
     self.filament['voltage'] = 0
     self.filament['current'] = 0
     self.filament['idle_voltage'] = 3
     self.filament['device'].set_current_limit(4)
     self.filament['device'].output_status(True)
     self.bias = {}
     self.bias['device'] = CPX.CPX400DPDriver(2, device=port)
     self.bias['grid_voltage'] = 0
     self.bias['grid_current'] = 0
     self.bias['device'].output_status(True)
     self.looptime = 0
     self.update_setpoint(0.1)
     i2c_helper = ABEHelpers()
     bus = i2c_helper.get_smbus()
     self.adc = DeltaSigma(bus, 0x68, 0x69, 18)
     self.adc.set_pga(1)  # This shold be 8, but amplifier seems broken on the available device
     self.running = True
     self.wanted_voltage = 0
     self.emission_current = 999
     self.pid = pid.PID(2, 0.03, 0, 9)
     self.pid.update_setpoint(self.setpoint)
开发者ID:neilanderson,项目名称:PyExpLabSys,代码行数:31,代码来源:emission_control.py

示例2: Init_IOPi

def Init_IOPi(): 
    global sensorbus    
    global buttonbus
    i2c_helper = ABEHelpers()
    i2c_bus = i2c_helper.get_smbus()
    sensorbus = IoPi(i2c_bus, 0x20) 
    # set both rows of pins to input mode
    sensorbus.set_port_direction(0, 0xFF)
    sensorbus.set_port_direction(1, 0xFF)
    #setup interrupts on bus 2, port 1
    buttonbus = IoPi(i2c_bus, 0x21)
    # Set all pins on the bus to be inputs with internal pull-ups enabled.
    buttonbus.set_port_pullups(1, 0xFF)
    buttonbus.set_port_direction(1, 0xFF)
    # Inverting the ports will allow a button connected to ground to register as 1 or on.
    buttonbus.invert_port(1, 0xFF)  # invert port 1 so a button press will register as 1
    # Set the interrupt polarity to be active low and mirroring enabled, so
    # INT A and INT B go low when an interrupt is triggered
    buttonbus.set_interrupt_polarity(0)
    #buttonbus.mirror_interrupts(1)
    # Set the interrupts default value to 0 so it will trigger when any of the pins on the bus change to 1
    buttonbus.set_interrupt_defaults(1, 0x00)
    # Set the interrupt type to be 0xFF for port B so an interrupt is
    # fired when the pin matches the default value
    buttonbus.set_interrupt_type(1, 0xFF)
    # Enable interrupts for all pins on the port
    buttonbus.set_interrupt_on_port(1, 0xFF)
    # reset the interrups on the IO Pi bus 
    buttonbus.reset_interrupts()

    GPIO.setmode(GPIO.BCM)
    # Set up GPIO 23 as an input. The pull-up resistor is disabled as the level shifter will act as a pull-up. 
    GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_OFF)
    # when a falling edge is detected on GPIO pin 23 the function button_pressed will be run  
    GPIO.add_event_detect(23, GPIO.FALLING, callback=hwbutton_pressed) 
开发者ID:zigel,项目名称:piplay,代码行数:35,代码来源:Start1.py

示例3: __init__

    def __init__(self, room, direction):
	self.room = room
	self.direction = direction
	self.channel = self.channelRoomMappings[direction][room]
        
	i2c_helper = ABEHelpers()
	bus = i2c_helper.get_smbus()
	self.adc = DeltaSigma(bus, 0x68, 0x69, 18)
开发者ID:beaf-o,项目名称:pi-blinds,代码行数:8,代码来源:voltage.py

示例4: __init__

    def __init__(self):

        i2c_helper = ABEHelpers()
        i2c_bus = i2c_helper.get_smbus()
        multibus = [IoPi(i2c_bus, 0x22), IoPi(i2c_bus, 0x23)]

        self.tenhome = Digit(multibus, 1, True)
        self.home = Digit(multibus, 8, True)
        self.tenguest = Digit(multibus, 17, True)
        self.guest = Digit(multibus, 24, True)
开发者ID:briankoppelaar,项目名称:digits,代码行数:10,代码来源:scoreboard.py

示例5: __init__

	def __init__(self):

		i2c_helper = ABEHelpers()
		i2c_bus = i2c_helper.get_smbus()
		multibus = [ IoPi(i2c_bus, 0x20), IoPi(i2c_bus, 0x21)]

		self.tenminute = Digit(multibus, 1, True)
		self.minute = Digit(multibus, 8, True)
		self.tensecond = Digit(multibus, 17, True)
		self.second = Digit(multibus, 24, True)
开发者ID:briankoppelaar,项目名称:digits,代码行数:10,代码来源:timeclock.py

示例6: __init__

   def __init__ (self, ph7, ph4, ds):
      self.ph7 = ph7
      self.ph4 = ph4
      self.ds  = ds

      i2c_helper = ABEHelpers()
      bus = i2c_helper.get_smbus()
      self.adc = ADCPi(bus, self.i2c1, self.i2c2, self.bitrate)

      self.calcpHSlope()
开发者ID:3epnm,项目名称:phController,代码行数:10,代码来源:PH.py

示例7: setup_adc

 def setup_adc(self, adr1, adr2, accu):
     print("setting up adc with accuracy <"
           + str(accu) + "> on addresses <"
           + str(adr1) + "> and <"
           + str(adr2) + ">")
     i2c_helper = ABEHelpers()
     bus = i2c_helper.get_smbus()
     adc = ADCPi(bus, adr1, adr2, accu)
     
     return adc
开发者ID:ManInAGarden,项目名称:PiADCMeasure,代码行数:10,代码来源:mainwindow.py

示例8: __init__

	def __init__(self, configfilename):

		config = ConfigParser.RawConfigParser()
		config.read(configfilename)
		inverted_logic = config.getboolean(self.__class__.__name__, 'inverted_logic')

		i2c_helper = ABEHelpers()
		i2c_bus = i2c_helper.get_smbus()
		multibus = [ IoPi(i2c_bus, 0x20), IoPi(i2c_bus, 0x21)]

		self.tendigit = Digit(multibus, 1, inverted_logic)
		self.digit = Digit(multibus, 8, inverted_logic)
开发者ID:tdrimmelen,项目名称:digits,代码行数:12,代码来源:shotclock.py

示例9: __init__

    def __init__(self, drive):
        """ Standard Constructor """
        logging.info("Proximity constructor")
        # set up ADC
        self.i2c_helper = ABEHelpers()
        self.bus = self.i2c_helper.get_smbus()
        self.adc = ADCPi(self.bus, 0x6a, 0x6b, 12)

        # define fixed values
        self.stopped = 0
        self.full_forward = 0.4
        self.slow_forward = 0.3
        self.full_reverse = -0.5
        self.slow_reverse = -0.25

        self.left_steering = -0.25
        self.right_steering = 0.25
        self.straight = 0
        self.distance_sensor = 1

        # Voltage value we are aiming for (2 was close, 0.5 was further away)
        self.distance_threshold = 50.0
        self.distance_required = 17.0

        # Drivetrain is passed in
        self.drive = drive
        self.killed = False
开发者ID:hackhitchin,项目名称:piwars,代码行数:27,代码来源:proximity.py

示例10: __init__

    def __init__(self, drive):
        """ Standard Constructor """
        logging.info("Three Point Turn constructor")
        # set up ADC
        self.i2c_helper = ABEHelpers()
        self.bus = self.i2c_helper.get_smbus()
        self.adc = ADCPi(self.bus, 0x6a, 0x6b, 12)

        # define fixed values
        # red is typically 3.5V
        self.red_min = 3
        self.red = 3.5
        self.stopped = 0
        self.full_forward = 0.4
        self.half_forward = 0.3
        self.slow_forward = 0.1
        self.full_reverse = -0.3
        self.half_reverse = -0.15
        self.slow_reverse = -0.1

        self.straight = 0
        self.full_left = -1
        self.slow_left = -0.5
        self.rear_line_sensor = 2
        # same sensor for now
        self.front_line_sensor = 2
        self.max_rate = 2

        # Drivetrain is passed in
        self.drive = drive

        self.killed = False
开发者ID:hackhitchin,项目名称:piwars,代码行数:32,代码来源:three_point_turn.py

示例11: __init__

    def __init__(self, drive):
        """ Standard Constructor """
        logging.info("Straight Line Speed constructor")
        # set up ADC
        self.i2c_helper = ABEHelpers()
        self.bus = self.i2c_helper.get_smbus()
        self.adc = ADCPi(self.bus, 0x6a, 0x6b, 12)

        # define fixed values
        self.stopped = 0
        self.full_forward = 0.5
        self.slow_forward = 0.1
        self.full_reverse = -0.5
        self.slow_reverse = -0.1

        self.left_steering = -0.25
        self.right_steering = 0.25
        self.straight = 0
        self.distance_sensor = 1

        # Voltage value we are aiming for (2 was close, 0.5 was further away)
        self.nominal_voltage = 0.5
        self.min_dist_voltage = 2.0
        self.max_dist_voltage = 0.4

        # Drivetrain is passed in
        self.drive = drive
        self.killed = False
开发者ID:markmellors,项目名称:piwars,代码行数:28,代码来源:proximity.py

示例12: __init__

    def __init__(self):
        self._a2d_chan_speed = a2d_chan_speed
        self._a2d_chan_direction = a2d_chan_direction
        self._a2d_chan_vcc = a2d_chan_vcc
        
        self._file_report_period = file_report_period

        self._i2c_helper = ABEHelpers()
        self._bus = self._i2c_helper.get_smbus()
        self._adc = ADCPi(self._bus, 0x68, 0x69, 12)

        self._CtrlPort = 8200
        self._IPAddr = self.get_local_ip()
        self._samples = list()
        self._samples_lock = threading.Lock()        
        self._display_lock = threading.Lock()        

        self._thread_sampling_obj = None
        self._thread_reporting_obj = None
        self._stop_requested = False

        self._dirs_stream = list() #stream of directions searched for callibration samples
        
        #calibrated directions
        self._dirs = list()
        self._dirs_volts = list()
        self._dirs_names = ("NN", "NE", "EE", "SE", "SS", "SW", "WW", "NW")
        self._dirs_file = "/home/pi/PyProj/dirs_calibration.txt"

        self._calibration_restore()
        self.files_to_compress = list()
        self.display = False
开发者ID:Mechelix,项目名称:RPi-Wind,代码行数:32,代码来源:05_wind_speed_meter_f200.py

示例13: __init__

class dld_solar_window:
    _channel = 0
    _report_period = 5

    _thread = None
    _stop_requested = False

    _srv_ip_addr = "1.2.2.201"
    _srv_port = 8200

    def __init__(self, channel=0, report_period=the_report_period):
        self._channel = channel
        self._report_period = report_period
        self._i2c_helper = ABEHelpers()
        self._bus = self._i2c_helper.get_smbus()
        self._adc = ADCPi(self._bus, 0x68, 0x69, 12)

    def Start(self):
        self._stop_requested = False
        self._thread = threading.Thread(target=self.SamplingThread)
        self._thread.start()
        print("sampling thread initialized")

    def SamplingThread(self):
        print("sampling thread started")

        mc_socket = None

        time_last_report = time.time()
        connected = False
        while self._stop_requested != True:
            if connected == False:
                try:
                    # time.sleep(5)
                    mc_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                    mc_socket.connect((self._srv_ip_addr, self._srv_port))
                    print("connected")
                    time.sleep(1)
                except Exception as e:
                    connected = False
                    continue

            time_now = time.time()
            voltage = self._adc.read_voltage(self._channel)

            try:
                mc_socket.send("Vout:%02f\n" % (voltage))
                print("Vout:%02f\n" % (voltage))
            except Exception as e:
                connected = False
            time.sleep(5.0)

    def Stop(self):
        if self._thread == None:
            return
        self._stop_requested = True
        if self._thread.isAlive():
            self._thread.join()
        self._thread = None
开发者ID:intelmakers,项目名称:Project--Energy-Friendly-House,代码行数:59,代码来源:dld_solar_window.py

示例14: init_servos

def init_servos(address):
    i2c_helper = ABEHelpers()
    bus = i2c_helper.get_smbus()
    pwm = PWM(bus, address)
    pwm.set_pwm_freq(60)
    pwm.output_enable()

    # cycle the arms on channels 0, 2, 4
    print("cycling through all valid positions")
    for x in (175, 300, 425, 550):
        pwm.set_pwm(0, 0, x)
        sleep(1)
        pwm.set_pwm(2, 0, x)
        sleep(1)
        pwm.set_pwm(4, 0, x)
        sleep(2)
    return pwm
开发者ID:joshjh,项目名称:steelie-clock,代码行数:17,代码来源:move_arm.py

示例15: __init__

    def __init__(self):
        """ Standard Constructor """
        logging.info("Three Point Turn constructor")
        # set up ADC
        self.i2c_helper = ABEHelpers()
        self.bus = self.i2c_helper.get_smbus()
        self.adc = ADCPi(self.bus, 0x6a, 0x6b, 12)

        self.killed = False
开发者ID:hackhitchin,项目名称:piwars,代码行数:9,代码来源:line_test.py


注:本文中的ABE_helpers.ABEHelpers类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。