Ejemplo n.º 1
0
def on_button_callback():
    codey.wifi_close()
    codey.wifi('Maker-guest', 'makeblock')
    while not codey.wifi_is_connected():
        pass

    codey.color('#1dff00', 1)
Ejemplo n.º 2
0
def conn_wifi():
	codey.wifi( "Maker-guest", "makeblock" )
	while( True ):
		if ( codey.wifi_is_connected() ):
			break;
		else:
			print( "Wait for wifi connected" )
			time.sleep( 1 )
Ejemplo n.º 3
0
def __iot_get(request_url):
    if not codey.wifi_is_connected():
        print('-------> No network connection: ' + request_url)
        return ''
    print('======request_url: ' + request_url)
    res = urequests.request('GET',
                            request_url,
                            headers=__iot_get_request_header()).json()
    print(res)
    return res['data']
Ejemplo n.º 4
0
def on_button_callback():
    global a
    codey.wifi_close()
    codey.wifi('Maker-guest', 'makeblock')
    codey.show('hello')
    while not codey.wifi_is_connected():
        pass

    codey.show(iot.weather('2164425', '0'))
    codey.color('#ffffff')
    time.sleep(2)
    while True:
        time.sleep(1)
        codey.show(codey.wifi_is_connected())
        if codey.wifi_is_connected():
            codey.say('step2.wav', True)
            codey.color('#00ff50')

        else:
            codey.color('#ff0000')
Ejemplo n.º 5
0
def iot_weather(city_code, data_type):
    if not codey.wifi_is_connected():
        return ''
    res = urequests.request(
        'GET', iot_weather_request_domin + 'getweather?woeid=' +
        str(city_code) + '&type=' + str(data_type))
    text = res.text
    print('=====iot_weather: ' + text)
    if int(data_type) <= 3:
        return int(text)
    return text
Ejemplo n.º 6
0
def on_button2_callback():
    if codey.wifi_is_connected():
        codey.show(iot.weather('2161853', '1'))
Ejemplo n.º 7
0
    codey.face('00001020402012020212204020100000', 1)
    while True:
        codey.show(iot.list_length('r'))


codey.on_message(str('gg'), on_message_callback)


def on_button_callback():
    codey.say('cat.wav')


codey.on_button('A', on_button_callback)


def on_message1_callback():
    codey.color('#ff0000', 1)
    while True:
        iot.list_add('r', iot.weather('2161853', '0'))


codey.on_message(str('ww'), on_message1_callback)

codey.wifi('Maker-guest', 'makeblock')
codey.show('connecting...')
while not codey.wifi_is_connected():
    pass

codey.message(str('gg'))
codey.message(str('ww'))