update code.

This commit is contained in:
luocai 2024-09-04 19:23:34 +08:00
parent 239cb2d10f
commit 36a5877a0c
3 changed files with 28 additions and 17 deletions

View File

@ -362,29 +362,31 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) {
break; break;
} }
case Note: { case Note: {
uint8_t noteId = data[5]; auto noteId = static_cast<NoteId>(data[5]);
switch (noteId) { switch (noteId) {
case Ready: { case NoteId::Ready: {
LOG_CAT(info, GUI) << "模组: " << protocolDataFormatString(data, size); LOG_CAT(info, GUI) << "模组: " << protocolDataFormatString(data, size);
LOG_CAT(info, GUI) << "模组上电初始化成功。"; LOG_CAT(info, GUI) << "模组上电初始化成功。";
LOG_CAT(info, GUI) << Separator; LOG_CAT(info, GUI) << Separator;
break; break;
} }
case PalmState: { // 模组返回的数据为当前帧的手掌状态 case NoteId::PalmState: { // 模组返回的数据为当前帧的手掌状态
auto state = reinterpret_cast<const PalmStateNote *>(data + 6);
LOG(info) << "palm state: " << (int)ntohs(state->state);
break; break;
} }
case UnknownError: { case NoteId::UnknownError: {
LOG_CAT(info, GUI) << "模组: " << protocolDataFormatString(data, size); LOG_CAT(info, GUI) << "模组: " << protocolDataFormatString(data, size);
LOG_CAT(info, GUI) << "未知错误。"; LOG_CAT(info, GUI) << "未知错误。";
LOG_CAT(info, GUI) << Separator; LOG_CAT(info, GUI) << Separator;
break; break;
} }
case DebugInfo: { case NoteId::DebugInfo: {
auto message = reinterpret_cast<const char *>(data + 6); auto message = reinterpret_cast<const char *>(data + 6);
LOG_CAT(info, GUI) << "模组日志: " << message; LOG_CAT(info, GUI) << "模组日志: " << message;
break; break;
} }
case NoAliveImage: { case NoteId::NoAliveImage: {
LOG(info) << "no alive image"; LOG(info) << "no alive image";
emit newImageInfo(Note, 600 * 800, nullptr); emit newImageInfo(Note, 600 * 800, nullptr);
break; break;

View File

@ -42,13 +42,20 @@ public:
}; };
Q_ENUM(MessageId) Q_ENUM(MessageId)
enum NoteId : uint8_t { enum class NoteId : uint8_t {
Ready = 0x00, Ready = 0x00,
PalmState = 0x01, PalmState = 0x01,
UnknownError = 0x02, UnknownError = 0x02,
DebugInfo = 0x55, DebugInfo = 0x55,
NoAliveImage = 0x56, NoAliveImage = 0x56,
}; };
enum PalmState {
NoPalm = 1,
NeedMoveToCenter = 15,
NoAlive = 122,
};
enum MessageStatus : uint8_t { enum MessageStatus : uint8_t {
Success = 0, Success = 0,
Rejected = 1, Rejected = 1,
@ -75,17 +82,14 @@ public:
uint8_t save_image; uint8_t save_image;
uint8_t timeout; // timeout, unit second, default 10s uint8_t timeout; // timeout, unit second, default 10s
}; };
struct VerifyNoteInfo {
int16_t state; // corresponding to PALM_STATE_* struct PalmStateNote {
uint16_t state;
// position // position
int16_t left; // in pixel uint16_t left; // in pixel
int16_t top; uint16_t top;
int16_t right; uint16_t right;
int16_t bottom; uint16_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
}; };
struct EnrollData { struct EnrollData {

View File

@ -27,6 +27,10 @@ endif()
option(Boost_USE_STATIC_LIBS OFF) option(Boost_USE_STATIC_LIBS OFF)
set(OpenSSL_ROOT D:/Qt/Tools/OpenSSLv3/Win_x64)
set(OPENSSL_INCLUDE_DIR ${OpenSSL_ROOT}/include)
set(OpenSSL_LIBRARY_DIRS ${OpenSSL_ROOT}/lib)
set(OpenSSL_LIBRARIES libssl libcrypto)
set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-7.0.1-full_build-shared) set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-7.0.1-full_build-shared)
set(FFmpeg_INCLUDE_DIR ${FFmpeg_ROOT}/include) set(FFmpeg_INCLUDE_DIR ${FFmpeg_ROOT}/include)
@ -42,6 +46,7 @@ include(FetchContent)
FetchContent_Declare(Kylin FetchContent_Declare(Kylin
GIT_REPOSITORY https://gitea.amass.fun/amass/Kylin.git GIT_REPOSITORY https://gitea.amass.fun/amass/Kylin.git
) )
set(KYLIN_WITH_FLUENT ON)
FetchContent_MakeAvailable(Kylin) FetchContent_MakeAvailable(Kylin)
add_subdirectory(Peripheral) add_subdirectory(Peripheral)