Skip to content

Commit

Permalink
stuf
Browse files Browse the repository at this point in the history
  • Loading branch information
Joeri Van Dooren committed Mar 25, 2023
0 parents commit 1dd03ca
Show file tree
Hide file tree
Showing 18 changed files with 148 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"python.languageServer": "Pylance",
"python.linting.pylintEnabled": false,
"python.analysis.diagnosticSeverityOverrides": {
"reportMissingModuleSource": "none"
"reportShadowedImports": "none"
},
"python.analysis.extraPaths": [
"",
"/Users/ure/.vscode/extensions/joedevivo.vscode-circuitpython-0.1.19-darwin-arm64/stubs",
"/Users/ure/Library/Application Support/Code/User/globalStorage/joedevivo.vscode-circuitpython/bundle/20221227/adafruit-circuitpython-bundle-py-20221227/lib"
],
"circuitpython.board.version": null
}
54 changes: 54 additions & 0 deletions OLED.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import board
import busio
import displayio
import terminalio
import adafruit_displayio_ssd1306
from adafruit_display_text import label
from adafruit_display_shapes.rect import Rect
import time

displayio.release_displays()

# Create the I2C interface.
i2c = busio.I2C(scl=board.GP21, sda=board.GP20)

if i2c.try_lock():
print("Starting I2C scan.")
devices = i2c.scan()
i2c.unlock()

print("Found %d I2C device(s)." % (len(devices)))
for dev in devices:
print(" I2C address: %d (0x%x)" % (dev, dev))

else:
print("Unable to lock I2C interface.")

display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)

display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=64)

# Make the display context
splash = displayio.Group()
display.show(splash)#

def printTitle(msg):
global splash

msg='{message: <6}'.format(message=msg)
# Draw a label
text_area = label.Label(terminalio.FONT, text=msg, color=0xFFFFFF, x=0, y=8, scale=2)
splash.append(text_area)
time.sleep(0.1)
splash.remove(text_area)

def printPWR(msg):
global splash

# Draw a label
text_area = label.Label(terminalio.FONT, text=msg, color=0xFFFFFF, x=10, y=40, scale=2)
splash.append(text_area)
time.sleep(0.1)
splash.remove(text_area)


59 changes: 59 additions & 0 deletions SmartSWR.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import board
import math
import time
import analogio
import OLED

rf1Level = analogio.AnalogIn(board.GP26)
rf2Level = analogio.AnalogIn(board.GP27)

def rf1_voltage():
return (rf1Level.value / 65535 * rf1Level.reference_voltage)

def rf2_voltage():
return (rf2Level.value / 65535 * rf2Level.reference_voltage)

def rf1_ppower():
while True:
result = 0
for x in range(10000):
voltage = rf1_voltage()
if voltage > result:
result = voltage

if result > 0.04:
voltage = rf1_voltage()
if voltage > result:
result = voltage
output = round(result * 3.1,4)
if output < 1:
output = output*1000
OLED.printPWR('A {message: <13}'.format(message=str(round(output,2))+" mW"))
else:
OLED.printPWR('A {message: <13}'.format(message=str(round(output,2))+" W"))
else:
return False


def rf1_apower():
counter = 0
sum = 0
while True:
result = 0
for x in range(10000):
voltage = rf1_voltage()
if voltage > result:
result = voltage

if result > 0.04:
voltage = rf1_voltage()
sum = voltage + sum
counter = counter + 1
output = round((sum/counter) * 3.1,4)
if output < 1:
output = output*1000
OLED.printPWR('A {message: <13}'.format(message=str(round(output,2))+" mW"))
else:
OLED.printPWR('A {message: <13}'.format(message=str(round(output,2))+" W"))
else:
return False
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Button toggles mode
Boot with button -> loads config + disk
19 changes: 19 additions & 0 deletions code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import OLED
import time
import SmartSWR

mode='peak'

if mode == 'peak':
OLED.printTitle("PEAK Pwr")
if mode == 'average':
OLED.printTitle("AVG Pwr")

while True:
OLED.printPWR('Waiting...')
print(SmartSWR.rf1_voltage())
print(SmartSWR.rf2_voltage())
# if mode == 'peak':
# SmartPWR.rf1_ppower()
# if mode == 'average':
# SmartPWR.rf1_apower()
Empty file.
Binary file added lib/adafruit_display_shapes/circle.mpy
Binary file not shown.
Binary file added lib/adafruit_display_shapes/line.mpy
Binary file not shown.
Binary file added lib/adafruit_display_shapes/polygon.mpy
Binary file not shown.
Binary file added lib/adafruit_display_shapes/rect.mpy
Binary file not shown.
Binary file added lib/adafruit_display_shapes/roundrect.mpy
Binary file not shown.
Binary file added lib/adafruit_display_shapes/sparkline.mpy
Binary file not shown.
Binary file added lib/adafruit_display_shapes/triangle.mpy
Binary file not shown.
Binary file added lib/adafruit_display_text/__init__.mpy
Binary file not shown.
Binary file added lib/adafruit_display_text/bitmap_label.mpy
Binary file not shown.
Binary file added lib/adafruit_display_text/label.mpy
Binary file not shown.
Binary file added lib/adafruit_display_text/scrolling_label.mpy
Binary file not shown.
Binary file added lib/adafruit_displayio_ssd1306.mpy
Binary file not shown.

0 comments on commit 1dd03ca

Please sign in to comment.