Created
February 8, 2017 07:57
-
-
Save tina1998612/b00dcd951b47cb74e89d55efe9d8466e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* | |
* main.cpp | |
* | |
* Author: Peter | |
* Copyright (c) 2014-2015 HKUST SmartCar Team | |
* Refer to LICENSE for details | |
*/ | |
#include <cassert> | |
#include <cstring> | |
#include <libbase/k60/mcg.h> | |
#include <libsc/system.h> | |
#include <libsc/st7735r.h> | |
#include <libsc/k60/ov7725.h> | |
#include <libsc/futaba_s3010.h> | |
#include <libsc/alternate_motor.h> | |
#include <libsc/k60/jy_mcu_bt_106.h> | |
namespace libbase | |
{ | |
namespace k60 | |
{ | |
Mcg::Config Mcg::GetMcgConfig() | |
{ | |
Mcg::Config config; | |
config.external_oscillator_khz = 50000; | |
config.core_clock_khz = 150000; | |
return config; | |
} | |
} | |
} | |
using namespace libsc; | |
using namespace libbase::k60; | |
using namespace libsc::k60; | |
int main(void) | |
{ | |
System::Init(); | |
Ov7725::Config C; //camera init; | |
C.id = 0; | |
C.w = 80; | |
C.h = 60; | |
Ov7725 cam(C); | |
St7735r::Config s; //screen init; | |
s.is_revert = false; | |
s.is_bgr = false; | |
s.fps = 100; | |
St7735r screen(s); | |
Timer::TimerInt t=0; | |
JyMcuBt106::Config bluetoothConfig; | |
bluetoothConfig.id = 0; | |
bluetoothConfig.baud_rate = libbase::k60::Uart::Config::BaudRate::k115200; | |
JyMcuBt106 bluetooth(bluetoothConfig); | |
cam.Start(); | |
while (true){ | |
while(t!=System::Time()){ | |
t = System::Time(); | |
if(t % 100 == 0){ | |
const Byte* camPtr; | |
const Byte tempInt = 170; | |
const Byte* temp = &tempInt; | |
camPtr = cam.LockBuffer(); | |
//for tft | |
screen.SetRegion(Lcd::Rect(0,0,80,60)); | |
screen.FillBits(St7735r::kBlack,St7735r::kWhite,camPtr,8*cam.GetBufferSize()); | |
//for bluetooth | |
bluetooth.SendBuffer(temp,1); | |
bluetooth.SendBuffer(camPtr, cam.GetBufferSize()); | |
cam.UnlockBuffer(); | |
} | |
} | |
} | |
cam.Stop(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment