diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-08-25 03:05:35 +0000 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-08-27 04:17:11 +0000 |
commit | 3806bd1f5ce56afdbb4cc0c1ed54d53e25603be2 (patch) | |
tree | e8eb9efb2b6c1abfaa0569b7c60b2f371fb215ef /hsm-cam/FFI | |
parent | c6bd9536038af5949924d1ad20a121bb10553300 (diff) |
Improves `hsm-cam`
- Moves C++ constants to Haskell side
- Uses better names for request callback related variables
- Captures and redirects libcamera's internal logging
Diffstat (limited to 'hsm-cam/FFI')
-rw-r--r-- | hsm-cam/FFI/Cam.cpp | 16 | ||||
-rw-r--r-- | hsm-cam/FFI/Cam.hpp | 11 |
2 files changed, 10 insertions, 17 deletions
diff --git a/hsm-cam/FFI/Cam.cpp b/hsm-cam/FFI/Cam.cpp index 9e371c1..bfdecf6 100644 --- a/hsm-cam/FFI/Cam.cpp +++ b/hsm-cam/FFI/Cam.cpp @@ -8,7 +8,7 @@ using namespace libcamera; using namespace std; HsLogger g_logger; -HsCallback g_callback; +HsRequestCallback g_request_callback; unique_ptr<CameraManager> g_manager; shared_ptr<Camera> g_camera; unique_ptr<CameraConfiguration> g_config; @@ -23,11 +23,11 @@ logMsg(Severity severity, const format_string<Args...> fmt, const Args &...args) } void -request_complete(Request *request) +internal_request_callback(Request *request) { int sequence = request->buffers().begin()->second->metadata().sequence; logMsg(Trace, "Completed request #{}", sequence); - g_callback(); + g_request_callback(); } extern "C" void @@ -38,10 +38,10 @@ register_logger(HsLogger hs_logger) } extern "C" void -register_callback(HsCallback hs_callback) +register_request_callback(HsRequestCallback hs_request_callback) { - g_callback = hs_callback; - logMsg(Info, "Registered FFI callback"); + g_request_callback = hs_request_callback; + logMsg(Info, "Registered FFI request callback"); } extern "C" void @@ -91,8 +91,8 @@ allocate_frame_buffer() g_allocator = make_unique<FrameBufferAllocator>(g_camera); g_allocator->allocate(g_config->at(0).stream()); - logMsg(Info, "Registering request complete callback"); - g_camera->requestCompleted.connect(request_complete); + logMsg(Info, "Registering internal request callback"); + g_camera->requestCompleted.connect(internal_request_callback); } extern "C" void diff --git a/hsm-cam/FFI/Cam.hpp b/hsm-cam/FFI/Cam.hpp index 374e16a..eeea814 100644 --- a/hsm-cam/FFI/Cam.hpp +++ b/hsm-cam/FFI/Cam.hpp @@ -1,15 +1,8 @@ #ifndef CAM_HPP #define CAM_HPP -// RGB888 configuration for ov5647 sensor (Raspberry Pi Camera Module) -// Must be updated if either: -// - Pixel format changes (e.g., to BGR, YUV, etc.) -// - Camera module is replaced #define FRAME_WIDTH (800) #define FRAME_HEIGHT (600) -#define FRAME_LINE (FRAME_WIDTH * 3) -#define FRAME_STRIDE (FRAME_LINE + 32) -#define FRAME_BUFFER_LENGTH (FRAME_STRIDE * FRAME_HEIGHT + 3072) enum Severity { @@ -19,14 +12,14 @@ enum Severity }; typedef void (*HsLogger)(enum Severity, const char *); -typedef void (*HsCallback)(); +typedef void (*HsRequestCallback)(); #ifdef __cplusplus extern "C" { #endif void register_logger(HsLogger hs_logger); - void register_callback(HsCallback hs_callback); + void register_request_callback(HsRequestCallback hs_request_callback); void start_camera_manager(); void stop_camera_manager(); void acquire_camera(); |