removed duplicate code
This commit is contained in:
parent
5715d60883
commit
e0a1e8d153
1 changed files with 14 additions and 14 deletions
28
src/main.c
28
src/main.c
|
|
@ -249,9 +249,7 @@ static Result post_multipart(const char *url, const char *filepath) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cam_thread(void *arg) {
|
static void setup_camera(u32 max) {
|
||||||
acInit();
|
|
||||||
camInit();
|
|
||||||
u32 sel = camIndex ? SELECT_IN1 : SELECT_OUT1;
|
u32 sel = camIndex ? SELECT_IN1 : SELECT_OUT1;
|
||||||
CAMU_SetSize(sel, SIZE_CTR_TOP_LCD, CONTEXT_A);
|
CAMU_SetSize(sel, SIZE_CTR_TOP_LCD, CONTEXT_A);
|
||||||
CAMU_SetOutputFormat(sel, OUTPUT_YUV_422, CONTEXT_A);
|
CAMU_SetOutputFormat(sel, OUTPUT_YUV_422, CONTEXT_A);
|
||||||
|
|
@ -259,29 +257,30 @@ static void cam_thread(void *arg) {
|
||||||
CAMU_SetNoiseFilter(sel, true);
|
CAMU_SetNoiseFilter(sel, true);
|
||||||
CAMU_SetAutoExposure(sel, true);
|
CAMU_SetAutoExposure(sel, true);
|
||||||
CAMU_SetAutoWhiteBalance(sel, true);
|
CAMU_SetAutoWhiteBalance(sel, true);
|
||||||
u32 max;
|
|
||||||
CAMU_GetMaxBytes(&max, W, H);
|
|
||||||
CAMU_SetTransferBytes(PORT_BOTH, max, W, H);
|
CAMU_SetTransferBytes(PORT_BOTH, max, W, H);
|
||||||
CAMU_Activate(sel);
|
CAMU_Activate(sel);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cam_thread(void *arg) {
|
||||||
|
acInit();
|
||||||
|
camInit();
|
||||||
|
u32 max;
|
||||||
|
CAMU_GetMaxBytes(&max, W, H);
|
||||||
|
|
||||||
|
setup_camera(max); // Initial setup
|
||||||
CAMU_ClearBuffer(PORT_BOTH);
|
CAMU_ClearBuffer(PORT_BOTH);
|
||||||
CAMU_SynchronizeVsyncTiming(SELECT_OUT1, SELECT_OUT2);
|
CAMU_SynchronizeVsyncTiming(SELECT_OUT1, SELECT_OUT2);
|
||||||
CAMU_StartCapture(PORT_BOTH);
|
CAMU_StartCapture(PORT_BOTH);
|
||||||
|
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
if (reinitCam) {
|
if (reinitCam) {
|
||||||
sel = camIndex ? SELECT_IN1 : SELECT_OUT1;
|
|
||||||
CAMU_StopCapture(PORT_BOTH);
|
CAMU_StopCapture(PORT_BOTH);
|
||||||
CAMU_ClearBuffer(PORT_BOTH);
|
CAMU_ClearBuffer(PORT_BOTH);
|
||||||
CAMU_SetSize(sel, SIZE_CTR_TOP_LCD, CONTEXT_A);
|
setup_camera(max); // Reuse same setup logic
|
||||||
CAMU_SetOutputFormat(sel, OUTPUT_YUV_422, CONTEXT_A);
|
|
||||||
CAMU_SetFrameRate(sel, FRAME_RATE_30);
|
|
||||||
CAMU_SetNoiseFilter(sel, true);
|
|
||||||
CAMU_SetAutoExposure(sel, true);
|
|
||||||
CAMU_SetAutoWhiteBalance(sel, true);
|
|
||||||
CAMU_SetTransferBytes(PORT_BOTH, max, W, H);
|
|
||||||
CAMU_Activate(sel);
|
|
||||||
CAMU_StartCapture(PORT_BOTH);
|
CAMU_StartCapture(PORT_BOTH);
|
||||||
reinitCam = false;
|
reinitCam = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle ev = 0;
|
Handle ev = 0;
|
||||||
int recv = camIndex ? PORT_CAM2 : PORT_CAM1;
|
int recv = camIndex ? PORT_CAM2 : PORT_CAM1;
|
||||||
CAMU_SetReceiving(&ev, camBuf[writeIdx], recv, W * H * 2, max);
|
CAMU_SetReceiving(&ev, camBuf[writeIdx], recv, W * H * 2, max);
|
||||||
|
|
@ -290,6 +289,7 @@ static void cam_thread(void *arg) {
|
||||||
svcSignalEvent(readyEv[writeIdx]);
|
svcSignalEvent(readyEv[writeIdx]);
|
||||||
writeIdx ^= 1;
|
writeIdx ^= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAMU_StopCapture(PORT_BOTH);
|
CAMU_StopCapture(PORT_BOTH);
|
||||||
CAMU_Activate(SELECT_NONE);
|
CAMU_Activate(SELECT_NONE);
|
||||||
camExit();
|
camExit();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue