<commit_before>/*
 * camera_test_app.cpp
 *
 * Author: <NAME>, <NAME>, <NAME>
 * Copyright (c) 2014-2015 HKUST SmartCar Team
 * Refer to LICENSE for details
 */

#include <cstdio>
#include <cstring>

#include <libsc/k60/led.h>
#include <libsc/k60/ov7725.h>
#include <libsc/k60/st7735r.h>
#include <libsc/k60/system.h>
#include <libsc/k60/timer.h>
#include <libutil/misc.h>

#include "camera_test_app.h"
#include "car.h"
#include "system_res.h"

using namespace libsc::k60;

namespace camera
{

void CameraTestApp::Run()
{
	printf("OV7725 Test\n");

	Car *car = GetSystemRes()->car;
	car->GetLcd().Clear(libutil::GetRgb565(0x33, 0xB5, 0xE5));

	const Uint image_size = car->GetCameraW() * car->GetCameraH() / 8;
	Byte *image2 = new Byte[image_size];
	car->GetCamera().Start();

	int led_time = 0;
	while (true)
	{
		if (car->GetCamera().IsAvailable())
		{
			memcpy(image2, car->GetCamera().LockBuffer(), image_size);
			car->GetCamera().UnlockBuffer();

			car->GetLcd().SetRegion({0, 0, car->GetCameraW(), car->GetCameraH()});
			car->GetLcd().FillBits(0, 0xFFFF, image2,
					car->GetCameraW() * car->GetCameraH());
		}

		if (Timer::TimeDiff(System::Time(), led_time) > 250)
		{
			car->GetLed(0).Switch();
			led_time = System::Time();<commit_msg>Corrrectly support exiting camera test app<commit_after>/*
 * camera_test_app.cpp
 *
 * Author: <NAME>, <NAME>, <NAME>
 * Copyright (c) 2014-2015 HKUST SmartCar Team
 * Refer to LICENSE for details
 */

#include <cstdio>
#include <cstring>
#include <memory>

#include <libsc/k60/led.h>
#include <libsc/k60/ov7725.h>
#include <libsc/k60/st7735r.h>
#include <libsc/k60/system.h>
#include <libsc/k60/timer.h>
#include <libutil/misc.h>

#include "camera_test_app.h"
#include "car.h"
#include "system_res.h"

using namespace libsc::k60;
using namespace std;

namespace camera
{

void CameraTestApp::Run()
{
	printf("OV7725 Test\n");

	Car *car = GetSystemRes()->car;
	car->GetLcd().Clear(libutil::GetRgb565(0x33, 0xB5, 0xE5));

	const Uint image_size = car->GetCameraW() * car->GetCameraH() / 8;
	unique_ptr<Byte[]> image2(new Byte[image_size]);
	car->GetCamera().Start();

	int led_time = 0;
	while (!car->GetButton(1).IsDown())
	{
		if (car->GetCamera().IsAvailable())
		{
			memcpy(image2.get(), car->GetCamera().LockBuffer(), image_size);
			car->GetCamera().UnlockBuffer();

			car->GetLcd().SetRegion({0, 0, car->GetCameraW(), car->GetCameraH()});
			car->GetLcd().FillBits(0, 0xFFFF, image2.get(),
					car->GetCameraW() * car->GetCameraH());
		}

		if (Timer::TimeDiff(System::Time(), led_time) > 250)
		{
			car->GetLed(0).Switch();
			led_time = System::Time();
{'fraction_non_alphanumeric': 0.19411539931218952, 'fraction_numerical': 0.042414978983568975, 'mean_word_length': 4.77924944812362, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6852281', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1018, 'n_words': 192}