Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremycote committed Mar 26, 2024
1 parent 3589b36 commit b5a6e39
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 153 deletions.
64 changes: 0 additions & 64 deletions Core/UI/HomeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,74 +25,12 @@ HomeView::HomeView(lv_obj_t* parent, DataAggregator& aggregator) : View(parent,

lv_obj_set_flex_flow(container, LV_FLEX_FLOW_COLUMN);

/* topRow = lv_obj_create(container);
lv_obj_set_width(topRow, lv_obj_get_width(container));
lv_obj_add_style(topRow, styles->GetFullscreenRowStyle(), LV_PART_MAIN);*/

bottomRow = lv_obj_create(container);
lv_obj_set_width(bottomRow, lv_obj_get_width(container));
lv_obj_add_style(bottomRow, styles->GetFullscreenRowStyle(), LV_PART_MAIN);

// lv_obj_set_flex_grow(topRow, 1);
lv_obj_set_flex_grow(bottomRow, 1);

/* lapTimeLabel = lv_label_create(bottomRow);
lv_label_set_text(lapTimeLabel, "0m 0s");
lv_obj_add_style(lapTimeLabel, styles->GetExtraLargeTextStyle(), LV_PART_MAIN);*/

/* batteryVoltageLabel = lv_label_create(bottomRow);
lv_label_set_text(batteryVoltageLabel, "2V");
lv_obj_add_style(batteryVoltageLabel, styles->GetExtraLargeTextStyle(), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_center(batteryVoltageLabel);
lv_obj_align(batteryVoltageLabel, LV_ALIGN_BOTTOM_MID, 0, 0);*/

/* motorRPMLabel = lv_label_create(bottomRow);
lv_label_set_text(motorRPMLabel, "0 RPM");
lv_obj_add_style(motorRPMLabel, styles->GetExtraLargeTextStyle(), LV_PART_MAIN | LV_STATE_DEFAULT);*/

/*
stopCountMeter = lv_meter_create(bottomRow);
lv_obj_remove_style(stopCountMeter, NULL, LV_PART_MAIN);
lv_obj_remove_style(stopCountMeter, NULL, LV_PART_INDICATOR);
lv_obj_set_size(stopCountMeter, 250, 250);
lv_obj_center(stopCountMeter);
lv_meter_scale_t * scale = lv_meter_add_scale(stopCountMeter);
lv_meter_set_scale_ticks(stopCountMeter, scale, 0, 0, 0, lv_color_black());
lv_meter_set_scale_range(stopCountMeter, scale, 0, 100, 360, 0);
//add indicator
lv_meter_indicator_t * indic_sec = lv_meter_add_arc(stopCountMeter, scale, 150, lv_palette_darken(LV_PALETTE_PURPLE, 1), 0);
lv_meter_set_indicator_start_value(stopCountMeter, indic_sec, 0);
lv_meter_set_indicator_end_value(stopCountMeter, indic_sec, 100);
lv_anim_t * secs;
lv_anim_init(secs);
lv_anim_set_exec_cb(secs, (lv_anim_exec_xcb_t) set_value);
lv_anim_set_values(secs, 0, 100);
lv_anim_set_repeat_count(secs, 0); //repeat set at 0 right now
lv_anim_set_time(secs, 2000);
lv_anim_set_var(secs, indic_sec);
lv_anim_start(secs);
*/

//get voltage, get current, calculate joules, put into array, display items of array in chart
uint32_t n;
uint32_t m;
uint32_t joule;

// getDataAggregator().batteryVoltage.addListener([this, &n, &m, &joule](const voltage_t& voltage) {
// n = voltage * 33 * 185 / 40960;
// joule = calculate_joule(n, m);
// });
//
// getDataAggregator().current.addListener([this, &m, &n, &joule](const current_t& current) {
// m = current;
// joule = calculate_joule(n, m);
// });


lv_obj_t* efficiency_chart;
efficiency_chart = lv_chart_create(bottomRow);
lv_obj_set_size(efficiency_chart, 800, 460);
Expand Down Expand Up @@ -121,6 +59,4 @@ HomeView::HomeView(lv_obj_t* parent, DataAggregator& aggregator) : View(parent,

lv_chart_refresh(efficiency_chart);
});


}
18 changes: 0 additions & 18 deletions Core/UI/HomeView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,6 @@
*/
class HomeView : public View {
private:
/** The label that displays the current lap time. */
lv_obj_t* lapTimeLabel;

/** The label that displays the last lap efficiency */
lv_obj_t* lapEfficiencyLabel;

/** The label that displays the battery voltage. */
lv_obj_t* batteryVoltageLabel;

/** The label that displays the motor RPM. */
lv_obj_t* motorRPMLabel;

/** bar graph for time laps display. */
lv_obj_t* lapTimeBarGraph;

/** Top row of the 2 row flex layout */
lv_obj_t* topRow;

/** Bottom row of the 2 row flex layout */
lv_obj_t* bottomRow;

Expand Down
23 changes: 0 additions & 23 deletions Core/UI/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,6 @@

static HomeView* homeView;

static uint8_t screenIndex = 0;
static uint8_t nScreens = 3;

void swipe_event_callback(lv_event_t* event) {
if (event->code == LV_EVENT_GESTURE) {
lv_dir_t direction = lv_indev_get_gesture_dir(lv_indev_get_act());

if (direction == LV_DIR_LEFT) {

if (screenIndex == 0) {
screenIndex = nScreens - 1;
} else {
screenIndex--;
}
} else if (direction == LV_DIR_RIGHT) {
screenIndex++;
screenIndex = screenIndex % nScreens;
} else {
return;
}
}
}

void Application_Create(DataAggregatorWrapper* aggregatorWrapper) {
DebugPrint("Creating application");

Expand Down
68 changes: 20 additions & 48 deletions UOSM-Core/Modules/InternalCommsModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,9 @@ PUBLIC result_t IComms_ReadPairInt32Message(iCommsMessage_t* msg, int32_t* a, in
return RESULT_OK;
}

<<<<<<<
HEAD
PUBLIC iCommsMessage_t
IComms_CreatePressureTemperatureMessage(uint16_t
standardMessageID,
pressure_t a, temperature_t
b) {
return
IComms_CreatePairInt32Message(standardMessageID, a, b
);
IComms_CreatePressureTemperatureMessage(uint16_t standardMessageID, pressure_t a, temperature_t b) {
return IComms_CreatePairInt32Message(standardMessageID, a, b);
}

PUBLIC result_t IComms_ReadPressureTemperatureMessage(iCommsMessage_t* msg, pressure_t* a, temperature_t* b) {
Expand All @@ -261,46 +254,25 @@ PUBLIC uint16_pair_t readMsgPairUInt16Bit(iCommsMessage_t* msg) {

pair.b = msg->data[3] << 8;
pair.b |= msg->data[2];
return pair;
}

=======
PUBLIC iCommsMessage_t
IComms_CreatePressureTemperatureMessage(uint16_t standardMessageID, pressure_t a, temperature_t b) {
return IComms_CreatePairInt32Message(standardMessageID, a, b);
}
PUBLIC result_t IComms_ReadPressureTemperatureMessage(iCommsMessage_t* msg, pressure_t* a, temperature_t* b) {
return IComms_ReadPairInt32Message(msg, a, b);
}

PUBLIC uint16_pair_t readMsgPairUInt16Bit(iCommsMessage_t* msg) {
uint16_pair_t pair = {};

if (msg->dataLength != 4) { return pair; }

pair.a = msg->data[1] << 8;
pair.a |= msg->data[0];

pair.b = msg->data[3] << 8;
pair.b |= msg->data[2];
>>>>>>> 4e0e7ec6f1268e9aade8c343ff4b4799b98cb9d7
return pair;
}

PUBLIC iCommsMessage_t
IComms_CreateEfficiencyMessage(uint16_t standardMessageID, lap_efficiencies_t* efficiencies) {
uint8_t data[8];
data[0] = efficiencies->lap_0;
data[1] = efficiencies->lap_1;
data[2] = efficiencies->lap_2;
data[3] = efficiencies->lap_3;
PUBLIC iCommsMessage_t
IComms_CreateEfficiencyMessage(uint16_t standardMessageID, lap_efficiencies_t* efficiencies) {
uint8_t data[8];
data[0] = efficiencies->lap_0;
data[1] = efficiencies->lap_1;
data[2] = efficiencies->lap_2;
data[3] = efficiencies->lap_3;

return IComms_CreateMessage(standardMessageID, 2, data);
}
return IComms_CreateMessage(standardMessageID, 2, data);
}

PUBLIC result_t IComms_ReadEfficiencyMessage(iCommsMessage_t* msg, lap_efficiencies_t* result) {
result->lap_0 = msg->data[0];
result->lap_1 = msg->data[1];
result->lap_2 = msg->data[2];
result->lap_3 = msg->data[3];
PUBLIC result_t IComms_ReadEfficiencyMessage(iCommsMessage_t* msg, lap_efficiencies_t* result) {
result->lap_0 = msg->data[0];
result->lap_1 = msg->data[1];
result->lap_2 = msg->data[2];
result->lap_3 = msg->data[3];

return RESULT_OK;
}
return RESULT_OK;
}

0 comments on commit b5a6e39

Please sign in to comment.