Ejemplo n.º 1
0
    def remainingTime(self):

        oAmbiance = ambiance.ambiance()
        oAmbiance.logger = self.logger
        remainingtime = oAmbiance.getRemainingSeconds()

        if remainingtime > 0:
            h = divmod(remainingtime, 3600)  # hours
            m = divmod(h[1], 60)  # minutes

            print(str(remainingtime) + ' - ' + str(h) + ':' + str(m))

            hours = math.trunc(h[0])
            minutes = math.trunc(m[0])

        else:
            hours = 0
            minutes = 0

        font = ImageFont.truetype(
            '%s/../fonts/digital-7mono.ttf' % os.path.dirname(__file__), 55)

        print(str(hours) + ':' + str(minutes))

        self.draw.text((0, 5), '{:0>2}'.format(hours), font=font, fill=1)
        self.draw.text((65, 5), '{:0>2}'.format(minutes), font=font, fill=1)
        self.draw.text((46, 5), ':', font=font, fill=1)
Ejemplo n.º 2
0
    def setVolume(self, screen):
        screen.cls()
        screen.setText(0, 10, "Volume", 1)

        oAmbiance = ambiance.ambiance()
        iVolume = oAmbiance.getVolume()

        volume = ((iVolume * 100.0) / 100) / 100
        pygame.mixer.init()
        oTestSound = pygame.mixer.Sound('%s/../sounds/volume.wav' %
                                        os.path.dirname(__file__))
        oTestSound.set_volume(volume)
        oTestSound.play(1)

        left = 0
        top = 22
        font = ImageFont.truetype(
            '%s/../fonts/FreeSans.ttf' % os.path.dirname(__file__), 45)
        screen.draw.rectangle(
            (left, top, screen.device.width - 1, screen.device.height - 1),
            outline="black",
            fill="black")
        screen.draw.text((left, top), str(iVolume), font=font, fill="white")

        screen.display()

        self.genericOptionMax = 100
        self.genericOptionMin = 0
        self.genericPos = iVolume
        self.oldPos = iVolume

        while (True):

            if self.oldPos != self.genericPos:
                screen.draw.rectangle((left, top, screen.device.width - 1,
                                       screen.device.height - 1),
                                      outline="black",
                                      fill="black")
                screen.draw.text((left, top),
                                 str(self.genericPos),
                                 font=font,
                                 fill="white")
                self.oldPos = self.genericPos
                screen.display()
                volume = ((self.genericPos * 100.0) / 100) / 100
                oTestSound.set_volume(volume)

            if self.swithRelease == 1:
                self.swithRelease = 0
                oTestSound.stop()
                oAmbiance.setVolume(self.genericPos)
                break

            time.sleep(0.10)
Ejemplo n.º 3
0
    def setSnooze(self, screen):
        screen.cls()
        screen.setText(0, 10, "Temps", 1)

        oAmbiance = ambiance.ambiance()
        iSnooze = oAmbiance.getSnooze()

        left = 0
        top = 22
        font = ImageFont.truetype(
            '%s/../fonts/FreeSans.ttf' % os.path.dirname(__file__), 30)
        screen.draw.rectangle(
            (left, top, screen.device.width - 1, screen.device.height - 1),
            outline="black",
            fill="black")
        screen.draw.text((left, top),
                         str(iSnooze) + ' min',
                         font=font,
                         fill="white")

        screen.display()

        self.genericOptionMax = 100
        self.genericOptionMin = 0
        self.genericOptionStep = 15
        self.genericPos = iSnooze
        self.oldPos = iSnooze

        while (True):

            if self.oldPos != self.genericPos:
                screen.draw.rectangle((left, top, screen.device.width - 1,
                                       screen.device.height - 1),
                                      outline="black",
                                      fill="black")
                screen.draw.text((left, top),
                                 str(self.genericPos) + ' min',
                                 font=font,
                                 fill="white")
                self.oldPos = self.genericPos
                screen.display()

            if self.swithRelease == 1:
                self.swithRelease = 0
                oAmbiance.setSnooze(self.genericPos)
                oAmbiance.start()
                break

            time.sleep(0.10)
Ejemplo n.º 4
0
    def setLight(self, screen):
        screen.cls()
        screen.setText(0, 10, "Eclairs", 1)
        screen.display()

        oAmbiance = ambiance.ambiance()
        iLight = oAmbiance.getLight()

        left = 40
        top = 22
        logoThunder = Image.open('%s/../icons/lightbulb-%s.png' %
                                 (os.path.dirname(__file__), str(iLight)))
        screen.draw.rectangle((left, top, left + 35, top + 35),
                              outline="white",
                              fill="white")
        screen.draw.bitmap((left, top), logoThunder, fill="black")
        screen.display()

        self.genericOptionMax = 1
        self.genericOptionMin = 0
        self.genericPos = iLight
        self.oldPos = iLight

        while (True):
            if self.oldPos != self.genericPos:
                logoThunder = Image.open(
                    '%s/../icons/lightbulb-%s.png' %
                    (os.path.dirname(__file__), str(self.genericPos)))
                screen.draw.rectangle((left, top, left + 35, top + 35),
                                      outline="white",
                                      fill="white")
                screen.draw.bitmap((left, top), logoThunder, fill="black")
                self.oldPos = self.genericPos
                screen.display()

            if self.swithRelease == 1:
                self.swithRelease = 0
                oAmbiance.setLight(self.genericPos)
                break

            time.sleep(0.10)
Ejemplo n.º 5
0
    def setRain(self, screen):
        screen.cls()
        screen.setText(0, 10, "Pluie", 1)

        oAmbiance = ambiance.ambiance()
        iRain = oAmbiance.getRain()

        left = 40
        top = 22
        logoRain = Image.open('%s/../icons/rain-%s.png' %
                              (os.path.dirname(__file__), str(iRain)))
        screen.draw.rectangle((left, top, left + 35, top + 35),
                              outline="white",
                              fill="white")
        screen.draw.bitmap((left, top), logoRain, fill="black")
        screen.display()

        self.genericOptionMax = 3
        self.genericOptionMin = 0
        self.genericPos = iRain
        self.oldPos = iRain

        while (True):
            if self.oldPos != self.genericPos:
                logoRain = Image.open(
                    '%s/../icons/rain-%s.png' %
                    (os.path.dirname(__file__), str(self.genericPos)))
                screen.draw.rectangle((left, top, left + 35, top + 35),
                                      outline="white",
                                      fill="white")
                screen.draw.bitmap((left, top), logoRain, fill="black")
                self.oldPos = self.genericPos
                screen.display()

            if self.swithRelease == 1:
                self.swithRelease = 0
                oAmbiance.setRain(self.genericPos)
                break

            time.sleep(0.10)
Ejemplo n.º 6
0
    def pulse(self):

        # pulse indicator
        step = 4

        #    if self.pulseStatus == 1:
        #      self.pulsePos = self.pulsePos + step
        #    else:
        #      self.pulsePos = self.pulsePos - step
        #
        #    if self.pulsePos < 0:
        #      self.pulsePos = self.pulsePos + (step * 2)
        #      self.pulseStatus = 1

        #    if self.pulsePos > self.device.width:
        #      self.pulsePos = self.pulsePos - (step * 2)
        #      self.pulseStatus = 0

        self.pulsePos = self.pulsePos + 1

        self.draw.rectangle((0, self.device.height - 1, self.device.width,
                             self.device.height - 1),
                            outline="black",
                            fill="black")
        if self.pulsePos > 2:
            self.pulsePos = 0
            self.draw.rectangle(
                (1, self.device.height - 1, 1, self.device.height - 1),
                outline="white",
                fill="white")

        oAmbiance = ambiance.ambiance()
        oAmbiance.logger = self.logger

        # remaining indicator
        remainingtimeSeconds = oAmbiance.getRemainingSeconds()
        if remainingtimeSeconds > 0:
            self.remainingPos = (
                self.device.width /
                (oAmbiance.getSnooze() * 60)) * remainingtimeSeconds
            self.draw.rectangle((0, self.device.height - 2, self.device.width,
                                 self.device.height - 2),
                                outline="black",
                                fill="black")
            self.draw.rectangle((self.remainingPos, self.device.height - 2,
                                 self.remainingPos, self.device.height - 2),
                                outline="white",
                                fill="white")
        else:
            self.draw.rectangle((0, self.device.height - 2, self.device.width,
                                 self.device.height - 2),
                                outline="black",
                                fill="black")

        # storm indicator
        stormDelta = oAmbiance.getEventDelta()
        stormPos = oAmbiance.getEventPos()

        if stormPos > 0 and stormDelta > 0 and remainingtimeSeconds > 0:
            stormPos = (self.device.width / stormDelta) * stormPos
            self.draw.rectangle((0, self.device.height - 3, self.device.width,
                                 self.device.height - 3),
                                outline="black",
                                fill="black")
            self.draw.rectangle((stormPos, self.device.height - 3, stormPos,
                                 self.device.height - 3),
                                outline="white",
                                fill="white")
        else:
            self.draw.rectangle((0, self.device.height - 3, self.device.width,
                                 self.device.height - 3),
                                outline="black",
                                fill="black")

        self.display()
Ejemplo n.º 7
0
 def setStop(self, screen):
     screen.cls()
     oAmbiance = ambiance.ambiance()
     oAmbiance.stop()
     time.sleep(0.10)
Ejemplo n.º 8
0
    logLevel = getattr(logging, 'ERROR', None)
    if args.log:
        logLevel = getattr(logging, args.log.upper(), None)

    if os.path.isfile(constant.AMBIANCE_CONF):
        confFile = config.config()
        confFile.read(constant.AMBIANCE_CONF)

        if confFile.has_option('general', 'debug'):
            logLevel = confFile.get('general', 'debug')
            logLevel = getattr(logging, logLevel.upper(), None)

    logging.basicConfig(filename='/var/log/storm-cloud-player.log',
                        level=logLevel)

    oAmbiance = ambiance.ambiance()
    oAmbiance.logger = logging

    if args.verbose:
        oAmbiance.verbose = True

    oAmbianceConf = oAmbiance.getAmbiance()

    if args.start:
        oAmbiance.start()

    isRunning = False

    oThunderlight = thunderlight.thunderlight()
    oThunderlight.logger = logging
    if args.verbose: