diff options
Diffstat (limited to 'src/displayapp/screens/Motion.cpp')
| -rw-r--r-- | src/displayapp/screens/Motion.cpp | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp index bd0191a..9e0c71f 100644 --- a/src/displayapp/screens/Motion.cpp +++ b/src/displayapp/screens/Motion.cpp @@ -8,12 +8,16 @@ // #define APX_TICK_PERIOD_MS portTICK_PERIOD_MS // #endif +#if configTICK_RATE_HZ == 1024 #define FRAME_HZ 100 -#define FRAME_MS (1000 / FRAME_HZ) -#define FRAME_TICKS (FRAME_MS / APX_TICK_PERIOD_MS) +#define FRAME_MS 10 +#define FRAME_TICKS 10 #define REDRAW_FRAME_HZ 40 -#define REDRAW_FRAME_MS (1000 / REDRAW_FRAME_HZ) -#define REDRAW_FRAME_TICKS (REDRAW_FRAME_MS / APX_TICK_PERIOD_MS) +#define REDRAW_FRAME_MS (1024 / REDRAW_FRAME_HZ) +#define REDRAW_FRAME_TICKS REDRAW_FRAME_MS +#else +#error "Unsupported configTICK_RATE_HZ" +#endif #define G_SCALE 0.001 using namespace Pinetime::Applications::Screens; @@ -22,6 +26,7 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, System::SystemTask& syst : Screen(app), motionController {motionController}, motorController {motorController}, systemTask {systemTask} { systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping); +#ifndef JUMPSCORE_NO_CHART chart = lv_chart_create(lv_scr_act(), NULL); lv_obj_set_size(chart, 100, 100); lv_obj_align(chart, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); @@ -35,13 +40,10 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, System::SystemTask& syst /*Add 3 data series*/ ser1 = lv_chart_add_series(chart, LV_COLOR_RED); - // ser2 = lv_chart_add_series(chart, LV_COLOR_GREEN); - // ser3 = lv_chart_add_series(chart, LV_COLOR_YELLOW); lv_chart_init_points(chart, ser1, 0); - // lv_chart_init_points(chart, ser2, 0); - // lv_chart_init_points(chart, ser3, 0); lv_chart_refresh(chart); /*Required after direct set*/ +#endif label = lv_label_create(lv_scr_act(), NULL); lv_label_set_text_static(label, labelText); @@ -56,6 +58,11 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, System::SystemTask& syst recordLabel = lv_label_create(lv_scr_act(), NULL); lv_obj_align(recordLabel, lastLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); +#ifdef DEBUG_JUMPSCORE_APP + infoLabel = lv_label_create(lv_scr_act(), NULL); + lv_obj_align(infoLabel, recordLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); +#endif + taskRefresh = lv_task_create(RefreshTaskCallback, FRAME_MS, LV_TASK_PRIO_MID, this); } @@ -70,11 +77,22 @@ void Motion::Refresh() { bool jump_started_or_ended = false; double X; double Y; double_t Z; double G = systemTask.ReadGXYZ(X,Y,Z); - // lv_chart_set_next(chart, ser2, motionController.Y()); - // lv_chart_set_next(chart, ser3, motionController.Z()); TickType_t current_time = xTaskGetTickCount(); if (started) { TickType_t current_frame_ms = current_time - last_frame_time; +#ifdef DEBUG_JUMPSCORE_APP + frame_count++; + total_frames_ms += current_frame_ms; + if (current_frame_ms > max_frame_ms) { + max_frame_ms = current_frame_ms; + } + if (frame_count % 300 == 0) { + avg_frame_ms = total_frames_ms/300; + lv_label_set_text_fmt(infoLabel, "%dM %dA", max_frame_ms, avg_frame_ms); + total_frames_ms = 0; + max_frame_ms = 0; + } +#endif double G_scaled = G * G_SCALE; if (G_scaled < 1.000) { if (!jumping) { @@ -113,7 +131,9 @@ void Motion::Refresh() { last_redraw_frame_time = current_time; { uint16_t G_uint16 = G < 0xffff ? G : 0xffff; +#ifndef JUMPSCORE_NO_CHART 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; |
