etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
MockController.h
[詳解]
1 #ifndef __CONTROLLER__
2 #define __CONTROLLER__
3 
4 #include <cstdint>
5 #include <cstdlib>
6 #include <iostream>
7 
8 class Motor {
9  public:
10  double count = 0.0;
11  int getCount() { return static_cast<int>(count); };
12  void setPWM(int pwm)
13  {
14  count += pwm * 0.05;
15  // std::cout << count << std::endl;
16  };
17  void stop(){};
18  void reset(){};
19  void setBrake(bool isBrake){};
20 };
21 
22 class Clock {
23  public:
24  void sleep(int time){};
25 };
26 
27 class TouchSensor {
28  public:
29  bool isPressed() { return false; }
30 };
31 
32 class ColorSensor {
33  public:
34  int getBrightness() { return brightness; }
35  int brightness = 0;
36 };
37 
38 class Controller {
39  public:
40  Clock clock;
46 
47  int noteFs6 = 0;
48  int noteFs4 = 0;
49  Controller() { mock_r = mock_g = mock_b = 0; }
50  void speakerSetVolume(int volume){};
52  void ledSetColorGreen(){};
53  int getBrightness() { return brightness; };
54  void speakerPlayTone(int frequency, int duration){};
56  {
57  counter++;
58  if(counter >= countLimit) {
59  return true;
60  }
61  return false;
62  };
63  void getRawColor(std::uint16_t& r, std::uint16_t& g, std::uint16_t& b)
64  {
65  r = mock_r;
66  g = mock_g;
67  b = mock_b;
68 
69  return;
70  };
71  bool buttonIsPressedUp() { return false; };
72  bool buttonIsPressedDown() { return false; };
73  bool buttonIsPressedRight() { return false; };
74  bool buttonIsPressedLeft() { return false; };
76  {
77  static int counter = 0;
78  counter++;
79  if(counter >= 10) {
80  return true;
81  }
82  return false;
83  };
84  void tslpTsk(int time)
85  {
86  exitCounter++;
87  if(exitCounter > exitCountLimit) std::exit(1);
88  }; // 4msec周期起動
89  void printDisplay(int row, const char* format, ...){};
90  int countLimit = 100;
91  int counter = 0;
92  int exitCounter = 0;
93  int exitCountLimit = 1000;
94  int brightness = 0;
95  std::uint16_t mock_r, mock_g, mock_b;
96  void setMockRgb(std::uint16_t r, std::uint16_t g, std::uint16_t b)
97  {
98  mock_r = r;
99  mock_g = g;
100  mock_b = b;
101  }
102 };
103 #endif
TouchSensor touchSensor
Definition: Controller.h:42
Motor liftMotor
Definition: Controller.h:44
void setBrake(bool isBrake)
void setMockRgb(std::uint16_t r, std::uint16_t g, std::uint16_t b)
void reset()
Clock clock
Definition: Controller.h:48
std::uint16_t mock_r
std::uint16_t mock_g
int exitCountLimit
uint16_t noteFs6
Definition: Controller.h:40
void speakerPlayTone(int frequency, int duration)
bool buttonIsPressedBack()
bool buttonIsPressedLeft()
bool buttonIsPressedRight()
void getRawColor(std::uint16_t &r, std::uint16_t &g, std::uint16_t &b)
void sleep(int time)
bool isPressed()
void stop()
int getCount()
void ledSetColorOrange()
uint16_t noteFs4
Definition: Controller.h:41
int getBrightness()
void printDisplay(int row, const char *format,...)
void tslpTsk(int time)
void ledSetColorGreen()
bool buttonIsPressedEnter()
bool buttonIsPressedUp()
int getBrightness()
ColorSensor colorSensor
Definition: Controller.h:43
Motor leftWheel
Definition: Controller.h:46
double count
bool buttonIsPressedDown()
void setPWM(int pwm)
void speakerSetVolume(int volume)
std::uint16_t mock_b
Motor rightWheel
Definition: Controller.h:45