Skip to content

Commit

Permalink
Hrs3300: clang-format for gain setting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hatmajster committed Jul 27, 2021
1 parent 5065002 commit 9675c30
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 51 deletions.
20 changes: 12 additions & 8 deletions src/components/settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,27 @@ namespace Pinetime {
return settings.brightLevel;
};

void SetStepsGoal( uint32_t goal ) {
if ( goal != settings.stepsGoal ) {
void SetStepsGoal(uint32_t goal) {
if (goal != settings.stepsGoal) {
settingsChanged = true;
}
settings.stepsGoal = goal;
settings.stepsGoal = goal;
};

uint32_t GetStepsGoal() const { return settings.stepsGoal; };

void SetHeartSensorGain( uint32_t gain ) {
if ( gain != settings.heartSensorGain ) {
uint32_t GetStepsGoal() const {
return settings.stepsGoal;
};

void SetHeartSensorGain(uint32_t gain) {
if (gain != settings.heartSensorGain) {
settingsChanged = true;
}
settings.heartSensorGain = gain;
};

uint32_t GetHeartSensorGain() const { return settings.heartSensorGain; };
uint32_t GetHeartSensorGain() const {
return settings.heartSensorGain;
};

private:
Pinetime::Controllers::FS& fs;
Expand Down
42 changes: 19 additions & 23 deletions src/displayapp/screens/settings/SettingHeartRate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@
using namespace Pinetime::Applications::Screens;

namespace {
static void event_handler(lv_obj_t * obj, lv_event_t event) {
SettingHeartRate* screen = static_cast<SettingHeartRate *>(obj->user_data);
static void event_handler(lv_obj_t* obj, lv_event_t event) {
SettingHeartRate* screen = static_cast<SettingHeartRate*>(obj->user_data);
screen->UpdateSelected(obj, event);
}
}

SettingHeartRate::SettingHeartRate(
Pinetime::Applications::DisplayApp *app,
Pinetime::Controllers::Settings &settingsController) :
SettingHeartRate::SettingHeartRate(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
:

Screen(app),
settingsController{settingsController}
{
Screen(app),
settingsController {settingsController} {

lv_obj_t * container1 = lv_cont_create(lv_scr_act(), nullptr);
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);

//lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
// lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10);
lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
Expand All @@ -32,12 +30,12 @@ SettingHeartRate::SettingHeartRate(
lv_obj_set_height(container1, LV_VER_RES - 60);
lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT);

lv_obj_t * title = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text_static(title,"HRS Gain");
lv_obj_t* title = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text_static(title, "HRS Gain");
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15);

lv_obj_t * icon = lv_label_create(lv_scr_act(), NULL);
lv_obj_t* icon = lv_label_create(lv_scr_act(), NULL);
lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);

lv_label_set_text_static(icon, Symbols::heartBeat);
Expand All @@ -63,7 +61,6 @@ SettingHeartRate::SettingHeartRate(
lv_obj_set_event_cb(btnMinus, event_handler);
lv_obj_align(btnMinus, lv_scr_act(), LV_ALIGN_CENTER, -55, 80);
lv_obj_set_style_local_value_str(btnMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");

}

SettingHeartRate::~SettingHeartRate() {
Expand All @@ -75,33 +72,32 @@ bool SettingHeartRate::Refresh() {
return running;
}

void SettingHeartRate::UpdateSelected(lv_obj_t *object, lv_event_t event) {
void SettingHeartRate::UpdateSelected(lv_obj_t* object, lv_event_t event) {
uint32_t value = settingsController.GetHeartSensorGain();
bool change = false;
if(object == btnPlus && (event == LV_EVENT_PRESSED)) {
if ( value < 8 ) {
if (object == btnPlus && (event == LV_EVENT_PRESSED)) {
if (value < 8) {
value *= 2;
change = true;
} else if ( value == 8 ) {
} else if (value == 8) {
value = 64;
change = true;
}
}

if(object == btnMinus && (event == LV_EVENT_PRESSED)) {
if ( value == 64 ) {
if (object == btnMinus && (event == LV_EVENT_PRESSED)) {
if (value == 64) {
value = 8;
change = true;
} else if ( value > 1 ) {
} else if (value > 1) {
value /= 2;
change = true;
}
}

if(change) {
if (change) {
settingsController.SetHeartSensorGain(value);
lv_label_set_text_fmt(gainValue, "%d", value);
lv_obj_align(gainValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10);
}

}
26 changes: 11 additions & 15 deletions src/displayapp/screens/settings/SettingHeartRate.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,20 @@ namespace Pinetime {
namespace Applications {
namespace Screens {

class SettingHeartRate : public Screen{
public:
SettingHeartRate(DisplayApp* app,
Pinetime::Controllers::Settings &settingsController
);
~SettingHeartRate() override;
class SettingHeartRate : public Screen {
public:
SettingHeartRate(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingHeartRate() override;

bool Refresh() override;
void UpdateSelected(lv_obj_t *object, lv_event_t event);
bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event);

private:

Controllers::Settings& settingsController;

lv_obj_t * gainValue;
lv_obj_t * btnPlus;
lv_obj_t * btnMinus;
private:
Controllers::Settings& settingsController;

lv_obj_t* gainValue;
lv_obj_t* btnPlus;
lv_obj_t* btnMinus;
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/heartratetask/HeartRateTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ using namespace Pinetime::Applications;

HeartRateTask::HeartRateTask(Drivers::Hrs3300& heartRateSensor,
Controllers::HeartRateController& controller,
Pinetime::Controllers::Settings &settingsController)
: heartRateSensor {heartRateSensor}, controller {controller}, settingsController{settingsController}, ppg{} {
Pinetime::Controllers::Settings& settingsController)
: heartRateSensor {heartRateSensor}, controller {controller}, settingsController {settingsController}, ppg {} {
}

void HeartRateTask::Start() {
Expand Down
4 changes: 2 additions & 2 deletions src/heartratetask/HeartRateTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Pinetime {

explicit HeartRateTask(Drivers::Hrs3300& heartRateSensor,
Controllers::HeartRateController& controller,
Pinetime::Controllers::Settings &settingsController);
Pinetime::Controllers::Settings& settingsController);
void Start();
void Work();
void PushMessage(Messages msg);
Expand All @@ -35,7 +35,7 @@ namespace Pinetime {
States state = States::Running;
Drivers::Hrs3300& heartRateSensor;
Controllers::HeartRateController& controller;
Pinetime::Controllers::Settings &settingsController;
Pinetime::Controllers::Settings& settingsController;
Controllers::Ppg ppg;
bool measurementStarted = false;
};
Expand Down
1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ void ble_manager_set_ble_disconnection_callback(void (*disconnection)());
static constexpr uint8_t pinTouchIrq = 28;
static constexpr uint8_t pinPowerPresentIrq = 19;


Pinetime::Controllers::DateTime dateTimeController;
Pinetime::Drivers::Watchdog watchdog;
Pinetime::Drivers::WatchdogView watchdogView(watchdog);
Expand Down

0 comments on commit 9675c30

Please sign in to comment.