summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/Motion.h
blob: 3ee6bfcd31fad4a018b7b55fceda7f4618ead11e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once

#include <cstdint>
#include <chrono>
#include "systemtask/SystemTask.h"
#include "displayapp/screens/Screen.h"
#include <lvgl/src/lv_core/lv_style.h>
#include <lvgl/src/lv_core/lv_obj.h>
#include <components/motor/MotorController.h>
#include <components/motion/MotionController.h>

#define DEBUG_JUMPSCORE_APP 1
#define JUMPSCORE_NO_CHART 1

namespace Pinetime {
  namespace Applications {
    namespace Screens {

      class Motion : public Screen {
      public:
        Motion(DisplayApp* app, System::SystemTask& systemTask, Controllers::MotionController& motionController, Controllers::MotorController& motorController);
        ~Motion() override;

        void Refresh() override;

      private:
        Controllers::MotionController& motionController;
        Controllers::MotorController& motorController;
        System::SystemTask& systemTask;
        // bool calibrating = true;
        bool started = false;
        bool jumping = false;
        bool new_record = true;
        TickType_t last_frame_time = 0;
        TickType_t last_redraw_frame_time = 0;
        // uint8_t dropped_frames = 0;
        double last_jump_length = 0;
        double best_jump_length = 0;     // Best jump length in this session
        lv_color_t color;
        double current_jump_length;
        double current_jump_speed;
        struct Record {
          double jump_length;
        };
        Record records[5] = { {-1}, {-1}, {-1}, {-1}, {-1} };
        char labelText[6] = { '0', '0', '0', '0', '0', 0 };
#ifndef JUMPSCORE_NO_CHART
        lv_obj_t* chart;
        lv_chart_series_t* ser1;
#endif
        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;
        int32_t frame_count = 0;
        int32_t max_frame_ms = 0;
        int32_t avg_frame_ms = 0;
        int32_t total_frames_ms = 0; 
#endif
      };
    }
  }
}