-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDFRobot_HuskylensV2.h
More file actions
76 lines (63 loc) · 2.44 KB
/
Copy pathDFRobot_HuskylensV2.h
File metadata and controls
76 lines (63 loc) · 2.44 KB
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
/*
为ino提供接口
存储分析result
*/
#ifndef DFROBOT_HUSKYLENS_V2_H
#define DFROBOT_HUSKYLENS_V2_H
#include <Arduino.h>
#include <ProtocolV2.h>
#define COLOR_WHITE 0xFFFFFF // 白色
#define COLOR_RED 0xFF0000 // 红色
#define COLOR_ORANGE 0xFFA500 // 橙色
#define COLOR_YELLOW 0xFFFF00 // 黄色
#define COLOR_GREEN 0x00FF00 // 绿色
#define COLOR_CYAN 0x00FFFF // 青色
#define COLOR_BLUE 0x0000FF // 蓝色
#define COLOR_PURPLE 0x800080 // 紫色
#define COLOR_PINK 0xFFC0CB // 粉色
#define COLOR_GRAY 0x808080 // 灰色
#define COLOR_BLACK 0x000000 // 黑色
#define COLOR_BROWN 0xA52A2A // 棕色
#define COLOR_OLIVE 0x808000 // 橄榄绿
#define COLOR_TEAL 0x008080 // 蓝绿色
#define COLOR_INDIGO 0x4B0082 // 靛蓝色
#define COLOR_MAGENTA 0xFF00FF // 洋红色
class HuskylensV2 : public ProtocolV2 {
public:
HuskylensV2();
~HuskylensV2();
bool begin(Stream &streamInput);
bool begin(TwoWire &streamInput);
int8_t getResult(eAlgorithm_t algo);
bool available(eAlgorithm_t algo);
bool switchAlgorithm(eAlgorithm_t algo);
Result *popCachedResult(eAlgorithm_t algo);
Result *getCachedCenterResult(eAlgorithm_t algo);
Result *getCachedResultByIndex(eAlgorithm_t algo, int16_t index);
Result *getCachedResultByID(eAlgorithm_t algo, int16_t ID);
int16_t getCachedResultNum(eAlgorithm_t algo);
int16_t getCachedResultLearnedNum(eAlgorithm_t algo);
int16_t getCachedResultNumByID(eAlgorithm_t algo, uint8_t id);
Result *getCachedIndexResultByID(eAlgorithm_t algo, uint8_t id,
uint8_t index);
int16_t getCachedResultMaxID(eAlgorithm_t algo);
Result *getCurrentBranch(eAlgorithm_t algo);
int8_t getUpcomingBranchCount(eAlgorithm_t algo);
Result *getBranch(eAlgorithm_t algo, int16_t index);
#ifdef LARGE_MEMORY
bool setMultiAlgorithm(eAlgorithm_t algo0, eAlgorithm_t algo1,
eAlgorithm_t algo2 = ALGORITHM_ANY);
#endif
public:
Result *result[ALGORITHM_COUNT][MAX_RESULT_NUM];
#ifdef LARGE_MEMORY
uint8_t customId[3];
uint8_t customAlgoNum;
eAlgorithm_t toRealID(uint8_t id);
#endif
};
#define RET_ITEM_NUM(func, type, item) \
[](type *rlt) { return rlt ? rlt->item : -1; }(static_cast<type *>(func))
#define RET_ITEM_STR(func, type, item) \
[](type *rlt) { return rlt ? rlt->item : ""; }(static_cast<type *>(func))
#endif // DFROBOT_HUSKYLENS_V2_H