-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestFrameworkLinux.h
105 lines (87 loc) · 2.55 KB
/
TestFrameworkLinux.h
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#pragma once
#include "VortexLib.h"
#include "Patterns/Patterns.h"
#include "Colors/ColorTypes.h"
#include "Colors/Colorset.h"
#include "Leds/LedTypes.h"
typedef uint32_t HDC;
typedef uint32_t HINSTANCE;
typedef uint32_t HWND;
typedef uint32_t WPARAM;
typedef uint32_t LPARAM;
typedef uint32_t HBRUSH;
typedef uint32_t DWORD;
typedef uint32_t LRESULT;
typedef uint32_t UINT;
typedef struct tagCRGB CRGB;
// paint callback type
typedef void (*paint_fn_t)(void *, HDC);
class TestFramework
{
public:
TestFramework();
~TestFramework();
// initialize the test framework
bool init(int argc, char *argv[]);
// run the test framework
void run();
void cleanup();
// handlers for the arduino routines
void show();
// whether the button is pressed
bool isButtonPressed() const;
// whether the test framework is still running
bool stillRunning() const;
// setup the array of leds
void installLeds(CRGB *leds, uint32_t count);
static void printlog(const char *file, const char *func, int line, const char *msg, va_list list);
void setColoredOutput(bool output) { m_outputType = OUTPUT_TYPE_COLOR; }
void setHexOutput(bool output) { m_outputType = OUTPUT_TYPE_HEX; }
void setNoTimestep(bool timestep) { m_noTimestep = timestep; }
void setInPlace(bool inplace) { m_inPlace = inplace; }
private:
class TestFrameworkCallbacks : public VortexCallbacks
{
public:
TestFrameworkCallbacks() {}
virtual ~TestFrameworkCallbacks() {}
virtual long checkPinHook(uint32_t pin) override;
virtual void ledsInit(void *cl, int count) override;
virtual void ledsShow() override;
private:
// receive a message from client
};
// internal helper for updating terminal size
void get_terminal_size();
// these are in no particular order
RGBColor *m_ledList;
uint32_t m_numLeds;
bool m_initialized;
bool m_buttonPressed;
bool m_keepGoing;
volatile bool m_isPaused;
PatternID m_curPattern;
Colorset m_curColorset;
enum OutputType {
OUTPUT_TYPE_NONE,
OUTPUT_TYPE_HEX,
OUTPUT_TYPE_COLOR,
};
OutputType m_outputType;
bool m_noTimestep;
bool m_lockstep;
bool m_inPlace;
bool m_record;
bool m_storage;
bool m_sleepEnabled;
bool m_lockEnabled;
std::string m_storageFile;
std::string m_patternIDStr;
std::string m_colorsetStr;
std::string m_argumentsStr;
// to pipe stuff into the engine
int m_pipe_fd[2];
int m_saved_stdin;
std::string m_inputBuffer;
};
extern TestFramework *g_pTestFramework;