Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions main/S3Dash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ void vTask_DataMock(void *pvParameter)
xSemaphoreTake(dash_data_lock, portMAX_DELAY);

dash_data_share.rpm = (dash_data_share.rpm + (2000000 / (dash_data_share.rpm + 1)) - 160) % 7800;
dash_data_share.oil_pressure = dash_data_share.rpm * 0.01 + 10;
dash_data_share.oil_temp = r2 % 250;
dash_data_share.engine_coolant_temp = r3 % 250;
dash_data_share.oil_pressure = dash_data_share.rpm * 0.01;
dash_data_share.oil_temp = r2 % 280;
dash_data_share.engine_coolant_temp = r3 % 280;
dash_data_share.throttle_per = r4 % 100;
dash_data_share.brake_per = r5 % 100;
dash_data_share.steering = r6 % 1800 - 900;
Expand Down
44 changes: 36 additions & 8 deletions main/views/SteeringWheelMountedView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@
#define RPM_INDICATOR_HEIGHT (LCD_V_RES - RPM_INDICATOR_LIGHT_COUNT * (RPM_INDICATOR_GUTTER - 1)) / RPM_INDICATOR_LIGHT_COUNT
#define RPM_INDICATOR_WIDTH 10

uint16_t color_warn_above_threshold(int value, int warning_threshold, int critical_threshold)
{
if (value > critical_threshold)
{
return Color::COLOR_RED;
}
if (value > warning_threshold)
{
return Color::COLOR_YELLOW;
}
return Color::COLOR_WHITE;
}

uint16_t color_warn_below_threshold(int value, int warning_threshold, int critical_threshold)
{
if (value < critical_threshold)
{
return Color::COLOR_RED;
}
if (value < warning_threshold)
{
return Color::COLOR_YELLOW;
}
return Color::COLOR_WHITE;
}

SteeringWheelMountedView::SteeringWheelMountedView(Sprite *renderOn)
{
sprite = renderOn;
Expand All @@ -21,11 +47,11 @@ void SteeringWheelMountedView::LabelView(const char *value, int x, int y)
sprite->drawString(value, x, y);
}

void SteeringWheelMountedView::MetricView(int x, int y, int width, metric_t *metric)
void SteeringWheelMountedView::MetricView(int x, int y, int width, metric_t *metric, uint16_t color)
{
LabelView(metric->label, x, y);

sprite->setTextColor(Color::COLOR_WHITE);
sprite->setTextColor(color);
sprite->setFont(&fonts::Font7);
sprite->setTextSize(.5);

Expand Down Expand Up @@ -100,11 +126,11 @@ void SteeringWheelMountedView::ShiftIndicator(dash_data_t *dash_data)
}
}

void SteeringWheelMountedView::HeroMetricView(int x, int y, int width, metric_t *metric)
void SteeringWheelMountedView::HeroMetricView(int x, int y, int width, metric_t *metric, uint16_t color)
{
LabelView(metric->label, x, y);

sprite->setTextColor(Color::COLOR_WHITE);
sprite->setTextColor(color);
sprite->setFont(&fonts::Font7);
sprite->setTextSize(2);

Expand All @@ -114,6 +140,7 @@ void SteeringWheelMountedView::HeroMetricView(int x, int y, int width, metric_t
void SteeringWheelMountedView::render(dash_data_t *dash_data)
{
sprite->fillScreen(0);

sprite->setColor(Color::COLOR_WHITE);

sprite->progressBarFromBottom(UI_SAFE_ZONE_MARGIN,
Expand All @@ -135,7 +162,8 @@ void SteeringWheelMountedView::render(dash_data_t *dash_data)
metric_t metric;
metric.label = "OILP (PSI)";
metric.value = dash_data->oil_pressure;
HeroMetricView(56, UI_SAFE_ZONE_MARGIN, 172, &metric);

HeroMetricView(56, UI_SAFE_ZONE_MARGIN, 172, &metric, color_warn_below_threshold(metric.value, 30, 10));

int y = UI_SAFE_ZONE_MARGIN;
const int METRIC_START = 238;
Expand All @@ -146,13 +174,13 @@ void SteeringWheelMountedView::render(dash_data_t *dash_data)

metric.label = "OILT (F)";
metric.value = dash_data->oil_temp;
MetricView(METRIC_START, y, METRIC_WIDTH, &metric);
MetricView(METRIC_START, y, METRIC_WIDTH, &metric, color_warn_above_threshold(metric.value, 240, 260));

metric.label = "ECT (F)";
metric.value = dash_data->engine_coolant_temp;
MetricView(METRIC_START, y + METRIC_HEIGHT, METRIC_WIDTH, &metric);
MetricView(METRIC_START, y + METRIC_HEIGHT, METRIC_WIDTH, &metric, color_warn_above_threshold(metric.value, 240, 260));

metric.label = "STEER";
metric.value = dash_data->steering;
MetricView(METRIC_START, y + METRIC_HEIGHT * 2, METRIC_WIDTH, &metric);
MetricView(METRIC_START, y + METRIC_HEIGHT * 2, METRIC_WIDTH, &metric, Color::COLOR_WHITE);
}
4 changes: 2 additions & 2 deletions main/views/SteeringWheelMountedView.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class SteeringWheelMountedView: public DisplayModeView
Sprite *sprite;

void LabelView(const char *value, int x, int y);
void MetricView(int x, int y, int width, metric_t *metric);
void HeroMetricView(int x, int y, int width, metric_t *metric);
void MetricView(int x, int y, int width, metric_t *metric, uint16_t color);
void HeroMetricView(int x, int y, int width, metric_t *metric, uint16_t color);
void ShiftIndicator(dash_data_t *dash_data);
void ShiftRect(int index, uint16_t color);

Expand Down