Skip to content

Commit 9bddaf8

Browse files
committed
1 parent 5645a1d commit 9bddaf8

File tree

4 files changed

+52
-15
lines changed

4 files changed

+52
-15
lines changed

src/eez/firmware.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ void boot() {
124124

125125
psu::ontime::g_mcuCounter.init();
126126

127+
int numInstalledModules = 0;
127128
for (uint8_t slotIndex = 0; slotIndex < NUM_SLOTS; slotIndex++) {
128129
static const uint16_t ADDRESS = 0;
129130
uint16_t value[3];
@@ -142,6 +143,42 @@ void boot() {
142143
if (moduleType != MODULE_TYPE_NONE) {
143144
psu::persist_conf::loadModuleConf(slotIndex);
144145
psu::ontime::g_moduleCounters[slotIndex].init();
146+
147+
numInstalledModules++;
148+
}
149+
}
150+
151+
if (numInstalledModules == 1) {
152+
g_isCol2Mode = true;
153+
154+
if (g_slots[0]->moduleInfo->moduleType == MODULE_TYPE_NONE) {
155+
int i;
156+
for (i = 1; i < NUM_SLOTS; i++) {
157+
if (g_slots[i]->moduleInfo->moduleType != MODULE_TYPE_NONE) {
158+
g_slotIndexes[0] = i - 1;
159+
g_slotIndexes[1] = i;
160+
break;
161+
}
162+
}
163+
164+
int k = 0;
165+
for (int j = 0; j < i - 1; j++) {
166+
g_slotIndexes[k++] = j;
167+
}
168+
for (int j = i + 1; j < NUM_SLOTS; j++) {
169+
g_slotIndexes[k++] = j;
170+
}
171+
}
172+
} else if (numInstalledModules == 2) {
173+
g_isCol2Mode = true;
174+
175+
int j = 0;
176+
for (int i = 0; i < NUM_SLOTS; i++) {
177+
if (g_slots[i]->moduleInfo->moduleType != MODULE_TYPE_NONE) {
178+
g_slotIndexes[j++] = i;
179+
} else {
180+
g_slotIndexes[2] = i;
181+
}
145182
}
146183
}
147184

src/eez/index.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434

3535
namespace eez {
3636

37+
bool g_isCol2Mode = false;
38+
int g_slotIndexes[3] = { 0, 1, 2 };
39+
3740
ModuleInfo::ModuleInfo(uint16_t moduleType_, uint16_t moduleCategory_, const char *moduleName_, const char *moduleBrand_, uint16_t latestModuleRevision_, FlashMethod flashMethod_, uint32_t flashDuration_, uint32_t spiBaudRatePrescaler_, bool spiCrcCalculationEnable_)
3841
: moduleType(moduleType_)
3942
, moduleCategory(moduleCategory_)

src/eez/index.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,7 @@ ModuleInfo *getModuleInfo(uint16_t moduleType);
101101

102102
void getModuleSerialInfo(uint8_t slotIndex, char *text);
103103

104+
extern bool g_isCol2Mode;
105+
extern int g_slotIndexes[NUM_SLOTS];
106+
104107
} // namespace eez

src/eez/modules/psu/gui/data.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,15 +1420,9 @@ void data_channels_is_max_view(DataOperationEnum operation, Cursor cursor, Value
14201420
}
14211421
}
14221422

1423-
bool is2ColMode() {
1424-
return g_slots[0]->moduleInfo->moduleType != MODULE_TYPE_NONE &&
1425-
g_slots[1]->moduleInfo->moduleType != MODULE_TYPE_NONE &&
1426-
g_slots[2]->moduleInfo->moduleType == MODULE_TYPE_NONE;
1427-
}
1428-
14291423
void data_channels_is_2col_view(DataOperationEnum operation, Cursor cursor, Value &value) {
14301424
if (operation == DATA_OPERATION_GET) {
1431-
value = is2ColMode();
1425+
value = g_isCol2Mode;
14321426
}
14331427
}
14341428

@@ -1531,15 +1525,15 @@ void data_slot_channel_index(int slotIndex, DataOperationEnum operation, Cursor
15311525
}
15321526

15331527
void data_slot1_channel_index(DataOperationEnum operation, Cursor cursor, Value &value) {
1534-
data_slot_channel_index(0, operation, cursor, value);
1528+
data_slot_channel_index(g_slotIndexes[0], operation, cursor, value);
15351529
}
15361530

15371531
void data_slot2_channel_index(DataOperationEnum operation, Cursor cursor, Value &value) {
1538-
data_slot_channel_index(1, operation, cursor, value);
1532+
data_slot_channel_index(g_slotIndexes[1], operation, cursor, value);
15391533
}
15401534

15411535
void data_slot3_channel_index(DataOperationEnum operation, Cursor cursor, Value &value) {
1542-
data_slot_channel_index(2, operation, cursor, value);
1536+
data_slot_channel_index(g_slotIndexes[2], operation, cursor, value);
15431537
}
15441538

15451539
void data_slot_max_channel_index(DataOperationEnum operation, Cursor cursor, Value &value) {
@@ -1571,20 +1565,20 @@ void data_slot_min2_channel_index(DataOperationEnum operation, Cursor cursor, Va
15711565

15721566
void data_slot_default_view(int slotIndex, DataOperationEnum operation, Cursor cursor, Value &value) {
15731567
if (operation == DATA_OPERATION_GET) {
1574-
value = getSlotView(is2ColMode() ? SLOT_VIEW_TYPE_DEFAULT_2COL : SLOT_VIEW_TYPE_DEFAULT, slotIndex, cursor);
1568+
value = getSlotView(g_isCol2Mode ? SLOT_VIEW_TYPE_DEFAULT_2COL : SLOT_VIEW_TYPE_DEFAULT, slotIndex, cursor);
15751569
}
15761570
}
15771571

15781572
void data_slot1_default_view(DataOperationEnum operation, Cursor cursor, Value &value) {
1579-
data_slot_default_view(0, operation, cursor, value);
1573+
data_slot_default_view(g_slotIndexes[0], operation, cursor, value);
15801574
}
15811575

15821576
void data_slot2_default_view(DataOperationEnum operation, Cursor cursor, Value &value) {
1583-
data_slot_default_view(1, operation, cursor, value);
1577+
data_slot_default_view(g_slotIndexes[1], operation, cursor, value);
15841578
}
15851579

15861580
void data_slot3_default_view(DataOperationEnum operation, Cursor cursor, Value &value) {
1587-
data_slot_default_view(2, operation, cursor, value);
1581+
data_slot_default_view(g_slotIndexes[2], operation, cursor, value);
15881582
}
15891583

15901584
void data_slot_max_view(DataOperationEnum operation, Cursor cursor, Value &value) {
@@ -1635,7 +1629,7 @@ void data_slot_def_2ch_view(DataOperationEnum operation, Cursor cursor, Value &v
16351629
if (operation == DATA_OPERATION_GET) {
16361630
Channel &channel = Channel::get(cursor);
16371631
int isVert = persist_conf::devConf.channelsViewMode == CHANNELS_VIEW_MODE_NUMERIC || persist_conf::devConf.channelsViewMode == CHANNELS_VIEW_MODE_VERT_BAR;
1638-
if (is2ColMode()) {
1632+
if (g_isCol2Mode) {
16391633
value = channel.isOutputEnabled() ?
16401634
(isVert ? PAGE_ID_SLOT_DEF_2CH_VERT_ON_2COL : PAGE_ID_SLOT_DEF_2CH_HORZ_ON_2COL) :
16411635
(isVert ? PAGE_ID_SLOT_DEF_2CH_VERT_OFF_2COL : PAGE_ID_SLOT_DEF_2CH_HORZ_OFF_2COL);

0 commit comments

Comments
 (0)