Exemplo n.º 1
0
def main(arguments):
    # init async and pygame
    loop = asyncio.get_event_loop()
    ui.init("hysbakstryd", (900, 700))

    # show loading scene
    ui.scene.push(LoadingScene())
    map_scene = MapScene()
    ui.scene.insert(0, map_scene)

    # from bomber.network import ClientStub
    # loop.call_soon(map_scene.map.player_register, ClientStub(None, None, map_scene.map))
    client = Observer(**arguments)
    asyncio. async (client.connect(**arguments))
    # show game ui
    ui.scene.pop()
    try:
        loop.run_until_complete(main_loop(loop))
    finally:
        loop.close()
Exemplo n.º 2
0
def main(arguments):
    # init async and pygame
    ui.init("hysbakstryd", (900, 700))

    # show loading scene
    ui.scene.push(LoadingScene())
    map_scene = MapScene()
    ui.scene.insert(0, map_scene)

    # from bomber.network import ClientStub
    # loop.call_soon(map_scene.map.player_register, ClientStub(None, None, map_scene.map))
    client = Observer(**arguments)

    # show game ui
    ui.scene.pop()
    try:
        main_loop_g = gevent.spawn(main_loop)
        client_g = gevent.spawn(client.connect, **arguments)
        gevent.joinall([main_loop_g, client_g])
    finally:
        logging.info("... BYE ...")
Exemplo n.º 3
0
 def __init__(self, socket_address, config):
     ui.init('pygameui - Kitchen Sink', config=config)
     ui.scene.push(RadioScene(socket_address))
     ui.run()
Exemplo n.º 4
0
        elif self.refresh_button == btn:
            subprocess.call("mpc stop ", shell=True)
            subprocess.call("mpc play ", shell=True)
        elif self.mute_button == btn:
            subprocess.call("mpc volume 0 ", shell=True)
        elif self.vol_up_button == btn:
            subprocess.call("mpc volume +10 ", shell=True)
        elif self.vol_down_button == btn:
            subprocess.call("mpc volume -10 ", shell=True)

    def update(self, dt):
        self.refresh_radio_info()
        ui.Scene.update(self, dt)
         
 
ui.init('BlueArrow UI', (320, 240))
pygame.mouse.set_visible(DEV_MODE)
 
pitft = MainScreen()

def signal_handler(signal, frame):
    print 'You pressed Ctrl+C!'
    sys.exit(0)
         
signal.signal(signal.SIGINT, signal_handler)
 
ui.scene.push(pitft)
ui.run()


Exemplo n.º 5
0
print hex(dev.idVendor)+','+hex(dev.idProduct)

class PiTft(ui.Scene):
    def __init__(self):
        ui.Scene.__init__(self)

        self.add_child(ui.Label(ui.Rect(0,0,320,50),'Raspberry Pi Sound Meter'))

        self.progress_view = ui.ProgressView(ui.Rect(20, 50, 280, 120))
        self.add_child(self.progress_view)

        self.db_value = ui.Label(ui.Rect(110, 170, 100, 30), '00.00 dB')
        self.add_child(self.db_value)

        self.progress = 0
        
    def update(self, dt):
        ui.Scene.update(self, dt)
        ret = dev.ctrl_transfer(0xC0,4,0,0,200)
        dB = (ret[0]+((ret[1]&3)*256))*0.1+30
        self.db_value.text = '%2.2f dB' % dB
        self.progress=(dB/100.0)
        self.progress_view.progress = self.progress
            
if __name__ == '__main__':
    ui.init('SoundMeter UI', (320, 240))
    ui.scene.push(PiTft())
    pygame.mouse.set_visible(False)
    ui.run()
Exemplo n.º 6
0
    if time.time() - getWuData.startForTime > forecastDataTimeout:
        getWuData.startForTime = time.time()
        print 'get forecast data'


getWuData.startCurTime = 0  #time.time()
getWuData.startForTime = time.time()

curDataDict = {
    'bigLabel': 'temp_f',
    'label1': 'feelslike_f',
    'label2': 'relative_humidity',
    'label3': 'wind_mph'
}

# start up gui
ui.init('pygameui - Weather Station', (320, 240))
pygame.mouse.set_visible(False)

mainScene = MainWthrScene()
settingsScene = SettingsScene()
wthrReader = GetWUdata(mainScene)
# threading.Thread(target=wthrReader).start()

signal.signal(signal.SIGINT, signal_handler)

ui.scene.push(mainScene)

ui.run(getWuData, mainScene, 10, 10)
Exemplo n.º 7
0
        logger.info(btn.text)

        if btn.text == 'DOUBLE':
            #print("double click")
            if current_effect in [5, 25, 35]:
                current_effect = effects[3]
            elif current_effect in [5, 25, 36]:
                current_effect = effects[2]
            drv.drv_effect_run(current_effect)
        elif btn.text == 'SINGLE':
            #print("single click")
            if current_effect in [5, 35, 36]:
                current_effect = effects[1]
            elif current_effect in [25, 35, 36]:
                current_effect = effects[0]
            drv.drv_effect_run(current_effect)
        elif btn.text == '<--':
            #print("BACK")
            drv.drv_effect_run(effects[0])
            pygame.quit()
        elif btn.text == 'PLAY':
            #print("PLAY")
            drv.drv_effect_run(current_effect)


## - UI / RUN
ui.init('PMD HFEK2 Touchscreen Demo', (320, 240))
pygame.mouse.set_visible(False)
ui.scene.push(PiTft())
ui.run()
Exemplo n.º 8
0
#             self.task_button.enabled = False
#             self.progress_view.hidden = False
#         self.progress_view.progress = 0
#         self.running_task = True

    def update(self, dt):
        ui.Scene.update(self, dt)
        self.volts_value.text = '%.2f' % self.progress
        self.progress_view.progress = self.progress
        self.progress += 0.01
        if self.progress > 1.0:
            self.progress = 0
#         if self.running_task:
#             progress = min(1.0, self.progress_view.progress + 0.01)
#             self.progress_view.progress = progress
#             self.running_task = (self.progress_view.progress < 1.0)
#             self.task_button.enabled = not self.running_task
#             if self.task_button.enabled:
#                 ui.show_alert("I'M FINISHED!", title='Milkshake')
#                 self.progress_view.progress = 0
#                 self.progress_view.hidden = True


if __name__ == '__main__':
    ui.init('Raspberry Pi UI', (800, 480))
    #pygame.mouse.set_visible(False)
    ui.scene.push(PiTft())
    ui.run()


Exemplo n.º 9
0
            'This is a notification\nwith a linebreak in it',
            'This notification is rather long and should ' +
            'automatically word wrap to multiple lines'
        ]
        msg = random.choice(msgs)
        ui.show_notification(msg)

    def run_fake_task(self, btn, mbtn):
        if not self.running_task:
            self.task_button.enabled = False
            self.progress_view.hidden = False
        self.progress_view.progress = 0
        self.running_task = True

    def update(self, dt):
        ui.Scene.update(self, dt)
        if self.running_task:
            progress = min(1.0, self.progress_view.progress + 0.01)
            self.progress_view.progress = progress
            self.running_task = (self.progress_view.progress < 1.0)
            self.task_button.enabled = not self.running_task
            if self.task_button.enabled:
                ui.show_alert("I'M FINISHED!", title='Milkshake')
                self.progress_view.progress = 0
                self.progress_view.hidden = True


if __name__ == '__main__':
    ui.init('pygameui - Kitchen Sink', (320, 240))
    ui.scene.push(KitchenSinkScene())
    ui.run()
Exemplo n.º 10
0
MARGIN = 20

img = pygame.image.load("images/m3_logo.png")

class PiTft(ui.Scene):
	def __init__(self):
		ui.Scene.__init__(self)
		
		self.on17_button = ui.ImageButton(None, img)
		#self.on17_button = ui.Button(ui.Rect(MARGIN, MARGIN, 130, 60), '17 on')
		self.on17_button.on_clicked.connect(self.gpi_button)
		self.add_child(self.on17_button)

	def gpi_button(self, frame, image):
		print "M3 Power!"

	def update(self, dt):
		ui.Scene.update(self, dt)

def signal_handler(signal, frame):
	sys.exit()
		
ui.init('Raspberry Pi UI', (480, 320))
#pygame.mouse.set_visible(False)

pitft = PiTft()

signal.signal(signal.SIGINT, signal_handler)

ui.scene.push(pitft)
ui.run()
            'This notification is rather long and should ' +
            'automatically word wrap to multiple lines'
        ]
        msg = random.choice(msgs)
        ui.show_notification(msg)

    def run_fake_task(self, btn, mbtn):
        if not self.running_task:
            self.task_button.enabled = False
            self.progress_view.hidden = False
        self.progress_view.progress = 0
        self.running_task = True

    def update(self, dt):
        ui.Scene.update(self, dt)
        if self.running_task:
            progress = min(1.0, self.progress_view.progress + 0.01)
            self.progress_view.progress = progress
            self.running_task = (self.progress_view.progress < 1.0)
            self.task_button.enabled = not self.running_task
            if self.task_button.enabled:
                ui.show_alert("I'M FINISHED!", title='Milkshake')
                self.progress_view.progress = 0
                self.progress_view.hidden = True


if __name__ == '__main__':
    ui.init('pygameui - Kitchen Sink', (480, 320))
    ui.scene.push(KitchenSinkScene())
    ui.run()
Exemplo n.º 12
0
                self.chan = 0

    def set_progress(self, percent):
        self.progress_view.progress = percent

    def set_volts_label(self, volts):
        self.volts_value.text = '%.2f V' % volts

    def set_chan_label(self, chan_in):
        self.chan_value.text = 'Channel: %d' % chan_in

    def update(self, dt):
        ui.Scene.update(self, dt)


ui.init('Raspberry Pi UI', (320, 240), True)

pitft = PiTft()

# Start the thread running the callable
potreader = PotReader(pitft)
threading.Thread(target=potreader).start()


def signal_handler(signal, frame):
    print('You pressed Ctrl+C!')
    potreader.terminate()
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)
Exemplo n.º 13
0
               TOP = TOP+320
               LEFT = 40
             relays[switch['name']] = Relay(switch['name'], switch['id'], switch['state'])
             self.buttonas = ui.Button(ui.Rect(TOP, LEFT, 300, 30), switch['name'])
             if switch['state'] == 0:
                logger.info(switch['name']+ ' yra ijungtas')
                self.buttonas.background_color = (64, 64, 62) # FIXME, does not change the color as necesarry
             self.buttonas.on_clicked.connect(self.gpi_button)
             self.add_child(self.buttonas)
 
    def gpi_button(self, btn, mbtn):
#        logger.info('Color: '+str(btn.background_color))
#        logger.info('We got presses on name: '+btn.text)
#        logger.info('We got presses on port: '+relay_port(btn.text))
        TurnOver(btn.text,relay_port(btn.text),btn)
 
ui.init('Raspberry Pi UI', (480, 320))
pygame.mouse.set_visible(False)
pitft = PiTft()

# Start the thread running the callable
 
def signal_handler(signal, frame):
    print 'You pressed Ctrl+C!'
    sys.exit(0)

signal.signal(signal.SIGINT, signal_handler)

ui.scene.push(pitft)
ui.run()
Exemplo n.º 14
0
           'This notification is rather long and should ' +
           'automatically word wrap to multiple lines'
        ]
        msg = random.choice(msgs)
        ui.show_notification(msg)

    def run_fake_task(self, btn, mbtn):
        if not self.running_task:
            self.task_button.enabled = False
            self.progress_view.hidden = False
        self.progress_view.progress = 0
        self.running_task = True

    def update(self, dt):
        ui.Scene.update(self, dt)
        if self.running_task:
            progress = min(1.0, self.progress_view.progress + 0.01)
            self.progress_view.progress = progress
            self.running_task = (self.progress_view.progress < 1.0)
            self.task_button.enabled = not self.running_task
            if self.task_button.enabled:
                ui.show_alert("I'M FINISHED!", title='Milkshake')
                self.progress_view.progress = 0
                self.progress_view.hidden = True


if __name__ == '__main__':
    ui.init('pygameui - Kitchen Sink')
    ui.scene.push(KitchenSinkScene())
    ui.run()
Exemplo n.º 15
0
        self.add_child(self.on17_button)
 
        self.on4_button = ui.Button(ui.Rect(170, MARGIN, 130, 90), '4 on')
        self.on4_button.on_clicked.connect(self.gpi_button)
        self.add_child(self.on4_button)
 
        self.off17_button = ui.Button(ui.Rect(MARGIN, 130, 130, 90), '17 off')
        self.off17_button.on_clicked.connect(self.gpi_button)
        self.add_child(self.off17_button)
 
        self.off4_button = ui.Button(ui.Rect(170, 130, 130, 90), '4 off')
        self.off4_button.on_clicked.connect(self.gpi_button)
        self.add_child(self.off4_button)
 
    def gpi_button(self, btn, mbtn):
        logger.info(btn.text)
         
        if btn.text == '17 on':
            GPIO.output(17, False)
        elif btn.text == '4 on':
            GPIO.output(4, False)
        elif btn.text == '17 off':
            GPIO.output(17, True)
        elif btn.text == '4 off':
            GPIO.output(4, True)
 
ui.init('Raspberry Pi UI', (320, 240))
pygame.mouse.set_visible(False)
ui.scene.push(PiTft())
ui.run()
Exemplo n.º 16
0
            "2")
        self.add_child(self.enabled_box1)
        self.enabled_box1.on_checked.connect(self.controller.toggle_light1)
        self.enabled_box1.on_unchecked.connect(self.controller.toggle_light1)
        self.enabled_box1.stylize()

        self.enabled_box2 = ui.Checkbox(
            ui.Rect(self.enabled_box1.frame.right + 15, 3 * MARGIN, 20, 40),
            "3")
        self.add_child(self.enabled_box2)
        self.enabled_box2.on_checked.connect(self.controller.toggle_light2)
        self.enabled_box2.on_unchecked.connect(self.controller.toggle_light2)
        self.enabled_box2.stylize()

        self.checkboxes = [
            self.enabled_box, self.enabled_box1, self.enabled_box2
        ]
        self.controller.initialize_checkboxes()


if __name__ == "__main__":
    sleep(5)
    os.putenv('SDL_FBDEV', '/dev/fb1')
    os.putenv('SDL_MOUSEDRV', 'TSLIB')
    os.putenv('SDL_MOUSEDEV', '/dev/input/touchscreen')

    ui.init("Lightswitch", (320, 240))
    pygame.mouse.set_visible(False)
    ui.scene.push(SwitchUI())
    ui.run()
Exemplo n.º 17
0
        item.state = 'normal'

    def update_people(self):
        r = requests.get("https://meepo-api.herokuapp.com/people")
        items = []
        for person in r.json()['people']:
            items.append(person['name'])

        label_height = ui.theme.current.label_height
        labels = [
            ui.Label(ui.Rect(0, 0, LIST_WIDTH, label_height),
                     item,
                     halign=ui.LEFT) for item in items
        ]
        self.list_view.items = labels

    def update(self, dt):
        ui.Scene.update(self, dt)
        now = datetime.now()
        timediff = now - self.lastUpdate
        if timediff.total_seconds() > 10:
            self.update_people()
            self.lastUpdate = now


if __name__ == '__main__':
    ui.init('pygameui - Rothschild People', (320, 240))
    peopleScene = PeopleScene()
    ui.scene.push(peopleScene)
    ui.run()
Exemplo n.º 18
0
        self.on4_button = ui.Button(ui.Rect(170, MARGIN, 130, 90), '4 on')
        self.on4_button.on_clicked.connect(self.gpi_button)
        self.add_child(self.on4_button)

        self.off17_button = ui.Button(ui.Rect(MARGIN, 130, 130, 90), '17 off')
        self.off17_button.on_clicked.connect(self.gpi_button)
        self.add_child(self.off17_button)

        self.off4_button = ui.Button(ui.Rect(170, 130, 130, 90), '4 off')
        self.off4_button.on_clicked.connect(self.gpi_button)
        self.add_child(self.off4_button)

    def gpi_button(self, btn, mbtn):
        logger.info(btn.text)

        if btn.text == '17 on':
            GPIO.output(17, False)
        elif btn.text == '4 on':
            GPIO.output(4, False)
        elif btn.text == '17 off':
            GPIO.output(17, True)
        elif btn.text == '4 off':
            GPIO.output(4, True)


ui.init('Raspberry Pi UI', (320, 240))
pygame.mouse.set_visible(False)
ui.scene.push(PiTft())
ui.run()
Exemplo n.º 19
0
        """

        if 0 <= dc < 1024:
            logging.debug("Setting LCD Brightnes to {}".format(dc))
            wiringpi.pwmWrite(
                18,
                dc)  # duty cycle between 0 and 1024. 0 = off, 1023 = fully on
        else:
            logging.error("Invalid duty cycle for LCD Brightnes {}".format(dc))


if __name__ == '__main__':

    player = Player()  # create new player object (Lockable MPDClient)

    ui.init('Raspberry Pi UI', (320, 240))  # init PiTFT UI and hide mouse icon
    pygame.mouse.set_visible(False)

    emscene = EmmaMusicScene(
        player)  # create new UI Scene, and pass reference to player object

    # start RFID Reader Thread
    rfidreader = RFIDReader(
        emscene, player
    )  # holds reference to UI for any updates and player to see directly launch a title TODO: can probably be simplified
    threading.Thread(target=rfidreader).start()

    ui.scene.push(emscene)  # put UI on the screen
    ui.run()  # run main loop

    # shutdown procedure