Skip to content

Commit

Permalink
io pins fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Oct 1, 2019
1 parent 2c6d1a2 commit a734141
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 189 deletions.
194 changes: 81 additions & 113 deletions modular-psu-firmware.eez-project
Original file line number Diff line number Diff line change
Expand Up @@ -1720,15 +1720,9 @@
},
{
"name": "ioPin.state",
"type": "boolean",
"enumItems": "",
"defaultValue": "1"
},
{
"name": "ioPin.isOutput",
"type": "boolean",
"enumItems": "",
"defaultValue": "1"
"type": "enum",
"enumItems": "[\n\"Inactive\",\n\"Active\",\n\"Inactive_Changeable\",\n\"Active_Changeable\",\n\"Unassigned\"\n]",
"defaultValue": "3"
}
],
"actions": [
Expand Down Expand Up @@ -17800,7 +17794,7 @@
},
"left": 81,
"top": 13,
"width": 70,
"width": 95,
"height": 28,
"text": "Ext Trg1"
},
Expand All @@ -17814,9 +17808,9 @@
"inheritFrom": "default",
"padding": 0
},
"left": 153,
"left": 178,
"top": 13,
"width": 70,
"width": 95,
"height": 28,
"text": "Ext Trg2"
},
Expand All @@ -17830,9 +17824,9 @@
"inheritFrom": "default",
"padding": 0
},
"left": 225,
"left": 275,
"top": 13,
"width": 70,
"width": 95,
"height": 28,
"text": "Dout1"
},
Expand All @@ -17846,9 +17840,9 @@
"inheritFrom": "default",
"padding": 0
},
"left": 297,
"left": 372,
"top": 13,
"width": 70,
"width": 95,
"height": 28,
"text": "Dout2"
},
Expand All @@ -17863,7 +17857,7 @@
"padding": 0
},
"left": 10,
"top": 43,
"top": 41,
"width": 71,
"height": 28,
"text": "Pin #:"
Expand All @@ -17879,7 +17873,7 @@
"padding": 0
},
"left": 10,
"top": 73,
"top": 71,
"width": 71,
"height": 28,
"text": "Function:"
Expand All @@ -17895,7 +17889,7 @@
"padding": 0
},
"left": 10,
"top": 103,
"top": 101,
"width": 71,
"height": 28,
"text": "Polarity:"
Expand All @@ -17911,7 +17905,7 @@
"padding": 0
},
"left": 10,
"top": 130,
"top": 131,
"width": 71,
"height": 28,
"text": "State:"
Expand All @@ -17929,7 +17923,7 @@
"data": "ioPins",
"left": 81,
"top": 41,
"width": 288,
"width": 388,
"height": 120,
"itemWidget": {
"type": "Container",
Expand All @@ -17943,7 +17937,7 @@
},
"left": 0,
"top": 0,
"width": 72,
"width": 97,
"height": 118,
"widgets": [
{
Expand All @@ -17959,7 +17953,7 @@
"data": "ioPin.number",
"left": 0,
"top": 0,
"width": 70,
"width": 97,
"height": 28,
"text": ""
},
Expand All @@ -17977,7 +17971,7 @@
"action": "ioPin.selectFunction",
"left": 0,
"top": 30,
"width": 70,
"width": 95,
"height": 28,
"text": "Pos"
},
Expand All @@ -17994,7 +17988,7 @@
"data": "ioPin.polarity",
"left": 0,
"top": 60,
"width": 70,
"width": 97,
"height": 28,
"widgets": [
{
Expand All @@ -18010,7 +18004,7 @@
"action": "ioPin.togglePolarity",
"left": 0,
"top": 0,
"width": 70,
"width": 95,
"height": 28,
"text": "Neg"
},
Expand All @@ -18027,7 +18021,7 @@
"action": "ioPin.togglePolarity",
"left": 0,
"top": 0,
"width": 70,
"width": 95,
"height": 28,
"text": "Pos"
}
Expand All @@ -18036,119 +18030,93 @@
{
"type": "Select",
"style": {
"inheritFrom": "default"
"inheritFrom": "default",
"padding": 0
},
"activeStyle": {
"inheritFrom": "default"
"inheritFrom": "default",
"padding": 0
},
"data": "ioPin.isOutput",
"data": "ioPin.state",
"left": 0,
"top": 90,
"width": 70,
"width": 95,
"height": 28,
"widgets": [
{
"type": "Select",
"type": "Text",
"style": {
"inheritFrom": "default",
"padding": 0
"inheritFrom": "edit_value_S_centered"
},
"activeStyle": {
"inheritFrom": "default",
"padding": 0
"inheritFrom": "default"
},
"data": "ioPin.state",
"action": "",
"left": 0,
"top": 0,
"width": 70,
"width": 95,
"height": 28,
"widgets": [
{
"type": "Text",
"style": {
"inheritFrom": "edit_value_S_centered",
"padding": 0
},
"activeStyle": {
"inheritFrom": "default",
"padding": 0
},
"action": "",
"left": 0,
"top": 0,
"width": 70,
"height": 28,
"text": "Inactive"
},
{
"type": "Text",
"style": {
"inheritFrom": "edit_value_S_centered",
"padding": 0
},
"activeStyle": {
"inheritFrom": "default",
"padding": 0
},
"action": "",
"left": 0,
"top": 0,
"width": 70,
"height": 28,
"text": "Active"
}
]
"text": "Inactive"
},
{
"type": "Select",
"type": "Text",
"style": {
"inheritFrom": "edit_value_S_centered"
},
"activeStyle": {
"inheritFrom": "default"
},
"action": "",
"left": 0,
"top": 0,
"width": 95,
"height": 28,
"text": "Active"
},
{
"type": "Text",
"style": {
"inheritFrom": "edit_value_active_S_center"
},
"activeStyle": {
"inheritFrom": "default"
},
"data": "ioPin.state",
"action": "ioPin.toggleState",
"left": 0,
"top": 0,
"width": 70,
"width": 95,
"height": 28,
"widgets": [
{
"type": "Text",
"style": {
"inheritFrom": "edit_value_active_S_center",
"padding": 0
},
"activeStyle": {
"inheritFrom": "default",
"padding": 0
},
"action": "",
"left": 0,
"top": 0,
"width": 70,
"height": 28,
"text": "Inactive"
},
{
"type": "Text",
"style": {
"inheritFrom": "edit_value_active_S_center",
"padding": 0
},
"activeStyle": {
"inheritFrom": "default",
"padding": 0
},
"action": "",
"left": 0,
"top": 0,
"width": 70,
"height": 28,
"text": "Active"
}
]
"text": "Inactive"
},
{
"type": "Text",
"style": {
"inheritFrom": "edit_value_active_S_center"
},
"activeStyle": {
"inheritFrom": "default"
},
"action": "ioPin.toggleState",
"left": 0,
"top": 0,
"width": 95,
"height": 28,
"text": "Active"
},
{
"type": "Text",
"style": {
"inheritFrom": "edit_value_S_centered"
},
"activeStyle": {
"inheritFrom": "default"
},
"action": "",
"left": 0,
"top": 0,
"width": 95,
"height": 28,
"text": "Unassigned"
}
]
}
Expand Down
32 changes: 18 additions & 14 deletions src/eez/apps/psu/gui/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3536,21 +3536,25 @@ void data_io_pin_state(data::DataOperationEnum operation, data::Cursor &cursor,
SysSettingsIOPinsPage *page = (SysSettingsIOPinsPage *)getPage(PAGE_ID_SYS_SETTINGS_IO);
if (page) {
int pin = cursor.i;
int state = io_pins::getPinState(cursor.i);
if (page->m_polarity[pin] != persist_conf::devConf2.ioPins[pin].polarity) {
state = state ? 0 : 1;
}
value = state;
}
}
}
if (page->m_function[pin] == io_pins::FUNCTION_NONE) {
value = 4; // Unassigned
} else {
int state = io_pins::getPinState(cursor.i);

void data_io_pin_is_output(data::DataOperationEnum operation, data::Cursor &cursor, data::Value &value) {
if (operation == data::DATA_OPERATION_GET) {
SysSettingsIOPinsPage *page = (SysSettingsIOPinsPage *)getPage(PAGE_ID_SYS_SETTINGS_IO);
if (page) {
int pin = cursor.i;
value = pin >= 2 && page->m_function[pin] == io_pins::FUNCTION_OUTPUT && persist_conf::devConf2.ioPins[pin].function == io_pins::FUNCTION_OUTPUT ? 1 : 0;
if (page->m_polarity[pin] != persist_conf::devConf2.ioPins[pin].polarity) {
state = state ? 0 : 1;
}

if (pin >= 2 && page->m_function[pin] == io_pins::FUNCTION_OUTPUT && persist_conf::devConf2.ioPins[pin].function == io_pins::FUNCTION_OUTPUT) {
if (state) {
value = 3; // Active_Changeable
} else {
value = 2; // Inactive_Changeable
}
} else {
value = state; // Active or Inactive
}
}
}
}
}
Expand Down
Loading

0 comments on commit a734141

Please sign in to comment.