Esempio n. 1
0
def handler():

	while True:

		while True:
		
			event = geniePi.genieReadObj(geniePi.GENIE_OBJ_WINBUTTON, 1)
			if event == 1:
				break
		
		scan_boards()
Esempio n. 2
0
def recover_data(ip):
	
	while True:
		# Add all the return bottons here.
		event = geniePi.genieReadObj(geniePi.GENIE_OBJ_WINBUTTON, 7)
		
		if event == 1:
			print ("valor de event: %d") % event
		if (event == 1):
			print >>sys.stderr, ("Recovering info to display!")
			time.sleep(0.1)
			geniePi.genieWriteObj(19, 0, 1)
			time.sleep(0.1)
			geniePi.genieWriteStr(0, MESSAGE_ON)
			time.sleep(0.1)
			geniePi.genieWriteStr(1, ip)
			time.sleep(0.1)
			event = 0
Esempio n. 3
0
def opening_serial_communication():

	geniePi.genieSetup(PORT, BAUD_RATE)
	geniePi.genieWriteStr(0, 'Conexao Local')
	geniePi.genieWriteObj(0x0E, 0x00, 0x01)
	#time.sleep(1)
	geniePi.genieWriteStr(1, 'Pronto para operar!')
	
	while True:
		event = geniePi.genieReadObj(geniePi.GENIE_OBJ_WINBUTTON, 1)
		if event == 1:
			break
			
	#time.sleep(0.2)
	geniePi.genieWriteStr(2, 'Procurando Placas...')
	
	for i in range(1,5):
		devices = bus.scan(i)
		geniePi.genieWriteStr(i+2, str(devices))    

	geniePi.genieWriteStr(2, 'Placas encontradas!')
    def run(self):
        # Connect to the display
        if geniePi.genieSetup('/dev/serial0', 115200) < 0:  # Error occurred
            self._logger.error(
                '  Cannot connect to the display - it will be updated')
            self._display_error = True
        else:  # Run the thread
            self._logger.debug('  Connected to the display')

            # Create the reply structure
            reply = geniePi.genieReplyStruct()

            # Start the clock thread
            clock_thread = ClockController(self._kill_event,
                                           self._display_error)
            clock_thread.start()

            # Start the weather display thread
            weather_thread = WeatherDisplay(self._kill_event,
                                            self._display_error)
            weather_thread.start()

            # Start infinite loop listening for messages from the display
            while not self._kill_event.is_set():
                # Handle any data coming from the display
                while geniePi.genieReplyAvail():
                    geniePi.genieGetReply(
                        reply)  # Read next reply for message handling

                    # Handle the message type - only expecting report events
                    if reply.cmd == geniePi.GENIE_REPORT_EVENT:
                        if reply.object == geniePi.GENIE_OBJ_4DBUTTON:  # Button pressed
                            if reply.index == PROGRAM_BTN_ADD:
                                self._update_power_status(reply.data)
                            elif reply.index == OVER_BTN_ADD:
                                # Only allow this to change state if the thermostat power is on
                                thermo_status = geniePi.genieReadObj(
                                    geniePi.GENIE_OBJ_4DBUTTON,
                                    PROGRAM_BTN_ADD)
                                if thermo_status:
                                    self._update_override(
                                        reply.data, self._setpoint)
                                else:  # Revert the override status to its initial state
                                    prev_override_status = BTN_OFF if reply.data else BTN_ON
                                    geniePi.genieWriteObj(
                                        geniePi.GENIE_OBJ_4DBUTTON,
                                        OVER_BTN_ADD, prev_override_status)
                            else:
                                self._logger.error(
                                    '  Unknown button pressed: %i.  No action taken',
                                    reply.index)
                        elif reply.object == geniePi.GENIE_OBJ_TRACKBAR:  # Slider interacted with
                            if reply.index == TRACKBAR_ADD:
                                # Update the internal setpoint register
                                self._setpoint = 15 + reply.data

                                # Update the thermostat controller iff override mode is on
                                override_status = geniePi.genieReadObj(
                                    geniePi.GENIE_OBJ_4DBUTTON, OVER_BTN_ADD)
                                self._logger.debug(
                                    '    Current display override status: %i',
                                    override_status)
                                if override_status:  # The override mode is on
                                    self._update_override(
                                        override_status, self._setpoint)
                            else:
                                self._logger.error(
                                    '  Unknown trackbar changes: %i.  No action taken',
                                    reply.index)
                        else:
                            self._logger.error(
                                '  Unknown object changed: %i.  No action taken',
                                reply.object)
                    else:  # Unknown item
                        self._logger.error(
                            '  Unknown display message type: %i.  No action taken',
                            reply.cmd)

                # Wait for next message
                self._kill_event.wait(0.02)  # Check every 20 milliseconds

            # Cleanup the clock thread
            weather_thread.join()
            clock_thread.join()

        # Indicate the thread is ending
        self._logger.debug('Display thread closing')
Esempio n. 5
0
def read_display(button):

	return geniePi.genieReadObj(geniePi.GENIE_OBJ_WINBUTTON, button)