-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy updated files to the release folder
- Loading branch information
1 parent
b3c9ab2
commit 0ef84bf
Showing
10 changed files
with
2,405 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#https://github.com/DFRobot/micropython-dflib/blob/master/ADXL345/user_lib/ADXL345.py | ||
from machine import Pin,I2C | ||
import math | ||
import time | ||
|
||
device = const(0x53) | ||
regAddress = const(0x32) | ||
TO_READ = 6 | ||
buff = bytearray(6) | ||
|
||
class ADXL345: | ||
def __init__(self,i2c,addr=device): | ||
self.addr = addr | ||
self.i2c = i2c | ||
b = bytearray(1) | ||
b[0] = 0 | ||
self.i2c.writeto_mem(self.addr,0x2d,b) | ||
b[0] = 16 | ||
self.i2c.writeto_mem(self.addr,0x2d,b) | ||
b[0] = 8 | ||
self.i2c.writeto_mem(self.addr,0x2d,b) | ||
|
||
@property | ||
def xValue(self): | ||
buff = self.i2c.readfrom_mem(self.addr,regAddress,TO_READ) | ||
x = (int(buff[1]) << 8) | buff[0] | ||
if x > 32767: | ||
x -= 65536 | ||
return x | ||
|
||
@property | ||
def yValue(self): | ||
buff = self.i2c.readfrom_mem(self.addr,regAddress,TO_READ) | ||
y = (int(buff[3]) << 8) | buff[2] | ||
if y > 32767: | ||
y -= 65536 | ||
return y | ||
|
||
@property | ||
def zValue(self): | ||
buff = self.i2c.readfrom_mem(self.addr,regAddress,TO_READ) | ||
z = (int(buff[5]) << 8) | buff[4] | ||
if z > 32767: | ||
z -= 65536 | ||
return z | ||
|
||
def RP_calculate(self,x,y,z): | ||
roll = math.atan2(y , z) * 57.3 | ||
pitch = math.atan2((- x) , math.sqrt(y * y + z * z)) * 57.3 | ||
return roll,pitch | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import sys | ||
def savetofile(pointstosave): # the points to save should have format of [[light, pot],[light,pot]] | ||
import os | ||
if(os.listdir().count('data.py')): | ||
import data | ||
datapoints=[] | ||
del sys.modules["data"] | ||
import data | ||
try: | ||
datapoints=data.points | ||
datapoints.append(pointstosave) | ||
except: | ||
datapoints.append(pointstosave) | ||
del sys.modules["data"] | ||
#getting ready to reimporting data file | ||
else: | ||
datapoints=[] | ||
datapoints.append(pointstosave) | ||
print("new file") | ||
|
||
#writing files to the data.py | ||
f=open("data.py","w") | ||
f.write("points="+str(datapoints)+"\r\n") | ||
f.close() | ||
|
||
|
||
def cleardatafile(): # the points to save should have format of [[light, pot],[light,pot]] | ||
import os | ||
f=open("data.py","w") | ||
f.write("points=[]") | ||
f.close() | ||
|
||
|
||
def replacefile(pointstosave): | ||
import os | ||
if(os.listdir().count('data.py')): | ||
f=open("data.py","w") | ||
f.write("points="+str(pointstosave)+"\r\n") | ||
f.close() | ||
else: | ||
return 0 | ||
|
||
|
||
|
||
def readfile(): | ||
|
||
import os | ||
if(os.listdir().count('data.py')): | ||
import data | ||
if(data.points): | ||
return(data.points) | ||
else: | ||
print("returning blank") | ||
return([]) | ||
else: | ||
return([]) | ||
|
||
#also make this go home | ||
|
||
def resetlog(): | ||
import os | ||
try: | ||
os.remove("log.py") | ||
except: | ||
print("no log file to remove") | ||
|
||
def resetprefs(): | ||
f=open("prefs.py","w") | ||
f.write("log=False\r\n") | ||
f.close() | ||
|
||
|
||
|
||
def setprefs(): | ||
f=open("prefs.py","w") | ||
f.write("log=True\r\n") | ||
f.close() | ||
|
||
|
||
def savetolog(*logtext): # the points to save should have format of [[light, pot],[light,pot]] | ||
import os | ||
if(os.listdir().count('log.py')): | ||
f=open("log.py","a") | ||
try: | ||
print("writing",logtext) | ||
f.write(str(logtext)+"\r\n") | ||
except: | ||
print("errr") | ||
else: | ||
f=open("log.py","w") | ||
f.write(str(logtext)+",") | ||
|
||
#writing files to the data.py | ||
f.close() | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from machine import Pin | ||
import machine | ||
import gc | ||
gc.collect() | ||
|
||
import time | ||
|
||
print("Running pyscript networking tool") | ||
|
||
from networking import Networking | ||
|
||
#Network | ||
networking = Networking(True, False, True) | ||
peer_mac = b'\xff\xff\xff\xff\xff\xff' | ||
|
||
print(f"{(time.ticks_ms() - networking.inittime) / 1000:.3f} Name: {networking.name}, ID: {networking.id}, config: {networking.config}, Sta mac: {networking.sta.mac()}, Ap mac: {networking.ap.mac()}, Version: {networking.version_n}") | ||
|
||
lastPressed = 0 | ||
|
||
message="Boop!" | ||
|
||
def boop(pin): | ||
global lastPressed | ||
if(time.ticks_ms()-lastPressed>1000): | ||
lastPressed = time.ticks_ms() | ||
networking.aen.ping(peer_mac) | ||
networking.aen.echo(peer_mac, message) | ||
networking.aen.send(peer_mac, message) | ||
print(f"{(time.ticks_ms() - networking.inittime) / 1000:.3f} Networking Tool: Sent {message} to {peer_mac}") | ||
print(f"{(time.ticks_ms() - networking.inittime) / 1000:.3f} Networking Tool: RSSI table: {networking.aen.rssi()}") | ||
|
||
switch_select = Pin(9, Pin.IN, Pin.PULL_UP) | ||
|
||
#Buttons | ||
switch_select = Pin(9, Pin.IN, Pin.PULL_UP) | ||
switch_select.irq(trigger=Pin.IRQ_FALLING, handler=boop) | ||
|
||
def heartbeat(timer): | ||
print("") | ||
print(f"{(time.ticks_ms() - networking.inittime) / 1000:.3f} Networking Tool Heartbeat: {gc.mem_free()} bytes") | ||
print("") | ||
gc.collect() | ||
|
||
timer = machine.Timer(0) | ||
timer.init(period=5000, mode=machine.Timer.PERIODIC, callback=heartbeat) |
Oops, something went wrong.