This commit is contained in:
ZetaDesigns
2017-09-08 23:18:41 +02:00
2 changed files with 14 additions and 29 deletions

View File

@@ -32,33 +32,32 @@
#include "themes.h"
u32 transfer_size;
Handle events[2] = {0};
Handle event;
void init_qr(void)
{
camInit();
CAMU_SetSize(SELECT_OUT1_OUT2, SIZE_CTR_TOP_LCD, CONTEXT_A);
CAMU_SetOutputFormat(SELECT_OUT1_OUT2, OUTPUT_RGB_565, CONTEXT_A);
CAMU_SetFrameRate(SELECT_OUT1_OUT2, FRAME_RATE_30);
CAMU_SetFrameRate(SELECT_OUT1_OUT2, FRAME_RATE_10);
CAMU_SetNoiseFilter(SELECT_OUT1_OUT2, true);
CAMU_SetAutoExposure(SELECT_OUT1_OUT2, true);
CAMU_SetAutoWhiteBalance(SELECT_OUT1_OUT2, true);
CAMU_SetTrimming(PORT_CAM1, false);
CAMU_SetTrimming(PORT_CAM2, false);
CAMU_Activate(SELECT_OUT1_OUT2);
CAMU_GetBufferErrorInterruptEvent(&events[1], PORT_BOTH);
CAMU_SetTrimming(PORT_BOTH, false);
buf = malloc(sizeof(u16) * 400 * 240 * 2);
CAMU_GetMaxBytes(&transfer_size, 400, 240);
CAMU_SetTransferBytes(PORT_BOTH, transfer_size, 400, 240);
CAMU_SynchronizeVsyncTiming(SELECT_OUT1, SELECT_OUT2);
CAMU_Activate(SELECT_OUT1_OUT2);
event = 0;
CAMU_ClearBuffer(PORT_BOTH);
buf = malloc(sizeof(u16) * 400 * 240 * 2);
CAMU_SetReceiving(&events[0], buf, PORT_CAM1, 240 * 400 * 2, transfer_size);
CAMU_SynchronizeVsyncTiming(SELECT_OUT1, SELECT_OUT2);
CAMU_StartCapture(PORT_BOTH);
context = quirc_new();
quirc_resize(context, 400, 240);
@@ -66,7 +65,6 @@ void init_qr(void)
void exit_qr(void)
{
CAMU_Activate(PORT_NONE);
CAMU_StopCapture(PORT_BOTH);
CAMU_Activate(SELECT_NONE);
camExit();
@@ -76,22 +74,9 @@ void exit_qr(void)
void take_picture(void)
{
s32 index;
svcWaitSynchronizationN(&index, events, 2, false, U64_MAX);
if (index == 0)
{
svcCloseHandle(events[0]);
events[0] = 0;
CAMU_SetReceiving(&events[0], buf, PORT_CAM1, 240 * 400 * 2, transfer_size);
} else if (index == 1)
{
svcCloseHandle(events[1]);
events[1] = 0;
CAMU_ClearBuffer(PORT_BOTH);
CAMU_SetReceiving(&events[0], buf, PORT_CAM1, 240 * 400 * 2, transfer_size);
CAMU_StartCapture(PORT_BOTH);
}
CAMU_SetReceiving(&event, buf, PORT_CAM1, 240 * 400 * 2, transfer_size);
svcWaitSynchronization(event, U64_MAX);
svcCloseHandle(event);
}
/*