Skip to content

Commit

Permalink
relay's UI
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Jan 28, 2021
1 parent a8ee8ef commit 50ae72b
Show file tree
Hide file tree
Showing 17 changed files with 55,130 additions and 54,800 deletions.
1 change: 1 addition & 0 deletions modular-psu-firmware.eez-project
Original file line number Diff line number Diff line change
Expand Up @@ -30891,6 +30891,7 @@
"inheritFrom": "default"
},
"data": "channel_protection_status",
"action": "show_ch_settings",
"left": 0,
"top": 57,
"width": 52,
Expand Down
4 changes: 3 additions & 1 deletion src/eez/firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ bool reset() {
}

void standBy() {
sendMessageToLowPriorityThread(THREAD_MESSAGE_PROFILE_SAVE);

psu::changePowerState(false);
}

Expand Down Expand Up @@ -434,7 +436,7 @@ void shutdown() {
} while (isLowPriorityThreadAlive());
#endif

profile::shutdownSave();
profile::saveIfDirty();

if (psu::isPowerUp()) {
psu::changePowerState(false);
Expand Down
67,251 changes: 33,637 additions & 33,614 deletions src/eez/gui/document_simulator.cpp

Large diffs are not rendered by default.

64 changes: 31 additions & 33 deletions src/eez/gui/document_simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -1982,37 +1982,37 @@ enum StylesEnum {
STYLE_ID_INLINE303 = 303,
STYLE_ID_INLINE304 = 304,
STYLE_ID_INLINE305 = 305,
STYLE_ID_INLINE306 = 306,
STYLE_ID_MON_VALUE_48_RIGHT = 306,
STYLE_ID_INLINE307 = 307,
STYLE_ID_MON_VALUE_48_RIGHT = 308,
STYLE_ID_INLINE309 = 309,
STYLE_ID_MON_VALUE_20_LEFT = 310,
STYLE_ID_BAR_GRAPH_U_DEFAULT = 311,
STYLE_ID_BAR_GRAPH_TEXT = 312,
STYLE_ID_BAR_GRAPH_SET_LINE = 313,
STYLE_ID_BAR_GRAPH_LIMIT_LINE = 314,
STYLE_ID_BAR_GRAPH_I_DEFAULT = 315,
STYLE_ID_LABELS_AND_COLORS_CHANNEL = 316,
STYLE_ID_MON_VALUE_20_LEFT = 308,
STYLE_ID_BAR_GRAPH_U_DEFAULT = 309,
STYLE_ID_BAR_GRAPH_TEXT = 310,
STYLE_ID_BAR_GRAPH_SET_LINE = 311,
STYLE_ID_BAR_GRAPH_LIMIT_LINE = 312,
STYLE_ID_BAR_GRAPH_I_DEFAULT = 313,
STYLE_ID_LABELS_AND_COLORS_CHANNEL = 314,
STYLE_ID_INLINE315 = 315,
STYLE_ID_TRIGGER_BUTTON_24 = 316,
STYLE_ID_INLINE317 = 317,
STYLE_ID_TRIGGER_BUTTON_24 = 318,
STYLE_ID_INLINE319 = 319,
STYLE_ID_INLINE320 = 320,
STYLE_ID_CHANNEL_OFF_BUTTON_38 = 321,
STYLE_ID_TRIGGER_BUTTON_14 = 322,
STYLE_ID_MON_VALUE_38_RIGHT = 323,
STYLE_ID_INLINE324 = 324,
STYLE_ID_CH_PROT_OFF = 325,
STYLE_ID_CH_PROT_ON = 326,
STYLE_ID_CH_PROT_TRIPPED = 327,
STYLE_ID_INLINE328 = 328,
STYLE_ID_MON_VALUE_20_RIGHT = 329,
STYLE_ID_MON_VALUE_14_LEFT = 330,
STYLE_ID_MON_VALUE_14_CENTER = 331,
STYLE_ID_ENCODER_CURSOR_14_RIGHT_ENABLED = 332,
STYLE_ID_CHANNEL_OFF_BUTTON_20 = 333,
STYLE_ID_MON_VALUE_14_RIGHT = 334,
STYLE_ID_CHANNEL_OFF_BUTTON_14 = 335,
STYLE_ID_MON_VALUE_24_RIGHT = 336,
STYLE_ID_INLINE318 = 318,
STYLE_ID_CHANNEL_OFF_BUTTON_38 = 319,
STYLE_ID_TRIGGER_BUTTON_14 = 320,
STYLE_ID_MON_VALUE_38_RIGHT = 321,
STYLE_ID_INLINE322 = 322,
STYLE_ID_CH_PROT_OFF = 323,
STYLE_ID_CH_PROT_ON = 324,
STYLE_ID_CH_PROT_TRIPPED = 325,
STYLE_ID_INLINE326 = 326,
STYLE_ID_MON_VALUE_20_RIGHT = 327,
STYLE_ID_MON_VALUE_14_LEFT = 328,
STYLE_ID_MON_VALUE_14_CENTER = 329,
STYLE_ID_ENCODER_CURSOR_14_RIGHT_ENABLED = 330,
STYLE_ID_CHANNEL_OFF_BUTTON_20 = 331,
STYLE_ID_MON_VALUE_14_RIGHT = 332,
STYLE_ID_CHANNEL_OFF_BUTTON_14 = 333,
STYLE_ID_MON_VALUE_24_RIGHT = 334,
STYLE_ID_INLINE335 = 335,
STYLE_ID_INLINE336 = 336,
STYLE_ID_INLINE337 = 337,
STYLE_ID_INLINE338 = 338,
STYLE_ID_INLINE339 = 339,
Expand All @@ -2023,9 +2023,7 @@ enum StylesEnum {
STYLE_ID_INLINE344 = 344,
STYLE_ID_INLINE345 = 345,
STYLE_ID_INLINE346 = 346,
STYLE_ID_INLINE347 = 347,
STYLE_ID_INLINE348 = 348,
STYLE_ID_INLINE349 = 349
STYLE_ID_INLINE347 = 347
};

enum ThemesEnum {
Expand Down Expand Up @@ -2426,4 +2424,4 @@ enum PagesEnum {
PAGE_ID_DIB_DCM224_LABELS_AND_COLORS_CH = 285
};

extern const uint8_t assets[548268];
extern const uint8_t assets[548638];
41,998 changes: 21,006 additions & 20,992 deletions src/eez/gui/document_stm32.cpp

Large diffs are not rendered by default.

60 changes: 29 additions & 31 deletions src/eez/gui/document_stm32.h
Original file line number Diff line number Diff line change
Expand Up @@ -1944,38 +1944,36 @@ enum StylesEnum {
STYLE_ID_INLINE296 = 296,
STYLE_ID_INLINE297 = 297,
STYLE_ID_INLINE298 = 298,
STYLE_ID_INLINE299 = 299,
STYLE_ID_MON_VALUE_48_RIGHT = 299,
STYLE_ID_INLINE300 = 300,
STYLE_ID_MON_VALUE_48_RIGHT = 301,
STYLE_ID_INLINE302 = 302,
STYLE_ID_MON_VALUE_20_LEFT = 303,
STYLE_ID_BAR_GRAPH_U_DEFAULT = 304,
STYLE_ID_BAR_GRAPH_TEXT = 305,
STYLE_ID_BAR_GRAPH_SET_LINE = 306,
STYLE_ID_BAR_GRAPH_LIMIT_LINE = 307,
STYLE_ID_BAR_GRAPH_I_DEFAULT = 308,
STYLE_ID_LABELS_AND_COLORS_CHANNEL = 309,
STYLE_ID_MON_VALUE_20_LEFT = 301,
STYLE_ID_BAR_GRAPH_U_DEFAULT = 302,
STYLE_ID_BAR_GRAPH_TEXT = 303,
STYLE_ID_BAR_GRAPH_SET_LINE = 304,
STYLE_ID_BAR_GRAPH_LIMIT_LINE = 305,
STYLE_ID_BAR_GRAPH_I_DEFAULT = 306,
STYLE_ID_LABELS_AND_COLORS_CHANNEL = 307,
STYLE_ID_INLINE308 = 308,
STYLE_ID_TRIGGER_BUTTON_24 = 309,
STYLE_ID_INLINE310 = 310,
STYLE_ID_TRIGGER_BUTTON_24 = 311,
STYLE_ID_INLINE312 = 312,
STYLE_ID_INLINE313 = 313,
STYLE_ID_CHANNEL_OFF_BUTTON_38 = 314,
STYLE_ID_TRIGGER_BUTTON_14 = 315,
STYLE_ID_MON_VALUE_38_RIGHT = 316,
STYLE_ID_INLINE317 = 317,
STYLE_ID_CH_PROT_OFF = 318,
STYLE_ID_CH_PROT_ON = 319,
STYLE_ID_CH_PROT_TRIPPED = 320,
STYLE_ID_INLINE321 = 321,
STYLE_ID_MON_VALUE_20_RIGHT = 322,
STYLE_ID_MON_VALUE_14_LEFT = 323,
STYLE_ID_MON_VALUE_14_CENTER = 324,
STYLE_ID_ENCODER_CURSOR_14_RIGHT_ENABLED = 325,
STYLE_ID_CHANNEL_OFF_BUTTON_20 = 326,
STYLE_ID_MON_VALUE_14_RIGHT = 327,
STYLE_ID_CHANNEL_OFF_BUTTON_14 = 328,
STYLE_ID_MON_VALUE_24_RIGHT = 329,
STYLE_ID_INLINE330 = 330
STYLE_ID_INLINE311 = 311,
STYLE_ID_CHANNEL_OFF_BUTTON_38 = 312,
STYLE_ID_TRIGGER_BUTTON_14 = 313,
STYLE_ID_MON_VALUE_38_RIGHT = 314,
STYLE_ID_INLINE315 = 315,
STYLE_ID_CH_PROT_OFF = 316,
STYLE_ID_CH_PROT_ON = 317,
STYLE_ID_CH_PROT_TRIPPED = 318,
STYLE_ID_INLINE319 = 319,
STYLE_ID_MON_VALUE_20_RIGHT = 320,
STYLE_ID_MON_VALUE_14_LEFT = 321,
STYLE_ID_MON_VALUE_14_CENTER = 322,
STYLE_ID_ENCODER_CURSOR_14_RIGHT_ENABLED = 323,
STYLE_ID_CHANNEL_OFF_BUTTON_20 = 324,
STYLE_ID_MON_VALUE_14_RIGHT = 325,
STYLE_ID_CHANNEL_OFF_BUTTON_14 = 326,
STYLE_ID_MON_VALUE_24_RIGHT = 327,
STYLE_ID_INLINE328 = 328
};

enum ThemesEnum {
Expand Down Expand Up @@ -2365,4 +2363,4 @@ enum PagesEnum {
PAGE_ID_DIB_DCM224_LABELS_AND_COLORS_CH = 274
};

extern const uint8_t assets[339813];
extern const uint8_t assets[340035];
16 changes: 8 additions & 8 deletions src/eez/modules/dib-dcp405/dib-dcp405.eez-project
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,9 @@
},
"data": "channel_display_value3",
"left": 0,
"top": 204,
"top": 205,
"width": 116,
"height": 32,
"height": 31,
"displayOption": 0
},
{
Expand All @@ -740,9 +740,9 @@
"data": "channel_u_edit",
"action": "edit",
"left": 0,
"top": 170,
"top": 172,
"width": 116,
"height": 32,
"height": 31,
"displayOption": 0
},
{
Expand All @@ -753,9 +753,9 @@
"data": "channel_i_edit",
"action": "edit",
"left": 118,
"top": 170,
"top": 172,
"width": 116,
"height": 32,
"height": 31,
"displayOption": 0
},
{
Expand All @@ -766,9 +766,9 @@
"data": "channel_protection_opp_limit",
"action": "edit",
"left": 118,
"top": 204,
"top": 205,
"width": 116,
"height": 32,
"height": 31,
"displayOption": 0
}
],
Expand Down
77 changes: 40 additions & 37 deletions src/eez/modules/dib-mio168/dib-mio168.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ using namespace eez::gui;
extern "C" DWORD get_fattime(void);
#endif

volatile uint32_t g_debugVar;

namespace eez {
namespace dib_mio168 {

Expand Down Expand Up @@ -1309,6 +1307,7 @@ struct Mio168Module : public Module {

uint8_t afeVersion;

bool powerDown = false;
bool synchronized = false;

uint32_t input[(sizeof(Request) + 3) / 4 + 1];
Expand All @@ -1320,6 +1319,7 @@ struct Mio168Module : public Module {

uint32_t lastTransferTime = 0;
SetParams lastTransferredParams;
bool forceTransferSetParams;

struct CommandDef {
uint32_t command;
Expand Down Expand Up @@ -1453,13 +1453,9 @@ struct Mio168Module : public Module {
}

void initChannels() override {
if (!synchronized) {
// give some time for MIO168 module to boot
auto t = millis();
if (t < 1700) {
osDelay(1700 - t);
}
powerDown = false;

if (!synchronized) {
executeCommand(&getInfo_command);

if (!g_isBooted) {
Expand All @@ -1478,7 +1474,7 @@ struct Mio168Module : public Module {
}
}

memset(&lastTransferredParams, 0, sizeof(SetParams));
forceTransferSetParams = true;
}
}

Expand Down Expand Up @@ -1568,37 +1564,37 @@ struct Mio168Module : public Module {
void fillSetParams(SetParams &params) {
memset(&params, 0, sizeof(SetParams));

params.dinRanges = dinChannel.m_pinRanges;
params.dinSpeeds = dinChannel.m_pinSpeeds;
params.dinRanges = dinChannel.m_pinRanges;
params.dinSpeeds = dinChannel.m_pinSpeeds;

params.doutStates = doutChannel.m_pinStates;
params.doutStates = doutChannel.m_pinStates;

for (int i = 0; i < 4; i++) {
auto channel = &ainChannels[i];
params.ain[i].mode = channel->m_mode;
params.ain[i].range = channel->m_mode == MEASURE_MODE_VOLTAGE ? channel->getVoltageRange() : channel->getCurrentRange();
params.ain[i].nplc = channel->ongoingCal ? 25.0f : (channel->m_mode == MEASURE_MODE_VOLTAGE ? channel->m_voltageNPLC : channel->m_currentNPLC);
}
for (int i = 0; i < 4; i++) {
auto channel = &ainChannels[i];
params.ain[i].mode = channel->m_mode;
params.ain[i].range = channel->m_mode == MEASURE_MODE_VOLTAGE ? channel->getVoltageRange() : channel->getCurrentRange();
params.ain[i].nplc = channel->ongoingCal ? 25.0f : (channel->m_mode == MEASURE_MODE_VOLTAGE ? channel->m_voltageNPLC : channel->m_currentNPLC);
}

params.powerLineFrequency = persist_conf::getPowerLineFrequency();
params.powerLineFrequency = persist_conf::getPowerLineFrequency();

for (int i = 0; i < 2; i++) {
auto channel = &aoutDac7760Channels[i];
params.aout_dac7760[i].outputEnabled = channel->m_outputEnabled;
params.aout_dac7760[i].outputRange = channel->getMode() == SOURCE_MODE_VOLTAGE ? channel->getVoltageRange() : channel->getCurrentRange();
params.aout_dac7760[i].outputValue = channel->getCalibratedValue();
}
for (int i = 0; i < 2; i++) {
auto channel = &aoutDac7760Channels[i];
params.aout_dac7760[i].outputEnabled = !powerDown && channel->m_outputEnabled;
params.aout_dac7760[i].outputRange = channel->getMode() == SOURCE_MODE_VOLTAGE ? channel->getVoltageRange() : channel->getCurrentRange();
params.aout_dac7760[i].outputValue = channel->getCalibratedValue();
}

for (int i = 0; i < 2; i++) {
auto channel = &aoutDac7563Channels[i];
params.aout_dac7563[i].voltage = channel->getCalibratedValue();
}
for (int i = 0; i < 2; i++) {
auto channel = &aoutDac7563Channels[i];
params.aout_dac7563[i].voltage = powerDown ? 0 : channel->getCalibratedValue();
}

for (int i = 0; i < 2; i++) {
auto channel = &pwmChannels[i];
params.pwm[i].freq = channel->m_freq;
params.pwm[i].duty = channel->m_duty;
}
for (int i = 0; i < 2; i++) {
auto channel = &pwmChannels[i];
params.pwm[i].freq = powerDown ? 0 : channel->m_freq;
params.pwm[i].duty = powerDown ? 0 : channel->m_duty;
}
}

void Command_SetParams_FillRequest(Request &request) {
Expand Down Expand Up @@ -1793,6 +1789,10 @@ struct Mio168Module : public Module {
(this->*currentCommand->done)(response, isSuccess);
}

if (powerDown) {
synchronized = false;
}

currentCommand = nullptr;
setState(STATE_IDLE);
}
Expand All @@ -1806,7 +1806,6 @@ struct Mio168Module : public Module {
if (event == EVENT_DMA_TRANSFER_COMPLETED) {
numCrcErrors = 0;
numTransferErrors = 0;
g_debugVar= 0;
}

if (state == STATE_WAIT_SLAVE_READY_BEFORE_REQUEST) {
Expand Down Expand Up @@ -1877,7 +1876,6 @@ struct Mio168Module : public Module {
// DebugTrace("Slot %d SPI transfer error %d no. %d\n", slotIndex + 1, status, numTransferErrors);
//}
}
g_debugVar++;
}

void tick() override {
Expand Down Expand Up @@ -1966,6 +1964,9 @@ struct Mio168Module : public Module {
} else if (tickCountMs - lastRefreshTime >= getRefreshTimeMs()) {
refreshStartTime = tickCountMs;
executeCommand(&getState_command);
} else if (forceTransferSetParams) {
forceTransferSetParams = false;
executeCommand(&setParams_command);
} else {
SetParams params;
fillSetParams(params);
Expand Down Expand Up @@ -1999,7 +2000,9 @@ struct Mio168Module : public Module {
}

void onPowerDown() override {
synchronized = false;
powerDown = true;
executeCommand(&setParams_command);

#ifdef EEZ_PLATFORM_SIMULATOR
sendMessageToLowPriorityThread(THREAD_MESSAGE_FS_DRIVER_UNLINK, slotIndex, 0);
#endif
Expand Down
Loading

0 comments on commit 50ae72b

Please sign in to comment.