Skip to content

Commit

Permalink
dlog time scale
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Nov 27, 2019
1 parent 384a8d1 commit 5fd6851
Show file tree
Hide file tree
Showing 26 changed files with 901 additions and 476 deletions.
556 changes: 292 additions & 264 deletions modular-psu-firmware.eez-project

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions src/eez/gui/app_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,6 @@ uint32_t AppContext::getCurrentHistoryValuePosition(const Cursor &cursor, uint16
return 0;
}

Value AppContext::getHistoryValue(const Cursor &cursor, uint16_t id, uint32_t position) {
return Value();
}

bool AppContext::isActiveWidget(const WidgetCursor &widgetCursor) {
return false;
}
Expand Down
1 change: 0 additions & 1 deletion src/eez/gui/app_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class AppContext {

virtual uint32_t getNumHistoryValues(uint16_t id);
virtual uint32_t getCurrentHistoryValuePosition(const Cursor &cursor, uint16_t id);
virtual Value getHistoryValue(const Cursor &cursor, uint16_t id, uint32_t position);

virtual bool isActiveWidget(const WidgetCursor &widgetCursor);
virtual void onPageTouch(const WidgetCursor &foundWidget, Event &touchEvent);
Expand Down
36 changes: 23 additions & 13 deletions src/eez/gui/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ void TIME_SECONDS_value_to_text(const Value &value, char *text, int count) {
text[count - 1] = 0;
}

bool compare_YT_DATA_GET_VALUE_FUNCTION_POINTER_value(const Value &a, const Value &b) {
return a.getUInt32() == b.getUInt32();
}

void YT_DATA_GET_VALUE_FUNCTION_POINTER_value_to_text(const Value &value, char *text, int count) {
text[0] = 0;
}

////////////////////////////////////////////////////////////////////////////////

static CompareValueFunction g_compareBuiltInValueFunctions[] = {
Expand All @@ -307,7 +315,8 @@ static CompareValueFunction g_compareBuiltInValueFunctions[] = {
compare_SLOT_INFO_value,
compare_SLOT_INFO2_value,
compare_TEST_RESULT_value,
compare_TIME_SECONDS_value
compare_TIME_SECONDS_value,
compare_YT_DATA_GET_VALUE_FUNCTION_POINTER_value
};

static ValueToTextFunction g_builtInValueToTextFunctions[] = {
Expand All @@ -328,7 +337,8 @@ static ValueToTextFunction g_builtInValueToTextFunctions[] = {
SLOT_INFO_value_to_text,
SLOT_INFO2_value_to_text,
TEST_RESULT_value_to_text,
TIME_SECONDS_value_to_text
TIME_SECONDS_value_to_text,
YT_DATA_GET_VALUE_FUNCTION_POINTER_value_to_text
};

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -660,9 +670,9 @@ int ytDataGetHorzDivisions(const Cursor &cursor, uint16_t id) {
return value.getInt();
}

float ytDataGetPerDiv(const Cursor &cursor, uint16_t id, uint8_t valueIndex) {
float ytDataGetDiv(const Cursor &cursor, uint16_t id, uint8_t valueIndex) {
Value value(valueIndex, VALUE_TYPE_UINT8);
g_dataOperationsFunctions[id](data::DATA_OPERATION_YT_DATA_GET_PER_DIV, (Cursor &)cursor, value);
g_dataOperationsFunctions[id](data::DATA_OPERATION_YT_DATA_GET_DIV, (Cursor &)cursor, value);
return value.getFloat();
}

Expand All @@ -678,10 +688,10 @@ bool ytDataDataValueIsVisible(const Cursor &cursor, uint16_t id, uint8_t valueIn
return value.getInt();
}

Value ytDataGetValue(const Cursor &cursor, uint16_t id, uint32_t position, uint8_t valueIndex) {
Value value(position, VALUE_TYPE_UINT32);
g_dataOperationsFunctions[id]((DataOperationEnum)(data::DATA_OPERATION_YT_DATA_GET_VALUE1 + valueIndex), (Cursor &)cursor, value);
return value;
Value::YtDataGetValueFunctionPointer ytDataGetGetValueFunc(const Cursor &cursor, uint16_t id) {
Value value;
g_dataOperationsFunctions[id](data::DATA_OPERATION_YT_DATA_GET_GET_VALUE_FUNC, (Cursor &)cursor, value);
return value.getYtDataGetValueFunctionPointer();
}

uint8_t ytDataGetGraphUpdateMethod(const Cursor &cursor, uint16_t id) {
Expand All @@ -708,17 +718,17 @@ uint32_t ytDataGetCursorOffset(const Cursor &cursor, uint16_t id) {
return value.getUInt32();
}

void ytDataSetCursorOffset(const Cursor &cursor, uint16_t id, uint32_t newCursorOffset) {
Value value(newCursorOffset, VALUE_TYPE_UINT32);
g_dataOperationsFunctions[id](data::DATA_OPERATION_YT_DATA_SET_CURSOR_OFFSET, (Cursor &)cursor, value);
}

Value ytDataGetCursorTime(const Cursor &cursor, uint16_t id) {
Value value;
g_dataOperationsFunctions[id](data::DATA_OPERATION_YT_DATA_GET_CURSOR_TIME, (Cursor &)cursor, value);
return value;
}

void ytDataTouchDrag(const Cursor &cursor, uint16_t id, TouchDrag *touchDrag) {
Value value = Value(touchDrag, VALUE_TYPE_POINTER);
g_dataOperationsFunctions[id](data::DATA_OPERATION_YT_DATA_TOUCH_DRAG, (Cursor &)cursor, value);
}

} // namespace data
} // namespace gui
} // namespace eez
Expand Down
37 changes: 26 additions & 11 deletions src/eez/gui/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <stdint.h>

#include <eez/unit.h>
#include <eez/gui/event.h>

namespace eez {

Expand All @@ -43,6 +44,7 @@ enum BuiltInValueType {
VALUE_TYPE_SLOT_INFO2,
VALUE_TYPE_TEST_RESULT,
VALUE_TYPE_TIME_SECONDS,
VALUE_TYPE_YT_DATA_GET_VALUE_FUNCTION_POINTER,
VALUE_TYPE_USER,
};

Expand Down Expand Up @@ -144,6 +146,13 @@ struct Value {
{
}

typedef float (*YtDataGetValueFunctionPointer)(int rowIndex, int columnIndex, float *max);

Value(YtDataGetValueFunctionPointer ytDataGetValueFunctionPointer)
: type_(VALUE_TYPE_YT_DATA_GET_VALUE_FUNCTION_POINTER), pVoid_((void *)ytDataGetValueFunctionPointer)
{
}

bool operator==(const Value &other) const;

bool operator!=(const Value &other) const {
Expand Down Expand Up @@ -219,6 +228,10 @@ struct Value {
return (AppContext *)pVoid_;
}

YtDataGetValueFunctionPointer getYtDataGetValueFunctionPointer() const {
return (YtDataGetValueFunctionPointer)pVoid_;
}

uint8_t getFirstUInt8() const {
return pairOfUint8_.first;
}
Expand Down Expand Up @@ -307,7 +320,6 @@ enum DataOperationEnum {
DATA_OPERATION_GET_LIMIT,
DATA_OPERATION_GET_NAME,
DATA_OPERATION_GET_UNIT,
DATA_OPERATION_GET_HISTORY_VALUE,
DATA_OPERATION_GET_VALUE_LIST,
DATA_OPERATION_GET_FLOAT_LIST_LENGTH,
DATA_OPERATION_GET_FLOAT_LIST,
Expand Down Expand Up @@ -340,19 +352,16 @@ enum DataOperationEnum {
DATA_OPERATION_YT_DATA_GET_MAX,
DATA_OPERATION_YT_DATA_GET_HORZ_DIVISIONS,
DATA_OPERATION_YT_DATA_GET_VERT_DIVISIONS,
DATA_OPERATION_YT_DATA_GET_PER_DIV,
DATA_OPERATION_YT_DATA_GET_DIV,
DATA_OPERATION_YT_DATA_GET_OFFSET,
DATA_OPERATION_YT_DATA_VALUE_IS_VISIBLE,
DATA_OPERATION_YT_DATA_GET_VALUE1,
DATA_OPERATION_YT_DATA_GET_VALUE2,
DATA_OPERATION_YT_DATA_GET_VALUE3,
DATA_OPERATION_YT_DATA_GET_VALUE4,
DATA_OPERATION_YT_DATA_GET_GET_VALUE_FUNC,
DATA_OPERATION_YT_DATA_GET_GRAPH_UPDATE_METHOD,
DATA_OPERATION_YT_DATA_GET_PERIOD,
DATA_OPERATION_YT_DATA_IS_CURSOR_VISIBLE,
DATA_OPERATION_YT_DATA_GET_CURSOR_OFFSET,
DATA_OPERATION_YT_DATA_SET_CURSOR_OFFSET,
DATA_OPERATION_YT_DATA_GET_CURSOR_TIME
DATA_OPERATION_YT_DATA_GET_CURSOR_TIME,
DATA_OPERATION_YT_DATA_TOUCH_DRAG
};

int count(uint16_t id);
Expand Down Expand Up @@ -395,17 +404,23 @@ Value ytDataGetMin(const Cursor &cursor, uint16_t id, uint8_t valueIndex);
Value ytDataGetMax(const Cursor &cursor, uint16_t id, uint8_t valueIndex);
int ytDataGetVertDivisions(const Cursor &cursor, uint16_t id);
int ytDataGetHorzDivisions(const Cursor &cursor, uint16_t id);
float ytDataGetPerDiv(const Cursor &cursor, uint16_t id, uint8_t valueIndex);
float ytDataGetDiv(const Cursor &cursor, uint16_t id, uint8_t valueIndex);
float ytDataGetOffset(const Cursor &cursor, uint16_t id, uint8_t valueIndex);
bool ytDataDataValueIsVisible(const Cursor &cursor, uint16_t id, uint8_t valueIndex);
Value ytDataGetValue(const Cursor &cursor, uint16_t id, uint32_t position, uint8_t valueIndex);
Value::YtDataGetValueFunctionPointer ytDataGetGetValueFunc(const Cursor &cursor, uint16_t id);
uint8_t ytDataGetGraphUpdateMethod(const Cursor &cursor, uint16_t id);
float ytDataGetPeriod(const Cursor &cursor, uint16_t id);
bool ytDataIsCursorVisible(const Cursor &cursor, uint16_t id);
uint32_t ytDataGetCursorOffset(const Cursor &cursor, uint16_t id);
void ytDataSetCursorOffset(const Cursor &cursor, uint16_t id, uint32_t newCursorOffset);
Value ytDataGetCursorTime(const Cursor &cursor, uint16_t id);

struct TouchDrag {
EventType type;
int x;
int y;
};
void ytDataTouchDrag(const Cursor &cursor, uint16_t id, TouchDrag *touchDrag);

} // namespace data
} // namespace gui
} // namespace eez
3 changes: 2 additions & 1 deletion src/eez/gui/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <assert.h>
#include <cstddef>
#include <limits.h>

#include <eez/debug.h>
#include <eez/system.h>
Expand Down Expand Up @@ -335,7 +336,7 @@ void findWidgetStep(const WidgetCursor &widgetCursor) {
return;
}
g_foundWidget = widgetCursor;
g_distanceToFoundWidget = distance;
g_distanceToFoundWidget = INT_MAX;
} else {
if (!g_foundWidget || distance <= g_distanceToFoundWidget || g_foundWidget.widget->type == WIDGET_TYPE_APP_VIEW) {
g_foundWidget = widgetCursor;
Expand Down
1 change: 1 addition & 0 deletions src/eez/gui/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ void drawWidgetCallback(const WidgetCursor &widgetCursor);

OnTouchFunctionType getTouchFunction(const WidgetCursor &widgetCursor);

uint16_t overrideStyleHook(const WidgetCursor &widgetCursor, uint16_t styleId);
uint16_t overrideStyleColorHook(const WidgetCursor &widgetCursor, const Style *style);
uint16_t overrideActiveStyleColorHook(const WidgetCursor &widgetCursor, const Style *style);

Expand Down
2 changes: 2 additions & 0 deletions src/eez/gui/widgets/bar_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ void BarGraphWidget_draw(const WidgetCursor &widgetCursor) {
pText = pValue;
} else {
textStyle.background_color = fg;
textStyle.color = textStyle.active_color;
wText += padding;
pText = pValue - wText;
}
Expand Down Expand Up @@ -260,6 +261,7 @@ void BarGraphWidget_draw(const WidgetCursor &widgetCursor) {
pText = pValue;
} else {
textStyle.background_color = fg;
textStyle.color = textStyle.active_color;
hText += padding;
pText = pValue - hText;
}
Expand Down
2 changes: 1 addition & 1 deletion src/eez/gui/widgets/display_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void DisplayDataWidget_draw(const WidgetCursor &widgetCursor) {
widgetCursor.currentState->size = sizeof(DisplayDataState);
widgetCursor.currentState->flags.focused = g_appContext->isFocusWidget(widgetCursor);

const Style *style = getStyle(widgetCursor.currentState->flags.focused ? display_data_widget->focusStyle : widget->style);
const Style *style = getStyle(overrideStyleHook(widgetCursor, widgetCursor.currentState->flags.focused ? display_data_widget->focusStyle : widget->style));

widgetCursor.currentState->flags.blinking = g_isBlinkTime && data::isBlinking(widgetCursor.cursor, widget->data);
widgetCursor.currentState->data = data::get(widgetCursor.cursor, widget->data);
Expand Down
Loading

0 comments on commit 5fd6851

Please sign in to comment.