-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwhats_my_ip.py
54 lines (43 loc) · 1.02 KB
/
whats_my_ip.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
### Author: Maidstone Hackspace
### License: MIT
### Appname: whats my ip
### Description: whats my ip
import wifi
import ugfx
import pyb
import time
import buttons
from http_client import *
import json
import math
def mainscreen():
ugfx.area(0,0,ugfx.width(),ugfx.height(),0x0000)
ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
ugfx.text(30,30,"Whats My IP",ugfx.YELLOW)
ugfx.text(40,75,"Press [A] to continue",ugfx.YELLOW)
return
def getdata():
server = 'badge.emf.camp'
#url = 'http://'+server+':9002/schedule'
#url = 'http://hackspace-leaderboard-scollins.c9users.io/schedule'
url = 'http://api.ipify.org/'
resp = get(url).text
ugfx.area(0,0,ugfx.width(),ugfx.height(),0x0000)
while True:
ugfx.text(30,30,resp,ugfx.WHITE)
return json.loads(resp)
#Check and Connect to WiFi
if wifi.is_connected():
pass
else:
wifi.connect()
#Init GFX and Buttons
ugfx.init()
buttons.init()
#Main Screen
mainscreen()
while True:
if buttons.is_triggered('BTN_A'):
getdata()
if buttons.is_triggered('BTN_B'):
mainscreen()