-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMuVisionSensor.h
More file actions
98 lines (83 loc) · 3.43 KB
/
MuVisionSensor.h
File metadata and controls
98 lines (83 loc) · 3.43 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Copyright 2018 Morpx Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUVISIONSENSOR_SRC_MUVISIONSENSOR_H_
#define MUVISIONSENSOR_SRC_MUVISIONSENSOR_H_
#include "mu_vision_sensor_interface.h"
class MuVisionSensor {
public:
MuVisionSensor(uint32_t address);
virtual ~MuVisionSensor();
MuVisionSensor(const MuVisionSensor&) = delete;
MuVisionSensor& operator=(const MuVisionSensor &) = delete;
// Advance Method
uint8_t begin(void* communication_port,
MuVsMode mode);
MuVisionType UpdateResult(MuVisionType vision_type,
bool wait_all_result = true);
uint8_t write(MuVisionType, MuVsObjectInf, uint8_t value);
uint8_t read(MuVisionType vision_type,
MuVsObjectInf object_inf,
uint8_t result_num = 1);
// Based interface
uint8_t VisionBegin(MuVisionType);
uint8_t VisionEnd(MuVisionType);
int GetValue(MuVisionType vision_type,
MuVsObjectInf object_inf);
int SetValue(MuVisionType vision_type,
MuVsObjectInf object_inf,
uint8_t value) {
return write(vision_type, object_inf, value);
}
// Sensor functions
uint8_t SensorSetRestart(void);
uint8_t SensorSetDefault(void);
// LED functions
uint8_t LedSetMode(MuVsLed led, bool manual, bool hold);
uint8_t LedSetColor(MuVsLed led,
MuVsLedColor detected_color,
MuVsLedColor undetected_color,
uint8_t level = 1);
// Camera functions
uint8_t CameraSetZoom(MuVsCameraZoom);
uint8_t CameraSetRotate(bool enable);
uint8_t CameraSetFPS(MuVsCameraFPS);
uint8_t CameraSetAwb(MuVsCameraWhiteBalance);
MuVsCameraZoom CameraGetZoom(void);
MuVsCameraWhiteBalance CameraGetAwb(void);
bool CameraGetRotate(void);
MuVsCameraFPS CameraGetFPS(void);
// Uart functions
uint8_t UartSetBaudrate(MuVsBaudrate);
// Vision functions
uint8_t VisionSetStatus(MuVisionType vision_type, bool enable);
uint8_t VisionSetOutputMode(MuVsStreamOutputMode mode);
uint8_t VisionSetOutputEnable(MuVisionType vision_type, bool status);
uint8_t VisionSetDefault(MuVisionType vision_type);
uint8_t VisionSetLevel(MuVisionType vision_type,
MuVsVisionLevel level);
bool VisionGetStatus(MuVisionType vision_type);
MuVsVisionLevel VisionGetLevel(MuVisionType vision_type);
MuVsStreamOutputMode VisionGetOutputMode(void);
private:
uint8_t SensorLockReg(bool lock);
MuVisionType UartUpdateResult(MuVisionType vision_type, bool wait_all_result);
bool malloc_vision_buffer(MuVsMessageVisionType);
bool free_vision_buffer(MuVsMessageVisionType);
uint8_t address_ = 0;
MuVsMode mode_ = kSerialMode;
MuVsMethod* mu_vs_method = nullptr;
MuVsStreamOutputMode output_mode_ = kCallBackMode;
MuVsVisionState *vision_state_[kVisionMaxType-1] = {nullptr};
// MuVsStreamOutputMode output_mode[kVisionMaxType-1];
};
#endif /* ARDUINO_LIB_MUVISIONSENSOR_SRC_MUVISIONSENSOR_H_ */