Exemple #1
0
def duerColor(color):
    ''' '''

    BLINKER_LOG('need set color: ', color)

    # if color == 0xFF0000: # 'Red':
    #     # your codes
    # elif color == 0xFFFF00: # 'Yellow':
    #     # your codes
    # elif color == 0x0000FF: # 'Blue':
    #     # your codes
    # elif color == 0x00FF00: # 'Green':
    #     # your codes
    # elif color == 0xFFFFFF: # 'White':
    #     # your codes
    # elif color == 0x000000: # 'Black':
    #     # your codes
    # elif color == 0x00FFFF: # 'Cyan':
    #     # your codes
    # elif color == 0x800080: # 'Purple':
    #     # your codes
    # elif color == 0xFFA500: # 'Orange':
    #     # your codes

    BlinkerDuerOS.color(color)
    BlinkerDuerOS.print()
Exemple #2
0
def duerPowerState(state):
    ''' '''

    BLINKER_LOG('need set power state: ', state)

    BlinkerDuerOS.powerState(state)
    BlinkerDuerOS.print()
Exemple #3
0
def duerBright(bright):
    ''' '''

    BLINKER_LOG('need set brightness: ', bright)

    BlinkerDuerOS.brightness(bright)
    BlinkerDuerOS.print()
Exemple #4
0
def duerRelativeBright(bright):
    ''' '''

    BLINKER_LOG('need set relative brightness: ', bright)

    BlinkerDuerOS.brightness(bright)
    BlinkerDuerOS.print()
Exemple #5
0
def duerPowerState(state, num):
    ''' '''

    BLINKER_LOG("need set outlet: ", num, ", power state: ", state)

    BlinkerDuerOS.powerState(state, num)
    BlinkerDuerOS.print()
def duerPowerState(state, num):
    ''' '''

    BLINKER_LOG("need set outlet: ", num, ", power state: ", state)

    global wsState
    wsState[num] = state

    if num == 0 and state == 'false':
        for i in len(wsState):
            wsState[i] = state

    BlinkerDuerOS.powerState(state, num)
    BlinkerDuerOS.print()
Exemple #7
0
def duerQuery(queryCode):
    ''' '''

    BLINKER_LOG('DuerOS Query codes: ', queryCode)

    if queryCode == BLINKER_CMD_QUERY_TIME_NUMBER:
        BLINKER_LOG("DuerOS Query time")
        BlinkerDuerOS.time(millis())
        BlinkerDuerOS.print()
    else:
        BlinkerDuerOS.time(millis())
        BlinkerDuerOS.print()
Exemple #8
0
def duercMode(cmode):
    ''' '''

    BLINKER_LOG('need cancel mode: ', cmode)

    # if mode == BLINKER_CMD_DUEROS_READING:
    #     # Your mode function
    # elif mode == BLINKER_CMD_DUEROS_SLEEP:
    #     # Your mode function
    # elif mode == BLINKER_CMD_DUEROS_ALARM:
    #     # Your mode function
    # elif mode == BLINKER_CMD_DUEROS_NIGHT_LIGHT:
    #     # Your mode function
    # elif mode == BLINKER_CMD_DUEROS_ROMANTIC:
    #     # Your mode function
    # elif mode == BLINKER_CMD_DUEROS_READING:
    #     # Your mode function

    BlinkerDuerOS.mode(cMode)
    BlinkerDuerOS.print()
Exemple #9
0
def button1_callback(state):
    ''' '''

    BLINKER_LOG('get button state: ', state)

    button1.icon('icon_1')
    button1.color('#FFFFFF')
    button1.text('Your button name or describe')
    button1.print(state)


def data_callback(data):
    global counter

    BLINKER_LOG('Blinker readString: ', data)
    counter += 1
    number1.print(counter)


button1.attach(button1_callback)
Blinker.attachData(data_callback)

BlinkerDuerOS.attachPowerState(duerPowerState)
BlinkerDuerOS.attachQuery(duerQuery)

if __name__ == '__main__':

    while True:
        Blinker.run()
Exemple #10
0
def duerQuery(queryCode):
    ''' '''

    BLINKER_LOG('DuerOS Query codes: ', queryCode)

    if queryCode == BLINKER_CMD_QUERY_AQI_NUMBER :
        BLINKER_LOG("DuerOS Query AQI")
        BlinkerDuerOS.aqi(20)
        BlinkerDuerOS.print()
    elif queryCode == BLINKER_CMD_QUERY_CO2_NUMBER :
        BLINKER_LOG("DuerOS Query CO2")
        BlinkerDuerOS.co2(20)
        BlinkerDuerOS.print()
    elif queryCode == BLINKER_CMD_QUERY_PM10_NUMBER :
        BLINKER_LOG("DuerOS Query CO2")
        BlinkerDuerOS.pm10(20)
        BlinkerDuerOS.print()
    elif queryCode == BLINKER_CMD_QUERY_PM25_NUMBER :
        BLINKER_LOG("DuerOS Query CO2")
        BlinkerDuerOS.pm25(20)
        BlinkerDuerOS.print()
    elif queryCode == BLINKER_CMD_QUERY_HUMI_NUMBER :
        BLINKER_LOG("DuerOS Query CO2")
        BlinkerDuerOS.humi(20)
        BlinkerDuerOS.print()
    elif queryCode == BLINKER_CMD_QUERY_TEMP_NUMBER :
        BLINKER_LOG("DuerOS Query CO2")
        BlinkerDuerOS.temp(20)
        BlinkerDuerOS.print()
    elif queryCode == BLINKER_CMD_QUERY_TIME_NUMBER :
        BLINKER_LOG("DuerOS Query CO2")
        BlinkerDuerOS.time(millis())
        BlinkerDuerOS.print()
    else :        
        BlinkerDuerOS.temp(20)
        BlinkerDuerOS.humi(20)
        BlinkerDuerOS.pm25(20)
        BlinkerDuerOS.print()
Exemple #11
0
        BlinkerDuerOS.humi(20)
        BlinkerDuerOS.pm25(20)
        BlinkerDuerOS.print()

def button1_callback(state):
    ''' '''

    BLINKER_LOG('get button state: ', state)

    button1.icon('icon_1')
    button1.color('#FFFFFF')
    button1.text('Your button name or describe')
    button1.print(state)

def data_callback(data):
    global counter
    
    BLINKER_LOG('Blinker readString: ', data)
    counter += 1
    number1.print(counter)

button1.attach(button1_callback)
Blinker.attachData(data_callback)

BlinkerDuerOS.attachQuery(duerQuery)

if __name__ == '__main__':

    while True:
        Blinker.run()
Exemple #12
0
    button1.icon('icon_1')
    button1.color('#FFFFFF')
    button1.text('Your button name or describe')
    button1.print(state)


def data_callback(data):
    global counter

    BLINKER_LOG('Blinker readString: ', data)
    counter += 1
    number1.print(counter)


button1.attach(button1_callback)
Blinker.attachData(data_callback)

BlinkerDuerOS.attachPowerState(duerPowerState)
BlinkerDuerOS.attachColor(duerColor)
BlinkerDuerOS.attachMode(duerMode)
BlinkerDuerOS.attachCancelMode(duercMode)
BlinkerDuerOS.attachBrightness(duerBright)
BlinkerDuerOS.attachRelativeBrightness(duerRelativeBright)
BlinkerDuerOS.attachQuery(duerQuery)

if __name__ == '__main__':

    while True:
        Blinker.run()
Exemple #13
0
def duerQuery(queryCode, num):
    ''' '''

    BLINKER_LOG("DuerOS Query outlet: ", num, ", codes: ", queryCode)

    if queryCode == BLINKER_CMD_QUERY_ALL_NUMBER:
        BLINKER_LOG('DuerOS Query All')
        BlinkerDuerOS.powerState(wsState, num)
        BlinkerDuerOS.print()
    elif queryCode == BLINKER_CMD_QUERY_POWERSTATE_NUMBER:
        BlinkerDuerOS.powerState(wsState, num)
        BlinkerDuerOS.print()
    else:
        BlinkerDuerOS.powerState(wsState, num)
        BlinkerDuerOS.print()
def duerQuery(queryCode, num):
    ''' '''

    BLINKER_LOG("DuerOS Query outlet: ", num, ", codes: ", queryCode)

    global wsState
    state = 'off'

    for i, val in enumerate(wsState):
        if i == num:
            state = val

    if queryCode == BLINKER_CMD_QUERY_ALL_NUMBER:
        BLINKER_LOG('DuerOS Query All')
        BlinkerDuerOS.powerState(state, num)
        BlinkerDuerOS.print()
    elif queryCode == BLINKER_CMD_QUERY_POWERSTATE_NUMBER:
        BlinkerDuerOS.powerState(state, num)
        BlinkerDuerOS.print()
    else:
        BlinkerDuerOS.powerState(state, num)
        BlinkerDuerOS.print()