예제 #1
0
 def toggleLed(self, isTurnedOn):
     if isTurnedOn:
         log("Turning led ON")
         GPIO.output(self.ledGPIO, GPIO.HIGH)
     else:
         log("Turning led OFF")
         GPIO.output(self.ledGPIO, GPIO.LOW)
예제 #2
0
def buttonPressed():
    global isInitiallyMode
    log('Button pressed received from Main')
    if isInitiallyMode:
        isInitiallyMode = False
        player.play(allParts[0])
        button.toggleLed(True)
        return

    isPaused = player.pause()
    button.toggleLed(not isPaused)
예제 #3
0
    def pause(self):
        if self.isPaused:
            pygame.mixer.music.unpause()
            self.isPaused = False
            log("UNPause")

            return self.isPaused
        else:
            pygame.mixer.music.pause()
            self.isPaused = True
            log("Pause")

            return self.isPaused
예제 #4
0
def rewButtonPressed():
    global currentPartPlaying

    player.pause()

    if player.getPosition() > 60:
        log("Cofam do poczatku modulu")
        player.play(allParts[currentPartPlaying])
        button.toggleLed(True)
    else:
        log("Laduje poprzedni modul")
        currentPartPlaying -= 1
        player.play(allParts[currentPartPlaying])
        button.toggleLed(True)
예제 #5
0
 def button_callback(self, channel):
     log('Some button pressed')
     self.callbackButtonPressed()
예제 #6
0
 def rewind(self):
     pygame.mixer.music.rewind()
     log('rewind?')
예제 #7
0
    def getPosition(self):
        position = round(pygame.mixer.music.get_pos() / 1000)

        log("Get position " + str(position) + "sec")
        return round(position)
예제 #8
0
 def play(self, fileToPlay):
     pygame.mixer.music.set_endevent(self.bookPartEndEvent)
     pygame.mixer.music.load(THIS_FOLDER + "/../book/" + fileToPlay)
     pygame.mixer.music.play()
     self.isPaused = False
     log("Playing next part: " + fileToPlay)
예제 #9
0
def loadNextPart():
    global currentPartPlaying
    print(currentPartPlaying)
    log('End of part: ' + str(currentPartPlaying))
    currentPartPlaying += 1
    player.play(allParts[currentPartPlaying])
예제 #10
0
import pygame
from src.Player import Player
from src.Logger import loggerInit, log, error
from src.FilesManager import getAllFileNames
from src.Button import Button

BOOK_PART_END = pygame.USEREVENT + 1

loggerInit()
player = Player(BOOK_PART_END)
log("--- APP STARTED ---")

allParts = getAllFileNames()
log('Loaded parts' + ', '.join(allParts))
currentPartPlaying = 0
isInitiallyMode = True

if len(allParts) == 0:
    error("There is no book to play!")


def buttonPressed():
    global isInitiallyMode
    log('Button pressed received from Main')
    if isInitiallyMode:
        isInitiallyMode = False
        player.play(allParts[0])
        button.toggleLed(True)
        return

    isPaused = player.pause()