Skip to content

Commit

Permalink
dlog legend heuristic changed
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Jan 2, 2020
1 parent 8bfe5da commit 4a0dfb1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/eez/modules/psu/dlog_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ int getNumVisibleDlogValues(const Recording &recording);
int getDlogValueIndex(Recording &recording, int visibleDlogValueIndex);
int getVisibleDlogValueIndex(Recording &recording, int dlogValueIndex);
DlogValueParams *getVisibleDlogValueParams(Recording &recording, int visibleDlogValueIndex);

bool yAxisHasDifferentUnits(Recording &recording);
Unit getXAxisUnit(Recording& recording);
Unit getYAxisUnit(Recording& recording, int dlogValueIndex);

Expand Down
16 changes: 8 additions & 8 deletions src/eez/modules/psu/gui/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4633,7 +4633,7 @@ void data_recording(data::DataOperationEnum operation, data::Cursor &cursor, dat
static int yAtTouchDown;

if (g_focusDataId == DATA_ID_DLOG_VISIBLE_VALUE_OFFSET) {
dlog_view::DlogValueParams *dlogValueParams = dlog_view::getVisibleDlogValueParams(recording, dlog_view::getNumVisibleDlogValues(recording) > 4 ? recording.selectedVisibleValueIndex : g_focusCursor.i);
dlog_view::DlogValueParams *dlogValueParams = dlog_view::getVisibleDlogValueParams(recording, !dlog_view::yAxisHasDifferentUnits(recording) ? recording.selectedVisibleValueIndex : g_focusCursor.i);

if (touchDrag->type == EVENT_TYPE_TOUCH_DOWN) {
valueAtTouchDown = dlogValueParams->offset;
Expand All @@ -4649,7 +4649,7 @@ void data_recording(data::DataOperationEnum operation, data::Cursor &cursor, dat
dlogValueParams->offset = newOffset;
}
} else if (g_focusDataId == DATA_ID_DLOG_VISIBLE_VALUE_DIV) {
dlog_view::DlogValueParams *dlogValueParams = dlog_view::getVisibleDlogValueParams(recording, dlog_view::getNumVisibleDlogValues(recording) > 4 ? recording.selectedVisibleValueIndex : g_focusCursor.i);
dlog_view::DlogValueParams *dlogValueParams = dlog_view::getVisibleDlogValueParams(recording, !dlog_view::yAxisHasDifferentUnits(recording) ? recording.selectedVisibleValueIndex : g_focusCursor.i);

if (touchDrag->type == EVENT_TYPE_TOUCH_DOWN) {
valueAtTouchDown = dlogValueParams->div;
Expand Down Expand Up @@ -4752,7 +4752,7 @@ void data_dlog_overlay(data::DataOperationEnum operation, data::Cursor &cursor,
int state = 0;
int numVisibleDlogValues = dlog_view::getNumVisibleDlogValues(recording);

if (dlog_view::g_showLegend && numVisibleDlogValues <= 4) {
if (dlog_view::g_showLegend && dlog_view::yAxisHasDifferentUnits(recording)) {
state = numVisibleDlogValues;
}

Expand Down Expand Up @@ -4799,7 +4799,7 @@ void data_dlog_overlay_over_4(data::DataOperationEnum operation, data::Cursor &c
value = data::Value(&overlay, VALUE_TYPE_POINTER);
} else if (operation == data::DATA_OPERATION_UPDATE_OVERLAY_DATA) {
dlog_view::Recording &recording = dlog_view::getRecording();
overlay.state = dlog_view::g_showLegend && dlog_view::getNumVisibleDlogValues(recording) > 4 ? 1 : 0;
overlay.state = dlog_view::g_showLegend && !dlog_view::yAxisHasDifferentUnits(recording);

WidgetCursor &widgetCursor = *(WidgetCursor *)value.getVoidPointer();
overlay.width = widgetCursor.widget->w;
Expand All @@ -4822,15 +4822,15 @@ void data_dlog_visible_values(data::DataOperationEnum operation, data::Cursor &c
void data_dlog_visible_value_label(data::DataOperationEnum operation, data::Cursor &cursor, data::Value &value) {
if (operation == data::DATA_OPERATION_GET) {
dlog_view::Recording &recording = dlog_view::getRecording();
int dlogValueIndex = dlog_view::getDlogValueIndex(recording, dlog_view::getNumVisibleDlogValues(recording) > 4 ? recording.selectedVisibleValueIndex : cursor.i);
int dlogValueIndex = dlog_view::getDlogValueIndex(recording, !dlog_view::yAxisHasDifferentUnits(recording) ? recording.selectedVisibleValueIndex : cursor.i);
value = Value(dlogValueIndex, VALUE_TYPE_DLOG_VALUE_LABEL);
}
}

void data_dlog_visible_value_div(data::DataOperationEnum operation, data::Cursor &cursor, data::Value &value) {
#if OPTION_SD_CARD
dlog_view::Recording &recording = dlog_view::getRecording();
int dlogValueIndex = dlog_view::getDlogValueIndex(recording, dlog_view::getNumVisibleDlogValues(recording) > 4 ? recording.selectedVisibleValueIndex : cursor.i);
int dlogValueIndex = dlog_view::getDlogValueIndex(recording, !dlog_view::yAxisHasDifferentUnits(recording) ? recording.selectedVisibleValueIndex : cursor.i);

if (operation == data::DATA_OPERATION_GET) {
bool focused = g_focusCursor == cursor && g_focusDataId == DATA_ID_DLOG_VISIBLE_VALUE_DIV;
Expand Down Expand Up @@ -4866,7 +4866,7 @@ void data_dlog_visible_value_div(data::DataOperationEnum operation, data::Cursor
void data_dlog_visible_value_offset(data::DataOperationEnum operation, data::Cursor &cursor, data::Value &value) {
#if OPTION_SD_CARD
dlog_view::Recording &recording = dlog_view::getRecording();
int dlogValueIndex = dlog_view::getDlogValueIndex(recording, dlog_view::getNumVisibleDlogValues(recording) > 4 ? recording.selectedVisibleValueIndex : cursor.i);
int dlogValueIndex = dlog_view::getDlogValueIndex(recording, !dlog_view::yAxisHasDifferentUnits(recording) ? recording.selectedVisibleValueIndex : cursor.i);

if (operation == data::DATA_OPERATION_GET) {
bool focused = g_focusCursor == cursor && g_focusDataId == DATA_ID_DLOG_VISIBLE_VALUE_OFFSET;
Expand Down Expand Up @@ -4985,7 +4985,7 @@ void data_dlog_visible_value_cursor(data::DataOperationEnum operation, data::Cur
#if OPTION_SD_CARD
if (operation == data::DATA_OPERATION_GET) {
dlog_view::Recording &recording = dlog_view::getRecording();
int dlogValueIndex = dlog_view::getDlogValueIndex(recording, dlog_view::getNumVisibleDlogValues(recording) > 4 ? recording.selectedVisibleValueIndex : cursor.i);
int dlogValueIndex = dlog_view::getDlogValueIndex(recording, !dlog_view::yAxisHasDifferentUnits(recording) ? recording.selectedVisibleValueIndex : cursor.i);
auto ytDataGetValue = data::ytDataGetGetValueFunc(cursor, DATA_ID_RECORDING);
float max;
float min = ytDataGetValue(ytDataGetPosition(cursor, DATA_ID_RECORDING) + recording.cursorOffset, dlogValueIndex, &max);
Expand Down
4 changes: 2 additions & 2 deletions src/eez/modules/psu/gui/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ uint16_t overrideStyleHook(const WidgetCursor &widgetCursor, uint16_t styleId) {
uint16_t overrideStyleColorHook(const WidgetCursor &widgetCursor, const Style *style) {
if (widgetCursor.widget->type == WIDGET_TYPE_TEXT && (widgetCursor.widget->data == DATA_ID_DLOG_VALUE_LABEL || widgetCursor.widget->data == DATA_ID_DLOG_VISIBLE_VALUE_LABEL)) {
psu::dlog_view::Recording &recording = psu::dlog_view::getRecording();
int dlogValueIndex = psu::dlog_view::getDlogValueIndex(recording, psu::dlog_view::getNumVisibleDlogValues(recording) > 4 ? recording.selectedVisibleValueIndex : widgetCursor.cursor.i);
int dlogValueIndex = psu::dlog_view::getDlogValueIndex(recording, !psu::dlog_view::yAxisHasDifferentUnits(recording) ? recording.selectedVisibleValueIndex : widgetCursor.cursor.i);
style = ytDataGetStyle(widgetCursor.cursor, DATA_ID_RECORDING, dlogValueIndex);
}
return style->color;
Expand All @@ -1437,7 +1437,7 @@ uint16_t overrideStyleColorHook(const WidgetCursor &widgetCursor, const Style *s
uint16_t overrideActiveStyleColorHook(const WidgetCursor &widgetCursor, const Style *style) {
if (widgetCursor.widget->type == WIDGET_TYPE_TEXT && (widgetCursor.widget->data == DATA_ID_DLOG_VALUE_LABEL || widgetCursor.widget->data == DATA_ID_DLOG_VISIBLE_VALUE_LABEL)) {
psu::dlog_view::Recording &recording = psu::dlog_view::getRecording();
int dlogValueIndex = psu::dlog_view::getDlogValueIndex(recording, psu::dlog_view::getNumVisibleDlogValues(recording) > 4 ? recording.selectedVisibleValueIndex : widgetCursor.cursor.i);
int dlogValueIndex = psu::dlog_view::getDlogValueIndex(recording, !psu::dlog_view::yAxisHasDifferentUnits(recording) ? recording.selectedVisibleValueIndex : widgetCursor.cursor.i);
style = ytDataGetStyle(widgetCursor.cursor, DATA_ID_RECORDING, dlogValueIndex);
}
return style->active_color;
Expand Down

0 comments on commit 4a0dfb1

Please sign in to comment.