summaryrefslogtreecommitdiff
path: root/src/components/motion/MotionController.h
blob: 88024127933423212d855010b6744320a6b9cf3a (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
#pragma once

#include <cstdint>
#include <drivers/Bma421.h>

namespace Pinetime {
  namespace Controllers {
    class MotionController {
    public:
      enum class DeviceTypes {
        Unknown,
        BMA421,
        BMA425,
      };

      void Update(int16_t x, int16_t y, int16_t z);

      int16_t X() const {
        return x;
      }
      int16_t Y() const {
        return y;
      }
      int16_t Z() const {
        return z;
      }

      void IsSensorOk(bool isOk);
      bool IsSensorOk() const {
        return isSensorOk;
      }

      DeviceTypes DeviceType() const {
        return deviceType;
      }

      void Init(Pinetime::Drivers::Bma421::DeviceTypes types);

    private:
      int16_t x;
      int16_t y;
      int16_t z;
      bool isSensorOk = false;
      DeviceTypes deviceType = DeviceTypes::Unknown;

      int32_t accumulatedspeed = 0;
    };
  }
}