initial commit without secrets :>

This commit is contained in:
cqc
2026-01-02 17:24:29 +01:00
commit 22c3128948
130 changed files with 140 additions and 0 deletions

140
code.py Executable file
View File

@ -0,0 +1,140 @@
print("\nchaos minimap!")
import os
import wifi
import adafruit_connection_manager
import adafruit_requests
import json
import time
import board
import busio
import displayio
import terminalio
from adafruit_display_text import label
# Import the SSD1306 module.
import adafruit_ssd1306
from secrets import hauk_endpoint,hauk_session,hauk_slug,hauk_name
# Create the I2C interface.
i2c = busio.I2C(board.D7, board.D8)
# Create the SSD1306 OLED class.
# The first two parameters are the pixel width and pixel height. Change these
# to the right size for your display!
display = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio)
requests = adafruit_requests.Session(pool, ssl_context)
locavg = []
def location_avg():
global locavg
if len(locavg) > 10:
locavg = locavg[1:]
lavg = list(zip(*locavg))
print(lavg[0], lavg[1])
lavg = (sum(lavg[0])/len(lavg[0]), sum(lavg[1])/len(lavg[1]))
return lavg
def update_location():
global locavg
print('scanning',)
wifi.radio.stop_scanning_networks()
time.sleep(2)
ns = wifi.radio.start_scanning_networks()
wifi_peers = []
for n in ns:
#print(n.ssid, n.bssid.hex(':'), n.rssi, n.channel)
wifi_peers.append({"bssid": n.bssid.hex(':'), "ssid": n.ssid, "rssi": n.rssi})
#print(wifi_peers)
wifi.radio.stop_scanning_networks()
print('loc request')
data = json.dumps(wifi_peers)
print(data)
lat,lon=0,0
with requests.post(f"{hauk_endpoint}/location", data=data) as response:
#print(response.text)
j = response.json()
if 'triangulation' in j:
print(j['triangulation'])
lat = j['triangulation']['Position']['Lat']
lon = j['triangulation']['Position']['Lon']
else:
print('no location received')
locavg.append((lat,lon))
lavg = location_avg()
print(lavg)
form_data={"sid":hauk_session, "lat":lavg[0],"lon":lavg[1], "time":0.0, "pwd":""}
print(form_data)
with requests.post("{hauk_endpoint}/api/post.php", data=form_data) as r:
print('post.php', r.text)
import math
def haversine(coord1, coord2):
"""
Calculate the great-circle distance between two points on the Earth
specified in decimal degrees (latitude and longitude).
Parameters:
coord1 (tuple): (latitude, longitude) for point 1
coord2 (tuple): (latitude, longitude) for point 2
Returns:
float: distance in kilometers between the two points
"""
# Convert latitude and longitude from degrees to radians
lat1, lon1 = map(math.radians, coord1)
lat2, lon2 = map(math.radians, coord2)
# Haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
a = math.sin(dlat / 2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon / 2)**2
c = 2 * math.asin(math.sqrt(a))
# Radius of Earth in kilometers (mean radius)
r = 6371.0
return c * r
def update_display():
display.fill(0)
display.text("freeside minimap!", 0, 0, 1)
l = {}
with requests.get(f"{hauk_endpoint}/api/fetch.php?id={hauk_slug}&since=0") as r:
#print('fetch.php', r.text)
l = r.json()
print(l)
d = location_avg()
for (name,val), i in zip(l['points'].items(), range(len(l['points']))):
if len(val) > 0:
distance = haversine(d, (val[0][0],val[0][1]))
else:
distance = float('inf')
print(name, "is", distance)
display.text(f"{name}: {distance}", 0, 10*(i+1), 1)
display.show()
display.fill(0)
display.text("freeside minimap!", 0, 0, 1)
display.show()
def code_update():
while True:
try:
update_location()
update_display()
except Exception as e:
raise e

BIN
font5x8.bin Executable file

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

BIN
lib/adafruit_color_terminal.mpy Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/adafruit_fakerequests.mpy Executable file

Binary file not shown.

BIN
lib/adafruit_framebuf.mpy Executable file

Binary file not shown.

BIN
lib/adafruit_hashlib/__init__.mpy Executable file

Binary file not shown.

BIN
lib/adafruit_hashlib/_md5.mpy Executable file

Binary file not shown.

BIN
lib/adafruit_hashlib/_sha1.mpy Executable file

Binary file not shown.

BIN
lib/adafruit_hashlib/_sha224.mpy Executable file

Binary file not shown.

BIN
lib/adafruit_hashlib/_sha256.mpy Executable file

Binary file not shown.

BIN
lib/adafruit_hashlib/_sha384.mpy Executable file

Binary file not shown.

BIN
lib/adafruit_hashlib/_sha512.mpy Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/adafruit_httpserver/route.mpy Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

0
lib/adafruit_io/__init__.py Executable file
View File

BIN
lib/adafruit_io/adafruit_io.mpy Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/adafruit_json_stream.mpy Executable file

Binary file not shown.

BIN
lib/adafruit_jwt.mpy Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More