Add progress bar to endurance view
This commit is contained in:
		@ -12,12 +12,14 @@ public:
 | 
			
		||||
 | 
			
		||||
  virtual void initialize();
 | 
			
		||||
 | 
			
		||||
  void setProgress(bool active, ProgressType type, float progress);
 | 
			
		||||
  void update();
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
private:
 | 
			
		||||
  touchgfx::Unicode::UnicodeChar r2dProgBuffer[16];
 | 
			
		||||
  touchgfx::Unicode::UnicodeChar socBuffer[4];
 | 
			
		||||
 | 
			
		||||
  void setProgress(bool active, ProgressType type, float progress);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // PROGRESSBAR_HPP
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,6 @@
 | 
			
		||||
 | 
			
		||||
#include "gui/common/NamedField.hpp"
 | 
			
		||||
#include "gui/containers/DriverViewFieldSelection.hpp"
 | 
			
		||||
#include "gui/containers/ProgressBar.hpp"
 | 
			
		||||
#include <gui/driverview_screen/DriverViewPresenter.hpp>
 | 
			
		||||
#include <gui_generated/driverview_screen/DriverViewViewBase.hpp>
 | 
			
		||||
 | 
			
		||||
@ -25,7 +24,7 @@ public:
 | 
			
		||||
 | 
			
		||||
  void setTemps(const Temperatures &temps);
 | 
			
		||||
  void setTSSoC(uint8_t soc);
 | 
			
		||||
  void setProgress(bool active, ProgressType type, float progress);
 | 
			
		||||
  void updateProgress();
 | 
			
		||||
 | 
			
		||||
  void showAMSError();
 | 
			
		||||
  void clearErrorPopup();
 | 
			
		||||
 | 
			
		||||
@ -58,6 +58,7 @@ public:
 | 
			
		||||
 | 
			
		||||
  void updateBatDelta();
 | 
			
		||||
  void updateDetails();
 | 
			
		||||
  void updateProgress();
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  BatDelta lastLapDelta;
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,22 @@ ProgressBar::ProgressBar() {}
 | 
			
		||||
 | 
			
		||||
void ProgressBar::initialize() { ProgressBarBase::initialize(); }
 | 
			
		||||
 | 
			
		||||
void ProgressBar::update() {
 | 
			
		||||
  if (vehicle_state.ts_state == TS_PRECHARGE) {
 | 
			
		||||
    float progress = 0;
 | 
			
		||||
    if (vehicle_state.ts_voltage_bat != 0) {
 | 
			
		||||
      progress =
 | 
			
		||||
          vehicle_state.ts_voltage_veh / vehicle_state.ts_voltage_bat * 100;
 | 
			
		||||
    }
 | 
			
		||||
    setProgress(true, ProgressType::PRECHARGE, progress);
 | 
			
		||||
  } else if (vehicle_state.r2d_progress > R2D_TSACTIVE &&
 | 
			
		||||
             vehicle_state.r2d_progress < R2D_INIT_SUCCESS) {
 | 
			
		||||
    setProgress(true, ProgressType::R2D, vehicle_state.r2d_progress);
 | 
			
		||||
  } else {
 | 
			
		||||
    setProgress(false, ProgressType::PRECHARGE, 0);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ProgressBar::setProgress(bool active, ProgressType type, float progress) {
 | 
			
		||||
  if (active) {
 | 
			
		||||
    switch (type) {
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,7 @@ void DriverViewPresenter::deactivate() {}
 | 
			
		||||
void DriverViewPresenter::vehicleStateUpdated() {
 | 
			
		||||
  view.setTemps(vehicle_state.temps);
 | 
			
		||||
  view.setTSSoC(vehicle_state.soc_ts);
 | 
			
		||||
  updateProgress();
 | 
			
		||||
  view.updateProgress();
 | 
			
		||||
  updateErrorPopup();
 | 
			
		||||
 | 
			
		||||
  view.updateFieldValues();
 | 
			
		||||
@ -42,22 +42,6 @@ void DriverViewPresenter::setFieldType(size_t i, DataFieldType type) {
 | 
			
		||||
  view.setFieldType(i, type);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DriverViewPresenter::updateProgress() {
 | 
			
		||||
  if (vehicle_state.ts_state == TS_PRECHARGE) {
 | 
			
		||||
    float progress = 0;
 | 
			
		||||
    if (vehicle_state.ts_voltage_bat != 0) {
 | 
			
		||||
      progress =
 | 
			
		||||
          vehicle_state.ts_voltage_veh / vehicle_state.ts_voltage_bat * 100;
 | 
			
		||||
    }
 | 
			
		||||
    view.setProgress(true, ProgressType::PRECHARGE, progress);
 | 
			
		||||
  } else if (vehicle_state.r2d_progress > R2D_TSACTIVE &&
 | 
			
		||||
             vehicle_state.r2d_progress < R2D_INIT_SUCCESS) {
 | 
			
		||||
    view.setProgress(true, ProgressType::R2D, vehicle_state.r2d_progress);
 | 
			
		||||
  } else {
 | 
			
		||||
    view.setProgress(false, ProgressType::PRECHARGE, 0);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DriverViewPresenter::updateErrorPopup() {
 | 
			
		||||
  static uint32_t last_error = 0;
 | 
			
		||||
  if (vehicle_state.ts_state == TS_ERROR) {
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,6 @@
 | 
			
		||||
#include "gui/containers/DriverViewStatusItem.hpp"
 | 
			
		||||
#include "gui/containers/ProgressBar.hpp"
 | 
			
		||||
#include "gui/driverview_screen/DriverViewPresenter.hpp"
 | 
			
		||||
#include "texts/TextKeysAndLanguages.hpp"
 | 
			
		||||
#include "touchgfx/Callback.hpp"
 | 
			
		||||
#include "touchgfx/Drawable.hpp"
 | 
			
		||||
#include "touchgfx/Unicode.hpp"
 | 
			
		||||
@ -97,10 +96,7 @@ void DriverViewView::setTSSoC(uint8_t value) {
 | 
			
		||||
  socLabel.invalidate();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DriverViewView::setProgress(bool active, ProgressType type,
 | 
			
		||||
                                 float progress) {
 | 
			
		||||
  progressBar.setProgress(active, type, progress);
 | 
			
		||||
}
 | 
			
		||||
void DriverViewView::updateProgress() { progressBar.update(); }
 | 
			
		||||
 | 
			
		||||
void DriverViewView::showAMSError() {
 | 
			
		||||
  errorPopup.setVisible(true);
 | 
			
		||||
 | 
			
		||||
@ -37,6 +37,8 @@ void EnduranceView::updateDetails() {
 | 
			
		||||
  tbatBuffer.setFloatValue(vehicle_state.max_cell_temp);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void EnduranceView::updateProgress() { progressBar.update(); }
 | 
			
		||||
 | 
			
		||||
BatDelta::BatDelta(touchgfx::BoxWithBorder &box,
 | 
			
		||||
                   touchgfx::TextAreaWithOneWildcard &field)
 | 
			
		||||
    : box(box), field(field), value(INT_MIN) {}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user