From 32ac1a5ccfaf2f74accbc6f719df9fa8dfdcded5 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Mon, 11 Aug 2025 04:40:05 -0400 Subject: [PATCH] got it to capture images --- source/main.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/source/main.c b/source/main.c index 4057359..c1b774d 100644 --- a/source/main.c +++ b/source/main.c @@ -3,12 +3,24 @@ #include #include <3ds.h> +#include +#include +#include +#include +#include +#include <3ds.h> +#include +#include +#include +#include + #define WIDTH 400 #define HEIGHT 240 #define SCREENSIZE WIDTH * HEIGHT * 2 #define BUFSIZE SCREENSIZE * 2 +#define WAIT_TIMEOUT 300000000ULL -inline void clearScreen(void) { +void clearScreen(void) { u8 *frame = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL); memset(frame, 0, 320 * 240 * 3); } @@ -27,6 +39,35 @@ void flushBuffs(u8 *buf) { buf = malloc(BUFSIZE); } +void takePicture(u8 *buf) { + u32 bufSize; + CAMU_GetMaxBytes(&bufSize, WIDTH, HEIGHT); + CAMU_SetTransferBytes(PORT_BOTH, bufSize, WIDTH, HEIGHT); + + CAMU_Activate(SELECT_OUT1_OUT2); + + Handle camReceiveEvent = 0; + Handle camReceiveEvent2 = 0; + + CAMU_ClearBuffer(PORT_BOTH); + CAMU_SynchronizeVsyncTiming(SELECT_OUT1, SELECT_OUT2); + + CAMU_StartCapture(PORT_BOTH); + + CAMU_SetReceiving(&camReceiveEvent, buf, PORT_CAM1, SCREENSIZE, (s16) bufSize); + CAMU_SetReceiving(&camReceiveEvent2, buf + SCREENSIZE, PORT_CAM2, SCREENSIZE, (s16) bufSize); + svcWaitSynchronization(camReceiveEvent, WAIT_TIMEOUT); + svcWaitSynchronization(camReceiveEvent2, WAIT_TIMEOUT); + CAMU_PlayShutterSound(SHUTTER_SOUND_TYPE_NORMAL); + + CAMU_StopCapture(PORT_BOTH); + + svcCloseHandle(camReceiveEvent); + svcCloseHandle(camReceiveEvent2); + + CAMU_Activate(SELECT_NONE); +} + int main(int argc, char* argv[]) { u8 *buf = malloc(BUFSIZE); @@ -51,7 +92,7 @@ int main(int argc, char* argv[]) gfxFlushBuffers(); gspWaitForVBlank(); gfxSwapBuffers(); - // clearScreen(); + clearScreen(); // break; // break in order to return to hbmenu } }