Skip to content

Commit

Permalink
fix emscripten build
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Nov 30, 2022
1 parent c51fa2b commit 8782700
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
30 changes: 15 additions & 15 deletions src/eez/function_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ float getMax(WaveformParameters &waveformParameters) {

class FunctionGeneratorPage : public SetPage {
public:
static const int PAGE_SIZE = 4;
static const int FUNC_GEN_PAGE_SIZE = 4;

bool m_initialized = false;

Expand Down Expand Up @@ -698,14 +698,14 @@ class FunctionGeneratorPage : public SetPage {
}

void setScrollPosition(int scrollPosition) {
if (g_selectedResources.m_numResources <= PAGE_SIZE) {
if (g_selectedResources.m_numResources <= FUNC_GEN_PAGE_SIZE) {
return;
}

if (scrollPosition < 0) {
scrollPosition = 0;
} else if (scrollPosition > g_selectedResources.m_numResources - PAGE_SIZE) {
scrollPosition = g_selectedResources.m_numResources - PAGE_SIZE;
} else if (scrollPosition > g_selectedResources.m_numResources - FUNC_GEN_PAGE_SIZE) {
scrollPosition = g_selectedResources.m_numResources - FUNC_GEN_PAGE_SIZE;
}

if (scrollPosition != m_scrollPosition) {
Expand Down Expand Up @@ -773,7 +773,7 @@ void initWaveformParameters(WaveformParameters &waveformParameters) {

class FunctionGeneratorSelectChannelsPage : public SetPage {
public:
static const int PAGE_SIZE = 7;
static const int FUNC_GEN_PAGE_SIZE = 7;

void pageAlloc() {
AllResources::reset();
Expand Down Expand Up @@ -839,14 +839,14 @@ class FunctionGeneratorSelectChannelsPage : public SetPage {
}

void setScrollPosition(int scrollPosition) {
if (AllResources::getNumResources() <= PAGE_SIZE) {
if (AllResources::getNumResources() <= FUNC_GEN_PAGE_SIZE) {
return;
}

if (scrollPosition < 0) {
scrollPosition = 0;
} else if (scrollPosition > AllResources::getNumResources() - PAGE_SIZE) {
scrollPosition = AllResources::getNumResources() - PAGE_SIZE;
} else if (scrollPosition > AllResources::getNumResources() - FUNC_GEN_PAGE_SIZE) {
scrollPosition = AllResources::getNumResources() - FUNC_GEN_PAGE_SIZE;
}

if (scrollPosition != m_scrollPosition) {
Expand Down Expand Up @@ -1180,8 +1180,8 @@ void selectWaveformParametersForChannel(int slotIndex, int subchannelIndex, int
if (tmpSlotIndex == slotIndex && tmpSubchannelIndex == subchannelIndex && (resourceIndex == -1 || tmpResourceIndex == resourceIndex)) {
g_functionGeneratorPage.m_selectedItem = i;

if (i >= FunctionGeneratorPage::PAGE_SIZE) {
g_functionGeneratorPage.setScrollPosition(i - FunctionGeneratorPage::PAGE_SIZE + 1);
if (i >= FunctionGeneratorPage::FUNC_GEN_PAGE_SIZE) {
g_functionGeneratorPage.setScrollPosition(i - FunctionGeneratorPage::FUNC_GEN_PAGE_SIZE + 1);
}

break;
Expand Down Expand Up @@ -2118,26 +2118,26 @@ void data_function_generator_channels(DataOperationEnum operation, Cursor cursor
} else if (operation == DATA_OPERATION_YT_DATA_GET_POSITION_INCREMENT) {
value = 1;
} else if (operation == DATA_OPERATION_YT_DATA_GET_PAGE_SIZE) {
value = FunctionGeneratorPage::PAGE_SIZE;
value = FunctionGeneratorPage::FUNC_GEN_PAGE_SIZE;
}
// scrollbar encoder support
else if (operation == DATA_OPERATION_GET) {
value = MakeValue(1.0f * g_functionGeneratorPage.getScrollPosition(), UNIT_NONE);
} else if (operation == DATA_OPERATION_GET_MIN) {
value = MakeValue(0, UNIT_NONE);
} else if (operation == DATA_OPERATION_GET_MAX) {
value = MakeValue(1.0f * (g_functionGeneratorPage.m_selectedResources.m_numResources - FunctionGeneratorPage::PAGE_SIZE), UNIT_NONE);
value = MakeValue(1.0f * (g_functionGeneratorPage.m_selectedResources.m_numResources - FunctionGeneratorPage::FUNC_GEN_PAGE_SIZE), UNIT_NONE);
} else if (operation == DATA_OPERATION_GET_ENCODER_STEP_VALUES) {
auto stepValues = value.getStepValues();

static float values[] = { 1.0f, 1.0f * FunctionGeneratorPage::PAGE_SIZE, 2.0f * FunctionGeneratorPage::PAGE_SIZE, 5.0f * FunctionGeneratorPage::PAGE_SIZE, 10.0f * FunctionGeneratorPage::PAGE_SIZE };
static float values[] = { 1.0f, 1.0f * FunctionGeneratorPage::FUNC_GEN_PAGE_SIZE, 2.0f * FunctionGeneratorPage::FUNC_GEN_PAGE_SIZE, 5.0f * FunctionGeneratorPage::FUNC_GEN_PAGE_SIZE, 10.0f * FunctionGeneratorPage::FUNC_GEN_PAGE_SIZE };

stepValues->values = values;
stepValues->count = sizeof(values) / sizeof(float);
stepValues->unit = UNIT_NONE;

stepValues->encoderSettings.accelerationEnabled = true;
stepValues->encoderSettings.range = 10.0f * FunctionGeneratorPage::PAGE_SIZE;
stepValues->encoderSettings.range = 10.0f * FunctionGeneratorPage::FUNC_GEN_PAGE_SIZE;
stepValues->encoderSettings.step = 1.0f;
stepValues->encoderSettings.mode = edit_mode_step::g_scrollBarEncoderMode;

Expand Down Expand Up @@ -2176,7 +2176,7 @@ void data_function_generator_channels(DataOperationEnum operation, Cursor cursor
} else if (operation == DATA_OPERATION_YT_DATA_GET_POSITION_INCREMENT) {
value = 1;
} else if (operation == DATA_OPERATION_YT_DATA_GET_PAGE_SIZE) {
value = FunctionGeneratorSelectChannelsPage::PAGE_SIZE;
value = FunctionGeneratorSelectChannelsPage::FUNC_GEN_PAGE_SIZE;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/eez/modules/bp3c/eeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ TestResult g_testResult = TEST_FAILED;
////////////////////////////////////////////////////////////////////////////////

#ifdef EEZ_PLATFORM_STM32
const int PAGE_SIZE = 32;
const int EEPROM_PAGE_SIZE = 32;
#endif

bool read(uint8_t slotIndex, uint8_t *buffer, uint16_t bufferSize, uint16_t address) {

#ifdef EEZ_PLATFORM_STM32
for (uint16_t i = 0; i < bufferSize; i += PAGE_SIZE) {
for (uint16_t i = 0; i < bufferSize; i += EEPROM_PAGE_SIZE) {
uint16_t chunkAddress = address + i;

uint16_t chunkSize = MIN(PAGE_SIZE, bufferSize - i);
uint16_t chunkSize = MIN(EEPROM_PAGE_SIZE, bufferSize - i);

uint8_t data[2];
data[0] = I2C_MEM_ADD_MSB(chunkAddress);
Expand Down Expand Up @@ -135,10 +135,10 @@ bool read(uint8_t slotIndex, uint8_t *buffer, uint16_t bufferSize, uint16_t addr
bool write(uint8_t slotIndex, const uint8_t *buffer, uint16_t bufferSize, uint16_t address) {

#ifdef EEZ_PLATFORM_STM32
for (uint16_t i = 0; i < bufferSize; i += PAGE_SIZE) {
for (uint16_t i = 0; i < bufferSize; i += EEPROM_PAGE_SIZE) {
uint16_t chunkAddress = address + i;

uint16_t chunkSize = MIN(PAGE_SIZE, bufferSize - i);
uint16_t chunkSize = MIN(EEPROM_PAGE_SIZE, bufferSize - i);

const uint16_t eepromAddress = EEPROM_ADDRESS[slotIndex];

Expand All @@ -154,7 +154,7 @@ bool write(uint8_t slotIndex, const uint8_t *buffer, uint16_t bufferSize, uint16
delay(5);

// verify
uint8_t verify[PAGE_SIZE];
uint8_t verify[EEPROM_PAGE_SIZE];

uint8_t data[2];
data[0] = I2C_MEM_ADD_MSB(chunkAddress);
Expand Down
12 changes: 6 additions & 6 deletions src/eez/modules/psu/dlog_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ unsigned Parameters::setPeriod(float value) {
class DlogParamsPage : public SetPage {
public:
static Parameters g_parameters;
static const int PAGE_SIZE = 6;
static const int DLOG_VIEW_PAGE_SIZE = 6;
static int g_scrollPosition;
static float g_minPeriod;

Expand Down Expand Up @@ -1636,14 +1636,14 @@ class DlogParamsPage : public SetPage {
}

static void setScrollPosition(int scrollPosition) {
if (g_numDlogResources <= PAGE_SIZE) {
if (g_numDlogResources <= DLOG_VIEW_PAGE_SIZE) {
return;
}

if (scrollPosition < 0) {
scrollPosition = 0;
} else if (scrollPosition > g_numDlogResources - PAGE_SIZE) {
scrollPosition = g_numDlogResources - PAGE_SIZE;
} else if (scrollPosition > g_numDlogResources - DLOG_VIEW_PAGE_SIZE) {
scrollPosition = g_numDlogResources - DLOG_VIEW_PAGE_SIZE;
}

if (scrollPosition != DlogParamsPage::g_scrollPosition) {
Expand Down Expand Up @@ -1911,7 +1911,7 @@ void data_recording_ready(DataOperationEnum operation, Cursor cursor, Value &val

void data_dlog_items_scrollbar_enabled(DataOperationEnum operation, Cursor cursor, Value &value) {
if (operation == DATA_OPERATION_GET) {
value = DlogParamsPage::getNumDlogResources() > DlogParamsPage::PAGE_SIZE;
value = DlogParamsPage::getNumDlogResources() > DlogParamsPage::DLOG_VIEW_PAGE_SIZE;
}
}

Expand Down Expand Up @@ -1952,7 +1952,7 @@ void data_dlog_items(DataOperationEnum operation, Cursor cursor, Value &value) {
} else if (operation == DATA_OPERATION_YT_DATA_GET_POSITION_INCREMENT) {
value = 1;
} else if (operation == DATA_OPERATION_YT_DATA_GET_PAGE_SIZE) {
value = DlogParamsPage::PAGE_SIZE;
value = DlogParamsPage::DLOG_VIEW_PAGE_SIZE;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/eez/modules/psu/gui/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5609,7 +5609,7 @@ void data_ramp_and_delay_list(DataOperationEnum operation, Cursor cursor, Value
return;
}

static const int PAGE_SIZE = 4;
static const int RAMP_AND_DELAY_PAGE_SIZE = 4;

if (operation == DATA_OPERATION_COUNT) {
value = CH_NUM;
Expand All @@ -5621,15 +5621,15 @@ void data_ramp_and_delay_list(DataOperationEnum operation, Cursor cursor, Value
int32_t newPosition = value.getUInt32();
if (newPosition < 0) {
page->startChannel = 0;
} else if (newPosition + PAGE_SIZE > CH_NUM) {
page->startChannel = CH_NUM - PAGE_SIZE;
} else if (newPosition + RAMP_AND_DELAY_PAGE_SIZE > CH_NUM) {
page->startChannel = CH_NUM - RAMP_AND_DELAY_PAGE_SIZE;
} else {
page->startChannel = newPosition;
}
} else if (operation == DATA_OPERATION_YT_DATA_GET_POSITION_INCREMENT) {
value = Value(1, VALUE_TYPE_UINT32);
} else if (operation == DATA_OPERATION_YT_DATA_GET_PAGE_SIZE) {
value = Value(PAGE_SIZE, VALUE_TYPE_UINT32);
value = Value(RAMP_AND_DELAY_PAGE_SIZE, VALUE_TYPE_UINT32);
} else if (operation == DATA_OPERATION_SELECT) {
value = Value(g_channel, VALUE_TYPE_POINTER);
selectChannel(&Channel::get(page->startChannel + cursor));
Expand Down

0 comments on commit 8782700

Please sign in to comment.