How to use the control.Control function in control

To help you get started, we’ve selected a few control examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yenkuanlee / IPDC / ER / chain.py View on Github external
import control
import json
import ObjectNode
import os
import subprocess
import sys
import time

AskResource = True
DbPath = "/tmp/.db"

a = control.Control()
def LoadDescription():
    Ddict = dict()
    f = open('description.conf','r')
    while True:
        line = f.readline()
        if not line:
                break
        tmp = line.split("=")
	try:
        	for i in range(len(tmp)):
			if tmp[0] == "description":
				tmp[i] = tmp[i].replace("\n","")
                        	continue
                	tmp[i] = tmp[i].replace(" ","")
                	tmp[i] = tmp[i].replace("\n","")
                	tmp[i] = tmp[i].replace("\t","")
github mattjml / pi_cam_line_follower / control.py View on Github external
len_left = len(closest_lefts)
        len_right = len(closest_rights)

        if len_left == 0 and len_right == 0:
            return None
        if len_left > 0 and len_right == 0:
            return Control.LEFT
        if len_left == 0 and len_right > 0:
            return Control.RIGHT
        print 'closest lefts then rights'
        print closest_lefts
        print closest_rights 
        if((50 - max(closest_lefts)) > (min(closest_rights) - 50)):
            return Control.RIGHT
        else:
            return Control.LEFT
github mkouhei / iori / src / iori / command.py View on Github external
def list_nodes(args):
    ctl = control.Control(repopath(args))
    ctl.list_nodes()
github mattjml / pi_cam_line_follower / control.py View on Github external
closest_rights = flatten([intersect for intersect in [[line[0] for line in row if line[0] >= 50] for row in lines.values()] if len(intersect) > 0])
        
        len_left = len(closest_lefts)
        len_right = len(closest_rights)

        if len_left == 0 and len_right == 0:
            return None
        if len_left > 0 and len_right == 0:
            return Control.LEFT
        if len_left == 0 and len_right > 0:
            return Control.RIGHT
        print 'closest lefts then rights'
        print closest_lefts
        print closest_rights 
        if((50 - max(closest_lefts)) > (min(closest_rights) - 50)):
            return Control.RIGHT
        else:
            return Control.LEFT
github ben174 / homecontrol / mainloop.py View on Github external
#!/usr/bin/env python

import RPi.GPIO as GPIO
from record import Recorder
from control import Control
from command import Command
import time
import logging

GPIO_PIN = 3

recorder = Recorder()
control = Control()
logger = None


def main():
    button_press()
    return
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(GPIO_PIN, GPIO.IN)
    while True:
        button_state = GPIO.input(GPIO_PIN)
        #print button_state
        if button_state == 0:
            button_press()


def button_press():
github awmartin / spatialpixel / ui / dropdown.py View on Github external
Arguments:

- controlId - an arbitrary string to uniquely identify the control
- options - a dict or list of options, or a function that returns such a list or dict
- getter - a function that will return the currently selected option
- setter - a function called when a user selects an option, takes one argument
- title - the default displayed title as a string
- size - a tuple of (width, height) in pixels
- position - a tuple of (x, y) in pixels of the upper-left corner of the control
"""

from control import Control
import button

class DropDown(Control):
    def __init__(self, controlId, options, getter, setter, title=None, size=None, position=None):
        self.options = options
        self.getter = getter
        self.setter = setter

        self.state = 'closed'

        super(DropDown, self).__init__(controlId, title=title, size=size, position=position)

        self.optionButtons = []

    def setController(self, controller):
        super(DropDown, self).setController(controller)
        self.buildOptions()

    def buildOptions(self):
github ben174 / homecontrol / remote.py View on Github external
def main():
    print sys.argv
    arg = sys.argv[1]
    command = Command()
    command.room='living'
    command.action='power'
    command.value='on'
    if arg == '1':
    	command.value = 'on'
    elif arg == '2':
    	command.value = 'off'
    control = Control()
    control.execute_command(command)
github awmartin / spatialpixel / ui / button.py View on Github external
from control import Control

class Button(Control):
    def __init__(self, controlId, onClick=None, title=None, size=None, position=None):
        self.onClick = onClick
        super(Button, self).__init__(controlId, title=title, size=size, position=position)

    def draw(self, graphics):
        if not self.visible:
            return
        
        graphics.noStroke()
        if self.mouseHover:
            graphics.fill(0, 100, 150)
            if self.controller.mousePressed:
                graphics.fill(0, 150, 250)
        else:
            graphics.fill(0, 50, 100)
        graphics.rect(self.x, self.y, self.width, self.height)
github amerkay / water-doser / src / main.py View on Github external
log(
            "Started with python version {}".format(sys.version_info),
            message_type="info",
            title="init",
        )

        currpos = device.get_current_position()
        # currpos = {'x': 0, 'y': 0} if currpos is None else currpos
        currpos = (
            {"x": 650, "y": 880} if currpos is None else currpos
        )  # arugula default for debugging
        # currpos = {'x': 680, 'y': 380} if currpos is None else currpos # radish

        # init instances
        water_dose = WaterDose(FARMWARE_NAME, input_store.input)
        control = Control(FARMWARE_NAME)

        # load the plants
        plant_search_radius = input_store.input["plant_search_radius"]
        plants = Plants(
            FARMWARE_NAME,
            config={
                "filter_plant_stage": ["planted", "sprouted"],
                "filter_min_x": int(float(currpos["x"])) - plant_search_radius,
                "filter_max_x": int(float(currpos["x"])) + plant_search_radius,
                "filter_min_y": int(float(currpos["y"])) - plant_search_radius,
                "filter_max_y": int(float(currpos["y"])) + plant_search_radius,
            },
        )
        points_plants = plants.load_points_with_filters()

        # get closest plant to currpos