update code.
This commit is contained in:
@ -362,29 +362,31 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) {
|
||||
break;
|
||||
}
|
||||
case Note: {
|
||||
uint8_t noteId = data[5];
|
||||
auto noteId = static_cast<NoteId>(data[5]);
|
||||
switch (noteId) {
|
||||
case Ready: {
|
||||
case NoteId::Ready: {
|
||||
LOG_CAT(info, GUI) << "模组: " << protocolDataFormatString(data, size);
|
||||
LOG_CAT(info, GUI) << "模组上电初始化成功。";
|
||||
LOG_CAT(info, GUI) << Separator;
|
||||
break;
|
||||
}
|
||||
case PalmState: { // 模组返回的数据为当前帧的手掌状态
|
||||
case NoteId::PalmState: { // 模组返回的数据为当前帧的手掌状态
|
||||
auto state = reinterpret_cast<const PalmStateNote *>(data + 6);
|
||||
LOG(info) << "palm state: " << (int)ntohs(state->state);
|
||||
break;
|
||||
}
|
||||
case UnknownError: {
|
||||
case NoteId::UnknownError: {
|
||||
LOG_CAT(info, GUI) << "模组: " << protocolDataFormatString(data, size);
|
||||
LOG_CAT(info, GUI) << "未知错误。";
|
||||
LOG_CAT(info, GUI) << Separator;
|
||||
break;
|
||||
}
|
||||
case DebugInfo: {
|
||||
case NoteId::DebugInfo: {
|
||||
auto message = reinterpret_cast<const char *>(data + 6);
|
||||
LOG_CAT(info, GUI) << "模组日志: " << message;
|
||||
break;
|
||||
}
|
||||
case NoAliveImage: {
|
||||
case NoteId::NoAliveImage: {
|
||||
LOG(info) << "no alive image";
|
||||
emit newImageInfo(Note, 600 * 800, nullptr);
|
||||
break;
|
||||
|
@ -42,13 +42,20 @@ public:
|
||||
};
|
||||
Q_ENUM(MessageId)
|
||||
|
||||
enum NoteId : uint8_t {
|
||||
enum class NoteId : uint8_t {
|
||||
Ready = 0x00,
|
||||
PalmState = 0x01,
|
||||
UnknownError = 0x02,
|
||||
DebugInfo = 0x55,
|
||||
NoAliveImage = 0x56,
|
||||
};
|
||||
|
||||
enum PalmState {
|
||||
NoPalm = 1,
|
||||
NeedMoveToCenter = 15,
|
||||
NoAlive = 122,
|
||||
};
|
||||
|
||||
enum MessageStatus : uint8_t {
|
||||
Success = 0,
|
||||
Rejected = 1,
|
||||
@ -75,17 +82,14 @@ public:
|
||||
uint8_t save_image;
|
||||
uint8_t timeout; // timeout, unit second, default 10s
|
||||
};
|
||||
struct VerifyNoteInfo {
|
||||
int16_t state; // corresponding to PALM_STATE_*
|
||||
|
||||
struct PalmStateNote {
|
||||
uint16_t state;
|
||||
// position
|
||||
int16_t left; // in pixel
|
||||
int16_t top;
|
||||
int16_t right;
|
||||
int16_t bottom;
|
||||
// pose
|
||||
int16_t yaw; // up and down in vertical orientation
|
||||
int16_t pitch; // right or left turned in horizontal orientation
|
||||
int16_t roll; // slope
|
||||
uint16_t left; // in pixel
|
||||
uint16_t top;
|
||||
uint16_t right;
|
||||
uint16_t bottom;
|
||||
};
|
||||
|
||||
struct EnrollData {
|
||||
|
Reference in New Issue
Block a user