Skip to content

Commit

Permalink
Hello World script
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Apr 12, 2020
1 parent 827492c commit 40fc43c
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 0 deletions.
146 changes: 146 additions & 0 deletions scripts/Hello World/Hello World.eez-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{
"settings": {
"general": {
"projectVersion": "v2",
"masterProject": "..\\..\\modular-psu-firmware.eez-project"
},
"build": {
"configurations": [
{
"name": "Default"
}
],
"files": []
}
},
"data": [
{
"name": "voltage",
"type": "float",
"defaultValue": "3.0 V"
},
{
"name": "can_set_voltage",
"type": "boolean",
"defaultValue": "0"
}
],
"actions": [
{
"name": "set_voltage"
},
{
"name": "input_voltage"
},
{
"name": "close"
}
],
"gui": {
"pages": [
{
"name": "main",
"widgets": [
{
"type": "Container",
"style": {
"inheritFrom": "default"
},
"left": 138,
"top": 75,
"width": 204,
"height": 90,
"widgets": [
{
"type": "Text",
"style": {
"inheritFrom": "default_M_left"
},
"left": 0,
"top": 0,
"width": 84,
"height": 40,
"text": "Voltage:"
},
{
"type": "Text",
"style": {
"inheritFrom": "edit_value_active_S_center"
},
"data": "voltage",
"action": "input_voltage",
"left": 84,
"top": 0,
"width": 120,
"height": 40,
"text": ""
},
{
"type": "Button",
"style": {
"inheritFrom": "button_M"
},
"action": "set_voltage",
"left": 84,
"top": 50,
"width": 120,
"height": 40,
"text": "Set",
"enabled": "can_set_voltage",
"disabledStyle": {
"inheritFrom": "button_M_disabled"
}
}
]
},
{
"type": "Container",
"style": {
"inheritFrom": "default"
},
"left": 0,
"top": 240,
"width": 480,
"height": 32,
"name": "Status line",
"widgets": [
{
"type": "Text",
"style": {
"inheritFrom": "status_icon_enabled"
},
"action": "close",
"left": 0,
"top": 0,
"width": 41,
"height": 32,
"text": "E"
},
{
"type": "Text",
"style": {
"inheritFrom": "status_title"
},
"data": "",
"left": 41,
"top": 0,
"width": 439,
"height": 32,
"text": "Hello World"
}
]
}
],
"left": 0,
"top": 0,
"width": 480,
"height": 272
}
],
"styles": [],
"fonts": [],
"bitmaps": [],
"colors": [],
"themes": []
}
}
39 changes: 39 additions & 0 deletions scripts/Hello World/Hello World.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Hello, World!

from eez import scpi

def input_voltage():
global voltage, max_voltage
value = scpi('DISP:INPUT? "",NUMBER,VOLT,0.0,' + str(max_voltage) + '.0,' + str(voltage))
if value != None:
voltage = float(value)
scpi('DISP:DIALog:DATA "voltage",FLOAT,VOLT,' + str(voltage))
scpi('DISP:DIALog:DATA "can_set_voltage",INT,1')

def set_voltage():
scpi("INST ch1")
scpi("VOLT " + str(voltage))

def main():
global voltage, max_voltage
scpi("INST ch1")
voltage = scpi("VOLT?")
max_voltage = scpi("VOLT? MAX")

scpi("DISP:DIAL:OPEN \"/Scripts/Hello World.res\"")
try:
scpi('DISP:DIAL:DATA "voltage",FLOAT,VOLT,' + str(voltage))

while True:
action = scpi("DISP:DIALog:ACTIon?")
if action == "input_voltage":
input_voltage()
elif action == "set_voltage":
set_voltage()
break
elif action == "close" or action == 0:
break
finally:
scpi("DISP:DIAL:CLOS")

main()
Binary file added scripts/Hello World/Hello World.res
Binary file not shown.

0 comments on commit 40fc43c

Please sign in to comment.