Ejemplo n.º 1
0
class Battery:
    def __init__(self, client, display):
        self.minVoltage = PowerSupply().min_voltage
        self.maxVoltage = PowerSupply().max_voltage
        self.medVoltage = self.maxVoltage * 0.5
        self.exitVoltage = self.minVoltage + (self.minVoltage * 0.05)

        self.action = Actions()

        self.client = client
        self.display = display
        print("Starting battery thread")

        # Execute battery thread
        batteryThread = Thread(target=self.chargeStatus, args=())
        batteryThread.start()

    # Get current user's voltage
    def getCurrentVoltage(self):
        return PowerSupply().measured_voltage * 10

    # Check if Ev3 has to be charged
    def chargeStatus(self):
        while True:
            if self.getCurrentVoltage() <= self.exitVoltage:
                # Exit system
                self.action.exit(self.client, self.display)
            else:
                # Sleep for 1 min and 30 sec
                time.sleep(90)
Ejemplo n.º 2
0
class Button:
    def __init__(self, speed):
        self.button = TouchSensor()
        self.action = Actions(speed)

        # Get current time HH:MM:SS
        now = datetime.now()
        time = now.strftime("%H:%M:%S")

        print(str(time) + "\tExecuting Touch Sensor Thread\n")

        # Execute button thread
        buttonThread = Thread(target=self.isPressed, args=())
        buttonThread.start()

    # Check if Ev3 button was pressed and program has to terminate
    def isPressed(self):
        while True:
            if self.button.is_pressed == True:
                # Exit system
                self.action.exit()
Ejemplo n.º 3
0
class Battery:
    def __init__(self, speed):
        self.minVoltage = PowerSupply().min_voltage
        self.maxVoltage = PowerSupply().max_voltage
        self.medVoltage = self.maxVoltage * 0.5
        self.exitVoltage = self.minVoltage + (self.minVoltage * 0.05)

        self.action = Actions(speed)

        # Get current time HH:MM:SS
        now = datetime.now()
        time = now.strftime("%H:%M:%S")

        print(str(time) + "\tExecuting Battery Thread\n")

        # Execute battery thread
        batteryThread = Thread(target=self.chargeStatus, args=())
        batteryThread.start()

    # Get current user's voltage
    def getCurrentVoltage(self):
        return PowerSupply().measured_voltage * 10

    # Check if Ev3 has to be charged
    def chargeStatus(self):
        while True:
            if self.getCurrentVoltage() <= self.exitVoltage:
                # Exit system
                self.action.exit()
            else:
                # Sleep for 1 min and 30 sec
                time.sleep(90)

    # Get the current percentage of the battery
    def getPercentage(self):
        percent = (self.getCurrentVoltage() / self.maxVoltage) * 100
        return str(round(percent)) + "%"