Skip to content

Commit 6f853c1

Browse files
committed
voltage divider calculator finished
1 parent 15ee686 commit 6f853c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+76539
-64469
lines changed

fonts/OpenSans-SemiBold.ttf

98.5 KB
Binary file not shown.

modular-psu-firmware.eez-project

Lines changed: 11181 additions & 244 deletions
Large diffs are not rendered by default.
-30.4 KB
Binary file not shown.

scripts/voltage-divider-calculator.py

Lines changed: 0 additions & 34 deletions
This file was deleted.
89.8 KB
Loading

scripts/voltage-divider-calculator/voltage-divider-calculator.eez-project

Lines changed: 301 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"viewOptions": {
3+
"outputVisible": true,
4+
"debugVisible": false
5+
},
6+
"navigationMap": {
7+
"/settings": {
8+
"general": {
9+
"$selected": true
10+
}
11+
},
12+
"/": "/gui",
13+
"/gui": "/gui/pages",
14+
"/gui/bitmaps": "/gui/bitmaps/0",
15+
"/gui/pages/0": "/gui/pages/0/widgets",
16+
"/gui/pages": "/gui/pages/0",
17+
"/gui/themes": "/gui/themes/0",
18+
"/actions": "/actions/7",
19+
"/data": "/data/0"
20+
},
21+
"editors": [
22+
{
23+
"object": "/gui/pages/0",
24+
"active": true,
25+
"permanent": true,
26+
"state": {
27+
"1": {}
28+
}
29+
}
30+
],
31+
"selectedBuildConfiguration": "Default",
32+
"features": {},
33+
"objects": {
34+
"/gui/pages/0": {
35+
"pageEditorCanvasViewState": {
36+
"transform": {
37+
"translate": {
38+
"x": -815.0999999999999,
39+
"y": -640.0545454545453
40+
},
41+
"scale": 16
42+
}
43+
}
44+
}
45+
}
46+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Calculate resitor valus for voltage divider
2+
3+
#
4+
# 1) Dodati SCPI komande:
5+
# DISP:DIALog:OPEN <file_path>
6+
# DISP:DIALog:DATA <data_name>,<value>
7+
# DISP:DIALog:ACTIon? <timeout>
8+
# DISP:DIALog:CLOSe
9+
#
10+
# 2) upisati u buildani projekt ime od: action i data (i page?)
11+
#
12+
# 3) odabir ohm, kilohms i megaohms za resistance
13+
#
14+
15+
from eez import scpi
16+
17+
Vin = None
18+
R1 = None
19+
R2 = None
20+
Vout = None
21+
22+
def input_Vin():
23+
global Vin
24+
value = scpi('DISP:INPUT? "Vin", NUMBER,VOLT,1E-3,1E3,' + (str(Vin) if Vin != None else "1"))
25+
if value != None:
26+
Vin = float(value)
27+
scpi("DISP:DIALog:DATA \"Vin\",FLOAT,VOLT," + str(Vin))
28+
29+
def input_R1():
30+
global R1
31+
value = scpi('DISP:INPUT? "R1",NUMBER,OHM,1E-12,1E12,' + (str(R1) if R1 != None else "1"))
32+
if value != None:
33+
R1 = float(value)
34+
scpi("DISP:DIALog:DATA \"R1\",FLOAT,OHM," + str(R1))
35+
36+
def input_R2():
37+
global R2
38+
value = scpi('DISP:INPUT? "R2",NUMBER,OHM,1E-12,1E12,' + (str(R2) if R2 != None else "1"))
39+
if value != None:
40+
R2 = float(value)
41+
scpi("DISP:DIALog:DATA \"R2\",FLOAT,OHM," + str(R2))
42+
43+
def input_Vout():
44+
global Vout
45+
value = scpi('DISP:INPUT? "Vout",NUMBER,VOLT,1E-3,1E3,' + (str(Vout) if Vout != None else "1"))
46+
if value != None:
47+
Vout = float(value)
48+
scpi("DISP:DIALog:DATA \"Vout\",FLOAT,VOLT," + str(Vout))
49+
50+
def can_calc_Vout():
51+
return Vin != None and R1 != None and R2 != None
52+
53+
def can_calc_R1():
54+
return Vin != None and Vout != None and Vin > Vout and R2 != None
55+
56+
def can_calc_R2():
57+
return Vin != None and Vout != None and Vin > Vout and R1 != None
58+
59+
def can_calc_Vin():
60+
return Vout != None and R1 != None and R2 != None
61+
62+
def calc_Vin():
63+
if can_calc_Vin():
64+
Vin = round(Vout * (R1 + R2) / R2, 3)
65+
scpi("DISP:DIALog:DATA \"Vin\",FLOAT,VOLT," + str(Vin))
66+
67+
def calc_R1():
68+
if can_calc_R1():
69+
R1 = round(R2 * (Vin - Vout) / Vout, 3)
70+
scpi("DISP:DIALog:DATA \"R1\",FLOAT,OHM," + str(R1))
71+
72+
def calc_R2():
73+
if can_calc_R2():
74+
R2 = round(R1 * Vout / (Vin - Vout), 3)
75+
scpi("DISP:DIALog:DATA \"R2\",FLOAT,OHM," + str(R2))
76+
77+
def calc_Vout():
78+
if can_calc_Vout():
79+
Vout = round(Vin * R2 / (R1 + R2), 3)
80+
scpi("DISP:DIALog:DATA \"Vout\",FLOAT,VOLT," + str(Vout))
81+
82+
scpi("DISP:DIALog:OPEN \"/Scripts/voltage-divider-calculator.res\"")
83+
while True:
84+
action = scpi("DISP:DIALog:ACTIon?")
85+
86+
if action == "close":
87+
scpi("DISP:DIALog:CLOSe")
88+
break
89+
90+
elif action == "input_Vin":
91+
input_Vin()
92+
elif action == "input_R1":
93+
input_R1()
94+
elif action == "input_R2":
95+
input_R2()
96+
elif action == "input_Vout":
97+
input_Vout()
98+
99+
elif action == "calc_Vin":
100+
calc_Vin()
101+
elif action == "calc_R1":
102+
calc_R1()
103+
elif action == "calc_R2":
104+
calc_R2()
105+
elif action == "calc_Vout":
106+
calc_Vout()
Binary file not shown.

src/eez/gui/app_context.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void AppContext::pushPage(int pageId, Page *page) {
171171
int previousPageId = getActivePageId();
172172

173173
// advance stack pointre
174-
if (getActivePageId() != INTERNAL_PAGE_ID_NONE) {
174+
if (getActivePageId() != PAGE_ID_NONE) {
175175
m_pageNavigationStackPointer++;
176176
assert (m_pageNavigationStackPointer < CONF_GUI_PAGE_NAVIGATION_STACK_SIZE);
177177
}
@@ -211,10 +211,6 @@ Page *AppContext::getPage(int pageId) {
211211
return nullptr;
212212
}
213213

214-
int AppContext::getNumPagesOnStack() {
215-
return m_pageNavigationStackPointer + 1;
216-
}
217-
218214
bool AppContext::isPageOnStack(int pageId) {
219215
for (int i = 0; i <= m_pageNavigationStackPointer; ++i) {
220216
if (m_pageNavigationStack[i].pageId == pageId) {
@@ -256,7 +252,7 @@ bool AppContext::testExecuteActionOnTouchDown(int action) {
256252
return false;
257253
}
258254

259-
bool AppContext::isBlinking(const data::Cursor &cursor, uint16_t id) {
255+
bool AppContext::isBlinking(const data::Cursor &cursor, int16_t id) {
260256
return false;
261257
}
262258

@@ -394,7 +390,7 @@ bool AppContext::isPageFullyCovered(int pageNavigationStackIndex) {
394390
}
395391

396392
void AppContext::updateAppView(WidgetCursor &widgetCursor) {
397-
if (getActivePageId() == INTERNAL_PAGE_ID_NONE) {
393+
if (getActivePageId() == PAGE_ID_NONE) {
398394
return;
399395
}
400396

0 commit comments

Comments
 (0)