summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2022-04-09 02:26:47 (GMT)
committerMichele Bini <michele.bini@gmail.com>2022-04-09 02:26:47 (GMT)
commit19631c56766c40f671095469d68be8c38bd62bc8 (patch)
tree80d5852ba967dd94675861c3bd2789b212cbb58a
parentc004e48fa5ff498ecb844796268f9bb850cc3aa2 (diff)
Try to improve jumpdev display
-rw-r--r--src/displayapp/screens/Motion.cpp64
-rw-r--r--src/displayapp/screens/Motion.h4
2 files changed, 46 insertions, 22 deletions
diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp
index 9100045..73ff524 100644
--- a/src/displayapp/screens/Motion.cpp
+++ b/src/displayapp/screens/Motion.cpp
@@ -25,13 +25,19 @@ using namespace Pinetime::Applications::Screens;
Motion::Motion(Pinetime::Applications::DisplayApp* app, System::SystemTask& systemTask, Controllers::MotionController& motionController, Controllers::MotorController& motorController)
: Screen(app), motionController {motionController}, motorController {motorController}, systemTask {systemTask} {
- {
- lv_obj_t *box;
- box = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_size(box, 20, 200);
- lv_obj_align(box, nullptr, LV_ALIGN_IN_LEFT_MID, 40, 0);
- lv_obj_set_style_local_text_color(box, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
- }
+ bar = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_size(bar, 8, 200);
+ lv_obj_align(bar, nullptr, LV_ALIGN_IN_RIGHT_MID, -20, 0);
+ lv_obj_set_style_local_radius(bar, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_style_local_bg_color(bar, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+
+#ifdef JUMPSCORE_ICON
+ icon = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_size(icon, 20, 20);
+ lv_obj_align(icon, bar, LV_ALIGN_OUT_RIGHT_BOTTOM, 0, -200);
+ lv_obj_set_style_local_radius(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_style_local_bg_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+#endif
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
#ifndef JUMPSCORE_NO_CHART
@@ -57,18 +63,21 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, System::SystemTask& syst
lv_label_set_text_static(label, labelText);
// lv_label_set_text_fmt(label, "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#", 0, 0, 0);
// lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
- lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
+ lv_obj_align(label, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
// lv_label_set_recolor(label, true);
lastLabel = lv_label_create(lv_scr_act(), NULL);
- lv_obj_align(lastLabel, label, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
+ lv_label_set_text_static(lastLabel, "?.???");
+ lv_obj_align(lastLabel, bar, LV_ALIGN_OUT_BOTTOM_RIGHT, -8, 0);
recordLabel = lv_label_create(lv_scr_act(), NULL);
- lv_obj_align(recordLabel, lastLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
+ lv_label_set_text_static(recordLabel, "?.???");
+ lv_obj_align(recordLabel, bar, LV_ALIGN_OUT_LEFT_BOTTOM, 0, -200);
#ifdef DEBUG_JUMPSCORE_APP
infoLabel = lv_label_create(lv_scr_act(), NULL);
- lv_obj_align(infoLabel, recordLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
+ lv_label_set_text_static(recordLabel, "???? ???");
+ lv_obj_align(infoLabel, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
#endif
taskRefresh = lv_task_create(RefreshTaskCallback, FRAME_MS, LV_TASK_PRIO_MID, this);
@@ -139,17 +148,30 @@ void Motion::Refresh() {
started = true;
}
last_redraw_frame_time = current_time;
- {
- uint16_t G_uint16 = G < 0xffff ? G : 0xffff;
+ uint16_t G_uint16 = G < 0xffff ? G : 0xffff;
+#ifdef JUMPSCORE_ICON
+ lv_obj_set_style_local_bg_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color);
+ if (jumping) {
+ lv_obj_set_size(icon, 20, 20 - G_uint16 / 200);
+ lv_obj_align(icon, bar, LV_ALIGN_OUT_RIGHT_BOTTOM, 0,
+ best_jump_length > 0 ?
+ current_jump_length > best_jump_length ?
+ -200 : -200*(current_jump_length / best_jump_length)
+ : 0
+ );
+ } else {
+ lv_obj_set_size(icon, 20, G_uint16 / 200 - 20);
+ lv_obj_align(icon, bar, LV_ALIGN_OUT_RIGHT_TOP, 0, 200);
+ }
+#endif
#ifndef JUMPSCORE_NO_CHART
- lv_chart_set_next(chart, ser1, 1000 - ((int16_t)G_uint16));
+ lv_chart_set_next(chart, ser1, 1000 - ((int16_t)G_uint16));
#endif
- labelText[4] = '0'+(G_uint16%10); G_uint16 /= 10;
- labelText[3] = '0'+(G_uint16%10); G_uint16 /= 10;
- labelText[2] = '0'+(G_uint16%10); G_uint16 /= 10;
- labelText[1] = '0'+(G_uint16%10); G_uint16 /= 10;
- labelText[0] = '0'+G_uint16;
- }
+ labelText[4] = '0'+(G_uint16%10); G_uint16 /= 10;
+ labelText[3] = '0'+(G_uint16%10); G_uint16 /= 10;
+ labelText[2] = '0'+(G_uint16%10); G_uint16 /= 10;
+ labelText[1] = '0'+(G_uint16%10); G_uint16 /= 10;
+ labelText[0] = '0'+G_uint16;
lv_label_set_text_static(label, labelText);
if (new_record) {
uint32_t a = (best_jump_length*100000.0);
@@ -160,7 +182,7 @@ void Motion::Refresh() {
uint32_t a = (last_jump_length*100000.0);
lv_label_set_text_fmt(lastLabel, "%d.%03d", a/1000, a%1000);
if (!new_record && last_jump_length > 0.05) {
- motorController.RunForDuration(11);
+ motorController.RunForDuration(14);
}
last_jump_length = 0;
}
diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h
index 3ee6bfc..304d1a9 100644
--- a/src/displayapp/screens/Motion.h
+++ b/src/displayapp/screens/Motion.h
@@ -11,6 +11,7 @@
#define DEBUG_JUMPSCORE_APP 1
#define JUMPSCORE_NO_CHART 1
+#define JUMPSCORE_ICON 1
namespace Pinetime {
namespace Applications {
@@ -48,11 +49,12 @@ namespace Pinetime {
lv_obj_t* chart;
lv_chart_series_t* ser1;
#endif
+ lv_obj_t* icon;
+ lv_obj_t* bar;
lv_obj_t* label;
lv_obj_t* recordLabel;
lv_obj_t* lastLabel;
- lv_obj_t* labelStep;
lv_task_t* taskRefresh;
#ifdef DEBUG_JUMPSCORE_APP
lv_obj_t* infoLabel;