-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmartSWR.py
executable file
·59 lines (51 loc) · 1.64 KB
/
SmartSWR.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
55
56
57
58
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