class PayloadDriver(object):
    def __init__(self):
        self.display = Display()
        self.add_vars()
        self.display.unlock()

        self.max_altitude = 0
        self.__first_time = time.time()

        self.run()

    def add_vars(self):
        self.display.add_variable("Altitude (ft)", "nan / 0", "left")
        self.display.add_variable("Lat", "nan", "left")
        self.display.add_variable("Long", "nan", "left")
        self.display.add_variable("uT", "nan", "left")

        self.display.add_variable("vel (ft/s)", "nan", "right")
        self.display.add_variable("accel (ft/s)", "nan", "right")
        self.display.add_slider("sig lock", 0, 0, 7, "right")

        self.display.update_slider("sig lock", 3, "right")

    def run(self):
        i = 0
        last_time = time.time()
        while 1:
            self.display.update_var("Altitude (ft)",
                                    str(i) + " / " + str(self.max_alt(i)),
                                    "left")
            self.display.update_var("Lat",
                                    str(random.randint(1, 1000) / 1000.0 * i),
                                    "left")
            self.display.update_var("Long",
                                    str(random.randint(1, 1000) / 1000.0 * i),
                                    "left")
            self.display.update_var("uT", self.up_time(), "left")
            self.display.update_var("vel (ft/s)", str(i * 2.5))
            self.display.update_var("accel (ft/s)", str(i * 1.5))
            i += 1
            self.display.update()

    def max_alt(self, newmax):
        if newmax > self.max_altitude:
            self.max_altitude = newmax
        return self.max_altitude

    def up_time(self):
        self.uptime = time.time() - self.__first_time
        return str(int(self.uptime / 360)) + ":" + str(int(
            self.uptime / 60)) + ":" + str(int(self.uptime % 60))

    def __check_lock(self):
        self.display.unlock()
Beispiel #2
0
 def draw(self):
     Disp.add_label(self._name)
     Disp.add_slider('R', 12, 0, 255, Config.red(), 3, self._changed_r,
                     self._focused)
     Disp.add_slider('G', 12, 0, 255, Config.green(), 3, self._changed_g,
                     self._focused)
     Disp.add_slider('B', 12, 0, 255, Config.blue(), 3, self._changed_b,
                     self._focused)
     Disp.add_slider('Brt', 12, 0, 100, Config.brightness(), 2,
                     self._changed_brt, self._focused)
     Disp.add_slider('Wdt', 12, 0, LED_COUNT, Config.width(), 2,
                     self._changed_wdt, self._focused)
     Disp.add_slider('Off', 12, -LED_COUNT // 2, LED_COUNT // 2,
                     Config.offset(), 1, self._changed_off, self._focused)
     super(ManualRGB, self).draw()