示例#1
0
def init():
    """Start the Energenie system running"""

    global registry, fsk_router, ook_router

    radio.init()
    OpenThings.init(Devices.CRYPT_PID)

    fsk_router = Registry.Router("fsk")

    #OOK receive not yet written
    #It will be used to be able to learn codes from Energenie legacy hand remotes
    ##ook_router = Registry.Router("ook")

    registry = Registry.DeviceRegistry()
    registry.set_fsk_router(fsk_router)
    ##registry.set_ook_router(ook_router

    path = os.path.join(sys.path[0], registry.DEFAULT_FILENAME)
    if os.path.isfile(path):
        registry.load_from(path)
        print("loaded registry from file")
        registry.list()
        fsk_router.list()

    # Default discovery mode, unless changed by app
    ##discovery_none()
    ##discovery_auto()
    ##discovery_ask(ask)
    discovery_autojoin()
示例#2
0
文件: __init__.py 项目: maxf/home
def init():
    """Start the Energenie system running"""

    global registry, fsk_router, ook_router

    radio.init()
    OpenThings.init(Devices.CRYPT_PID)

    fsk_router = Registry.Router("fsk")

    #OOK receive not yet written
    #It will be used to be able to learn codes from Energenie legacy hand remotes
    ##ook_router = Registry.Router("ook")

    registry = Registry.DeviceRegistry()
    registry.set_fsk_router(fsk_router)
    ##registry.set_ook_router(ook_router

    if os.path.isfile(registry.DEFAULT_FILENAME):
        registry.load_from(registry.DEFAULT_FILENAME)
        print("loaded registry from file")
        registry.list()
        fsk_router.list()

    # Default discovery mode, unless changed by app
    ##discovery_none()
    ##discovery_auto()
    ##discovery_ask(ask)
    discovery_autojoin()
示例#3
0
def main():

	#Inicialización de los módulos
	radio.init()
	sensor.init()
#	gps.init()

	while True:
		#Graba los datos a la microSD
		sensor.writeLogLine()
#		gps.writeLogLine()

		#Envía los datos por radio
		packet = bytes(sensor.line(), "utf-8")

			#Paquetiza la información para que no supere el tamaño de 60
		while len(packet) > 60:
			radio.rfm69.send(packet[:60])
			packet = packet[60:]

		if len(packet) > 0:
			radio.rfm69.send(packet)

		time.sleep(0.5)

	radio.close()
	sensor.close()
示例#4
0
def main():
    radio.init()
    sensor.init()

    while True:
        sensor.writeLogLine()
        packet = bytes(sensor.line(), "utf-8")
        radio.rfm69.send(packet)
        time.sleep(0.5)

    radio.close()
    sensor.close()
示例#5
0
def main():
    radio.init()
    i = 0

    sensorLog = open('dataTARS.txt', 'at')
    gpsLog = open('gpsData.txt', 'a')

    while True:
        packet = radio.rfm69.receive(timeout=2)

        if packet is None:
            print("No packet")
            radio.display.fill(0)
            radio.display.text('No packet', 25, 15, 1)
            radio.display.show()
        else:
            dataLine = packet.decode()

            fields = dataLine.split(' ')

            for x in fields:
                if x[:5] == '16204':
                    gpsLog.flush()
                    sensorLog.write(x + " ")
                    i += 1

                elif i > 0:
                    if i == 4:
                        sensorLog.write(x + "\n")
                        sensorLog.flush()
                        i = 0
                    else:
                        sensorLog.write(x + " ")
                        i += 1
                else:
                    gpsLog.write(x + "\n")
            '''


			radio.display.fill(0)
			radio.display.text('%0.2f  P:%0.1f hPa' % (float(fields[0]), float(fields[3])), 2, 2, 1)
			radio.display.text('T:%0.1f C  Hum:%0.2f%%' % (float(fields[1]), float(fields[2])), 2, 13, 1)
			radio.display.text('Alt:%0.2fm' % (float(fields[4])), 2, 25, 1)
			radio.display.show()
			'''

    radio.close()
    sensorLog.close()
    gpsLog.close()
示例#6
0
    def __init__(self, loop_hz):
        self._loop_hz = loop_hz
        self._loop_us = 1e6 / loop_hz
        self._average_cpu = 1.0

        self.inputs = hardware.Inputs()
        self.display = hardware.Display()
        radio.init()

        self._connected = False
        self._connected_id = None

        self.packet_counter = PacketLossCounter()

        self._loop_counter = loop_hz
示例#7
0
def main():
	radio.init()

	outputLog = open('dataTARS.txt', 'a')


	while True:
		packet = radio.rfm69.receive(timeout = 2)

		if packet is None:
			radio.display.fill(0)
			radio.display.text('No packet', 25, 15, 1)
			radio.display.show()
		else:
			dataLine = packet.decode()

			outputLog.write(dataLine)
			outputLog.flush()

			fields = dataLine.split (' ')

#			timeStamp = float(fields[0])
			temperature = float(fields[0])
			humedad = float(fields[1])
			presion = float(fields[2])
			altitud = float(fields[3])

#			outputLog.write("xxx %f %f %f %f %f\n" % (timeStamp, temperature, humedad, presion, altitud))
#			print("\nTime: %0.2f s" % (timeStamp - startTime))
			print("Temperature: %0.1f C" % temperature)
			print("Humedad: %0.1f %%" % humedad)
			print("Presión: %0.1f hPa" % presion)
			print("Altitud: %0.2f meters" % altitud)

			radio.display.fill(0)
#			radio.display.text('%0.2f  P:%0.1f hPa' % (timeStamp - startTime, presion), 2, 2, 1)
			radio.display.text('T:%0.1f C  Hum:%0.2f%%' % (temperature, humedad), 2, 13, 1)
			radio.display.text('Alt:%0.2fm' % (altitud), 2, 25, 1)
			radio.display.show()


	radio.close()
	outputLog.close()
示例#8
0
def radio_test_ook():
    """Repeatedly test switch 1 ON then OFF"""

    radio.init()
    # init() defaults to standby()
    try:
        radio.modulation(ook=True)
        while True:
            print("Switch 1 ON")
            radio.transmit(enc_1on, TIMES)
            # auto returns to standby
            if DELAY != 0: time.sleep(DELAY)

            print("Switch 1 OFF")
            radio.transmit(enc_1off, TIMES)
            # auto returns to standby
            if DELAY != 0: time.sleep(DELAY)

    finally:
        radio.finished()
示例#9
0
def radio_test_ook():
    """Repeatedly test switch 1 ON then OFF"""

    radio.init()
    # init() defaults to standby()
    try:
        radio.modulation(ook=True)
        while True:
            print("Switch 1 ON")
            radio.transmit(enc_1on, TIMES)
            # auto returns to standby
            if DELAY!=0: time.sleep(DELAY)

            print("Switch 1 OFF")
            radio.transmit(enc_1off, TIMES)
            # auto returns to standby
            if DELAY!=0: time.sleep(DELAY)

    finally:
        radio.finished()
示例#10
0
def init():
    """Start the Energenie system running"""
    radio.DEBUG = True
    radio.init()
    OpenThings.init(Devices.CRYPT_PID)
示例#11
0
import time
import radio
import sensor

radio.init()
sensor.init()

gpsLines = []
gpsPacket = []
i = 0

while True:
    sensor.writeLogLine()

    #Se escribe en la lista gpsPacket las líneas a enviar
    with open('gpsInfo.txt', 'rt') as gpsFile:
        for line in gpsFile:
            gpsLines.append(line)

    gpsPacket.clear()

    for x in gpsLines[i:]:
        gpsPacket.append(x)
        i += 1

    gpsLines.clear()

    #Envía los datos por radio
    packet = bytes(sensor.line(), "utf-8")
    gpsSend = bytes(str(gpsPacket), "utf-8")
示例#12
0
    def __init__(self, loop_hz):
        self.drive = hardware.Drive()
        radio.init()
        self._loop_us = 1000 / loop_hz

        self.telemetry_manager = TelemetryManager("Crawler", 100)
示例#13
0
文件: Devices_test.py 项目: maxf/home
def init():
    """Start the Energenie system running"""
    radio.DEBUG = True
    radio.init()
    OpenThings.init(Devices.CRYPT_PID)